From 8394eb0da6d415d37d711da9b6d3e18bf7eb99d9 Mon Sep 17 00:00:00 2001 From: niklas Date: Fri, 15 Mar 1996 22:17:26 +0000 Subject: [PATCH] Import of GNU libg++ 2.7.1 port (prepared by Erik Theisen) --- gnu/lib/libg++/COPYING.LIB | 481 ++ gnu/lib/libg++/Makefile.in | 1259 +++ gnu/lib/libg++/README | 47 + gnu/lib/libg++/cfg-ml-com.in | 419 + gnu/lib/libg++/cfg-ml-pos.in | 111 + gnu/lib/libg++/config.guess | 565 ++ gnu/lib/libg++/config.sub | 1091 +++ gnu/lib/libg++/config/ChangeLog | 198 + gnu/lib/libg++/config/mh-a68bsd | 12 + gnu/lib/libg++/config/mh-aix386 | 1 + gnu/lib/libg++/config/mh-apollo68 | 3 + gnu/lib/libg++/config/mh-cxux | 15 + gnu/lib/libg++/config/mh-decstation | 5 + gnu/lib/libg++/config/mh-delta88 | 4 + gnu/lib/libg++/config/mh-dgux | 4 + gnu/lib/libg++/config/mh-go32 | 27 + gnu/lib/libg++/config/mh-hp300 | 13 + gnu/lib/libg++/config/mh-hpux | 4 + gnu/lib/libg++/config/mh-hpux8 | 4 + gnu/lib/libg++/config/mh-i386win32 | 29 + gnu/lib/libg++/config/mh-irix4 | 8 + gnu/lib/libg++/config/mh-irix5 | 3 + gnu/lib/libg++/config/mh-linux | 2 + gnu/lib/libg++/config/mh-lynxos | 2 + gnu/lib/libg++/config/mh-lynxrs6k | 8 + gnu/lib/libg++/config/mh-ncr3000 | 17 + gnu/lib/libg++/config/mh-ncrsvr43 | 9 + gnu/lib/libg++/config/mh-papic | 1 + gnu/lib/libg++/config/mh-riscos | 15 + gnu/lib/libg++/config/mh-sco | 10 + gnu/lib/libg++/config/mh-solaris | 7 + gnu/lib/libg++/config/mh-sparcpic | 1 + gnu/lib/libg++/config/mh-sun3 | 3 + gnu/lib/libg++/config/mh-sysv | 3 + gnu/lib/libg++/config/mh-sysv4 | 11 + gnu/lib/libg++/config/mh-vaxult2 | 2 + gnu/lib/libg++/config/mh-x86pic | 1 + gnu/lib/libg++/config/mpw-mh-mpw | 138 + gnu/lib/libg++/config/mt-netware | 1 + gnu/lib/libg++/config/mt-papic | 1 + gnu/lib/libg++/config/mt-sparcpic | 1 + gnu/lib/libg++/config/mt-v810 | 9 + gnu/lib/libg++/config/mt-x86pic | 1 + gnu/lib/libg++/configure | 1217 +++ gnu/lib/libg++/configure.in | 655 ++ gnu/lib/libg++/etc/Makefile.in | 100 + gnu/lib/libg++/etc/cfg-paper.info | 659 ++ gnu/lib/libg++/etc/cfg-paper.texi | 717 ++ gnu/lib/libg++/etc/configure.in | 17 + gnu/lib/libg++/etc/configure.info | 64 + gnu/lib/libg++/etc/configure.info-1 | 1174 +++ gnu/lib/libg++/etc/configure.info-2 | 572 ++ gnu/lib/libg++/etc/configure.man | 166 + gnu/lib/libg++/etc/configure.texi | 1830 +++++ gnu/lib/libg++/etc/make-stds.texi | 528 ++ gnu/lib/libg++/etc/standards.info | 59 + gnu/lib/libg++/etc/standards.info-1 | 1225 +++ gnu/lib/libg++/etc/standards.info-2 | 1462 ++++ gnu/lib/libg++/etc/standards.texi | 2295 ++++++ gnu/lib/libg++/include/COPYING | 339 + gnu/lib/libg++/include/ChangeLog | 921 +++ gnu/lib/libg++/include/ansidecl.h | 141 + gnu/lib/libg++/include/demangle.h | 107 + gnu/lib/libg++/include/floatformat.h | 88 + gnu/lib/libg++/include/getopt.h | 129 + gnu/lib/libg++/include/libiberty.h | 129 + gnu/lib/libg++/include/obstack.h | 513 ++ gnu/lib/libg++/install.sh | 236 + gnu/lib/libg++/libg++/ChangeLog | 2189 +++++ gnu/lib/libg++/libg++/Makefile.in | 246 + gnu/lib/libg++/libg++/NEWS | 560 ++ gnu/lib/libg++/libg++/README | 248 + gnu/lib/libg++/libg++/README.SHLIB | 52 + gnu/lib/libg++/libg++/TODO | 13 + gnu/lib/libg++/libg++/config.shared | 7 + gnu/lib/libg++/libg++/config/aix.ml | 7 + gnu/lib/libg++/libg++/config/dec-osf.ml | 2 + gnu/lib/libg++/libg++/config/elf.ml | 3 + gnu/lib/libg++/libg++/config/elfshlibm.ml | 3 + gnu/lib/libg++/libg++/config/hpux.ml | 4 + gnu/lib/libg++/libg++/config/irix5.ml | 2 + gnu/lib/libg++/libg++/config/linux.ml | 8 + gnu/lib/libg++/libg++/config/linux.mt | 12 + gnu/lib/libg++/libg++/config/sol2shm.ml | 3 + gnu/lib/libg++/libg++/config/solaris2.mt | 1 + gnu/lib/libg++/libg++/config/sunos4.ml | 4 + gnu/lib/libg++/libg++/configure.in | 170 + .../libg++/etc/ADT-examples/Makefile.in | 47 + .../libg++/libg++/etc/ADT-examples/Patmain.cc | 53 + .../libg++/etc/ADT-examples/Patricia.cc | 202 + .../libg++/libg++/etc/ADT-examples/Patricia.h | 67 + .../libg++/etc/ADT-examples/configure.in | 26 + gnu/lib/libg++/libg++/etc/ADT-examples/depend | 39 + .../libg++/etc/ADT-examples/genPatkey.cc | 31 + .../libg++/etc/ADT-examples/generic-q.cc | 103 + .../libg++/libg++/etc/ADT-examples/keyhash.cc | 165 + gnu/lib/libg++/libg++/etc/ADT-examples/kmp.cc | 310 + .../libg++/libg++/etc/ADT-examples/search.cc | 220 + .../libg++/libg++/etc/ADT-examples/tsort.cc | 300 + .../libg++/etc/ADT-examples/tsortinp.cc | 15 + gnu/lib/libg++/libg++/etc/ChangeLog | 176 + gnu/lib/libg++/libg++/etc/HINTS | 668 ++ gnu/lib/libg++/libg++/etc/Makefile.in | 26 + .../libg++/libg++/etc/PlotFile3D/Makefile.in | 15 + .../libg++/etc/PlotFile3D/PlotFile3D.cc | 501 ++ .../libg++/libg++/etc/PlotFile3D/PlotFile3D.h | 223 + gnu/lib/libg++/libg++/etc/PlotFile3D/README | 117 + gnu/lib/libg++/libg++/etc/PlotFile3D/Vec3D.h | 197 + .../libg++/libg++/etc/PlotFile3D/configure.in | 26 + gnu/lib/libg++/libg++/etc/PlotFile3D/depend | 21 + .../libg++/etc/PlotFile3D/tPlotFile3D.cc | 14 + .../libg++/libg++/etc/benchmarks/ChangeLog | 33 + gnu/lib/libg++/libg++/etc/benchmarks/Char.h | 403 + gnu/lib/libg++/libg++/etc/benchmarks/Int.h | 401 + .../libg++/libg++/etc/benchmarks/Makefile.in | 75 + .../libg++/libg++/etc/benchmarks/configure.in | 26 + .../libg++/libg++/etc/benchmarks/dhrystone.cc | 701 ++ gnu/lib/libg++/libg++/etc/configure.in | 24 + gnu/lib/libg++/libg++/etc/fib/Makefile.in | 32 + gnu/lib/libg++/libg++/etc/fib/configure.in | 26 + gnu/lib/libg++/libg++/etc/fib/fib.cc | 615 ++ gnu/lib/libg++/libg++/etc/graph/ChangeLog | 133 + gnu/lib/libg++/libg++/etc/graph/Makefile.in | 70 + gnu/lib/libg++/libg++/etc/graph/configure.in | 27 + gnu/lib/libg++/libg++/etc/graph/depend | 38 + gnu/lib/libg++/libg++/etc/graph/eGetOpt.cc | 43 + gnu/lib/libg++/libg++/etc/graph/eGetOpt.h | 40 + gnu/lib/libg++/libg++/etc/graph/ePlotFile.cc | 13 + gnu/lib/libg++/libg++/etc/graph/ePlotFile.h | 40 + gnu/lib/libg++/libg++/etc/graph/graph.cc | 697 ++ gnu/lib/libg++/libg++/etc/graph/graph.tex | 401 + gnu/lib/libg++/libg++/etc/graph/pdefs.h | 9 + gnu/lib/libg++/libg++/etc/graph/read_data.cc | 114 + gnu/lib/libg++/libg++/etc/graph/read_data.h | 27 + gnu/lib/libg++/libg++/etc/graph/test.dat | 99 + gnu/lib/libg++/libg++/etc/graph/test2.dat | 5 + .../libg++/libg++/etc/graph/tick_intrvl.cc | 39 + gnu/lib/libg++/libg++/etc/graph/tick_intrvl.h | 12 + gnu/lib/libg++/libg++/etc/lf/ChangeLog | 59 + gnu/lib/libg++/libg++/etc/lf/Dirent.cc | 107 + gnu/lib/libg++/libg++/etc/lf/Dirent.h | 93 + gnu/lib/libg++/libg++/etc/lf/Makefile.in | 29 + gnu/lib/libg++/libg++/etc/lf/configure.in | 26 + gnu/lib/libg++/libg++/etc/lf/depend | 28 + gnu/lib/libg++/libg++/etc/lf/directory.cc | 97 + gnu/lib/libg++/libg++/etc/lf/directory.h | 33 + gnu/lib/libg++/libg++/etc/lf/entry.cc | 94 + gnu/lib/libg++/libg++/etc/lf/entry.h | 81 + gnu/lib/libg++/libg++/etc/lf/lf.cc | 23 + gnu/lib/libg++/libg++/etc/lf/option.cc | 65 + gnu/lib/libg++/libg++/etc/lf/option.h | 35 + gnu/lib/libg++/libg++/etc/lf/screen.cc | 61 + gnu/lib/libg++/libg++/etc/lf/screen.h | 37 + gnu/lib/libg++/libg++/etc/lf/sort.cc | 181 + gnu/lib/libg++/libg++/etc/trie-gen/ChangeLog | 132 + .../libg++/libg++/etc/trie-gen/Makefile.in | 56 + gnu/lib/libg++/libg++/etc/trie-gen/compact.cc | 405 + gnu/lib/libg++/libg++/etc/trie-gen/compact.h | 78 + .../libg++/libg++/etc/trie-gen/configure.in | 26 + gnu/lib/libg++/libg++/etc/trie-gen/depend | 25 + gnu/lib/libg++/libg++/etc/trie-gen/main.cc | 39 + gnu/lib/libg++/libg++/etc/trie-gen/options.cc | 208 + gnu/lib/libg++/libg++/etc/trie-gen/options.h | 93 + gnu/lib/libg++/libg++/etc/trie-gen/renew.h | 24 + gnu/lib/libg++/libg++/etc/trie-gen/test.cc | 28 + gnu/lib/libg++/libg++/etc/trie-gen/trie-gen.1 | 113 + gnu/lib/libg++/libg++/etc/trie-gen/trie.cc | 200 + gnu/lib/libg++/libg++/etc/trie-gen/trie.h | 49 + gnu/lib/libg++/libg++/etc/trie-gen/version.cc | 22 + gnu/lib/libg++/libg++/g++FAQ.texi | 1781 ++++ gnu/lib/libg++/libg++/g++FAQ.txt | 1391 ++++ gnu/lib/libg++/libg++/genclass/ChangeLog | 27 + gnu/lib/libg++/libg++/genclass/Makefile.in | 23 + gnu/lib/libg++/libg++/genclass/configure.in | 26 + gnu/lib/libg++/libg++/genclass/expected.out | 1027 +++ gnu/lib/libg++/libg++/genclass/genclass.sh | 452 ++ gnu/lib/libg++/libg++/genclass/gentest.sh | 174 + gnu/lib/libg++/libg++/gperf/COPYING | 249 + gnu/lib/libg++/libg++/gperf/ChangeLog | 1213 +++ gnu/lib/libg++/libg++/gperf/Makefile.in | 43 + gnu/lib/libg++/libg++/gperf/README | 24 + gnu/lib/libg++/libg++/gperf/configure.in | 27 + gnu/lib/libg++/libg++/gperf/gperf.1 | 23 + gnu/lib/libg++/libg++/gperf/gperf.info | 1127 +++ gnu/lib/libg++/libg++/gperf/gperf.texi | 1184 +++ gnu/lib/libg++/libg++/gperf/src/Makefile.in | 35 + gnu/lib/libg++/libg++/gperf/src/bool-array.cc | 99 + gnu/lib/libg++/libg++/gperf/src/bool-array.h | 114 + gnu/lib/libg++/libg++/gperf/src/configure.in | 24 + gnu/lib/libg++/libg++/gperf/src/depend | 76 + gnu/lib/libg++/libg++/gperf/src/gen-perf.cc | 358 + gnu/lib/libg++/libg++/gperf/src/gen-perf.h | 50 + gnu/lib/libg++/libg++/gperf/src/hash-table.cc | 86 + gnu/lib/libg++/libg++/gperf/src/hash-table.h | 40 + gnu/lib/libg++/libg++/gperf/src/iterator.cc | 88 + gnu/lib/libg++/libg++/gperf/src/iterator.h | 51 + gnu/lib/libg++/libg++/gperf/src/key-list.cc | 1228 +++ gnu/lib/libg++/libg++/gperf/src/key-list.h | 87 + gnu/lib/libg++/libg++/gperf/src/list-node.cc | 99 + gnu/lib/libg++/libg++/gperf/src/list-node.h | 46 + gnu/lib/libg++/libg++/gperf/src/main.cc | 85 + gnu/lib/libg++/libg++/gperf/src/new.cc | 81 + gnu/lib/libg++/libg++/gperf/src/options.cc | 643 ++ gnu/lib/libg++/libg++/gperf/src/options.h | 261 + gnu/lib/libg++/libg++/gperf/src/read-line.cc | 98 + gnu/lib/libg++/libg++/gperf/src/read-line.h | 68 + gnu/lib/libg++/libg++/gperf/src/std-err.cc | 86 + gnu/lib/libg++/libg++/gperf/src/std-err.h | 37 + gnu/lib/libg++/libg++/gperf/src/trace.h | 20 + gnu/lib/libg++/libg++/gperf/src/vectors.h | 38 + gnu/lib/libg++/libg++/gperf/src/version.cc | 23 + gnu/lib/libg++/libg++/gperf/tests/Makefile.in | 72 + .../libg++/libg++/gperf/tests/ada-pred.exp | 54 + gnu/lib/libg++/libg++/gperf/tests/ada-res.exp | 63 + gnu/lib/libg++/libg++/gperf/tests/ada.gperf | 63 + .../libg++/libg++/gperf/tests/adadefs.gperf | 54 + gnu/lib/libg++/libg++/gperf/tests/c++.gperf | 47 + .../libg++/libg++/gperf/tests/c-parse.gperf | 56 + gnu/lib/libg++/libg++/gperf/tests/c.exp | 32 + gnu/lib/libg++/libg++/gperf/tests/c.gperf | 32 + .../libg++/libg++/gperf/tests/configure.in | 26 + gnu/lib/libg++/libg++/gperf/tests/gpc.gperf | 48 + gnu/lib/libg++/libg++/gperf/tests/gplus.gperf | 76 + gnu/lib/libg++/libg++/gperf/tests/irc.gperf | 63 + .../libg++/libg++/gperf/tests/makeinfo.gperf | 116 + gnu/lib/libg++/libg++/gperf/tests/modula.exp | 106 + .../libg++/libg++/gperf/tests/modula2.gperf | 40 + .../libg++/libg++/gperf/tests/modula3.gperf | 106 + gnu/lib/libg++/libg++/gperf/tests/pascal.exp | 36 + .../libg++/libg++/gperf/tests/pascal.gperf | 36 + gnu/lib/libg++/libg++/gperf/tests/test-1.exp | 140 + gnu/lib/libg++/libg++/gperf/tests/test-2.exp | 183 + gnu/lib/libg++/libg++/gperf/tests/test-3.exp | 169 + gnu/lib/libg++/libg++/gperf/tests/test-4.exp | 138 + gnu/lib/libg++/libg++/gperf/tests/test-5.exp | 111 + gnu/lib/libg++/libg++/gperf/tests/test-6.exp | 74 + gnu/lib/libg++/libg++/gperf/tests/test-7.exp | 32 + gnu/lib/libg++/libg++/gperf/tests/test.c | 26 + gnu/lib/libg++/libg++/libg++.info | 82 + gnu/lib/libg++/libg++/libg++.info-1 | 822 ++ gnu/lib/libg++/libg++/libg++.info-2 | 1160 +++ gnu/lib/libg++/libg++/libg++.info-3 | 1397 ++++ gnu/lib/libg++/libg++/libg++.info-4 | 1578 ++++ gnu/lib/libg++/libg++/libg++.info-5 | 102 + gnu/lib/libg++/libg++/libg++.texi | 4818 +++++++++++ gnu/lib/libg++/libg++/no-stream/.cvsignore | 2 + gnu/lib/libg++/libg++/no-stream/Makefile.in | 24 + gnu/lib/libg++/libg++/no-stream/configure.in | 25 + gnu/lib/libg++/libg++/old-stream/.cvsignore | 2 + gnu/lib/libg++/libg++/old-stream/ChangeLog | 18 + gnu/lib/libg++/libg++/old-stream/File.cc | 580 ++ gnu/lib/libg++/libg++/old-stream/File.h | 316 + gnu/lib/libg++/libg++/old-stream/Filebuf.cc | 326 + gnu/lib/libg++/libg++/old-stream/Filebuf.h | 62 + gnu/lib/libg++/libg++/old-stream/Fmodes.h | 33 + gnu/lib/libg++/libg++/old-stream/Makefile.in | 33 + gnu/lib/libg++/libg++/old-stream/PlotFile.cc | 181 + gnu/lib/libg++/libg++/old-stream/PlotFile.h | 149 + gnu/lib/libg++/libg++/old-stream/SFile.cc | 48 + gnu/lib/libg++/libg++/old-stream/SFile.h | 82 + gnu/lib/libg++/libg++/old-stream/configure.in | 25 + gnu/lib/libg++/libg++/old-stream/depend | 50 + gnu/lib/libg++/libg++/old-stream/filebuf.cc | 137 + gnu/lib/libg++/libg++/old-stream/filebuf.h | 61 + gnu/lib/libg++/libg++/old-stream/form.cc | 56 + gnu/lib/libg++/libg++/old-stream/istream.cc | 503 ++ gnu/lib/libg++/libg++/old-stream/istream.h | 254 + gnu/lib/libg++/libg++/old-stream/itoa.cc | 251 + gnu/lib/libg++/libg++/old-stream/ostream.cc | 219 + gnu/lib/libg++/libg++/old-stream/ostream.h | 250 + gnu/lib/libg++/libg++/old-stream/stream.h | 12 + gnu/lib/libg++/libg++/old-stream/streambuf.cc | 133 + gnu/lib/libg++/libg++/old-stream/streambuf.h | 162 + gnu/lib/libg++/libg++/proto-kit/Makefile | 379 + gnu/lib/libg++/libg++/proto-kit/Makefile.new | 438 + .../libg++/proto-kit/file_types.hierarchy | 7 + .../libg++/proto-kit/file_types.includes.h | 15 + .../libg++/proto-kit/file_types.operation.h | 17 + .../libg++/libg++/proto-kit/file_types.type.h | 30 + .../libg++/libg++/proto-kit/genclass.extnsn | 112 + gnu/lib/libg++/libg++/proto-kit/hierarchy | 139 + .../libg++/libg++/proto-kit/make-defs-file | 16 + .../libg++/proto-kit/make-source-dependencies | 45 + gnu/lib/libg++/libg++/proto-kit/make-types | 50 + gnu/lib/libg++/libg++/proto-kit/prepend | 29 + .../libg++/libg++/proto-kit/prepend-header | 29 + gnu/lib/libg++/libg++/proto-kit/prototype | 176 + .../libg++/proto-kit/prototype.dependencies | 107 + gnu/lib/libg++/libg++/src/.cvsignore | 3 + gnu/lib/libg++/libg++/src/ACG.cc | 292 + gnu/lib/libg++/libg++/src/ACG.h | 68 + gnu/lib/libg++/libg++/src/AllocRing.cc | 110 + gnu/lib/libg++/libg++/src/AllocRing.h | 62 + gnu/lib/libg++/libg++/src/Binomial.cc | 34 + gnu/lib/libg++/libg++/src/Binomial.h | 55 + gnu/lib/libg++/libg++/src/BitSet.cc | 1101 +++ gnu/lib/libg++/libg++/src/BitSet.h | 370 + gnu/lib/libg++/libg++/src/BitString.cc | 1608 ++++ gnu/lib/libg++/libg++/src/BitString.h | 763 ++ gnu/lib/libg++/libg++/src/ChangeLog | 1127 +++ gnu/lib/libg++/libg++/src/Complex.h | 10 + gnu/lib/libg++/libg++/src/CursesW.cc | 257 + gnu/lib/libg++/libg++/src/CursesW.h | 603 ++ gnu/lib/libg++/libg++/src/DLList.cc | 327 + gnu/lib/libg++/libg++/src/DLList.h | 139 + gnu/lib/libg++/libg++/src/DiscUnif.cc | 29 + gnu/lib/libg++/libg++/src/DiscUnif.h | 72 + gnu/lib/libg++/libg++/src/Erlang.cc | 32 + gnu/lib/libg++/libg++/src/Erlang.h | 68 + gnu/lib/libg++/libg++/src/Fix.cc | 670 ++ gnu/lib/libg++/libg++/src/Fix.h | 523 ++ gnu/lib/libg++/libg++/src/Fix16.cc | 238 + gnu/lib/libg++/libg++/src/Fix16.h | 648 ++ gnu/lib/libg++/libg++/src/Fix24.cc | 329 + gnu/lib/libg++/libg++/src/Fix24.h | 597 ++ gnu/lib/libg++/libg++/src/Geom.cc | 30 + gnu/lib/libg++/libg++/src/Geom.h | 52 + gnu/lib/libg++/libg++/src/GetOpt.cc | 253 + gnu/lib/libg++/libg++/src/GetOpt.h | 129 + gnu/lib/libg++/libg++/src/HypGeom.cc | 30 + gnu/lib/libg++/libg++/src/HypGeom.h | 70 + gnu/lib/libg++/libg++/src/Incremental.h | 12 + gnu/lib/libg++/libg++/src/Intdouble.cc | 142 + gnu/lib/libg++/libg++/src/Integer.cc | 2282 ++++++ gnu/lib/libg++/libg++/src/Integer.h | 1121 +++ gnu/lib/libg++/libg++/src/Integer.hP | 30 + gnu/lib/libg++/libg++/src/LogNorm.cc | 36 + gnu/lib/libg++/libg++/src/LogNorm.h | 78 + gnu/lib/libg++/libg++/src/MLCG.cc | 103 + gnu/lib/libg++/libg++/src/MLCG.h | 87 + gnu/lib/libg++/libg++/src/Makefile.in | 75 + gnu/lib/libg++/libg++/src/NegExp.cc | 28 + gnu/lib/libg++/libg++/src/NegExp.h | 55 + gnu/lib/libg++/libg++/src/Normal.cc | 60 + gnu/lib/libg++/libg++/src/Normal.h | 66 + gnu/lib/libg++/libg++/src/Obstack.cc | 127 + gnu/lib/libg++/libg++/src/Obstack.h | 218 + gnu/lib/libg++/libg++/src/Pix.h | 5 + gnu/lib/libg++/libg++/src/Poisson.cc | 36 + gnu/lib/libg++/libg++/src/Poisson.h | 51 + gnu/lib/libg++/libg++/src/RNG.cc | 131 + gnu/lib/libg++/libg++/src/RNG.h | 58 + gnu/lib/libg++/libg++/src/Random.cc | 4 + gnu/lib/libg++/libg++/src/Random.h | 54 + gnu/lib/libg++/libg++/src/Rational.cc | 416 + gnu/lib/libg++/libg++/src/Rational.h | 290 + gnu/lib/libg++/libg++/src/Regex.cc | 140 + gnu/lib/libg++/libg++/src/Regex.h | 78 + gnu/lib/libg++/libg++/src/RndInt.cc | 4 + gnu/lib/libg++/libg++/src/RndInt.h | 176 + gnu/lib/libg++/libg++/src/SLList.cc | 247 + gnu/lib/libg++/libg++/src/SLList.h | 129 + gnu/lib/libg++/libg++/src/Sample.cc | 241 + gnu/lib/libg++/libg++/src/SmplHist.cc | 112 + gnu/lib/libg++/libg++/src/SmplHist.h | 72 + gnu/lib/libg++/libg++/src/SmplStat.cc | 160 + gnu/lib/libg++/libg++/src/SmplStat.h | 69 + gnu/lib/libg++/libg++/src/String.cc | 1307 +++ gnu/lib/libg++/libg++/src/String.h | 1284 +++ gnu/lib/libg++/libg++/src/Uniform.cc | 27 + gnu/lib/libg++/libg++/src/Uniform.h | 71 + gnu/lib/libg++/libg++/src/Weibull.cc | 33 + gnu/lib/libg++/libg++/src/Weibull.h | 74 + gnu/lib/libg++/libg++/src/bitand.c | 41 + gnu/lib/libg++/libg++/src/bitany.c | 38 + gnu/lib/libg++/libg++/src/bitblt.c | 97 + gnu/lib/libg++/libg++/src/bitclear.c | 37 + gnu/lib/libg++/libg++/src/bitcopy.c | 41 + gnu/lib/libg++/libg++/src/bitcount.c | 64 + gnu/lib/libg++/libg++/src/bitdo1.h | 32 + gnu/lib/libg++/libg++/src/bitdo2.h | 184 + gnu/lib/libg++/libg++/src/bitinvert.c | 37 + gnu/lib/libg++/libg++/src/bitlcomp.c | 81 + gnu/lib/libg++/libg++/src/bitprims.h | 124 + gnu/lib/libg++/libg++/src/bitset1.c | 37 + gnu/lib/libg++/libg++/src/bitxor.c | 41 + gnu/lib/libg++/libg++/src/bool.h | 24 + gnu/lib/libg++/libg++/src/builtin.cc | 4 + gnu/lib/libg++/libg++/src/builtin.h | 125 + gnu/lib/libg++/libg++/src/chr.cc | 37 + gnu/lib/libg++/libg++/src/compare.cc | 4 + gnu/lib/libg++/libg++/src/compare.h | 91 + gnu/lib/libg++/libg++/src/configure.in | 34 + gnu/lib/libg++/libg++/src/depend | 889 ++ gnu/lib/libg++/libg++/src/dtoa.cc | 335 + gnu/lib/libg++/libg++/src/error.cc | 49 + gnu/lib/libg++/libg++/src/fmtq.cc | 29 + gnu/lib/libg++/libg++/src/gcd.cc | 52 + gnu/lib/libg++/libg++/src/gen/AVLMap.ccP | 614 ++ gnu/lib/libg++/libg++/src/gen/AVLMap.hP | 141 + gnu/lib/libg++/libg++/src/gen/AVLSet.ccP | 892 ++ gnu/lib/libg++/libg++/src/gen/AVLSet.hP | 152 + gnu/lib/libg++/libg++/src/gen/AVec.ccP | 397 + gnu/lib/libg++/libg++/src/gen/AVec.hP | 118 + gnu/lib/libg++/libg++/src/gen/BSTSet.ccP | 377 + gnu/lib/libg++/libg++/src/gen/BSTSet.hP | 152 + gnu/lib/libg++/libg++/src/gen/Bag.ccP | 74 + gnu/lib/libg++/libg++/src/gen/Bag.hP | 79 + gnu/lib/libg++/libg++/src/gen/CHBag.ccP | 210 + gnu/lib/libg++/libg++/src/gen/CHBag.hP | 76 + gnu/lib/libg++/libg++/src/gen/CHMap.ccP | 168 + gnu/lib/libg++/libg++/src/gen/CHMap.hP | 104 + gnu/lib/libg++/libg++/src/gen/CHNode.ccP | 21 + gnu/lib/libg++/libg++/src/gen/CHNode.hP | 43 + gnu/lib/libg++/libg++/src/gen/CHSet.ccP | 273 + gnu/lib/libg++/libg++/src/gen/CHSet.hP | 84 + gnu/lib/libg++/libg++/src/gen/DLDeque.ccP | 4 + gnu/lib/libg++/libg++/src/gen/DLDeque.hP | 130 + gnu/lib/libg++/libg++/src/gen/DLList.ccP | 339 + gnu/lib/libg++/libg++/src/gen/DLList.hP | 157 + gnu/lib/libg++/libg++/src/gen/Deque.ccP | 11 + gnu/lib/libg++/libg++/src/gen/Deque.hP | 57 + gnu/lib/libg++/libg++/src/gen/FPQueue.ccP | 4 + gnu/lib/libg++/libg++/src/gen/FPQueue.hP | 112 + gnu/lib/libg++/libg++/src/gen/FPStack.ccP | 4 + gnu/lib/libg++/libg++/src/gen/FPStack.hP | 114 + gnu/lib/libg++/libg++/src/gen/FPlex.ccP | 167 + gnu/lib/libg++/libg++/src/gen/FPlex.hP | 253 + gnu/lib/libg++/libg++/src/gen/List.ccP | 972 +++ gnu/lib/libg++/libg++/src/gen/List.hP | 279 + gnu/lib/libg++/libg++/src/gen/MPlex.ccP | 848 ++ gnu/lib/libg++/libg++/src/gen/MPlex.hP | 414 + gnu/lib/libg++/libg++/src/gen/Map.ccP | 59 + gnu/lib/libg++/libg++/src/gen/Map.hP | 87 + gnu/lib/libg++/libg++/src/gen/OSLBag.ccP | 196 + gnu/lib/libg++/libg++/src/gen/OSLBag.hP | 91 + gnu/lib/libg++/libg++/src/gen/OSLSet.ccP | 321 + gnu/lib/libg++/libg++/src/gen/OSLSet.hP | 101 + gnu/lib/libg++/libg++/src/gen/OXPBag.ccP | 221 + gnu/lib/libg++/libg++/src/gen/OXPBag.hP | 73 + gnu/lib/libg++/libg++/src/gen/OXPSet.ccP | 280 + gnu/lib/libg++/libg++/src/gen/OXPSet.hP | 102 + gnu/lib/libg++/libg++/src/gen/PHPQ.ccP | 339 + gnu/lib/libg++/libg++/src/gen/PHPQ.hP | 108 + gnu/lib/libg++/libg++/src/gen/PQ.ccP | 63 + gnu/lib/libg++/libg++/src/gen/PQ.hP | 78 + gnu/lib/libg++/libg++/src/gen/PSList.hP | 32 + gnu/lib/libg++/libg++/src/gen/PVec.hP | 79 + gnu/lib/libg++/libg++/src/gen/Plex.ccP | 222 + gnu/lib/libg++/libg++/src/gen/Plex.hP | 494 ++ gnu/lib/libg++/libg++/src/gen/Queue.ccP | 14 + gnu/lib/libg++/libg++/src/gen/Queue.hP | 51 + gnu/lib/libg++/libg++/src/gen/RAVLMap.ccP | 690 ++ gnu/lib/libg++/libg++/src/gen/RAVLMap.hP | 147 + gnu/lib/libg++/libg++/src/gen/RPlex.ccP | 477 ++ gnu/lib/libg++/libg++/src/gen/RPlex.hP | 257 + gnu/lib/libg++/libg++/src/gen/SLBag.ccP | 105 + gnu/lib/libg++/libg++/src/gen/SLBag.hP | 96 + gnu/lib/libg++/libg++/src/gen/SLList.ccP | 292 + gnu/lib/libg++/libg++/src/gen/SLList.hP | 137 + gnu/lib/libg++/libg++/src/gen/SLQueue.ccP | 4 + gnu/lib/libg++/libg++/src/gen/SLQueue.hP | 108 + gnu/lib/libg++/libg++/src/gen/SLSet.ccP | 77 + gnu/lib/libg++/libg++/src/gen/SLSet.hP | 87 + gnu/lib/libg++/libg++/src/gen/SLStack.ccP | 4 + gnu/lib/libg++/libg++/src/gen/SLStack.hP | 109 + gnu/lib/libg++/libg++/src/gen/Set.ccP | 117 + gnu/lib/libg++/libg++/src/gen/Set.hP | 78 + gnu/lib/libg++/libg++/src/gen/SkipBag.ccP | 322 + gnu/lib/libg++/libg++/src/gen/SkipBag.hP | 171 + gnu/lib/libg++/libg++/src/gen/SkipMap.ccP | 307 + gnu/lib/libg++/libg++/src/gen/SkipMap.hP | 176 + gnu/lib/libg++/libg++/src/gen/SkipSet.ccP | 395 + gnu/lib/libg++/libg++/src/gen/SkipSet.hP | 187 + gnu/lib/libg++/libg++/src/gen/SplayBag.ccP | 445 + gnu/lib/libg++/libg++/src/gen/SplayBag.hP | 126 + gnu/lib/libg++/libg++/src/gen/SplayMap.ccP | 401 + gnu/lib/libg++/libg++/src/gen/SplayMap.hP | 154 + gnu/lib/libg++/libg++/src/gen/SplayNode.ccP | 21 + gnu/lib/libg++/libg++/src/gen/SplayNode.hP | 44 + gnu/lib/libg++/libg++/src/gen/SplayPQ.ccP | 523 ++ gnu/lib/libg++/libg++/src/gen/SplayPQ.hP | 123 + gnu/lib/libg++/libg++/src/gen/SplaySet.ccP | 499 ++ gnu/lib/libg++/libg++/src/gen/SplaySet.hP | 145 + gnu/lib/libg++/libg++/src/gen/Stack.ccP | 11 + gnu/lib/libg++/libg++/src/gen/Stack.hP | 51 + gnu/lib/libg++/libg++/src/gen/VHBag.ccP | 264 + gnu/lib/libg++/libg++/src/gen/VHBag.hP | 84 + gnu/lib/libg++/libg++/src/gen/VHMap.ccP | 210 + gnu/lib/libg++/libg++/src/gen/VHMap.hP | 84 + gnu/lib/libg++/libg++/src/gen/VHSet.ccP | 263 + gnu/lib/libg++/libg++/src/gen/VHSet.hP | 96 + gnu/lib/libg++/libg++/src/gen/VOHSet.ccP | 305 + gnu/lib/libg++/libg++/src/gen/VOHSet.hP | 88 + gnu/lib/libg++/libg++/src/gen/VQueue.ccP | 83 + gnu/lib/libg++/libg++/src/gen/VQueue.hP | 130 + gnu/lib/libg++/libg++/src/gen/VStack.ccP | 66 + gnu/lib/libg++/libg++/src/gen/VStack.hP | 120 + gnu/lib/libg++/libg++/src/gen/Vec.ccP | 470 ++ gnu/lib/libg++/libg++/src/gen/Vec.hP | 135 + gnu/lib/libg++/libg++/src/gen/XPBag.ccP | 72 + gnu/lib/libg++/libg++/src/gen/XPBag.hP | 98 + gnu/lib/libg++/libg++/src/gen/XPDeque.ccP | 4 + gnu/lib/libg++/libg++/src/gen/XPDeque.hP | 133 + gnu/lib/libg++/libg++/src/gen/XPPQ.ccP | 143 + gnu/lib/libg++/libg++/src/gen/XPPQ.hP | 105 + gnu/lib/libg++/libg++/src/gen/XPQueue.ccP | 4 + gnu/lib/libg++/libg++/src/gen/XPQueue.hP | 114 + gnu/lib/libg++/libg++/src/gen/XPSet.ccP | 63 + gnu/lib/libg++/libg++/src/gen/XPSet.hP | 89 + gnu/lib/libg++/libg++/src/gen/XPStack.ccP | 4 + gnu/lib/libg++/libg++/src/gen/XPStack.hP | 115 + gnu/lib/libg++/libg++/src/gen/XPlex.ccP | 397 + gnu/lib/libg++/libg++/src/gen/XPlex.hP | 238 + gnu/lib/libg++/libg++/src/gen/defs.hP | 57 + gnu/lib/libg++/libg++/src/gen/intSList.hP | 33 + gnu/lib/libg++/libg++/src/gen/intVec.hP | 80 + gnu/lib/libg++/libg++/src/generic.h | 54 + gnu/lib/libg++/libg++/src/getpagesize.h | 27 + gnu/lib/libg++/libg++/src/hash.cc | 56 + gnu/lib/libg++/libg++/src/ioob.cc | 32 + gnu/lib/libg++/libg++/src/lg.cc | 32 + gnu/lib/libg++/libg++/src/libc.h | 1 + gnu/lib/libg++/libg++/src/malloc.c | 1205 +++ gnu/lib/libg++/libg++/src/minmax.cc | 5 + gnu/lib/libg++/libg++/src/minmax.h | 65 + gnu/lib/libg++/libg++/src/osfcn.h | 17 + gnu/lib/libg++/libg++/src/pow.cc | 70 + gnu/lib/libg++/libg++/src/sqrt.cc | 43 + gnu/lib/libg++/libg++/src/std.h | 35 + gnu/lib/libg++/libg++/src/str.cc | 38 + gnu/lib/libg++/libg++/src/strclass.h | 5 + gnu/lib/libg++/libg++/src/swap.h | 3 + gnu/lib/libg++/libg++/src/sysent.h | 2 + gnu/lib/libg++/libg++/src/timer.c | 165 + gnu/lib/libg++/libg++/src/typemacros.h | 8 + gnu/lib/libg++/libg++/test-install/.cvsignore | 2 + gnu/lib/libg++/libg++/test-install/ChangeLog | 74 + gnu/lib/libg++/libg++/test-install/Foo.cc | 89 + gnu/lib/libg++/libg++/test-install/Foo.h | 24 + .../libg++/libg++/test-install/Makefile.in | 170 + gnu/lib/libg++/libg++/test-install/a.cc | 10 + gnu/lib/libg++/libg++/test-install/bf.cc | 18 + gnu/lib/libg++/libg++/test-install/bm.cc | 14 + .../libg++/libg++/test-install/configure.in | 25 + gnu/lib/libg++/libg++/test-install/ex_bar.cc | 123 + .../libg++/libg++/test-install/expected.out | 15 + .../libg++/libg++/test-install/foo_func.cc | 17 + .../libg++/libg++/test-install/foo_main.cc | 40 + gnu/lib/libg++/libg++/tests/.cvsignore | 135 + gnu/lib/libg++/libg++/tests/ChangeLog | 330 + gnu/lib/libg++/libg++/tests/Makefile.in | 22 + gnu/lib/libg++/libg++/tests/Makefile.sh | 178 + gnu/lib/libg++/libg++/tests/configure.in | 27 + gnu/lib/libg++/libg++/tests/depend | 161 + gnu/lib/libg++/libg++/tests/tBag.cc | 540 ++ gnu/lib/libg++/libg++/tests/tBag.exp | 35 + gnu/lib/libg++/libg++/tests/tBag.inp | 0 gnu/lib/libg++/libg++/tests/tBitSet.cc | 220 + gnu/lib/libg++/libg++/tests/tBitSet.exp | 49 + gnu/lib/libg++/libg++/tests/tBitSet.inp | 0 gnu/lib/libg++/libg++/tests/tBitString.cc | 327 + gnu/lib/libg++/libg++/tests/tBitString.exp | 79 + gnu/lib/libg++/libg++/tests/tBitString.inp | 0 gnu/lib/libg++/libg++/tests/tCurses.cc | 80 + gnu/lib/libg++/libg++/tests/tCurses.inp | 2 + gnu/lib/libg++/libg++/tests/tDeque.cc | 168 + gnu/lib/libg++/libg++/tests/tDeque.exp | 6 + gnu/lib/libg++/libg++/tests/tDeque.inp | 0 gnu/lib/libg++/libg++/tests/tFile.cc | 371 + gnu/lib/libg++/libg++/tests/tFile.exp | 49 + gnu/lib/libg++/libg++/tests/tFile.inp | 4 + gnu/lib/libg++/libg++/tests/tFix.cc | 101 + gnu/lib/libg++/libg++/tests/tFix.exp | 70 + gnu/lib/libg++/libg++/tests/tFix.inp | 0 gnu/lib/libg++/libg++/tests/tFix16.cc | 110 + gnu/lib/libg++/libg++/tests/tFix16.exp | 64 + gnu/lib/libg++/libg++/tests/tFix16.inp | 0 gnu/lib/libg++/libg++/tests/tFix24.cc | 113 + gnu/lib/libg++/libg++/tests/tFix24.exp | 61 + gnu/lib/libg++/libg++/tests/tFix24.inp | 0 gnu/lib/libg++/libg++/tests/tGetOpt.cc | 65 + gnu/lib/libg++/libg++/tests/tGetOpt.exp | 11 + gnu/lib/libg++/libg++/tests/tGetOpt.inp | 0 gnu/lib/libg++/libg++/tests/tInteger.cc | 437 + gnu/lib/libg++/libg++/tests/tInteger.exp | 48 + gnu/lib/libg++/libg++/tests/tInteger.inp | 3 + gnu/lib/libg++/libg++/tests/tLList.cc | 236 + gnu/lib/libg++/libg++/tests/tLList.exp | 49 + gnu/lib/libg++/libg++/tests/tLList.inp | 0 gnu/lib/libg++/libg++/tests/tList.cc | 129 + gnu/lib/libg++/libg++/tests/tList.exp | 39 + gnu/lib/libg++/libg++/tests/tList.inp | 0 gnu/lib/libg++/libg++/tests/tMap.cc | 339 + gnu/lib/libg++/libg++/tests/tMap.exp | 25 + gnu/lib/libg++/libg++/tests/tMap.inp | 0 gnu/lib/libg++/libg++/tests/tObstack.cc | 80 + gnu/lib/libg++/libg++/tests/tObstack.exp | 32 + gnu/lib/libg++/libg++/tests/tObstack.inp | 5 + gnu/lib/libg++/libg++/tests/tPQ.cc | 275 + gnu/lib/libg++/libg++/tests/tPQ.exp | 15 + gnu/lib/libg++/libg++/tests/tPQ.inp | 0 gnu/lib/libg++/libg++/tests/tPlex.cc | 719 ++ gnu/lib/libg++/libg++/tests/tPlex.exp | 10 + gnu/lib/libg++/libg++/tests/tPlex.inp | 0 gnu/lib/libg++/libg++/tests/tQueue.cc | 209 + gnu/lib/libg++/libg++/tests/tQueue.exp | 15 + gnu/lib/libg++/libg++/tests/tQueue.inp | 0 gnu/lib/libg++/libg++/tests/tRandom.cc | 103 + gnu/lib/libg++/libg++/tests/tRandom.exp | 85 + gnu/lib/libg++/libg++/tests/tRandom.inp | 0 gnu/lib/libg++/libg++/tests/tRational.cc | 194 + gnu/lib/libg++/libg++/tests/tRational.exp | 41 + gnu/lib/libg++/libg++/tests/tRational.inp | 1 + gnu/lib/libg++/libg++/tests/tSet.cc | 744 ++ gnu/lib/libg++/libg++/tests/tSet.exp | 50 + gnu/lib/libg++/libg++/tests/tSet.inp | 0 gnu/lib/libg++/libg++/tests/tStack.cc | 188 + gnu/lib/libg++/libg++/tests/tStack.exp | 8 + gnu/lib/libg++/libg++/tests/tStack.inp | 0 gnu/lib/libg++/libg++/tests/tString.cc | 416 + gnu/lib/libg++/libg++/tests/tString.exp | 50 + gnu/lib/libg++/libg++/tests/tString.inp | 1 + gnu/lib/libg++/libg++/tests/tVec.cc | 96 + gnu/lib/libg++/libg++/tests/tVec.exp | 33 + gnu/lib/libg++/libg++/tests/tVec.inp | 0 gnu/lib/libg++/libg++/tests/test_h.cc | 102 + gnu/lib/libg++/libg++/tests/tiLList.cc | 271 + gnu/lib/libg++/libg++/tests/tiLList.exp | 54 + gnu/lib/libg++/libg++/utils/.cvsignore | 4 + gnu/lib/libg++/libg++/utils/Makefile.in | 31 + gnu/lib/libg++/libg++/utils/configure.in | 25 + gnu/lib/libg++/libg++/utils/g++dep.sh | 73 + gnu/lib/libg++/libg++/utils/gendepend | 57 + gnu/lib/libg++/libg++/vms/AAAREADME.TXT | 260 + gnu/lib/libg++/libg++/vms/CXLINK.COM | 6 + gnu/lib/libg++/libg++/vms/CXSHARE.COM | 7 + gnu/lib/libg++/libg++/vms/EXPECTED.LIST | 25 + gnu/lib/libg++/libg++/vms/EXPECTED.VMS | 1027 +++ gnu/lib/libg++/libg++/vms/FNDVEC.C | 223 + gnu/lib/libg++/libg++/vms/GENCLASS.COM | 60 + gnu/lib/libg++/libg++/vms/GENCLASS.TPU | 49 + gnu/lib/libg++/libg++/vms/GXX_MAIN_SHR.MAR | 16 + gnu/lib/libg++/libg++/vms/OPTIONS.OPT | 8 + .../libg++/libg++/vms/VMS-BUILD-LIBGXX.COM | 382 + gnu/lib/libg++/libg++/vms/VMS-CURSES.C | 41 + gnu/lib/libg++/libg++/vms/VMS-GCCLIB.MAR | 56 + .../libg++/libg++/vms/VMS-INSTALL-LIBGXX.COM | 326 + gnu/lib/libg++/libg++/vms/VMS-TEST-LIBGXX.COM | 108 + gnu/lib/libg++/libg++/vms/VMS_FIXINCLUDES.TPU | 53 + gnu/lib/libg++/libg++/vms/_G_config.h | 44 + gnu/lib/libg++/libiberty/COPYING.LIB | 481 ++ gnu/lib/libg++/libiberty/ChangeLog | 1695 ++++ gnu/lib/libg++/libiberty/Makefile.in | 315 + gnu/lib/libg++/libiberty/README | 129 + gnu/lib/libg++/libiberty/alloca-botch.h | 5 + gnu/lib/libg++/libiberty/alloca-norm.h | 16 + gnu/lib/libg++/libiberty/alloca.c | 475 ++ gnu/lib/libg++/libiberty/argv.c | 328 + gnu/lib/libg++/libiberty/basename.c | 43 + gnu/lib/libg++/libiberty/bcmp.c | 49 + gnu/lib/libg++/libiberty/bcopy.c | 35 + gnu/lib/libg++/libiberty/bzero.c | 31 + gnu/lib/libg++/libiberty/clock.c | 73 + gnu/lib/libg++/libiberty/concat.c | 167 + gnu/lib/libg++/libiberty/config.table | 73 + gnu/lib/libg++/libiberty/config/mh-a68bsd | 2 + gnu/lib/libg++/libiberty/config/mh-aix | 10 + gnu/lib/libg++/libiberty/config/mh-apollo68 | 2 + gnu/lib/libg++/libiberty/config/mh-cxux7 | 3 + gnu/lib/libg++/libiberty/config/mh-go32 | 4 + gnu/lib/libg++/libiberty/config/mh-hpbsd | 2 + gnu/lib/libg++/libiberty/config/mh-hpux | 1 + gnu/lib/libg++/libiberty/config/mh-i386win32 | 5 + gnu/lib/libg++/libiberty/config/mh-irix4 | 4 + gnu/lib/libg++/libiberty/config/mh-lynxos | 1 + gnu/lib/libg++/libiberty/config/mh-ncr3000 | 19 + gnu/lib/libg++/libiberty/config/mh-riscix | 6 + gnu/lib/libg++/libiberty/config/mh-sysv | 1 + gnu/lib/libg++/libiberty/config/mh-sysv4 | 3 + gnu/lib/libg++/libiberty/config/mt-sunos4 | 2 + gnu/lib/libg++/libiberty/config/mt-vxworks5 | 27 + gnu/lib/libg++/libiberty/configure.bat | 15 + gnu/lib/libg++/libiberty/configure.in | 63 + gnu/lib/libg++/libiberty/copysign.c | 140 + gnu/lib/libg++/libiberty/cplus-dem.c | 3001 +++++++ gnu/lib/libg++/libiberty/dummy.c | 49 + gnu/lib/libg++/libiberty/fdmatch.c | 73 + gnu/lib/libg++/libiberty/floatformat.c | 385 + gnu/lib/libg++/libiberty/functions.def | 65 + gnu/lib/libg++/libiberty/getcwd.c | 52 + gnu/lib/libg++/libiberty/getopt.c | 757 ++ gnu/lib/libg++/libiberty/getopt1.c | 190 + gnu/lib/libg++/libiberty/getpagesize.c | 89 + gnu/lib/libg++/libiberty/getruntime.c | 82 + gnu/lib/libg++/libiberty/hex.c | 33 + gnu/lib/libg++/libiberty/index.c | 11 + gnu/lib/libg++/libiberty/insque.c | 50 + gnu/lib/libg++/libiberty/makefile.dos | 29 + gnu/lib/libg++/libiberty/memchr.c | 60 + gnu/lib/libg++/libiberty/memcmp.c | 38 + gnu/lib/libg++/libiberty/memcpy.c | 28 + gnu/lib/libg++/libiberty/memmove.c | 18 + gnu/lib/libg++/libiberty/memset.c | 19 + gnu/lib/libg++/libiberty/mpw-config.in | 9 + gnu/lib/libg++/libiberty/mpw-make.sed | 49 + gnu/lib/libg++/libiberty/mpw.c | 996 +++ gnu/lib/libg++/libiberty/msdos.c | 15 + gnu/lib/libg++/libiberty/obstack.c | 493 ++ gnu/lib/libg++/libiberty/random.c | 373 + gnu/lib/libg++/libiberty/rename.c | 22 + gnu/lib/libg++/libiberty/rindex.c | 11 + gnu/lib/libg++/libiberty/sigsetmask.c | 30 + gnu/lib/libg++/libiberty/spaces.c | 71 + gnu/lib/libg++/libiberty/strcasecmp.c | 81 + gnu/lib/libg++/libiberty/strchr.c | 34 + gnu/lib/libg++/libiberty/strdup.c | 10 + gnu/lib/libg++/libiberty/strerror.c | 829 ++ gnu/lib/libg++/libiberty/strncasecmp.c | 82 + gnu/lib/libg++/libiberty/strrchr.c | 34 + gnu/lib/libg++/libiberty/strsignal.c | 627 ++ gnu/lib/libg++/libiberty/strstr.c | 51 + gnu/lib/libg++/libiberty/strtod.c | 122 + gnu/lib/libg++/libiberty/strtol.c | 143 + gnu/lib/libg++/libiberty/strtoul.c | 110 + gnu/lib/libg++/libiberty/tmpnam.c | 39 + gnu/lib/libg++/libiberty/vasprintf.c | 165 + gnu/lib/libg++/libiberty/vfork.c | 8 + gnu/lib/libg++/libiberty/vfprintf.c | 13 + gnu/lib/libg++/libiberty/vmsbuild.com | 142 + gnu/lib/libg++/libiberty/vprintf.c | 11 + gnu/lib/libg++/libiberty/vsprintf.c | 55 + gnu/lib/libg++/libiberty/waitpid.c | 11 + gnu/lib/libg++/libiberty/win32.c | 64 + gnu/lib/libg++/libiberty/xatexit.c | 82 + gnu/lib/libg++/libiberty/xexit.c | 36 + gnu/lib/libg++/libiberty/xmalloc.c | 106 + gnu/lib/libg++/libiberty/xstrerror.c | 54 + gnu/lib/libg++/libio/ChangeLog | 1595 ++++ gnu/lib/libg++/libio/Makefile.in | 122 + gnu/lib/libg++/libio/NEWS | 51 + gnu/lib/libg++/libio/PlotFile.cc | 157 + gnu/lib/libg++/libio/PlotFile.h | 89 + gnu/lib/libg++/libio/README | 30 + gnu/lib/libg++/libio/SFile.cc | 82 + gnu/lib/libg++/libio/SFile.h | 55 + gnu/lib/libg++/libio/builtinbuf.cc | 78 + gnu/lib/libg++/libio/builtinbuf.h | 68 + gnu/lib/libg++/libio/cleanup.c | 15 + gnu/lib/libg++/libio/config.shared | 460 ++ gnu/lib/libg++/libio/config/hpux.mt | 3 + gnu/lib/libg++/libio/config/isc.mt | 4 + gnu/lib/libg++/libio/config/linux.mt | 26 + gnu/lib/libg++/libio/config/netware.mt | 16 + gnu/lib/libg++/libio/config/sco4.mt | 3 + gnu/lib/libg++/libio/configure.in | 78 + gnu/lib/libg++/libio/dbz/Makefile.in | 217 + gnu/lib/libg++/libio/dbz/README | 25 + gnu/lib/libg++/libio/dbz/altbytes | 7 + gnu/lib/libg++/libio/dbz/byteflip.c | 37 + gnu/lib/libg++/libio/dbz/case.c | 129 + gnu/lib/libg++/libio/dbz/case.h | 12 + gnu/lib/libg++/libio/dbz/configure.in | 17 + gnu/lib/libg++/libio/dbz/dbz.1 | 221 + gnu/lib/libg++/libio/dbz/dbz.3z | 547 ++ gnu/lib/libg++/libio/dbz/dbz.c | 1766 ++++ gnu/lib/libg++/libio/dbz/dbz.h | 32 + gnu/lib/libg++/libio/dbz/dbzmain.c | 518 ++ gnu/lib/libg++/libio/dbz/fake.c | 143 + gnu/lib/libg++/libio/dbz/firstlast25 | 50 + gnu/lib/libg++/libio/dbz/getmap | 6 + gnu/lib/libg++/libio/dbz/random.c | 31 + gnu/lib/libg++/libio/dbz/revbytes | 7 + gnu/lib/libg++/libio/dbz/stdio.h | 1 + gnu/lib/libg++/libio/depend | 351 + gnu/lib/libg++/libio/editbuf.cc | 717 ++ gnu/lib/libg++/libio/editbuf.h | 185 + gnu/lib/libg++/libio/filebuf.cc | 198 + gnu/lib/libg++/libio/filedoalloc.c | 104 + gnu/lib/libg++/libio/fileops.c | 738 ++ gnu/lib/libg++/libio/floatconv.c | 2349 ++++++ gnu/lib/libg++/libio/floatio.h | 51 + gnu/lib/libg++/libio/fstream.cc | 110 + gnu/lib/libg++/libio/fstream.h | 92 + gnu/lib/libg++/libio/gen-params | 681 ++ gnu/lib/libg++/libio/genops.c | 837 ++ gnu/lib/libg++/libio/indstream.cc | 116 + gnu/lib/libg++/libio/indstream.h | 76 + gnu/lib/libg++/libio/ioassign.cc | 49 + gnu/lib/libg++/libio/ioextend.cc | 132 + gnu/lib/libg++/libio/iofclose.c | 47 + gnu/lib/libg++/libio/iofdopen.c | 121 + gnu/lib/libg++/libio/iofflush.c | 38 + gnu/lib/libg++/libio/iofgetpos.c | 46 + gnu/lib/libg++/libio/iofgets.c | 40 + gnu/lib/libg++/libio/iofopen.c | 49 + gnu/lib/libg++/libio/iofprintf.c | 48 + gnu/lib/libg++/libio/iofputs.c | 37 + gnu/lib/libg++/libio/iofread.c | 38 + gnu/lib/libg++/libio/iofscanf.c | 48 + gnu/lib/libg++/libio/iofsetpos.c | 43 + gnu/lib/libg++/libio/ioftell.c | 45 + gnu/lib/libg++/libio/iofwrite.c | 44 + gnu/lib/libg++/libio/iogetdelim.c | 99 + gnu/lib/libg++/libio/iogetline.c | 74 + gnu/lib/libg++/libio/iogets.c | 47 + gnu/lib/libg++/libio/ioignore.c | 46 + gnu/lib/libg++/libio/iolibio.h | 53 + gnu/lib/libg++/libio/iomanip.cc | 90 + gnu/lib/libg++/libio/iomanip.h | 165 + gnu/lib/libg++/libio/iopadn.c | 65 + gnu/lib/libg++/libio/ioperror.c | 22 + gnu/lib/libg++/libio/iopopen.c | 222 + gnu/lib/libg++/libio/ioprims.c | 72 + gnu/lib/libg++/libio/ioprintf.c | 47 + gnu/lib/libg++/libio/ioputs.c | 38 + gnu/lib/libg++/libio/ioscanf.c | 47 + gnu/lib/libg++/libio/ioseekoff.c | 43 + gnu/lib/libg++/libio/ioseekpos.c | 39 + gnu/lib/libg++/libio/iosetbuffer.c | 36 + gnu/lib/libg++/libio/iosetvbuf.c | 77 + gnu/lib/libg++/libio/iosprintf.c | 47 + gnu/lib/libg++/libio/iosscanf.c | 47 + gnu/lib/libg++/libio/iostdio.h | 110 + gnu/lib/libg++/libio/iostream.cc | 821 ++ gnu/lib/libg++/libio/iostream.h | 248 + gnu/lib/libg++/libio/iostream.info | 73 + gnu/lib/libg++/libio/iostream.info-1 | 1367 ++++ gnu/lib/libg++/libio/iostream.info-2 | 429 + gnu/lib/libg++/libio/iostream.texi | 1971 +++++ gnu/lib/libg++/libio/iostreamP.h | 26 + gnu/lib/libg++/libio/iostrerror.c | 12 + gnu/lib/libg++/libio/ioungetc.c | 35 + gnu/lib/libg++/libio/iovfprintf.c | 881 ++ gnu/lib/libg++/libio/iovfscanf.c | 787 ++ gnu/lib/libg++/libio/iovsprintf.c | 40 + gnu/lib/libg++/libio/iovsscanf.c | 37 + gnu/lib/libg++/libio/isgetline.cc | 139 + gnu/lib/libg++/libio/isgetsb.cc | 59 + gnu/lib/libg++/libio/isscan.cc | 45 + gnu/lib/libg++/libio/istream.h | 25 + gnu/lib/libg++/libio/libio.h | 254 + gnu/lib/libg++/libio/libioP.h | 481 ++ gnu/lib/libg++/libio/osform.cc | 54 + gnu/lib/libg++/libio/ostream.h | 25 + gnu/lib/libg++/libio/outfloat.c | 204 + gnu/lib/libg++/libio/parsestream.cc | 317 + gnu/lib/libg++/libio/parsestream.h | 156 + gnu/lib/libg++/libio/pfstream.cc | 92 + gnu/lib/libg++/libio/pfstream.h | 59 + gnu/lib/libg++/libio/procbuf.cc | 55 + gnu/lib/libg++/libio/procbuf.h | 50 + gnu/lib/libg++/libio/sbform.cc | 40 + gnu/lib/libg++/libio/sbgetline.cc | 31 + gnu/lib/libg++/libio/sbscan.cc | 45 + gnu/lib/libg++/libio/stdfiles.c | 44 + gnu/lib/libg++/libio/stdio/ChangeLog | 84 + gnu/lib/libg++/libio/stdio/Makefile.in | 23 + gnu/lib/libg++/libio/stdio/clearerr.c | 10 + gnu/lib/libg++/libio/stdio/configure.in | 48 + gnu/lib/libg++/libio/stdio/fdopen.c | 9 + gnu/lib/libg++/libio/stdio/feof.c | 34 + gnu/lib/libg++/libio/stdio/ferror.c | 10 + gnu/lib/libg++/libio/stdio/fgetc.c | 10 + gnu/lib/libg++/libio/stdio/fileno.c | 12 + gnu/lib/libg++/libio/stdio/fputc.c | 11 + gnu/lib/libg++/libio/stdio/freopen.c | 14 + gnu/lib/libg++/libio/stdio/fseek.c | 12 + gnu/lib/libg++/libio/stdio/getc.c | 11 + gnu/lib/libg++/libio/stdio/getchar.c | 10 + gnu/lib/libg++/libio/stdio/getline.c | 13 + gnu/lib/libg++/libio/stdio/getw.c | 13 + gnu/lib/libg++/libio/stdio/popen.c | 23 + gnu/lib/libg++/libio/stdio/putc.c | 12 + gnu/lib/libg++/libio/stdio/putchar.c | 10 + gnu/lib/libg++/libio/stdio/putw.c | 15 + gnu/lib/libg++/libio/stdio/rewind.c | 10 + gnu/lib/libg++/libio/stdio/setbuf.c | 9 + gnu/lib/libg++/libio/stdio/setfileno.c | 17 + gnu/lib/libg++/libio/stdio/setlinebuf.c | 11 + gnu/lib/libg++/libio/stdio/snprintf.c | 51 + gnu/lib/libg++/libio/stdio/stdio.h | 179 + gnu/lib/libg++/libio/stdio/vfprintf.c | 35 + gnu/lib/libg++/libio/stdio/vfscanf.c | 36 + gnu/lib/libg++/libio/stdio/vprintf.c | 33 + gnu/lib/libg++/libio/stdio/vscanf.c | 34 + gnu/lib/libg++/libio/stdio/vsnprintf.c | 43 + gnu/lib/libg++/libio/stdiostream.cc | 159 + gnu/lib/libg++/libio/stdiostream.h | 79 + gnu/lib/libg++/libio/stdstrbufs.cc | 115 + gnu/lib/libg++/libio/stdstreams.cc | 149 + gnu/lib/libg++/libio/stream.cc | 144 + gnu/lib/libg++/libio/stream.h | 57 + gnu/lib/libg++/libio/streambuf.cc | 343 + gnu/lib/libg++/libio/streambuf.h | 473 ++ gnu/lib/libg++/libio/strfile.h | 46 + gnu/lib/libg++/libio/strops.c | 285 + gnu/lib/libg++/libio/strstream.cc | 168 + gnu/lib/libg++/libio/strstream.h | 123 + gnu/lib/libg++/libio/tests/ChangeLog | 102 + gnu/lib/libg++/libio/tests/Makefile.in | 195 + gnu/lib/libg++/libio/tests/configure.in | 21 + gnu/lib/libg++/libio/tests/hounddog.cc | 85 + gnu/lib/libg++/libio/tests/hounddog.exp | 7 + gnu/lib/libg++/libio/tests/hounddog.inp | 7 + gnu/lib/libg++/libio/tests/putbackdog.cc | 97 + gnu/lib/libg++/libio/tests/tFile.cc | 550 ++ gnu/lib/libg++/libio/tests/tFile.exp | 75 + gnu/lib/libg++/libio/tests/tFile.inp | 5 + gnu/lib/libg++/libio/tests/tfformat.c | 4145 ++++++++++ gnu/lib/libg++/libio/tests/tiformat.c | 5093 ++++++++++++ gnu/lib/libg++/libio/tests/tiomanip.cc | 35 + gnu/lib/libg++/libio/tests/tiomanip.exp | 4 + gnu/lib/libg++/libio/tests/tiomisc.cc | 200 + gnu/lib/libg++/libio/tests/tiomisc.exp | 10 + gnu/lib/libg++/libio/tests/tstdiomisc.c | 43 + gnu/lib/libg++/libio/tests/tstdiomisc.exp | 8 + gnu/lib/libg++/librx/COPYING.LIB | 481 ++ gnu/lib/libg++/librx/ChangeLog | 284 + gnu/lib/libg++/librx/DOC | 179 + gnu/lib/libg++/librx/INSTALL | 90 + gnu/lib/libg++/librx/INSTALL.rx | 8 + gnu/lib/libg++/librx/Makefile.in | 114 + gnu/lib/libg++/librx/configure | 1316 +++ gnu/lib/libg++/librx/configure.in | 38 + gnu/lib/libg++/librx/rx.c | 7192 +++++++++++++++++ gnu/lib/libg++/librx/rx.h | 3732 +++++++++ gnu/lib/libg++/libstdc++/ChangeLog | 529 ++ gnu/lib/libg++/libstdc++/Make.pack | 225 + gnu/lib/libg++/libstdc++/Makefile.in | 292 + gnu/lib/libg++/libstdc++/algorithm | 7 + gnu/lib/libg++/libstdc++/cassert | 6 + gnu/lib/libg++/libstdc++/cctype | 6 + gnu/lib/libg++/libstdc++/cerrno | 6 + gnu/lib/libg++/libstdc++/cfloat | 6 + gnu/lib/libg++/libstdc++/cinst.cc | 151 + gnu/lib/libg++/libstdc++/ciso646 | 6 + gnu/lib/libg++/libstdc++/climits | 6 + gnu/lib/libg++/libstdc++/clocale | 6 + gnu/lib/libg++/libstdc++/cmath | 6 + gnu/lib/libg++/libstdc++/cmathi.cc | 7 + gnu/lib/libg++/libstdc++/complex | 6 + gnu/lib/libg++/libstdc++/complex.h | 6 + gnu/lib/libg++/libstdc++/config/aix.ml | 7 + gnu/lib/libg++/libstdc++/config/dec-osf.ml | 6 + gnu/lib/libg++/libstdc++/config/elf.ml | 8 + gnu/lib/libg++/libstdc++/config/elfshlibm.ml | 6 + gnu/lib/libg++/libstdc++/config/hpux.ml | 6 + gnu/lib/libg++/libstdc++/config/irix5.ml | 5 + gnu/lib/libg++/libstdc++/config/linux.ml | 11 + gnu/lib/libg++/libstdc++/config/sol2shm.ml | 6 + gnu/lib/libg++/libstdc++/config/sunos4.ml | 9 + gnu/lib/libg++/libstdc++/configure.in | 74 + gnu/lib/libg++/libstdc++/csetjmp | 6 + gnu/lib/libg++/libstdc++/csignal | 6 + gnu/lib/libg++/libstdc++/cstdarg | 6 + gnu/lib/libg++/libstdc++/cstddef | 6 + gnu/lib/libg++/libstdc++/cstdio | 6 + gnu/lib/libg++/libstdc++/cstdlib | 6 + gnu/lib/libg++/libstdc++/cstdlibi.cc | 7 + gnu/lib/libg++/libstdc++/cstring | 6 + gnu/lib/libg++/libstdc++/cstringi.cc | 7 + gnu/lib/libg++/libstdc++/ctime | 6 + gnu/lib/libg++/libstdc++/cwchar | 6 + gnu/lib/libg++/libstdc++/cwctype | 6 + gnu/lib/libg++/libstdc++/deque | 7 + gnu/lib/libg++/libstdc++/exception | 6 + gnu/lib/libg++/libstdc++/exceptioni.cc | 78 + gnu/lib/libg++/libstdc++/functional | 7 + gnu/lib/libg++/libstdc++/iterator | 7 + gnu/lib/libg++/libstdc++/list | 7 + gnu/lib/libg++/libstdc++/map | 7 + gnu/lib/libg++/libstdc++/memory | 7 + gnu/lib/libg++/libstdc++/new | 6 + gnu/lib/libg++/libstdc++/new.h | 7 + gnu/lib/libg++/libstdc++/newi.cc | 7 + gnu/lib/libg++/libstdc++/numeric | 7 + gnu/lib/libg++/libstdc++/queue | 7 + gnu/lib/libg++/libstdc++/set | 7 + gnu/lib/libg++/libstdc++/sinst.cc | 147 + gnu/lib/libg++/libstdc++/stack | 7 + gnu/lib/libg++/libstdc++/std/bastring.cc | 483 ++ gnu/lib/libg++/libstdc++/std/bastring.h | 574 ++ gnu/lib/libg++/libstdc++/std/cassert.h | 7 + gnu/lib/libg++/libstdc++/std/cctype.h | 7 + gnu/lib/libg++/libstdc++/std/cerrno.h | 7 + gnu/lib/libg++/libstdc++/std/cfloat.h | 7 + gnu/lib/libg++/libstdc++/std/cinst.h | 112 + gnu/lib/libg++/libstdc++/std/ciso646.h | 7 + gnu/lib/libg++/libstdc++/std/climits.h | 7 + gnu/lib/libg++/libstdc++/std/clocale.h | 7 + gnu/lib/libg++/libstdc++/std/cmath.h | 76 + gnu/lib/libg++/libstdc++/std/complex.h | 18 + gnu/lib/libg++/libstdc++/std/complext.cc | 273 + gnu/lib/libg++/libstdc++/std/complext.h | 317 + gnu/lib/libg++/libstdc++/std/csetjmp.h | 8 + gnu/lib/libg++/libstdc++/std/csignal.h | 7 + gnu/lib/libg++/libstdc++/std/cstdarg.h | 7 + gnu/lib/libg++/libstdc++/std/cstddef.h | 7 + gnu/lib/libg++/libstdc++/std/cstdio.h | 7 + gnu/lib/libg++/libstdc++/std/cstdlib.h | 23 + gnu/lib/libg++/libstdc++/std/cstring.h | 71 + gnu/lib/libg++/libstdc++/std/ctime.h | 7 + gnu/lib/libg++/libstdc++/std/cwchar.h | 7 + gnu/lib/libg++/libstdc++/std/cwctype.h | 7 + gnu/lib/libg++/libstdc++/std/dcomplex.h | 89 + gnu/lib/libg++/libstdc++/std/exception.h | 39 + gnu/lib/libg++/libstdc++/std/fcomplex.h | 85 + gnu/lib/libg++/libstdc++/std/ldcomplex.h | 93 + gnu/lib/libg++/libstdc++/std/new.h | 34 + gnu/lib/libg++/libstdc++/std/sinst.h | 73 + gnu/lib/libg++/libstdc++/std/stddef.h | 25 + gnu/lib/libg++/libstdc++/std/stdexcept.h | 126 + gnu/lib/libg++/libstdc++/std/straits.h | 161 + gnu/lib/libg++/libstdc++/std/string.h | 13 + gnu/lib/libg++/libstdc++/std/typeinfo.h | 245 + gnu/lib/libg++/libstdc++/stddef | 6 + gnu/lib/libg++/libstdc++/stddefi.cc | 7 + gnu/lib/libg++/libstdc++/stdexcept | 6 + gnu/lib/libg++/libstdc++/stdexcepti.cc | 8 + gnu/lib/libg++/libstdc++/stl.h | 15 + gnu/lib/libg++/libstdc++/stl/ChangeLog | 73 + gnu/lib/libg++/libstdc++/stl/Makefile.in | 8 + gnu/lib/libg++/libstdc++/stl/README | 92 + gnu/lib/libg++/libstdc++/stl/algo.h | 2386 ++++++ gnu/lib/libg++/libstdc++/stl/algobase.h | 232 + gnu/lib/libg++/libstdc++/stl/bool.h | 20 + gnu/lib/libg++/libstdc++/stl/bvector.h | 421 + gnu/lib/libg++/libstdc++/stl/configure.in | 25 + gnu/lib/libg++/libstdc++/stl/defalloc.h | 176 + gnu/lib/libg++/libstdc++/stl/deque.h | 681 ++ gnu/lib/libg++/libstdc++/stl/faralloc.h | 120 + gnu/lib/libg++/libstdc++/stl/fdeque.h | 39 + gnu/lib/libg++/libstdc++/stl/flist.h | 39 + gnu/lib/libg++/libstdc++/stl/fmap.h | 44 + gnu/lib/libg++/libstdc++/stl/fmultmap.h | 44 + gnu/lib/libg++/libstdc++/stl/fmultset.h | 44 + gnu/lib/libg++/libstdc++/stl/fset.h | 44 + gnu/lib/libg++/libstdc++/stl/function.h | 282 + gnu/lib/libg++/libstdc++/stl/hdeque.h | 39 + gnu/lib/libg++/libstdc++/stl/heap.h | 193 + gnu/lib/libg++/libstdc++/stl/hlist.h | 39 + gnu/lib/libg++/libstdc++/stl/hmap.h | 44 + gnu/lib/libg++/libstdc++/stl/hmultmap.h | 44 + gnu/lib/libg++/libstdc++/stl/hmultset.h | 44 + gnu/lib/libg++/libstdc++/stl/hset.h | 44 + gnu/lib/libg++/libstdc++/stl/hugalloc.h | 38 + gnu/lib/libg++/libstdc++/stl/hvector.h | 39 + gnu/lib/libg++/libstdc++/stl/iterator.h | 395 + gnu/lib/libg++/libstdc++/stl/lbvector.h | 39 + gnu/lib/libg++/libstdc++/stl/ldeque.h | 39 + gnu/lib/libg++/libstdc++/stl/list.h | 531 ++ gnu/lib/libg++/libstdc++/stl/llist.h | 39 + gnu/lib/libg++/libstdc++/stl/lmap.h | 44 + gnu/lib/libg++/libstdc++/stl/lmultmap.h | 44 + gnu/lib/libg++/libstdc++/stl/lmultset.h | 44 + gnu/lib/libg++/libstdc++/stl/lngalloc.h | 54 + gnu/lib/libg++/libstdc++/stl/lset.h | 44 + gnu/lib/libg++/libstdc++/stl/map.h | 150 + gnu/lib/libg++/libstdc++/stl/multimap.h | 142 + gnu/lib/libg++/libstdc++/stl/multiset.h | 129 + gnu/lib/libg++/libstdc++/stl/neralloc.h | 38 + gnu/lib/libg++/libstdc++/stl/nmap.h | 44 + gnu/lib/libg++/libstdc++/stl/nmultmap.h | 44 + gnu/lib/libg++/libstdc++/stl/nmultset.h | 44 + gnu/lib/libg++/libstdc++/stl/nset.h | 44 + gnu/lib/libg++/libstdc++/stl/pair.h | 46 + gnu/lib/libg++/libstdc++/stl/projectn.h | 33 + gnu/lib/libg++/libstdc++/stl/random.cc | 60 + gnu/lib/libg++/libstdc++/stl/set.h | 132 + gnu/lib/libg++/libstdc++/stl/stack.h | 120 + gnu/lib/libg++/libstdc++/stl/tempbuf.cc | 18 + gnu/lib/libg++/libstdc++/stl/tempbuf.h | 55 + gnu/lib/libg++/libstdc++/stl/tree.cc | 3 + gnu/lib/libg++/libstdc++/stl/tree.h | 1246 +++ gnu/lib/libg++/libstdc++/stl/vector.h | 355 + gnu/lib/libg++/libstdc++/string | 6 + gnu/lib/libg++/libstdc++/tests/ChangeLog | 44 + gnu/lib/libg++/libstdc++/tests/Makefile.in | 35 + gnu/lib/libg++/libstdc++/tests/configure.in | 49 + gnu/lib/libg++/libstdc++/tests/tcomplex.cc | 143 + gnu/lib/libg++/libstdc++/tests/tcomplex.exp | 37 + gnu/lib/libg++/libstdc++/tests/tcomplex.inp | 1 + gnu/lib/libg++/libstdc++/tests/tlist.cc | 146 + gnu/lib/libg++/libstdc++/tests/tlist.exp | 39 + gnu/lib/libg++/libstdc++/tests/tmap.cc | 66 + gnu/lib/libg++/libstdc++/tests/tmap.exp | 7 + gnu/lib/libg++/libstdc++/tests/tstring.cc | 189 + gnu/lib/libg++/libstdc++/tests/tstring.exp | 20 + gnu/lib/libg++/libstdc++/tests/tstring.inp | 1 + gnu/lib/libg++/libstdc++/tests/tvector.cc | 20 + gnu/lib/libg++/libstdc++/tests/tvector.exp | 4 + gnu/lib/libg++/libstdc++/typeinfo | 6 + gnu/lib/libg++/libstdc++/typeinfoi.cc | 129 + gnu/lib/libg++/libstdc++/utility | 8 + gnu/lib/libg++/libstdc++/vector | 7 + gnu/lib/libg++/move-if-change | 15 + gnu/lib/libg++/mpw-README | 207 + gnu/lib/libg++/mpw-build.in | 191 + gnu/lib/libg++/mpw-config.in | 98 + gnu/lib/libg++/mpw-configure | 342 + gnu/lib/libg++/texinfo/gpl.texinfo | 398 + gnu/lib/libg++/texinfo/lgpl.texinfo | 548 ++ gnu/lib/libg++/texinfo/tex3patch | 68 + gnu/lib/libg++/texinfo/texinfo.tex | 4119 ++++++++++ 1095 files changed, 209614 insertions(+) create mode 100644 gnu/lib/libg++/COPYING.LIB create mode 100644 gnu/lib/libg++/Makefile.in create mode 100644 gnu/lib/libg++/README create mode 100644 gnu/lib/libg++/cfg-ml-com.in create mode 100644 gnu/lib/libg++/cfg-ml-pos.in create mode 100644 gnu/lib/libg++/config.guess create mode 100644 gnu/lib/libg++/config.sub create mode 100644 gnu/lib/libg++/config/ChangeLog create mode 100644 gnu/lib/libg++/config/mh-a68bsd create mode 100644 gnu/lib/libg++/config/mh-aix386 create mode 100644 gnu/lib/libg++/config/mh-apollo68 create mode 100644 gnu/lib/libg++/config/mh-cxux create mode 100644 gnu/lib/libg++/config/mh-decstation create mode 100644 gnu/lib/libg++/config/mh-delta88 create mode 100644 gnu/lib/libg++/config/mh-dgux create mode 100644 gnu/lib/libg++/config/mh-go32 create mode 100644 gnu/lib/libg++/config/mh-hp300 create mode 100644 gnu/lib/libg++/config/mh-hpux create mode 100644 gnu/lib/libg++/config/mh-hpux8 create mode 100644 gnu/lib/libg++/config/mh-i386win32 create mode 100644 gnu/lib/libg++/config/mh-irix4 create mode 100644 gnu/lib/libg++/config/mh-irix5 create mode 100644 gnu/lib/libg++/config/mh-linux create mode 100644 gnu/lib/libg++/config/mh-lynxos create mode 100644 gnu/lib/libg++/config/mh-lynxrs6k create mode 100644 gnu/lib/libg++/config/mh-ncr3000 create mode 100644 gnu/lib/libg++/config/mh-ncrsvr43 create mode 100644 gnu/lib/libg++/config/mh-papic create mode 100644 gnu/lib/libg++/config/mh-riscos create mode 100644 gnu/lib/libg++/config/mh-sco create mode 100644 gnu/lib/libg++/config/mh-solaris create mode 100644 gnu/lib/libg++/config/mh-sparcpic create mode 100644 gnu/lib/libg++/config/mh-sun3 create mode 100644 gnu/lib/libg++/config/mh-sysv create mode 100644 gnu/lib/libg++/config/mh-sysv4 create mode 100644 gnu/lib/libg++/config/mh-vaxult2 create mode 100644 gnu/lib/libg++/config/mh-x86pic create mode 100644 gnu/lib/libg++/config/mpw-mh-mpw create mode 100644 gnu/lib/libg++/config/mt-netware create mode 100644 gnu/lib/libg++/config/mt-papic create mode 100644 gnu/lib/libg++/config/mt-sparcpic create mode 100644 gnu/lib/libg++/config/mt-v810 create mode 100644 gnu/lib/libg++/config/mt-x86pic create mode 100644 gnu/lib/libg++/configure create mode 100644 gnu/lib/libg++/configure.in create mode 100644 gnu/lib/libg++/etc/Makefile.in create mode 100644 gnu/lib/libg++/etc/cfg-paper.info create mode 100644 gnu/lib/libg++/etc/cfg-paper.texi create mode 100644 gnu/lib/libg++/etc/configure.in create mode 100644 gnu/lib/libg++/etc/configure.info create mode 100644 gnu/lib/libg++/etc/configure.info-1 create mode 100644 gnu/lib/libg++/etc/configure.info-2 create mode 100644 gnu/lib/libg++/etc/configure.man create mode 100644 gnu/lib/libg++/etc/configure.texi create mode 100644 gnu/lib/libg++/etc/make-stds.texi create mode 100644 gnu/lib/libg++/etc/standards.info create mode 100644 gnu/lib/libg++/etc/standards.info-1 create mode 100644 gnu/lib/libg++/etc/standards.info-2 create mode 100644 gnu/lib/libg++/etc/standards.texi create mode 100644 gnu/lib/libg++/include/COPYING create mode 100644 gnu/lib/libg++/include/ChangeLog create mode 100644 gnu/lib/libg++/include/ansidecl.h create mode 100644 gnu/lib/libg++/include/demangle.h create mode 100644 gnu/lib/libg++/include/floatformat.h create mode 100644 gnu/lib/libg++/include/getopt.h create mode 100644 gnu/lib/libg++/include/libiberty.h create mode 100644 gnu/lib/libg++/include/obstack.h create mode 100644 gnu/lib/libg++/install.sh create mode 100644 gnu/lib/libg++/libg++/ChangeLog create mode 100644 gnu/lib/libg++/libg++/Makefile.in create mode 100644 gnu/lib/libg++/libg++/NEWS create mode 100644 gnu/lib/libg++/libg++/README create mode 100644 gnu/lib/libg++/libg++/README.SHLIB create mode 100644 gnu/lib/libg++/libg++/TODO create mode 100644 gnu/lib/libg++/libg++/config.shared create mode 100644 gnu/lib/libg++/libg++/config/aix.ml create mode 100644 gnu/lib/libg++/libg++/config/dec-osf.ml create mode 100644 gnu/lib/libg++/libg++/config/elf.ml create mode 100644 gnu/lib/libg++/libg++/config/elfshlibm.ml create mode 100644 gnu/lib/libg++/libg++/config/hpux.ml create mode 100644 gnu/lib/libg++/libg++/config/irix5.ml create mode 100644 gnu/lib/libg++/libg++/config/linux.ml create mode 100644 gnu/lib/libg++/libg++/config/linux.mt create mode 100644 gnu/lib/libg++/libg++/config/sol2shm.ml create mode 100644 gnu/lib/libg++/libg++/config/solaris2.mt create mode 100644 gnu/lib/libg++/libg++/config/sunos4.ml create mode 100644 gnu/lib/libg++/libg++/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/Patmain.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.h create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/depend create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/genPatkey.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/generic-q.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/keyhash.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/kmp.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/search.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/tsort.cc create mode 100644 gnu/lib/libg++/libg++/etc/ADT-examples/tsortinp.cc create mode 100644 gnu/lib/libg++/libg++/etc/ChangeLog create mode 100644 gnu/lib/libg++/libg++/etc/HINTS create mode 100644 gnu/lib/libg++/libg++/etc/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.cc create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.h create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/README create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/Vec3D.h create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/depend create mode 100644 gnu/lib/libg++/libg++/etc/PlotFile3D/tPlotFile3D.cc create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/ChangeLog create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/Char.h create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/Int.h create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/benchmarks/dhrystone.cc create mode 100644 gnu/lib/libg++/libg++/etc/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/fib/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/fib/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/fib/fib.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/ChangeLog create mode 100644 gnu/lib/libg++/libg++/etc/graph/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/graph/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/graph/depend create mode 100644 gnu/lib/libg++/libg++/etc/graph/eGetOpt.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/eGetOpt.h create mode 100644 gnu/lib/libg++/libg++/etc/graph/ePlotFile.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/ePlotFile.h create mode 100644 gnu/lib/libg++/libg++/etc/graph/graph.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/graph.tex create mode 100644 gnu/lib/libg++/libg++/etc/graph/pdefs.h create mode 100644 gnu/lib/libg++/libg++/etc/graph/read_data.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/read_data.h create mode 100644 gnu/lib/libg++/libg++/etc/graph/test.dat create mode 100644 gnu/lib/libg++/libg++/etc/graph/test2.dat create mode 100644 gnu/lib/libg++/libg++/etc/graph/tick_intrvl.cc create mode 100644 gnu/lib/libg++/libg++/etc/graph/tick_intrvl.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/ChangeLog create mode 100644 gnu/lib/libg++/libg++/etc/lf/Dirent.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/Dirent.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/lf/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/lf/depend create mode 100644 gnu/lib/libg++/libg++/etc/lf/directory.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/directory.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/entry.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/entry.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/lf.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/option.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/option.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/screen.cc create mode 100644 gnu/lib/libg++/libg++/etc/lf/screen.h create mode 100644 gnu/lib/libg++/libg++/etc/lf/sort.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/ChangeLog create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/Makefile.in create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/compact.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/compact.h create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/configure.in create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/depend create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/main.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/options.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/options.h create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/renew.h create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/test.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/trie-gen.1 create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/trie.cc create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/trie.h create mode 100644 gnu/lib/libg++/libg++/etc/trie-gen/version.cc create mode 100644 gnu/lib/libg++/libg++/g++FAQ.texi create mode 100644 gnu/lib/libg++/libg++/g++FAQ.txt create mode 100644 gnu/lib/libg++/libg++/genclass/ChangeLog create mode 100644 gnu/lib/libg++/libg++/genclass/Makefile.in create mode 100644 gnu/lib/libg++/libg++/genclass/configure.in create mode 100644 gnu/lib/libg++/libg++/genclass/expected.out create mode 100644 gnu/lib/libg++/libg++/genclass/genclass.sh create mode 100644 gnu/lib/libg++/libg++/genclass/gentest.sh create mode 100644 gnu/lib/libg++/libg++/gperf/COPYING create mode 100644 gnu/lib/libg++/libg++/gperf/ChangeLog create mode 100644 gnu/lib/libg++/libg++/gperf/Makefile.in create mode 100644 gnu/lib/libg++/libg++/gperf/README create mode 100644 gnu/lib/libg++/libg++/gperf/configure.in create mode 100644 gnu/lib/libg++/libg++/gperf/gperf.1 create mode 100644 gnu/lib/libg++/libg++/gperf/gperf.info create mode 100644 gnu/lib/libg++/libg++/gperf/gperf.texi create mode 100644 gnu/lib/libg++/libg++/gperf/src/Makefile.in create mode 100644 gnu/lib/libg++/libg++/gperf/src/bool-array.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/bool-array.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/configure.in create mode 100644 gnu/lib/libg++/libg++/gperf/src/depend create mode 100644 gnu/lib/libg++/libg++/gperf/src/gen-perf.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/gen-perf.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/hash-table.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/hash-table.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/iterator.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/iterator.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/key-list.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/key-list.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/list-node.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/list-node.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/main.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/new.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/options.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/options.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/read-line.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/read-line.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/std-err.cc create mode 100644 gnu/lib/libg++/libg++/gperf/src/std-err.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/trace.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/vectors.h create mode 100644 gnu/lib/libg++/libg++/gperf/src/version.cc create mode 100644 gnu/lib/libg++/libg++/gperf/tests/Makefile.in create mode 100644 gnu/lib/libg++/libg++/gperf/tests/ada-pred.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/ada-res.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/ada.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/adadefs.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/c++.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/c-parse.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/c.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/c.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/configure.in create mode 100644 gnu/lib/libg++/libg++/gperf/tests/gpc.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/gplus.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/irc.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/makeinfo.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/modula.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/modula2.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/modula3.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/pascal.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/pascal.gperf create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-1.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-2.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-3.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-4.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-5.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-6.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test-7.exp create mode 100644 gnu/lib/libg++/libg++/gperf/tests/test.c create mode 100644 gnu/lib/libg++/libg++/libg++.info create mode 100644 gnu/lib/libg++/libg++/libg++.info-1 create mode 100644 gnu/lib/libg++/libg++/libg++.info-2 create mode 100644 gnu/lib/libg++/libg++/libg++.info-3 create mode 100644 gnu/lib/libg++/libg++/libg++.info-4 create mode 100644 gnu/lib/libg++/libg++/libg++.info-5 create mode 100644 gnu/lib/libg++/libg++/libg++.texi create mode 100644 gnu/lib/libg++/libg++/no-stream/.cvsignore create mode 100644 gnu/lib/libg++/libg++/no-stream/Makefile.in create mode 100644 gnu/lib/libg++/libg++/no-stream/configure.in create mode 100644 gnu/lib/libg++/libg++/old-stream/.cvsignore create mode 100644 gnu/lib/libg++/libg++/old-stream/ChangeLog create mode 100644 gnu/lib/libg++/libg++/old-stream/File.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/File.h create mode 100644 gnu/lib/libg++/libg++/old-stream/Filebuf.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/Filebuf.h create mode 100644 gnu/lib/libg++/libg++/old-stream/Fmodes.h create mode 100644 gnu/lib/libg++/libg++/old-stream/Makefile.in create mode 100644 gnu/lib/libg++/libg++/old-stream/PlotFile.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/PlotFile.h create mode 100644 gnu/lib/libg++/libg++/old-stream/SFile.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/SFile.h create mode 100644 gnu/lib/libg++/libg++/old-stream/configure.in create mode 100644 gnu/lib/libg++/libg++/old-stream/depend create mode 100644 gnu/lib/libg++/libg++/old-stream/filebuf.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/filebuf.h create mode 100644 gnu/lib/libg++/libg++/old-stream/form.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/istream.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/istream.h create mode 100644 gnu/lib/libg++/libg++/old-stream/itoa.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/ostream.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/ostream.h create mode 100644 gnu/lib/libg++/libg++/old-stream/stream.h create mode 100644 gnu/lib/libg++/libg++/old-stream/streambuf.cc create mode 100644 gnu/lib/libg++/libg++/old-stream/streambuf.h create mode 100644 gnu/lib/libg++/libg++/proto-kit/Makefile create mode 100644 gnu/lib/libg++/libg++/proto-kit/Makefile.new create mode 100644 gnu/lib/libg++/libg++/proto-kit/file_types.hierarchy create mode 100644 gnu/lib/libg++/libg++/proto-kit/file_types.includes.h create mode 100644 gnu/lib/libg++/libg++/proto-kit/file_types.operation.h create mode 100644 gnu/lib/libg++/libg++/proto-kit/file_types.type.h create mode 100644 gnu/lib/libg++/libg++/proto-kit/genclass.extnsn create mode 100644 gnu/lib/libg++/libg++/proto-kit/hierarchy create mode 100644 gnu/lib/libg++/libg++/proto-kit/make-defs-file create mode 100644 gnu/lib/libg++/libg++/proto-kit/make-source-dependencies create mode 100644 gnu/lib/libg++/libg++/proto-kit/make-types create mode 100644 gnu/lib/libg++/libg++/proto-kit/prepend create mode 100644 gnu/lib/libg++/libg++/proto-kit/prepend-header create mode 100644 gnu/lib/libg++/libg++/proto-kit/prototype create mode 100644 gnu/lib/libg++/libg++/proto-kit/prototype.dependencies create mode 100644 gnu/lib/libg++/libg++/src/.cvsignore create mode 100644 gnu/lib/libg++/libg++/src/ACG.cc create mode 100644 gnu/lib/libg++/libg++/src/ACG.h create mode 100644 gnu/lib/libg++/libg++/src/AllocRing.cc create mode 100644 gnu/lib/libg++/libg++/src/AllocRing.h create mode 100644 gnu/lib/libg++/libg++/src/Binomial.cc create mode 100644 gnu/lib/libg++/libg++/src/Binomial.h create mode 100644 gnu/lib/libg++/libg++/src/BitSet.cc create mode 100644 gnu/lib/libg++/libg++/src/BitSet.h create mode 100644 gnu/lib/libg++/libg++/src/BitString.cc create mode 100644 gnu/lib/libg++/libg++/src/BitString.h create mode 100644 gnu/lib/libg++/libg++/src/ChangeLog create mode 100644 gnu/lib/libg++/libg++/src/Complex.h create mode 100644 gnu/lib/libg++/libg++/src/CursesW.cc create mode 100644 gnu/lib/libg++/libg++/src/CursesW.h create mode 100644 gnu/lib/libg++/libg++/src/DLList.cc create mode 100644 gnu/lib/libg++/libg++/src/DLList.h create mode 100644 gnu/lib/libg++/libg++/src/DiscUnif.cc create mode 100644 gnu/lib/libg++/libg++/src/DiscUnif.h create mode 100644 gnu/lib/libg++/libg++/src/Erlang.cc create mode 100644 gnu/lib/libg++/libg++/src/Erlang.h create mode 100644 gnu/lib/libg++/libg++/src/Fix.cc create mode 100644 gnu/lib/libg++/libg++/src/Fix.h create mode 100644 gnu/lib/libg++/libg++/src/Fix16.cc create mode 100644 gnu/lib/libg++/libg++/src/Fix16.h create mode 100644 gnu/lib/libg++/libg++/src/Fix24.cc create mode 100644 gnu/lib/libg++/libg++/src/Fix24.h create mode 100644 gnu/lib/libg++/libg++/src/Geom.cc create mode 100644 gnu/lib/libg++/libg++/src/Geom.h create mode 100644 gnu/lib/libg++/libg++/src/GetOpt.cc create mode 100644 gnu/lib/libg++/libg++/src/GetOpt.h create mode 100644 gnu/lib/libg++/libg++/src/HypGeom.cc create mode 100644 gnu/lib/libg++/libg++/src/HypGeom.h create mode 100644 gnu/lib/libg++/libg++/src/Incremental.h create mode 100644 gnu/lib/libg++/libg++/src/Intdouble.cc create mode 100644 gnu/lib/libg++/libg++/src/Integer.cc create mode 100644 gnu/lib/libg++/libg++/src/Integer.h create mode 100644 gnu/lib/libg++/libg++/src/Integer.hP create mode 100644 gnu/lib/libg++/libg++/src/LogNorm.cc create mode 100644 gnu/lib/libg++/libg++/src/LogNorm.h create mode 100644 gnu/lib/libg++/libg++/src/MLCG.cc create mode 100644 gnu/lib/libg++/libg++/src/MLCG.h create mode 100644 gnu/lib/libg++/libg++/src/Makefile.in create mode 100644 gnu/lib/libg++/libg++/src/NegExp.cc create mode 100644 gnu/lib/libg++/libg++/src/NegExp.h create mode 100644 gnu/lib/libg++/libg++/src/Normal.cc create mode 100644 gnu/lib/libg++/libg++/src/Normal.h create mode 100644 gnu/lib/libg++/libg++/src/Obstack.cc create mode 100644 gnu/lib/libg++/libg++/src/Obstack.h create mode 100644 gnu/lib/libg++/libg++/src/Pix.h create mode 100644 gnu/lib/libg++/libg++/src/Poisson.cc create mode 100644 gnu/lib/libg++/libg++/src/Poisson.h create mode 100644 gnu/lib/libg++/libg++/src/RNG.cc create mode 100644 gnu/lib/libg++/libg++/src/RNG.h create mode 100644 gnu/lib/libg++/libg++/src/Random.cc create mode 100644 gnu/lib/libg++/libg++/src/Random.h create mode 100644 gnu/lib/libg++/libg++/src/Rational.cc create mode 100644 gnu/lib/libg++/libg++/src/Rational.h create mode 100644 gnu/lib/libg++/libg++/src/Regex.cc create mode 100644 gnu/lib/libg++/libg++/src/Regex.h create mode 100644 gnu/lib/libg++/libg++/src/RndInt.cc create mode 100644 gnu/lib/libg++/libg++/src/RndInt.h create mode 100644 gnu/lib/libg++/libg++/src/SLList.cc create mode 100644 gnu/lib/libg++/libg++/src/SLList.h create mode 100644 gnu/lib/libg++/libg++/src/Sample.cc create mode 100644 gnu/lib/libg++/libg++/src/SmplHist.cc create mode 100644 gnu/lib/libg++/libg++/src/SmplHist.h create mode 100644 gnu/lib/libg++/libg++/src/SmplStat.cc create mode 100644 gnu/lib/libg++/libg++/src/SmplStat.h create mode 100644 gnu/lib/libg++/libg++/src/String.cc create mode 100644 gnu/lib/libg++/libg++/src/String.h create mode 100644 gnu/lib/libg++/libg++/src/Uniform.cc create mode 100644 gnu/lib/libg++/libg++/src/Uniform.h create mode 100644 gnu/lib/libg++/libg++/src/Weibull.cc create mode 100644 gnu/lib/libg++/libg++/src/Weibull.h create mode 100644 gnu/lib/libg++/libg++/src/bitand.c create mode 100644 gnu/lib/libg++/libg++/src/bitany.c create mode 100644 gnu/lib/libg++/libg++/src/bitblt.c create mode 100644 gnu/lib/libg++/libg++/src/bitclear.c create mode 100644 gnu/lib/libg++/libg++/src/bitcopy.c create mode 100644 gnu/lib/libg++/libg++/src/bitcount.c create mode 100644 gnu/lib/libg++/libg++/src/bitdo1.h create mode 100644 gnu/lib/libg++/libg++/src/bitdo2.h create mode 100644 gnu/lib/libg++/libg++/src/bitinvert.c create mode 100644 gnu/lib/libg++/libg++/src/bitlcomp.c create mode 100644 gnu/lib/libg++/libg++/src/bitprims.h create mode 100644 gnu/lib/libg++/libg++/src/bitset1.c create mode 100644 gnu/lib/libg++/libg++/src/bitxor.c create mode 100644 gnu/lib/libg++/libg++/src/bool.h create mode 100644 gnu/lib/libg++/libg++/src/builtin.cc create mode 100644 gnu/lib/libg++/libg++/src/builtin.h create mode 100644 gnu/lib/libg++/libg++/src/chr.cc create mode 100644 gnu/lib/libg++/libg++/src/compare.cc create mode 100644 gnu/lib/libg++/libg++/src/compare.h create mode 100644 gnu/lib/libg++/libg++/src/configure.in create mode 100644 gnu/lib/libg++/libg++/src/depend create mode 100644 gnu/lib/libg++/libg++/src/dtoa.cc create mode 100644 gnu/lib/libg++/libg++/src/error.cc create mode 100644 gnu/lib/libg++/libg++/src/fmtq.cc create mode 100644 gnu/lib/libg++/libg++/src/gcd.cc create mode 100644 gnu/lib/libg++/libg++/src/gen/AVLMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/AVLMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/AVLSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/AVLSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/AVec.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/AVec.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/BSTSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/BSTSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Bag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Bag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHNode.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHNode.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/CHSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/DLDeque.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/DLDeque.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/DLList.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/DLList.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Deque.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Deque.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPQueue.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPQueue.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPStack.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPStack.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPlex.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/FPlex.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/List.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/List.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/MPlex.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/MPlex.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Map.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Map.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/OSLBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/OSLBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/OSLSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/OSLSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/OXPBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/OXPBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/OXPSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/OXPSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/PHPQ.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/PHPQ.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/PQ.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/PQ.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/PSList.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/PVec.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Plex.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Plex.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Queue.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Queue.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/RAVLMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/RAVLMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/RPlex.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/RPlex.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLList.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLList.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLQueue.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLQueue.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLStack.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SLStack.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Set.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Set.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SkipSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayNode.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayNode.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayPQ.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplayPQ.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplaySet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/SplaySet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Stack.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Stack.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHMap.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHMap.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VHSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VOHSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VOHSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VQueue.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VQueue.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/VStack.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/VStack.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/Vec.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/Vec.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPBag.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPBag.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPDeque.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPDeque.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPPQ.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPPQ.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPQueue.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPQueue.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPSet.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPSet.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPStack.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPStack.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPlex.ccP create mode 100644 gnu/lib/libg++/libg++/src/gen/XPlex.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/defs.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/intSList.hP create mode 100644 gnu/lib/libg++/libg++/src/gen/intVec.hP create mode 100644 gnu/lib/libg++/libg++/src/generic.h create mode 100644 gnu/lib/libg++/libg++/src/getpagesize.h create mode 100644 gnu/lib/libg++/libg++/src/hash.cc create mode 100644 gnu/lib/libg++/libg++/src/ioob.cc create mode 100644 gnu/lib/libg++/libg++/src/lg.cc create mode 100644 gnu/lib/libg++/libg++/src/libc.h create mode 100644 gnu/lib/libg++/libg++/src/malloc.c create mode 100644 gnu/lib/libg++/libg++/src/minmax.cc create mode 100644 gnu/lib/libg++/libg++/src/minmax.h create mode 100644 gnu/lib/libg++/libg++/src/osfcn.h create mode 100644 gnu/lib/libg++/libg++/src/pow.cc create mode 100644 gnu/lib/libg++/libg++/src/sqrt.cc create mode 100644 gnu/lib/libg++/libg++/src/std.h create mode 100644 gnu/lib/libg++/libg++/src/str.cc create mode 100644 gnu/lib/libg++/libg++/src/strclass.h create mode 100644 gnu/lib/libg++/libg++/src/swap.h create mode 100644 gnu/lib/libg++/libg++/src/sysent.h create mode 100644 gnu/lib/libg++/libg++/src/timer.c create mode 100644 gnu/lib/libg++/libg++/src/typemacros.h create mode 100644 gnu/lib/libg++/libg++/test-install/.cvsignore create mode 100644 gnu/lib/libg++/libg++/test-install/ChangeLog create mode 100644 gnu/lib/libg++/libg++/test-install/Foo.cc create mode 100644 gnu/lib/libg++/libg++/test-install/Foo.h create mode 100644 gnu/lib/libg++/libg++/test-install/Makefile.in create mode 100644 gnu/lib/libg++/libg++/test-install/a.cc create mode 100644 gnu/lib/libg++/libg++/test-install/bf.cc create mode 100644 gnu/lib/libg++/libg++/test-install/bm.cc create mode 100644 gnu/lib/libg++/libg++/test-install/configure.in create mode 100644 gnu/lib/libg++/libg++/test-install/ex_bar.cc create mode 100644 gnu/lib/libg++/libg++/test-install/expected.out create mode 100644 gnu/lib/libg++/libg++/test-install/foo_func.cc create mode 100644 gnu/lib/libg++/libg++/test-install/foo_main.cc create mode 100644 gnu/lib/libg++/libg++/tests/.cvsignore create mode 100644 gnu/lib/libg++/libg++/tests/ChangeLog create mode 100644 gnu/lib/libg++/libg++/tests/Makefile.in create mode 100644 gnu/lib/libg++/libg++/tests/Makefile.sh create mode 100644 gnu/lib/libg++/libg++/tests/configure.in create mode 100644 gnu/lib/libg++/libg++/tests/depend create mode 100644 gnu/lib/libg++/libg++/tests/tBag.cc create mode 100644 gnu/lib/libg++/libg++/tests/tBag.exp create mode 100644 gnu/lib/libg++/libg++/tests/tBag.inp create mode 100644 gnu/lib/libg++/libg++/tests/tBitSet.cc create mode 100644 gnu/lib/libg++/libg++/tests/tBitSet.exp create mode 100644 gnu/lib/libg++/libg++/tests/tBitSet.inp create mode 100644 gnu/lib/libg++/libg++/tests/tBitString.cc create mode 100644 gnu/lib/libg++/libg++/tests/tBitString.exp create mode 100644 gnu/lib/libg++/libg++/tests/tBitString.inp create mode 100644 gnu/lib/libg++/libg++/tests/tCurses.cc create mode 100644 gnu/lib/libg++/libg++/tests/tCurses.inp create mode 100644 gnu/lib/libg++/libg++/tests/tDeque.cc create mode 100644 gnu/lib/libg++/libg++/tests/tDeque.exp create mode 100644 gnu/lib/libg++/libg++/tests/tDeque.inp create mode 100644 gnu/lib/libg++/libg++/tests/tFile.cc create mode 100644 gnu/lib/libg++/libg++/tests/tFile.exp create mode 100644 gnu/lib/libg++/libg++/tests/tFile.inp create mode 100644 gnu/lib/libg++/libg++/tests/tFix.cc create mode 100644 gnu/lib/libg++/libg++/tests/tFix.exp create mode 100644 gnu/lib/libg++/libg++/tests/tFix.inp create mode 100644 gnu/lib/libg++/libg++/tests/tFix16.cc create mode 100644 gnu/lib/libg++/libg++/tests/tFix16.exp create mode 100644 gnu/lib/libg++/libg++/tests/tFix16.inp create mode 100644 gnu/lib/libg++/libg++/tests/tFix24.cc create mode 100644 gnu/lib/libg++/libg++/tests/tFix24.exp create mode 100644 gnu/lib/libg++/libg++/tests/tFix24.inp create mode 100644 gnu/lib/libg++/libg++/tests/tGetOpt.cc create mode 100644 gnu/lib/libg++/libg++/tests/tGetOpt.exp create mode 100644 gnu/lib/libg++/libg++/tests/tGetOpt.inp create mode 100644 gnu/lib/libg++/libg++/tests/tInteger.cc create mode 100644 gnu/lib/libg++/libg++/tests/tInteger.exp create mode 100644 gnu/lib/libg++/libg++/tests/tInteger.inp create mode 100644 gnu/lib/libg++/libg++/tests/tLList.cc create mode 100644 gnu/lib/libg++/libg++/tests/tLList.exp create mode 100644 gnu/lib/libg++/libg++/tests/tLList.inp create mode 100644 gnu/lib/libg++/libg++/tests/tList.cc create mode 100644 gnu/lib/libg++/libg++/tests/tList.exp create mode 100644 gnu/lib/libg++/libg++/tests/tList.inp create mode 100644 gnu/lib/libg++/libg++/tests/tMap.cc create mode 100644 gnu/lib/libg++/libg++/tests/tMap.exp create mode 100644 gnu/lib/libg++/libg++/tests/tMap.inp create mode 100644 gnu/lib/libg++/libg++/tests/tObstack.cc create mode 100644 gnu/lib/libg++/libg++/tests/tObstack.exp create mode 100644 gnu/lib/libg++/libg++/tests/tObstack.inp create mode 100644 gnu/lib/libg++/libg++/tests/tPQ.cc create mode 100644 gnu/lib/libg++/libg++/tests/tPQ.exp create mode 100644 gnu/lib/libg++/libg++/tests/tPQ.inp create mode 100644 gnu/lib/libg++/libg++/tests/tPlex.cc create mode 100644 gnu/lib/libg++/libg++/tests/tPlex.exp create mode 100644 gnu/lib/libg++/libg++/tests/tPlex.inp create mode 100644 gnu/lib/libg++/libg++/tests/tQueue.cc create mode 100644 gnu/lib/libg++/libg++/tests/tQueue.exp create mode 100644 gnu/lib/libg++/libg++/tests/tQueue.inp create mode 100644 gnu/lib/libg++/libg++/tests/tRandom.cc create mode 100644 gnu/lib/libg++/libg++/tests/tRandom.exp create mode 100644 gnu/lib/libg++/libg++/tests/tRandom.inp create mode 100644 gnu/lib/libg++/libg++/tests/tRational.cc create mode 100644 gnu/lib/libg++/libg++/tests/tRational.exp create mode 100644 gnu/lib/libg++/libg++/tests/tRational.inp create mode 100644 gnu/lib/libg++/libg++/tests/tSet.cc create mode 100644 gnu/lib/libg++/libg++/tests/tSet.exp create mode 100644 gnu/lib/libg++/libg++/tests/tSet.inp create mode 100644 gnu/lib/libg++/libg++/tests/tStack.cc create mode 100644 gnu/lib/libg++/libg++/tests/tStack.exp create mode 100644 gnu/lib/libg++/libg++/tests/tStack.inp create mode 100644 gnu/lib/libg++/libg++/tests/tString.cc create mode 100644 gnu/lib/libg++/libg++/tests/tString.exp create mode 100644 gnu/lib/libg++/libg++/tests/tString.inp create mode 100644 gnu/lib/libg++/libg++/tests/tVec.cc create mode 100644 gnu/lib/libg++/libg++/tests/tVec.exp create mode 100644 gnu/lib/libg++/libg++/tests/tVec.inp create mode 100644 gnu/lib/libg++/libg++/tests/test_h.cc create mode 100644 gnu/lib/libg++/libg++/tests/tiLList.cc create mode 100644 gnu/lib/libg++/libg++/tests/tiLList.exp create mode 100644 gnu/lib/libg++/libg++/utils/.cvsignore create mode 100644 gnu/lib/libg++/libg++/utils/Makefile.in create mode 100644 gnu/lib/libg++/libg++/utils/configure.in create mode 100644 gnu/lib/libg++/libg++/utils/g++dep.sh create mode 100644 gnu/lib/libg++/libg++/utils/gendepend create mode 100644 gnu/lib/libg++/libg++/vms/AAAREADME.TXT create mode 100644 gnu/lib/libg++/libg++/vms/CXLINK.COM create mode 100644 gnu/lib/libg++/libg++/vms/CXSHARE.COM create mode 100644 gnu/lib/libg++/libg++/vms/EXPECTED.LIST create mode 100644 gnu/lib/libg++/libg++/vms/EXPECTED.VMS create mode 100644 gnu/lib/libg++/libg++/vms/FNDVEC.C create mode 100644 gnu/lib/libg++/libg++/vms/GENCLASS.COM create mode 100644 gnu/lib/libg++/libg++/vms/GENCLASS.TPU create mode 100644 gnu/lib/libg++/libg++/vms/GXX_MAIN_SHR.MAR create mode 100644 gnu/lib/libg++/libg++/vms/OPTIONS.OPT create mode 100644 gnu/lib/libg++/libg++/vms/VMS-BUILD-LIBGXX.COM create mode 100644 gnu/lib/libg++/libg++/vms/VMS-CURSES.C create mode 100644 gnu/lib/libg++/libg++/vms/VMS-GCCLIB.MAR create mode 100644 gnu/lib/libg++/libg++/vms/VMS-INSTALL-LIBGXX.COM create mode 100644 gnu/lib/libg++/libg++/vms/VMS-TEST-LIBGXX.COM create mode 100644 gnu/lib/libg++/libg++/vms/VMS_FIXINCLUDES.TPU create mode 100644 gnu/lib/libg++/libg++/vms/_G_config.h create mode 100644 gnu/lib/libg++/libiberty/COPYING.LIB create mode 100644 gnu/lib/libg++/libiberty/ChangeLog create mode 100644 gnu/lib/libg++/libiberty/Makefile.in create mode 100644 gnu/lib/libg++/libiberty/README create mode 100644 gnu/lib/libg++/libiberty/alloca-botch.h create mode 100644 gnu/lib/libg++/libiberty/alloca-norm.h create mode 100644 gnu/lib/libg++/libiberty/alloca.c create mode 100644 gnu/lib/libg++/libiberty/argv.c create mode 100644 gnu/lib/libg++/libiberty/basename.c create mode 100644 gnu/lib/libg++/libiberty/bcmp.c create mode 100644 gnu/lib/libg++/libiberty/bcopy.c create mode 100644 gnu/lib/libg++/libiberty/bzero.c create mode 100644 gnu/lib/libg++/libiberty/clock.c create mode 100644 gnu/lib/libg++/libiberty/concat.c create mode 100644 gnu/lib/libg++/libiberty/config.table create mode 100644 gnu/lib/libg++/libiberty/config/mh-a68bsd create mode 100644 gnu/lib/libg++/libiberty/config/mh-aix create mode 100644 gnu/lib/libg++/libiberty/config/mh-apollo68 create mode 100644 gnu/lib/libg++/libiberty/config/mh-cxux7 create mode 100644 gnu/lib/libg++/libiberty/config/mh-go32 create mode 100644 gnu/lib/libg++/libiberty/config/mh-hpbsd create mode 100644 gnu/lib/libg++/libiberty/config/mh-hpux create mode 100644 gnu/lib/libg++/libiberty/config/mh-i386win32 create mode 100644 gnu/lib/libg++/libiberty/config/mh-irix4 create mode 100644 gnu/lib/libg++/libiberty/config/mh-lynxos create mode 100644 gnu/lib/libg++/libiberty/config/mh-ncr3000 create mode 100644 gnu/lib/libg++/libiberty/config/mh-riscix create mode 100644 gnu/lib/libg++/libiberty/config/mh-sysv create mode 100644 gnu/lib/libg++/libiberty/config/mh-sysv4 create mode 100644 gnu/lib/libg++/libiberty/config/mt-sunos4 create mode 100644 gnu/lib/libg++/libiberty/config/mt-vxworks5 create mode 100644 gnu/lib/libg++/libiberty/configure.bat create mode 100644 gnu/lib/libg++/libiberty/configure.in create mode 100644 gnu/lib/libg++/libiberty/copysign.c create mode 100644 gnu/lib/libg++/libiberty/cplus-dem.c create mode 100644 gnu/lib/libg++/libiberty/dummy.c create mode 100644 gnu/lib/libg++/libiberty/fdmatch.c create mode 100644 gnu/lib/libg++/libiberty/floatformat.c create mode 100644 gnu/lib/libg++/libiberty/functions.def create mode 100644 gnu/lib/libg++/libiberty/getcwd.c create mode 100644 gnu/lib/libg++/libiberty/getopt.c create mode 100644 gnu/lib/libg++/libiberty/getopt1.c create mode 100644 gnu/lib/libg++/libiberty/getpagesize.c create mode 100644 gnu/lib/libg++/libiberty/getruntime.c create mode 100644 gnu/lib/libg++/libiberty/hex.c create mode 100644 gnu/lib/libg++/libiberty/index.c create mode 100644 gnu/lib/libg++/libiberty/insque.c create mode 100644 gnu/lib/libg++/libiberty/makefile.dos create mode 100644 gnu/lib/libg++/libiberty/memchr.c create mode 100644 gnu/lib/libg++/libiberty/memcmp.c create mode 100644 gnu/lib/libg++/libiberty/memcpy.c create mode 100644 gnu/lib/libg++/libiberty/memmove.c create mode 100644 gnu/lib/libg++/libiberty/memset.c create mode 100644 gnu/lib/libg++/libiberty/mpw-config.in create mode 100644 gnu/lib/libg++/libiberty/mpw-make.sed create mode 100644 gnu/lib/libg++/libiberty/mpw.c create mode 100644 gnu/lib/libg++/libiberty/msdos.c create mode 100644 gnu/lib/libg++/libiberty/obstack.c create mode 100644 gnu/lib/libg++/libiberty/random.c create mode 100644 gnu/lib/libg++/libiberty/rename.c create mode 100644 gnu/lib/libg++/libiberty/rindex.c create mode 100644 gnu/lib/libg++/libiberty/sigsetmask.c create mode 100644 gnu/lib/libg++/libiberty/spaces.c create mode 100644 gnu/lib/libg++/libiberty/strcasecmp.c create mode 100644 gnu/lib/libg++/libiberty/strchr.c create mode 100644 gnu/lib/libg++/libiberty/strdup.c create mode 100644 gnu/lib/libg++/libiberty/strerror.c create mode 100644 gnu/lib/libg++/libiberty/strncasecmp.c create mode 100644 gnu/lib/libg++/libiberty/strrchr.c create mode 100644 gnu/lib/libg++/libiberty/strsignal.c create mode 100644 gnu/lib/libg++/libiberty/strstr.c create mode 100644 gnu/lib/libg++/libiberty/strtod.c create mode 100644 gnu/lib/libg++/libiberty/strtol.c create mode 100644 gnu/lib/libg++/libiberty/strtoul.c create mode 100644 gnu/lib/libg++/libiberty/tmpnam.c create mode 100644 gnu/lib/libg++/libiberty/vasprintf.c create mode 100644 gnu/lib/libg++/libiberty/vfork.c create mode 100644 gnu/lib/libg++/libiberty/vfprintf.c create mode 100644 gnu/lib/libg++/libiberty/vmsbuild.com create mode 100644 gnu/lib/libg++/libiberty/vprintf.c create mode 100644 gnu/lib/libg++/libiberty/vsprintf.c create mode 100644 gnu/lib/libg++/libiberty/waitpid.c create mode 100644 gnu/lib/libg++/libiberty/win32.c create mode 100644 gnu/lib/libg++/libiberty/xatexit.c create mode 100644 gnu/lib/libg++/libiberty/xexit.c create mode 100644 gnu/lib/libg++/libiberty/xmalloc.c create mode 100644 gnu/lib/libg++/libiberty/xstrerror.c create mode 100644 gnu/lib/libg++/libio/ChangeLog create mode 100644 gnu/lib/libg++/libio/Makefile.in create mode 100644 gnu/lib/libg++/libio/NEWS create mode 100644 gnu/lib/libg++/libio/PlotFile.cc create mode 100644 gnu/lib/libg++/libio/PlotFile.h create mode 100644 gnu/lib/libg++/libio/README create mode 100644 gnu/lib/libg++/libio/SFile.cc create mode 100644 gnu/lib/libg++/libio/SFile.h create mode 100644 gnu/lib/libg++/libio/builtinbuf.cc create mode 100644 gnu/lib/libg++/libio/builtinbuf.h create mode 100644 gnu/lib/libg++/libio/cleanup.c create mode 100644 gnu/lib/libg++/libio/config.shared create mode 100644 gnu/lib/libg++/libio/config/hpux.mt create mode 100644 gnu/lib/libg++/libio/config/isc.mt create mode 100644 gnu/lib/libg++/libio/config/linux.mt create mode 100644 gnu/lib/libg++/libio/config/netware.mt create mode 100644 gnu/lib/libg++/libio/config/sco4.mt create mode 100644 gnu/lib/libg++/libio/configure.in create mode 100644 gnu/lib/libg++/libio/dbz/Makefile.in create mode 100644 gnu/lib/libg++/libio/dbz/README create mode 100644 gnu/lib/libg++/libio/dbz/altbytes create mode 100644 gnu/lib/libg++/libio/dbz/byteflip.c create mode 100644 gnu/lib/libg++/libio/dbz/case.c create mode 100644 gnu/lib/libg++/libio/dbz/case.h create mode 100644 gnu/lib/libg++/libio/dbz/configure.in create mode 100644 gnu/lib/libg++/libio/dbz/dbz.1 create mode 100644 gnu/lib/libg++/libio/dbz/dbz.3z create mode 100644 gnu/lib/libg++/libio/dbz/dbz.c create mode 100644 gnu/lib/libg++/libio/dbz/dbz.h create mode 100644 gnu/lib/libg++/libio/dbz/dbzmain.c create mode 100644 gnu/lib/libg++/libio/dbz/fake.c create mode 100644 gnu/lib/libg++/libio/dbz/firstlast25 create mode 100644 gnu/lib/libg++/libio/dbz/getmap create mode 100644 gnu/lib/libg++/libio/dbz/random.c create mode 100644 gnu/lib/libg++/libio/dbz/revbytes create mode 100644 gnu/lib/libg++/libio/dbz/stdio.h create mode 100644 gnu/lib/libg++/libio/depend create mode 100644 gnu/lib/libg++/libio/editbuf.cc create mode 100644 gnu/lib/libg++/libio/editbuf.h create mode 100644 gnu/lib/libg++/libio/filebuf.cc create mode 100644 gnu/lib/libg++/libio/filedoalloc.c create mode 100644 gnu/lib/libg++/libio/fileops.c create mode 100644 gnu/lib/libg++/libio/floatconv.c create mode 100644 gnu/lib/libg++/libio/floatio.h create mode 100644 gnu/lib/libg++/libio/fstream.cc create mode 100644 gnu/lib/libg++/libio/fstream.h create mode 100644 gnu/lib/libg++/libio/gen-params create mode 100644 gnu/lib/libg++/libio/genops.c create mode 100644 gnu/lib/libg++/libio/indstream.cc create mode 100644 gnu/lib/libg++/libio/indstream.h create mode 100644 gnu/lib/libg++/libio/ioassign.cc create mode 100644 gnu/lib/libg++/libio/ioextend.cc create mode 100644 gnu/lib/libg++/libio/iofclose.c create mode 100644 gnu/lib/libg++/libio/iofdopen.c create mode 100644 gnu/lib/libg++/libio/iofflush.c create mode 100644 gnu/lib/libg++/libio/iofgetpos.c create mode 100644 gnu/lib/libg++/libio/iofgets.c create mode 100644 gnu/lib/libg++/libio/iofopen.c create mode 100644 gnu/lib/libg++/libio/iofprintf.c create mode 100644 gnu/lib/libg++/libio/iofputs.c create mode 100644 gnu/lib/libg++/libio/iofread.c create mode 100644 gnu/lib/libg++/libio/iofscanf.c create mode 100644 gnu/lib/libg++/libio/iofsetpos.c create mode 100644 gnu/lib/libg++/libio/ioftell.c create mode 100644 gnu/lib/libg++/libio/iofwrite.c create mode 100644 gnu/lib/libg++/libio/iogetdelim.c create mode 100644 gnu/lib/libg++/libio/iogetline.c create mode 100644 gnu/lib/libg++/libio/iogets.c create mode 100644 gnu/lib/libg++/libio/ioignore.c create mode 100644 gnu/lib/libg++/libio/iolibio.h create mode 100644 gnu/lib/libg++/libio/iomanip.cc create mode 100644 gnu/lib/libg++/libio/iomanip.h create mode 100644 gnu/lib/libg++/libio/iopadn.c create mode 100644 gnu/lib/libg++/libio/ioperror.c create mode 100644 gnu/lib/libg++/libio/iopopen.c create mode 100644 gnu/lib/libg++/libio/ioprims.c create mode 100644 gnu/lib/libg++/libio/ioprintf.c create mode 100644 gnu/lib/libg++/libio/ioputs.c create mode 100644 gnu/lib/libg++/libio/ioscanf.c create mode 100644 gnu/lib/libg++/libio/ioseekoff.c create mode 100644 gnu/lib/libg++/libio/ioseekpos.c create mode 100644 gnu/lib/libg++/libio/iosetbuffer.c create mode 100644 gnu/lib/libg++/libio/iosetvbuf.c create mode 100644 gnu/lib/libg++/libio/iosprintf.c create mode 100644 gnu/lib/libg++/libio/iosscanf.c create mode 100644 gnu/lib/libg++/libio/iostdio.h create mode 100644 gnu/lib/libg++/libio/iostream.cc create mode 100644 gnu/lib/libg++/libio/iostream.h create mode 100644 gnu/lib/libg++/libio/iostream.info create mode 100644 gnu/lib/libg++/libio/iostream.info-1 create mode 100644 gnu/lib/libg++/libio/iostream.info-2 create mode 100644 gnu/lib/libg++/libio/iostream.texi create mode 100644 gnu/lib/libg++/libio/iostreamP.h create mode 100644 gnu/lib/libg++/libio/iostrerror.c create mode 100644 gnu/lib/libg++/libio/ioungetc.c create mode 100644 gnu/lib/libg++/libio/iovfprintf.c create mode 100644 gnu/lib/libg++/libio/iovfscanf.c create mode 100644 gnu/lib/libg++/libio/iovsprintf.c create mode 100644 gnu/lib/libg++/libio/iovsscanf.c create mode 100644 gnu/lib/libg++/libio/isgetline.cc create mode 100644 gnu/lib/libg++/libio/isgetsb.cc create mode 100644 gnu/lib/libg++/libio/isscan.cc create mode 100644 gnu/lib/libg++/libio/istream.h create mode 100644 gnu/lib/libg++/libio/libio.h create mode 100644 gnu/lib/libg++/libio/libioP.h create mode 100644 gnu/lib/libg++/libio/osform.cc create mode 100644 gnu/lib/libg++/libio/ostream.h create mode 100644 gnu/lib/libg++/libio/outfloat.c create mode 100644 gnu/lib/libg++/libio/parsestream.cc create mode 100644 gnu/lib/libg++/libio/parsestream.h create mode 100644 gnu/lib/libg++/libio/pfstream.cc create mode 100644 gnu/lib/libg++/libio/pfstream.h create mode 100644 gnu/lib/libg++/libio/procbuf.cc create mode 100644 gnu/lib/libg++/libio/procbuf.h create mode 100644 gnu/lib/libg++/libio/sbform.cc create mode 100644 gnu/lib/libg++/libio/sbgetline.cc create mode 100644 gnu/lib/libg++/libio/sbscan.cc create mode 100644 gnu/lib/libg++/libio/stdfiles.c create mode 100644 gnu/lib/libg++/libio/stdio/ChangeLog create mode 100644 gnu/lib/libg++/libio/stdio/Makefile.in create mode 100644 gnu/lib/libg++/libio/stdio/clearerr.c create mode 100644 gnu/lib/libg++/libio/stdio/configure.in create mode 100644 gnu/lib/libg++/libio/stdio/fdopen.c create mode 100644 gnu/lib/libg++/libio/stdio/feof.c create mode 100644 gnu/lib/libg++/libio/stdio/ferror.c create mode 100644 gnu/lib/libg++/libio/stdio/fgetc.c create mode 100644 gnu/lib/libg++/libio/stdio/fileno.c create mode 100644 gnu/lib/libg++/libio/stdio/fputc.c create mode 100644 gnu/lib/libg++/libio/stdio/freopen.c create mode 100644 gnu/lib/libg++/libio/stdio/fseek.c create mode 100644 gnu/lib/libg++/libio/stdio/getc.c create mode 100644 gnu/lib/libg++/libio/stdio/getchar.c create mode 100644 gnu/lib/libg++/libio/stdio/getline.c create mode 100644 gnu/lib/libg++/libio/stdio/getw.c create mode 100644 gnu/lib/libg++/libio/stdio/popen.c create mode 100644 gnu/lib/libg++/libio/stdio/putc.c create mode 100644 gnu/lib/libg++/libio/stdio/putchar.c create mode 100644 gnu/lib/libg++/libio/stdio/putw.c create mode 100644 gnu/lib/libg++/libio/stdio/rewind.c create mode 100644 gnu/lib/libg++/libio/stdio/setbuf.c create mode 100644 gnu/lib/libg++/libio/stdio/setfileno.c create mode 100644 gnu/lib/libg++/libio/stdio/setlinebuf.c create mode 100644 gnu/lib/libg++/libio/stdio/snprintf.c create mode 100644 gnu/lib/libg++/libio/stdio/stdio.h create mode 100644 gnu/lib/libg++/libio/stdio/vfprintf.c create mode 100644 gnu/lib/libg++/libio/stdio/vfscanf.c create mode 100644 gnu/lib/libg++/libio/stdio/vprintf.c create mode 100644 gnu/lib/libg++/libio/stdio/vscanf.c create mode 100644 gnu/lib/libg++/libio/stdio/vsnprintf.c create mode 100644 gnu/lib/libg++/libio/stdiostream.cc create mode 100644 gnu/lib/libg++/libio/stdiostream.h create mode 100644 gnu/lib/libg++/libio/stdstrbufs.cc create mode 100644 gnu/lib/libg++/libio/stdstreams.cc create mode 100644 gnu/lib/libg++/libio/stream.cc create mode 100644 gnu/lib/libg++/libio/stream.h create mode 100644 gnu/lib/libg++/libio/streambuf.cc create mode 100644 gnu/lib/libg++/libio/streambuf.h create mode 100644 gnu/lib/libg++/libio/strfile.h create mode 100644 gnu/lib/libg++/libio/strops.c create mode 100644 gnu/lib/libg++/libio/strstream.cc create mode 100644 gnu/lib/libg++/libio/strstream.h create mode 100644 gnu/lib/libg++/libio/tests/ChangeLog create mode 100644 gnu/lib/libg++/libio/tests/Makefile.in create mode 100644 gnu/lib/libg++/libio/tests/configure.in create mode 100644 gnu/lib/libg++/libio/tests/hounddog.cc create mode 100644 gnu/lib/libg++/libio/tests/hounddog.exp create mode 100644 gnu/lib/libg++/libio/tests/hounddog.inp create mode 100644 gnu/lib/libg++/libio/tests/putbackdog.cc create mode 100644 gnu/lib/libg++/libio/tests/tFile.cc create mode 100644 gnu/lib/libg++/libio/tests/tFile.exp create mode 100644 gnu/lib/libg++/libio/tests/tFile.inp create mode 100644 gnu/lib/libg++/libio/tests/tfformat.c create mode 100644 gnu/lib/libg++/libio/tests/tiformat.c create mode 100644 gnu/lib/libg++/libio/tests/tiomanip.cc create mode 100644 gnu/lib/libg++/libio/tests/tiomanip.exp create mode 100644 gnu/lib/libg++/libio/tests/tiomisc.cc create mode 100644 gnu/lib/libg++/libio/tests/tiomisc.exp create mode 100644 gnu/lib/libg++/libio/tests/tstdiomisc.c create mode 100644 gnu/lib/libg++/libio/tests/tstdiomisc.exp create mode 100644 gnu/lib/libg++/librx/COPYING.LIB create mode 100644 gnu/lib/libg++/librx/ChangeLog create mode 100644 gnu/lib/libg++/librx/DOC create mode 100644 gnu/lib/libg++/librx/INSTALL create mode 100644 gnu/lib/libg++/librx/INSTALL.rx create mode 100644 gnu/lib/libg++/librx/Makefile.in create mode 100644 gnu/lib/libg++/librx/configure create mode 100644 gnu/lib/libg++/librx/configure.in create mode 100644 gnu/lib/libg++/librx/rx.c create mode 100644 gnu/lib/libg++/librx/rx.h create mode 100644 gnu/lib/libg++/libstdc++/ChangeLog create mode 100644 gnu/lib/libg++/libstdc++/Make.pack create mode 100644 gnu/lib/libg++/libstdc++/Makefile.in create mode 100644 gnu/lib/libg++/libstdc++/algorithm create mode 100644 gnu/lib/libg++/libstdc++/cassert create mode 100644 gnu/lib/libg++/libstdc++/cctype create mode 100644 gnu/lib/libg++/libstdc++/cerrno create mode 100644 gnu/lib/libg++/libstdc++/cfloat create mode 100644 gnu/lib/libg++/libstdc++/cinst.cc create mode 100644 gnu/lib/libg++/libstdc++/ciso646 create mode 100644 gnu/lib/libg++/libstdc++/climits create mode 100644 gnu/lib/libg++/libstdc++/clocale create mode 100644 gnu/lib/libg++/libstdc++/cmath create mode 100644 gnu/lib/libg++/libstdc++/cmathi.cc create mode 100644 gnu/lib/libg++/libstdc++/complex create mode 100644 gnu/lib/libg++/libstdc++/complex.h create mode 100644 gnu/lib/libg++/libstdc++/config/aix.ml create mode 100644 gnu/lib/libg++/libstdc++/config/dec-osf.ml create mode 100644 gnu/lib/libg++/libstdc++/config/elf.ml create mode 100644 gnu/lib/libg++/libstdc++/config/elfshlibm.ml create mode 100644 gnu/lib/libg++/libstdc++/config/hpux.ml create mode 100644 gnu/lib/libg++/libstdc++/config/irix5.ml create mode 100644 gnu/lib/libg++/libstdc++/config/linux.ml create mode 100644 gnu/lib/libg++/libstdc++/config/sol2shm.ml create mode 100644 gnu/lib/libg++/libstdc++/config/sunos4.ml create mode 100644 gnu/lib/libg++/libstdc++/configure.in create mode 100644 gnu/lib/libg++/libstdc++/csetjmp create mode 100644 gnu/lib/libg++/libstdc++/csignal create mode 100644 gnu/lib/libg++/libstdc++/cstdarg create mode 100644 gnu/lib/libg++/libstdc++/cstddef create mode 100644 gnu/lib/libg++/libstdc++/cstdio create mode 100644 gnu/lib/libg++/libstdc++/cstdlib create mode 100644 gnu/lib/libg++/libstdc++/cstdlibi.cc create mode 100644 gnu/lib/libg++/libstdc++/cstring create mode 100644 gnu/lib/libg++/libstdc++/cstringi.cc create mode 100644 gnu/lib/libg++/libstdc++/ctime create mode 100644 gnu/lib/libg++/libstdc++/cwchar create mode 100644 gnu/lib/libg++/libstdc++/cwctype create mode 100644 gnu/lib/libg++/libstdc++/deque create mode 100644 gnu/lib/libg++/libstdc++/exception create mode 100644 gnu/lib/libg++/libstdc++/exceptioni.cc create mode 100644 gnu/lib/libg++/libstdc++/functional create mode 100644 gnu/lib/libg++/libstdc++/iterator create mode 100644 gnu/lib/libg++/libstdc++/list create mode 100644 gnu/lib/libg++/libstdc++/map create mode 100644 gnu/lib/libg++/libstdc++/memory create mode 100644 gnu/lib/libg++/libstdc++/new create mode 100644 gnu/lib/libg++/libstdc++/new.h create mode 100644 gnu/lib/libg++/libstdc++/newi.cc create mode 100644 gnu/lib/libg++/libstdc++/numeric create mode 100644 gnu/lib/libg++/libstdc++/queue create mode 100644 gnu/lib/libg++/libstdc++/set create mode 100644 gnu/lib/libg++/libstdc++/sinst.cc create mode 100644 gnu/lib/libg++/libstdc++/stack create mode 100644 gnu/lib/libg++/libstdc++/std/bastring.cc create mode 100644 gnu/lib/libg++/libstdc++/std/bastring.h create mode 100644 gnu/lib/libg++/libstdc++/std/cassert.h create mode 100644 gnu/lib/libg++/libstdc++/std/cctype.h create mode 100644 gnu/lib/libg++/libstdc++/std/cerrno.h create mode 100644 gnu/lib/libg++/libstdc++/std/cfloat.h create mode 100644 gnu/lib/libg++/libstdc++/std/cinst.h create mode 100644 gnu/lib/libg++/libstdc++/std/ciso646.h create mode 100644 gnu/lib/libg++/libstdc++/std/climits.h create mode 100644 gnu/lib/libg++/libstdc++/std/clocale.h create mode 100644 gnu/lib/libg++/libstdc++/std/cmath.h create mode 100644 gnu/lib/libg++/libstdc++/std/complex.h create mode 100644 gnu/lib/libg++/libstdc++/std/complext.cc create mode 100644 gnu/lib/libg++/libstdc++/std/complext.h create mode 100644 gnu/lib/libg++/libstdc++/std/csetjmp.h create mode 100644 gnu/lib/libg++/libstdc++/std/csignal.h create mode 100644 gnu/lib/libg++/libstdc++/std/cstdarg.h create mode 100644 gnu/lib/libg++/libstdc++/std/cstddef.h create mode 100644 gnu/lib/libg++/libstdc++/std/cstdio.h create mode 100644 gnu/lib/libg++/libstdc++/std/cstdlib.h create mode 100644 gnu/lib/libg++/libstdc++/std/cstring.h create mode 100644 gnu/lib/libg++/libstdc++/std/ctime.h create mode 100644 gnu/lib/libg++/libstdc++/std/cwchar.h create mode 100644 gnu/lib/libg++/libstdc++/std/cwctype.h create mode 100644 gnu/lib/libg++/libstdc++/std/dcomplex.h create mode 100644 gnu/lib/libg++/libstdc++/std/exception.h create mode 100644 gnu/lib/libg++/libstdc++/std/fcomplex.h create mode 100644 gnu/lib/libg++/libstdc++/std/ldcomplex.h create mode 100644 gnu/lib/libg++/libstdc++/std/new.h create mode 100644 gnu/lib/libg++/libstdc++/std/sinst.h create mode 100644 gnu/lib/libg++/libstdc++/std/stddef.h create mode 100644 gnu/lib/libg++/libstdc++/std/stdexcept.h create mode 100644 gnu/lib/libg++/libstdc++/std/straits.h create mode 100644 gnu/lib/libg++/libstdc++/std/string.h create mode 100644 gnu/lib/libg++/libstdc++/std/typeinfo.h create mode 100644 gnu/lib/libg++/libstdc++/stddef create mode 100644 gnu/lib/libg++/libstdc++/stddefi.cc create mode 100644 gnu/lib/libg++/libstdc++/stdexcept create mode 100644 gnu/lib/libg++/libstdc++/stdexcepti.cc create mode 100644 gnu/lib/libg++/libstdc++/stl.h create mode 100644 gnu/lib/libg++/libstdc++/stl/ChangeLog create mode 100644 gnu/lib/libg++/libstdc++/stl/Makefile.in create mode 100644 gnu/lib/libg++/libstdc++/stl/README create mode 100644 gnu/lib/libg++/libstdc++/stl/algo.h create mode 100644 gnu/lib/libg++/libstdc++/stl/algobase.h create mode 100644 gnu/lib/libg++/libstdc++/stl/bool.h create mode 100644 gnu/lib/libg++/libstdc++/stl/bvector.h create mode 100644 gnu/lib/libg++/libstdc++/stl/configure.in create mode 100644 gnu/lib/libg++/libstdc++/stl/defalloc.h create mode 100644 gnu/lib/libg++/libstdc++/stl/deque.h create mode 100644 gnu/lib/libg++/libstdc++/stl/faralloc.h create mode 100644 gnu/lib/libg++/libstdc++/stl/fdeque.h create mode 100644 gnu/lib/libg++/libstdc++/stl/flist.h create mode 100644 gnu/lib/libg++/libstdc++/stl/fmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/fmultmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/fmultset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/fset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/function.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hdeque.h create mode 100644 gnu/lib/libg++/libstdc++/stl/heap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hlist.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hmultmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hmultset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hugalloc.h create mode 100644 gnu/lib/libg++/libstdc++/stl/hvector.h create mode 100644 gnu/lib/libg++/libstdc++/stl/iterator.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lbvector.h create mode 100644 gnu/lib/libg++/libstdc++/stl/ldeque.h create mode 100644 gnu/lib/libg++/libstdc++/stl/list.h create mode 100644 gnu/lib/libg++/libstdc++/stl/llist.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lmultmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lmultset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lngalloc.h create mode 100644 gnu/lib/libg++/libstdc++/stl/lset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/map.h create mode 100644 gnu/lib/libg++/libstdc++/stl/multimap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/multiset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/neralloc.h create mode 100644 gnu/lib/libg++/libstdc++/stl/nmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/nmultmap.h create mode 100644 gnu/lib/libg++/libstdc++/stl/nmultset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/nset.h create mode 100644 gnu/lib/libg++/libstdc++/stl/pair.h create mode 100644 gnu/lib/libg++/libstdc++/stl/projectn.h create mode 100644 gnu/lib/libg++/libstdc++/stl/random.cc create mode 100644 gnu/lib/libg++/libstdc++/stl/set.h create mode 100644 gnu/lib/libg++/libstdc++/stl/stack.h create mode 100644 gnu/lib/libg++/libstdc++/stl/tempbuf.cc create mode 100644 gnu/lib/libg++/libstdc++/stl/tempbuf.h create mode 100644 gnu/lib/libg++/libstdc++/stl/tree.cc create mode 100644 gnu/lib/libg++/libstdc++/stl/tree.h create mode 100644 gnu/lib/libg++/libstdc++/stl/vector.h create mode 100644 gnu/lib/libg++/libstdc++/string create mode 100644 gnu/lib/libg++/libstdc++/tests/ChangeLog create mode 100644 gnu/lib/libg++/libstdc++/tests/Makefile.in create mode 100644 gnu/lib/libg++/libstdc++/tests/configure.in create mode 100644 gnu/lib/libg++/libstdc++/tests/tcomplex.cc create mode 100644 gnu/lib/libg++/libstdc++/tests/tcomplex.exp create mode 100644 gnu/lib/libg++/libstdc++/tests/tcomplex.inp create mode 100644 gnu/lib/libg++/libstdc++/tests/tlist.cc create mode 100644 gnu/lib/libg++/libstdc++/tests/tlist.exp create mode 100644 gnu/lib/libg++/libstdc++/tests/tmap.cc create mode 100644 gnu/lib/libg++/libstdc++/tests/tmap.exp create mode 100644 gnu/lib/libg++/libstdc++/tests/tstring.cc create mode 100644 gnu/lib/libg++/libstdc++/tests/tstring.exp create mode 100644 gnu/lib/libg++/libstdc++/tests/tstring.inp create mode 100644 gnu/lib/libg++/libstdc++/tests/tvector.cc create mode 100644 gnu/lib/libg++/libstdc++/tests/tvector.exp create mode 100644 gnu/lib/libg++/libstdc++/typeinfo create mode 100644 gnu/lib/libg++/libstdc++/typeinfoi.cc create mode 100644 gnu/lib/libg++/libstdc++/utility create mode 100644 gnu/lib/libg++/libstdc++/vector create mode 100644 gnu/lib/libg++/move-if-change create mode 100644 gnu/lib/libg++/mpw-README create mode 100644 gnu/lib/libg++/mpw-build.in create mode 100644 gnu/lib/libg++/mpw-config.in create mode 100644 gnu/lib/libg++/mpw-configure create mode 100644 gnu/lib/libg++/texinfo/gpl.texinfo create mode 100644 gnu/lib/libg++/texinfo/lgpl.texinfo create mode 100644 gnu/lib/libg++/texinfo/tex3patch create mode 100644 gnu/lib/libg++/texinfo/texinfo.tex diff --git a/gnu/lib/libg++/COPYING.LIB b/gnu/lib/libg++/COPYING.LIB new file mode 100644 index 00000000000..eb685a5ec98 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/Makefile.in b/gnu/lib/libg++/Makefile.in new file mode 100644 index 00000000000..fdedd3ae715 --- /dev/null +++ b/gnu/lib/libg++/Makefile.in @@ -0,0 +1,1259 @@ +# +# Makefile for directory with subdirs to build. +# Copyright (C) 1990, 1991, 1992, 1993 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)/lib +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 +docdir = $(datadir)/doc +GDB_NLM_DEPS = + +SHELL = /bin/sh + +INSTALL = $${srcroot}/install.sh -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 +INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)' + +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- + +# We don't specify -g -O because many compilers don't support -g -O, +# and/or -O is broken in and of itself. +CFLAGS = -g +LIBCFLAGS = $(CFLAGS) +CFLAGS_FOR_TARGET = $(CFLAGS) +LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET) +PICFLAG = +PICFLAG_FOR_TARGET = + +CXX = gcc + +# Use -O2 to stress test the compiler. +CXXFLAGS = -g -O2 +LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates +CXXFLAGS_FOR_TARGET = $(CXXFLAGS) +LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates + +RANLIB = ranlib +NM = nm +# Not plain GZIP, since gzip looks there for extra command-line options. +GZIPPROG = gzip + +BISON = bison -y +LEX = `if [ -f $$r/flex/flex ] ; \ + then echo $$r/flex/flex ; \ + else echo flex ; fi` + +M4 = `if [ -f $$r/m4/m4 ] ; \ + then echo $$r/m4/m4 ; \ + else echo m4 ; fi` + +MAKEINFO = `if [ -f $$r/texinfo/makeinfo/makeinfo ] ; \ + 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 $${srcroot}/dejagnu/runtest ] ; \ + then echo $${srcroot}/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: +TARGET_SUBDIR = . # Changed by configure to $(target_alias) if cross. + +# This is set by the configure script to the arguments passed to configure. +CONFIG_ARGUMENTS = + +ALL = all.normal +INSTALL_TARGET = install-dirs \ + $(INSTALL_MODULES) \ + $(INSTALL_TARGET_MODULES) \ + $(INSTALL_X11_MODULES) \ + install-gcc \ + $(INSTALL_DOSREL) + + +CC_FOR_TARGET = ` \ + if [ -f $$r/gcc/Makefile ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $${srcroot}/newlib/libc/include -nostdinc; \ + 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` + + +CXX_FOR_TARGET = ` \ + if [ -f $$r/gcc/Makefile ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $${srcroot}/newlib/libc/include -nostdinc; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/; \ + fi; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(CXX); \ + else \ + t='$(program_transform_name)'; echo gcc | 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` + +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)" \ + "GCC_FOR_TARGET=$(CC_FOR_TARGET)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "INSTALL_XFORM=$(INSTALL_XFORM)" \ + "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)" \ + "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)" \ + "YACC=$(BISON)" \ + "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)' \ + 'NM=$(NM)' \ + 'RANLIB=$(RANLIB)' + +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)' + +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)' \ + 'HOST_CC=$(CC_FOR_BUILD)' \ + 'HOST_PREFIX=$(HOST_PREFIX)' \ + 'HOST_PREFIX_1=$(HOST_PREFIX_1)' \ + 'NM=$(NM)' \ + 'RANLIB=$$(RANLIB_FOR_TARGET)' + +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-autoconf \ + all-bfd \ + all-binutils \ + all-byacc \ + all-cvs \ + all-dejagnu \ + all-diff \ + all-dosutils \ + all-etc \ + all-fileutils \ + all-find \ + all-flex \ + all-gas \ + all-gawk \ + all-gprof \ + all-grep \ + all-gzip \ + all-hello \ + all-indent \ + all-ispell \ + all-ld \ + all-libiberty \ + all-m4 \ + all-make \ + all-mmalloc \ + all-opcodes \ + all-patch \ + all-prms \ + all-rcs \ + all-readline \ + all-release \ + all-recode \ + all-sed \ + all-send-pr \ + all-shellutils \ + all-sim \ + 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). +# 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-byacc \ + check-flex + +CROSS_CHECK_MODULES = \ + check-autoconf \ + check-bfd \ + check-binutils \ + check-cvs \ + check-dejagnu \ + check-diff \ + check-etc \ + check-fileutils \ + check-find \ + check-gas \ + check-gawk \ + check-gprof \ + check-grep \ + check-gzip \ + check-hello \ + check-indent \ + check-ispell \ + check-ld \ + check-libiberty \ + check-m4 \ + check-make \ + check-mmcheckoc \ + check-opcodes \ + check-patch \ + check-prms \ + check-rcs \ + check-readline \ + check-recode \ + check-sed \ + check-send-pr \ + check-shellutils \ + 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). +INSTALL_MODULES = \ + install-autoconf \ + install-bfd \ + install-binutils \ + install-byacc \ + install-cvs \ + install-dejagnu \ + install-diff \ + install-dosutils \ + install-etc \ + install-fileutils \ + install-find \ + install-flex \ + install-gas \ + install-gawk \ + install-gprof \ + install-grep \ + install-gzip \ + install-hello \ + install-indent \ + install-ispell \ + install-ld \ + install-libiberty \ + install-m4 \ + install-make \ + install-mmalloc \ + install-opcodes \ + install-patch \ + install-prms \ + install-rcs \ + install-readline \ + install-recode \ + install-sed \ + install-send-pr \ + install-shellutils \ + install-sim \ + install-tar \ + install-tcl \ + 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-tclX \ + all-tk + +# 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-expect \ + check-gash \ + check-tclX \ + check-tk + +# 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-expect \ + install-gash \ + install-tclX \ + install-tk + +# 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 + +# 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 + +# 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 + +# 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 + +# 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_TARGET_MODULES) \ + $(ALL_X11_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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + 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 NM RANLIB; \ + if (cd ./$$i; \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + $${target}); \ + then true; else exit 1; fi; \ + else true; fi; \ + done + @target=`echo $@ | sed -e 's/^do-//'`; \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + 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 NM RANLIB; \ + if (cd $(TARGET_SUBDIR)/$$i; \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + $${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 + +install-info: do-install-info dir.info + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + 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 + +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 + +# 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 ; \ + (cd ./gcc; \ + $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \ + else \ + true ; \ + fi + +# install-no-fixedincludes is used because Cygnus can not distribute +# the fixed header files. +.PHONY: install-no-fixedincludes +install-no-fixedincludes: \ + install-dirs \ + $(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; \ + srcroot=`cd $(srcdir); pwd` ; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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): install-dirs + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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 [ -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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + 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; \ + LD="$(LD_FOR_TARGET)"; export LD; \ + NM="$(NM_FOR_TARGET)"; export NM; \ + RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \ + echo Configuring in $(TARGET_SUBDIR)/$${dir}; \ + cd $(TARGET_SUBDIR)/$${dir}; \ + if [ -f $${srcroot}/$${dir}/configure ] ; then \ + $${srcroot}/$${dir}/configure \ + $(CONFIG_ARGUMENTS) --srcdir=$${srcroot}/$${dir}; \ + else \ + $${srcroot}/configure \ + $(CONFIG_ARGUMENTS) --srcdir=$${srcroot}/$${dir}; \ + 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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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): install-dirs + @dir=`echo $@ | sed -e 's/install-target-//'`; \ + if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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): + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) all); \ + else \ + true; \ + fi + +.PHONY: check-gcc +check-gcc: + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (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: install-dirs info + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + srcroot=`cd $(srcdir); pwd`; export srcroot; \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + +install-dosrel-fake: + + +# This is a list of inter-dependencies among modules. +all-autoconf: all-m4 +all-bfd: +all-binutils: all-libiberty all-opcodes all-bfd all-flex all-byacc +all-byacc: +all-cvs: +all-dejagnu: all-tcl all-expect all-tk +all-diff: all-libiberty +all-emacs: +all-emacs19: all-byacc +all-etc: +all-expect: all-tcl all-tk +all-fileutils: all-libiberty +all-find: +all-flex: all-libiberty all-byacc +all-gas: all-libiberty all-opcodes all-bfd +all-gash: all-tcl +all-gawk: +ALL_GCC = all-gcc +all-gcc: all-libiberty all-byacc all-binutils all-gas all-ld +all-gdb: all-libiberty all-opcodes all-bfd all-mmalloc all-readline all-byacc all-sim $(gdbnlmrequirements) +all-gprof: all-libiberty all-bfd +all-grep: all-libiberty +all-gui: all-gdb all-libproc all-target-librx +all-gzip: all-libiberty +all-hello: all-libiberty +all-indent: +all-ispell: all-emacs19 +all-ld: all-libiberty all-bfd all-byacc all-flex +configure-target-libg++: $(ALL_GCC) +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-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-patch: all-libiberty +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-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-time: +all-wdiff: +all-target-winsup: all-target-newlib 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 + +### other supporting targets + +MAKEDIRS= \ + $(prefix) \ + $(exec_prefix) \ + $(tooldir) + +.PHONY: install-dirs +install-dirs: + @for i in $(MAKEDIRS) ; do \ + echo Making $$i... ; \ + parent=`echo $$i | sed -e 's@/[^/]*$$@@' | sed -e 's@^$$@/@'`; \ + if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi ; \ + if [ ! -d $$i ] ; then \ + if mkdir $$i ; then \ + true ; \ + else \ + exit 1 ; \ + fi ; \ + else \ + true ; \ + fi ; \ + done + + +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 \ + COPYING COPYING.LIB install.sh cfg-ml-com.in cfg-ml-pos.in + +# 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 cfg-paper.texi configure.in configure.man \ + configure.texi standards.texi make-stds.texi \ + configure.info* standards.info* cfg-paper.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 +# Files where "byacc" (Cygnus version) should be changed to "bison -y" (FSF). +DISTBISONFILES= binutils/Makefile.in gas/Makefile.in gdb/Makefile.in + +.PHONY: taz + +taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \ + texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo + # Make sure "diststuff" files get built properly. + for f in $(DISTBISONFILES) ; do \ + if [ -r $$f ]; then \ + sed '/^BISON *=.*$$/s/.*/BISON = bison -y/' <$$f >tmp ; \ + mv -f tmp $$f ; \ + else true; fi ; \ + done + # Take out texinfo from a few places; make simple BISON=bison line. + sed -e '/^all\.normal: /s/\all-texinfo //' \ + -e '/^ install-texinfo /d' \ + -e '/^BISON = /,/^$$/d' \ + -e '/^# BISON:/s/.*/BISON = bison -y/' \ + 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/ + ln -s ../../texinfo/tex3patch proto-toplev/texinfo/ + chmod og=u `find . -print` + (VER=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \ + echo "==> Making $(TOOL)-$$VER.tar.gz"; \ + rm -f $(TOOL)-$$VER; ln -s proto-toplev $(TOOL)-$$VER; \ + tar cfh - $(TOOL)-$$VER \ + | $(GZIPPROG) -v -9 >$(TOOL)-$$VER.tar.gz ) + +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 +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 +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). +# Compensate here by configuring newlib for a simple (no multilib support) +# cross target (sparc64), building the info files, and doing make distclean +# ourselves. +newlib.tar.gz: $(DIST_SUPPORT) $(NEWLIB_SUPPORT_DIRS) newlib + rootme=`pwd` ; \ + cd newlib && ../configure --srcdir $$rootme/newlib \ + --host sun4 --target sparc64-elf + cd newlib ; make info + cd newlib ; make distclean + $(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/gnu/lib/libg++/README b/gnu/lib/libg++/README new file mode 100644 index 00000000000..622a5be4309 --- /dev/null +++ b/gnu/lib/libg++/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 gas release, see gas/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 + +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 CC=gcc + +A similar example using csh: + + setenv CC gcc + ./configure + make CC=gcc + +See etc/cfg-paper.texi, etc/configure.texi, and/or the README files in +various subdirectories, for more details. + +Much of the code and documentation enclosed, and this file, is +copyright 1993 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, gas/README, etc., for info on where and +how to report problems. diff --git a/gnu/lib/libg++/cfg-ml-com.in b/gnu/lib/libg++/cfg-ml-com.in new file mode 100644 index 00000000000..4d9218f23cd --- /dev/null +++ b/gnu/lib/libg++/cfg-ml-com.in @@ -0,0 +1,419 @@ +# Configure fragment invoked in the common section for subdirs +# wanting multilib support. +# +# The common section was chosen because xiberty clobbers $srcdir in the +# common section of its configure.in. +# +# The intent is to keep as much of this in one place as possible (and out +# of each subdirectory, eg: newlib, libio, etc.) until the right way to do +# this (ha ha) is decided upon. +# +# This is where a target selects what multilib directories to build. +# 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 initial ("common") section of configure.in: +# +#if [ -n "${with_multilib_top}" ]; then +# . ${with_multilib_top}/../cfg-ml-com.in +#else +# . ${srcdir}/../cfg-ml-com.in +#fi +# +# `with_multilib_top' exists to handle the case of configuring in the source +# tree: ${srcdir} is not constant. +# +# The following should be added to the "post-target" section of configure.in: +# +#if [ -n "${with_multilib_top}" ]; then +# . ${with_multilib_top}/../cfg-ml-pos.in +#else +# . ${srcdir}/../cfg-ml-pos.in +#fi + +# 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. +# +# FIXME: It would be better if we could use the --print-multi-lib switch to +# gcc to get the list of directories to build, but at this point the compiler +# has not been built. + +# Only do this if --enable-multilib. +# And only if at the top level, not a multilib subdirectory. + +if [ "${enable_multilib}" = yes -a -z "${with_multisubdir}" ]; then + +# Doing this in the common section means ${target} isn't set yet, so compute +# a copy here. This is a bit kludgey, but again the current (short term) goal +# is to be as unobtrusive (sp?) to the rest of the sources as possible. + +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} + +# FIXME: Perhaps we can do something like the following instead. +# Fetch from gcc the multilib directories to use if we can. +# if [ -f ${srcdir}/../gcc/genmultilib -a -f ../gcc/Makefile ]; then +# options=`grep "^MULTILIB_OPTIONS" ../gcc/Makefile | sed -e 's/^.*=//'` +# multidirs=`${srcdir}/../gcc/genmultilib "$options" | \ +# sed -e 's/^#define.*//' -e 's/^[.].*//' -e 's/".*//' -e 's/ .*//'` +# else +# multidirs="" +# fi + +case "${target}" in +hppa*-*-*) + multidirs="soft-float" + ;; +m68*-*-aout* | m68*-*-coff* | m68*-*-elf* | m68*-*-vxworks*) + multidirs="m68000 m68020 m68881 msoft-float m68000/m68881 m68000/msoft-float m68020/m68881 m68020/msoft-float" + ;; +i960-*-*) + multidirs=float + ;; +sparclite-*-* | sparclitefrw*-*-*) + multidirs="mfpu msoft-float mflat mno-flat mfpu/mflat mfpu/mno-flat msoft-float/mflat msoft-float/mno-flat" + ;; +sparc-*-* | sparcfrw*-*-*) + multidirs="soft v8 soft/v8" + ;; +z8k-*-coff) + multidirs="z8001 std z8001/std" + ;; +h8300-*-*) + multidirs=h8300h + ;; +h8500-*-*) + multidirs="mbig msmall mcompact mmedium" + ;; +sh-*-*) + multidirs="ml m2 ml/m2" + ;; +mips*-*-*) + # Note that not all of these will be built for a particular + # target; what is build depends upon the output gcc + # --print-multi-lib. We configure them all, to make our life + # simpler here. If somebody cares about configuration + # efficiency, they will need to switch off on the various + # targets to configure just the directories needed for that + # target. + # + # In the long run, it would be better to configure based on + # the output of gcc --print-multi-lib, but, to do that, we + # would have to build gcc before configuring newlib. + # + # Default to including the single-float directories. + if [ x$enable_single_float = x ]; then + enable_single_float=yes + fi + if [ x$enable_single_float = xyes ]; then + multidirs="soft-float single el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 single/el single/eb single/mips1 single/mips3 single/el/mips1 single/el/mips3 single/eb/mips1 single/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3" + else + multidirs="soft-float el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3" + fi + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *endian* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_relocatable = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *relocatable* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_sysv = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *sysv* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + ;; +powerpc-ibm-aix* | rs6000-ibm-aix*) + multidirs="soft-float common soft-float/common" + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_commoncpu = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *common* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + ;; +powerpc-*-eabiaix*) + multidirs="soft-float relocatable little sysv little/sysv relocatable/little relocatable/sysv relocatable/little/sysv soft-float/relocatable soft-float/little soft-float/sysv soft-float/little/sysv soft-float/relocatable/little soft-float/relocatable/sysv soft-float/relocatable/little/sysv" + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *endian* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_relocatable = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *relocatable* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_sysv = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *sysv* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + ;; +powerpc-*-eabi* | powerpc-*-elf* | powerpc-*-sysv4*) + multidirs="soft-float relocatable little aix little/aix relocatable/little relocatable/aix relocatable/little/aix soft-float/relocatable soft-float/little soft-float/aix soft-float/little/aix soft-float/relocatable/little soft-float/relocatable/aix soft-float/relocatable/little/aix aixdesc soft-float/aixdesc" + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *endian* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_relocatable = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *relocatable* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_aix = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *aix* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + ;; +powerpcle-*-eabi* | powerpcle-*-elf* | powerpcle-*-sysv4*) + multidirs="soft-float relocatable big aix big/aix relocatable/big relocatable/aix relocatable/big/aix soft-float/relocatable soft-float/big soft-float/aix soft-float/big/aix soft-float/relocatable/big soft-float/relocatable/aix soft-float/relocatable/big/aix" + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *endian* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_relocatable = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *relocatable* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + if [ x$enable_aix = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *aix* ) : ;; + *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; + esac + done + fi + ;; +*) + multidirs= + ;; +esac + +# We must freshly configure each subdirectory. This bit of code is +# actually partially stolen from the main configure script. FIXME. + +if [ -n "${multidirs}" ] && [ -z "${norecursion}" ]; then + for dir in ${multidirs}; do + + if [ -d ${dir} ]; then true; else mkdir ${dir}; fi + + dotdot=../`echo ${dir} | sed -e 's|[^/]||g' -e 's|/|../|g'` + + case ${srcdir} in + ".") + echo Building symlink tree in `pwd`/${dir} + rm -f tmpconfig + cat >tmpconfig <<\EOF +#!/bin/sh +for f in `ls -a $1`; do + if [ -d $1$f ]; then + found= + for i in $2; do + if [ "$f" = "$i" ]; then + found=yes + fi + done + if [ -z "${found}" ]; then + if [ -d $f ]; then true; else mkdir $f; fi + (cd $f; ../$0 ../$1$f/ "$2") + fi + else + rm -f $f + ln -s $1$f . + fi +done +EOF + chmod +x tmpconfig + (cd ${dir}; + ${dotdot}tmpconfig ${dotdot} ". .. CVS tmpconfig ${multidirs}") + rm -f tmpconfig + srcdiroption= + multilib_top=${dotdot} + ;; + *) + case "${srcdir}" in + /*) # absolute path + newsrcdir=${srcdir}/${configdir} + ;; + *) # otherwise relative + newsrcdir=${dotdot}${srcdir}/${configdir} + ;; + esac + srcdiroption="-srcdir=${newsrcdir}" + multilib_top=${newsrcdir} + ;; + esac + + case "${progname}" in + /*) recprog=${progname} ;; + *) recprog=${dotdot}${progname} ;; + esac + + POPDIR=${PWD=`pwd`} + cd ${dir} + if eval ${config_shell} ${recprog} ${verbose} \ + --with-multisubdir=${dir} --with-multilib-top=${multilib_top} \ + ${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} \ + ${cache_file_option} ${removing} ${other_options} ${redirect} ; then + true + else + exit 1 + fi + + cd ${POPDIR} + + done +fi + +fi # ${enable_multilib = yes -a -z ${with_multisubdir} diff --git a/gnu/lib/libg++/cfg-ml-pos.in b/gnu/lib/libg++/cfg-ml-pos.in new file mode 100644 index 00000000000..34030986d42 --- /dev/null +++ b/gnu/lib/libg++/cfg-ml-pos.in @@ -0,0 +1,111 @@ +# Configure fragment invoked in the post-target section for subdirs +# wanting multilib support. +# The intent is to keep as much of this in one place as possible (and out +# of each subdirectory, eg: newlib, libio, etc.) until the right way to do +# this (ha ha) is decided upon. + +# Only do this if --enable-multilib. + +if [ "${enable_multilib}" = yes ]; then + +if [ -z "${with_multisubdir}" ]; then + multisubdir= +else + multisubdir="/${with_multisubdir}" + # The '[^/][^/]*' appears that way to work around a SunOS sed bug. + dotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'` + # TOP is used by newlib and should not be used elsewhere for this purpose. + # MULTITOP is the proper one to use. + # FIXME: newlib needs to be updated to use MULTITOP so we can delete TOP. + # Newlib may wish to continue to use TOP for its own purposes of course. + sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${dotdot}/\1:" \ + -e "s:^MULTITOP[ ]*=.*$:MULTITOP = ${dotdot}:" \ + ${Makefile} > Makefile.tem + rm -f ${Makefile} + mv Makefile.tem ${Makefile} +fi + +# 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:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \ + -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${multisubdir}:" \ + -e 's:^MULTIDO[ ]*=.*$:MULTIDO = $(MAKE):' \ + -e 's:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $(MAKE):' \ + ${Makefile} > Makefile.tem +rm -f ${Makefile} +mv Makefile.tem ${Makefile} + +# ??? May wish to add a check to avoid appending this to Makefiles that +# don't need it. It's not necessary, but is cleaner. + +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; \ + 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} ]; then \ + flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ + if (cd $${dir}; $(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 \ + for dir in Makefile $(MULTIDIRS); do \ + if [ -f ./$$dir/Makefile ]; then \ + if (cd ./$$dir; $(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 # "${enable_multilib}" = yes diff --git a/gnu/lib/libg++/config.guess b/gnu/lib/libg++/config.guess new file mode 100644 index 00000000000..2ff0eba28ac --- /dev/null +++ b/gnu/lib/libg++/config.guess @@ -0,0 +1,565 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995 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:V*:*) + # After 1.2, OSF1 uses "V1.3" for uname -r. + echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` + exit 0 ;; + alpha:OSF1:*:*) + # 1.2 uses "1.2" for uname -r. + echo alpha-dec-osf${UNAME_RELEASE} + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + Pyramid*:OSx*:*:*) + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + sun4*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-unknown-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 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + mips:*:4*:UMIPS) + echo mips-mips-riscos4sysv + exit 0 ;; + mips:*:5*:RISCos) + echo mips-mips-riscos${UNAME_RELEASE} + 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:*:*) + 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 + 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[34]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?[79] ) 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 ;; + 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*C90:*:*:*) + echo c90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + i[34]86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-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 ;; + *: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` + if echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: elf_i[345]86"; then + echo "${UNAME_MACHINE}-unknown-linux" ; exit 0 + elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86linux"; then + echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0 + elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86coff"; then + echo "${UNAME_MACHINE}-unknown-linuxcoff" ; exit 0 + elif test "${UNAME_MACHINE}" = "alpha" ; then + echo alpha-unknown-linux ; exit 0 + else + # Either a pre-BFD a.out linker (linuxoldld) or one that does not give us + # useful --help. Gcc wants to distinguish between linuxoldld and linuxaout. + test ! -d /usr/lib/ldscripts/. \ + && echo "${UNAME_MACHINE}-unknown-linuxoldld" && exit 0 + # Determine whether the default compiler is a.out or elf + cat >dummy.c </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[34]86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i[34]86:*:4.*:* | i[34]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}-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i[34]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 + echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-unknown-sysv32 + fi + exit 0 ;; + Intel:Mach:3*:*) + echo i386-unknown-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 ;; + M680[234]0:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3 && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m680[234]0:LynxOS:2.[23]*:*) + echo m68k-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i[34]86:LynxOS:2.[23]*:*) + echo i386-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.[23]*:*) + echo sparc-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.[23]*:*) + echo rs6000-lynx-lynxos${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 ;; +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%s\n", __ARCHITECTURE__, version==2 ? "2" : "3"); + 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-unknown-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/gnu/lib/libg++/config.sub b/gnu/lib/libg++/config.sub new file mode 100644 index 00000000000..d731da06f7b --- /dev/null +++ b/gnu/lib/libg++/config.sub @@ -0,0 +1,1091 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 1992, 1993, 1994, 1995 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 +# 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 (if any). +basic_machine=`echo $1 | sed 's/-[^-]*$//'` +if [ $basic_machine != $1 ] +then os=`echo $1 | sed 's/.*-/-/'` +else os=; fi + +### 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 ) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond ) # CYGNUS LOCAL + os= + basic_machine=$1 + ;; + -apple*) # CYGNUS LOCAL + os= + basic_machine=$1 + ;; + -scout) # CYGNUS LOCAL + ;; + -wrs) # CYGNUS LOCAL + os=vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; +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 | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm | armeb \ + | armel | pyramid \ + | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \ + | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \ + | powerpc | powerpcle | sparc64 | 1750a | dsp16xx | mips64 | mipsel \ + | pdp11 | mips64el | mips64orion | mips64orionel \ + | sparc) + 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 + basic_machine=$basic_machine-unknown + ;; + # 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[345]86-* | i860-* | m68k-* | m68000-* | m88k-* \ + | sparc-* | ns32k-* | fx80-* | arm-* | arme[lb]-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \ + | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ + | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ + | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ + | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-*) + ;; + m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | h8500-*) # CYGNUS LOCAL + ;; + mips64vr4300-* | mips64vr4300el-*) # CYGNUS LOCAL jsmith + ;; + # 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 + ;; + arm | armel | armeb) + basic_machine=arm-arm + os=-aout + ;; + 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 + ;; + 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 + ;; + 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[345]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + os=-sysv32 + ;; + i[345]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + os=-sysv4 + ;; + i[345]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + os=-sysv + ;; + i[345]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` + 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 + ;; + 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 + ;; + 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 | p6) + # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium + basic_machine=i586-intel + ;; + pentium-* | p5-* | p6-*) + # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium + basic_machine=i586-`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 + ;; + nexgen) + # 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 + ;; + sparcfrw) # CYGNUS LOCAL + basic_machine=sparcfrw-sun + os=-sunos4 + ;; + sparcfrwcompat) # CYGNUS LOCAL + basic_machine=sparcfrwcompat-sun + os=-sunos4 + ;; + sparclitefrw) # CYGNUS LOCAL + basic_machine=sparclitefrw-fujitsu + ;; + sparclitefrwcompat) # CYGNUS LOCAL + basic_machine=sparclitefrwcompat-fujitsu + ;; + 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 + ;; + 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 + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) # CYGNUS LOCAL + 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) + basic_machine=mips-mips + ;; + 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) # CYGNUS LOCAL + basic_machine=m68k-apple + ;; + mpw) # CYGNUS LOCAL + basic_machine=m68k-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 + # -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|'` + ;; + # 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* | -lites* | -minix* | -genix* | -ultrix* | -irix* \ + | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[345]* \ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigados* | -msdos* | -moss* | -newsos* | -unicos* | -aos* \ + | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \ + | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* | -lites* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta | -udi | -eabi*) + ;; + # CYGNUS LOCAL + -go32 | -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -proelf | -os9*) + ;; + -macos*) # CYGNUS LOCAL + ;; + -mac*) # CYGNUS LOCAL + os=`echo $os | sed -e 's|mac|macos|'` + ;; + + -mpw*) # CYGNUS LOCAL + ;; + -pe*) + ;; + -win32) + ;; + -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 + ;; + # 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 + ;; + 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 + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-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 + ;; + *-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 + ;; + *-rom68k) # CYGNUS LOCAL + os=-coff + ;; + *-*bug) # CYGNUS LOCAL + os=-coff + ;; + *-apple) # CYGNUS LOCAL + os=-macos7 + ;; + *) + 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 + ;; + -bosx*) # CYGNUS LOCAL + vendor=bull + ;; + -lynxos*) + vendor=lynx + ;; + -aix*) + vendor=ibm + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxworks*) + vendor=wrs + ;; + -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/gnu/lib/libg++/config/ChangeLog b/gnu/lib/libg++/config/ChangeLog new file mode 100644 index 00000000000..7576a359bd9 --- /dev/null +++ b/gnu/lib/libg++/config/ChangeLog @@ -0,0 +1,198 @@ +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/gnu/lib/libg++/config/mh-a68bsd b/gnu/lib/libg++/config/mh-a68bsd new file mode 100644 index 00000000000..c991289dd5f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-aix386 b/gnu/lib/libg++/config/mh-aix386 new file mode 100644 index 00000000000..4accd1cddfb --- /dev/null +++ b/gnu/lib/libg++/config/mh-aix386 @@ -0,0 +1 @@ +RANLIB = @: diff --git a/gnu/lib/libg++/config/mh-apollo68 b/gnu/lib/libg++/config/mh-apollo68 new file mode 100644 index 00000000000..4497ed93585 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-cxux b/gnu/lib/libg++/config/mh-cxux new file mode 100644 index 00000000000..c5f4bb149e8 --- /dev/null +++ b/gnu/lib/libg++/config/mh-cxux @@ -0,0 +1,15 @@ +# 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. +CFLAGS=-Xa -g +LDFLAGS=-Xa -g diff --git a/gnu/lib/libg++/config/mh-decstation b/gnu/lib/libg++/config/mh-decstation new file mode 100644 index 00000000000..37201926d5f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-delta88 b/gnu/lib/libg++/config/mh-delta88 new file mode 100644 index 00000000000..bc9c45302d5 --- /dev/null +++ b/gnu/lib/libg++/config/mh-delta88 @@ -0,0 +1,4 @@ +RANLIB = true + + + diff --git a/gnu/lib/libg++/config/mh-dgux b/gnu/lib/libg++/config/mh-dgux new file mode 100644 index 00000000000..e7d85d6126a --- /dev/null +++ b/gnu/lib/libg++/config/mh-dgux @@ -0,0 +1,4 @@ +HDEFINES=-DHOST_SYS=DGUX_SYS +CC=gcc -Wall -ansi -D__using_DGUX +RANLIB=true + diff --git a/gnu/lib/libg++/config/mh-go32 b/gnu/lib/libg++/config/mh-go32 new file mode 100644 index 00000000000..4f9d27a9346 --- /dev/null +++ b/gnu/lib/libg++/config/mh-go32 @@ -0,0 +1,27 @@ +CC=i386-go32-gcc +AR=i386-go32-ar +RANLIB=i386-go32-ranlib +CC_FOR_BUILD=gcc +HOST_CC=gcc +HOST_CFLAGS= +CFLAGS=-O2 -fno-omit-frame-pointer +HOST_PREFIX=foo +HOST_PREFIX_1=foo +RANLIB=i386-go32-ranlib +AR=i386-go32-ar +GCC_FOR_TARGET=${target_alias}-gcc +CXX_FOR_TARGET=${target_alias}-gcc +CC_FOR_TARGET=${target_alias}-gcc +AS_FOR_TARGET=${target_alias}-as +AR_FOR_TARGET=${target_alias}-ar +NM_FOR_TARGET=${target_alias}-nm +RANLIB_FOR_TARGET=${target_alias}-ranlib +HOST_PREFIX=cross +HOST_PREFIX_1=cross +MAKEINFOFLAGS=--no-split + +INSTALL_DOSREL=install-dosrel + + + + diff --git a/gnu/lib/libg++/config/mh-hp300 b/gnu/lib/libg++/config/mh-hp300 new file mode 100644 index 00000000000..761724d92de --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-hpux b/gnu/lib/libg++/config/mh-hpux new file mode 100644 index 00000000000..4d71c9dc837 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-hpux8 b/gnu/lib/libg++/config/mh-hpux8 new file mode 100644 index 00000000000..4d71c9dc837 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-i386win32 b/gnu/lib/libg++/config/mh-i386win32 new file mode 100644 index 00000000000..fa921d905e4 --- /dev/null +++ b/gnu/lib/libg++/config/mh-i386win32 @@ -0,0 +1,29 @@ +CC=i386-win32-gcc +AR=i386-win32-ar +ARFLAGS=rv +RANLIB=i386-win32-ranlib +BISON=byacc +CC_FOR_BUILD=gcc +HOST_CC=gcc +HOST_CFLAGS= +CFLAGS=-O2 +CXXFLAGS=-O2 +HOST_PREFIX=foo +HOST_PREFIX_1=foo +RANLIB=i386-win32-ranlib +AR=i386-win32-ar +GCC_FOR_TARGET=${target_alias}-gcc +CXX_FOR_TARGET=${target_alias}-gcc +CC_FOR_TARGET=${target_alias}-gcc +AS_FOR_TARGET=${target_alias}-as +DLLTOOL_FOR_TARGET=${target_alias}-dlltool +AR_FOR_TARGET=${target_alias}-ar +NM_FOR_TARGET=${target_alias}-nm +RANLIB_FOR_TARGET=${target_alias}-ranlib +HOST_PREFIX=cross +HOST_PREFIX_1=cross +MAKEINFOFLAGS=--no-split + + + + diff --git a/gnu/lib/libg++/config/mh-irix4 b/gnu/lib/libg++/config/mh-irix4 new file mode 100644 index 00000000000..a48334c72f5 --- /dev/null +++ b/gnu/lib/libg++/config/mh-irix4 @@ -0,0 +1,8 @@ +# 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 +RANLIB = true diff --git a/gnu/lib/libg++/config/mh-irix5 b/gnu/lib/libg++/config/mh-irix5 new file mode 100644 index 00000000000..8bd7c99f844 --- /dev/null +++ b/gnu/lib/libg++/config/mh-irix5 @@ -0,0 +1,3 @@ +# Makefile changes for SGI's running IRIX-5.x. +SYSV = -DSYSV +RANLIB = true diff --git a/gnu/lib/libg++/config/mh-linux b/gnu/lib/libg++/config/mh-linux new file mode 100644 index 00000000000..0fb3a054bfc --- /dev/null +++ b/gnu/lib/libg++/config/mh-linux @@ -0,0 +1,2 @@ +# This is the Makefile fragment used when running on a Linux host. +# It does not have to do anything at present. diff --git a/gnu/lib/libg++/config/mh-lynxos b/gnu/lib/libg++/config/mh-lynxos new file mode 100644 index 00000000000..9afcb79fca7 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-lynxrs6k b/gnu/lib/libg++/config/mh-lynxrs6k new file mode 100644 index 00000000000..b2793996eff --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-ncr3000 b/gnu/lib/libg++/config/mh-ncr3000 new file mode 100644 index 00000000000..5bbd8037009 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-ncrsvr43 b/gnu/lib/libg++/config/mh-ncrsvr43 new file mode 100644 index 00000000000..4717f67efaf --- /dev/null +++ b/gnu/lib/libg++/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. +CFLAGS = -g -Hnocopyr + +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true diff --git a/gnu/lib/libg++/config/mh-papic b/gnu/lib/libg++/config/mh-papic new file mode 100644 index 00000000000..35cf2c8ee4e --- /dev/null +++ b/gnu/lib/libg++/config/mh-papic @@ -0,0 +1 @@ +PICFLAG=-fPIC diff --git a/gnu/lib/libg++/config/mh-riscos b/gnu/lib/libg++/config/mh-riscos new file mode 100644 index 00000000000..e586b30b1a9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-sco b/gnu/lib/libg++/config/mh-sco new file mode 100644 index 00000000000..cc337c98f93 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-solaris b/gnu/lib/libg++/config/mh-solaris new file mode 100644 index 00000000000..7170cae1a88 --- /dev/null +++ b/gnu/lib/libg++/config/mh-solaris @@ -0,0 +1,7 @@ +# Makefile changes for Suns running Solaris 2 + +SYSV = -DSYSV +RANLIB = true +CFLAGS = -g + +X11_EXTRA_LIBS = -lnsl -lsocket diff --git a/gnu/lib/libg++/config/mh-sparcpic b/gnu/lib/libg++/config/mh-sparcpic new file mode 100644 index 00000000000..92e48d90fbd --- /dev/null +++ b/gnu/lib/libg++/config/mh-sparcpic @@ -0,0 +1 @@ +PICFLAG=-fpic diff --git a/gnu/lib/libg++/config/mh-sun3 b/gnu/lib/libg++/config/mh-sun3 new file mode 100644 index 00000000000..dcd5155b736 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-sysv b/gnu/lib/libg++/config/mh-sysv new file mode 100644 index 00000000000..16b1187b447 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-sysv4 b/gnu/lib/libg++/config/mh-sysv4 new file mode 100644 index 00000000000..81066510600 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-vaxult2 b/gnu/lib/libg++/config/mh-vaxult2 new file mode 100644 index 00000000000..3de2dc8ffe3 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/config/mh-x86pic b/gnu/lib/libg++/config/mh-x86pic new file mode 100644 index 00000000000..92e48d90fbd --- /dev/null +++ b/gnu/lib/libg++/config/mh-x86pic @@ -0,0 +1 @@ +PICFLAG=-fpic diff --git a/gnu/lib/libg++/config/mpw-mh-mpw b/gnu/lib/libg++/config/mpw-mh-mpw new file mode 100644 index 00000000000..a41dff0bef0 --- /dev/null +++ b/gnu/lib/libg++/config/mpw-mh-mpw @@ -0,0 +1,138 @@ +# 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 -i "{topsrcdir}"include:mpw:sys: -sym on + +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 + +CC_68K_GCC = gC -Dpascal= -DANSI_PROTOTYPES -DMPW + +CC_PPC_GCC = gC -Dpowerc=1 -Dpascal= -DANSI_PROTOTYPES -DMPW + +# Nothing for the default CFLAGS. + +CFLAGS = + +# These two definitions must *not* have any trailing blanks. + +SEGFLAG_68K = -s + +SEGFLAG_PPC = -d dumdum_ + +# Tool to use for making libraries/archives. + +AR_LIB = Lib + +AR_MWLINK68K = MWLink68K + +AR_PPCLINK = PPCLink -xm library + +AR_MWLINKPPC = MWLinkPPC -xm library + +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 -d -model far {CC_LD_TOOL_FLAGS} -sym on + +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_PPC = \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 + +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/gnu/lib/libg++/config/mt-netware b/gnu/lib/libg++/config/mt-netware new file mode 100644 index 00000000000..9482f9b36d2 --- /dev/null +++ b/gnu/lib/libg++/config/mt-netware @@ -0,0 +1 @@ +GDB_NLM_DEPS = all-gcc all-ld diff --git a/gnu/lib/libg++/config/mt-papic b/gnu/lib/libg++/config/mt-papic new file mode 100644 index 00000000000..35b8c9e4dc2 --- /dev/null +++ b/gnu/lib/libg++/config/mt-papic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fPIC diff --git a/gnu/lib/libg++/config/mt-sparcpic b/gnu/lib/libg++/config/mt-sparcpic new file mode 100644 index 00000000000..ff987275575 --- /dev/null +++ b/gnu/lib/libg++/config/mt-sparcpic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fpic diff --git a/gnu/lib/libg++/config/mt-v810 b/gnu/lib/libg++/config/mt-v810 new file mode 100644 index 00000000000..c5d2a889f5e --- /dev/null +++ b/gnu/lib/libg++/config/mt-v810 @@ -0,0 +1,9 @@ +CC = ca732 +AS = as732 +AR = ar732 +RANLIB = true +NEWLIB_CFLAGS = +TARGET_CFLAGS = +CFLAGS = +INCLUDES = + diff --git a/gnu/lib/libg++/config/mt-x86pic b/gnu/lib/libg++/config/mt-x86pic new file mode 100644 index 00000000000..ff987275575 --- /dev/null +++ b/gnu/lib/libg++/config/mt-x86pic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fpic diff --git a/gnu/lib/libg++/configure b/gnu/lib/libg++/configure new file mode 100644 index 00000000000..e9ea839dcf6 --- /dev/null +++ b/gnu/lib/libg++/configure @@ -0,0 +1,1217 @@ +#!/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 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= +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.1.1.1 $" +x11=default + +### we might need to use some other shell than /bin/sh for running subshells +# +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/^[^=]*=//'` + ;; +# These options have mandatory values. Since we didn't find an = sign, +# the value must be in the next argument + --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*) + optarg=$1 + shift + ;; + esac + +# Now, process the options + case $option in + + --build* | --b*) + 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 + ;; + --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" + ;; + --*) + 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=`${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 + ;; + 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 + ;; + 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 ${configsub} sun4 >/dev/null 2>&1 ; then + true +else + echo '***' cannot find config.sub. 1>&2 + exit 1 +fi + +touch config.junk +if ${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 + ;; +*) ;; +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} \ + ${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 +/\\$/ b loop +s/\\\n//g +/^CC[ ]*=/ s/CC[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CC=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +if [ -z "${CXX}" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +/\\$/ b loop +s/\\\n//g +/^CXX[ ]*=/ s/CXX[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CXX=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +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 HOST_PREFIX" + tools="${tools} HOST_PREFIX_1 LEX MAKEINFO NM NM_FOR_TARGET" + tools="${tools} RANLIB RANLIB_FOR_TARGET" + + for var in ${tools}; do + if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +/\\$/ b loop +s/\\\n//g +/^'"${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} + CC=${CC-${host_alias}-gcc} + CXX=${CXX-${host_alias}-gcc} + CC_FOR_BUILD=${CC_FOR_BUILD-gcc} + CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc} + CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-gcc} + HOST_PREFIX=${build_alias}- + HOST_PREFIX_1=${build_alias}- + 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} + + if [ -z "${BISON}" ]; then + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/byacc; then + BISON=byacc + break + fi + if test -f $dir/bison; then + BISON=bison + break + fi + if test -f $dir/yacc; then + BISON=yacc + break + fi + done + IFS="$save_ifs" + BISON=${BISON-bison} + 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 NM + export RANLIB +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 -O2" + break + fi + done + IFS="$save_ifs" + CC=${CC-cc} + fi + + CXX=${CXX-"gcc"} +fi + +export CC +export CXX + +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.tem2 + sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \ + -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \ + ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2 + rm -f ${subdir}/Makefile.tem + mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem + fi + sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \ + -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \ + -e "/^CC[ ]*=/{ + :loop1 + /\\\\$/ N + /\\\\$/ b loop1 + s/\\\\\\n//g + s%^CC[ ]*=.*$%CC = ${CC}% + }" \ + -e "/^CXX[ ]*=/{ + :loop2 + /\\\\$/ N + /\\\\$/ b loop2 + s/\\\\\\n//g + s%^CXX[ ]*=.*$%CXX = ${CXX}% + }" \ + -e "s:^SHELL[ ]*=.*$:SHELL = ${config_shell}:" \ + -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}:" \ + ${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 + ${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}" + ;; + *) # 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}" + ;; + *) # 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} ;; + 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} ${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/gnu/lib/libg++/configure.in b/gnu/lib/libg++/configure.in new file mode 100644 index 00000000000..5f665354b67 --- /dev/null +++ b/gnu/lib/libg++/configure.in @@ -0,0 +1,655 @@ +############################################################################## + +## 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). + +############################################################################## + +### 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 tcl tk tclX" + +if [ "${enable_gdbgui}" = "yes" ] ; then + host_libs="${host_libs} libgui" +fi + +# these tools are built for the host environment +# +host_tools="byacc flex bison binutils ld gas gcc gdb make patch + prms send-pr gprof gdbtest tgas etc expect dejagnu sim + m4 autoconf ispell grep diff rcs cvs fileutils shellutils + textutils wdiff find emacs emacs19 uudecode hello tar gzip indent + recode release sed utils" + + +# 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" + +################################################################################ + +## 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 +# +native_only="autoconf cvs emacs emacs19 fileutils find grep gzip hello + indent ispell m4 rcs recode sed shellutils tar textutils gash + uudecode wdiff gprof target-groff" + +# directories to be built in a cross environment only +# +cross_only="target-libiberty 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*-sgi-irix[56]*) 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[345]86-ncr-sysv4.3) host_makefile_frag=config/mh-ncrsvr43 ;; + i[345]86-ncr-sysv4*) host_makefile_frag=config/mh-ncr3000 ;; + i[345]86-*-sco*) host_makefile_frag=config/mh-sco ;; + i[345]86-*-isc*) host_makefile_frag=config/mh-sysv ;; + i[345]86-*-linux*) host_makefile_frag=config/mh-linux ;; + i[345]86-*-solaris2*) host_makefile_frag=config/mh-sysv4 ;; + i[345]86-*-aix*) host_makefile_frag=config/mh-aix386 ;; + i[345]86-*-go32*) host_makefile_frag=config/mh-go32 ;; + i[345]86-*-win32) host_makefile_frag=config/mh-i386win32 ;; + 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 + +# See if we can extract a definition of CC from the fragment. +if [ -z "${CC}" ]; then + if [ -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 + +# The Solaris /usr/ucb/cc compiler does not appear to work. +case "${host}" in + sparc-sun-solaris2*) + if [ "`/usr/bin/which ${CC-cc}`" = "/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 + +# 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 ;; + mips-sgi-irix5*) enable_shared=yes ;; + *) enable_shared=no ;; + esac +fi + +if [ x${enable_shared} = xyes ]; then + waugh= + case "${host}" in + hppa*) waugh=config/mh-papic ;; + i[345]86-*) waugh=config/mh-x86pic ;; + *) 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[345]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=. +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} + 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 +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 + +# 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[345]86-*-win32* | i[345]86-*-go32*) + 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[345]86-*-vsta) + noconfigdirs="tcl expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff" + ;; + i[345]86-*-go32) + noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff" + ;; + i[345]86-*-win32) + noconfigdirs="tk tcl expect dejagnu cvs autoconf texinfo bison send-pr gprof rcs" + ;; +esac + + +case "${target}" in + *-*-netware) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-librx target-newlib target-libiberty" + ;; + *-*-vxworks5.1) + noconfigdirs="$noconfigdirs target-newlib" + ;; + 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 or grep. + noconfigdirs="$noconfigdirs ld emacs fileutils grep target-newlib" + ;; + alpha*-*-*) + # newlib is not 64 bit ready + noconfigdirs="$noconfigdirs target-newlib" + ;; + arm-*-riscix*) + noconfigdirs="$noconfigdirs ld" + ;; + h8300*-*-* | \ + h8500-*-*) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx" + ;; + hppa*-*-*elf* | \ + hppa*-*-lites*) + # 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[345]86-*-go32) + # but don't build gdb + noconfigdirs="$noconfigdirs gdb target-libg++ target-libstdc++ target-libio target-librx" + ;; + + i[345]86-*-win32) + noconfigdirs="$noconfigdirs tk" + # Can't build gdb for win32 if not native. + if [ x${is_cross_compiler} = xyes ]; then + noconfigdirs="$noconfigdirs gdb" + fi + # always build newlib. + skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` + # and winsup + configdirs="$configdirs target-winsup" + ;; + i[345]86-*-pe) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx" + ;; + i[345]86-*-sco*) + noconfigdirs="$noconfigdirs gprof" + ;; + i[345]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" + ;; + i[345]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" + ;; + powerpc-*-aix*) + # copied from rs6000-*-* entry + noconfigdirs="$noconfigdirs gprof cvs" + ;; + powerpc*-*-winnt* | powerpc*-*-pe*) + noconfigdirs="$noconfigdirs ld gdb" + ;; + 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-*-*) + noconfigdirs="$noconfigdirs gprof" + ;; + m68k-*-netbsd*) + noconfigdirs="$noconfigdirs gdb" + ;; + m68k-apollo-*) + noconfigdirs="$noconfigdirs ld binutils gprof" + ;; + 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" + ;; + mips*-dec-bsd*) + noconfigdirs="$noconfigdirs gprof" + ;; + mips*-*-bsd*) + noconfigdirs="$noconfigdirs gprof" + ;; + mips*-*-*) + noconfigdirs="$noconfigdirs gprof" + ;; + romp-*-*) + noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes" + ;; + sh-*-*) + case "${host}" in + i[345]86-*-vsta) ;; # don't add gprof back in + i[345]86-*-go32) ;; # don't add gprof back in + *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;; + esac + ;; + sparc-*-sunos4*) + if [ x${is_cross_compiler} != xno ] ; then + noconfigdirs="$noconfigdirs gdb gdbtest target-newlib" + else + use_gnu_ld=no + fi + ;; + v810-*-*) + noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld target-libg++ target-libstdc++ opcodes" + ;; + vax-*-vms) + noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes" + ;; + vax-*-*) + noconfigdirs="$noconfigdirs target-newlib" + ;; + *-*-lynxos*) + # Newlib makes problems for libg++ in crosses. + noconfigdirs="$noconfigdirs target-newlib" + ;; +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 make texinfo diff" +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-//` ; 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 [ x${enable_shared} = xyes ]; then + case "${target}" in + hppa*) target_makefile_frag=config/mt-papic ;; + i[345]86-*) target_makefile_frag=config/mt-x86pic ;; + *) target_makefile_frag=config/mt-${target_cpu}pic ;; + esac +fi + +# post-target: + +# 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/--*cache[a-z-]*[ ][ ]*[^ ]*//'` +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/gnu/lib/libg++/etc/Makefile.in b/gnu/lib/libg++/etc/Makefile.in new file mode 100644 index 00000000000..699ada6ae9a --- /dev/null +++ b/gnu/lib/libg++/etc/Makefile.in @@ -0,0 +1,100 @@ +# +# Makefile.in for etc +# + +prefix = /usr/local +exec_prefix = $(prefix) + +srcdir = . +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +tooldir = $(libdir) +datadir = $(prefix)/lib + +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 + +SHELL = /bin/sh + +INSTALL = install -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) + +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 = configure.info standards.info cfg-paper.info +DVIFILES = configure.dvi standards.dvi cfg-paper.dvi + +all: + +install: $(srcdir)/configure.man + $(INSTALL_DATA) $(srcdir)/configure.man $(man1dir)/configure.1 + +uninstall: + cd $(infodir) && rm -f configure.info* standards.info* cfg-paper.info* + +info: $(INFOFILES) + +install-info: info + if test ! -f configure.info ; then cd $(srcdir); fi; \ + for i in configure.info* standards.info* cfg-paper.info*; do \ + $(INSTALL_DATA) $$i $(infodir)/$$i; \ + done + +dvi: $(DVIFILES) + +configure.info: $(srcdir)/configure.texi + $(MAKEINFO) -o configure.info $(srcdir)/configure.texi + +configure.dvi: $(srcdir)/configure.texi + TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/configure.texi + +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 + +cfg-paper.info : $(srcdir)/cfg-paper.texi + $(MAKEINFO) -o cfg-paper.info $(srcdir)/cfg-paper.texi + +cfg-paper.dvi: $(srcdir)/cfg-paper.texi + TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/cfg-paper.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 + +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/gnu/lib/libg++/etc/cfg-paper.info b/gnu/lib/libg++/etc/cfg-paper.info new file mode 100644 index 00000000000..717ce559186 --- /dev/null +++ b/gnu/lib/libg++/etc/cfg-paper.info @@ -0,0 +1,659 @@ +This is Info file cfg-paper.info, produced by Makeinfo-1.55 from the +input file ./cfg-paper.texi. + + This document attempts to describe the general concepts behind +configuration of the GNU Development Tools. It also discusses common +usage. + + Copyright (C) 1991, 1992, 1994 Cygnus Support 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 Cygnus Support. + +START-INFO-DIR-ENTRY +* configuration: (cfg-paper). Some theory on configuring source. +END-INFO-DIR-ENTRY + + +File: cfg-paper.info, Node: Top, Next: Some Basic Terms, Prev: (dir), Up: (dir) + + This document attempts to describe the general concepts behind +configuration of the GNU Development Tools. It also discusses common +usage. + +* Menu: + +* Some Basic Terms:: Some Basic Terms +* Specifics.:: Specifics +* Building Development Environments:: Building Development Environments +* A Walk Through:: A Walk Through +* Final Notes:: Final Notes +* Index:: Index + + -- The Detailed Node Listing -- + +Some Basic Terms + +* Host Environments:: Host Environments +* Configuration Time Options:: Configuration Time Options + +A Walk Through + +* Native Development Environments:: Native Development Environments +* Emulation Environments:: Emulation Environments +* Simple Cross Environments:: Simple Cross Environments +* Crossing Into Targets:: Crossing Into Targets +* Canadian Cross:: Canadian Cross + +Final Notes + +* Hacking Configurations:: Hacking Configurations + + +File: cfg-paper.info, Node: Some Basic Terms, Next: Specifics., Prev: Top, Up: Top + +Some Basic Terms +**************** + + There are a lot of terms that are frequently used when discussing +development tools. Most of the common terms have been used for many +different concepts such that their meanings have become ambiguous to the +point of being confusing. Typically, we only guess at their meanings +from context and we frequently guess wrong. + + This document uses very few terms by comparison. The intent is to +make the concepts as clear as possible in order to convey the usage and +intent of these tools. + + *Programs* run on *machines*. Programs are very nearly always +written in *source*. Programs are *built* from source. *Compilation* +is a process that is frequently, but not always, used when building +programs. + +* Menu: + +* Host Environments:: Host Environments +* Configuration Time Options:: Configuration Time Options + + +File: cfg-paper.info, Node: Host Environments, Next: Configuration Time Options, Prev: Some Basic Terms, Up: Some Basic Terms + +Host Environments +================= + + In this document, the word *host* refers to the environment in which +the source in question will be compiled. *host* and *host name* have +nothing to do with the proper name of your host, like *ucbvax*, +*prep.ai.mit.edu* or *att.com*. Instead they refer to things like +*sun4* and *dec3100*. + + Forget for a moment that this particular directory of source is the +source for a development environment. Instead, pretend that it is the +source for a simpler, more mundane, application, say, a desk calculator. + + Source that can be compiled in more than one environment, generally +needs to be set up for each environment explicitly. Here we refer to +that process as configuration. That is, we configure the source for a +host. + + For example, if we wanted to configure our mythical desk calculator +to compile on a SparcStation, we might configure for host sun4. With +our configuration system: + + cd desk-calculator ; ./configure sun4 + +does the trick. `configure' is a shell script that sets up Makefiles, +subdirectories, and symbolic links appropriate for compiling the source +on a sun4. + + The *host* environment does not necessarily refer to the machine on +which the tools are built. It is possible to provide a sun3 development +environment on a sun4. If we wanted to use a cross compiler on the sun4 +to build a program intended to be run on a sun3, we would configure the +source for sun3. + + cd desk-calculator ; ./configure sun3 + +The fact that we are actually building the program on a sun4 makes no +difference if the sun3 cross compiler presents an environment that looks +like a sun3 from the point of view of the desk calculator source code. +Specifically, the environment is a sun3 environment if the header files, +predefined symbols, and libraries appear as they do on a sun3. + + Nor does the host environment refer to the the machine on which the +program to be built will run. It is possible to provide a sun3 +emulation environment on a sun4 such that programs built in a sun3 +development environment actually run on the sun4. This technique is +often used within individual programs to remedy deficiencies in the host +operating system. For example, some operating systems do not provide +the `bcopy' function and so it is emulated using the `memcpy' funtion. + + Host environment simply refers to the environment in which the +program will be built from the source. + + +File: cfg-paper.info, Node: Configuration Time Options, Prev: Host Environments, Up: Some Basic Terms + +Configuration Time Options +========================== + + Many programs have compile time options. That is, features of the +program that are either compiled into the program or not based on a +choice made by the person who builds the program. We refer to these as +*configuration options*. For example, our desk calculator might be +capable of being compiled into a program that either uses infix notation +or postfix as a configuration option. For a sun3, to choose infix you +might use: + + ./configure sun3 --enable-notation=infix + +while for a sun4 with postfix you might use: + + ./configure sun4 --enable-notation=postfix + + If we wanted to build both at the same time, the intermediate pieces +used in the build process must be kept separate. + + mkdir ../objdir.sun4 + (cd ../objdir.sun4 ; ../configure sun4 --enable-notation=postfix --srcdir=../src) + mkdir ../objdir.sun3 + (cd ../objdir.sun3 ; ../configure sun3 --enable-notation=infix --srcdir=../src) + +will create subdirectories for the intermediate pieces of the sun4 and +sun3 configurations. This is necessary as previous systems were only +capable of one configuration at a time. Otherwise, a second +configuration would write over the first. We've chosen to retain this +behaviour so the obj directories and the `--srcdir' configuration +option are necessary to get the new behaviour. The order of the +arguments doesn't matter. There should be exactly one argument without +a leading `-' and that argument will be assumed to be the host name. + + From here on the examples will assume that you want to build the +tools *in place* and won't show the `--srcdir' option, but remember +that it is available. + + In order to actually install the program, the configuration system +needs to know where you would like the program installed. The default +location is `/usr/local'. We refer to this location as `$(prefix)'. +All user visible programs will be installed in ``$(prefix)'/bin'. All +other programs and files will be installed in a subdirectory of +``$(prefix)'/lib'. + + You can only change `$(prefix)' as a configuration time option. + + ./configure sun4 --enable-notation=postfix --prefix=/local + +Will configure the source such that: + + make install + +will put its programs in `/local/bin' and `/local/lib/gcc'. If you +change `$(prefix)' after building the source, you will need to: + + make clean + +before the change will be propogated properly. This is because some +tools need to know the locations of other tools. + + With these concepts in mind, we can drop the desk calculator example +and move on to the application that resides in these directories, +namely, the source to a development environment. + + +File: cfg-paper.info, Node: Specifics., Next: Building Development Environments, Prev: Some Basic Terms, Up: Top + +Specifics +********* + + The GNU Development Tools can be built on a wide variety of hosts. +So, of course, they must be configured. Like the last example, + + ./configure sun4 --prefix=/local + ./configure sun3 --prefix=/local + +will configure the source to be built in subdirectories, in order to +keep the intermediate pieces separate, and to be installed in `/local'. + + When built with suitable development environments, these will be +native tools. We'll explain the term *native* later. + + +File: cfg-paper.info, Node: Building Development Environments, Next: A Walk Through, Prev: Specifics., Up: Top + +Building Development Environments +********************************* + + The GNU development tools can not only be built in a number of host +development environments, they can also be configured to create a +number of different development environments on each of those hosts. +We refer to a specific development environment created as a *target*. +That is, the word *target* refers to the development environment +produced by compiling this source and installing the resulting programs. + + For the GNU development tools, the default target is the same as the +host. That is, the development environment produced is intended to be +compatible with the environment used to build the tools. + + In the example above, we created two configurations, one for sun4 and +one for sun3. The first configuration is expecting to be built in a +sun4 development environment, to create a sun4 development environment. +It doesn't necessarily need to be built on a sun4 if a sun4 development +environment is available elsewhere. Likewise, if the available sun4 +development environment produces executables intended for something +other than sun4, then the development environment built from this sun4 +configuration will run on something other than a sun4. From the point +of view of the configuration system and the GNU development tools +source, this doesn't matter. What matters is that they will be built in +a sun4 environment. + + Similarly, the second configuration given above is expecting to be +built in a sun3 development environment, to create a sun3 development +environment. + + The development environment produced is a configuration time option, +just like `$(prefix)'. + + ./configure sun4 --prefix=/local --target=sun3 + ./configure sun3 --prefix=/local --target=sun4 + + In this example, like before, we create two configurations. The +first is intended to be built in a sun4 environment, in subdirectories, +to be installed in `/local'. The second is intended to be built in a +sun3 environment, in subdirectories, to be installed in `/local'. + + Unlike the previous example, the first configuration will produce a +sun3 development environment, perhaps even suitable for building the +second configuration. Likewise, the second configuration will produce +a sun4 development environment, perhaps even suitable for building the +first configuration. + + The development environment used to build these configurations will +determine the machines on which the resulting development environments +can be used. + + +File: cfg-paper.info, Node: A Walk Through, Next: Final Notes, Prev: Building Development Environments, Up: Top + +A Walk Through +************** + +* Menu: + +* Native Development Environments:: Native Development Environments +* Emulation Environments:: Emulation Environments +* Simple Cross Environments:: Simple Cross Environments +* Crossing Into Targets:: Crossing Into Targets +* Canadian Cross:: Canadian Cross + + +File: cfg-paper.info, Node: Native Development Environments, Next: Emulation Environments, Prev: A Walk Through, Up: A Walk Through + +Native Development Environments +=============================== + + Let us assume for a moment that you have a sun4 and that with your +sun4 you received a development environment. This development +environment is intended to be run on your sun4 to build programs that +can be run on your sun4. You could, for instance, run this development +environment on your sun4 to build our example desk calculator program. +You could then run the desk calculator program on your sun4. + + The resulting desk calculator program is referred to as a *native* +program. The development environment itself is composed of native +programs that, when run, build other native programs. Any other program +is referred to as *foreign*. Programs intended for other machines are +foreign programs. + + This type of development environment, which is by far the most +common, is refered to as *native*. That is, a native development +environment runs on some machine to build programs for that same +machine. The process of using a native development environment to +build native programs is called a *native* build. + + ./configure sun4 + +will configure this source such that when built in a sun4 development +environment, with a development environment that builds programs +intended to be run on sun4 machines, the programs built will be native +programs and the resulting development environment will be a native +development environment. + + The development system that came with your sun4 is one such +environment. Using it to build the GNU Development Tools is a very +common activity and the resulting development environment is quite +popular. + + make all + +will build the tools as configured and will assume that you want to use +the native development environment that came with your machine. + + Using a development environment to build a development environment is +called *bootstrapping*. The release of the GNU Development Tools is +capable of bootstrapping itself. This is a very powerful feature that +we'll return to later. For now, let's pretend that you used the native +development environment that came with your sun4 to bootstrap the +release and let's call the new development environment *stage1*. + + Why bother? Well, most people find that the GNU development +environment builds programs that run faster and take up less space than +the native development environments that came with their machines. Some +people didn't get development environments with their machines and some +people just like using the GNU tools better than using other tools. + + While you're at it, if the GNU tools produce better programs, maybe +you should use them to build the GNU tools. So let's pretend that you +do. Let's call the new development environment *stage2*. + + So far you've built a development environment, stage1, and you've +used stage1 to build a new, faster and smaller development environment, +stage2, but you haven't run any of the programs that the GNU tools have +built. You really don't yet know if these tools work. Do you have any +programs built with the GNU tools? Yes, you do. stage2. What does +that program do? It builds programs. Ok, do you have any source handy +to build into a program? Yes, you do. The GNU tools themselves. In +fact, if you use stage2 to build the GNU tools again the resulting +programs should be identical to stage2. Let's pretend that you do and +call the new development environment *stage3*. + + You've just completed what's called a *three stage boot*. You now +have a small, fast, somewhat tested, development environment. + + make bootstrap + +will do a three stage boot across all tools and will compare stage2 to +stage3 and complain if they are not identical. + + Once built, + + make install + +will install the development environment in the default location, or in +`$(prefix)' if you specified an alternate when you configured. + + Any development environment that is not a native development +environment is refered to as a *cross* development environment. There +are many different types of cross development environments but most +fall into one of three basic categories. + + +File: cfg-paper.info, Node: Emulation Environments, Next: Simple Cross Environments, Prev: Native Development Environments, Up: A Walk Through + +Emulation Environments +====================== + + The first category of cross development environment is called +*emulation*. There are two primary types of emulation, but both types +result in programs that run on the native host. + + The first type is *software emulation*. This form of cross +development environment involves a native program that when run on the +native host, is capable of interpreting, and in most aspects running, a +program intended for some other machine. This technique is typically +used when the other machine is either too expensive, too slow, too fast, +or not available, perhaps because it hasn't yet been built. The native, +interpreting program is called a *software emulator*. + + The GNU Development Tools do not currently include any software +emulators. Some do exist and the GNU Development Tools can be +configured to create simple cross development environments for with +these emulators. More on this later. + + The second type of emulation is when source intended for some other +development environment is built into a program intended for the native +host. The concepts of operating system universes and hosted operating +systems are two such development environments. + + +File: cfg-paper.info, Node: Simple Cross Environments, Next: Crossing Into Targets, Prev: Emulation Environments, Up: A Walk Through + +Simple Cross Environments +========================= + + ./configure sun4 --target=a29k + +will configure the tools such that when compiled in a sun4 development +environment the resulting development environment can be used to create +programs intended for an a29k. Again, this does not necessarily mean +that the new development environment can be run on a sun4. That would +depend on the development environment used to build these tools. + + Earlier you saw how to configure the tools to build a native +development environment, that is, a development environment that runs +on your sun4 and builds programs for your sun4. Let's pretend that you +use stage3 to build this simple cross configuration and let's call the +new development environment gcc-a29k. Remember that this is a native +build. Gcc-a29k is a collection of native programs intended to run on +your sun4. That's what stage3 builds, programs for your sun4. +Gcc-a29k represents an a29k development environment that builds +programs intended to run on an a29k. But, remember, gcc-a29k runs on +your sun4. Programs built with gcc-a29k will run on your sun4 only +with the help of an appropriate software emulator. + + Building gcc-a29k is also a bootstrap but of a slightly different +sort. We call gcc-a29k a *simple cross* environment and using gcc-a29k +to build a program intended for a29k is called *crossing to* a29k. +Simple cross environments are the second category of cross development +environments. + + +File: cfg-paper.info, Node: Crossing Into Targets, Next: Canadian Cross, Prev: Simple Cross Environments, Up: A Walk Through + +Crossing Into Targets +===================== + + ./configure a29k --target=a29k + +will configure the tools such that when compiled in an a29k development +environment, the resulting development environment can be used to create +programs intended for an a29k. Again, this does not necessarily mean +that the new development environment can be run on an a29k. That would +depend on the development environment used to build these tools. + + If you've been following along this walk through, then you've already +built an a29k environment, namely gcc-a29k. Let's pretend you use +gcc-a29k to build the current configuration. + + Gcc-a29k builds programs intended for the a29k so the new development +environment will be intended for use on an a29k. That is, this new gcc +consists of programs that are foreign to your sun4. They cannot be run +on your sun4. + + The process of building this configuration is a another bootstrap. +This bootstrap is also a cross to a29k. Because this type of build is +both a bootstrap and a cross to a29k, it is sometimes referred to as a +*cross into* a29k. This new development environment isn't really a +cross development environment at all. It is intended to run on an a29k +to produce programs for an a29k. You'll remember that this makes it, by +definition, an a29k native compiler. *Crossing into* has been +introduced here not because it is a type of cross development +environment, but because it is frequently mistaken as one. The process +is *a cross* but the resulting development environment is a native +development environment. + + You could not have built this configuration with stage3, because +stage3 doesn't provide an a29k environment. Instead it provides a sun4 +environment. + + If you happen to have an a29k lying around, you could now use this +fresh development environment on the a29k to three-stage these tools +all over again. This process would look just like it did when we built +the native sun4 development environment because we would be building +another native development environment, this one on a29k. + + +File: cfg-paper.info, Node: Canadian Cross, Prev: Crossing Into Targets, Up: A Walk Through + +Canadian Cross +============== + + So far you've seen that our development environment source must be +configured for a specific host and for a specific target. You've also +seen that the resulting development environment depends on the +development environment used in the build process. + + When all four match identically, that is, the configured host, the +configured target, the environment presented by the development +environment used in the build, and the machine on which the resulting +development environment is intended to run, then the new development +environment will be a native development environment. + + When all four match except the configured host, then we can assume +that the development environment used in the build is some form of +library emulation. + + When all four match except for the configured target, then the +resulting development environment will be a simple cross development +environment. + + When all four match except for the host on which the development +environment used in the build runs, the build process is a *cross into* +and the resulting development environment will be native to some other +machine. + + Most of the other permutations do exist in some form, but only one +more is interesting to the current discussion. + + ./configure a29k --target=sun3 + +will configure the tools such that when compiled in an a29k development +environment, the resulting development environment can be used to create +programs intended for a sun3. Again, this does not necessarily mean +that the new development environment can be run on an a29k. That would +depend on the development environment used to build these tools. + + If you are still following along, then you have two a29k development +environments, the native development environment that runs on a29k, and +the simple cross that runs on your sun4. If you use the a29k native +development environment on the a29k, you will be doing the same thing we +did a while back, namely building a simple cross from a29k to sun3. +Let's pretend that instead, you use gcc-a29k, the simple cross +development environment that runs on sun4 but produces programs for +a29k. + + The resulting development environment will run on a29k because that's +what gcc-a29k builds, a29k programs. This development environment will +produce programs for a sun3 because that is how it was configured. This +means that the resulting development environment is a simple cross. + + There really isn't a common name for this process because very few +development environments are capable of being configured this +extensively. For the sake of discussion, let's call this process a +*Canadian cross*. It's a three party cross, Canada has a three party +system, hence Canadian Cross. + + +File: cfg-paper.info, Node: Final Notes, Next: Index, Prev: A Walk Through, Up: Top + +Final Notes +*********** + + By *configures*, I mean that links, Makefile, .gdbinit, and +config.status are built. Configuration is always done from the source +directory. + +`./configure NAME' + configures this directory, perhaps recursively, for a single + host+target pair where the host and target are both NAME. If a + previous configuration existed, it will be overwritten. + +`./configure HOSTNAME --target=TARGETNAME' + configures this directory, perhaps recursively, for a single + host+target pair where the host is HOSTNAME and target is + TARGETNAME. If a previous configuration existed, it will be + overwritten. + +* Menu: + +* Hacking Configurations:: Hacking Configurations + + +File: cfg-paper.info, Node: Hacking Configurations, Prev: Final Notes, Up: Final Notes + +Hacking Configurations +====================== + + The configure scripts essentially do three things, create +subdirectories if appropriate, build a `Makefile', and create links to +files, all based on and tailored to, a specific host+target pair. The +scripts also create a `.gdbinit' if appropriate but this is not +tailored. + + The Makefile is created by prepending some variable definitions to a +Makefile template called `Makefile.in' and then inserting host and +target specific Makefile fragments. The variables are set based on the +chosen host+target pair and build style, that is, if you use `--srcdir' +or not. The host and target specific Makefile may or may not exist. + + * Makefiles can be edited directly, but those changes will + eventually be lost. Changes intended to be permanent for a + specific host should be made to the host specific Makefile + fragment. This should be in `./config/mh-HOST' if it exists. + Changes intended to be permanent for a specific target should be + made to the target specific Makefile fragment. This should be in + `./config/mt-TARGET' if it exists. Changes intended to be + permanent for the directory should be made in `Makefile.in'. To + propogate changes to any of these, either use `make Makefile' or + `./config.status' or re-configure. + + +File: cfg-paper.info, Node: Index, Prev: Final Notes, Up: Top + +Index +***** + +* Menu: + +* Bootstrapping: Native Development Environments. +* Building: Some Basic Terms. +* Canadian Cross: Canadian Cross. +* Compilation: Some Basic Terms. +* Cross: Native Development Environments. +* Crossing into: Crossing Into Targets. +* Crossing to: Simple Cross Environments. +* Emulation: Emulation Environments. +* Foreign: Native Development Environments. +* host: Host Environments. +* Machines: Some Basic Terms. +* Native: Native Development Environments. +* Programs: Some Basic Terms. +* Simple cross: Simple Cross Environments. +* Software emulation: Emulation Environments. +* Software emulator: Emulation Environments. +* Source: Some Basic Terms. +* Stage1: Native Development Environments. +* Stage2: Native Development Environments. +* Stage3: Native Development Environments. +* Target: Building Development Environments. +* Three party cross: Canadian Cross. +* Three stage boot: Native Development Environments. + + + +Tag Table: +Node: Top1055 +Node: Some Basic Terms2009 +Node: Host Environments2951 +Node: Configuration Time Options5513 +Node: Specifics.8316 +Node: Building Development Environments8934 +Node: A Walk Through11554 +Node: Native Development Environments11972 +Node: Emulation Environments16221 +Node: Simple Cross Environments17579 +Node: Crossing Into Targets19188 +Node: Canadian Cross21381 +Node: Final Notes24208 +Node: Hacking Configurations25003 +Node: Index26418 + +End Tag Table diff --git a/gnu/lib/libg++/etc/cfg-paper.texi b/gnu/lib/libg++/etc/cfg-paper.texi new file mode 100644 index 00000000000..bcfbb31e13f --- /dev/null +++ b/gnu/lib/libg++/etc/cfg-paper.texi @@ -0,0 +1,717 @@ +\input texinfo +@c %**start of header +@setfilename cfg-paper.info +@settitle On Configuring Development Tools +@c %**end of header +@setchapternewpage off + +@ifinfo +This document attempts to describe the general concepts behind +configuration of the @sc{gnu} Development Tools. +It also discusses common usage. + +Copyright (C) 1991, 1992, 1994 Cygnus Support +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 Cygnus Support. +@end ifinfo + +@titlepage +@sp 10 +@title{On Configuring Development Tools} +@author{K. Richard Pixley, @code{rich@@cygnus.com}} +@author{Cygnus Support} +@page + +@vskip 0pt plus 1filll +Copyright @copyright{} 1991, 1992, 1994 Cygnus Support + +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 Cygnus Support. +@end titlepage + +@ifinfo +@format +START-INFO-DIR-ENTRY +* configuration: (cfg-paper). Some theory on configuring source. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@node top, Some Basic Terms, (dir), (dir) + +@ifinfo +This document attempts to describe the general concepts behind +configuration of the @sc{gnu} Development Tools. +It also discusses common usage. +@end ifinfo + +@menu +* Some Basic Terms:: Some Basic Terms +* Specifics.:: Specifics +* Building Development Environments:: Building Development Environments +* A Walk Through:: A Walk Through +* Final Notes:: Final Notes +* Index:: Index + + --- The Detailed Node Listing --- + +Some Basic Terms + +* Host Environments:: Host Environments +* Configuration Time Options:: Configuration Time Options + +A Walk Through + +* Native Development Environments:: Native Development Environments +* Emulation Environments:: Emulation Environments +* Simple Cross Environments:: Simple Cross Environments +* Crossing Into Targets:: Crossing Into Targets +* Canadian Cross:: Canadian Cross + +Final Notes + +* Hacking Configurations:: Hacking Configurations +@end menu + +@node Some Basic Terms, Specifics., top, top +@chapter Some Basic Terms + +There are a lot of terms that are frequently used when discussing +development tools. Most of the common terms have been used for many +different concepts such that their meanings have become ambiguous to the +point of being confusing. Typically, we only guess at their meanings +from context and we frequently guess wrong. + +This document uses very few terms by comparison. The intent is to make +the concepts as clear as possible in order to convey the usage and +intent of these tools. + +@emph{Programs} run on @emph{machines}. Programs are very nearly always +written in @emph{source}. Programs are @emph{built} from source. +@emph{Compilation} is a process that is frequently, but not always, used +when building programs. +@cindex Programs +@cindex Machines +@cindex Source +@cindex Building +@cindex Compilation + +@menu +* Host Environments:: Host Environments +* Configuration Time Options:: Configuration Time Options +@end menu + +@node Host Environments, Configuration Time Options, Some Basic Terms, Some Basic Terms +@section Host Environments + +@cindex host +In this document, the word @emph{host} refers to the environment in +which the source in question will be compiled. @emph{host} and +@emph{host name} have nothing to do with the proper name of your host, +like @emph{ucbvax}, @emph{prep.ai.mit.edu} or @emph{att.com}. Instead +they refer to things like @emph{sun4} and @emph{dec3100}. + +Forget for a moment that this particular directory of source is the +source for a development environment. Instead, pretend that it is the +source for a simpler, more mundane, application, say, a desk calculator. + +Source that can be compiled in more than one environment, generally +needs to be set up for each environment explicitly. Here we refer to +that process as configuration. That is, we configure the source for a +host. + +For example, if we wanted to configure our mythical desk calculator to +compile on a SparcStation, we might configure for host sun4. With our +configuration system: + +@example +cd desk-calculator ; ./configure sun4 +@end example + +@noindent +does the trick. @code{configure} is a shell script that sets up Makefiles, +subdirectories, and symbolic links appropriate for compiling the source +on a sun4. + +The @emph{host} environment does not necessarily refer to the machine on +which the tools are built. It is possible to provide a sun3 development +environment on a sun4. If we wanted to use a cross compiler on the sun4 +to build a program intended to be run on a sun3, we would configure the +source for sun3. + +@example +cd desk-calculator ; ./configure sun3 +@end example + +@noindent +The fact that we are actually building the program on a sun4 makes no +difference if the sun3 cross compiler presents an environment that looks +like a sun3 from the point of view of the desk calculator source code. +Specifically, the environment is a sun3 environment if the header files, +predefined symbols, and libraries appear as they do on a sun3. + +Nor does the host environment refer to the the machine on which the +program to be built will run. It is possible to provide a sun3 +emulation environment on a sun4 such that programs built in a sun3 +development environment actually run on the sun4. This technique is +often used within individual programs to remedy deficiencies in the host +operating system. For example, some operating systems do not provide +the @code{bcopy} function and so it is emulated using the +@code{memcpy} funtion. + +Host environment simply refers to the environment in which the program +will be built from the source. + + +@node Configuration Time Options, , Host Environments, Some Basic Terms +@section Configuration Time Options + +Many programs have compile time options. That is, features of the +program that are either compiled into the program or not based on a +choice made by the person who builds the program. We refer to these as +@emph{configuration options}. For example, our desk calculator might be +capable of being compiled into a program that either uses infix notation +or postfix as a configuration option. For a sun3, to choose infix you +might use: + +@example +./configure sun3 --enable-notation=infix +@end example + +@noindent +while for a sun4 with postfix you might use: + +@example +./configure sun4 --enable-notation=postfix +@end example + +If we wanted to build both at the same time, the intermediate pieces +used in the build process must be kept separate. + +@example +mkdir ../objdir.sun4 +(cd ../objdir.sun4 ; ../configure sun4 --enable-notation=postfix --srcdir=../src) +mkdir ../objdir.sun3 +(cd ../objdir.sun3 ; ../configure sun3 --enable-notation=infix --srcdir=../src) +@end example + +@noindent +will create subdirectories for the intermediate pieces of the sun4 and +sun3 configurations. This is necessary as previous systems were only +capable of one configuration at a time. Otherwise, a second +configuration would write over the first. We've chosen to retain this +behaviour so the obj directories and the @code{--srcdir} configuration +option are necessary to get the new behaviour. The order of the +arguments doesn't matter. There should be exactly one argument without +a leading @samp{-} and that argument will be assumed to be the host +name. + +From here on the examples will assume that you want to build the tools +@emph{in place} and won't show the @code{--srcdir} option, but remember +that it is available. + +In order to actually install the program, the configuration system needs +to know where you would like the program installed. The default +location is @file{/usr/local}. We refer to this location as +@code{$(prefix)}. All user visible programs will be installed in +@file{@code{$(prefix)}/bin}. All other programs and files will be +installed in a subdirectory of @file{@code{$(prefix)}/lib}. + +You can only change @code{$(prefix)} as a configuration time +option. + +@example +./configure sun4 --enable-notation=postfix --prefix=/local +@end example + +@noindent +Will configure the source such that: + +@example +make install +@end example + +@noindent +will put its programs in @file{/local/bin} and @file{/local/lib/gcc}. +If you change @code{$(prefix)} after building the source, you will need +to: + +@example +make clean +@end example + +@noindent +before the change will be propogated properly. This is because some +tools need to know the locations of other tools. + +With these concepts in mind, we can drop the desk calculator example and +move on to the application that resides in these directories, namely, +the source to a development environment. + +@node Specifics., Building Development Environments, Some Basic Terms, top +@chapter Specifics + +The @sc{gnu} Development Tools can be built on a wide variety of hosts. So, +of course, they must be configured. Like the last example, + +@example +./configure sun4 --prefix=/local +./configure sun3 --prefix=/local +@end example + +@noindent +will configure the source to be built in subdirectories, in order to +keep the intermediate pieces separate, and to be installed in +@file{/local}. + +When built with suitable development environments, these will be native +tools. We'll explain the term @emph{native} later. + +@node Building Development Environments, A Walk Through, Specifics., top +@chapter Building Development Environments + +@cindex Target + +The @sc{gnu} development tools can not only be built in a +number of host development environments, they can also be configured to +create a number of different development environments on each of those +hosts. We refer to a specific development environment created as a +@emph{target}. That is, the word @emph{target} refers to the development +environment produced by compiling this source and installing the +resulting programs. + +For the @sc{gnu} development tools, the default target is the +same as the host. That is, the development environment produced is +intended to be compatible with the environment used to build the tools. + +In the example above, we created two configurations, one for sun4 and +one for sun3. The first configuration is expecting to be built in a +sun4 development environment, to create a sun4 development environment. +It doesn't necessarily need to be built on a sun4 if a sun4 development +environment is available elsewhere. Likewise, if the available sun4 +development environment produces executables intended for something +other than sun4, then the development environment built from this sun4 +configuration will run on something other than a sun4. From the point +of view of the configuration system and the @sc{gnu} development tools +source, this doesn't matter. What matters is that they will be built in +a sun4 environment. + +Similarly, the second configuration given above is expecting to be built +in a sun3 development environment, to create a sun3 development +environment. + +The development environment produced is a configuration time option, +just like @code{$(prefix)}. + +@example +./configure sun4 --prefix=/local --target=sun3 +./configure sun3 --prefix=/local --target=sun4 +@end example + +In this example, like before, we create two configurations. The first +is intended to be built in a sun4 environment, in subdirectories, to be +installed in @file{/local}. The second is intended to be built in a +sun3 environment, in subdirectories, to be installed in @file{/local}. + +Unlike the previous example, the first configuration will produce a sun3 +development environment, perhaps even suitable for building the second +configuration. Likewise, the second configuration will produce a sun4 +development environment, perhaps even suitable for building the first +configuration. + +The development environment used to build these configurations will +determine the machines on which the resulting development environments +can be used. + + +@node A Walk Through, Final Notes, Building Development Environments, top +@chapter A Walk Through + + +@menu +* Native Development Environments:: Native Development Environments +* Emulation Environments:: Emulation Environments +* Simple Cross Environments:: Simple Cross Environments +* Crossing Into Targets:: Crossing Into Targets +* Canadian Cross:: Canadian Cross +@end menu + +@node Native Development Environments, Emulation Environments, A Walk Through, A Walk Through +@section Native Development Environments + +Let us assume for a moment that you have a sun4 and that with your sun4 +you received a development environment. This development environment is +intended to be run on your sun4 to build programs that can be run on +your sun4. You could, for instance, run this development environment on +your sun4 to build our example desk calculator program. You could then +run the desk calculator program on your sun4. + +@cindex Native +@cindex Foreign +The resulting desk calculator program is referred to as a @emph{native} +program. The development environment itself is composed of native +programs that, when run, build other native programs. Any other program +is referred to as @emph{foreign}. Programs intended for other machines are +foreign programs. + +This type of development environment, which is by far the most common, +is refered to as @emph{native}. That is, a native development environment +runs on some machine to build programs for that same machine. The +process of using a native development environment to build native +programs is called a @emph{native} build. + +@example +./configure sun4 +@end example + +@noindent +will configure this source such that when built in a sun4 development +environment, with a development environment that builds programs +intended to be run on sun4 machines, the programs built will be native +programs and the resulting development environment will be a native +development environment. + +The development system that came with your sun4 is one such environment. +Using it to build the @sc{gnu} Development Tools is a very common activity +and the resulting development environment is quite popular. + +@example +make all +@end example + +@noindent +will build the tools as configured and will assume that you want to use +the native development environment that came with your machine. + +@cindex Bootstrapping +@cindex Stage1 +Using a development environment to build a development environment is +called @emph{bootstrapping}. The release of the @sc{gnu} +Development Tools is capable of bootstrapping itself. This is a very +powerful feature that we'll return to later. For now, let's pretend +that you used the native development environment that came with your +sun4 to bootstrap the release and let's call the new +development environment @emph{stage1}. + +Why bother? Well, most people find that the @sc{gnu} development +environment builds programs that run faster and take up less space than +the native development environments that came with their machines. Some +people didn't get development environments with their machines and some +people just like using the @sc{gnu} tools better than using other tools. + +@cindex Stage2 +While you're at it, if the @sc{gnu} tools produce better programs, maybe you +should use them to build the @sc{gnu} tools. So let's +pretend that you do. Let's call the new development environment +@emph{stage2}. + +@cindex Stage3 +So far you've built a development environment, stage1, and you've used +stage1 to build a new, faster and smaller development environment, +stage2, but you haven't run any of the programs that the @sc{gnu} tools have +built. You really don't yet know if these tools work. Do you have any +programs built with the @sc{gnu} tools? Yes, you do. stage2. What does +that program do? It builds programs. Ok, do you have any source handy +to build into a program? Yes, you do. The @sc{gnu} tools themselves. In +fact, if you use stage2 to build the @sc{gnu} tools again the resulting +programs should be identical to stage2. Let's pretend that you do and +call the new development environment @emph{stage3}. + +@cindex Three stage boot +You've just completed what's called a @emph{three stage boot}. You now have +a small, fast, somewhat tested, development environment. + +@example +make bootstrap +@end example + +@noindent +will do a three stage boot across all tools and will compare stage2 to +stage3 and complain if they are not identical. + +Once built, + +@example +make install +@end example + +@noindent +will install the development environment in the default location, or in +@code{$(prefix)} if you specified an alternate when you configured. + +@cindex Cross +Any development environment that is not a native development environment +is refered to as a @emph{cross} development environment. There are many +different types of cross development environments but most fall into one +of three basic categories. + + +@node Emulation Environments, Simple Cross Environments, Native Development Environments, A Walk Through +@section Emulation Environments + +@cindex Emulation +The first category of cross development environment is called +@emph{emulation}. There are two primary types of emulation, but both +types result in programs that run on the native host. + +@cindex Software emulation +@cindex Software emulator +The first type is @emph{software emulation}. This form of cross +development environment involves a native program that when run on the +native host, is capable of interpreting, and in most aspects running, a +program intended for some other machine. This technique is typically +used when the other machine is either too expensive, too slow, too fast, +or not available, perhaps because it hasn't yet been built. The native, +interpreting program is called a @emph{software emulator}. + +The @sc{gnu} Development Tools do not currently include any software +emulators. Some do exist and the @sc{gnu} Development Tools can be +configured to create simple cross development environments for with +these emulators. More on this later. + +The second type of emulation is when source intended for some other +development environment is built into a program intended for the native +host. The concepts of operating system universes and hosted operating +systems are two such development environments. + +@node Simple Cross Environments, Crossing Into Targets, Emulation Environments, A Walk Through +@section Simple Cross Environments + +@example +./configure sun4 --target=a29k +@end example + +@noindent +will configure the tools such that when compiled in a sun4 development +environment the resulting development environment can be used to create +programs intended for an a29k. Again, this does not necessarily mean +that the new development environment can be run on a sun4. That would +depend on the development environment used to build these tools. + +Earlier you saw how to configure the tools to build a native development +environment, that is, a development environment that runs on your sun4 +and builds programs for your sun4. Let's pretend that you use stage3 to +build this simple cross configuration and let's call the new development +environment gcc-a29k. Remember that this is a native build. Gcc-a29k +is a collection of native programs intended to run on your sun4. That's +what stage3 builds, programs for your sun4. Gcc-a29k represents an a29k +development environment that builds programs intended to run on an a29k. +But, remember, gcc-a29k runs on your sun4. Programs built with gcc-a29k +will run on your sun4 only with the help of an appropriate software +emulator. + +@cindex Simple cross +@cindex Crossing to +Building gcc-a29k is also a bootstrap but of a slightly different sort. +We call gcc-a29k a @emph{simple cross} environment and using gcc-a29k to +build a program intended for a29k is called @emph{crossing to} a29k. +Simple cross environments are the second category of cross development +environments. + + +@node Crossing Into Targets, Canadian Cross, Simple Cross Environments, A Walk Through +@section Crossing Into Targets + +@example +./configure a29k --target=a29k +@end example + +@noindent +will configure the tools such that when compiled in an a29k development +environment, the resulting development environment can be used to create +programs intended for an a29k. Again, this does not necessarily mean +that the new development environment can be run on an a29k. That would +depend on the development environment used to build these tools. + +If you've been following along this walk through, then you've already +built an a29k environment, namely gcc-a29k. Let's pretend you use +gcc-a29k to build the current configuration. + +Gcc-a29k builds programs intended for the a29k so the new development +environment will be intended for use on an a29k. That is, this new gcc +consists of programs that are foreign to your sun4. They cannot be run +on your sun4. + +@cindex Crossing into +The process of building this configuration is a another bootstrap. This +bootstrap is also a cross to a29k. Because this type of build is both a +bootstrap and a cross to a29k, it is sometimes referred to as a +@emph{cross into} a29k. This new development environment isn't really a +cross development environment at all. It is intended to run on an a29k +to produce programs for an a29k. You'll remember that this makes it, by +definition, an a29k native compiler. @emph{Crossing into} has been +introduced here not because it is a type of cross development +environment, but because it is frequently mistaken as one. The process +is @emph{a cross} but the resulting development environment is a native +development environment. + +You could not have built this configuration with stage3, because stage3 +doesn't provide an a29k environment. Instead it provides a sun4 +environment. + +If you happen to have an a29k lying around, you could now use this fresh +development environment on the a29k to three-stage these tools all over +again. This process would look just like it did when we built the +native sun4 development environment because we would be building another +native development environment, this one on a29k. + + +@node Canadian Cross, , Crossing Into Targets, A Walk Through +@section Canadian Cross + +So far you've seen that our development environment source must be +configured for a specific host and for a specific target. You've also +seen that the resulting development environment depends on the +development environment used in the build process. + +When all four match identically, that is, the configured host, the +configured target, the environment presented by the development +environment used in the build, and the machine on which the resulting +development environment is intended to run, then the new development +environment will be a native development environment. + +When all four match except the configured host, then we can assume that +the development environment used in the build is some form of library +emulation. + +When all four match except for the configured target, then the resulting +development environment will be a simple cross development environment. + +When all four match except for the host on which the development +environment used in the build runs, the build process is a @emph{cross into} +and the resulting development environment will be native to some other +machine. + +Most of the other permutations do exist in some form, but only one more +is interesting to the current discussion. + +@example +./configure a29k --target=sun3 +@end example + +@noindent +will configure the tools such that when compiled in an a29k development +environment, the resulting development environment can be used to create +programs intended for a sun3. Again, this does not necessarily mean +that the new development environment can be run on an a29k. That would +depend on the development environment used to build these tools. + +If you are still following along, then you have two a29k development +environments, the native development environment that runs on a29k, and +the simple cross that runs on your sun4. If you use the a29k native +development environment on the a29k, you will be doing the same thing we +did a while back, namely building a simple cross from a29k to sun3. +Let's pretend that instead, you use gcc-a29k, the simple cross +development environment that runs on sun4 but produces programs for +a29k. + +The resulting development environment will run on a29k because that's +what gcc-a29k builds, a29k programs. This development environment will +produce programs for a sun3 because that is how it was configured. This +means that the resulting development environment is a simple cross. + +@cindex Canadian Cross +@cindex Three party cross +There really isn't a common name for this process because very few +development environments are capable of being configured this +extensively. For the sake of discussion, let's call this process a +@emph{Canadian cross}. It's a three party cross, Canada has a three +party system, hence Canadian Cross. + +@node Final Notes, Index, A Walk Through, top +@chapter Final Notes + +By @emph{configures}, I mean that links, Makefile, .gdbinit, and +config.status are built. Configuration is always done from the source +directory. + +@table @code + +@item ./configure @var{name} +configures this directory, perhaps recursively, for a single host+target +pair where the host and target are both @var{name}. If a previous +configuration existed, it will be overwritten. + +@item ./configure @var{hostname} --target=@var{targetname} +configures this directory, perhaps recursively, for a single host+target +pair where the host is @var{hostname} and target is @var{targetname}. +If a previous configuration existed, it will be overwritten. + +@end table + +@menu +* Hacking Configurations:: Hacking Configurations +@end menu + +@node Hacking Configurations, , Final Notes, Final Notes +@section Hacking Configurations + +The configure scripts essentially do three things, create subdirectories +if appropriate, build a @file{Makefile}, and create links to files, all +based on and tailored to, a specific host+target pair. The scripts also +create a @file{.gdbinit} if appropriate but this is not tailored. + +The Makefile is created by prepending some variable definitions to a +Makefile template called @file{Makefile.in} and then inserting host and +target specific Makefile fragments. The variables are set based on the +chosen host+target pair and build style, that is, if you use +@code{--srcdir} or not. The host and target specific Makefile may or may +not exist. + +@itemize @bullet + +@item +Makefiles can be edited directly, but those changes will eventually be +lost. Changes intended to be permanent for a specific host should be +made to the host specific Makefile fragment. This should be in +@file{./config/mh-@var{host}} if it exists. Changes intended to be +permanent for a specific target should be made to the target specific +Makefile fragment. This should be in @file{./config/mt-@var{target}} if +it exists. Changes intended to be permanent for the directory should be +made in @file{Makefile.in}. To propogate changes to any of these, +either use @code{make Makefile} or @code{./config.status} or +re-configure. + +@end itemize + +@page +@node Index, , Final Notes, top +@appendix Index + +@printindex cp + +@contents +@bye + +@c Local Variables: +@c fill-column: 72 +@c End: diff --git a/gnu/lib/libg++/etc/configure.in b/gnu/lib/libg++/etc/configure.in new file mode 100644 index 00000000000..c94a6237ba8 --- /dev/null +++ b/gnu/lib/libg++/etc/configure.in @@ -0,0 +1,17 @@ +# 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. + +srctrigger=configure.texi +srcname="general documentation" + +# per-host: + +# per-target: + +# +# Local Variables: +# fill-column: 131 +# End: +# diff --git a/gnu/lib/libg++/etc/configure.info b/gnu/lib/libg++/etc/configure.info new file mode 100644 index 00000000000..b1a3f01b5a8 --- /dev/null +++ b/gnu/lib/libg++/etc/configure.info @@ -0,0 +1,64 @@ +This is Info file configure.info, produced by Makeinfo-1.55 from the +input file ./configure.texi. + +START-INFO-DIR-ENTRY +* configure: (configure). Cygnus configure. +END-INFO-DIR-ENTRY + + This document describes the Cygnus Support version of `configure'. + + Copyright (C) 1991, 1992, 1993 Cygnus Support 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 Cygnus Support. + + +Indirect: +configure.info-1: 968 +configure.info-2: 50440 + +Tag Table: +(Indirect) +Node: Top968 +Node: What configure does1463 +Node: Invoking configure4783 +Node: Using configure11838 +Node: What configure really does13103 +Node: Build variables18380 +Node: Build directories20582 +Node: Makefile generation23984 +Node: config.guess25515 +Node: config.status26405 +Node: configure.in26962 +Node: configure variables28632 +Node: Minimal36798 +Node: Declarations37608 +Node: per-host38082 +Node: per-target38819 +Node: post-target39642 +Node: Example40225 +Node: Install locations40932 +Node: prefix41733 +Node: exec_prefix42626 +Node: Install details44431 +Node: Host49368 +Node: Target50004 +Node: Makefile fragments50440 +Node: Makefile extensions52056 +Node: Porting55783 +Node: Programs56235 +Node: Hosts and targets61089 +Node: Sites62752 +Node: Variables Index63452 +Node: Concept Index66624 + +End Tag Table diff --git a/gnu/lib/libg++/etc/configure.info-1 b/gnu/lib/libg++/etc/configure.info-1 new file mode 100644 index 00000000000..52e8c46aae7 --- /dev/null +++ b/gnu/lib/libg++/etc/configure.info-1 @@ -0,0 +1,1174 @@ +This is Info file configure.info, produced by Makeinfo-1.55 from the +input file ./configure.texi. + +START-INFO-DIR-ENTRY +* configure: (configure). Cygnus configure. +END-INFO-DIR-ENTRY + + This document describes the Cygnus Support version of `configure'. + + Copyright (C) 1991, 1992, 1993 Cygnus Support 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 Cygnus Support. + + +File: configure.info, Node: Top, Next: What configure does, Prev: (DIR), Up: (DIR) + +Cygnus configure +**************** + + This file documents the configuration system used and distributed by +Cygnus Support. + +* Menu: + +* What configure does:: What configure does +* Invoking configure:: Invoking configure--basic usage +* Using configure:: More than you ever wanted to know +* Porting:: How to use configure with new programs +* Variables Index:: +* Concept Index:: + + +File: configure.info, Node: What configure does, Next: Invoking configure, Prev: Top, Up: Top + +What `configure' does +********************* + + This manual documents Cygnus `configure', a program which helps to +automate much of the setup activity associated with building large +suites of programs, such the Cygnus Support Developer's Kit. This +manual is therefore geared toward readers who are likely to face the +problem of configuring software in source form before compiling and +installing it. We assume you are an experienced programmer or system +administrator. For further background on this topic, see *Note +Apologia Configure: (cfg-paper)Some Basic Terms, by K. Richard Pixley. + + When `configure' runs, it does the following things: + +** creates build directories* + When you run `configure' with the `--srcdir' option, it uses the + current directory as the "build directory", creating under it a + directory tree that parallels the directory structure of the + source directory. If you don't specify a `srcdir', `configure' + first assumes that the source code you wish to configure is in + your current directory; if it finds no `configure.in' input file + there, it searches in the directory `configure' itself lies in. + (For details, see *Note Build directories: Build directories.) + +** generates `Makefile'* + A `Makefile' template from the source directory, usually called + `Makefile.in', is copied to an output file in the build directory + which is most often named `Makefile'. `configure' places + definitions for a number of standard `Makefile' macros at the + beginning of the output file. If `--prefix=DIR' or + `--exec_prefix=DIR' are specified on the `configure' command line, + corresponding `Makefile' variables are set accordingly. If host, + target, or site-specific `Makefile' fragments exist, these are + inserted into the output file. (For details, see *Note `Makefile' + generation: Makefile generation.) + +** generates `.gdbinit'* + If the source directory contains a `.gdbinit' file and the build + directory is not the same as the source directory, a `.gdbinit' + file is created in the build directory. This `.gdbinit' file + contains commands which allow the source directory to be read when + debugging with the GNU debugger, `gdb'. (*Note Command Files: + (gdb)Command Files.) + +** makes symbolic links* + Most build directories require that some symbolic links with + generic names are built pointing to specific files in the source + directory. If the system where `configure' runs cannot support + symbolic links, hard links are used instead. (For details, see + *Note The `configure.in' input file: configure.in.) + +** generates `config.status'* + `configure' creates a shell script named `config.status' in the + build directory. This shell script, when run from the build + directory (usually from within a `Makefile'), will reconfigure the + build directory (but not its subdirectories). This is most often + used to have a `Makefile' update itself automatically if a new + source directory is available. + +** calls itself recursively* + If the source directory has subdirectories that should also be + configured, `configure' is called for each. + + +File: configure.info, Node: Invoking configure, Next: Using configure, Prev: What configure does, Up: Top + +Invoking `configure' +******************** + + Cygnus `configure' is a shell script which resides in a source tree. +The usual way to invoke `configure' is from the shell, as follows: + + eg$ ./configure HOSTTYPE + +This prepares the source in the current directory (`.') to be compiled +for a HOSTTYPE environment. It assumes that you wish to build programs +and files in the default "build directory" (also the current directory, +`.'). If you do not specify a value for HOSTTYPE, Cygnus `configure' +will attempt to discover this information by itself (*note Determining +system information: config.guess.). For information on HOSTTYPE +environments, *Note Host: Host. + + All GNU software is packaged with one or more `configure' script(s) +(*note How Configuration Should Work: (standards)Configuration.). By +using `configure' you prepare the source for your specific environment +by selecting and using `Makefile' fragments and fragments of shell +scripts, which are prepared in advance and stored with the source. + + `configure''s command-line options also allow you to specify other +aspects of the source configuration: + + configure HOSTTYPE [--target=TARGET] [--srcdir=DIR] [--rm] + [--site=SITE] [--prefix=DIR] [--exec-prefix=DIR] + [--program-prefix=STRING] [--tmpdir=DIR] + [--with-PACKAGE[=YES/NO]] [--without-PACKAGE] + [--enable-FEATURE[=YES/NO]] [--disable-FEATURE] + [--norecursion] [--nfp] [-s] [-v] [-V | --version] [--help] + +`--target=TARGET' + Requests that the sources be configured to target the TARGET + machine. If no target is specified explicitly, the target is + assumed to be the same as the host (i.e., a "native" + configuration). *Note Host: Host, and *Note Target: Target, for + discussions of each. + +`--srcdir=DIR' + Direct each generated `Makefile' to use the sources located in + directory DIR. Use this option whenever you wish the object code + to reside in a different place from the source code. The "build + directory" is always assumed to be the directory you call + `configure' from. See *Note Build directories: Build directories, + for an example. If the source directory is not specified, + `configure' assumes that the source is in your current directory. + If `configure' finds no `configure.in' there, it searches in the + same directory that the `configure' script itself lies in. + Pathnames specified (Values for DIR) can be either absolute + relative to the *build* directory. + +`--rm' + *Remove* the configuration specified by HOSTTYPE and the other + command-line options, rather than create it. + + *Note:* We recommend that you use `make distclean' rather than + use this option; see *Note Invoking `make': (make)Invoking + make, for details on `make distclean'. + +`--site=SITE' + Generate the `Makefile' using site-specific `Makefile' fragments + for SITE. *Note Adding information about local conventions: + Makefile fragments. + +`--prefix=DIR' + Configure the source to install programs and files under directory + DIR. + + This option sets the variable `prefix'. Each generated `Makefile' + will have its `prefix' variables set to this value. (*Note What + `configure' really does: What configure really does.) + +`--exec-prefix=DIR' + Configure the source to install "host dependent" files in DIR. + + This option sets the variable `exec_prefix'. Each generated + `Makefile' will have its `exec_prefix' variables set to this value. + (*Note What `configure' really does: What configure really does.) + +`--program-prefix=STRING' + Configure the source to install certain programs using STRING as a + prefix. This applies to programs which might be used for + cross-compilation, such as the compiler and the binary utilities, + and also to programs which have the same names as common Unix + programs, such as `make'. + + This option sets the variable `program_prefix'. Each generated + `Makefile' will have its `program_prefix' variables set to this + value. (*Note What `configure' really does: What configure really + does.) + +`--tmpdir=TMPDIR' + Use the directory TMPDIR for `configure''s temporary files. The + default is the value of the environment variable `TMPDIR', or + `/tmp' if the environment variable is not set. + +`--with-PACKAGE[=YES/NO]' +`--without-PACKAGE' + Indicate that PACKAGE is present, or not present, depending on + YES/NO. If YES/NO is nonexistent, its value is assumed to be + `yes'. `--without-PACKAGE' is equivalent to `--with-PACKAGE=no'. + + For example, if you wish to configure the program `gcc' for a Sun + SPARCstation running SunOS 4.x, and you want `gcc' to use the GNU + linker `ld', you can configure `gcc' using + + eg$ configure --with-gnu-ld sun4 + + *Note What `configure' really does: What configure really does, for + details. See the installation or release notes for your + particular package for details on which other PACKAGE options are + recognized. + +`--enable-FEATURE[=YES/NO]' +`--disable-FEATURE' + Include FEATURE, or not, depending on YES/NO. If YES/NO is + nonexistent, its value is assumed to be `yes'. + `--disable-FEATURE' is equivalent to `--enable-FEATURE=no'. + + *Note What `configure' really does: What configure really does, for + details. See the installation or release notes for your + particular package for details on which other FEATURE options are + recognized. + +`--norecursion' + Configure only this directory; ignore any subdirectories. This is + used by the executable shell script `config.status' to reconfigure + only the current directory; it is most often used + non-interactively, when `make' is invoked. (*Note + `config.status': config.status.) + +`--nfp' + Assume that the intended HOSTTYPE has no floating point unit. + +`-s' + Suppress status output. This option is used internally by + `configure' when calling itself recursively in subdirectories. You + can override this option with the `--verbose' option. + +`-v' +`--verbose' + Print status lines for each directory configured. Normally, only + the status lines for the initial working directory are printed. + +`--version' +`-V' + Print the `configure' version number. + +`--help' + Print a short summary of how to invoke `configure'. + + *Note:* You may introduce options with a single dash, `-', rather +than two dashes, `--'. However, you may not be able to truncate long +option names when using a single dash. When using two dashes, options +may be abbreviated as long as each option can be uniquely identified. +For example, + eg$ configure --s=/u/me/src HOSTTYPE + +is ambiguous, as `--s' could refer to either `--site' or `--srcdir'. +However, + eg$ configure --src=/u/me/src HOSTTYPE + +is a valid abbreviation. + + +File: configure.info, Node: Using configure, Next: Porting, Prev: Invoking configure, Up: Top + +Using `configure' +***************** + + `configure' prepares source directories for building programs in +them. "Configuring" is the process of preparing software to compile +correctly on a given "host", for a given "target". + + `configure' subsequently writes a configured `Makefile' from a +pre-built template; `configure' uses variables that have been set in the +configuring process to determine the values of some variables in the +`Makefile'. Because of this we will refer to both `configure' +variables and `Makefile' variables. This convention allows us to +determine where the variable should be set initially, in either +`configure.in' or `Makefile.in'. + +* Menu: + +* What configure really does:: What configure really does +* configure.in:: The configure.in input file +* Install locations:: Where to install things once they are built +* Host:: Telling configure what will source will be built +* Target:: Telling configure what the source will target +* Makefile fragments:: Adding information about local conventions +* Makefile extensions:: Extensions to the GNU coding standards + + +File: configure.info, Node: What configure really does, Next: configure.in, Up: Using configure + +What `configure' really does +============================ + + Cygnus `configure' is a shell script that sets up an environment in +which your programs will compile correctly for your machine and +operating system, and will install in proper places. `configure' +accomplishes this task by doing the following: + + * it generates a `Makefile' from a custom template called + `Makefile.in' in each relevant source directory; + + * it customizes the build process to your specifications; you set + certain variables for `configure', either on the command line or + in the file `configure.in', which subsequently sets variables in + each generated `Makefile' to be used by `make' when actually + building the software; + + * it creates "build directories", places for your code to be compiled + in before being installed; + + * it generates a `.gdbinit' in the build directory, if needed, to + communicate to `gdb' where to find the program's source code; + + * it generates a shell script called `config.status' which is used + most often by the `Makefile' to reconfigure itself; + + * it recurses in subdirectories, setting up entire trees so that + they build correctly; if `configure' finds another `configure' + script further down in a given source tree, it knows to use this + script and not recur. + + For the sake of safety (i.e., in order to prevent broken +installations), the GNU coding standards call for software to be +"configured" in such a way that an end user trying to build a given +package will be able to do so by affecting a finite number of +variables. All GNU software comes with an executable `configure' shell +script which sets up an environment within a build directory which will +correctly compile your new package for your host (or, alternatively, +whatever host you specify to `configure'). For further background on +this topic, see *Note Apologia Configure: (cfg-paper)Some Basic Terms, +by K. Richard Pixley. + + Use `configure' to set for the build process: + + * correct values for certain variables; + + * which type of host you wish to configure a given package for + (*note Host: Host.); + + * where you want to install this package (by using `prefix', + `exec-prefix' and `program-prefix'; *note Full descriptions of all + installation directories: Install details.); + + * optionally, which type of machine you wish to "target" this + package's output to (*note Target: Target.); + + * which other GNU packages are already installed and available to + this particular build (by using the `--with-PACKAGE' option; *note + Invoking `configure': Invoking configure.); + + * where to place temporary files (by using the `--tmpdir=DIR' + option; *note Invoking `configure': Invoking configure.); + + * whether to recur in subdirectories (changeable through the + `--norecursion' option; *note Invoking `configure': Invoking + configure.). + + `configure' uses a few other files to complete its tasks. These are +discussed in detail where noted. + +`configure.in' + Input file for `configure'. Shell script fragments reside here. + *Note The `configure.in' input file: configure.in. + +`Makefile.in' + Template which `configure' uses to build a file called `Makefile' + in the "build directory". *Note `Makefile' generation: Makefile + generation. + +`config.sub' + Shell script used by `configure' to expand referents to the + HOSTTYPE argument into a single specification of the form + CPU-VENDOR-OS. For instance, on the command line you can specify + + eg$ ./configure sun4 + + to configure for a Sun SPARCstation running SunOS 4.x. `configure' + consults `config.sub' to find that the three-part specification + for this is + + sparc-sun-sunos4.1.1 + + which notes the CPU as `sparc', the MANUFACTURER as `sun' (Sun + Microsystems), and the OS (operating system) as `sunos4.1.1', the + SunOS 4.1.1 release. *Note Variables available to `configure': + configure variables. + +`config.guess' + If you do not put the HOSTTYPE argument on the command line, + `configure' uses the `config.guess' shell script to make an + analysis of your machine (it assumes that you wish to configure + your software for the type of machine on which you are running). + The output of `config.guess' is a three-part identifier as + described above. + +`config.status' + The final step in configuring a directory is to create a shell + script, `config.status'. The main purpose of this file is to + allow the `Makefile' for the current directory to rebuild itself, + if necessary. *Note `config.status': config.status. + +`config/*' + `configure' uses three types of `Makefile' "fragments", which + reside in the directory `SRCDIR/config/'. *Note Adding + information about local conventions: Makefile fragments. + +* Menu: + +* Build variables:: Variable-spaghetti made simple +* Build directories:: Build directories described well +* Makefile generation:: To build a Makefile +* config.guess:: Be vewwy quiet, I'm hunting system information +* config.status:: To rebuild a Makefile + + +File: configure.info, Node: Build variables, Next: Build directories, Up: What configure really does + +Build variables +--------------- + + There are several variables in the build process which you can +control through build programs such as `make'. These include machine +definitions, local conventions, installation locations, locations for +temporary files, etc. This data is accessible through certain +variables which are configurable in the build process; we refer to them +as "build variables". + + For lists of build variables which you can affect by using +`configure', see *Note Variables available to `configure.in': configure +variables, and *Note Full descriptions of all installation directories: +Install details. + + Generally, build variables, which are used by the `Makefile' to +determine various aspects of the build and installation processes, are +changeable with command-line options to `configure'. In most large +suites of programs, like the Cygnus Support Developer's Kit, the +individual programs reside in several subdirectories of a single source +code "tree". All of these subdirectories need to be configured with +information relative to the "build directory", which is not known until +`configure' is run. Unless specified otherwise, `configure' +recursively configures every subdirectory in the source tree. + + Build variables are passed from `configure' directly into the +`Makefile', and use the same names (except that dashes are transformed +into underbars; for example, when you specify the option +`--exec-prefix' on the command line, the `Makefile' variable +`exec_prefix' is set). In other words, if you specify + + eg$ ./configure --prefix=/usr/gnu/local ... HOSTTYPE + +on the command line, `configure' sets an variable called `prefix' to +`/usr/gnu/local', and passes this into the `Makefile' in the same +manner. After this command, each `Makefile' generated by `configure' +will contain a line that reads: + + prefix = /usr/gnu/local + + For a list of the `Makefile' variables `configure' can change, and +instructions on how to change them, see *Note Variables available to +`configure.in': configure variables, and *Note Invoking `configure': +Invoking configure. + + +File: configure.info, Node: Build directories, Next: Makefile generation, Prev: Build variables, Up: What configure really does + +Build directories +----------------- + + By default, `configure' builds a `Makefile' and symbolic links in the +same directory as the source files. This default works for many cases, +but it has limitations. For instance, using this approach, you can +only build object code for one host at a time. + + We refer to each directory where `configure' builds a `Makefile' as +a "build directory". + + The build directory for any given build is always the directory from +which you call `configure', or `.' relative to your prompt. The default +"source directory", the place `configure' looks to find source code, is +also `.'. For instance, if we have a directory `/gnu-stuff/src/' that +is the top branch of a tree of GNU source code we wish to configure, +then the program we will use to configure this code is +`/gnu-stuff/src/configure', as follows. (Assume for the sake of +argument that our machine is a sun4.) + + eg$ cd /gnu-stuff/src + eg$ ./configure sun4 + Created "Makefile" in /gnu-stuff/src + eg$ + + We just configured the code in `/gnu-stuff/src' to run on a Sun +SPARCstation using SunOS 4.x by creating a `Makefile' in +`/gnu-stuff/src'. By default, we also specified that when this code is +built, the object code should reside in the same directory, +`/gnu-stuff/src'. + + However, if we wanted to build this code for more than one host, we +would be in trouble, because the new configuration would write over the +old one, destroying it in the process. What we can do is to make a new +"build directory" and configure from there. Running `configure' from +the new directory will place a correct `Makefile' and a `config.status' +in this new file. That is all `configure' does; we must run `make' to +generate any object code. + + The new `Makefile' in `/gnu-stuff/sun4-obj', created from the +template file `/gnu-stuff/src/Makefile.in', contains all the information +needed to build the program. + + eg$ mkdir /gnu-stuff/sun4-obj + eg$ cd /gnu-stuff/sun4-obj + eg$ ../src/configure --srcdir=../src sun4 + Created "Makefile" in /gnu-stuff/sun4-obj + eg$ ls + Makefile config.status + eg$ make all info install install-info clean + COMPILATION MESSAGES... + eg$ mkdir /gnu-stuff/solaris2 + eg$ cd /gnu-stuff/solaris2 + eg$ ../src/configure --srcdir=../src sol2 + Created "Makefile" in /gnu-stuff/solaris2 + eg$ ls + Makefile config.status + eg$ make all info install install-info clean + COMPILATION MESSAGES... + + We can repeat this for other configurations of the same software +simply by making a new build directory and reconfiguring from inside +it. If you do not specify the HOSTTYPE argument, `configure' will +attempt to figure out what kind of machine and operating system you +happen to be using. *Note Determining system information: +config.guess. Of course, this may not always be the configuration you +wish to build. + + *Caution:* If you build more than one configuration for a single +program, remember that you must also specify a different `--prefix' for +each configuration at configure-time. Otherwise, both configurations +will be installed in the same default location (`/usr/local'); the +configuration to be installed last would overwrite previously installed +configurations. + + +File: configure.info, Node: Makefile generation, Next: config.guess, Prev: Build directories, Up: What configure really does + +`Makefile' generation +--------------------- + + Cygnus `configure' creates a file called `Makefile' in the build +directory which can be used with `make' to automatically build a given +program or package. `configure' also builds a `Makefile' for each +relevant subdirectory for a given program or package (irrelevant +subdirectories would be those which contain no code which needs +configuring, and which therefore have no `configure' input file +`configure.in' and no `Makefile' template `Makefile.in'). *Note `make' +Invocation: (make)Running, for details on using `make' to compile your +source code. + + Each `Makefile' contains variables which have been configured for a +specific build. These build variables are determined when `configure' +is run. All build variables have defaults. By default, `configure' +generates a `Makefile' which specifies: + + * a "native" build, which is to occur + + * in the current directory, and which will be installed + + * in the default installation directory (`/usr/local') when the code + is compiled with `make'. + +Variables are changeable through command-line options to `configure' +(*note Invoking `configure': Invoking configure.). + + If you are porting a new program and intend to use `configure', see +*Note Porting with `configure': Porting, as well as *Note Writing +Makefiles: (make)Makefiles, and *Note Makefile Conventions: +(standards)Makefiles. + + +File: configure.info, Node: config.guess, Next: config.status, Prev: Makefile generation, Up: What configure really does + +Determining system information +------------------------------ + + The shell script `config.guess' is called when you do not specify a +HOSTTYPE on the command line to `configure'. `config.guess' acquires +available system information from your local machine through the shell +command `uname'. It compares this information to a database and +attempts to determine a usable three-part system identifier (known as a +"triple") to use as your HOSTTYPE. *Note What `configure' really does: +What configure really does, to see how this information is used. + + *Note:* If you do not specify a HOSTTYPE on the command line, +`configure' will attempt to configure your software to run on the +machine you happen to be using. This may not be the configuration you +desire. + + +File: configure.info, Node: config.status, Prev: config.guess, Up: What configure really does + +`config.status' +--------------- + + The final step in configuring a directory is to create an executable +shell script, `config.status'. The main purpose of this file is to +allow the `Makefile' for the current directory to rebuild itself, if +necessary. It is usually run from within the `Makefile'. *Note +Extensions to the GNU coding standards: Makefile extensions. + + `config.status' also contains a record of the `configure' session +which created it. + + +File: configure.info, Node: configure.in, Next: Install locations, Prev: What configure really does, Up: Using configure + +The `configure.in' input file +============================= + + A `configure.in' file for Cygnus `configure' consists of a +"per-invocation" section, followed by a "per-host" section, followed by +a "per-target" section, optionally followed by a "post-target" section. +Each section is a shell script fragment, which is executed by the +`configure' shell script at an appropriate time. Values are passed +among `configure' and the shell fragments through a set of shell +variables. When each section is being interpreted by the shell, the +shell's current directory is the build directory, and any files created +by the section (or referred to by the section) will be relative to the +build directory. To reference files in other places (such as the +source directory), prepend a shell variable such as `$(srcdir)/' to the +desired file name. + + The beginning of the `configure.in' file begins the "per-invocation" +section. + + A line beginning with `# per-host:' begins the "per-host" section. + + A line beginning with `# per-target:' begins the "per-target" +section. + + If it exists, the "post-target" section begins with `# post-target:'. + +* Menu: + +* configure variables:: Variables available to configure.in +* Minimal:: A minimal configure.in +* Declarations:: For each invocation +* per-host:: Host-specific instructions +* per-target:: Target-specific instructions +* post-target:: Instructions to be executed after target info +* Example:: An example configure.in + + +File: configure.info, Node: configure variables, Next: Minimal, Up: configure.in + +Variables available to `configure.in' +------------------------------------- + + The following variables pass information between the standard parts +of `configure' and the shell-script fragments in `configure.in': + +`srctrigger' + Contains the name of a source file that is expected to live in the + source directory. You must usually set this in the + "per-invocation" section of `configure.in'. `configure' tests to + see that this file exists. If the file does not exist, + `configure' prints an error message. This is used as a sanity + check that `configure.in' matches the source directory. + +`srcname' + Contains the name of the source collection contained in the source + directory. You must usually set this in the "per-invocation" + section of `configure.in'. If the file named in `srctrigger' does + not exist, `configure' uses the value of `srcname' when it prints + the error message. + +`configdirs' + Contains the names of any subdirectories in which `configure' + should recurse. You must usually set this in the "per-invocation" + section of `configure.in'. If `Makefile.in' contains a line + starting with `SUBDIRS =', then it will be replaced with an + assignment to `SUBDIRS' using the value of `configdirs' (if + `subdirs' is empty). This can be used to determine which + directories to configure and build depending on the host and + target configurations. Use `configdirs' (instead of the `subdirs' + variable described below) if you want to be able to partition the + subdirectories, or use independent `Makefile' fragments. Each + subdirectory can be independent, and independently reconfigured. + +`subdirs' + Contains the names of any subdirectories where `configure' should + create a `Makefile' (in addition to the current directory), + *without* recursively running `configure'. Use `subdirs' (instead + of the `configdirs' variable described above) if you want to + configure all of the directories as a unit. Since there is a + single invocation of `configure' that configures many directories, + all the directories can use the same `Makefile' fragments, and the + same `configure.in'. + +`host' + Contains the full configuration name for the host (generated by + the script `config.sub' from the name that you entered). This is + a three-part name (commonly referred to as a "triple") of the form + CPU-VENDOR-OS. + + There are separate variables `host_cpu', `host_vendor', and + `host_os' that you can use to test each of the three parts; this + variable is useful, however, for error messages, and for testing + combinations of the three components. + +`host_cpu' + Contains the first element of the canonical triple representing + the host as returned by `config.sub'. This is occasionally used to + distinguish between minor variations of a particular vendor's + operating system and sometimes to determine variations in binary + format between the host and the target. + +`host_vendor' + Contains the second element of the canonical triple representing + the host as returned by `config.sub'. This is usually used to + distinguish among the numerous variations of *common* operating + systems. + +`host_os' + Contains the the third element of the canonical triple + representing the host as returned by `config.sub'. + +`target' + Contains the full configuration name (generated by the script + `config.sub' from the name that you entered) for the target. Like + the host, this is a three-part name of the form CPU-VENDOR-OS. + + There are separate variables `target_cpu', `target_vendor', and + `target_os' that you can use to test each of the three parts; this + variable is useful, however, for error messages, and for testing + combinations of the three components. + +`target_cpu' + Contains the first element of the canonical triple representing + the target as returned by `config.sub'. This variable is used + heavily by programs which are involved in building other programs, + like the compiler, assembler, linker, etc. Most programs will not + need the `target' variables at all, but this one could conceivably + be used to build a program, for instance, that operated on binary + data files whose byte order or alignment differ from the system + where the program is running. + +`target_vendor' + Contains the second element of the canonical triple representing + the target as returned by `config.sub'. This is usually used to + distinguish among the numerous variations of *common* operating + systems or object file formats. It is sometimes used to switch + between different flavors of user interfaces. + +`target_os' + Contains the the third element of the canonical triple + representing the target as returned by `config.sub'. This + variable is used by development tools to distinguish between + subtle variations in object file formats that some vendors use + across operating system releases. It might also be use to decide + which libraries to build or what user interface the tool should + provide. + +`floating_point' + Set to `no' if you invoked `configure' with the `--nfp' + command-line option, otherwise it is empty. This is a request to + target machines with "no floating point" unit, even if the targets + ordinarily have floating point units available. + +`gas' + Set to `true' if you invoked `configure' with the `--with-gnu-as' + command line option, otherwise it is empty. This is a request to + assume that the specified HOSTTYPE machine has GNU `as' available + even if it ordinarily does not. + +`srcdir' + Set to the name of the directory containing the source for this + program. This will be different from `.' if you have specified the + `--srcdir=DIR' option. `srcdir' can indicate either an absolute + path or a path relative to the build directory. + +`package_makefile_frag' + If set in `configure.in', this variable should be the name a file + relative to `srcdir' to be included in the resulting `Makefile'. + If the named file does not exist, `configure' will print a warning + message. This variable is not set by `configure'. + +`host_makefile_frag' + If set in `configure.in', this variable should be the name a file + relative to `srcdir' to be included in the resulting `Makefile'. + If the named file does not exist, `configure' will print a warning + message. This variable is not set by `configure'. + +`target_makefile_frag' + If set in `configure.in', this variable should be the name of a + file, relative to `srcdir', to be included in the resulting + `Makefile'. If the named file does not exist, `configure' will + print a warning message. This variable is not set by `configure'. + +`site_makefile_frag' + Set to a file name representing to the default `Makefile' fragment + for this host. It may be set in `configure.in' to override this + default. Normally `site_makefile_frag' is empty, but will have a + value if you specify `--site=SITE' on the command line. + +`Makefile' + Set to the name of the generated `Makefile'. Normally this value + is precisely `Makefile', but some programs may want something else. + +`removing' + Normally empty but will be set to some non-null value if you + specified `--rm' on the command line. That is, if `removing' is + not empty, then `configure' is *removing* a configuration rather + than creating one. + +`files' + If this variable is not empty following the "per-target" section, + then each word in its value will be the target of a symbolic link + named in the corresponding word from the `links' variable. + +`links' + If the `files' variable is not empty following the "per-target" + section, then `configure' creates symbolic links with the first + word of `links' pointing to the first word of `files', the second + word of `links' pointing to the second word of `files', and so on. + + +File: configure.info, Node: Minimal, Next: Declarations, Prev: configure variables, Up: configure.in + +A minimal `configure.in' +------------------------ + + A minimal `configure.in' consists of four lines. + + srctrigger=foo.c + srcname="source for the foo program" + # per-host: + # per-target: + + The `# per-host:' and `# per-target:' lines divide the file into the +three required sections. The `srctrigger' line names a file. +`configure' checks to see that this file exists in the source directory +before configuring. If the `srctrigger' file does not exist, +`configure' uses the value of `srcname' to print an error message about +not finding the source. + + This particular example uses no links, and only the default host, +target, and site-specific `Makefile' fragments if they exist. + + +File: configure.info, Node: Declarations, Next: per-host, Prev: Minimal, Up: configure.in + +For each invocation +------------------- + + `configure' invokes the entire shell script fragment from the start +of `configure.in' up to a line beginning with `# per-host:' immediately +after parsing command line arguments. The variables `srctrigger' and +`srcname' *must* be set here. + + You might also want to set the variables `configdirs' and +`package_makefile_frag' here. + + +File: configure.info, Node: per-host, Next: per-target, Prev: Declarations, Up: configure.in + +Host-specific instructions +-------------------------- + + The "per-host" section of `configure.in' starts with the line that +begins with `# per-host:' and ends before a line beginning with +`# per-target:'. `configure' invokes the commands in the "per-host" +section when determining host-specific information. + + This section usually contains a big `case' statement using the +variable `host' to determine appropriate values for +`host_makefile_frag' and `files', although `files' is not usually set +here. Usually, it is set at the end of the "per-target" section after +determining the names of the target specific configuration files. + + +File: configure.info, Node: per-target, Next: post-target, Prev: per-host, Up: configure.in + +Target-specific instructions +---------------------------- + + The "per-target" section of `configure.in' starts with the line that +begins with `# per-target:' and ends before the line that begins with +`# post-target:', if there is such a line. Otherwise the "per-target" +section extends to the end of the file. `configure' invokes the +commands in the "per-target" section when determining target-specific +information, and before building any files, directories, or links. + + This section usually contains a big `case' statement using the +variable `target' to determine appropriate values for +`target_makefile_frag' and `files'. The last lines in the "per-target" +section normally set the variables `files' and `links'. + + +File: configure.info, Node: post-target, Next: Example, Prev: per-target, Up: configure.in + +Instructions to be executed after target info +--------------------------------------------- + + The "post-target" section is optional. If it exists, the +`post-target' section starts with a line beginning with +`# Post-target:' and extends to the end of the file. If it exists, +`configure' invokes this section once for each target after building +all files, directories, or links. + + This section is seldom needed, but you can use it to edit the +`Makefile' generated by `configure'. + + +File: configure.info, Node: Example, Prev: post-target, Up: configure.in + +An example `configure.in' +------------------------- + + Here is a small example of a `configure.in' file. + + # This file is a collection of shell script fragments + # used to tailor a template configure script as + # appropriate for this directory. For more information, + # see configure.texi. + + configdirs= + srctrigger=warshall.c + srcname="bison" + + # per-host: + case "${host}" in + m88k-motorola-*) + host_makefile_frag=config/mh-delta88 + ;; + esac + + # per-target: + files="bison_in.hairy" + links="bison.hairy" + + # post-target: + + +File: configure.info, Node: Install locations, Next: Host, Prev: configure.in, Up: Using configure + +Install locations +================= + + Using the default configuration, `make install' creates a single +tree of files, some of which are programs. The location of this tree +is determined by the value of the variable `prefix'. The default value +of `prefix' is `/usr/local'. This is often correct for native tools +installed on only one host. + +* Menu: + +* prefix:: Changing the default install directory +* exec_prefix:: How to separate host independent files + from host dependent files when + installing for multiple hosts +* Install details:: Full descriptions of all installation subdirectories + + +File: configure.info, Node: prefix, Next: exec_prefix, Up: Install locations + +Changing the default install directory +-------------------------------------- + + In the default configuration, all files are installed in +subdirectories of `/usr/local'. The location is determined by the +value of the `configure' variable `prefix'; in turn, this determines the +value of the `Makefile' variable of the same name (`prefix'). + + You can also set the value of the `Makefile' variable `prefix' +explicitly each time you invoke `make' if you are so inclined. However, +because many programs have this location compiled in, you must specify +the `prefix' value consistently on each invocation of `make', or you +will end up with a broken installation. + + To make this easier, the value of the `configure' variable `prefix' +can be set on the command line to `configure' using the option +`--prefix='. + + +File: configure.info, Node: exec_prefix, Next: Install details, Prev: prefix, Up: Install locations + +Installing for multiple hosts +----------------------------- + + By default, host dependent files are installed in subdirectories of +`$(exec_prefix)'. The location is determined by the value of the +`configure' variable `exec_prefix', which determines the value of the +`Makefile' variable `exec_prefix'. This makes it easier to install for +a single host, and simplifies changing the default location for the +install tree. The default doesn't allow for multiple hosts to +effectively share host independent files, however. + + To configure so that multiple hosts can share common files, use +something like: + + configure HOST1 -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host1 + make all info install install-info clean + + configure HOST2 -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host2 + make all info install install-info + + The first line configures the source for HOST1 to place host-specific +programs in subdirectories of `/usr/gnu/H-HOST1'. + + The second line builds and installs all programs for HOST1, +including both host-independent and host-specific files, as well as +removing the host-specific object files from of the build directory. + + The third line reconfigures the source for HOST2 to place host +specific programs in subdirectories of `/usr/gnu/H-HOST2'. + + The fourth line builds and installs all programs for HOST2. Host +specific files are installed in new directories, but the host +independent files are installed *on top of* the host independent files +installed for HOST1. This results in a single copy of the host +independent files, suitable for use by both hosts. + + *Note Extensions to the GNU coding standards: Makefile extensions, +for more information. + + +File: configure.info, Node: Install details, Prev: exec_prefix, Up: Install locations + +Full descriptions of all installation subdirectories +---------------------------------------------------- + + During any install, a number of standard directories are created. +Their names are determined by `Makefile' variables. Some of the +defaults for `Makefile' variables can be changed at configuration time +using command line options to `configure'. For more information on the +standard directories or the `Makefile' variables, please refer to *Note +Makefile Conventions: (standards)Makefiles. See also *Note Extensions +to the GNU coding standards: Makefile extensions. + + Note that `configure' does not create the directory indicated by the +variable `srcdir' at any time. `$(srcdir)' is not an installation +directory. + + You can override all `Makefile' variables on the command line to +`make'. (*Note Overriding Variables: (make)Overriding.) If you do so, +you will need to specify the value precisely the same way for each +invocation of `make', or you risk ending up with a broken installation. +This is because many programs have the locations of other programs or +files compiled into them. If you find yourself overriding any of the +variables frequently, you should consider site dependent `Makefile' +fragments. See also *Note Adding site info: Sites. + + During `make install', a number of standard directories are created +and populated. The following `Makefile' variables define them. Those +whose defaults are set by corresponding `configure' variables are marked +"`Makefile' and `configure'". + +`prefix (`Makefile' and `configure')' + The root of the installation tree. You can set its `Makefile' + default with the `--prefix=' command line option to `configure' + (*note Invoking `configure': Invoking configure.). The default + value for `prefix' is `/usr/local'. + +`bindir' + A directory for binary programs that users can run. The default + value for `bindir' depends on `prefix'; `bindir' is normally + changed only indirectly through `prefix'. The default value for + `bindir' is `$(prefix)/bin'. + +`exec_prefix (`Makefile' and `configure')' + A directory for host dependent files. You can specify the + `Makefile' default value by using the `--exec_prefix=' option to + `configure'. (*Note Invoking `configure': Invoking configure.) + The default value for `exec_prefix' is `$(prefix)'. + +`libdir' + A directory for libraries and support programs. The default value + for `libdir' depends on `prefix'; `libdir' is normally changed only + indirectly through `prefix'. The default value for `libdir' is + `$(prefix)/lib'. + +`mandir' + A directory for `man' format documentation ("man pages"). The + default value for `mandir' depends on `prefix'; `mandir' is + normally changed only indirectly through `prefix'. The default + value for `mandir' is `$(prefix)/man'. + +`manNdir' + These are eight variables named `man1dir', `man2dir', etc. They + name the specific directories for each man page section. For + example, `man1dir' by default holds the filename `$(mandir)/man1'; + this directory contains `emacs.1' (the man page for GNU Emacs). + Similarly, `man5dir' contains the value `$(mandir)/man5', + indicating the directory which holds `rcsfile.5' (the man page + describing the `rcs' data file format). The default value for any + of the `manNdir' variables depends indirectly on `prefix', and is + normally changed only through `prefix'. The default value for + `manNdir' is `$(mandir)/manN'. + +`manNext' + *Not supported by Cygnus `configure'*. The `GNU Coding Standards' + do not call for `man1ext', `man2ext', so the intended use for + `manext' is apparently not parallel to `mandir'. Its use is not + clear. (See also *Note Extensions to the GNU coding standards: + Makefile extensions.) + +`infodir' + A directory for `info' format documentation. The default value for + `infodir' depends indirectly on `prefix'; `infodir' is normally + changed only through `prefix'. The default value for `infodir' is + `$(prefix)/info'. + +`docdir' + A directory for any documentation that is in a format other than + those used by `info' or `man'. The default value for `docdir' + depends indirectly on `prefix'; `docdir' is normally changed only + through `prefix'. The default value for `docdir' is + `$(datadir)/doc'. *This variable is an extension to the GNU + coding standards*. (See also *Note Extensions to the GNU coding + standards: Makefile extensions.) + +`includedir' + A directory for the header files accompanying the libraries + installed in `libdir'. The default value for `includedir' depends + on `prefix'; `includedir' is normally changed only indirectly + through `prefix'. The default value for `includedir' is + `$(prefix)/include'. + + +File: configure.info, Node: Host, Next: Target, Prev: Install locations, Up: Using configure + +Host +==== + + The arguments to `configure' are "hosttypes". By "hosttype" we mean +the "environment" in which the source will be compiled. This need not +necessarily be the same as the physical machine involved, although it +usually is. + + For example, if some obscure machine had the GNU `POSIX' emulation +libraries available, it would be possible to configure most GNU source +for a `POSIX' system and build it on the obscure host. + + For more on this topic, see *Note On Configuring Development Tools: +(cfg-paper)Host Environments. + + +File: configure.info, Node: Target, Next: Makefile fragments, Prev: Host, Up: Using configure + +Target +====== + + For building native development tools, or most of the other GNU +tools, you need not worry about the target. The "target" of a +configuration defaults to the same as the "host". + + For building cross development tools, please see *Note On +Configuring Development Tools: (cfg-paper)Building Development +Environments. + diff --git a/gnu/lib/libg++/etc/configure.info-2 b/gnu/lib/libg++/etc/configure.info-2 new file mode 100644 index 00000000000..022d187f819 --- /dev/null +++ b/gnu/lib/libg++/etc/configure.info-2 @@ -0,0 +1,572 @@ +This is Info file configure.info, produced by Makeinfo-1.55 from the +input file ./configure.texi. + +START-INFO-DIR-ENTRY +* configure: (configure). Cygnus configure. +END-INFO-DIR-ENTRY + + This document describes the Cygnus Support version of `configure'. + + Copyright (C) 1991, 1992, 1993 Cygnus Support 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 Cygnus Support. + + +File: configure.info, Node: Makefile fragments, Next: Makefile extensions, Prev: Target, Up: Using configure + +Adding information about local conventions +========================================== + + If you find that a tool does not get configured to your liking, or if +`configure''s conventions differ from your local conventions, you should +probably consider "site-specific `Makefile' fragments". See also *Note +Adding site info: Sites. + + These are probably not the right choice for options that can be set +from the `configure' command line or for differences that are host or +target dependent. + + Cygnus `configure' uses three types of `Makefile' fragments. In a +generated `Makefile' they appear in the order: "target fragment", "host +fragment", and "site fragment". This allows host fragments to override +target fragments, and site fragments to override both. + + Host-specific `Makefile' fragments conventionally reside in the +`./config/' subdirectory with names of the form `mh-HOSTTYPE'. They +are used for hosts that require odd options to the standard compiler and +for compile time options based on the host configuration. + + Target-specific `Makefile' fragments conventionally reside in the +`./config/' subdirectory with names of the form `mt-TARGET'. They are +used for target dependent compile time options. + + Site specific `Makefile' fragments conventionally reside in the +`./config/' subdirectory with names of the form `ms-SITE'. They are +used to override host- and target-independent compile time options. +Note that you can also override these options on the `make' invocation +line. + + +File: configure.info, Node: Makefile extensions, Prev: Makefile fragments, Up: Using configure + +Extensions to the GNU coding standards +====================================== + + The following additions to the GNU coding standards are required for +Cygnus `configure' to work properly. + + * The `Makefile' must contain exactly one line starting with `####'. + This line should follow any default macro definitions but precede + any rules. Host, target, and site-specific `Makefile' fragments + will be inserted immediately after this line. If the line is + missing, the fragments will not be inserted. + + * Cygnus adds the following targets to each `Makefile'. Their + existence is not required for Cygnus `configure', but they are + documented here for completeness. + + `info' + Build all info files from texinfo source. + + `install-info' + Install all info files. + + `clean-info' + Remove all info files and any intermediate files that can be + generated from texinfo source. + + `Makefile' + Calls `./config.status' to rebuild the `Makefile' in this + directory. + + * The following `Makefile' targets have revised semantics: + + `install' + Should *not* depend on the target `all'. If the program is + not already built, `make install' should fail. This allows + you to install programs even when `make' would otherwise + determine them to be out of date. This can happen, for + example, when the result of a `make all' is transported via + tape to another machine for installation. + + `clean' + Should remove any file that can be regenerated by the + `Makefile', excepting only the `Makefile' itself, and any + links created by `configure'. That is, `make all clean' + should return all directories to their original condition. + If this is not done, then the command sequence + + configure HOST1 ; make all install clean ; + configure HOST2 ; make all install + + will fail because of intermediate files intended for HOST1. + + * Cygnus adds the following macros to all `Makefile.in' files, but + you are not required to use them to run Cygnus `configure'. + + `docdir' + The directory in which to install any documentation that is + not either a `man' page or an `info' file. For `man' pages, + see `mandir'; for `info', see `infodir'. + + `includedir' + The directory in which to install any header files that + should be made available to users. This is distinct from the + `gcc' include directory, which is intended for `gcc' only. + Files in `includedir' may be used by `cc' as well. + + * The following macros have revised semantics. Most of them describe + installation directories; see also *Note Full description of all + installation subdirectories: Install details. + + `datadir' + is used for host independent data files. + + `mandir' + The default path for `mandir' depends on `prefix'. + + `infodir' + The default path for `infodir' depends on `prefix'. + + `BISON' + is assumed to have a `yacc' calling convention. To use GNU + `bison', use `BISON=bison -y'. + + * Each Cygnus `Makefile' also conforms to one additional restriction: + + When libraries are installed, the line containing the call to + `INSTALL_DATA' should always be followed by a line containing a + call to `RANLIB' on the installed library. This is to accommodate + systems that use `ranlib'. Systems that do not use `ranlib' can + set `RANLIB' to "`echo'" in a host specific `Makefile' fragment. + + +File: configure.info, Node: Porting, Next: Variables Index, Prev: Using configure, Up: Top + +Porting with `configure' +************************ + + This section explains how to add programs, host and target +configuration names, and site-specific information to Cygnus +`configure'. + +* Menu: + +* Programs:: Adding configure to new programs +* Hosts and targets:: Adding hosts and targets +* Sites:: Adding site info + + +File: configure.info, Node: Programs, Next: Hosts and targets, Up: Porting + +Adding `configure' to new programs +================================== + + If you are writing a new program, you probably shouldn't worry about +porting or configuration issues until it is running reasonably on some +host. Then refer back to this section. + + If your program currently has a `configure' script that meets the GNU +standards (*note How Configuration Should Work: +(standards)Configuration., please do not add Cygnus `configure'. It +should be possible to add this program without change to a Cygnus +`configure' style source tree. + + If the program is not target dependent, please consider using +`autoconf' instead of Cygnus `configure'. `autoconf' is available from +the Free Software Foundation; it is a program which generates an +executable shell script called `configure' by automatically finding +information on the system to be configured on and embedding this +information in the shell script. `configure' scripts generated by +`autoconf' require no arguments, and accept the same options as Cygnus +`configure'. For detailed instructions on using `autoconf', see *Note +How to organize and produce Autoconf scripts: (autoconf)Making +configure Scripts. + + To add Cygnus `configure' to an existing program, do the following: + +*Make sure the `Makefile' conforms to the GNU standard + The coding standard for writing a GNU `Makefile' is described in + *Note Makefile Conventions: (standards)Makefiles. For technical + information on writing a `Makefile', see *Note Writing Makefiles: + (make)Makefiles. + +*Add Cygnus extensions to the `Makefile' + These are described in *Note Extensions to the GNU coding + standards: Makefile extensions. + +*Collect package specific definitions in a single file + Many packages are best configured using a common `Makefile' + fragment which is included by all of the makefiles in the + different directories of the package. In order to accomplish + this, set the variable `package_makefile_fragment' to the name of + the file. It will be inserted into the final `Makefile' before + the target-specific fragment. + +*Move host support from `Makefile' to fragments + This usually involves finding sections of the `Makefile' that say + things like "uncomment these lines for host HOSTTYPE" and moving + them to a new file called `./config/mh-HOSTTYPE'. For more + information, see *Note Adding hosts and targets: Hosts and targets. + +*Choose defaults + If the program has compile-time options that determine the way the + program should behave, choose reasonable defaults and make these + `Makefile' variables. Be sure the variables are assigned their + default values before the `####' line so that site-specific + `Makefile' fragments can override them (*note Extensions to the + GNU coding standards: Makefile extensions.). + +*Locate configuration files + If there is configuration information in header files or source + files, separate it in such a way that the files have generic + names. Then move the specific instances of those files into the + `./config/' subdirectory. + +*Separate host and target information + Some programs already have this information separated. If yours + does not, you will need to separate these two kinds of + configuration information. "Host specific" information is the + information needed to compile the program. "Target specific" + information is information on the format of data files that the + program will read or write. This information should live in + separate files in the `./config/' subdirectory with names that + reflect the configuration for which they are intended. + + At this point you might skip this step and simply move on. If you + do, you should end up with a program that can be configured only + to build "native" tools, that is, tools for which the host system + is also the target system. Later, you could attempt to build a + cross tool and separate out the target-specific information by + figuring out what went wrong. This is often simpler than combing + through all of the source code. + +*Write `configure.in' + Usually this involves writing shell script fragments to map from + canonical configuration names into the names of the configuration + files. These files will then be linked at configure time from the + specific instances of those files in `./config' to files in the + build directory with more generic names. (See also *Note Build + directories: Build directories.) The format of `configure.in' is + described in *Note The `configure.in' input file: configure.in. + +*Rename `Makefile' to `Makefile.in' + At this point you should have a program that can be configured using +Cygnus `configure'. + + +File: configure.info, Node: Hosts and targets, Next: Sites, Prev: Programs, Up: Porting + +Adding hosts and targets +======================== + + To add a host or target to a program that already uses Cygnus +`configure', do the following. + + * Make sure the new configuration name is represented in + `config.sub'. If not, add it. For more details, see the comments + in the shell script `config.sub'. + + * If you are adding a host configuration, look in `configure.in', in + the "per-host" section. Make sure that your configuration name is + represented in the mapping from host configuration names to + configuration files. If not, add it. Also see *Note The + `configure.in' input file: configure.in. + + * If you are adding a target configuration, look in `configure.in', + in the "per-target" section. Make sure that your configuration + name is represented in the mapping from target configuration names + to configuration files. If not, add it. Also see *Note The + `configure.in' input file: configure.in. + + * Look in `configure.in' for the variables `files', `links', + `host_makefile_frag', and `target_makefile_frag'. The values + assigned to these variables are the names of the configuration + files, (relative to `srcdir') that the program uses. Make sure + that copies of the files exist for your host. If not, create + them. See also *Note Variables available to `configure.in': + configure variables. + + This should be enough to `configure' for a new host or target +configuration name. Getting the program to compile and run properly +represents the hardest work of any port. + + +File: configure.info, Node: Sites, Prev: Hosts and targets, Up: Porting + +Adding site info +================ + + If some of the `Makefile' defaults are not right for your site, you +can build site-specific `Makefile' fragments. To do this, do the +following. + + * Choose a name for your site. It must currently be less than + eleven characters. + + * If the program source does not have a `./config/' subdirectory, + create it. + + * Create a file called `./config/ms-SITE' where SITE is the name of + your site. In it, set whatever `Makefile' variables you need to + override to match your site's conventions. + + * Configure the program with: + + configure ... --site=SITE + + +File: configure.info, Node: Variables Index, Next: Concept Index, Prev: Porting, Up: Top + +Variable Index +************** + +* Menu: + +* bindir: Install details. +* configdirs: configure variables. +* disable-FEATURE: Invoking configure. +* docdir: Install details. +* enable-FEATURE: Invoking configure. +* exec-prefix: Invoking configure. +* exec_prefix: exec_prefix. +* exec_prefix: Install details. +* files: configure variables. +* floating_point: configure variables. +* gas: configure variables. +* host: configure variables. +* host_cpu: configure variables. +* host_makefile_frag: configure variables. +* host_os: configure variables. +* host_vendor: configure variables. +* includedir: Install details. +* infodir: Install details. +* libdir: Install details. +* links: configure variables. +* Makefile: configure variables. +* manNdir: Install details. +* manNext: Install details. +* mandir: Install details. +* nfp: Invoking configure. +* norecursion: Invoking configure. +* package_makefile_frag: configure variables. +* prefix: prefix. +* prefix: Install details. +* prefix: Invoking configure. +* program-prefix: Invoking configure. +* removing: configure variables. +* rm: Invoking configure. +* site: Invoking configure. +* site_makefile_frag: configure variables. +* srcdir: configure variables. +* srcdir: What configure does. +* srcdir: Invoking configure. +* srcname: configure variables. +* srctrigger: configure variables. +* subdirs: configure variables. +* target: Invoking configure. +* target: configure variables. +* target_cpu: configure variables. +* target_makefile_frag: configure variables. +* target_os: configure variables. +* target_vendor: configure variables. +* tmpdir: Invoking configure. +* verbose: Invoking configure. +* with-PACKAGE: Invoking configure. +* without-PACKAGE: Invoking configure. + + +File: configure.info, Node: Concept Index, Prev: Variables Index, Up: Top + +Concept Index +************* + +* Menu: + +* -disable-FEATURE: Invoking configure. +* -enable-FEATURE: Invoking configure. +* -exec-prefix: Invoking configure. +* -help: Invoking configure. +* -nfp: Invoking configure. +* -norecursion: Invoking configure. +* -prefix: Invoking configure. +* -program-prefix: Invoking configure. +* -rm: Invoking configure. +* -site: Invoking configure. +* -srcdir: Invoking configure. +* -target: Invoking configure. +* -tmpdir: Invoking configure. +* -verbose: Invoking configure. +* -version: Invoking configure. +* -with-PACKAGE: Invoking configure. +* -without-PACKAGE: Invoking configure. +* -s: Invoking configure. +* -v: Invoking configure. +* .gdbinit: What configure does. +* autoconf: Programs. +* bindir: Install details. +* config.guess: config.guess. +* config.guess definition: What configure really does. +* config.status: config.status. +* config.status: What configure does. +* config.status definition: What configure really does. +* config.sub definition: What configure really does. +* config/ subdirectory: What configure really does. +* configdirs: configure variables. +* configure.in: configure.in. +* configure.in definition: What configure really does. +* configure back end: What configure really does. +* configure details: What configure really does. +* disable-FEATURE option: Invoking configure. +* docdir: Install details. +* enable-FEATURE option: Invoking configure. +* exec-prefix option: Invoking configure. +* exec_prefix: Install details. +* floating_point: configure variables. +* help option: Invoking configure. +* host: configure variables. +* includedir: Install details. +* infodir: Install details. +* libdir: Install details. +* Makefile.in definition: What configure really does. +* Makefile extensions: Makefile extensions. +* Makefile fragments: Makefile fragments. +* Makefile generation: Makefile generation. +* Makefile generation: What configure does. +* manNdir: Install details. +* manNext: Install details. +* mandir: Install details. +* nfp option: Invoking configure. +* nfp option: configure variables. +* norecursion option: Invoking configure. +* prefix: Install details. +* prefix option: Invoking configure. +* prefix option: prefix. +* program-prefix option: Invoking configure. +* rm option: Invoking configure. +* rm option: configure variables. +* site option: Invoking configure. +* srcdir: configure variables. +* srcdir: What configure does. +* srcdir option: Invoking configure. +* srcname: configure variables. +* srctrigger: configure variables. +* subdirs: configure variables. +* s option: Invoking configure. +* target: configure variables. +* target option: Invoking configure. +* tmpdir option: Invoking configure. +* verbose option: Invoking configure. +* v option: Invoking configure. +* with-PACKAGE option: Invoking configure. +* with-gnu-as option: configure variables. +* without-PACKAGE option: Invoking configure. +* configure.in interface: configure variables. +* host shell-script fragment: per-host. +* per-host section: per-host. +* per-host section: configure.in. +* per-invocation section: configure.in. +* per-invocation section: Declarations. +* per-target section: configure.in. +* per-target section: per-target. +* post-target section: configure.in. +* post-target section: post-target. +* Abbreviating option names: Invoking configure. +* Adding configure to new programs: Programs. +* Adding hosts and targets: Hosts and targets. +* Adding local info: Makefile fragments. +* Adding site info: Sites. +* Adding site info: Makefile fragments. +* Behind the scenes: What configure really does. +* BISON: Makefile extensions. +* Build directories: What configure does. +* Build directories: Build directories. +* Build variables: Build variables. +* Building for multiple hosts: Build directories. +* Building for multiple targets: Build directories. +* Canonical "triple": configure variables. +* Canonical "triple": configure variables. +* Changing the install directory: prefix. +* clean: Makefile extensions. +* clean-info: Makefile extensions. +* Coding standards extensions: Makefile extensions. +* configure variables: configure variables. +* Configuring for multiple hosts: exec_prefix. +* Cygnus extensions: Makefile extensions. +* Cygnus Support Developer's Kit: What configure does. +* Cygnus Support Developer's Kit: Build variables. +* datadir: Makefile extensions. +* Declarations section: Declarations. +* Default configuration: Makefile generation. +* Detailed usage: Using configure. +* docdir: Makefile extensions. +* Example configure.in: Example. +* Example session: Build directories. +* Example session: Build directories. +* Example session: exec_prefix. +* Example session: Build variables. +* Example session: Makefile extensions. +* Example session: What configure really does. +* Example session: Sites. +* Example session: Invoking configure. +* Example session: Invoking configure. +* For each invocation: Declarations. +* Host: Host. +* Host-specific instructions: per-host. +* Hosts and targets: Hosts and targets. +* includedir: Makefile extensions. +* info: Makefile extensions. +* infodir: Makefile extensions. +* install: Makefile extensions. +* Install details: Install details. +* Install locations: Install locations. +* install-info: Makefile extensions. +* Installation subdirectories: Install details. +* Installing host-independent files: exec_prefix. +* Introduction: What configure does. +* Invoking configure: Invoking configure. +* Local conventions: Makefile fragments. +* Makefile: Makefile extensions. +* mandir: Makefile extensions. +* Minimal configure.in example: Minimal. +* Object directories: Build directories. +* Other files: What configure really does. +* Overview: What configure does. +* Porting with configure: Porting. +* Post-target shell-script fragment: post-target. +* Recursion: What configure does. +* Sample configure.in: Example. +* Sharing host-independent files: exec_prefix. +* Sites: Sites. +* Subdirectories: Install details. +* Symbolic links: What configure does. +* Symbolic links: configure variables. +* Symbolic links: configure variables. +* Target: Target. +* target shell-script fragment: per-target. +* Target-specific instructions: per-target. +* The exec_prefix directory: exec_prefix. +* Truncating option names: Invoking configure. +* Usage: Invoking configure. +* Usage: Invoking configure. +* Usage: detailed: Using configure. +* Using configure: Using configure. +* Variables: Build variables. +* Verbose Output: Invoking configure. +* version: Invoking configure. +* version: Invoking configure. +* What configure does: What configure does. +* What configure really does: What configure really does. +* Where to install: Install locations. + + diff --git a/gnu/lib/libg++/etc/configure.man b/gnu/lib/libg++/etc/configure.man new file mode 100644 index 00000000000..0761854dc43 --- /dev/null +++ b/gnu/lib/libg++/etc/configure.man @@ -0,0 +1,166 @@ +.\" -*- nroff -*- +.\" Copyright (c) 1991, 1992 Cygnus Support +.\" written by K. Richard Pixley +.TH configure 1 "2 February 1993" "cygnus support" "Cygnus Support" +.de BP +.sp +.ti \-.2i +\(** +.. + +.SH NAME +configure \(em\& prepare source code to be built + +.SH SYNOPSIS +configure HOST [--target=TARGET] [--srcdir=DIR] [--rm] + [--site=SITE] [--prefix=DIR] [--exec_prefix=DIR] + [--program_prefix=DIR] [--tmpdir=DIR] + [--with-PACKAGE[=YES/NO]] [--without-PACKAGE] + [--enable-FEATURE[=YES/NO]] [--disable-FEATURE] + [--norecursion] [--nfp] [-s] [-v] [-V | --version] [--help] + +.SH DESCRIPTION +.I configure +is a program used to prepare souce code to be built. It does this by +generating Makefiles and .gdbinit files, creating symlinks, recursing +in subdirectories, and some other miscellaneous file editing. + +.SH OPTIONS +.I configure +accepts the following options: + +.TP +.I \--target=TARGET +Requests that the sources be configured to target the +.I TARGET +machine. If no target is specified explicitly, the target is assumed +to be the same as the host. + +.TP +.I \--srcdir=DIR +tells configure to find the source in +.I DIR. +Object code is always built in the current directory, +.I `.'. + +.TP +.I \--rm +asks configure to remove a configuration rather than create one. + +.TP +.I \--site=SITE +asks configure to use any site-specific Makefile fragments for +.I SITE +when building Makefiles. + +.TP +.I \--prefix=DIR +sets the location in which to install files to +.I DIR. +The default is "/usr/local". + +.TP +.I \--exec_prefix=DIR +sets the root directory for host-dependent files to +.I DIR. +The default location is the value of +.I prefix. + +.TP +.I \--program_prefix=DIR +configures the source to install programs which have the same names as +common Unix programs, such as "make", in +.I DIR. +Also applies to programs which might be used for cross-compilation. + +.TP +.I \--tmpdir=DIR +sets the directory in which configure creates temporary files to +.I DIR. + +.TP +.I \--with-PACKAGE[=YES/NO] +sets a flag for the build to recognize that +.I PACKAGE +is explicitly present or not present. If +.I \=YES/NO +is nonexistent, the default is +.I YES. +.I \--without-PACKAGE +is equivalent to +.IR \--with-PACKAGE=no . + +.TP +.I \--enable-FEATURE[=YES/NO] +sets a flag for the build to recognize that +.I FEATURE +should be included or not included. If +.I \=YES/NO +is nonexistent, the default is +.I YES. +.I \--disable-FEATURE +is equivalent to +.IR --enable-FEATURE=no . + +.TP +.I \--norecursion +asks that only the current directory be configured. Normally +.I configure +recurs on subdirectories. + +.TP +.I \-nfp +Notifies +.I configure +that all of the specified hosts have +.I no floating point +units. + +.TP +.I \-s +used internally by configure to supress status messages on +subdirectory recursions. Override with +.I \-v + +.TP +.I \-v +verbose output. Asks that configure print status lines for each +directory configured. Normally, only the status lines for the current +directory are printed. + +.TP +.I \--version +.I \-V +prints +.I configure +version number. + +.TP +.I \-help +displays a brief usage summary. + + +.SH FILES +configure.in for each directory's individual needs +.br +Makefile.in Makefile template +.br +config.sub for parsing configuration names +.br +config.guess for guessing HOST when not specified +.br +config.status non-recursively rebuilds current directory + +.SH FILES +.ta \w'gmon.sum 'u +a.out the namelist and text space. +.br +gmon.out dynamic call graph and profile. +.br +gmon.sum summarized dynamic call graph and profile. + +.SH "SEE ALSO" +.RB "`\|" configure "\|'" +entry in +.B +info. diff --git a/gnu/lib/libg++/etc/configure.texi b/gnu/lib/libg++/etc/configure.texi new file mode 100644 index 00000000000..445777491fb --- /dev/null +++ b/gnu/lib/libg++/etc/configure.texi @@ -0,0 +1,1830 @@ +\input texinfo @c -*-texinfo-*- +@setfilename configure.info +@settitle Cygnus configure + +@synindex ky cp + +@setchapternewpage odd + +@ifinfo +@format +START-INFO-DIR-ENTRY +* configure: (configure). Cygnus configure. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@ifinfo +This document describes the Cygnus Support version of @code{configure}. + +Copyright (C) 1991, 1992, 1993 Cygnus Support +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 Cygnus Support. +@end ifinfo + +@c We should not distribute texinfo files with smallbook enabled. +@c @smallbook +@finalout +@titlepage +@title Cygnus configure +@author K. Richard Pixley +@author Cygnus Support +@page +@cindex copyleft + +@vskip 0pt plus 1filll +Edited January, 1993, by Jeffrey Osier, Cygnus Support. + +Copyright @copyright{} 1991, 1992, 1993 Cygnus Support + +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 Cygnus Support. +@end titlepage + +@c --------------------------------------------------------------------- +@ifinfo +@node Top +@top Cygnus configure + +This file documents the configuration system used and distributed by +Cygnus Support. + +@menu +* What configure does:: What configure does +* Invoking configure:: Invoking configure---basic usage +* Using configure:: More than you ever wanted to know +* Porting:: How to use configure with new programs +* Variables Index:: +* Concept Index:: +@end menu +@end ifinfo + +@c --------------------------------------------------------------------- +@node What configure does +@chapter What @code{configure} does +@cindex Introduction +@cindex Overview +@cindex What @code{configure} does +@kindex Cygnus Support Developer's Kit + +This manual documents Cygnus @code{configure}, a program which helps to +automate much of the setup activity associated with building large suites of +programs, such the Cygnus Support Developer's Kit. This manual is therefore +geared toward readers who are likely to face the problem of configuring +software in source form before compiling and installing it. We assume you are +an experienced programmer or system administrator. +@ifinfo +For further background on this topic, see @ref{Some Basic Terms, , Apologia +Configure, cfg-paper, On Configuring Development Tools}, by K. Richard +Pixley. +@end ifinfo +@iftex +For further background on this topic, see @cite{On Configuring Development +Tools} by K. Richard Pixley. +@end iftex + +When @code{configure} runs, it does the following things: + +@table @emph +@item @bullet{} creates build directories +@vindex srcdir +@cindex @code{srcdir} +@cindex Build directories +When you run @code{configure} with the @samp{--srcdir} option, it uses the +current directory as the @dfn{build directory}, creating under it a directory +tree that parallels the directory structure of the source directory. If you +don't specify a @samp{srcdir}, @code{configure} first assumes that the source +code you wish to configure is in your current directory; if it finds no +@file{configure.in} input file there, it searches in the directory +@code{configure} itself lies in. (For details, see @ref{Build directories, , +Build directories}.) + +@item @bullet{} generates @file{Makefile} +@cindex @code{Makefile} generation +A @file{Makefile} template from the source directory, usually called +@file{Makefile.in}, is copied to an output file in the build directory which is +most often named @file{Makefile}. @code{configure} places definitions for a +number of standard @file{Makefile} macros at the beginning of the output file. +If @w{@samp{--prefix=@var{dir}}} or @w{@samp{--exec_prefix=@var{dir}}} are +specified on the @code{configure} command line, corresponding @file{Makefile} +variables are set accordingly. If host, target, or site-specific +@file{Makefile} fragments exist, these are inserted into the output file. (For +details, see @ref{Makefile generation, , @code{Makefile} generation}.) + +@item @bullet{} generates @file{.gdbinit} +@cindex @code{.gdbinit} +If the source directory contains a @file{.gdbinit} file and the build directory +is not the same as the source directory, a @file{.gdbinit} file is created in +the build directory. This @file{.gdbinit} file contains commands which allow +the source directory to be read when debugging with the @sc{gnu} debugger, +@code{gdb}. (@xref{Command Files, , Command Files, gdb, Debugging With GDB}.) + +@item @bullet{} makes symbolic links +@cindex Symbolic links +Most build directories require that some symbolic links with generic names are +built pointing to specific files in the source directory. If the system where +@code{configure} runs cannot support symbolic links, hard links are used +instead. (For details, see @ref{configure.in, , The @code{configure.in} input +file}.) + +@item @bullet{} generates @file{config.status} +@cindex @code{config.status} +@code{configure} creates a shell script named @file{config.status} in the build +directory. This shell script, when run from the build directory (usually from +within a @file{Makefile}), will reconfigure the build directory (but not its +subdirectories). This is most often used to have a @file{Makefile} update +itself automatically if a new source directory is available. + +@item @bullet{} calls itself recursively +@cindex Recursion +If the source directory has subdirectories that should also be configured, +@code{configure} is called for each. +@end table + +@c --------------------------------------------------------------------- +@node Invoking configure +@chapter Invoking @code{configure} +@cindex Invoking @code{configure} +@cindex Usage + +Cygnus @code{configure} is a shell script which resides in a source tree. The +usual way to invoke @code{configure} is from the shell, as follows: + +@cindex Example session +@example +eg$ ./configure @var{hosttype} +@end example + +@noindent +This prepares the source in the current directory (@file{.}) to be +compiled for a @var{hosttype} environment. It assumes that you wish to +build programs and files in the default @dfn{build directory} (also the +current directory, @file{.}). If you do not specify a value for +@var{hosttype}, Cygnus @code{configure} will attempt to discover this +information by itself (@pxref{config.guess, , Determining system +information}). For information on @var{hosttype} environments, +@xref{Host, , Host}. + +All @sc{gnu} software is packaged with one or more @code{configure} script(s) +(@pxref{Configuration, , How Configuration Should Work, standards, GNU Coding +Standards}). By using @code{configure} you prepare the source for your +specific environment by selecting and using @file{Makefile} fragments and +fragments of shell scripts, which are prepared in advance and stored with the +source. + +@code{configure}'s command-line options also allow you to specify other aspects +of the source configuration: + +@smallexample + configure @var{hosttype} [--target=@var{target}] [--srcdir=@var{dir}] [--rm] + [--site=@var{site}] [--prefix=@var{dir}] [--exec-prefix=@var{dir}] + [--program-prefix=@var{string}] [--tmpdir=@var{dir}] + [--with-@var{package}[=@var{yes/no}]] [--without-@var{package}] + [--enable-@var{feature}[=@var{yes/no}]] [--disable-@var{feature}] + [--norecursion] [--nfp] [-s] [-v] [-V | --version] [--help] +@end smallexample + +@table @code +@item --target=@var{target} +@cindex @code{--target} +@cindex @code{target} option +@vindex target +Requests that the sources be configured to target the @var{target} machine. If +no target is specified explicitly, the target is assumed to be the same as the +host (i.e., a @dfn{native} configuration). @xref{Host, , Host}, and +@ref{Target, , Target}, for +discussions of each. + +@item --srcdir=@var{dir} +@cindex @code{--srcdir} +@cindex @code{srcdir} option +@vindex srcdir +Direct each generated @file{Makefile} to use the sources located in directory +@var{dir}. Use this option whenever you wish the object code to reside in a +different place from the source code. The @dfn{build directory} is always +assumed to be the directory you call @code{configure} from. See @ref{Build +directories, , Build directories}, for an example. If the source directory is +not specified, @code{configure} assumes that the source is in your current +directory. If @code{configure} finds no @file{configure.in} there, it searches +in the same directory that the @code{configure} script itself lies in. +Pathnames specified (Values for @var{dir}) can be either absolute relative to +the @emph{build} directory. + +@item --rm +@cindex @code{--rm} +@cindex @code{rm} option +@vindex rm +@emph{Remove} the configuration specified by @var{hosttype} and the other +command-line options, rather than create it. + +@c FIXME: check @ref +@quotation +@emph{Note:} We recommend that you use @samp{make distclean} rather than +use this option; see @ref{Invoking make,,Invoking @code{make},make,GNU +Make}, for details on @samp{make distclean}. +@end quotation + +@item --site=@var{site} +@cindex @code{--site} +@cindex @code{site} option +@vindex site +Generate the @file{Makefile} using site-specific @file{Makefile} fragments for +@var{site}. @xref{Makefile fragments, , Adding information about local +conventions}. + +@item --prefix=@var{dir} +@cindex @code{--prefix} +@cindex @code{prefix} option +@vindex prefix +Configure the source to install programs and files under directory @var{dir}. + +This option sets the variable @samp{prefix}. Each generated @file{Makefile} +will have its @samp{prefix} variables set to this value. (@xref{What configure +really does, , What @code{configure} really does}.) + +@item --exec-prefix=@var{dir} +@cindex @code{--exec-prefix} +@cindex @code{exec-prefix} option +@vindex exec-prefix +Configure the source to install @dfn{host dependent} files in @var{dir}. + +This option sets the variable @samp{exec_prefix}. Each generated +@file{Makefile} will have its @samp{exec_prefix} variables set to this value. +(@xref{What configure really does, , What @code{configure} really does}.) + +@item --program-prefix=@var{string} +@cindex @code{--program-prefix} +@cindex @code{program-prefix} option +@vindex program-prefix +Configure the source to install certain programs using @var{string} as a +prefix. This applies to programs which might be used for cross-compilation, +such as the compiler and the binary utilities, and also to programs which have +the same names as common Unix programs, such as @code{make}. + +This option sets the variable @samp{program_prefix}. Each generated +@file{Makefile} will have its @samp{program_prefix} variables set to this +value. (@xref{What configure really does, , What @code{configure} really +does}.) + +@item --tmpdir=@var{tmpdir} +@cindex @code{--tmpdir} +@cindex @code{tmpdir} option +@vindex tmpdir +Use the directory @var{tmpdir} for @code{configure}'s temporary files. The +default is the value of the environment variable @w{@code{TMPDIR}}, or +@file{/tmp} if the environment variable is not set. + +@item --with-@var{package}[=@var{yes/no}] +@itemx --without-@var{package} +@cindex @code{--with-@var{package}} +@cindex @code{with-@var{package}} option +@vindex with-@var{package} +@cindex @code{--without-@var{package}} +@cindex @code{without-@var{package}} option +@vindex without-@var{package} +Indicate that @var{package} is present, or not present, depending on +@var{yes/no}. If @var{yes/no} is nonexistent, its value is assumed to be +@code{yes}. @samp{--without-@var{package}} is equivalent to +@samp{--with-@var{package}=no}. + +For example, if you wish to configure the program @code{gcc} for a Sun +SPARCstation running SunOS 4.x, and you want @code{gcc} to use the +@sc{gnu} linker @code{ld}, you can configure @code{gcc} using + +@cindex Example session +@smallexample +eg$ configure --with-gnu-ld sun4 +@end smallexample + +@noindent +@xref{What configure really does, , What @code{configure} really does}, for +details. See the installation or release notes for your particular package for +details on which other @var{package} options are recognized. +@c FIXME - need to include info about --with-* in other dox! + +@item --enable-@var{feature}[=@var{yes/no}] +@itemx --disable-@var{feature} +@cindex @code{--enable-@var{feature}} +@cindex @code{enable-@var{feature}} option +@vindex enable-@var{feature} +@cindex @code{--disable-@var{feature}} +@cindex @code{disable-@var{feature}} option +@vindex disable-@var{feature} +Include @var{feature}, or not, depending on @var{yes/no}. If @var{yes/no} is +nonexistent, its value is assumed to be @code{yes}. +@samp{--disable-@var{feature}} is equivalent to +@samp{--enable-@var{feature}=no}. + +@noindent +@xref{What configure really does, , What @code{configure} really does}, for +details. See the installation or release notes for your particular package for +details on which other @var{feature} options are recognized. +@c FIXME - need to include info about --enable-* in other dox! + +@item --norecursion +@cindex @code{--norecursion} +@cindex @code{norecursion} option +@vindex norecursion +Configure only this directory; ignore any subdirectories. This is used by the +executable shell script @file{config.status} to reconfigure only the current +directory; it is most often used non-interactively, when @code{make} is +invoked. (@xref{config.status, , @code{config.status}}.) + +@item --nfp +@cindex @code{--nfp} +@cindex @code{nfp} option +@vindex nfp +Assume that the intended @var{hosttype} has no floating point unit. + +@item -s +@cindex @code{-s} +@cindex @code{s} option +Suppress status output. This option is used internally by +@code{configure} when calling itself recursively in subdirectories. You +can override this option with the @code{--verbose} option. + +@item -v +@itemx --verbose +@cindex @code{-v} +@cindex @code{--verbose} +@cindex @code{v} option +@cindex @code{verbose} option +@cindex Verbose Output +@vindex verbose +Print status lines for each directory configured. Normally, only the +status lines for the initial working directory are printed. + +@item --version +@itemx -V +@cindex version +@cindex @code{--version} +@cindex version +Print the @code{configure} version number. + +@item --help +@cindex Usage +@cindex @code{--help} +@cindex @code{help} option +Print a short summary of how to invoke @code{configure}. +@end table + +@cindex Abbreviating option names +@cindex Truncating option names +@cartouche +@emph{Note:} You may introduce options with a single dash, @samp{-}, rather +than two dashes, @samp{--}. However, you may not be able to truncate long +option names when using a single dash. When using two dashes, options may be +abbreviated as long as each option can be uniquely identified. For example, +@smallexample +eg$ configure --s=/u/me/src @var{hosttype} +@end smallexample +@noindent +is ambiguous, as @w{@samp{--s}} could refer to either @w{@samp{--site}} or +@w{@samp{--srcdir}}. However, +@smallexample +eg$ configure --src=/u/me/src @var{hosttype} +@end smallexample +@noindent +is a valid abbreviation. +@end cartouche + + +@c ======================================================================== +@node Using configure +@chapter Using @code{configure} +@cindex Using @code{configure} +@cindex Detailed usage +@cindex Usage: detailed + +@code{configure} prepares source directories for building programs in +them. ``Configuring'' is the process of preparing software to compile +correctly on a given @dfn{host}, for a given @dfn{target}. + +@code{configure} subsequently writes a configured @file{Makefile} from a +pre-built template; @code{configure} uses variables that have been set in the +configuring process to determine the values of some variables in the +@file{Makefile}. Because of this we will refer to both @code{configure} +variables and @file{Makefile} variables. This convention allows us to +determine where the variable should be set initially, in either +@file{configure.in} or @file{Makefile.in}. + +@menu +* What configure really does:: What configure really does +* configure.in:: The configure.in input file +* Install locations:: Where to install things once they are built +* Host:: Telling configure what will source will be built +* Target:: Telling configure what the source will target +* Makefile fragments:: Adding information about local conventions +* Makefile extensions:: Extensions to the GNU coding standards +@end menu + +@c --------------------------------------------------------------------- +@node What configure really does +@section What @code{configure} really does +@cindex What @code{configure} really does +@cindex Behind the scenes +@cindex @code{configure} back end +@cindex @code{configure} details + +Cygnus @code{configure} is a shell script that sets up an environment in +which your programs will compile correctly for your machine and +operating system, and will install in proper places. @code{configure} +accomplishes this task by doing the following: + +@itemize @bullet +@item +it generates a @file{Makefile} from a custom template called +@file{Makefile.in} in each relevant source directory; + +@item +it customizes the build process to your specifications; you set certain +variables for @code{configure}, either on the command line or in the +file @file{configure.in}, which subsequently sets variables in each +generated @file{Makefile} to be used by @code{make} when actually +building the software; + +@item +it creates @dfn{build directories}, places for your code to be compiled +in before being installed; + +@item +it generates a @file{.gdbinit} in the build directory, if needed, to +communicate to @code{gdb} where to find the program's source code; + +@item +it generates a shell script called @file{config.status} +which is used most often by the @file{Makefile} to reconfigure itself; + +@item +it recurses in subdirectories, setting up entire trees so that they build +correctly; if @code{configure} finds another @code{configure} script +further down in a given source tree, it knows to use this script and not +recur. +@end itemize + +For the sake of safety (i.e., in order to prevent broken installations), the +@sc{gnu} coding standards call for software to be @dfn{configured} in such a +way that an end user trying to build a given package will be able to do so by +affecting a finite number of variables. All @sc{gnu} software comes with an +executable @code{configure} shell script which sets up an environment within a +build directory which will correctly compile your new package for your host +(or, alternatively, whatever host you specify to @code{configure}). +@ifinfo +For further background on this topic, see @ref{Some Basic Terms, , Apologia +Configure, cfg-paper, On Configuring Development Tools}, by K. Richard +Pixley. +@end ifinfo +@iftex +For further background on this topic, see @cite{On Configuring Development +Tools} by K. Richard Pixley. +@end iftex + +Use @code{configure} to set for the build process: + +@itemize @bullet +@item +correct values for certain variables; + +@item +which type of host you wish to configure a given package for +(@pxref{Host, , Host}); + +@item +where you want to install this package (by using @samp{prefix}, +@samp{exec-prefix} and @samp{program-prefix}; @pxref{Install details, , +Full descriptions of all installation directories}); + +@item +optionally, which type of machine you wish to @dfn{target} this +package's output to (@pxref{Target, , Target}); + +@item +which other @sc{gnu} packages are already installed and available to +this particular build (by using the @samp{--with-@var{package}} option; +@pxref{Invoking configure, , Invoking @code{configure}}); + +@item +where to place temporary files (by using the @samp{--tmpdir=@var{dir}} +option; @pxref{Invoking configure, , Invoking @code{configure}}); + +@item whether to recur in subdirectories (changeable through the +@w{@samp{--norecursion}} option; @pxref{Invoking configure, , Invoking +@code{configure}}). +@end itemize + +@code{configure} uses a few other files to complete its tasks. These are +discussed in detail where noted. + +@table @code +@cindex Other files +@item configure.in +@cindex @code{configure.in} definition +Input file for @code{configure}. Shell script fragments reside here. +@xref{configure.in, , The @code{configure.in} input file}. + +@item Makefile.in +@cindex @code{Makefile.in} definition +Template which @code{configure} uses to build a file called @file{Makefile} in +the @dfn{build directory}. @xref{Makefile generation, , @code{Makefile} +generation}. + +@item config.sub +@cindex @code{config.sub} definition +Shell script used by @code{configure} to expand referents to the +@var{hosttype} argument into a single specification of the form +@w{@var{cpu-vendor-os}}. For instance, on the command line you can +specify + +@cindex Example session +@example +eg$ ./configure sun4 +@end example + +@noindent +to configure for a Sun SPARCstation running SunOS 4.x. @code{configure} +consults @code{config.sub} to find that the three-part specification for this +is + +@example +sparc-sun-sunos4.1.1 +@end example + +@noindent +which notes the @var{cpu} as @samp{sparc}, the @var{manufacturer} as @samp{sun} +(Sun Microsystems), and the @var{os} (operating system) as @samp{sunos4.1.1}, +the SunOS 4.1.1 release. @xref{configure variables, , Variables available to @code{configure}}. + +@item config.guess +@cindex @code{config.guess} definition +If you do not put the @var{hosttype} argument on the command line, +@code{configure} uses the @code{config.guess} shell script to make an +analysis of your machine (it assumes that you wish to configure your +software for the type of machine on which you are running). The output +of @code{config.guess} is a three-part identifier as described above. + +@item config.status +@cindex @code{config.status} definition +The final step in configuring a directory is to create a shell script, +@code{config.status}. The main purpose of this file is to allow the +@file{Makefile} for the current directory to rebuild itself, if +necessary. @xref{config.status, , @code{config.status}}. + +@item config/* +@cindex @code{config/} subdirectory +@code{configure} uses three types of @file{Makefile} @dfn{fragments}, which +reside in the directory @file{@var{srcdir}/config/}. @xref{Makefile fragments, +, Adding information about local conventions}. +@end table + +@menu +* Build variables:: Variable-spaghetti made simple +* Build directories:: Build directories described well +* Makefile generation:: To build a Makefile +* config.guess:: Be vewwy quiet, I'm hunting system information +* config.status:: To rebuild a Makefile +@end menu + +@c --------------------------------------------------------------------- +@node Build variables +@subsection Build variables +@cindex Build variables +@cindex Cygnus Support Developer's Kit +@cindex Variables + +There are several variables in the build process which you can control through +build programs such as @code{make}. These include machine definitions, local +conventions, installation locations, locations for temporary files, etc. This +data is accessible through certain variables which are configurable in the +build process; we refer to them as @dfn{build variables}. + +For lists of build variables which you can affect by using @code{configure}, +see @ref{configure variables, , Variables available to @code{configure.in}}, +and @ref{Install details, , Full descriptions of all installation directories}. + +Generally, build variables, which are used by the @file{Makefile} to +determine various aspects of the build and installation processes, are +changeable with command-line options to @code{configure}. In most large +suites of programs, like the Cygnus Support Developer's Kit, the +individual programs reside in several subdirectories of a single source +code ``tree''. All of these subdirectories need to be configured with +information relative to the @dfn{build directory}, which is not known +until @code{configure} is run. Unless specified otherwise, +@code{configure} recursively configures every subdirectory in the source +tree. + +Build variables are passed from @code{configure} directly into the +@file{Makefile}, and use the same names (except that dashes are +transformed into underbars; for example, when you specify the option +@samp{--exec-prefix} on the command line, the @file{Makefile} variable +@samp{exec_prefix} is set). In other words, if you specify + +@cindex Example session +@example +eg$ ./configure --prefix=/usr/gnu/local @dots{} @var{hosttype} +@end example + +@noindent +on the command line, @code{configure} sets an variable called @samp{prefix} to +@samp{/usr/gnu/local}, and passes this into the @file{Makefile} in the same +manner. After this command, each @file{Makefile} generated by @code{configure} +will contain a line that reads: + +@example +prefix = /usr/gnu/local +@end example + +For a list of the @file{Makefile} variables @code{configure} can change, and +instructions on how to change them, see @ref{configure variables, , Variables +available to @code{configure.in}}, and @ref{Invoking configure, , Invoking +@code{configure}}. + +@c --------------------------------------------------------------------- +@node Build directories +@subsection Build directories +@cindex Build directories +@cindex Object directories +@cindex Building for multiple hosts +@cindex Building for multiple targets + +By default, @code{configure} builds a @file{Makefile} and symbolic links in the +same directory as the source files. This default works for many cases, but it +has limitations. For instance, using this approach, you can only build object +code for one host at a time. + +We refer to each directory where @code{configure} builds a @file{Makefile} as +a @dfn{build directory}. + +The build directory for any given build is always the directory from which you +call @code{configure}, or @file{.} relative to your prompt. The default +@dfn{source directory}, the place @code{configure} looks to find source code, +is also @file{.}. For instance, if we have a directory @file{/gnu-stuff/src/} +that is the top branch of a tree of @sc{gnu} source code we wish to configure, +then the program we will use to configure this code is +@file{/gnu-stuff/src/configure}, as follows. (Assume for the sake of argument +that our machine is a sun4.) + +@cindex Example session +@smallexample +@group +eg$ cd /gnu-stuff/src +eg$ ./configure sun4 +Created "Makefile" in /gnu-stuff/src +eg$ +@end group +@end smallexample + +We just configured the code in @file{/gnu-stuff/src} to run on a Sun +SPARCstation using SunOS 4.x by creating a @file{Makefile} in +@file{/gnu-stuff/src}. By default, we also specified that when this code is +built, the object code should reside in the same directory, +@file{/gnu-stuff/src}. + +However, if we wanted to build this code for more than one host, we would be in +trouble, because the new configuration would write over the old one, destroying +it in the process. What we can do is to make a new @dfn{build directory} and +configure from there. Running @code{configure} from the new directory will +place a correct @file{Makefile} and a @file{config.status} in this new file. +That is all @code{configure} does; we must run @code{make} to generate any +object code. + +The new @file{Makefile} in @file{/gnu-stuff/sun4-obj}, created from the +template file @file{/gnu-stuff/src/Makefile.in}, contains all the information +needed to build the program. + +@cindex Example session +@smallexample +@group +eg$ mkdir /gnu-stuff/sun4-obj +eg$ cd /gnu-stuff/sun4-obj +eg$ ../src/configure --srcdir=../src sun4 +Created "Makefile" in /gnu-stuff/sun4-obj +eg$ ls +Makefile config.status +eg$ make all info install install-info clean +@var{compilation messages@dots{}} +eg$ mkdir /gnu-stuff/solaris2 +eg$ cd /gnu-stuff/solaris2 +eg$ ../src/configure --srcdir=../src sol2 +Created "Makefile" in /gnu-stuff/solaris2 +eg$ ls +Makefile config.status +eg$ make all info install install-info clean +@var{compilation messages@dots{}} +@end group +@end smallexample + +We can repeat this for other configurations of the same software simply +by making a new build directory and reconfiguring from inside it. If +you do not specify the @var{hosttype} argument, @code{configure} +will attempt to figure out what kind of machine and operating system you +happen to be using. @xref{config.guess, , Determining system +information}. Of course, this may not always be the configuration you +wish to build. + +@emph{Caution:} If you build more than one configuration for a single program, +remember that you must also specify a different @samp{--prefix} for each +configuration at configure-time. Otherwise, both configurations will be +installed in the same default location (@file{/usr/local}); the configuration +to be installed last would overwrite previously installed configurations. + +@c --------------------------------------------------------------------- +@node Makefile generation +@subsection @code{Makefile} generation +@cindex @code{Makefile} generation + +Cygnus @code{configure} creates a file called @file{Makefile} in the build +directory which can be used with @code{make} to automatically build a given +program or package. @code{configure} also builds a @file{Makefile} for each +relevant subdirectory for a given program or package (irrelevant subdirectories +would be those which contain no code which needs configuring, and which +therefore have no @code{configure} input file @file{configure.in} and no +@file{Makefile} template @file{Makefile.in}). @xref{Running, @code{make} +Invocation, How to Run @code{make}, make, GNU Make}, for details on using +@code{make} to compile your source code. + +Each @file{Makefile} contains variables which have been configured for a +specific build. These build variables are determined when @code{configure} is +run. All build variables have defaults. By default, @code{configure} +generates a @file{Makefile} which specifies: + +@cindex Default configuration +@itemize @bullet +@item a @dfn{native} build, which is to occur + +@item in the current directory, and which will be installed + +@item in the default installation directory (@file{/usr/local}) when the code +is compiled with @code{make}. +@end itemize + +@noindent +Variables are changeable through command-line options to @code{configure} +(@pxref{Invoking configure, , Invoking @code{configure}}). + +If you are porting a new program and intend to use @code{configure}, see +@ref{Porting, , Porting with @code{configure}}, as well as @ref{Makefiles, , +Writing Makefiles, make, GNU Make}, and @ref{Makefiles, , Makefile Conventions, +standards, GNU Coding Standards}. + +@c --------------------------------------------------------------------- +@node config.guess +@subsection Determining system information +@cindex @code{config.guess} + +The shell script @code{config.guess} is called when you do not specify a +@var{hosttype} on the command line to @code{configure}. @code{config.guess} +acquires available system information from your local machine through the shell +command @code{uname}. It compares this information to a database and attempts +to determine a usable three-part system identifier (known as a @dfn{triple}) to +use as your @var{hosttype}. @xref{What configure really does, , What +@code{configure} really does}, to see how this information is used. + +@emph{Note:} If you do not specify a @var{hosttype} on the command line, +@code{configure} will attempt to configure your software to run on the machine +you happen to be using. This may not be the configuration you desire. + +@c --------------------------------------------------------------------- +@node config.status +@subsection @code{config.status} +@cindex @code{config.status} + +The final step in configuring a directory is to create an executable shell +script, @file{config.status}. The main purpose of this file is to allow the +@file{Makefile} for the current directory to rebuild itself, if necessary. It +is usually run from within the @file{Makefile}. @xref{Makefile extensions, , +Extensions to the @sc{gnu} coding standards}. + +@file{config.status} also contains a record of the @code{configure} session +which created it. + +@c --------------------------------------------------------------------- +@node configure.in +@section The @code{configure.in} input file +@cindex @code{configure.in} + +A @file{configure.in} file for Cygnus @code{configure} consists of a +@dfn{per-invocation} section, followed by a @dfn{per-host} section, followed by +a @dfn{per-target} section, optionally followed by a @dfn{post-target} section. +Each section is a shell script fragment, which is executed by the +@code{configure} shell script at an appropriate time. Values are passed among +@code{configure} and the shell fragments through a set of shell variables. +When each section is being interpreted by the shell, the shell's current +directory is the build directory, and any files created by the section (or +referred to by the section) will be relative to the build directory. To +reference files in other places (such as the source directory), prepend a shell +variable such as @samp{$(srcdir)/} to the desired file name. + +@cindex @i{per-invocation} section +The beginning of the @file{configure.in} file begins the @dfn{per-invocation} +section. + +@cindex @i{per-host} section +A line beginning with @samp{# per-host:} begins the @dfn{per-host} section. + +@cindex @i{per-target} section +A line beginning with @samp{# per-target:} begins the @dfn{per-target} section. + +@cindex @i{post-target} section +If it exists, the @dfn{post-target} section begins with @samp{# post-target:}. + +@menu +* configure variables:: Variables available to configure.in +* Minimal:: A minimal configure.in +* Declarations:: For each invocation +* per-host:: Host-specific instructions +* per-target:: Target-specific instructions +* post-target:: Instructions to be executed after target info +* Example:: An example configure.in +@end menu + +@c --------------------------------------------------------------------- +@node configure variables +@subsection Variables available to @code{configure.in} +@cindex @file{configure.in} interface +@cindex configure variables + +The following variables pass information between the standard parts of +@code{configure} and the shell-script fragments in @file{configure.in}: + +@table @code +@item srctrigger +@cindex @code{srctrigger} +@vindex srctrigger +Contains the name of a source file that is expected to live in the source +directory. You must usually set this in the @dfn{per-invocation} section of +@file{configure.in}. @code{configure} tests to see that this file exists. If +the file does not exist, @code{configure} prints an error message. This is +used as a sanity check that @file{configure.in} matches the source directory. + +@item srcname +@cindex @code{srcname} +@vindex srcname +Contains the name of the source collection contained in the source directory. +You must usually set this in the @dfn{per-invocation} section of +@file{configure.in}. If the file named in @samp{srctrigger} does not exist, +@code{configure} uses the value of @samp{srcname} when it prints the error +message. + +@item configdirs +@cindex @code{configdirs} +@vindex configdirs +Contains the names of any subdirectories in which @code{configure} should +recurse. You must usually set this in the @dfn{per-invocation} section of +@file{configure.in}. +If @file{Makefile.in} contains a line starting with @samp{SUBDIRS =}, +then it will be replaced with an assignment to @samp{SUBDIRS} using +the value of @samp{configdirs} (if @samp{subdirs} is empty). This can +be used to determine which directories to configure and build depending +on the host and target configurations. +@c Most other matching makefile/config vars use the same name. Why not +@c this? (FIXME). +@c Can we get rid of SUBDIRS-substitution? It doesn't work well with subdirs. +Use @samp{configdirs} (instead of the @samp{subdirs} variable +described below) if you want to be able to partition the +subdirectories, or use independent @file{Makefile} fragments. +Each subdirectory can be independent, and independently reconfigured. + +@item subdirs +@cindex @code{subdirs} +@vindex subdirs +Contains the names of any subdirectories where @code{configure} should create a +@file{Makefile} (in addition to the current directory), @emph{without} +recursively running @code{configure}. Use @samp{subdirs} (instead of the +@samp{configdirs} variable described above) if you want to configure all of the +directories as a unit. Since there is a single invocation of @code{configure} +that configures many directories, all the directories can use the same +@file{Makefile} fragments, and the same @code{configure.in}. + +@item host +@cindex @code{host} +@cindex Canonical ``triple'' +@vindex host +Contains the full configuration name for the host (generated by the script +@file{config.sub} from the name that you entered). This is a three-part +name (commonly referred to as a @dfn{triple}) of the form +@var{cpu}-@var{vendor}-@var{os}. + +There are separate variables @samp{host_cpu}, @samp{host_vendor}, and +@samp{host_os} that you can use to test each of the three parts; this variable +is useful, however, for error messages, and for testing combinations of the +three components. + +@item host_cpu +@vindex host_cpu +Contains the first element of the canonical triple representing the host +as returned by @file{config.sub}. This is occasionally used to +distinguish between minor variations of a particular vendor's operating +system and sometimes to determine variations in binary format between +the host and the target. + +@item host_vendor +@vindex host_vendor +Contains the second element of the canonical triple representing the host as +returned by @file{config.sub}. This is usually used to distinguish among the +numerous variations of @emph{common} operating systems. +@c "@emph{common} OS" doesn't convey much to me. Is this meant to cover +@c cases like Unix, widespread but with many variations? + +@item host_os +@vindex host_os +Contains the the third element of the canonical triple representing the +host as returned by @file{config.sub}. + +@item target +@cindex @code{target} +@cindex Canonical ``triple'' +@vindex target +Contains the full configuration name (generated by the script @file{config.sub} +from the name that you entered) for the target. Like the host, this is a +three-part name of the form @var{cpu}-@var{vendor}-@var{os}. + +There are separate variables @samp{target_cpu}, @samp{target_vendor}, and +@samp{target_os} that you can use to test each of the three parts; this +variable is useful, however, for error messages, and for testing combinations +of the three components. + +@item target_cpu +@vindex target_cpu +Contains the first element of the canonical triple representing the target as +returned by @file{config.sub}. This variable is used heavily by programs which +are involved in building other programs, like the compiler, assembler, linker, +etc. Most programs will not need the @samp{target} variables at all, but this +one could conceivably be used to build a program, for instance, that operated +on binary data files whose byte order or alignment differ from the system where +the program is running. + +@item target_vendor +@vindex target_vendor +Contains the second element of the canonical triple representing the target as +returned by @file{config.sub}. This is usually used to distinguish among the +numerous variations of @emph{common} operating systems or object file +formats. It is sometimes used to switch between different flavors of user +interfaces. +@c above query re "@emph{common} OS" applies here too + +@item target_os +@vindex target_os +Contains the the third element of the canonical triple representing the +target as returned by @file{config.sub}. This variable is used by +development tools to distinguish between subtle variations in object +file formats that some vendors use across operating system releases. It +might also be use to decide which libraries to build or what user +interface the tool should provide. + +@item floating_point +@cindex @code{floating_point} +@cindex @code{nfp} option +@vindex floating_point +Set to @samp{no} if you invoked @code{configure} with the @samp{--nfp} +command-line option, otherwise it is empty. This is a request to target +machines with @dfn{no floating point} unit, even if the targets ordinarily have +floating point units available. + +@item gas +@cindex @code{with-gnu-as} option +@vindex gas +Set to @samp{true} if you invoked @code{configure} with the +@w{@samp{--with-gnu-as}} command line option, otherwise it is empty. This is a +request to assume that the specified @var{hosttype} machine has @sc{gnu} @code{as} +available even if it ordinarily does not. + +@item srcdir +@cindex @code{srcdir} +@vindex srcdir +Set to the name of the directory containing the source for this program. +This will be different from @file{.} if you have specified the +@samp{--srcdir=@var{dir}} option. @samp{srcdir} can indicate either an +absolute path or a path relative to the build directory. + +@item package_makefile_frag +@vindex package_makefile_frag +If set in @file{configure.in}, this variable should be the name a file relative +to @samp{srcdir} to be included in the resulting @file{Makefile}. If the named +file does not exist, @code{configure} will print a warning message. This +variable is not set by @code{configure}. + +@item host_makefile_frag +@vindex host_makefile_frag +If set in @file{configure.in}, this variable should be the name a file relative +to @samp{srcdir} to be included in the resulting @file{Makefile}. If the named +file does not exist, @code{configure} will print a warning message. This +variable is not set by @code{configure}. + +@item target_makefile_frag +@vindex target_makefile_frag +If set in @file{configure.in}, this variable should be the name of a file, +relative to @samp{srcdir}, to be included in the resulting @file{Makefile}. If +the named file does not exist, @code{configure} will print a warning message. +This variable is not set by @code{configure}. + +@item site_makefile_frag +@vindex site_makefile_frag +Set to a file name representing to the default @file{Makefile} fragment for +this host. It may be set in @file{configure.in} to override this default. +Normally @samp{site_makefile_frag} is empty, but will have a value if you +specify @samp{--site=@var{site}} on the command line. +@ignore -- this doesn't fit +It is probably not a good idea to override this variable from +@file{configure.in}, since that may defeat the @code{configure} user's +intentions. +@end ignore + +@item Makefile +@vindex Makefile +Set to the name of the generated @file{Makefile}. Normally this value is +precisely @file{Makefile}, but some programs may want something else. + +@item removing +@cindex @code{rm} option +@vindex removing +Normally empty but will be set to some non-null value if you specified +@samp{--rm} on the command line. That is, if @samp{removing} is not empty, +then @code{configure} is @emph{removing} a configuration rather than creating +one. + +@item files +@cindex Symbolic links +@vindex files +If this variable is not empty following the @dfn{per-target} section, +then each word in its value will be the target of a symbolic link named +in the corresponding word from the @samp{links} variable. + +@item links +@cindex Symbolic links +@vindex links +If the @samp{files} variable is not empty following the @dfn{per-target} +section, then @code{configure} creates symbolic links with the first word of +@samp{links} pointing to the first word of @samp{files}, the second word of +@samp{links} pointing to the second word of @samp{files}, and so on. +@end table + +@c --------------------------------------------------------------------- +@node Minimal +@subsection A minimal @code{configure.in} +@cindex Minimal @file{configure.in} example + +A minimal @file{configure.in} consists of four lines. + +@example +srctrigger=foo.c +srcname="source for the foo program" +# per-host: +# per-target: +@end example + +The @samp{# per-host:} and @samp{# per-target:} lines divide the file into the +three required sections. The @samp{srctrigger} line names a file. +@code{configure} checks to see that this file exists in the source directory +before configuring. If the @samp{srctrigger} file does not exist, +@code{configure} uses the value of @samp{srcname} to print an error message +about not finding the source. + +This particular example uses no links, and only the default host, +target, and site-specific @file{Makefile} fragments if they exist. + +@c --------------------------------------------------------------------- +@node Declarations +@subsection For each invocation +@cindex For each invocation +@cindex Declarations section +@cindex @i{per-invocation} section + +@code{configure} invokes the entire shell script fragment from the start of +@file{configure.in} up to a line beginning with @w{@samp{# per-host:}} +immediately after parsing command line arguments. The variables +@samp{srctrigger} and @samp{srcname} @emph{must} be set here. + +You might also want to set the variables @samp{configdirs} and +@samp{package_makefile_frag} here. + +@c --------------------------------------------------------------------- +@node per-host +@subsection Host-specific instructions +@cindex Host-specific instructions +@cindex @i{host} shell-script fragment +@cindex @i{per-host} section + +The @dfn{per-host} section of @file{configure.in} starts with the line that +begins with @w{@samp{# per-host:}} and ends before a line beginning with +@w{@samp{# per-target:}}. @code{configure} invokes the commands in the +@dfn{per-host} section when determining host-specific information. + +This section usually contains a big @code{case} statement using the variable +@samp{host} to determine appropriate values for @samp{host_makefile_frag} and +@samp{files}, although @samp{files} is not usually set here. Usually, it is +set at the end of the @dfn{per-target} section after determining the names of +the target specific configuration files. + +@c --------------------------------------------------------------------- +@node per-target +@subsection Target-specific instructions +@cindex Target-specific instructions +@cindex target shell-script fragment +@cindex @i{per-target} section + +The @dfn{per-target} section of @file{configure.in} starts with the line that +begins with @w{@samp{# per-target:}} and ends before the line that begins with +@w{@samp{# post-target:}}, if there is such a line. Otherwise the +@dfn{per-target} section extends to the end of the file. @code{configure} +invokes the commands in the @dfn{per-target} section when determining +target-specific information, and before building any files, directories, or +links. + +This section usually contains a big @code{case} statement using the variable +@samp{target} to determine appropriate values for @samp{target_makefile_frag} +and @samp{files}. The last lines in the @dfn{per-target} section normally set +the variables @samp{files} and @samp{links}. + +@c --------------------------------------------------------------------- +@node post-target +@subsection Instructions to be executed after target info +@cindex Post-target shell-script fragment +@cindex @i{post-target} section + +The @dfn{post-target} section is optional. If it exists, the +@samp{post-target} section starts with a line beginning with @w{@samp{# +Post-target:}} and extends to the end of the file. If it exists, +@code{configure} invokes this section once for each target after +building all files, directories, or links. + +This section is seldom needed, but you can use it to edit the @file{Makefile} +generated by @code{configure}. + +@c --------------------------------------------------------------------- +@node Example +@subsection An example @code{configure.in} +@cindex Example @file{configure.in} +@cindex Sample @file{configure.in} +@c @cindex @code{bison} @file{configure.in} +@c this won't be the bison configure.in for long.. need better example + +Here is a small example of a @file{configure.in} file. + +@cartouche +@example +@group +# This file is a collection of shell script fragments +# used to tailor a template configure script as +# appropriate for this directory. For more information, +# see configure.texi. + +configdirs= +srctrigger=warshall.c +srcname="bison" + +# per-host: +case "$@{host@}" in +m88k-motorola-*) + host_makefile_frag=config/mh-delta88 + ;; +esac + +# per-target: +files="bison_in.hairy" +links="bison.hairy" + +# post-target: +@end group +@end example +@end cartouche + +@c --------------------------------------------------------------------- +@node Install locations +@section Install locations +@cindex Where to install +@cindex Install locations + +Using the default configuration, @samp{make install} creates a single tree of +files, some of which are programs. The location of this tree is determined by +the value of the variable @samp{prefix}. The default value of @samp{prefix} is +@samp{/usr/local}. This is often correct for native tools installed on only +one host. + +@menu +* prefix:: Changing the default install directory +* exec_prefix:: How to separate host independent files + from host dependent files when + installing for multiple hosts +* Install details:: Full descriptions of all installation subdirectories +@end menu + +@c --------------------------------------------------------------------- +@node prefix +@subsection Changing the default install directory +@cindex Changing the install directory +@cindex @code{prefix} option +@vindex prefix + +In the default configuration, all files are installed in subdirectories +of @file{/usr/local}. The location is determined by the value of +the @code{configure} variable @samp{prefix}; in turn, this determines the +value of the @file{Makefile} variable of the same name (@samp{prefix}). + +You can also set the value of the @file{Makefile} variable @samp{prefix} +explicitly each time you invoke @code{make} if you are so inclined. However, +because many programs have this location compiled in, you must specify the +@samp{prefix} value consistently on each invocation of @code{make}, or you will +end up with a broken installation. + +To make this easier, the value of the @code{configure} variable +@samp{prefix} can be set on the command line to @code{configure} +using the option @samp{--prefix=}. + +@c --------------------------------------------------------------------- +@node exec_prefix +@subsection Installing for multiple hosts +@cindex Configuring for multiple hosts +@cindex Sharing host-independent files +@cindex Installing host-independent files +@cindex The @code{exec_prefix} directory +@vindex exec_prefix + +By default, host dependent files are installed in subdirectories of +@file{$(exec_prefix)}. The location is determined by the value of the +@code{configure} variable @samp{exec_prefix}, which determines the value of the +@file{Makefile} variable @samp{exec_prefix}. This makes it easier to install +for a single host, and simplifies changing the default location for the install +tree. The default doesn't allow for multiple hosts to effectively share +host independent files, however. + +To configure so that multiple hosts can share common files, use something like: + +@cindex Example session +@smallexample +configure @var{host1} -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host1 +make all info install install-info clean + +configure @var{host2} -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host2 +make all info install install-info +@end smallexample + +The first line configures the source for @var{host1} to place host-specific +programs in subdirectories of @file{/usr/gnu/H-@var{host1}}. + +The second line builds and installs all programs for @var{host1}, +including both host-independent and host-specific files, as well as removing +the host-specific object files from of the build directory. + +The third line reconfigures the source for @var{host2} to place host +specific programs in subdirectories of @file{/usr/gnu/H-@var{host2}}. + +The fourth line builds and installs all programs for @var{host2}. Host +specific files are installed in new directories, but the host +independent files are installed @emph{on top of} the host +independent files installed for @var{host1}. This results in a single +copy of the host independent files, suitable for use by both hosts. + +@xref{Makefile extensions, , Extensions to the @sc{gnu} coding standards}, for +more information. + +@c --------------------------------------------------------------------- +@node Install details +@subsection Full descriptions of all installation subdirectories +@cindex Install details +@cindex Installation subdirectories +@cindex Subdirectories + +During any install, a number of standard directories are created. Their names +are determined by @file{Makefile} variables. Some of the defaults for +@file{Makefile} variables can be changed at configuration time using command +line options to @code{configure}. For more information on the standard +directories or the @file{Makefile} variables, please refer to @ref{Makefiles, , +Makefile Conventions, standards, GNU Coding Standards}. See also @ref{Makefile +extensions, , Extensions to the @sc{gnu} coding standards}. + +Note that @code{configure} does not create the directory indicated by the +variable @samp{srcdir} at any time. @code{$(srcdir)} is not an installation +directory. + +You can override all @file{Makefile} variables on the command line to +@code{make}. (@xref{Overriding, , Overriding Variables, make, GNU Make}.) If +you do so, you will need to specify the value precisely the same way for each +invocation of @code{make}, or you risk ending up with a broken installation. +This is because many programs have the locations of other programs or files +compiled into them. If you find yourself overriding any of the variables +frequently, you should consider site dependent @file{Makefile} fragments. See +also @ref{Sites, , Adding site info}. + +During @samp{make install}, a number of standard directories are created and +populated. The following @file{Makefile} variables define them. Those whose +defaults are set by corresponding @code{configure} variables are marked +``@code{Makefile} and @code{configure}''. + +@table @code +@item prefix (@code{Makefile} and @code{configure}) +@cindex @code{prefix} +@vindex prefix +The root of the installation tree. You can set its @file{Makefile} default +with the @samp{--prefix=} command line option to @code{configure} +(@pxref{Invoking configure, , Invoking @code{configure}}). The default value +for @samp{prefix} is @samp{/usr/local}. + +@item bindir +@cindex @code{bindir} +@vindex bindir +A directory for binary programs that users can run. The default value for +@samp{bindir} depends on @samp{prefix}; @samp{bindir} is normally changed only +indirectly through @samp{prefix}. The default value for @samp{bindir} is +@samp{$(prefix)/bin}. + +@item exec_prefix (@code{Makefile} and @code{configure}) +@cindex @code{exec_prefix} +@vindex exec_prefix +A directory for host dependent files. You can specify the @file{Makefile} +default value by using the @samp{--exec_prefix=} option to @code{configure}. +(@xref{Invoking configure, , Invoking @code{configure}}.) The default value +for @samp{exec_prefix} is @samp{$(prefix)}. + +@item libdir +@cindex @code{libdir} +@vindex libdir +A directory for libraries and support programs. The default value for +@samp{libdir} depends on @samp{prefix}; @samp{libdir} is normally changed only +indirectly through @samp{prefix}. The default value for @samp{libdir} is +@samp{$(prefix)/lib}. + +@item mandir +@cindex @code{mandir} +@vindex mandir +A directory for @code{man} format documentation (``man pages''). The default +value for @samp{mandir} depends on @samp{prefix}; @samp{mandir} is normally +changed only indirectly through @samp{prefix}. The default value for +@samp{mandir} is @samp{$(prefix)/man}. + +@item man@var{N}dir +@cindex @code{man@var{N}dir} +@vindex man@var{N}dir +These are eight variables named @samp{man1dir}, @samp{man2dir}, etc. They name +the specific directories for each man page section. For example, +@samp{man1dir} by default holds the filename @file{$(mandir)/man1}; this +directory contains @file{emacs.1} (the man page for @sc{gnu} Emacs). +Similarly, @samp{man5dir} contains the value @file{$(mandir)/man5}, indicating +the directory which holds @file{rcsfile.5} (the man page describing the +@code{rcs} data file format). The default value for any of the +@samp{man@var{N}dir} variables depends indirectly on @samp{prefix}, and is +normally changed only through @samp{prefix}. The default value for +@samp{man@var{N}dir} is @samp{$(mandir)/man@var{N}}. + +@item man@var{N}ext +@cindex @code{man@var{N}ext} +@vindex man@var{N}ext +@emph{Not supported by Cygnus @code{configure}}. The @cite{@sc{gnu} Coding +Standards} do not call for @samp{man1ext}, @samp{man2ext}, so the intended use +for @code{manext} is apparently not parallel to @samp{mandir}. Its use is not +clear. (See also @ref{Makefile extensions, , Extensions to the @sc{gnu} coding +standards}.) + +@item infodir +@cindex @code{infodir} +@vindex infodir +A directory for @code{info} format documentation. The default value for +@samp{infodir} depends indirectly on @samp{prefix}; @samp{infodir} is +normally changed only through @samp{prefix}. The default value for +@samp{infodir} is @samp{$(prefix)/info}. + +@item docdir +@cindex @code{docdir} +@vindex docdir +A directory for any documentation that is in a format other than those used by +@code{info} or @code{man}. The default value for @samp{docdir} depends +indirectly on @samp{prefix}; @samp{docdir} is normally changed only through +@samp{prefix}. The default value for @samp{docdir} is @samp{$(datadir)/doc}. +@emph{This variable is an extension to the @sc{gnu} coding standards}. (See +also @ref{Makefile extensions, , Extensions to the @sc{gnu} coding standards}.) + +@item includedir +@cindex @code{includedir} +@vindex includedir +A directory for the header files accompanying the libraries installed in +@samp{libdir}. The default value for @samp{includedir} depends on +@samp{prefix}; @samp{includedir} is normally changed only indirectly +through @samp{prefix}. The default value for @samp{includedir} is +@samp{$(prefix)/include}. +@end table + +@c --------------------------------------------------------------------- +@node Host +@section Host +@cindex Host + +The arguments to @code{configure} are @dfn{hosttypes}. By +@dfn{hosttype} we mean the @dfn{environment} in which the source will be +compiled. This need not necessarily be the same as the physical machine +involved, although it usually is. + +For example, if some obscure machine had the @sc{gnu} @code{POSIX} emulation +libraries available, it would be possible to configure most @sc{gnu} source for +a @code{POSIX} system and build it on the obscure host. + +For more on this topic, see @ref{Host Environments, On Configuring Development +Tools, Host Environments, cfg-paper, On Configuring Development Tools}. + +@c --------------------------------------------------------------------- +@node Target +@section Target +@cindex Target + +For building native development tools, or most of the other @sc{gnu} +tools, you need not worry about the target. The @dfn{target} of a +configuration defaults to the same as the @dfn{host}. + +For building cross development tools, please see @ref{Building Development +Environments, On Configuring Development Tools, Building Development +Environments, cfg-paper, On Configuring Development Tools}. + +@c --------------------------------------------------------------------- +@node Makefile fragments +@section Adding information about local conventions +@cindex @code{Makefile} fragments +@cindex Local conventions +@cindex Adding local info +@cindex Adding site info + +If you find that a tool does not get configured to your liking, or if +@code{configure}'s conventions differ from your local conventions, you should +probably consider @dfn{site-specific @file{Makefile} fragments}. See also +@ref{Sites, , Adding site info}. + +These are probably not the right choice for options that can be set from +the @code{configure} command line or for differences that are host or +target dependent. + +Cygnus @code{configure} uses three types of @file{Makefile} fragments. In a +generated @file{Makefile} they appear in the order: @dfn{target fragment}, +@dfn{host fragment}, and @dfn{site fragment}. This allows host fragments to +override target fragments, and site fragments to override both. + +Host-specific @file{Makefile} fragments conventionally reside in the +@file{./config/} subdirectory with names of the form @file{mh-@var{hosttype}}. +They are used for hosts that require odd options to the standard compiler and +for compile time options based on the host configuration. + +Target-specific @file{Makefile} fragments conventionally reside in the +@file{./config/} subdirectory with names of the form @file{mt-@var{target}}. +They are used for target dependent compile time options. + +Site specific @file{Makefile} fragments conventionally reside in the +@file{./config/} subdirectory with names of the form @file{ms-@var{site}}. +They are used to override host- and target-independent compile time options. +Note that you can also override these options on the @code{make} invocation +line. + +@c --------------------------------------------------------------------- +@node Makefile extensions +@section Extensions to the @sc{gnu} coding standards +@cindex @code{Makefile} extensions +@cindex Cygnus extensions +@cindex Coding standards extensions + +The following additions to the @sc{gnu} coding standards are required for +Cygnus @code{configure} to work properly. + +@itemize @bullet +@item +The @file{Makefile} must contain exactly one line starting with @samp{####}. +This line should follow any default macro definitions but precede any rules. +Host, target, and site-specific @file{Makefile} fragments will be inserted +immediately after this line. If the line is missing, the fragments will not be +inserted. + +@item +Cygnus adds the following targets to each @file{Makefile}. Their existence is +not required for Cygnus @code{configure}, but they are documented here for +completeness. + +@table @code +@kindex info +@item info +Build all info files from texinfo source. + +@kindex install-info +@item install-info +Install all info files. + +@kindex clean-info +@item clean-info +Remove all info files and any intermediate files that can be generated +from texinfo source. + +@kindex Makefile +@item Makefile +Calls @code{./config.status} to rebuild the @file{Makefile} in this directory. +@end table + +@item +The following @file{Makefile} targets have revised semantics: + +@table @code +@kindex install +@item install +Should @emph{not} depend on the target @samp{all}. If the program is not +already built, @samp{make install} should fail. This allows you to install +programs even when @code{make} would otherwise determine them to be out of +date. This can happen, for example, when the result of a @samp{make all} is +transported via tape to another machine for installation. + +@kindex clean +@item clean +Should remove any file that can be regenerated by the @file{Makefile}, +excepting only the @file{Makefile} itself, and any links created by +@code{configure}. That is, @code{make all clean} should return all directories +to their original condition. If this is not done, then the command sequence + +@cindex Example session +@example +configure @var{host1} ; make all install clean ; +configure @var{host2} ; make all install +@end example + +@noindent +will fail because of intermediate files intended for @var{host1}. +@end table + +@item +Cygnus adds the following macros to all @file{Makefile.in} files, but +you are not required to use them to run Cygnus @code{configure}. + +@table @code +@kindex docdir +@item docdir +The directory in which to install any documentation that is not either a +@code{man} page or an @code{info} file. For @code{man} pages, see +@samp{mandir}; for @code{info}, see @samp{infodir}. + +@kindex includedir +@item includedir +The directory in which to install any header files that should be made +available to users. This is distinct from the @code{gcc} include directory, +which is intended for @code{gcc} only. Files in @samp{includedir} may be used +by @code{cc} as well. +@end table + +@item +The following macros have revised semantics. Most of them describe +installation directories; see also @ref{Install details, , Full description of +all installation subdirectories}. + +@table @code +@kindex datadir +@item datadir +is used for host independent data files. + +@kindex mandir +@item mandir +The default path for @samp{mandir} depends on @samp{prefix}. + +@kindex infodir +@item infodir +The default path for @samp{infodir} depends on @samp{prefix}. + +@kindex BISON +@item BISON +is assumed to have a @code{yacc} calling convention. To use @sc{gnu} +@code{bison}, use @samp{BISON=bison -y}. +@end table + +@item +Each Cygnus @file{Makefile} also conforms to one additional restriction: + +When libraries are installed, the line containing the call to +@samp{INSTALL_DATA} should always be followed by a line containing a call to +@samp{RANLIB} on the installed library. This is to accommodate systems that +use @code{ranlib}. Systems that do not use @code{ranlib} can set @samp{RANLIB} +to ``@code{echo}'' in a host specific @file{Makefile} fragment. +@end itemize + +@c ======================================================================== +@node Porting +@chapter Porting with @code{configure} +@cindex Porting with @code{configure} + +This section explains how to add programs, host and target configuration +names, and site-specific information to Cygnus @code{configure}. + +@menu +* Programs:: Adding configure to new programs +* Hosts and targets:: Adding hosts and targets +* Sites:: Adding site info +@end menu + +@c --------------------------------------------------------------------- +@node Programs +@section Adding @code{configure} to new programs +@cindex Adding @code{configure} to new programs + +If you are writing a new program, you probably shouldn't worry about porting or +configuration issues until it is running reasonably on some host. Then refer +back to this section. + +If your program currently has a @code{configure} script that meets the @sc{gnu} +standards (@pxref{Configuration, , How Configuration Should Work, standards, +GNU Coding Standards}, please do not add Cygnus @code{configure}. It should be +possible to add this program without change to a Cygnus @code{configure} style +source tree. + +@cindex @code{autoconf} +If the program is not target dependent, please consider using @code{autoconf} +instead of Cygnus @code{configure}. @code{autoconf} is available from the Free +Software Foundation; it is a program which generates an executable shell script +called @file{configure} by automatically finding information on the system to +be configured on and embedding this information in the shell script. +@file{configure} scripts generated by @code{autoconf} require no arguments, and +accept the same options as Cygnus @code{configure}. For detailed instructions +on using @code{autoconf}, see @ref{Making configure Scripts, , How to organize +and produce Autoconf scripts, autoconf, Autoconf}. + + +To add Cygnus @code{configure} to an existing program, do the following: + +@table @bullet +@item Make sure the @file{Makefile} conforms to the @sc{gnu} standard +The coding standard for writing a @sc{gnu} @file{Makefile} is described in +@ref{Makefiles, , Makefile Conventions, standards, GNU Coding Standards}. For +technical information on writing a @file{Makefile}, see @ref{Makefiles, , +Writing Makefiles, make, GNU Make}. + +@item Add Cygnus extensions to the @file{Makefile} +These are described in @ref{Makefile extensions, , Extensions to the @sc{gnu} +coding standards}. + +@item Collect package specific definitions in a single file +Many packages are best configured using a common @file{Makefile} fragment which +is included by all of the makefiles in the different directories of the +package. In order to accomplish this, set the variable +@samp{package_makefile_fragment} to the name of the file. It will be inserted +into the final @file{Makefile} before the target-specific fragment. + +@item Move host support from @file{Makefile} to fragments +This usually involves finding sections of the @file{Makefile} that say things +like ``uncomment these lines for host @var{hosttype}'' and moving them to a new +file called @file{./config/mh-@var{hosttype}}. For more information, see @ref{Hosts +and targets, , Adding hosts and targets}. + +@item Choose defaults +If the program has compile-time options that determine the way the program +should behave, choose reasonable defaults and make these @file{Makefile} +variables. Be sure the variables are assigned their default values before the +@samp{####} line so that site-specific @file{Makefile} fragments can override +them (@pxref{Makefile extensions, , Extensions to the @sc{gnu} coding +standards}). + +@item Locate configuration files +If there is configuration information in header files or source files, separate +it in such a way that the files have generic names. Then move the specific +instances of those files into the @file{./config/} subdirectory. + +@item Separate host and target information +Some programs already have this information separated. If yours does not, you +will need to separate these two kinds of configuration information. @dfn{Host +specific} information is the information needed to compile the program. +@dfn{Target specific} information is information on the format of data files +that the program will read or write. This information should live in separate +files in the @file{./config/} subdirectory with names that reflect the +configuration for which they are intended. + +At this point you might skip this step and simply move on. If you do, you +should end up with a program that can be configured only to build @dfn{native} +tools, that is, tools for which the host system is also the target system. +Later, you could attempt to build a cross tool and separate out the +target-specific information by figuring out what went wrong. This is often +simpler than combing through all of the source code. + +@item Write @code{configure.in} +Usually this involves writing shell script fragments to map from canonical +configuration names into the names of the configuration files. These files +will then be linked at configure time from the specific instances of those +files in @file{./config} to files in the build directory with more generic +names. (See also @ref{Build directories, , Build directories}.) The format of +@file{configure.in} is described in @ref{configure.in, , The +@code{configure.in} input file}. + +@item Rename @file{Makefile} to @file{Makefile.in} +@end table + +At this point you should have a program that can be configured using +Cygnus @code{configure}. + +@c --------------------------------------------------------------------- +@node Hosts and targets +@section Adding hosts and targets +@cindex Adding hosts and targets +@cindex Hosts and targets + +To add a host or target to a program that already uses Cygnus @code{configure}, +do the following. + +@itemize @bullet + +@item +Make sure the new configuration name is represented in @file{config.sub}. If +not, add it. For more details, see the comments in the shell script +@file{config.sub}. + +@item +If you are adding a host configuration, look in @file{configure.in}, in the +@dfn{per-host} section. Make sure that your configuration name is represented +in the mapping from host configuration names to configuration files. If not, +add it. Also see @ref{configure.in, , The @code{configure.in} input file}. + +@item +If you are adding a target configuration, look in @file{configure.in}, in the +@dfn{per-target} section. Make sure that your configuration name is +represented in the mapping from target configuration names to configuration +files. If not, add it. Also see @ref{configure.in, , The @code{configure.in} +input file}. + +@item +Look in @file{configure.in} for the variables @samp{files}, @samp{links}, +@samp{host_makefile_frag}, and @samp{target_makefile_frag}. The values +assigned to these variables are the names of the configuration files, (relative +to @samp{srcdir}) that the program uses. Make sure that copies of the files +exist for your host. If not, create them. See also @ref{configure variables, +, Variables available to @code{configure.in}}. +@end itemize + +This should be enough to @code{configure} for a new host or target +configuration name. Getting the program to compile and run properly represents +the hardest work of any port. + +@c --------------------------------------------------------------------- +@node Sites +@section Adding site info +@cindex Sites +@cindex Adding site info + +If some of the @file{Makefile} defaults are not right for your site, you can +build site-specific @file{Makefile} fragments. To do this, do the following. + +@itemize @bullet + +@item +Choose a name for your site. It must currently be less than eleven characters. + +@item +If the program source does not have a @file{./config/} subdirectory, create it. + +@item +Create a file called @file{./config/ms-@var{site}} where @var{site} is the name +of your site. In it, set whatever @file{Makefile} variables you need to +override to match your site's conventions. + +@item +Configure the program with: + +@cindex Example session +@example +configure @dots{} --site=@var{site} +@end example + +@end itemize + +@c --------------------------------------------------------------------- +@node Variables Index +@unnumbered Variable Index + +@printindex vr + +@page +@c --------------------------------------------------------------------- +@node Concept Index +@unnumbered Concept Index + +@printindex cp +@contents +@bye + +@c Local Variables: +@c fill-column: 79 +@c outline-regexp: "@chap" +@c End: +@c (setq outline-regexp "@chapt\\\|@unnum\\\|@setf\\\|@conte\\\|@sectio\\\|@subsect\\\|@itemize\\\|@defvar{") + diff --git a/gnu/lib/libg++/etc/make-stds.texi b/gnu/lib/libg++/etc/make-stds.texi new file mode 100644 index 00000000000..4b4ff7ef953 --- /dev/null +++ b/gnu/lib/libg++/etc/make-stds.texi @@ -0,0 +1,528 @@ +@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 chapter describes conventions for writing the Makefiles for GNU programs. + +@menu +* Makefile Basics:: +* Utilities in Makefiles:: +* Standard Targets:: +* Command Variables:: +* Directory Variables:: +@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}.) + +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{./} and @file{$(srcdir)/} is important +when 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 current directory is not the source directory, +because @file{foo.man} and @file{sedscript} are not in the current +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 @file{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) $(CFLAGS) $< -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 -s $(srcdir)/sedscript $(srcdir)/foo.man > foo.1 +@end smallexample + +@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: + +@example +cat cmp cp echo egrep expr grep +ln mkdir mv pwd rm rmdir sed test touch +@end example + +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. + +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 lex +make makeinfo ranlib texi2dvi yacc +@end example + +When you use @code{ranlib}, you should test whether it exists, and run +it only if it exists, so that the distribution will work on systems that +don't have @code{ranlib}. + +If you use symbolic links, you should implement a fallback for systems +that don't have symbolic links. + +It is ok to use other utilities in Makefile portions (or scripts) +intended only for particular systems where you know those utilities to +exist. + +@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. + +@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. + +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 script that edits the Info @file{dir} file to add or update the +menu entry for the given Info file; it will be 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 +# 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 --infodir=$(infodir) $$d/foo.info; \ + else true; fi +@end smallexample + +@item uninstall +Delete all the installed files that the @samp{install} target would +create (but not the noninstalled files such as @samp{make all} would +create). + +@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 realclean +Delete 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. + +One exception, however: @samp{make realclean} should not delete +@file{configure} even if @file{configure} can be remade using a rule in +the Makefile. More generally, @samp{make realclean} should not delete +anything that needs to exist in order to run @file{configure} +and then begin to build the program. + +@item TAGS +Update a tags table for this program. + +@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. + +@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. Alternatively, write just the dependencies, and allow GNU +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. + +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. +@xref{Releases, , Making Releases, standards, GNU Coding Standards}. + +@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; 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 +@end table + +@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: + +@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} +(at least for now). + +@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)}. + +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. + +@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}. + +@item libdir +The directory for installing executable files to be run by the program +rather than by users. Object files and libraries of object code should +also go in this directory. The idea is that this directory is used for +files that pertain to a specific machine architecture, but need not be +in the path for commands. The value of @code{libdir} should normally be +@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}. + +@item datadir +The directory for installing read-only data files which the programs +refer to while they run. This directory is used for files which are +independent of the type of machine being used. This should normally be +@file{/usr/local/lib}, but write it as @file{$(prefix)/lib}. + +@item statedir +The directory for installing data files which the programs modify while +they run. These files should be independent of the type of machine +being used, and it should be possible to share them among machines at a +network installation. This should normally be @file{/usr/local/lib}, +but write it as @file{$(prefix)/lib}. + +@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}. + +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}. + +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 grep for that string. + +@item mandir +The directory for installing the man pages (if any) for this package. +It should include the suffix for the proper section of the +manual---usually @samp{1} for a utility. It will normally be +@file{/usr/local/man/man1}, but you should write it as +@file{$(prefix)/man/man1}. + +@item man1dir +The directory for installing section 1 man pages. +@item man2dir +The directory for installing section 2 man pages. +@item @dots{} +Use these names instead of @samp{mandir} if the package needs to install man +pages in more than one section of the manual. + +@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. + +@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}. + +@item srcdir +The directory for the sources being compiled. The value of this +variable is normally inserted by the @code{configure} shell script. +@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. +libdir = $(exec_prefix)/lib +# 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. + diff --git a/gnu/lib/libg++/etc/standards.info b/gnu/lib/libg++/etc/standards.info new file mode 100644 index 00000000000..92b0dc90c04 --- /dev/null +++ b/gnu/lib/libg++/etc/standards.info @@ -0,0 +1,59 @@ +This is Info file standards.info, produced by Makeinfo-1.55 from the +input file ./standards.texi. + +START-INFO-DIR-ENTRY +* Standards: (standards). GNU coding standards. +END-INFO-DIR-ENTRY + + GNU Coding Standards Copyright (C) 1992, 1993, 1994 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 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. + + +Indirect: +standards.info-1: 950 +standards.info-2: 49237 + +Tag Table: +(Indirect) +Node: Top950 +Node: Reading Non-Free Code2051 +Node: Contributions3777 +Node: Change Logs5375 +Node: Compatibility9091 +Node: Makefile Conventions10730 +Node: Makefile Basics11087 +Node: Utilities in Makefiles12978 +Node: Standard Targets14414 +Node: Command Variables21523 +Node: Directory Variables24353 +Node: Configuration30825 +Node: Source Language37849 +Node: Formatting38979 +Node: Comments42269 +Node: Syntactic Conventions45055 +Node: Names47947 +Node: Using Extensions49237 +Node: System Functions50978 +Node: Semantics55781 +Node: Errors58747 +Node: Libraries59950 +Node: Portability61174 +Node: User Interfaces64461 +Node: Documentation79291 +Node: Releases83225 + +End Tag Table diff --git a/gnu/lib/libg++/etc/standards.info-1 b/gnu/lib/libg++/etc/standards.info-1 new file mode 100644 index 00000000000..38184e4a1bb --- /dev/null +++ b/gnu/lib/libg++/etc/standards.info-1 @@ -0,0 +1,1225 @@ +This is Info file standards.info, produced by Makeinfo-1.55 from the +input file ./standards.texi. + +START-INFO-DIR-ENTRY +* Standards: (standards). GNU coding standards. +END-INFO-DIR-ENTRY + + GNU Coding Standards Copyright (C) 1992, 1993, 1994 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 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. + + +File: standards.info, Node: Top, Next: Reading Non-Free Code, Prev: (dir), Up: (dir) + +Version +******* + + Last updated 28 March 1994. + +* Menu: + +* Reading Non-Free Code:: Referring to Proprietary Programs +* Contributions:: Accepting Contributions +* Change Logs:: Recording Changes +* Compatibility:: Compatibility with Other Implementations +* Makefile Conventions:: Makefile Conventions +* Configuration:: How Configuration Should Work +* Source Language:: Using Languages Other Than C +* Formatting:: Formatting Your Source Code +* Comments:: Commenting Your Work +* Syntactic Conventions:: Clean Use of C Constructs +* Names:: Naming Variables and Functions +* Using Extensions:: Using Non-standard Features +* System Functions:: Portability and "standard" library functions +* Semantics:: Program Behavior for All Programs +* Errors:: Formatting Error Messages +* Libraries:: Library Behavior +* Portability:: Portability As It Applies to GNU +* User Interfaces:: Standards for Command Line Interfaces +* Documentation:: Documenting Programs +* Releases:: Making Releases + + +File: standards.info, Node: Reading Non-Free Code, Next: Contributions, Prev: Top, Up: Top + +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. + + +File: standards.info, Node: Contributions, Next: Change Logs, Prev: Reading Non-Free Code, Up: Top + +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. *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 change, 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. + + I 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. + + +File: standards.info, Node: Change Logs, Next: Compatibility, Prev: Contributions, Up: Top + +Change Logs +*********** + + Keep a change log for each directory, describing the changes made to +source files in that directory. 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 +eliminate conceptual inconsistencies between different parts of a +program; they can give you a history of how the conflicting concepts +arose. + + Use the Emacs command `M-x add-change' to start a new entry in the +change log. 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. + + Separate unrelated 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. + + Here are some examples: + + * 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. + + It's important to name the changed function or variable in full. +Don't abbreviate them; 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 `* register.el ({insert,jump-to}-register)'; +this is not a good idea, since searching for `jump-to-register' or +`insert-register' would not find the entry. + + There's no need to describe the full purpose of the changes or how +they work together. It is better to put such explanations in comments +in the code. That's why just "New function" is enough; there is a +comment with the function in the source to explain what it does. + + However, sometimes it is useful to write one line to describe the +overall purpose of a large batch of changes. + + 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. + + 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. Just write in the +entry for the function being called, "All callers changed." + + When you change just comments or doc strings, it is enough to write +an entry for the file, without mentioning the functions. Write just, +"Doc fix." There's no need to keep a change log 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. + + +File: standards.info, Node: Compatibility, Next: Makefile Conventions, Prev: Change Logs, Up: Top + +Compatibility with Other Implementations +**************************************** + + With certain exceptions, utility programs and libraries for GNU +should be upward compatible with those in Berkeley Unix, and upward +compatible with ANSI C if ANSI C specifies their behavior, and upward +compatible with POSIX if POSIX specifies their behavior. + + When these standards conflict, it is useful to offer compatibility +modes for each of them. + + ANSI C and POSIX prohibit many kinds of extensions. Feel free to +make the extensions anyway, and include a `--ansi' or `--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 `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, +vi is replaced with Emacs.) But it is nice to offer a compatible +feature as well. (There is a free 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. + + +File: standards.info, Node: Makefile Conventions, Next: Configuration, Prev: Compatibility, Up: Top + +Makefile Conventions +******************** + + This chapter describes conventions for writing the Makefiles for GNU +programs. + +* Menu: + +* Makefile Basics:: +* Utilities in Makefiles:: +* Standard Targets:: +* Command Variables:: +* Directory Variables:: + + +File: standards.info, Node: Makefile Basics, Next: Utilities in Makefiles, Up: Makefile Conventions + +General Conventions for Makefiles +================================= + + Every Makefile should contain this line: + + SHELL = /bin/sh + +to avoid trouble on systems where the `SHELL' variable might be +inherited from the environment. (This is never a problem with GNU +`make'.) + + Don't assume that `.' 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 `./' if the program is built as +part of the make or `$(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 `./' and `$(srcdir)/' is important when +using the `--srcdir' option to `configure'. A rule of the form: + + foo.1 : foo.man sedscript + sed -e sedscript foo.man > foo.1 + +will fail when the current directory is not the source directory, +because `foo.man' and `sedscript' are not in the current directory. + + When using GNU `make', relying on `VPATH' to find the source file +will work in the case where there is a single dependency file, since +the `make' automatic variable `$<' will represent the source file +wherever it is. (Many versions of `make' set `$<' only in implicit +rules.) A makefile target like + + foo.o : bar.c + $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o + +should instead be written as + + foo.o : bar.c + $(CC) $(CFLAGS) $< -o $@ + +in order to allow `VPATH' to work correctly. When the target has +multiple dependencies, using an explicit `$(srcdir)' is the easiest way +to make the rule work well. For example, the target above for `foo.1' +is best written as: + + foo.1 : foo.man sedscript + sed -s $(srcdir)/sedscript $(srcdir)/foo.man > foo.1 + + +File: standards.info, Node: Utilities in Makefiles, Next: Standard Targets, Prev: Makefile Basics, Up: Makefile Conventions + +Utilities in Makefiles +====================== + + Write the Makefile commands (and any shell scripts, such as +`configure') to run in `sh', not in `csh'. Don't use any special +features of `ksh' or `bash'. + + The `configure' script and the Makefile rules for building and +installation should not use any utilities directly except these: + + cat cmp cp echo egrep expr grep + ln mkdir mv pwd rm rmdir sed test touch + + Stick to the generally supported options for these programs. For +example, don't use `mkdir -p', convenient as it may be, because most +systems don't support it. + + The Makefile rules for building and installation can also use +compilers and related programs, but should do so via `make' variables +so that the user can substitute alternatives. Here are some of the +programs we mean: + + ar bison cc flex install ld lex + make makeinfo ranlib texi2dvi yacc + + When you use `ranlib', you should test whether it exists, and run it +only if it exists, so that the distribution will work on systems that +don't have `ranlib'. + + If you use symbolic links, you should implement a fallback for +systems that don't have symbolic links. + + It is ok to use other utilities in Makefile portions (or scripts) +intended only for particular systems where you know those utilities to +exist. + + +File: standards.info, Node: Standard Targets, Next: Command Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions + +Standard Targets for Users +========================== + + All GNU programs should have the following targets in their +Makefiles: + +`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. + +`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. + + 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 `prefix' and + `exec_prefix', as well as all subdirectories that are needed. One + way to do this is by means of an `installdirs' target as described + below. + + Use `-' before any command for installing a man page, so that + `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 `$(infodir)' + with `$(INSTALL_DATA)' (*note Command Variables::.), and then run + the `install-info' program if it is present. `install-info' is a + script that edits the Info `dir' file to add or update the menu + entry for the given Info file; it will be part of the Texinfo + package. Here is a sample rule to install an Info file: + + $(infodir)/foo.info: foo.info + # 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 --infodir=$(infodir) $$d/foo.info; \ + else true; fi + +`uninstall' + Delete all the installed files that the `install' target would + create (but not the noninstalled files such as `make all' would + create). + +`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 `.dvi' files here if they are not part of the distribution. + +`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, + `make distclean' should leave only the files that were in the + distribution. + +`mostlyclean' + Like `clean', but may refrain from deleting a few files that people + normally don't want to recompile. For example, the `mostlyclean' + target for GCC does not delete `libgcc.a', because recompiling it + is rarely necessary and takes a lot of time. + +`realclean' + Delete everything from the current directory that can be + reconstructed with this Makefile. This typically includes + everything deleted by `distclean', plus more: C source files + produced by Bison, tags tables, Info files, and so on. + + One exception, however: `make realclean' should not delete + `configure' even if `configure' can be remade using a rule in the + Makefile. More generally, `make realclean' should not delete + anything that needs to exist in order to run `configure' and then + begin to build the program. + +`TAGS' + Update a tags table for this program. + +`info' + Generate any Info files needed. The best way to write the rules + is as follows: + + info: foo.info + + foo.info: foo.texi chap1.texi chap2.texi + $(MAKEINFO) $(srcdir)/foo.texi + + You must define the variable `MAKEINFO' in the Makefile. It should + run the `makeinfo' program, which is part of the Texinfo + distribution. + +`dvi' + Generate DVI files for all TeXinfo documentation. For example: + + dvi: foo.dvi + + foo.dvi: foo.texi chap1.texi chap2.texi + $(TEXI2DVI) $(srcdir)/foo.texi + + You must define the variable `TEXI2DVI' in the Makefile. It should + run the program `texi2dvi', which is part of the Texinfo + distribution. Alternatively, write just the dependencies, and + allow GNU Make to provide the command. + +`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 `gcc-1.40'. + + The easiest way to do this is to create a subdirectory + appropriately named, use `ln' or `cp' to install the proper files + in it, and then `tar' that subdirectory. + + The `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. *Note Making Releases: (standards)Releases. + +`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. + + The following targets are suggested as conventional names, for +programs in which they are useful. + +`installcheck' + Perform installation tests (if any). The user must build and + install the program before running the tests. You should not + assume that `$(bindir)' is in the search path. + +`installdirs' + It's useful to add a target named `installdirs' to create the + directories where files are installed, and their parent + directories. There is a script called `mkinstalldirs' which is + convenient for this; find it in the Texinfo package.You can use a + rule like this: + + # Make sure all installation directories (e.g. $(bindir)) + # actually exist by making them if necessary. + installdirs: mkinstalldirs + $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ + $(libdir) $(infodir) \ + $(mandir) + + +File: standards.info, Node: Command Variables, Next: Directory Variables, Prev: Standard Targets, Up: Makefile Conventions + +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 `BISON' whose default +value is set with `BISON = bison', and refer to it with `$(BISON)' +whenever you need to use Bison. + + File management utilities such as `ln', `rm', `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 `FLAGS' to the +program-name variable name to get the options variable name--for +example, `BISONFLAGS'. (The name `CFLAGS' is an exception to this +rule, but we keep it because it is standard.) Use `CPPFLAGS' in any +compilation command that runs the preprocessor, and use `LDFLAGS' in +any compilation command that does linking as well as in any direct use +of `ld'. + + If there are C compiler options that *must* be used for proper +compilation of certain files, do not include them in `CFLAGS'. Users +expect to be able to specify `CFLAGS' freely themselves. Instead, +arrange to pass the necessary options to the C compiler independently +of `CFLAGS', by writing them explicitly in the compilation commands or +by defining an implicit rule, like this: + + CFLAGS = -g + ALL_CFLAGS = -I. $(CFLAGS) + .c.o: + $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< + + Do include the `-g' option in `CFLAGS', because that is not +*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 `-O' in the default +value of `CFLAGS' as well. + + Put `CFLAGS' last in the compilation command, after other variables +containing compiler options, so the user can use `CFLAGS' to override +the others. + + Every Makefile should define the variable `INSTALL', which is the +basic command for installing a file into the system. + + Every Makefile should also define the variables `INSTALL_PROGRAM' +and `INSTALL_DATA'. (The default for each of these should be +`$(INSTALL)'.) Then it should use those variables as the commands for +actual installation, for executables and nonexecutables respectively. +Use these variables as follows: + + $(INSTALL_PROGRAM) foo $(bindir)/foo + $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a + +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. + + +File: standards.info, Node: Directory Variables, Prev: Command Variables, Up: Makefile Conventions + +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: + +`prefix' + A prefix used in constructing the default values of the variables + listed below. The default value of `prefix' should be `/usr/local' + (at least for now). + +`exec_prefix' + A prefix used in constructing the default values of some of the + variables listed below. The default value of `exec_prefix' should + be `$(prefix)'. + + Generally, `$(exec_prefix)' is used for directories that contain + machine-specific files (such as executables and subroutine + libraries), while `$(prefix)' is used directly for other + directories. + +`bindir' + The directory for installing executable programs that users can + run. This should normally be `/usr/local/bin', but write it as + `$(exec_prefix)/bin'. + +`libdir' + The directory for installing executable files to be run by the + program rather than by users. Object files and libraries of + object code should also go in this directory. The idea is that + this directory is used for files that pertain to a specific + machine architecture, but need not be in the path for commands. + The value of `libdir' should normally be `/usr/local/lib', but + write it as `$(exec_prefix)/lib'. + +`datadir' + The directory for installing read-only data files which the + programs refer to while they run. This directory is used for + files which are independent of the type of machine being used. + This should normally be `/usr/local/lib', but write it as + `$(prefix)/lib'. + +`statedir' + The directory for installing data files which the programs modify + while they run. These files should be independent of the type of + machine being used, and it should be possible to share them among + machines at a network installation. This should normally be + `/usr/local/lib', but write it as `$(prefix)/lib'. + +`includedir' + The directory for installing header files to be included by user + programs with the C `#include' preprocessor directive. This + should normally be `/usr/local/include', but write it as + `$(prefix)/include'. + + Most compilers other than GCC do not look for header files in + `/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 + `includedir' and one specified by `oldincludedir'. + +`oldincludedir' + The directory for installing `#include' header files for use with + compilers other than GCC. This should normally be `/usr/include'. + + The Makefile commands should check whether the value of + `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 `foo.h', then it should install the + header file in the `oldincludedir' directory if either (1) there + is no `foo.h' there or (2) the `foo.h' that exists came from the + Foo package. + + To tell whether `foo.h' came from the Foo package, put a magic + string in the file--part of a comment--and grep for that string. + +`mandir' + The directory for installing the man pages (if any) for this + package. It should include the suffix for the proper section of + the manual--usually `1' for a utility. It will normally be + `/usr/local/man/man1', but you should write it as + `$(prefix)/man/man1'. + +`man1dir' + The directory for installing section 1 man pages. + +`man2dir' + The directory for installing section 2 man pages. + +`...' + Use these names instead of `mandir' if the package needs to + install man pages in more than one section of the manual. + + *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.* + +`manext' + The file name extension for the installed man page. This should + contain a period followed by the appropriate digit; it should + normally be `.1'. + +`man1ext' + The file name extension for installed section 1 man pages. + +`man2ext' + The file name extension for installed section 2 man pages. + +`...' + Use these names instead of `manext' if the package needs to + install man pages in more than one section of the manual. + +`infodir' + The directory for installing the Info files for this package. By + default, it should be `/usr/local/info', but it should be written + as `$(prefix)/info'. + +`srcdir' + The directory for the sources being compiled. The value of this + variable is normally inserted by the `configure' shell script. + + For example: + + # 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. + libdir = $(exec_prefix)/lib + # Where to put the Info files. + infodir = $(prefix)/info + + 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 `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. + + +File: standards.info, Node: Configuration, Next: Source Language, Prev: Makefile Conventions, Up: Top + +How Configuration Should Work +***************************** + + Each GNU distribution should come with a shell script named +`configure'. This script is given arguments which describe the kind of +machine and system you want to compile the program for. + + The `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 +`config.h' to the proper configuration file for the chosen system. If +you use this technique, the distribution should *not* contain a file +named `config.h'. This is so that people won't be able to build the +program without configuring it first. + + Another thing that `configure' can do is to edit the Makefile. If +you do this, the distribution should *not* contain a file named +`Makefile'. Instead, include a 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 `configure' does write the `Makefile', then `Makefile' should +have a target named `Makefile' which causes `configure' to be rerun, +setting up the same configuration that was set up last time. The files +that `configure' reads should be listed as dependencies of `Makefile'. + + All the files which are output from the `configure' script should +have comments at the beginning explaining that they were generated +automatically using `configure'. This is so that users won't think of +trying to edit them by hand. + + The `configure' script should write a file named `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 `configure' script should accept an option of the form +`--srcdir=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 `--srcdir', then `configure' should +check both `.' and `..' 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 `--srcdir' is by editing a +definition of `VPATH' into the Makefile. Some rules may need to refer +explicitly to the specified source directory. To make this possible, +`configure' can add to the Makefile a variable named `srcdir' whose +value is precisely the specified directory. + + The `configure' script should also take an argument which specifies +the type of system to build the program for. This argument should look +like this: + + CPU-COMPANY-SYSTEM + + For example, a Sun 3 might be `m68k-sun-sunos4.1'. + + The `configure' script needs to be able to decode all plausible +alternatives for how to describe a machine. Thus, `sun3-sunos4.1' +would be a valid alias. So would `sun3-bsd4.2', since SunOS is +basically BSD and no other BSD system is used on a Sun. For many +programs, `vax-dec-ultrix' would be an alias for `vax-dec-bsd', simply +because the differences between Ultrix and BSD are rarely noticeable, +but a few programs might need to distinguish them. + + There is a shell script called `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: + +`--enable-FEATURE[=PARAMETER]' + Configure the package to build and install an optional user-level + facility called FEATURE. This allows users to choose which + optional features to include. Giving an optional PARAMETER of + `no' should omit FEATURE, if it is built by default. + + No `--enable' option should *ever* cause one feature to replace + another. No `--enable' option should ever substitute one useful + behavior for another useful behavior. The only proper use for + `--enable' is for questions of whether to build part of the program + or exclude it. + +`--with-PACKAGE' + The package PACKAGE will be installed, so configure this package + to work with PACKAGE. + + Possible values of PACKAGE include `x', `x-toolkit', `gnu-as' (or + `gas'), `gnu-ld', `gnu-libc', and `gdb'. + + Do not use a `--with' option to specify the file name to use to + find certain files. That is outside the scope of what `--with' + options are for. + +`--nfp' + The target machine has no floating point processor. + +`--gas' + The target machine assembler is GAS, the GNU assembler. This is + obsolete; users should use `--with-gnu-as' instead. + +`--x' + The target machine has the X Window System installed. This is + obsolete; users should use `--with-x' instead. + + All `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 +`--with-' or `--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 `--with-' and `--enable-' are +narrow: they *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 compilation may support +cross-compilation. In such a case, the host and target machines for +the program may be different. The `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 `--host=HOSTTYPE' when running +`configure'. This specifies the host system without changing the type +of target system. The syntax for 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 `--build=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 `--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 `configure' script can simply +ignore most of its arguments. + + +File: standards.info, Node: Source Language, Next: Formatting, Prev: Configuration, Up: Top + +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: + + * It is okay to use a special language if the same program contains + an interpreter for that language. + + Thus, it is not a problem that GNU Emacs contains code written in + Emacs Lisp, because it comes with a Lisp interpreter. + + * 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. + + * If an application is not of extremely widespread interest, then + perhaps it's not important if the application is inconvenient to + install. + + +File: standards.info, Node: Formatting, Next: Comments, Prev: Source Language, Up: Top + +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: + + static char * + concat (s1, s2) /* Name starts in column zero here */ + char *s1, *s2; + { /* Open brace in column zero here */ + ... + } + +or, if you want to use ANSI C, format the definition like this: + + static char * + concat (char *s1, char *s2) + { + ... + } + + In ANSI C, if the arguments don't fit nicely on one line, split it +like this: + + int + lots_of_args (int an_integer, long a_long, short a_short, + double a_double, float a_float) + ... + + For the body of the function, we prefer code formatted like this: + + if (x < foo (y, z)) + haha = bar[4] + 5; + else + { + while (z) + { + haha += foo (z, z); + z--; + } + return ++x + bar (); + } + + 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: + + if (foo_this_is_long && bar > win (x, y, z) + && remaining_condition) + + Try to avoid having two operators of different precedence at the same +level of indentation. For example, don't write this: + + mode = (inmode[j] == VOIDmode + || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j]) + ? outmode[j] : inmode[j]); + + Instead, use extra parentheses so that the indentation shows the +nesting: + + mode = ((inmode[j] == VOIDmode + || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j]))) + ? outmode[j] : inmode[j]); + + 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: + + 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; + + But adding a set of parentheses solves the problem: + + 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); + + Format do-while statements like this: + + do + { + a = foo (a); + } + while (a > 0); + + 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. + + +File: standards.info, Node: Comments, Next: Syntactic Conventions, Prev: Formatting, Up: Top + +Commenting Your Work +******************** + + Every program should start with a comment saying briefly what it is +for. Example: `fmt - filter for simple filling of text'. + + 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 `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 +identifer 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 ..."). + + 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: + + /* Nonzero means truncate lines in the display; + zero means continue them. */ + int truncate_lines; + + Every `#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, *including its +sense*. `#else' should have a comment describing the condition *and +sense* of the code that follows. For example: + + #ifdef foo + ... + #else /* not foo */ + ... + #endif /* not foo */ + +but, by contrast, write the comments this way for a `#ifndef': + + #ifndef foo + ... + #else /* foo */ + ... + #endif /* foo */ + + +File: standards.info, Node: Syntactic Conventions, Next: Names, Prev: Comments, Up: Top + +Clean Use of C Constructs +************************* + + Please explicitly declare all arguments to functions. Don't omit +them just because they are `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 `extern' declarations inside +functions. + + It used to be common practice to use the same local variables (with +names like `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: + + int foo, + bar; + +write either this: + + int foo, bar; + +or this: + + int foo; + int bar; + +(If they are global variables, each should have a comment preceding it +anyway.) + + When you have an `if'-`else' statement nested in another `if' +statement, always put braces around the `if'-`else'. Thus, never write +like this: + + if (foo) + if (bar) + win (); + else + lose (); + +always like this: + + if (foo) + { + if (bar) + win (); + else + lose (); + } + + If you have an `if' statement nested inside of an `else' statement, +either write `else if' on one line, like this, + + if (foo) + ... + else if (bar) + ... + +with its `then'-part indented like the preceding `then'-part, or write +the nested `if' within braces like this: + + if (foo) + ... + else + { + if (bar) + ... + } + + 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 `if'-conditions. For example, don't +write this: + + if ((foo = (char *) malloc (sizeof *foo)) == 0) + fatal ("virtual memory exhausted"); + +instead, write this: + + foo = (char *) malloc (sizeof *foo); + if (foo == 0) + fatal ("virtual memory exhausted"); + + Don't make the program ugly to placate `lint'. Please don't insert +any casts to `void'. Zero without a cast is perfectly fine as a null +pointer constant. + + +File: standards.info, Node: Names, Next: Using Extensions, Prev: Syntactic Conventions, Up: Top + +Naming Variables and Functions +****************************** + + 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 `enum' constants, and for name-prefixes that +follow a uniform convention. + + For example, you should use names like `ignore_space_change_flag'; +don't use names like `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, + + /* Ignore changes in horizontal whitespace (-b). */ + int ignore_space_change_flag; + + When you want to define names with constant integer values, use +`enum' rather than `#define'. GDB knows about enumeration constants. + + Use file names of 14 characters or less, to avoid creating gratuitous +problems on System V. You can use the program `doschk' to test for +this. `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. + diff --git a/gnu/lib/libg++/etc/standards.info-2 b/gnu/lib/libg++/etc/standards.info-2 new file mode 100644 index 00000000000..119f28149f4 --- /dev/null +++ b/gnu/lib/libg++/etc/standards.info-2 @@ -0,0 +1,1462 @@ +This is Info file standards.info, produced by Makeinfo-1.55 from the +input file ./standards.texi. + +START-INFO-DIR-ENTRY +* Standards: (standards). GNU coding standards. +END-INFO-DIR-ENTRY + + GNU Coding Standards Copyright (C) 1992, 1993, 1994 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 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. + + +File: standards.info, Node: Using Extensions, Next: System Functions, Prev: Names, Up: Top + +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" `INLINE' and +define that as a macro to expand into either `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. + + Since most computer systems do not yet implement ANSI C, using the +ANSI C features is effectively using a GNU extension, so the same +considerations apply. (Except for ANSI features that we discourage, +such as trigraphs--don't ever use them.) + + +File: standards.info, Node: System Functions, Next: Semantics, Prev: Using Extensions, Up: Top + +Calling System Functions +************************ + + C implementations differ substantially. ANSI C reduces but does not +eliminate the incompatibilities; meanwhile, many users wish to compile +GNU software with pre-ANSI compilers. This chapter gives +recommendations for how to use the more or less standard C library +functions to avoid unnecessary loss of portability. + + * Don't use the value of `sprintf'. It returns the number of + characters written on some systems, but not on all systems. + + * 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. The problem is only + theoretical. By contrast, actual declarations have frequently + caused actual conflicts. + + * If you must declare a system function, don't specify the argument + types. Use an old-style declaration, not an ANSI prototype. The + more you specify about the function, the more likely a conflict. + + * In particular, don't unconditionally declare `malloc' or `realloc'. + + Most GNU programs use those functions just once, in functions + conventionally named `xmalloc' and `xrealloc'. These functions + call `malloc' and `realloc', respectively, and check the results. + + Because `xmalloc' and `xrealloc' are defined in your program, you + can declare them in other files without any risk of type conflict. + + On most systems, `int' is the same length as a pointer; thus, the + calls to `malloc' and `realloc' work fine. For the few + exceptional systems (mostly 64-bit machines), you can use + *conditionalized* declarations of `malloc' and `realloc'--or put + these declarations in configuration files specific to those + systems. + + * The string functions require special treatment. Some Unix systems + have a header file `string.h'; other have `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. + + * 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 ANSI + string functions are off-limits anyway because many systems still + don't support them. The string functions you can use are these: + + strcpy strncpy strcat strncat + strlen strcmp strncmp + strchr strrchr + + 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 `int', and perhaps in other cases. It + is trivial to avoid using their values, so do that. + + The compare functions and `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 *conditionally* on a few + systems. + + The search functions must be declared to return `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 `index' and `rindex'; other systems use the names `strchr' + and `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 `strchr' and + `strrchr'.) Declare both of those names as functions returning + `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 `strchr' and `strrchr' throughout: + + #ifndef HAVE_STRCHR + #define strchr index + #endif + #ifndef HAVE_STRRCHR + #define strrchr rindex + #endif + + char *strchr (); + char *strrchr (); + + Here we assume that `HAVE_STRCHR' and `HAVE_STRRCHR' are macros +defined in systems where the corresponding functions exist. One way to +get them properly defined is to use Autoconf. + + +File: standards.info, Node: Semantics, Next: Errors, Prev: System Functions, Up: Top + +Program Behavior for All Programs +********************************* + + Avoid arbitrary limits on the length or number of *any* data +structure, including filenames, 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 *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 `perror' or +equivalent) in *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 `malloc' or `realloc' to see if it returned +zero. Check `realloc' even if you are making the block smaller; in a +system that rounds block sizes to a power of 2, `realloc' may get a +different block if you ask for less space. + + In Unix, `realloc' can destroy the storage block if it returns zero. +GNU `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 `malloc'. + + You must expect `free' to alter the contents of the block that was +freed. Anything you want to fetch from the block, you must fetch before +calling `free'. + + Use `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. + + 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 `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 BSD and of 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. + + +File: standards.info, Node: Errors, Next: Libraries, Prev: Semantics, Up: Top + +Formatting Error Messages +************************* + + Error messages from compilers should look like this: + + SOURCE-FILE-NAME:LINENO: MESSAGE + + Error messages from other noninteractive programs should look like +this: + + PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE + +when there is an appropriate source file, or like this: + + PROGRAM: MESSAGE + +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 MESSAGE should not begin with a capital letter when it +follows a program name and/or filename. 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. + + +File: standards.info, Node: Libraries, Next: Portability, Prev: Errors, Up: Top + +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 `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 `_'. 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. + + +File: standards.info, Node: Portability, Next: User Interfaces, Prev: Libraries, Up: Top + +Portability As It Applies to GNU +******************************** + + Much of what is called "portability" in the Unix world refers to +porting to different Unix versions. This is a secondary consideration +for GNU software, because its primary purpose is to run on top of one +and only one kernel, the GNU kernel, compiled with one and only one C +compiler, the GNU C compiler. The amount and kinds of variation among +GNU systems on different cpu's will be like the variation among Berkeley +4.3 systems on different cpu's. + + All users today run GNU software on non-GNU systems. So supporting a +variety of non-GNU systems is desirable; simply not paramount. The +easiest way to achieve portability to a reasonable range of systems is +to use Autoconf. It's unlikely that your program needs to know more +information about the host machine than Autoconf can provide, simply +because most of the programs that need such knowledge have already been +written. + + It is difficult to be sure exactly what facilities the GNU kernel +will provide, since it isn't finished yet. Therefore, assume you can +use anything in 4.3; just avoid using the format of semi-internal data +bases (e.g., directories) when there is a higher-level alternative +(`readdir'). + + You can freely assume any reasonably standard facilities in the C +language, libraries or kernel, because we will find it necessary to +support these facilities in the full GNU system, whether or not we have +already done so. The fact that there may exist kernels or C compilers +that lack these facilities is irrelevant as long as the GNU kernel and +C compiler support them. + + It remains necessary to worry about differences among cpu types, such +as the difference in byte ordering and alignment restrictions. It's +unlikely that 16-bit machines will ever be supported by GNU, so there +is no point in spending any time to consider the possibility that an +int will be less than 32 bits. + + You can assume that all pointers have the same format, regardless of +the type they point to, and that this is really an integer. There are +some weird machines where this isn't true, but they aren't important; +don't waste time catering to them. Besides, eventually we will put +function prototypes into all GNU programs, and that will probably make +your program work even on weird machines. + + Since some important machines (including the 68000) are big-endian, +it is important not to assume that the address of an `int' object is +also the address of its least-significant byte. Thus, don't make the +following mistake: + + int c; + ... + while ((c = getchar()) != EOF) + write(file_descriptor, &c, 1); + + You can assume that it is reasonable to use a meg of memory. Don't +strain to reduce memory usage unless it can get to that level. If your +program creates complicated data structures, just make them in core and +give a fatal error if malloc returns zero. + + 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. + + +File: standards.info, Node: User Interfaces, Next: Documentation, Prev: Portability, Up: Top + +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 `ls' or `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 `dir' program much like +`ls' except that its default output format is always multi-column +format. + + It is a good idea to follow the POSIX guidelines for the +command-line options of a program. The easiest way to do this is to use +`getopt' to parse them. Note that the GNU version of `getopt' will +normally permit options anywhere among the arguments unless the special +argument `--' is used. This is not what 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 +`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 `--verbose'. To achieve this uniformity, look at the +table of common long-option names when you choose the option names for +your program. The table appears below. + + If you use names not already in the table, please send +`gnu@prep.ai.mit.edu' a list of them, with their meanings, so we can +update the 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 `-o'). Even if you allow an output file name as an +ordinary argument for compatibility, try to provide a suitable option +as well. This will lead to more consistency among GNU utilities, so +that there are fewer idiosyncracies for users to remember. + + Programs should support an option `--version' which prints the +program's version number on standard output and exits successfully, and +an option `--help' which prints option usage information on standard +output and exits successfully. These options should inhibit the normal +function of the command; they should do nothing except print the +requested information. + +`auto-check' + `-a' in `recode'. + +`auto-reference' + `-A' in `ptx'. + +`after-date' + `-N' in `tar'. + +`all' + `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'. + +`all-text' + `-a' in `diff'. + +`almost-all' + `-A' in `ls'. + +`append' + `-a' in `etags', `tee', `time'; `-r' in `tar'. + +`archive' + `-a' in `cp'. + +`arglength' + `-l' in `m4'. + +`ascii' + `-a' in `diff'. + +`assume-new' + `-W' in Make. + +`assume-old' + `-o' in Make. + +`backward-search' + `-B' in etags. + +`batch' + Used in GDB. + +`baud' + Used in GDB. + +`before' + `-b' in `tac'. + +`binary' + `-b' in `cpio' and `diff'. + +`block-size' + Used in `cpio' and `tar'. + +`blocks' + `-b' in `head' and `tail'. + +`break-file' + `-b' in `ptx'. + +`brief' + Used in various programs to make output shorter. + +`bytes' + `-c' in `head', `split', and `tail'. + +`c++' + `-C' in `etags'. + +`catenate' + `-A' in `tar'. + +`cd' + Used in various programs to specify the directory to use. + +`changes' + `-c' in `chgrp' and `chown'. + +`classify' + `-F' in `ls'. + +`colons' + `-c' in `recode'. + +`command' + `-c' in `su'; `-x' in GDB. + +`compare' + `-d' in `tar'. + +`compress' + `-Z' in `tar'. + +`concatenate' + `-A' in `tar'. + +`confirmation' + `-w' in `tar'. + +`context' + Used in `diff'. + +`copyright' + `-C' in `ptx' and `recode'. + +`core' + Used in GDB. + +`count' + `-q' in `who'. + +`count-links' + `-l' in `du'. + +`create' + Used in `tar' and `cpio'. + +`cxref' + `-x' in `etags'. + +`date' + `-d' in `touch'. + +`debug' + `-d' in Make and `m4'; `-t' in Bison. + +`define' + `-D' in `m4'. + +`defines' + `-d' in Bison and `etags'. + +`delete' + `-D' in `tar'. + +`dereference' + `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'. + +`dereference-args' + `-D' in `du'. + +`diacritics' + `-d' in `recode'. + +`dictionary-order' + `-d' in `look'. + +`diff' + `-d' in `tar'. + +`digits' + `-n' in `csplit'. + +`directory' + Specify the directory to use, in various programs. In `ls', it + means to show directories themselves rather than their contents. + In `rm' and `ln', it means to not treat links to directories + specially. + +`discard-all' + `-x' in `strip'. + +`discard-locals' + `-X' in `strip'. + +`diversions' + `-N' in `m4'. + +`dry-run' + `-n' in Make. + +`ed' + `-e' in `diff'. + +`elide-empty-files' + `-z' in `csplit'. + +`entire-new-file' + `-N' in `diff'. + +`environment-overrides' + `-e' in Make. + +`eof' + `-e' in `xargs'. + +`epoch' + Used in GDB. + +`error-limit' + Used in Makeinfo. + +`error-output' + `-o' in `m4'. + +`escape' + `-b' in `ls'. + +`exclude-from' + `-X' in `tar'. + +`exec' + Used in GDB. + +`exit' + `-x' in `xargs'. + +`expand-tabs' + `-t' in `diff'. + +`expression' + `-e' in `sed'. + +`extern-only' + `-g' in `nm'. + +`extract' + `-i' in `cpio'; `-x' in `tar'. + +`faces' + `-f' in `finger'. + +`fast' + `-f' in `su'. + +`file' + `-f' in `info', Make, `mt', and `tar'; `-n' in `sed'; `-r' in + `touch'. + +`file-prefix' + `-b' in Bison. + +`file-type' + `-F' in `ls'. + +`files-from' + `-T' in `tar'. + +`fill-column' + Used in Makeinfo. + +`flag-truncation' + `-F' in `ptx'. + +`fixed-output-files' + `-y' in Bison. + +`follow' + `-f' in `tail'. + +`footnote-style' + Used in Makeinfo. + +`force' + `-f' in `cp', `ln', `mv', and `rm'. + +`format' + Used in `ls', `time', and `ptx'. + +`forward-search' + `-F' in `etags'. + +`fullname' + Used in GDB. + +`gap-size' + `-g' in `ptx'. + +`get' + `-x' in `tar'. + +`graphic' + `-i' in `ul'. + +`graphics' + `-g' in `recode'. + +`group' + `-g' in `install'. + +`gzip' + `-z' in `tar'. + +`hashsize' + `-H' in `m4'. + +`header' + `-h' in `objdump' and `recode' + +`heading' + `-H' in `who'. + +`help' + Used to ask for brief usage information. + +`hide-control-chars' + `-q' in `ls'. + +`idle' + `-u' in `who'. + +`ifdef' + `-D' in `diff'. + +`ignore' + `-I' in `ls'; `-x' in `recode'. + +`ignore-all-space' + `-w' in `diff'. + +`ignore-backups' + `-B' in `ls'. + +`ignore-blank-lines' + `-B' in `diff'. + +`ignore-case' + `-f' in `look' and `ptx'; `-i' in `diff'. + +`ignore-errors' + `-i' in Make. + +`ignore-file' + `-i' in `ptx'. + +`ignore-indentation' + `-S' in `etags'. + +`ignore-init-file' + `-f' in Oleo. + +`ignore-interrupts' + `-i' in `tee'. + +`ignore-matching-lines' + `-I' in `diff'. + +`ignore-space-change' + `-b' in `diff'. + +`ignore-zeros' + `-i' in `tar'. + +`include' + `-i' in `etags'; `-I' in `m4'. + +`include-dir' + `-I' in Make. + +`incremental' + `-G' in `tar'. + +`info' + `-i', `-l', and `-m' in Finger. + +`initial' + `-i' in `expand'. + +`initial-tab' + `-T' in `diff'. + +`inode' + `-i' in `ls'. + +`interactive' + `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs'; + `-w' in `tar'. + +`jobs' + `-j' in Make. + +`just-print' + `-n' in Make. + +`keep-going' + `-k' in Make. + +`keep-files' + `-k' in `csplit'. + +`kilobytes' + `-k' in `du' and `ls'. + +`line-bytes' + `-C' in `split'. + +`lines' + Used in `split', `head', and `tail'. + +`link' + `-l' in `cpio'. + +`list' + `-t' in `cpio'; `-l' in `recode'. + +`list' + `-t' in `tar'. + +`literal' + `-N' in `ls'. + +`load-average' + `-l' in Make. + +`login' + Used in `su'. + +`machine' + No listing of which programs already use this; someone should + check to see if any actually do and tell `gnu@prep.ai.mit.edu'. + +`macro-name' + `-M' in `ptx'. + +`mail' + `-m' in `hello' and `uname'. + +`make-directories' + `-d' in `cpio'. + +`makefile' + `-f' in Make. + +`mapped' + Used in GDB. + +`max-args' + `-n' in `xargs'. + +`max-chars' + `-n' in `xargs'. + +`max-lines' + `-l' in `xargs'. + +`max-load' + `-l' in Make. + +`max-procs' + `-P' in `xargs'. + +`mesg' + `-T' in `who'. + +`message' + `-T' in `who'. + +`minimal' + `-d' in `diff'. + +`mode' + `-m' in `install', `mkdir', and `mkfifo'. + +`modification-time' + `-m' in `tar'. + +`multi-volume' + `-M' in `tar'. + +`name-prefix' + `-a' in Bison. + +`new-file' + `-W' in Make. + +`no-builtin-rules' + `-r' in Make. + +`no-create' + `-c' in `touch'. + +`no-defines' + `-D' in `etags'. + +`no-dereference' + `-d' in `cp'. + +`no-keep-going' + `-S' in Make. + +`no-lines' + `-l' in Bison. + +`no-prof' + `-e' in `gprof'. + +`no-sort' + `-p' in `nm'. + +`no-split' + Used in Makeinfo. + +`no-static' + `-a' in `gprof'. + +`no-time' + `-E' in `gprof'. + +`no-validate' + Used in Makeinfo. + +`no-warn' + Used in various programs to inhibit warnings. + +`node' + `-n' in `info'. + +`nodename' + `-n' in `uname'. + +`nonmatching' + `-f' in `cpio'. + +`nstuff' + `-n' in `objdump'. + +`null' + `-0' in `xargs'. + +`number' + `-n' in `cat'. + +`number-nonblank' + `-b' in `cat'. + +`numeric-sort' + `-n' in `nm'. + +`numeric-uid-gid' + `-n' in `cpio' and `ls'. + +`nx' + Used in GDB. + +`old-archive' + `-o' in `tar'. + +`old-file' + `-o' in Make. + +`one-file-system' + `-l' in `tar', `cp', and `du'. + +`only-file' + `-o' in `ptx'. + +`only-prof' + `-f' in `gprof'. + +`only-time' + `-F' in `gprof'. + +`output' + In various programs, specify the output file name. + +`override' + `-o' in `rm'. + +`owner' + `-o' in `install'. + +`paginate' + `-l' in `diff'. + +`paragraph-indent' + Used in Makeinfo. + +`parents' + `-p' in `mkdir' and `rmdir'. + +`pass-all' + `-p' in `ul'. + +`pass-through' + `-p' in `cpio'. + +`port' + `-P' in `finger'. + +`portability' + `-c' in `cpio' and `tar'. + +`prefix-builtins' + `-P' in `m4'. + +`prefix' + `-f' in `csplit'. + +`preserve' + Used in `tar' and `cp'. + +`preserve-environment' + `-p' in `su'. + +`preserve-modification-time' + `-m' in `cpio'. + +`preserve-order' + `-s' in `tar'. + +`preserve-permissions' + `-p' in `tar'. + +`print' + `-l' in `diff'. + +`print-chars' + `-L' in `cmp'. + +`print-data-base' + `-p' in Make. + +`print-directory' + `-w' in Make. + +`print-file-name' + `-o' in `nm'. + +`print-symdefs' + `-s' in `nm'. + +`question' + `-q' in Make. + +`quiet' + Used in many programs to inhibit the usual output. *Note:* every + program accepting `--quiet' should accept `--silent' as a synonym. + +`quote-name' + `-Q' in `ls'. + +`rcs' + `-n' in `diff'. + +`read-full-blocks' + `-B' in `tar'. + +`readnow' + Used in GDB. + +`recon' + `-n' in Make. + +`record-number' + `-R' in `tar'. + +`recursive' + Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'. + +`reference-limit' + Used in Makeinfo. + +`references' + `-r' in `ptx'. + +`regex' + `-r' in `tac'. + +`release' + `-r' in `uname'. + +`relocation' + `-r' in `objdump'. + +`rename' + `-r' in `cpio'. + +`replace' + `-i' in `xargs'. + +`report-identical-files' + `-s' in `diff'. + +`reset-access-time' + `-a' in `cpio'. + +`reverse' + `-r' in `ls' and `nm'. + +`reversed-ed' + `-f' in `diff'. + +`right-side-defs' + `-R' in `ptx'. + +`same-order' + `-s' in `tar'. + +`same-permissions' + `-p' in `tar'. + +`save' + `-g' in `stty'. + +`se' + Used in GDB. + +`sentence-regexp' + `-S' in `ptx'. + +`separate-dirs' + `-S' in `du'. + +`separator' + `-s' in `tac'. + +`sequence' + Used by `recode' to chose files or pipes for sequencing passes. + +`shell' + `-s' in `su'. + +`show-all' + `-A' in `cat'. + +`show-c-function' + `-p' in `diff'. + +`show-ends' + `-E' in `cat'. + +`show-function-line' + `-F' in `diff'. + +`show-tabs' + `-T' in `cat'. + +`silent' + Used in many programs to inhibit the usual output. *Note:* every + program accepting `--silent' should accept `--quiet' as a synonym. + +`size' + `-s' in `ls'. + +`sort' + Used in `ls'. + +`sparse' + `-S' in `tar'. + +`speed-large-files' + `-H' in `diff'. + +`squeeze-blank' + `-s' in `cat'. + +`starting-file' + Used in `tar' and `diff' to specify which file within a directory + to start processing with. + +`stop' + `-S' in Make. + +`strict' + `-s' in `recode'. + +`strip' + `-s' in `install'. + +`strip-all' + `-s' in `strip'. + +`strip-debug' + `-S' in `strip'. + +`suffix' + `-S' in `cp', `ln', `mv'. + +`suffix-format' + `-b' in `csplit'. + +`sum' + `-s' in `gprof'. + +`summarize' + `-s' in `du'. + +`symbolic' + `-s' in `ln'. + +`symbols' + Used in GDB and `objdump'. + +`synclines' + `-s' in `m4'. + +`sysname' + `-s' in `uname'. + +`tabs' + `-t' in `expand' and `unexpand'. + +`tabsize' + `-T' in `ls'. + +`terminal' + `-T' in `tput' and `ul'. + +`text' + `-a' in `diff'. + +`time' + Used in `ls' and `touch'. + +`to-stdout' + `-O' in `tar'. + +`total' + `-c' in `du'. + +`touch' + `-t' in Make, `ranlib', and `recode'. + +`trace' + `-t' in `m4'. + +`traditional' + `-t' in `hello'; `-G' in `m4' and `ptx'. + +`tty' + Used in GDB. + +`typedefs' + `-t' in `etags'. + +`typedefs-and-c++' + `-T' in `etags'. + +`typeset-mode' + `-t' in `ptx'. + +`uncompress' + `-z' in `tar'. + +`unconditional' + `-u' in `cpio'. + +`undefine' + `-U' in `m4'. + +`undefined-only' + `-u' in `nm'. + +`update' + `-u' in `cp', `etags', `mv', `tar'. + +`verbose' + Print more information about progress. Many programs support this. + +`verify' + `-W' in `tar'. + +`version' + Print the version number. + +`version-control' + `-V' in `cp', `ln', `mv'. + +`vgrind' + `-v' in `etags'. + +`volume' + `-V' in `tar'. + +`what-if' + `-W' in Make. + +`width' + `-w' in `ls' and `ptx'. + +`word-regexp' + `-W' in `ptx'. + +`writable' + `-T' in `who'. + +`zeros' + `-z' in `gprof'. + + +File: standards.info, Node: Documentation, Next: Releases, Prev: User Interfaces, Up: Top + +Documenting Programs +******************** + + Please use Texinfo for documenting GNU programs. See the Texinfo +manual, either the hardcopy or the version in the GNU Emacs Info +subsystem (`C-h i'). See existing GNU Texinfo files (e.g., those under +the `man/' directory in the GNU Emacs distribution) for examples. + + The title page of the manual should state the version of the program +which the manual applies to. 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. + + The manual should document all command-line arguments and all +commands. It should give examples of their use. But don't organize +the manual as a list of features. Instead, organize it by the concepts +a user will have before reaching that point in the manual. Address the +goals that a user will have in mind, and explain how to accomplish +them. Don't use Unix man pages as a model for how to write GNU +documentation; they are a bad example to follow. + + The manual should have a node named `PROGRAM Invocation' or +`Invoking PROGRAM', where PROGRAM stands for the name of the program +being described, as you would type it in the shell to run the 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 +`@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. + + In addition to its manual, the package should have a file named +`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 `NEWS' file gets very long, move some of the older items into +a file named `ONEWS' and put a note at the end referring the user to +that file. + + 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. + + It is ok to supply a man page for the program as well as a Texinfo +manual if you wish to. But keep in mind that supporting a man page +requires continual effort, each time the program is changed. Any time +you spend on the man page is time taken away from more useful things you +could contribute. + + Thus, even if a user volunteers to donate a man page, you may find +this gift costly to accept. Unless you have time on your hands, it may +be better to refuse the man page unless the same volunteer agrees to +take full responsibility for maintaining it--so that you can wash your +hands of it entirely. If the volunteer ceases to do the job, then +don't feel obliged to pick it up yourself; it may be better to withdraw +the man page until another volunteer offers to carry on with it. + + Alternatively, if you expect the discrepancies to be small enough +that the man page remains useful, 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, and describing how to +access the Texinfo documentation. + + +File: standards.info, Node: Releases, Prev: Documentation, Up: Top + +Making Releases +*************** + + Package the distribution of Foo version 69.96 in a gzipped tar file +named `foo-69.96.tar.gz'. It should unpack into a subdirectory named +`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 "source +files" and "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, Lex, TeX, and 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 *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 `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-DOG. A +name on MS-DOG consists of up to 8 characters, optionally followed by a +period and up to three characters. MS-DOG will truncate extra +characters both before and after the period. Thus, `foobarhacker.c' +and `foobarhacker.o' are not ambiguous; they are truncated to +`foobarha.c' and `foobarha.o', which are distinct. + + Include in your distribution a copy of the `texinfo.tex' you used to +test print any `*.texinfo' 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. + + diff --git a/gnu/lib/libg++/etc/standards.texi b/gnu/lib/libg++/etc/standards.texi new file mode 100644 index 00000000000..13908d65fe4 --- /dev/null +++ b/gnu/lib/libg++/etc/standards.texi @@ -0,0 +1,2295 @@ +\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 28 March 1994 +@c %**end of header + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Standards: (standards). GNU coding standards. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@setchapternewpage off + +@ifinfo +GNU Coding Standards +Copyright (C) 1992, 1993, 1994 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. + +@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 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 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 Free Software Foundation. +@end titlepage + +@ifinfo +@node Top, Reading Non-Free Code, (dir), (dir) +@top Version + +Last updated @value{lastupdate}. +@end ifinfo + +@menu +* Reading Non-Free Code:: Referring to Proprietary Programs +* Contributions:: Accepting Contributions +* Change Logs:: Recording Changes +* Compatibility:: Compatibility with Other Implementations +* Makefile Conventions:: Makefile Conventions +* Configuration:: How Configuration Should Work +* Source Language:: Using Languages Other Than C +* Formatting:: Formatting Your Source Code +* Comments:: Commenting Your Work +* Syntactic Conventions:: Clean Use of C Constructs +* Names:: Naming Variables and Functions +* Using Extensions:: Using Non-standard Features +* System Functions:: Portability and ``standard'' library functions +* Semantics:: Program Behavior for All Programs +* Errors:: Formatting Error Messages +* Libraries:: Library Behavior +* Portability:: Portability As It Applies to GNU +* User Interfaces:: Standards for Command Line Interfaces +* Documentation:: Documenting Programs +* Releases:: Making Releases +@end menu + +@node Reading Non-Free Code +@chapter 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 +@chapter 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 change, 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. + +I 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 Change Logs +@chapter Change Logs + +Keep a change log for each directory, describing the changes made to +source files in that directory. 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 eliminate conceptual inconsistencies between different parts +of a program; they can give you a history of how the conflicting +concepts arose. + +Use the Emacs command @kbd{M-x add-change} to start a new entry in the +change log. 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. + +Separate unrelated 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. + +Here are some examples: + +@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 them; 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 the +entry. + +There's no need to describe the full purpose of the changes or how they +work together. It is better to put such explanations in comments in the +code. That's why just ``New function'' is enough; there is a comment +with the function in the source to explain what it does. + +However, sometimes it is useful to write one line to describe the +overall purpose of a large batch of changes. + +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. + +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. Just write in +the entry for the function being called, ``All callers changed.'' + +When you change just comments or doc strings, it is enough to write an +entry for the file, without mentioning the functions. Write just, +``Doc fix.'' There's no need to keep a change log 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. + + +@node Compatibility +@chapter Compatibility with Other Implementations + +With certain 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} 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, +vi is replaced with Emacs.) But it is nice to offer a compatible +feature as well. (There is a free 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. + +@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. +@include make-stds.texi + +@node Configuration +@chapter 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, 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. So would @samp{sun3-bsd4.2}, since SunOS is +basically @sc{BSD} and no other @sc{BSD} system is used on a Sun. 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. + +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 compilation 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. + + +@node Source Language +@chapter 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. + +Thus, it is not a problem that GNU Emacs contains code written in Emacs +Lisp, because it comes with a Lisp interpreter. + +@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 Formatting +@chapter 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 +@chapter 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 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 +identifer 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 +#ifdef foo + @dots{} +#else /* not foo */ + @dots{} +#endif /* not foo */ +@end example + +@noindent +but, by contrast, write the comments this way for a @samp{#ifndef}: + +@example +#ifndef foo + @dots{} +#else /* foo */ + @dots{} +#endif /* foo */ +@end example + + +@node Syntactic Conventions +@chapter 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 +int foo, + bar; +@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. + +@node Names +@chapter Naming Variables and Functions + +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 +/* Ignore changes in horizontal whitespace (-b). */ +int ignore_space_change_flag; +@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 System V. 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 Using Extensions +@chapter 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. + +Since most computer systems do not yet implement @sc{ANSI} C, using the +@sc{ANSI} C features is effectively using a GNU extension, so the +same considerations apply. (Except for @sc{ANSI} features that we +discourage, such as trigraphs---don't ever use them.) + + +@node System Functions +@chapter Calling System Functions + +C implementations differ substantially. ANSI C reduces but does not +eliminate the incompatibilities; meanwhile, many users wish to compile +GNU software with pre-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 +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. The problem 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 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}; other 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 ANSI +string functions are off-limits 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}.) 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 Semantics +@chapter Program Behavior for All Programs + +Avoid arbitrary limits on the length or number of @emph{any} data +structure, including filenames, 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}. + +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. + +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. + + +@node Errors +@chapter 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 filename. 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 Libraries +@chapter 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 Portability +@chapter Portability As It Applies to GNU + +Much of what is called ``portability'' in the Unix world refers to +porting to different Unix versions. This is a secondary consideration +for GNU software, because its primary purpose is to run on top of one +and only one kernel, the GNU kernel, compiled with one and only one C +compiler, the GNU C compiler. The amount and kinds of variation among +GNU systems on different cpu's will be like the variation among Berkeley +4.3 systems on different cpu's. + +All users today run GNU software on non-GNU systems. So supporting a +variety of non-GNU systems is desirable; simply not paramount. +The easiest way to achieve portability to a reasonable range of systems +is to use Autoconf. It's unlikely that your program needs to know more +information about the host machine than Autoconf can provide, simply +because most of the programs that need such knowledge have already been +written. + +It is difficult to be sure exactly what facilities the GNU kernel +will provide, since it isn't finished yet. Therefore, assume you can +use anything in 4.3; just avoid using the format of semi-internal data +bases (e.g., directories) when there is a higher-level alternative +(@code{readdir}). + +You can freely assume any reasonably standard facilities in the C +language, libraries or kernel, because we will find it necessary to +support these facilities in the full GNU system, whether or not we +have already done so. The fact that there may exist kernels or C +compilers that lack these facilities is irrelevant as long as the GNU +kernel and C compiler support them. + +It remains necessary to worry about differences among cpu types, such +as the difference in byte ordering and alignment restrictions. It's +unlikely that 16-bit machines will ever be supported by GNU, so there +is no point in spending any time to consider the possibility that an +int will be less than 32 bits. + +You can assume that all pointers have the same format, regardless +of the type they point to, and that this is really an integer. +There are some weird machines where this isn't true, but they aren't +important; don't waste time catering to them. Besides, eventually +we will put function prototypes into all GNU programs, and that will +probably make your program work even on weird machines. + +Since some important machines (including the 68000) are big-endian, +it is important not to assume that the address of an @code{int} object +is also the address of its least-significant byte. Thus, don't +make the following mistake: + +@example +int c; +@dots{} +while ((c = getchar()) != EOF) + write(file_descriptor, &c, 1); +@end example + +You can assume that it is reasonable to use a meg of memory. Don't +strain to reduce memory usage unless it can get to that level. If +your program creates complicated data structures, just make them in +core and give a fatal error if malloc returns zero. + +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. + + +@node User Interfaces +@chapter 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. The table appears below. + +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. + +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}). Even if you allow an output file name +as an ordinary argument for compatibility, try to provide a suitable +option as well. This will lead to more consistency among GNU +utilities, so that there are fewer idiosyncracies for users to +remember. + +Programs should support an option @samp{--version} which prints the +program's version number on standard output and exits successfully, and +an option @samp{--help} which prints option usage information on +standard output and exits successfully. These options should inhibit +the normal function of the command; they should do nothing except print +the requested information. + +@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 auto-check +@samp{-a} in @code{recode}. + +@item auto-reference +@samp{-A} in @code{ptx}. + +@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 arglength +@samp{-l} in @code{m4}. + +@item ascii +@samp{-a} in @code{diff}. + +@item assume-new +@samp{-W} in Make. + +@item assume-old +@samp{-o} in Make. + +@item backward-search +@samp{-B} in etags. + +@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 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++ +@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 compress +@samp{-Z} in @code{tar}. + +@item concatenate +@samp{-A} in @code{tar}. + +@item confirmation +@samp{-w} in @code{tar}. + +@item context +Used in @code{diff}. + +@item copyright +@samp{-C} in @code{ptx} and @code{recode}. + +@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 cxref +@samp{-x} in @code{etags}. + +@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{etags}. + +@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 diversions +@samp{-N} in @code{m4}. + +@item dry-run +@samp{-n} in Make. + +@item ed +@samp{-e} in @code{diff}. + +@item elide-empty-files +@samp{-z} in @code{csplit}. + +@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 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 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 file +@samp{-f} in @code{info}, Make, @code{mt}, and @code{tar}; +@samp{-n} in @code{sed}; +@samp{-r} in @code{touch}. + +@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 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 Makeinfo. + +@item force +@samp{-f} in @code{cp}, @code{ln}, @code{mv}, and @code{rm}. + +@item format +Used in @code{ls}, @code{time}, and @code{ptx}. + +@item forward-search +@samp{-F} in @code{etags}. + +@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}. + +@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 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}. + +@item ignore-errors +@samp{-i} in Make. + +@item ignore-file +@samp{-i} in @code{ptx}. + +@item ignore-indentation +@samp{-S} 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 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 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 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 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 new-file +@samp{-W} in Make. + +@item no-builtin-rules +@samp{-r} in Make. + +@item no-create +@samp{-c} in @code{touch}. + +@item no-defines +@samp{-D} in @code{etags}. + +@item no-dereference +@samp{-d} in @code{cp}. + +@item no-keep-going +@samp{-S} in Make. + +@item no-lines +@samp{-l} in Bison. + +@item no-prof +@samp{-e} in @code{gprof}. + +@item no-sort +@samp{-p} in @code{nm}. + +@item no-split +Used in Makeinfo. + +@item no-static +@samp{-a} in @code{gprof}. + +@item no-time +@samp{-E} in @code{gprof}. + +@item no-validate +Used in Makeinfo. + +@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 override +@samp{-o} in @code{rm}. + +@item owner +@samp{-o} in @code{install}. + +@item paginate +@samp{-l} in @code{diff}. + +@item paragraph-indent +Used in 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 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 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 quote-name +@samp{-Q} in @code{ls}. + +@item rcs +@samp{-n} in @code{diff}. + +@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 Makeinfo. + +@item references +@samp{-r} in @code{ptx}. + +@item regex +@samp{-r} in @code{tac}. + +@item release +@samp{-r} in @code{uname}. + +@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 sparse +@samp{-S} in @code{tar}. + +@item speed-large-files +@samp{-H} in @code{diff}. + +@item squeeze-blank +@samp{-s} in @code{cat}. + +@item starting-file +Used in @code{tar} and @code{diff} to specify which file within +a directory to start processing with. + +@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 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}. + +@item text +@samp{-a} in @code{diff}. + +@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{-G} in @code{m4} and @code{ptx}. + +@item tty +Used in GDB. + +@item typedefs +@samp{-t} in @code{etags}. + +@item typedefs-and-c++ +@samp{-T} in @code{etags}. + +@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}, @samp{etags}, @samp{mv}, @samp{tar}. + +@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{etags}. + +@item volume +@samp{-V} in @code{tar}. + +@item what-if +@samp{-W} in Make. + +@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 Documentation +@chapter Documenting Programs + +Please use Texinfo for documenting GNU programs. See the Texinfo +manual, either the hardcopy or the version in the GNU Emacs Info +subsystem (@kbd{C-h i}). See existing GNU Texinfo files (e.g., those +under the @file{man/} directory in the GNU Emacs distribution) for +examples. + +The title page of the manual should state the version of the program +which the manual applies to. 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. + +The manual should document all command-line arguments and all +commands. It should give examples of their use. But don't organize +the manual as a list of features. Instead, organize it by the +concepts a user will have before reaching that point in the manual. +Address the goals that a user will have in mind, and explain how to +accomplish them. Don't use Unix man pages as a model for how to +write GNU documentation; they are a bad example to follow. + +The manual should have a node named @samp{@var{program} Invocation} or +@samp{Invoking @var{program}}, where @var{program} stands for the name +of the program being described, as you would type it in the shell to run +the 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. + +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. + +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. + +It is ok to supply a man page for the program as well as a Texinfo +manual if you wish to. But keep in mind that supporting a man page +requires continual effort, each time the program is changed. Any time +you spend on the man page is time taken away from more useful things you +could contribute. + +Thus, even if a user volunteers to donate a man page, you may find this +gift costly to accept. Unless you have time on your hands, it may be +better to refuse the man page unless the same volunteer agrees to take +full responsibility for maintaining it---so that you can wash your hands +of it entirely. If the volunteer ceases to do the job, then don't feel +obliged to pick it up yourself; it may be better to withdraw the man +page until another volunteer offers to carry on with it. + +Alternatively, if you expect the discrepancies to be small enough that +the man page remains useful, 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, and describing how to access the Texinfo +documentation. + +@node Releases +@chapter 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, Lex, @TeX{}, and 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-DOG. A +name on MS-DOG consists of up to 8 characters, optionally followed by a +period and up to three characters. MS-DOG 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} 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/gnu/lib/libg++/include/COPYING b/gnu/lib/libg++/include/COPYING new file mode 100644 index 00000000000..a43ea2126fb --- /dev/null +++ b/gnu/lib/libg++/include/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 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. + + 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., 675 Mass Ave, Cambridge, MA 02139, 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/gnu/lib/libg++/include/ChangeLog b/gnu/lib/libg++/include/ChangeLog new file mode 100644 index 00000000000..caf304a9d5d --- /dev/null +++ b/gnu/lib/libg++/include/ChangeLog @@ -0,0 +1,921 @@ +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: indented-text +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/gnu/lib/libg++/include/ansidecl.h b/gnu/lib/libg++/include/ansidecl.h new file mode 100644 index 00000000000..be04e42d56a --- /dev/null +++ b/gnu/lib/libg++/include/ansidecl.h @@ -0,0 +1,141 @@ +/* ANSI and traditional C compatability macros + Copyright 1991, 1992 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. + + 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'. + + 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)'. + + 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. + + For example: + extern int printf PARAMS ((CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#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 CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) + +#define PROTO(type, name, arglist) type name arglist +#define PARAMS(paramlist) paramlist +#define ANSI_PROTOTYPES 1 + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#ifndef const /* some systems define it in header files for non-ansi mode */ +#define const +#endif +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() +#define PROTO(type, name, arglist) type name () +#define PARAMS(paramlist) () + +#endif /* ANSI C. */ + +#endif /* ansidecl.h */ diff --git a/gnu/lib/libg++/include/demangle.h b/gnu/lib/libg++/include/demangle.h new file mode 100644 index 00000000000..377d4d697d1 --- /dev/null +++ b/gnu/lib/libg++/include/demangle.h @@ -0,0 +1,107 @@ +/* Defs for interface to demanglers. + Copyright 1992, 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. */ + + +#if !defined (DEMANGLE_H) +#define DEMANGLE_H + +#ifdef IN_GCC + +/* Add prototype support. */ +#ifndef PROTO +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define PROTO(ARGS) ARGS +#else +#define PROTO(ARGS) () +#endif +#endif + +#define PARAMS(ARGS) PROTO(ARGS) + +#ifdef __STDC__ +#define PTR void * +#else +#ifndef const +#define const +#endif +#define PTR char * +#endif + +#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_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 ((char *opname, char *result, int options)); + +extern char * +cplus_mangle_opname PARAMS ((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/gnu/lib/libg++/include/floatformat.h b/gnu/lib/libg++/include/floatformat.h new file mode 100644 index 00000000000..01e3dcb2944 --- /dev/null +++ b/gnu/lib/libg++/include/floatformat.h @@ -0,0 +1,88 @@ +/* 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. */ + +enum floatformat_byteorders { floatformat_little, floatformat_big }; + +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; + +/* 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/gnu/lib/libg++/include/getopt.h b/gnu/lib/libg++/include/getopt.h new file mode 100644 index 00000000000..abf91538320 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/include/libiberty.h b/gnu/lib/libg++/include/libiberty.h new file mode 100644 index 00000000000..4710c517691 --- /dev/null +++ b/gnu/lib/libg++/include/libiberty.h @@ -0,0 +1,129 @@ +/* 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. */ + +extern char *basename (); + +/* 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)); + +/* 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. + + FIXME: We do not declare the parameter type (size_t) in order to + avoid conflicts with other declarations of xmalloc that exist in + programs which use libiberty. */ + +extern PTR xmalloc (); + +/* 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 (); + +/* 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)]) + +#endif /* ! defined (LIBIBERTY_H) */ diff --git a/gnu/lib/libg++/include/obstack.h b/gnu/lib/libg++/include/obstack.h new file mode 100644 index 00000000000..234132d2783 --- /dev/null +++ b/gnu/lib/libg++/include/obstack.h @@ -0,0 +1,513 @@ +/* obstack.h - object stack macros + Copyright (C) 1988, 89, 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 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. */ + +/* 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__) && ! 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 + +#ifdef __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. */ + 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 */ + 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. */ + +#ifdef __STDC__ +extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_free (struct obstack *, void *); +extern int _obstack_begin (struct obstack *, int, int, + void *(*) (), void (*) ()); +extern int _obstack_begin_1 (struct obstack *, int, int, + void *(*) (), void (*) (), void *); +#else +extern void _obstack_newchunk (); +extern void _obstack_free (); +extern int _obstack_begin (); +extern int _obstack_begin_1 (); +#endif + +#ifdef __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); + +#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) + +#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)) + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +#if defined (__GNUC__) && defined (__STDC__) +#if __GNUC__ < 2 +#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) \ + { \ + bcopy (where, __o->next_free, __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) \ + { \ + bcopy (where, __o->next_free, __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 : \ + (bcopy (where, (h)->next_free, (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 : \ + (bcopy (where, (h)->next_free, (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))) + +#ifdef __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/gnu/lib/libg++/install.sh b/gnu/lib/libg++/install.sh new file mode 100644 index 00000000000..31420abacc5 --- /dev/null +++ b/gnu/lib/libg++/install.sh @@ -0,0 +1,236 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ +# +# 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}" + +tranformbasename="" +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/gnu/lib/libg++/libg++/ChangeLog b/gnu/lib/libg++/libg++/ChangeLog new file mode 100644 index 00000000000..7356c2cfb28 --- /dev/null +++ b/gnu/lib/libg++/libg++/ChangeLog @@ -0,0 +1,2189 @@ +Sun Nov 12 16:28:06 1995 Per Bothner + + * g++FAQ.texi, g++FAQ.txt: Update to September 15 version. + + * Makefile.in (VERSION), README: Update to 2.7.1. + +Thu Nov 9 17:45:00 1995 Jason Merrill + + * config/*.ml: Don't include -lcurses in LIBS. Tweak. + + * configure.in (MOSTLYCLEAN): Add piclist. + +Wed Nov 8 17:02:42 1995 Jason Merrill + + * Makefile.in (piclist): Don't include CursesW.o for targets that + lack a shared libcurses. + +Mon Nov 6 14:18:16 1995 Jason Merrill + + * config/linux.ml: Be sure to get the right libstdc++. + +Thu Oct 26 22:51:44 1995 Per Bothner + + * Makefile.in (VERSION): Increase to 2.7.0.90. + +Tue Oct 24 15:53:59 1995 Brendan Kehoe + + * config/sol2shm.ml: New file, to pass -R to links. + * configure.in: For solaris2*, use sol2shm.ml instead of elfshlibm.ml. + +Tue Sep 26 15:22:31 1995 Jason Merrill + + * config/irix5.ml: Pass -rpath to links. + +Fri Sep 15 00:24:52 1995 Jason Merrill + + * config/linux.ml: Conform to Linux shared library numbering scheme. + * Makefile.in: Ditto. + +Mon Aug 21 11:46:03 1995 Jason Merrill + + * Makefile.in (install): Make shared library executable and + non-writable. Tidy. + +Sat Jul 22 14:00:26 1995 Doug Evans + + * Makefile.in (list): Add multilib support. + ($(SHLIB), rx.o, install): Likewise. + * configure.in: Likewise. + * src/Makefile.in (install): Likewise. + * src/configure.in (XCINCLUDES): Likewise. + * src/depend: Regenerated. + +Wed Jun 28 13:45:24 1995 Per Bothner + + * g++FAQ.texi, g++FAQ.txt: New versions from Joe Buck. + +Tue Jun 27 01:56:34 1995 Jeffrey A. Law + + * config/hpux.ml (SHFLAGS): Use $(PICFLAG), not $(LIBCFLAGS). + +Fri Jun 23 16:54:17 1995 Jason Merrill + + * Makefile.in (SHLINK): Force link. + (install): Ditto. + + * Makefile.in (SHARLIB): Provide a default value. + +Fri Jun 16 15:35:33 1995 Per Bothner + + * g++FAQ.texi, g++FAQ.txt: New files: Joe Buck's FAQ for G++. + +Thu Jun 15 21:01:10 1995 Per Bothner + + * Makefile.in (VERSION): Set to 2.7.0 + +Fri Jun 16 13:57:22 1995 Jason Merrill + + * 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 7 11:13:32 1995 Jason Merrill + + * configure.in (MOSTLYCLEAN): Remove stamp-picdir. + +Mon Jun 5 18:41:03 1995 Jason Merrill + + * Makefile.in (piclist): New rule. + (SHLIB): Use it. + + * configure.in (MOSTLYCLEAN): Remove pic. + (frags): Use toplevel pic frags. + + * config/*.ml: Build both shared and archive libraries. + +Mon May 22 23:36:42 1995 Per Bothner + + * Makefile.in (VERSION): Bump to 2.6.90. + (install): Re-format; add missing semi-colon. + +Wed May 10 05:07:45 1995 Jason Merrill + + * config/aix.ml: New file. + + * 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). + +Wed Apr 19 23:22:36 1995 Jason Merrill + + * config/dec-osf.ml (SHDEPS): Link with -lstdc++. + + * Makefile.in (SHLIB): Don't link with -lstdc++. + +Sun Apr 16 17:54:28 1995 Per Bothner + + * README: Minor updates. + * libg++.texi: Fix two typos. + +Wed Mar 8 16:34:44 1995 Jason Merrill + + * config/elf.ml (LIBS): Also link with libstdc++. + * config/sunos4.ml: Ditto. + + * config/dec-osf.ml (LIBS): Pass -rpath to linker. + +Thu Feb 16 00:13:44 1995 Jason Merrill + + * Makefile.in, config/*.ml: Generate shared library on most hosts + as libg++.so.$(VERSION), with a symlink to libg++.so, so that + multiple versions can coexist. + +Fri Jan 20 01:34:04 1995 Jason Merrill + + * Makefile.in (list): Don't include files from libio and libiberty. + (SHLIB): Link with libstdc++. + + * README.SHLIB: Add note about setting LD_LIBRARY_PATH. + +Mon Dec 5 19:45:21 1994 Per Bothner + + * README: Add note about AIX. + * NEWS: Mention STL and shared library support. + +Wed Nov 9 01:24:09 1994 Jason Merrill + + * README.SHLIB: Update for new shared library support. + +Mon Nov 7 16:22:44 1994 Jason Merrill + + * configure.in, config/*.ml: Handle --enable-shared. + (ALL): Reference 'libs' now. + (MOSTLYCLEAN): Handle 'list'. + (CLEAN): $(BUILD_LIBS) replaces $(TARGETLIB). + + * Makefile.in (ALL, CHECK, TARGET_LIB): Remove. + (ARLIB): libg++.a. + (SHLIB): libg++.so. + (SHFLAGS): flags used when building $(SHLIB). + (SHDEPS) : libraries linked when building $(SHLIB). + (LIBIBERTY_OBJECTS_TO_GET): Reference file in other directory. + (list): Build master list of objects. + (libg++.a): Use it. + (libg++.so): Ditto. + (install): Only ranlib $(ARLIB). + +Sat Nov 5 16:09:24 1994 Per Bothner + + * Makefile.in (VERSION): Update to 2.6.2. + * Makefile.in: Support for adding in ../libio/rx.o into libg++.a + moved here from src/Makefile.in. + * NEWS, README: Update. Libstdc++ is now enabled by default. + +Fri Nov 4 17:14:09 1994 Per Bothner + + * NEWS, TODO: Fix typos. + +Mon Oct 24 15:43:09 1994 Per Bothner + + * configure.in: Remove no-longer-used NOSTDINC setting. + * utils/etags.c: Removed. The one in emacs-19 is better maintained. + * utils/Makefile.in, utils/configure.in, README: Removed etags stuff. + +Thu Oct 20 17:07:53 1994 Per Bothner + + * README, NEWS: Note libstdc++. Other updates. + + * README.SHLIB: Update from Joseph E. Sacco . + +Tue Oct 18 17:52:42 1994 Per Bothner + + * README: Minor improvements. + * README.SHLIB: New file. (Notes on building shared libraries.) + * utils/c++-mode.el: Removed. + +Thu Oct 13 18:29:02 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (install): Warn if we detect headers from a pre-2.5 + installation. + + * README: Add more information about problems from old + installations. + +Wed Aug 24 12:54:04 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in: Change i[34]86-*-linux to i[345]86-*-linux. + +Sat Aug 20 12:12:01 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 2.6.1. + * NEWS: Note use of librx. + +Fri Jul 22 00:09:06 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * utils/etags.c: Replace index -> strchr and rindex -> strrchr. + Protect extern definitions of strchr, strrchr, strcpy, strncpy, + and strcmp by #ifndef's in case they are macros. + (This is a problem under AIX-3.2.5, as reported by + Tom McConnell .) + Remove commented-out definitions of index and rindex. + +Wed Jul 13 12:56:43 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 2.6. + * README, NEWS, TODO: Some updating. + +Mon Jul 11 18:56:59 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * README: Update libg+.texinfo -> libg++.texi, + Take out Doug Lea's prominent address. + +Tue May 31 09:25:41 1994 Mike Stump (mrs@cygnus.com) + + * utils/etags.c: Add #include , to avoid warning on alpha. + +Mon May 30 17:34:39 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (install): Various cleaning up. + Move commands to install include files to src/Makefile.in. + +Wed May 25 16:00:55 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Set to 2.5.4. + +Thu Mar 17 22:35:05 1994 Per Bothner (bothner@deneb.cygnus.com) + + * configure.in: Always set NOSTDINC in Makefiles. (Don't try + to determine if C++ compiler can handle it. We can't really + do that with the current configure setup.) + * README: Recommend build using 'make all "CC=gcc -O"'. + Note "make NOSTDIC=" is needed if using non-g++. + +Mon Mar 7 13:51:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (.stmp-tests): Don't recurse into tests directory if + it does not exist. + +Sun Dec 19 19:04:12 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Set to 2.5.3. + * README.386bsd: Removed. + +Fri Nov 26 19:07:36 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Set to 2.5.2. + +Thu Nov 4 16:58:40 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Update to version 2.5.1. + * Makefile.in (install): Remove code to install g++-include. + * configure.in: Restore code to set NOSTDINC. + +Wed Nov 3 11:50:21 1993 Per Bothner (bothner@kalessin.cygnus.com) + + +Mon Nov 1 17:56:05 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * g++-include directory: Removed. (We assume fixproto now.) + +Mon Oct 25 21:08:33 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * libg++.texi: Fix typo Slater -> [Daliel] Sleator. + Reported by Nathan Loofbourrow . + +Sat Oct 23 22:06:00 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Update to version 2.5. + * README, NEWS: Various updates. + +Thu Oct 14 16:04:10 1993 Karen Christiansen (karen@deneb.cygnus.com) + + * configure.in: changed mv to mv -f + +Mon Oct 11 12:43:51 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Bump version number to 2.4.90. + * README, NEWS: Update. + * Makefile.in: Remove iostream references. + +Mon Oct 4 17:47:51 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * libg++.texi: Note NIHCL availability and status. + * Makefile.in: Bump version number to 2.4.8. + +Wed Aug 25 13:00:55 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config/{aix3-1.mt, hpux.mt, isc.mt, sco4.mt}: + Moved to ../libio/config (since they affect _G_config.h). + * configure.in: Don't set my_target for sco/hpux/isc/aix. + +Wed Aug 18 12:23:19 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Use FOO.list files instead of SUBDIR/stamp. + +Tue Aug 17 18:36:08 1993 Per Bothner (bothner@kalessin.cygnus.com) + + Set up for using ../libio instead of ./iostream. + * Makefile.in (SUBDIRS): Don't include IO_DIR. + * utils/gen-params: Moved to ../libio. + * Makefile.in: Don't build or use _G_config.h; use ../libio. + * Makefile.in (stamp-libg++.a, libg++.a): Re-do to use + $(IO_DIR)/iostream-files, where IO_DIR defaults to ../libio. + * config.shared: Now just a stub that invokes ../libio/config.shared. + * utils/configure.in (srctrigger): gen-params -> g++dep.sh. + +Wed Aug 4 17:29:14 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in (install): add some 'else true' clauses for the + dain-bramaged DECstation Bourne shell + +Tue Aug 3 11:41:27 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config.shared: Change INSTALL to use ../install.sh -c. + * configure.in: Removed setting of INSTALL*. + * configure.in: Removed reference to aix.mt. + * config/aix.mt: Removed; no longer needed. + * config/{aix3-1.mt, hpux.mt, linux.mt, sco4.mt, solaris2.mt}: + Removed no-longer-needed setting of INSTALL*, NOSTDINC, + HAVE_CPLUS_EXTERN, and WRAP_C_INCLUDES. + +Sun Jul 25 19:21:45 1993 Per Bothner (bothner@kalessin) + + * config.shared: Set WRAP_C_INCLUDES to no longer search + g++-include, now that gcc has the fixproto script. + * configure.in: Don't need -nostdinc++ flag any more, + now that we're not using g++-include (with its #include_nexts). + * config.shared: Restructure *clean rules, partly to + avoid some duplication. + * README: Various clarifications. + +Wed Jul 7 15:33:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * utils/gen-params (DOLLAR_IN_LABEL): Look for `7filebuf' instead + of just `filebuf' on the vtable name. + +Tue Jun 29 13:02:39 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (VERSION): Set to 2.4 (yeah!). + * Makefile (install): Don't depend on all. + * config.shared: Undo change of Jun 25. + * configure.in: Handle *-*-solaris like *-*-solaris2. + +Fri Jun 25 12:23:22 1993 Per Bothner (bothner@rtl.cygnus.com) + + * config.shared: Make install-info depend on info. + +Wed Jun 23 12:56:23 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Define VERSION (for cd ..; make taz). + * Makefile.in: Set to version 2.3.91. + * Makefile.in (diststuff): Needed for distributions. + * Makefile (dts): Rip out. Subsumed by stuff in ../Makefile.in. + +Tue Jun 22 13:16:30 1993 Per Bothner (bothner@deneb.cygnus.com) + + * README.386bsd: Patches for 386bsd. + * utils/etags.c: Add AIX alloca support. + * config.shared (CXXINCLUDES): Fix quoting bug. + * libg++.texi: Document Integer methods fits_in_long(), + as_long(), fits_in_double(), as_long(). + +Tue Jun 15 11:54:42 1993 Per Bothner (bothner@deneb.cygnus.com) + + * config.shared (CLEAN): Default to ${TARGETPROG} ${TARGETLIB}. + * configure.in (DISTCLEAN): Add target-mkfrag. + +Mon Jun 7 13:13:27 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Increase version number to 2.3.90. + * configure.in: Always automatically generate a target Makefile + fragment, and then posibly append the one in config/*.mt. + This means the config/*.mt only needs to contain what is + different from the normal case, which should ease updates. + * config/rs6000.mt: Replace by aix3-1.mt (for buggy AIX 3.1), + and aix.mt (for more recent versions). + * config/isc.mt: New file. + * configure.in: Update for above config/*.mt changes. + +Tue Jun 1 16:53:14 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (stamp-$(TARGETLIB)): Delegate adding the + files from $(IODIR) to the sub-Makefile, invoking latter + with target add-to-targetlib. + * Makefile.in (_G_config.h): Set CC=$(CXX) when invoking + utils/gen-params, to "force" use of C++ compiler. + + * no-stream/Makefile.in (add-to-targetlib): New rule. + * utils/gen-params: Remove OLD_PLACEMENT support. + +Fri Jun 4 14:14:39 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (installcheck): Pass CXXFLAGS to test-install. + * config.shared: It's .SUFFIXES, not SUFFIXES. + +Thu Jun 3 00:53:03 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (install): split off the running of the installation + tests into a new target, installcheck + +Wed May 12 13:39:46 1993 Ian Lance Taylor (ian@cygnus.com) + + * utils/Makefile.in (etags.o, etags): Build etags via etags.o, + rather than directly from etags.c. + +Tue May 11 16:32:31 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * utils/gen-params: Look for new types `int32_t' and `uint32_t'. + +Mon May 10 09:57:25 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: Create target-mkfrag using move-if-change. + +Thu May 6 09:24:21 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): If TEST_INSTALL was overridden by + configure.in, don't try to install the test-install directory. + * configure.in: If cross, take gperf, test-install and utils out + of configdirs. Otherwise they wind up in subdirs and get built. + Override TEST_INSTALL to be empty rather than Makefile. + +Mon May 3 18:55:19 1993 Per Bothner (bothner@cygnus.com) + + * configure.in: If cross, use sed to hack Makefile, rather + than appending to target_makefile_frag, since that doesn't + work if there is a pre-existing fragment. + * Makefile.in: Re-order INSTALLDIR. + +Mon May 3 11:45:41 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.shared: Added missing quotes around TOUCH_ON_COMPILE. + +Fri Apr 30 15:12:36 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in (tooldir): New definition. + * Makefile.in (install): Install _G_config in $(tooldir)/include, + since it is the only include file that is target-dependent. + * Makefile.in (dist-fix-Makefile): Remove no-longer-needed kludge. + * config.shared: If TOUCH_ON_COMPILE is defined (at configure + time), make sure to 'touch stamp' on every compile. + This prevents unneeded re-builing of libg++.a. + +Wed Apr 28 11:44:05 1993 Ian Lance Taylor (ian@rtl.cygnus.com) + + * config.shared (MAKEOVERRIDES): Define to be empty. + +Tue Apr 27 15:52:19 1993 Per Bothner (bothner@cygnus.com) + + * config.shared (FLAGS_TO_PASS): Also pass INSTALL, INSTALL_DATA, + and INSTALL_PROGRAM. + * Makefile.in: Remove duplicate definition of FLAGS_TO_PASS. + Replace uses of BASE_FLAGS_TO_PASS by FLAGS_TO_PASS. + +Tue Apr 27 11:09:04 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.shared: info depends on .info files, not .texi files. + +Fri Apr 23 11:31:01 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * configure.in (target_makefile_frag): If there was one in srcdir, + then reset it to include ${srcdir} so we'll copy it properly. + +Sun Apr 18 23:54:45 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in and configure.in all directories, config.shared: + Revamped configure scheme. See libg++/NEWS. + * README: Some extra information, including a note + about what it means when test-install fails. + * libg++.texinfo: Renamed to libg++.texi. + * gen-params: Minor improvements (we hope) here and there. + +Tue Mar 23 00:14:33 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: minimal support for installcheck (FIXME), some + support for dvi target + +Fri Mar 19 10:35:32 1993 Ian Lance Taylor (ian@cygnus.com) + + * david d `zoo' zuhn's patches for ARG_MAX: + Makefile.in (BASE_FLAGS_TO_PASS): New variable. + (FLAGS_TO_PASS): Use BASE_FLAGS_TO_PASS. + (info, install-info, install): Use BASE_FLAGS_TO_PASS. + (subdir_do): Don't echo FLAGS_TO_PASS. + +Fri Mar 12 18:35:02 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: recognize *-*-solaris2* instead of *-*-solaris2 + +Fri Mar 5 11:41:15 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (MAKEOVERRIDES): Override GNU make 3.63 default + definition in order to reduce length of command line. + +Wed Feb 17 05:28:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: when making include files non-executable, make them + world readable as well + +Mon Jan 25 14:40:28 1993 Brendan Kehoe (brendan@cygnus.com) + + * config/alpha.mh: New file, for DEC's Alpha family. + +Wed Jan 13 21:17:26 1993 Mike Stump (mrs@cygnus.com) + + * .../Makefile.in, utils/gen-params, configure.in: Change .../gcc + to .../xgcc. + +Tue Jan 5 02:38:37 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: get the xiberty kludge "working" + +Wed Dec 30 14:15:31 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (info): added -I to command line, for @include + +Tue Dec 29 08:54:13 1992 Ian Lance Taylor (ian@cygnus.com) + + * utils/gen-params: Define _G_MATH_H_INLINES. Based only on + arguments to gen-params; no test yet. + * config/sco4.mt, config/hpux.mt (G_CONFIG_ARGS): pass + MATH_H_INLINES as 1. + + * Makefile.in: pass $(FLAGS_TO_PASS) to all calls to make. + +Mon Dec 28 12:07:11 1992 Ian Lance Taylor (ian@cygnus.com) + + * utils/gen-params: added check for CURSES_FORMAT_ARG, which + differs from system to system. + + * configure.in: for SCO 3.2v4 use sco4. + * config/sco4.mh: new file: SCO header files are C++ ready, and + SCO curses doesn't work with libg++ curses. + +Tue Dec 22 14:58:04 1992 Per Bothner (bothner@rtl.cygnus.com) + + * utils/gen-params: At end, delete all temporary files. + * configure.in: Don't bother linking lgpl.texinfo. + Clean up temp.o when done. + * Makefile.in: Set version number to 2.3.1. + * Makefile.in (*clean rules): Use ALL_SUBDIRS, which includes + old-stream and no-stream. + * Makefile.in: Add dependencies for libg++.a, to support + parallel makes. + +Tue Dec 15 14:45:05 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: configure based on target, instead of host. This + was a simple text substitution, which also involved renaming: + + * config/{hpux.mt,linux.mt,rs6000.mt,solaris2.mt}: renamed from .mh + +Sat Dec 12 00:05:42 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: No longer use HAVE_CPLUS_EXTERN; we can use + WRAP_C_INCLUDES instead. This should be somewhat more robust, + since we only depend on WRAP_C_INCLUDES being over-ridden. + * configure.in: Don't generate HAVE_CPLUS_EXTERN. + +Wed Dec 9 15:08:34 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Set version to 2.3. + * README, NEWS, TODO: Various updates. + +Fri Dec 4 17:44:40 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (install): Pass CXX to test-install, not CC. + * Makefile.in (dist): Use new ../etc directory for config stuff. + +Thu Dec 3 20:03:05 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Bump to version 2.2.95. + * Makefile.in (distclean, realclean): Don't delete + Makefile until *after* recursive makes. + * Makefile.in: Add a kludge to reconcile FSF/Cygnus conflict. + +Fri Nov 20 15:34:27 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (install): don't change permissions on all info files, + just the ones that get installed by this Makefile + +Fri Nov 20 14:34:52 1992 Per Bothner (bothner@cygnus.com) + + * configure.in: Add etc/fib to subdirs. + * configure.in, config/{linux,solaris2}.mh: Fix typo + INSTALLDATA -> INSTALL_DATA. + +Tue Nov 17 21:48:10 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to 2.2.92. + * Makefile.in (install): Use $(FLAGS_TO_PASS). + + * utils/gen-params: More "robust" sed patterns for extracting + type definitions. + +Sat Nov 7 19:45:42 1992 Per Bothner (bothner@rtl.cygnus.com) + + * config/solaris2.mh: New file, for Sun's Solaris2 OS. + * configure.in: Use it. + +Thu Nov 5 18:45:53 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to version 2.1.91. + * Makefile.in, */Makefile.in, etc: Replace ${C++} and + ${C++FLAGS} by ${CXX} and ${CXXFLAGS}. (Some versions of + 'make' do not like '+' in variable names.) + * Makefile.in (install): Fix typo (chmod directory). + +Mon Nov 2 13:20:54 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Don't pass $(NOSTDINC) as part of $(CC). + * Makefile.in (dist): include/demangle.h is also needed. + +Sun Nov 1 16:25:00 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in, */Makefile.in, etc: Use ${C++} (and ${C++FLAGS}) + to compile C++ programs, not ${CC}. + * Makefile.in: Bump to version 2.2.90. + * Makefile.in: Use FLAGS_TO_PASS more consistently. + +Sat Oct 31 19:24:05 1992 Per Bothner (bothner@rtl.cygnus.com) + + * libg++.texinfo: Fix a number of typos (from + meyering@cs.utexas.edu (Jim Meyering)). + +Fri Oct 9 16:44:30 1992 Per Bothner (bothner at PersSony) + + * Makefile.in: Fixed rule for building libg++.a to not do + anything if everyting is up-to-date, using a stamp-libg++.a + indicator file. + +Tue Sep 29 15:47:05 1992 Per Bothner (bothner@rtl.cygnus.com) + + * COPYING, COPYING-LIB: Removed (- use versions in ..). + * README: Update accordingly. + +Fri Sep 25 11:28:24 1992 Per Bothner (bothner@cygnus.com) + + * utils/gen-params: Define the type names (such as _G_size_t) + using typedefs, not macros. + * utils/gen-params: Add commented-out hook for turning + off use of templates (for old compilers). + +Thu Oct 1 23:53:29 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: use cpu-vendor-os triple instead of nested cases + +Tue Sep 29 12:07:35 1992 Ian Lance Taylor (ian@cygnus.com) + + * utils/gen-params: do the stdarg test with C++, not C, since + otherwise a type incompatibility is only a warning. + +Tue Sep 15 15:43:35 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): install libg++.a in $(INSTALLDIR), which + defaults to $(libdir), not $(tooldir). Default $(gxx_includedir) + to $(tooldir/g++-include; the g++-include directory is currently + target dependent because of the _G_config.h file. Also, gcc now + looks in $(tooldir) by default. + configure.in: if cross-compiling, override $(INSTALLDIR) to + $(tooldir)/lib. + +Fri Sep 11 16:05:08 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure.in, Makefile.in: When cross-compiling, don't build + gperf, or the utils directory, or test-install. + +Thu Sep 10 22:49:34 1992 Ian Lance Taylor (ian@cygnus.com) + + * utils/gen-params: test for existence of curses.h. It's not in + newlib. Also corrected a couple of typos. + +Wed Sep 9 12:34:00 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: try to get correct version of nm for target for + gen-params. + +Mon Aug 31 16:14:34 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to version 2.2.3. + * Makefile.in: Convert ${readme} to be `pwd`/ (with a + trailing slash) (as done in iostream). + +Mon Aug 17 17:15:06 1992 Per Bothner (bothner@rtl.cygnus.com) + + * utils/gen-params: Allow command-line (e.g. HAVE_UNISTD=0) + to override feature testing for various include files. + * Makefile.in: Pass $(NOSTDINC) to gen-params. + Turn off execute permission after installing data. + +Wed Aug 12 00:33:09 1992 Per Bothner (bothner@cygnus.com) + + * utils/c++-mode.el: New version. + + * Makefile.in: Change to version 2.2.1. + * Makefile.in: Remove some old junk. + Let 'install' depend on 'all'. + Let 'install' also install gperf. + * utils/gen-params: Test for Posix-compatible (or rather + iostream/procbuf.C-compatible) sys/wait.h by compiling + C++ test program, not C. Fixes NeXT problem, I hope. + Also, fix typo when predefined DOLLAR_IN_LABEL (fixes hpux). + +Mon Aug 10 11:38:14 1992 Ian Lance Taylor (ian@dumbest.cygnus.com) + + * Makefile.in: always create installation directories. + +Fri Jun 26 12:26:35 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Change to version 2.2. + * Makefile.in: Don't `cd ../libiberty; make'; since this + may cause some confusion (with old versions of GNU make + passing the wrong environment); instead assume that + ../Makefile takes care of it. + * configure.in, config/hpux.mh: hpux support. + * utils/etags.c: stat fixes for Posix and SVR3. + * utils/gen-params: Minor fixes. + +Mon Jun 22 23:54:31 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Increase to version 2.1.92. + * utils/gen-params. Add some paranoia when trying to + figure out a type for _G_ssize_t - make sure it doesn't + conflict with read(). + +Fri Jun 19 23:15:13 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Increase to version 2.1.91. + * utils/etags.c: New version, from emacs-19. + * utils/Makefile.in: New etags needs GNU getopt. + * utils/gen-params: Take out _G_HAVE_UNION_WAIT testing. + Instead, check that wait() will accept an (int*) - as + Posix and tradition (but not NeXT) says it should - + if it doesn't, say that we don't HAVE_SYS_WAIT. + +Wed Jun 17 18:48:16 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Increase version number to 2.1.90. + * no-stream/Makefile.in: New directory and file. + Useful for building libg++ *without* iostreams. + * Makefile.in, */Makefile.in: Cleanup *clean rules, + following standards.texi. + * utils/gendepend: Remove tempoary file depend.tmp. + * utils/gen-params: Check if defines union wait. + * WHATS.NEW: Merge old stuff from (deleted) etc/release.log. + * configure.in: Check that we find an install that works; + for SYSV, also try /usr/ucb/install. + * TODO, README, libg++.texinfo: Minor changes. + +Wed Jun 3 23:10:20 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Set version number to 2.1. + * utils/gen-params: If ${NAMES_HAVE_UNDERSCORE} is non-null, + use that value; don't bother trying to deduce it. + Ditto for ${DOLLAR_IN_LABEL}. + Replace sed-idiom -n -e 1,1p by -e '2,$d', because the + former doesn't work in GNU sed. + Add sigset_t to the list of types searched for. + Look for and defined _G_HAVE_SYS_WAIT appropriately. + * vms/{_G_config.h,AAAREADME.TXT}: New versions from Youngdale. + * libg++.texinfo: Note failure behavior for String::before(). + * Makefile.in: Use FLAGS_TO_PASS variable to be more + consistent about flags to pass to sub-makes. + Add some hooks for people with unusual environments: + Unually powerful C-libraries, or they don't want iostreams + to be part of libg++.a. + * configure.in: Test for Linux configuration. + Avoid confusing error message when looking for ranlib. + +Fri May 29 13:08:12 1992 Per Bothner (bothner@rtl.cygnus.com) + + * utils/gen-params: Remove TMP before running a sed which + writes to it (GNU sed supposedly has a bug where in that it + doesn't truncate a file before writing to it). + * Makefile.in: Include strerror.o strsignal.o (from libiberty). + + * Makefile.in: Bump to version 2.0.91. + * etags.c: #undef TRUE and FALSE before defining, to + avoid collisions. (These inevitable collisions make it + a mistake to define TRUE and FALSE in the first place.) + * gen-params: Test for . + Use ${SED} instead of sed, since GNU sed may be broken. + Check if the type we found for va_list works, and have + a fall-back plan for when it doesn't. + * gen-params: Check for sprintf return type. + Don't emit unneeded _G_const. + * config/mt-*: Remove unused and obsolete files. + * vms directory: Updates from Eric Youngdale. + * README: Minor fixes. + +Thu May 14 12:29:29 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Set version to 2.0.90. + * Makefile.in: Pass new flags to test-install, now that + test-install has been changed to to use ../libg++.a etc; + override that to use -lg++ etc to get inststalled versions. + * COPYING: Replace by version 2 GPL. + * README: Explain what copyrights apply to what. + * libg++.texinfo: Remove comments about gperf, since it + is not part of libg++ proper (and is GPL, not LGPL). + + * util/gen-params: Re-order in a logical order. + Change _G_NO_UNISTD_H to _G_HAVE_UNISTD for consistency. + Add test for _G_FRIEND_BUG (if the compiler barfs on + extern "C" functions as friends). + +Wed May 13 12:06:57 1992 Per Bothner (bothner@rtl.cygnus.com) + + * configure.in: Make sure to append 'depend' (if it exists) + to each Makefile. + +Sat May 9 12:43:38 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump version to 2.0.9. + + * WHATS.NEW: Be more expansive. + * configure.in: Fix some typos. + * Various Makefile.in's: Pass $(NOSTDINC) when compiling. + Also, fix some other CFLAGS problems. + +Wed May 6 11:48:32 1992 Per Bothner (bothner@rtl.cygnus.com) + + * utils/gen-params: Also #include in dummy.c, + so we can get clock_t. + + * utils/gen-params: Moved argument evaluation to start. + Pass -I${gccdir}/include if using ${gccdir}/gcc. + * Makefile.in: Pass $(XTRAFLAGS) to gen-params. + * vms directory: Renamed _G_CONFIG.H to _G_config.h. + +Sat May 2 16:48:07 1992 Per Bothner (bothner@rtl.cygnus.com) + + * vms directory: New files from Eric Youngdale. + +Thu Apr 30 13:42:59 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Bump to version 2.0.8 for "progressive" release. + * every Makefile.in: Replace gcc -O by just gcc, for constiency. + * utils/gen-params: Rename every temp.c -> dummy.c. + Add test for sys/resource.h, and use that instead of the + no-longer-meaning test for sysv. + * Makefile.in: Install sys/*.h from g++-include, not src. + Fix so that 'make libg++.a' does the right thing. + +Mon Apr 20 14:59:59 1992 Per Bothner (bothner@cygnus.com) + + * utils/gen-params: Add introductory commentary. + Replace tabs by space in dummy.out, so following + sed scripts don't have to worry about tabs. + +Thu Apr 30 09:06:32 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: add .NOEXPORT so that subdirs don't inherit + bad definitions. Notably, so that libiberty doesn't inherit + host_makefile_frag. + +Fri Apr 17 13:50:41 1992 Per Bothner (bothner@cygnus.com) + + * configure.in: Use new 'subdirs' feature of configure, + to configure all sub-directories in one invocation of + 'configure'. This means we can get rid of all subdir + configure.in files, and we can share configuration files. + * configure.in: If there is no host makefile fragment. + generate one. + * Makefile.in, */Makefile.in, etc: Use new configure scheme. + Also, define CC using a test for ../gcc/gcc, not just + a ../gcc directory. Similar for AR etc. + * utils/gen-params: New shell script to generate a .h + file with various system-specific parameters. + * Makefile.in: New rule to generate _G_config.h using + utils/gen-params. All Makefiles include the top-level + directory in the include search path, to make sure they + get _G_config.h (which is the the libg++ build directory, + not the srcdir). + +Mon Mar 23 16:46:01 1992 Per Bothner (bothner@rtl.cygnus.com) + + * libg++.texinfo: Remove references to itoa and similar + deprecated functions that return a pseudo-static buffer + (allocated by AllocRings). Replace by reference + to (new) printon() methods. + +Tue Mar 10 18:06:49 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Bump to version 2.0. + * Makefile.in (dist): Fix to avoid symlink cycles. + +Sat Mar 7 19:36:35 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (dist): Handle '.' as a srcdir. + +Sat Mar 7 00:03:05 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Make.defs: removed. + + * libg++.texinfo: added menu item hook. + +Fri Mar 6 16:51:58 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: bump version to 1.99. + +Fri Mar 6 15:53:13 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Remove some obsolete stuff. + * README, WHATS.NEW: Update. + * PROBLEMS renamed to TODO. + +Thu Mar 5 00:18:15 1992 Heinrich G. Seidl (hgs@cygnus.com) + + * configure.in, Makefile.in: use `g++' as compiler for the library + as does the user. + + * Make.defs: use again awk for depend rules, since sed + has too many bugs (sun's and GNU). + utils/g++dep.sh: print each dependency on one line + +Wed Mar 4 12:04:45 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Don't pass $(MAKE_ENVIRON) to test-install, + since we're trying to test the *installed* compiler. + Also, install-progs before the test-install. + +Tue Mar 3 23:01:05 1992 Per Bothner (bothner@cygnus.com) + + * PROBLEMS: Added to list of things to do. + +Tue Mar 3 21:06:38 1992 Heinrich G. Seidl (hgs@rtl.cygnus.com) + + * Created `utils' directory and moved "progs" from + `etc' into `utils'. + Makefile.in: `all' builds only programs and the libary, + `check' builds all in `tests' and `etc' and + runs the tests. + Some minor bug fixes to Makefiles. + +Tue Mar 3 16:58:38 1992 Per Bothner (bothner@cygnus.com) + + * vms directory: New files from + Eric Youngdale . + +Sun Mar 1 17:17:54 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Added 'check' and 'etc-tests' rules. + +Thu Feb 27 17:05:49 1992 Per Bothner (bothner@cygnus.com) + + * Make.defs: Change GXX from g++ to gcc, since g++ + passes -lg++ to ld, which may not be installed yet. + +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. + +Wed Feb 26 12:46:49 1992 Per Bothner (bothner at cygnus.com) + + * Make.defs: Change IDIR to use libdir instead of + datadir, to be compatible with FSF's gcc-2.0. + * Makefile.in: Removed bogus '@' prefix in rule. + +Wed Feb 26 01:24:34 1992 Michael Tiemann (tiemann at cygnus.com) + + * Make.defs: Propagate XTRAFLAGS into MAKE_ENVIRON. + +Wed Feb 19 23:23:02 1992 Per Bothner (bothner at cygnus.com) + + * Make.defs: Add IO_SRCDIR macro to name source + of either isotream or old-stream. This allows + an independent iostream distribution. + * Make.defs (depend rule): Create empty file if no sources. + * README: Move change summary to WHATS.NEW. + * WHATS.NEWS: Minor updates (and merge). + * COPYING-LIB: New file defining Library Licence. + +Sat Feb 15 13:06:50 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in (dist): Add some more top-level (above + libg++) files to the distribution. + + * Makefile.in: Bumped LIBG++_DIST_VERSION to 1.91. + * README: Made some very inadequate updates. + +Mon Feb 10 11:28:19 1992 Per Bothner (bothner at rtl.cygnus.com) + + * libg++.texinfo: Discourage use of AllocRings, + and encourage care using String::operator const char *. + (The latter has just now been changed to not copy + using an AllocRing.) + +Fri Feb 7 11:46:18 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Added LIBG++_DIST_VERSION; set it to 1.90. + Added 'dist' rule to make distribution tar file. + * libg++.texinfo: Preliminary changes to document + new iostream facilities. + +Fri Jan 31 17:13:11 1992 Per Bothner (bothner at cygnus.com) + + * WHATS.NEW: New file, to document recent changes. + +Wed Jan 29 12:54:10 1992 Per Bothner (bothner at cygnus.com) + + * Make.defs: Change LIBDIR and IDIR so that libg++.a and + g++-include/* go info $(libdir) and $(datadir)/g++-include. + Thus we don't have to worry about gcc's $(libsubdir) + depending on gcc's version number. + Also, add compilation rules for *.C. + +Sat Jan 25 15:59:01 1992 Per Bothner (bothner at PersSony) + + * Make.defs, all Makefile.in files: Centralize rules for + depend, FORCE, and Makefile in MAke.defs. Remove such + rules from every Makeifle.in. + * Makefile.in: Don't pass GXXFLAGS or EH_FILES to sub-makes. + +Fri Jan 17 15:32:01 1992 Per Bothner (bothner at cygnus.com) + + * Make.defs: Make iostream be the default value of IO_DIR. + Removed duplicate -I$(SRCIDIR) from COMPILE.cc macro. + +Sun Jan 5 00:23:20 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in, Make.defs, old-stream/Makefile.in: + Fix install-include-files rule. + * Makefile.in, Make.defs: Move installation directory + names and INSTALL defines from former to latter. + * configure.in: Add test-install directory. + + * Makefile.in, Make.defs: Move stuff from former to latter. + * Make.defs: Allow switching between old stream and new + iostream library. Allow use from any sub-directory. + * configure.in: Add old-stream and gperf sub-directories. + +Fri Jan 3 16:36:31 1992 Per Bothner (bothner at cygnus.com) + + * Complex.h, Fix.h, String.h, gen/DLList.ccP, gen/SLList.ccP, + gen/Plex.ccP, gen/Vec.hP: Add #include as needed. + It was included by the old stream.h, but not by the new iostream.h. + * String.h: Fix some portabilty problems that depended + on the old stream code. + +Thu Jan 2 21:07:04 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in (info, install-info, clean-info): Handle info files. + (assorted): Clean up unused macros, etc. + + * libg++.texinfo: Minor lint found by makeinfo and tex. + +Tue Dec 31 18:16:12 1991 Per Bothner (bothner at cygnus.com) + + Changes that allow makes to take be made either from here, + or directly in a sub-directory. + * Make.defs: New file to contain defiitions shared between + libg++ sub-directories. + * Makefile.in: Removed stuff now in Make.defs. + * configure.in: Add iostream to configdirs. + Define host_makefile_frag to pull in Make.defs. + +Tue Feb 19 06:41:00 1991 Doug Lea (dl at g.oswego.edu) + + * malloc.c: Don't override use of libg++ version of bcopy + for SYSV users + + * timer.cc: Removed ifdefs for tek4300, since they are reported + not to be necessary or useful + + * CursesW.h, curses.h: removed touchline and touchoverlap, + since they are apparently nonstandard, and aren't supported + in most C curses libraries. + + * Removed test0 and twrapper from tests, since + they are not fully supported in g++-1.39.0 + +Sat Jan 26 05:24:22 1991 Doug Lea (dl at g.oswego.edu) + + * signal.h: Reinstate full path name of C version of signal.h + +Fri Jan 25 08:45:09 1991 Doug Lea (dl at g.oswego.edu) + + * BitSet.h, BitString.h: pos and index fns inlined regardless + of __OPTIMIZE__, since needed elsewhere. + + * RNG.h killed redundant #ifdef __GNU__ + +Fri Dec 28 06:31:03 1990 Doug Lea (dl at g.oswego.edu) + + * FPQueue.hP, FPStack.hP: removed defaults from defs (kept in decls) + +Sat Dec 22 14:51:40 1990 Doug Lea (dl at g.oswego.edu) + + * Integer.cc; atoIntRep: pulled sgn assignment out of loop + +Fri Dec 14 16:43:04 1990 Doug Lea (dl at g.oswego.edu) + + * Complex.cc: Fixed pow(Complex, Complex), and added + pow(Complex, double), from thc@cs.brown.edu + +Wed Dec 12 11:47:51 1990 Doug Lea (dl at g.oswego.edu) + + * malloc.c: Killed prototype decls of fputs, fprintf; + just use whatever stdio.h gives. + +Thu Nov 29 13:02:32 1990 Doug Lea (dl at g.oswego.edu) + + * dtoa.cc: better bounds for workspace arrays + +Wed Nov 7 05:53:36 1990 Doug Lea (dl at g.oswego.edu) + + * ACG.cc: function LCG marked as static + +Sun Oct 28 05:32:30 1990 Doug Lea (dl at g.oswego.edu) + + * std.h: ioctl decl now has void*, not char* as last param, since + sometimes need to pass in structs. + +Sat Oct 20 05:51:21 1990 Doug Lea (dl at g.oswego.edu) + + * sys/socket.h: added getpeername decl + +Tue Oct 16 08:00:14 1990 Doug Lea (dl at g.oswego.edu) + + * Integer.cc (div) Overallocate `r' if necessary to ensure + trailing 0. + +Mon Oct 15 05:11:09 1990 Doug Lea (dl at g.oswego.edu) + + * EH2.c: Added __raise_exception from tiemann + +Thu Oct 11 05:50:34 1990 Doug Lea (dl at g.oswego.edu) + + * VHMap.ccP, CHMap.ccP. Base initializers explicitly name base + classes in constructors + +Sat Oct 6 08:56:56 1990 Doug Lea (dl at g.oswego.edu) + + * RNG.cc: `volatile' added for vars that might have + greater precision in FP hardware than in memory, to + force comparisons to be done with memory versions, + thus avoiding rounding error. + + * Incorporated patches for graph from rich@rice.edu + + * CHMap.hP: Fixed ifdef name to match class name for CHNode + +Sun Sep 30 06:50:45 1990 Doug Lea (dl at g.oswego.edu) + + * pow.cc: removed redundant tests + +Tue Sep 4 15:07:35 1990 Doug Lea (dl at g.oswego.edu) + + * Regex.cc: Don't die when someone declares Regex(0). + +Mon Aug 27 06:06:08 1990 Doug Lea (dl at g.oswego.edu) + + * curses.h, CursesW: added vax to list of implementations not + supporting touchline & touchoverlap + +Thu Aug 23 05:46:16 1990 Doug Lea (dl at g.oswego.edu) + + * std.h, resource.h text.hello.cc: more changes for i386 + + * sys/wait.h: Include , not + + * MPlex.hP: low() now returns lowest valid index. Similar + changes elsewhere. + + * (stdio.h, math.h...) Installed patches for HPUX 7.0 + +Mon Aug 13 08:17:29 1990 Doug Lea (dl at g.oswego.edu) + + * istream.h: ctor istream(int filedesc, char* buf, int buflen, + int sk, ostream* t = 0) -- made sk non-default to + prevent ambiguous matches. + + * Makefiles: rearrangements, patches from Ron Guillmette + to enable compiles of etc and gperf files without install + + * Added swap.h, from Ron Guilmette. Apparently needed for + Hansen's C++ answer book code. + + * String.h: String operator() made a synonym for at(int, int), + for compatibilty with Hansen's classes. + + * ostream.h: added ostream << (const void * p) to print p in hex. + + * std.h: qsort should return void; srand takes unsigned arg + (required under USG, doesn't matter for others). + + * Added complex.h, to include Complex.h & typedef Complex complex; + similarly with strclass.h + + * builtin.h: Added min & max inlines; added min.h, max.h, + minmax.h, and abs.h to just include builtin.h + + * values.h: defined HIBITS, HIBITL + + * CursesW.h, curses.h: sequent patches from jw@sics.se + + * streambuf.h: sputback renamed sputbackc for AT&T 1.2 compatibility + +Sat Aug 11 08:01:00 1990 Doug Lea (dl at g.oswego.edu) + + * MPlex.ccP: fixed off by one errors reported by bashford@scripps.edu + + * stdio.h: more patches from will@nirvana.westford.ccur.com + + * made #pragma implementation files for ctype, MIN, MAX, std, + curses, compare, math. Changed .h files accordingly + +Thu Aug 9 06:19:17 1990 Doug Lea (dl at g.oswego.edu) + + * SmplHist.h: fixed bad #include + +Wed Aug 8 09:49:56 1990 Doug Lea (dl at g.oswego.edu) + + * Shortened all .h and .cc file names to work for SYSV, + even ones preoviously OK because they were in own subdir. + Necessary for #pragma interface. Yuck. + +Mon Aug 6 09:54:23 1990 Doug Lea (dl at g.oswego.edu) + + * stdio.h, math.h, etc., added masscomp support from + will@nirvana.westford.ccur.com + + * twrapper, tgwrapper: killed now-unnecessary deletes + +Wed Jul 25 10:05:13 1990 Doug Lea (dl at g.oswego.edu) + + * stdio.h: new #defines for i386 + + * DLList.ccP (ins_after). Prepend if null pix, as stated in doc. + + * installed malloc.c revisions + +Fri Jul 20 12:00:05 1990 Doug Lea (dl at g.oswego.edu) + + * ostream.h (put) prevent sign extension comparing against EOF + +Tue Jul 17 10:06:12 1990 Doug Lea (dl at g.oswego.edu) + + * libg++.texinfo updated + +Thu Jul 12 08:10:07 1990 Doug Lea (dl at g.oswego.edu) + + * added Maxima.h from Igor Metz + +Fri Jul 6 06:19:32 1990 Doug Lea (dl at g.oswego.edu) + + * etc/PlotFile3D: updates from ngo + + * time.h don't include /usr/include/time.h on NeXT + +Mon Jul 2 07:48:51 1990 Doug Lea (dl at g.oswego.edu) + + * installed VMS patches from Eric Youngdale + + + * filebuf.cc (underflow) only reset iobuf ptrs if successful + + * filebuf.cc (overflow) loop ::write's in case whole + request can't be satisfied in one + +Sat Jun 23 12:18:54 1990 Doug Lea (dl at g.oswego.edu) + + * added bcopy.c, compiled ifdef USG, to guarantee compatibility, + from Eric Newton. Changed corresponding std.h declarations. + + * std.h: added declarations for re_comp, re_exec + + * (.h's, .hP's) added conditional compilation of + inlines under optimization only for all files + with #pragma interface + +Thu Jun 7 08:23:10 1990 Doug Lea (dl at g.oswego.edu) + + * killed all g++ prefix const member functions, since they + are no longer supported in g++. + + * (everywhere) added support for #pragma interface + and #pragma implementation; undid .il files since these + will be done via same mecahnism in g++. + +Fri May 25 10:39:18 1990 Doug Lea (dl at g.oswego.edu) + + * filebuf.cc (open) O_WRONLY added to append mode flags + +Sun May 6 09:27:06 1990 Doug Lea (dl at g.oswego.edu) + + * Complex.cc operator /(Complex&) replaced with that from + romine, that avoids potential under & overflow. + + * std.h; Commented out declaration for umask, pending a better + fix, since it is wrong for SunOS4.1 + + * File.cc, Curses.cc: patches to work with vsscanf from bothner + +Tue May 1 07:45:29 1990 Doug Lea (dl at g.oswego.edu) + + * math.h #include belongs inside extern "C" + +Fri Apr 27 06:15:32 1990 Doug Lea (dl at g.oswego.edu) + + * String.cc (ncopy0): null terminate even if same source + +Thu Apr 19 07:29:24 1990 Doug Lea (dl at g.oswego.edu) + + * Map.ccP (Map::error): error message reads "Map", not "Set" + +Tue Apr 17 10:32:25 1990 Doug Lea (dl at g.oswego.edu) + + * Stack, Queue, Set, Bag, Map .hP : added virtual destructors + +Fri Apr 6 07:05:31 1990 Doug Lea (dl at g.oswego.edu) + + * List.hP (pop) patch from dsouza + +Wed Apr 4 12:21:29 1990 Doug Lea (dl at g.oswego.edu) + + * Makefiles: use make var AR, not just ar + + * streambuf.cc (setbuf) delete old base if one was allocated + +Tue Apr 3 08:07:45 1990 Doug Lea (dl at g.oswego.edu) + + * time.h, std.h: changes for convex from schmidt + + * installed new malloc.c, with valloc & memalign added. + +Thu Mar 29 08:28:16 1990 Doug Lea (dl at g.oswego.edu) + + * stddef.h : added offsetof macro. + +Tue Mar 20 11:24:41 1990 Doug Lea (dl at g.oswego.edu) + + * Sample.cc: Confidence intervals now call t with degrees of freedom, + (n-1), not n. + +Sat Mar 17 10:17:02 1990 Doug Lea (dl at g.oswego.edu) + + * All genclass-able files moved to g++-include/gen. + genclass.sh script file changed accordingly. + + * (Everywhere) All X.h file inlines moved to il/X.il, + and only inlcuded when optimizing. Backup libg++.a + versions now generated via src/Xi.cc files. + Exceptions: ctype.h, and std.h (for SysV->Bsd conv (like bcopy)) + + * Regex.h now a separate file from String.h + +Mon Mar 12 06:53:57 1990 Doug Lea (dl at g.oswego.edu) + + * RPlex.cc:RPlex:: RPlex(int l, int chunksize). Fixed + incorrect biasing of initial chunk indices. + +Sun Mar 11 05:40:29 1990 Doug Lea (dl at g.oswego.edu) + + * timer.cc: ifdef USG -> if defined(USG) || defined(tek4300) + +Wed Feb 28 05:27:15 1990 Doug Lea (dl at g.oswego.edu) + + * gperf: patches from schmidt + + * Makefiles: removed dependencies on /usr/include files + +Tue Feb 27 05:21:22 1990 Doug Lea (dl at g.oswego.edu) + + * Installed c++-mode.el update from detlefs + +Mon Feb 26 08:03:32 1990 Doug Lea (dl at g.oswego.edu) + + * Incremental.h now includes a default destructor to avoid linking + problems. Thanks to eirik@elf.TN.Cornell.EDU. + + * all `error' routines now have const char*, not char* args. + + * Plex classes revamped to support const Plexes. Also, + removed `changes', `changed', since they aren't necessary anymore + +Sat Feb 24 05:56:13 1990 Doug Lea (dl at g.oswego.edu) + + * File.h verbose_error_handler, et al now have const char*, not + char* args + + * Installed EH2.cc in src + +Mon Feb 19 08:34:51 1990 Doug Lea (dl at g.oswego.edu) + + * installed Ngo's PlotFile3D in libg++/etc + +Sat Feb 17 05:28:25 1990 Doug Lea (dl at g.oswego.edu) + + * installed Schmidt's gperf, trie-gen, and Patricia revisions + + * String.cc pos <= 0 should be pos < 0 + +Tue Feb 13 08:21:11 1990 Doug Lea (dl at g.oswego.edu) + + * Itolong (Integer.cc) patch from salzman@rand.org + +Mon Feb 12 08:21:07 1990 Doug Lea (dl at g.oswego.edu) + + * allowed separate inclusion of ostream.h, istream.h and/or stream.h + +Thu Feb 8 07:02:49 1990 Doug Lea (dl at g.oswego.edu) + + * PlotFile: patches from ngo for Convex byte-ordering. + +Tue Feb 6 06:29:11 1990 Doug Lea (dl at g.oswego.edu) + + * Vec.ccP: sort() killed goto, replaced with nested if's, + since g++ complains about binding contours. + +Sat Feb 3 08:30:06 1990 Doug Lea (dl at g.oswego.edu) + + * Getopt.h: opterr is public, not private + + * builtin.cc, Random.cc, streambuf.cc broken into little pieces + + * std.h getpgrp, setpgrp now have (...) signatures, since + some versions on some systems have arguments. + + * put in malloc revision + + * prepend-header: globbing changes via ngo's patches + + * Plex: fixed declaration mismatches for fill + +Tue Jan 30 10:22:35 1990 Doug Lea (dl at g.oswego.edu) + + * kmp.cc: modified to use libg++ GetOpt, not libc getopt + +Wed Jan 24 05:47:53 1990 Doug Lea (dl at g.oswego.edu) + + * broke out struct xyzzy from builtin.cc into its own file in /src + +Sun Jan 21 09:44:10 1990 Doug Lea (dl at g.oswego.edu) + + * sys/types.h: protect wchar_t and ptrdiff_t from /usr/include version + + * stddef.h: wchar_t now defaults as unsigned short + +Sat Jan 20 08:51:01 1990 Doug Lea (dl at g.oswego.edu) + + * sys/file.h KERNEL now defined only if ultrix. + Also a typo: file_f should be file_h + +Fri Jan 19 05:18:03 1990 Doug Lea (dl at g.oswego.edu) + + * malloc.c: added #ifndef NO_NEW_HANDLER, so malloc.c + compilable in C environments with no new handlers, and + other #ifdefs to make it C++-compilable as well. + +Tue Jan 16 04:54:27 1990 Doug Lea (dl at g.oswego.edu) + + * libg++-1.36.3 released. + + * etc/benchmarks: enabled various options, now that + g++ works with them. + + * values.h vax MAX/MINFLOAT changed to be same as expected by gcc. + + * streambuf.cc: Filebuf::overflow(): Fp->eof() is not an + error condition. + + * std.h, stdio.h: more extern C fns declared as + returning int, not void when not specified as void by ANSI + or C man pages. + +Sat Jan 13 13:41:29 1990 Doug Lea (dl at g.oswego.edu) + + * stdio.h: puts returns int + +Fri Jan 12 05:49:09 1990 Doug Lea (dl at g.oswego.edu) + + * etc/lf/Dirent.h closedir returns void on some system, so + Dirent versions do too. + +Wed Jan 10 10:01:15 1990 Doug Lea (dl at g.oswego.edu) + + * Rational.h: 175 typo + +Mon Jan 8 09:43:14 1990 Doug Lea (dl at g.oswego.edu) + + * file.h: more protection against getting bad fn declarations + from /usr/include + + * builtin.cc: removed dependency on float.h + + * String.h Join, replicate need to be friends + +Sat Jan 6 08:48:18 1990 Doug Lea (dl at g.oswego.edu) + + * from rfg: minor DGUX accomodations in std.h, stdio.h, + math.h + +Fri Jan 5 06:41:02 1990 Doug Lea (dl at g.oswego.edu) + + * from Widen: added warning about tCurses needing linefeeds + on broken libcurses, fixed misc typos, added cfree() to malloc.c + + * math.h -- added inline defs of isnan and isinf for sequents + +Wed Jan 3 08:29:43 1990 Doug Lea (dl at g.oswego.edu) + + * builtin.cc: Deleted global _libgxx_io_oblast: no longer needed + killed extern decls of it elsewhere. + + * Strings, Integers: finished/cleaned up previous changes + +Tue Jan 2 10:43:29 1990 Doug Lea (dl at g.oswego.edu) + + * Integer.cc: isolated copy and clear calls to allocation fns + + * Strings: Removed StrTmp class, added double concatenation + +Mon Dec 11 08:31:48 1989 Doug Lea (dl at g.oswego.edu) + + * AVLSet.cc op &= plugged little memory leak: when u is exhausted, + but t isn't, delete rest of t. + + * AVLMap: _delete: cont field wasn't copied in a case it should + have been + + * merged tSet2 back into tSet and tBag2 back into tBag + + * BitSet.cc (BitSetCompl) ensure all 1's in s[0] when + complementing empty set + + * builtin.cc (return_elapsd_time, set_timer) No longer #ifdef'ed + for machines -- new .h organization should work for all. + + * builtin.cc (lg) redeclared as unsigned->long + + * DGUX patches from rfg installed + +Tue Dec 5 11:58:51 1989 Doug Lea (dl at g.oswego.edu) + + * BitSet, Integer, Rational: added constness, removed Tmp + classes, and used named return values + +Sat Dec 2 06:21:12 1989 Doug Lea (dl at g.oswego.edu) + + * builtin.cc (dtoa) #if _IEEE != 0 handle isnan, isinf + + * builtin.cc (itoa) force unsigned division in case + num == MININT + +Fri Dec 1 10:08:21 1989 Doug Lea (dl at g.oswego.edu) + + * istream::operator>> clear eof if at eof but got something valid + + * String::match and Regex::match return -1 on failure, since + 0 could be a legal value + + * gnulib3.c: Commented out ON_EXIT stuff. On Suns, for some + reason, on_exit routines don't link into libraries right. + + * std.h: fixed getopt proto + + * stat.h : added fn protos + + * installed Schmidt's reorganization of etc + + * math-68881.h fix paren error noted on bug-gcc list + + * CursesWindow(WINDOW*) initialize sib + + * Renamed AllocQueue to AllocRing + + * test.hello.cc #ifdefs for MIPSEL + + * Plex::del_chunk() delete the chunk, not just the chunk's data + +Sat Nov 25 12:50:06 1989 Doug Lea (dl at g.oswego.edu) + + * VStack, VQueue: add operator =() + + * Obstack::Obstack don't allocate on constructor, just on + first use + + * String::_gsub: don't build new rep if no matches + + * builtin.h: added more versions of abs + + * installed new malloc, and new.{h, cc} + + +Thu Nov 23 06:20:17 1989 Doug Lea (dl at g.oswego.edu) + + * added Schmidt's g++dep to etc + + * math.h: additions for anint(), etc., HP HAVE_FPU + +Wed Nov 22 14:48:24 1989 Doug Lea (dl at g.oswego.edu) + + * Added Schmidt's trie-gen to libg++/etc + +Tue Nov 21 08:50:47 1989 Doug Lea (dl at g.oswego.edu) + + * streambuf: eptr is now the pointer to the last valid + char in buffer, not the fence pointer, for AT&T compatibilty + + * stream, streambuf : Added line buffered put's as default + must #define NO_LINE_BUFFER_STREAMBUF to override + +Mon Nov 20 09:52:47 1989 Doug Lea (dl at g.oswego.edu) + + * Plex: finish previous change: add_low, add_high don't introduce + straggling chunks + + * new.h: typo, plus add default placement version of new() + + * PlotFile, BitString, Fix16 .h's: more cfrontisms + +Sun Nov 19 07:38:36 1989 Doug Lea (dl at g.oswego.edu) + + * removed File::operator FILE*() because it can lead + to ambiguities. + + * incorporated cfront-dependent #ifdefs, etc. from Schmidt + + * Fix24: integrated patches from wang + +Sat Nov 18 07:17:04 1989 Doug Lea (dl at g.oswego.edu) + + * XPlex, RPlex, MPlex (del_low, del_high) old straggling + empty chunks weren't being deleted. fixed. + +Thu Nov 16 05:56:43 1989 Doug Lea (dl at g.oswego.edu) + + * resource.h: added getrlimit, setrlimit + +Wed Nov 15 05:54:46 1989 Doug Lea (dl at g.oswego.edu) + + * String.h: typo const& Regex => const Regex& + +Fri Nov 10 06:45:55 1989 Doug Lea (dl at g.oswego.edu) + + * Makefile: force submakes in non-gnumake fashion + +Thu Nov 9 09:32:21 1989 Doug Lea (dl at g.oswego.edu) + + * Curses.cc, curses.h, ctype.h: patches based on darrlyo's stuff. + + * Fix.cc : *Correctly* installed ++i patch! + +Wed Nov 8 06:19:39 1989 Doug Lea (dl at g.oswego.edu) + + * stdio.h now is now sub-included in other .h's needing USG-based + info. + + * new etc/c++-mode.el from detlefs + + * etc/Makefile: -DETAGS for etags.c + + * more HPUX patches from darrylo and mike fion + +Tue Nov 7 07:23:25 1989 Doug Lea (dl at g.oswego.edu) + + * Fix.{h, cc}: cleanup in search of memory leaks + + * Added -DNO_GNULIB3 option in top-level Makefile + +Mon Nov 6 05:53:42 1989 Doug Lea (dl at g.oswego.edu) + + * std.h, stdio.h, ctype.h.... HPUX and DGUX patches from + cole & darrylo + + * tests/Makefile tCurses taken out of checktests + + * Bitset.cc: fixed underallocation in BitSettoa according to + patch from darrylo@hpsrdmo.hp.com + +Sun Nov 5 06:45:26 1989 Doug Lea (dl at g.oswego.edu) + + * gnulib3, Incremental.h, test.hello.cc: patched + via Eirik Fuller's incremental loading fixes + +Fri Nov 3 11:22:39 1989 Doug Lea (dl at g.oswego.edu) + + * 1.36.0 released, after misc cleanup + +Tue Oct 31 09:44:32 1989 Doug Lea (dl at g.oswego.edu) + + * added Rich Murphey's graph program to libg++/etc + +Mon Oct 30 10:13:07 1989 Doug Lea (dl at g.oswego.edu) + + * sys/file.h: include types.h & maybe fcntl.h Some folks need them + + * std.h: index, bcopy, etc. now inline, not macro if USG + + * streambuf.h: sputback returns success; + stream.h istream::putback/unget: set(_fail) if bad + +Tue Oct 24 16:53:05 1989 Doug Lea (dl at g.oswego.edu) + + * stddef.h -- now really defines size_t. OK via new sys/types.h + fake-out. + + * time.h -- now includes //usr/include/time.h too + +Sun Oct 22 07:58:36 1989 Doug Lea (dl at g.oswego.edu) + + * String.h, cc: reworked to allow proper operation for consts + (some new stuff #ifdef'ed out because of g++ problems) + +Sat Oct 21 15:29:55 1989 Doug Lea (dl at g.oswego.edu) + + * Fix.cc: (new_Fix) cure for d < 0 problem from eirik fuller + + * builtin.cc: added dtoa + + * AllocQueue.h,cc: added it & use elsewhere for building + formatting & ascii conversions + +Wed Oct 18 05:37:11 1989 Doug Lea (dl at g.oswego.edu) + + * Fix16.cc, Fix24.cc: Fixed operator / per wang's suggestions + +Tue Oct 17 06:47:25 1989 Doug Lea (dl at g.oswego.edu) + + * stream.cc, Integer.cc: istream op >>, fixed to not read + after EOF when decoding numbers + +Mon Oct 16 15:33:11 1989 Doug Lea (dl at g.oswego.edu) + + * added ostream << long long, and itoa's to handle + + * values.h, stdio.h, Fix.cc, File.cc: things for convex from + convex!csmith@uxc.cso.uiuc.edu + +Sat Oct 14 07:19:30 1989 Doug Lea (dl at g.oswego.edu) + + * time.h: typedef'ed timezone to c_proto_timezone if not USG + +Wed Oct 11 09:42:39 1989 Doug Lea (dl at g.oswego.edu) + + * Makefiles: fixed various typos + + * misc: cleaned up enum clashes reported with -Wenum-clash + + * stream.cc Added #ifdefs to use filebufs for standard streams + if Filebufs give people trouble. + +Tue Oct 3 07:02:56 1989 Doug Lea (dl at g.oswego.edu) + + * setjmp.h: now #includes host /usr/include/setjmp.h + +Mon Oct 2 16:00:59 1989 Doug Lea (dl at g.oswego.edu) + + * commented out gcc constness in revised Complex.h since + it's still officially illegal to declare fns with refs(ptrs) + as const + + * incorporated new gperf from schmidt + + * added dhrystone benchmark to etc + +Sat Sep 30 09:02:07 1989 Doug Lea (dl at g.oswego.edu) + + * Complex.h: revamped to use const, etc. + +Fri Sep 29 06:58:56 1989 Doug Lea (dl at g.oswego.edu) + + * added src/EH.cc from tiemann + + * SLList.hP now #include's the .defs file + + * CHSet, CHBag, CHMap, VHSet, VHBag, VHMap -- changed ints + to unsigned ints to ensure unsigned operations throughout. + +Mon Sep 25 07:32:11 1989 Doug Lea (dl at g.oswego.edu) + + * added new.h + +Sun Sep 24 05:31:50 1989 Doug Lea (dl at g.oswego.edu) + + * tgwrapper.cc: added init_nil to avoid crashes on exit. + + * other miscellaneous cleanup (fixed enum/int clashes, etc.) to + adapt to latest g++-1.36.0- + + * bool enum now in bool.h + +Thu Sep 14 06:18:46 1989 Doug Lea (dl at g.oswego.edu) + + * sys/socket.h: select must have void* args, since different + systems use int* or fd_set* + +Wed Sep 13 11:38:19 1989 Doug Lea (dl at g.oswego.edu) + + * builtin.cc: added unsigned versions of itoa, hex, dec, oct + +Tue Sep 12 09:28:01 1989 Doug Lea (dl at g.oswego.edu) + + * more misc. cleanup to avoid warnings: removed redundant + type information from declarations of all coercion operators. + +Sat Sep 9 06:25:03 1989 Doug Lea (dl at g.oswego.edu) + + * (everywhere) miscellaneous aesthetic cleanup to minimize g++ + warning messages. + + * (lots of files) used 'virtual fn() = 0' for pure virtual + functions, removing old `error(unimplemented...)' constructs. + allowed deletion of Stack.ccP, Queue.ccP, Deque.ccP files + which did only this. + + * took all defines out of libconfig.h, and killed it + HAVE_VPRINTF, etc -> stdio.h + CHAR_PER_LONG, etc -> Integer.cc + SHOULD_FREE_TO_REALLOC -> (no longer needed, killed) + USG -> people should run g++ with -DUSG now + +Fri Sep 8 06:48:58 1989 Doug Lea (dl at g.oswego.edu) + + * added Clark's version of etags that handles c++, to etc/ + + * moved special sparc alloca decl from libconfig.h to std.h + + * std.h, math.h, ... killed `overload' declarations + + * etc/getopt* => src/GetOpt.cc, g++-include/GetOpt.h, with + various corresponding changes + +Wed Sep 6 09:15:50 1989 Doug Lea (dl at g.oswego.edu) + + * math.h renamed `struct exception' to `libm_exception' + + * regex.c converted to use prototypes, etc. from schmidt + +Tue Sep 5 06:43:37 1989 Doug Lea (dl at g.oswego.edu) + + * new c++-mode.el from detlefs + + * added sys/param.h, which #undefs common macros, but keeps + needed constants + + * Integer.h: rearranged ordering of some inlines to please g++ + + * Fix.h: need new constructor Fix(int, _Frep*) to please g++ + + * added __xyzzy hack from tiemann to builtin.cc + + * added gnulib3 from tiemann + +Thu Aug 31 07:36:42 1989 Doug Lea (dl at g.oswego.edu) + + * more USG stuff from Klossner (stdio.h, libconfig.h, + values.h, ctype.h) + +Sun Aug 27 08:30:15 1989 Doug Lea (dl at g.oswego.edu) + + * genclass: changed to take output filename prefix argument + to avoid long file names on SYSV; tests files change accordingly + + * installed gperf update from schmidt + + * tests: added runtests, checktests to Makefile. Some tests + modified to suit. + +Sat Aug 26 09:00:14 1989 Doug Lea (dl at g.oswego.edu) + + * Plex, PHPQ files: deleted const qualifiers for some params + as temporary measure until all containers revised to use + const qualifiers as needed. + + * curses.h macros converted into inlines + + * added RankedAVLMap, based on code from paul%lfcs.ed.ac.uk + + * moved non-ANSI stuff (TRUE, etc., ) from stddef.h to builtin.h + + * added more USG stuff sent from rfg, grandi, cole, to standard headers + + * std.h: added #ifdef USG section for USG->BSD conversions + + * Makefiles: made more things adjustable, better USG support + + * PHPQ.ccP: (preallocate) added missing size argument to vector delete + +Fri Aug 25 12:25:12 1989 Doug Lea (dl at g.oswego.edu) + + * streambuf.cc: dumb error in filebuf::overflow + +Thu Aug 24 11:46:16 1989 Doug Lea (dl at g.oswego.edu) + + * libconfig.h, values.h: #defines for sony from jkp + +Wed Aug 23 06:54:43 1989 Doug Lea (dl at g.oswego.edu) + + * Fix16.h, Fix32.h: declared op* as friends correctly + + * String.h: declared StrTmp op + as friends of String + +Mon Aug 21 07:02:53 1989 Doug Lea (dl at g.oswego.edu) + + * Poisson.h, Lognormal.h: add missing `public' + + * assert.h: abort() declared volatile + + * Vec.ccP: made gsort static + + * std.h: added rewind & bsearch + + * Makefiles: deleted -fchar-charconst + +Thu Aug 10 07:31:37 1989 Doug Lea (dl at g.oswego.edu) + + * builtin.{h, cc}: added str(const char*, int width = 0) + + * streambuf.cc: init_streambuf_ptrs: postpone action if fp->_cnt 0 + (apparently needed for some USG systems) + + * stream.cc: get, getline: match AT&T 1.2 _fail conditions + +Sun Aug 6 07:16:19 1989 Doug Lea (dl at g.oswego.edu) + + * stream.cc, File.cc get(char[], int, char) read too many chars + +Thu Jul 20 09:42:44 1989 Doug Lea (dl at g.oswego.edu) + + * adapted more C-compatibility .h files from Interviews + +Wed Jul 19 09:23:27 1989 Doug Lea (dl at g.oswego.edu) + + * installed more C-compatibilty files: pwd.h, grp.h time.h + +Mon Jul 17 07:37:35 1989 Doug Lea (dl at g.oswego.edu) + + * installed Interviews/et++ compatible (I hope) signal.h + + * installed new version of gperf from schmidt + + * std.h: declared abort() and exit() as volatile + + * builtin.cc: typo in gcd + + * math.h: added overload decl for atan, etc + + * VHMap.cc: removed assumption that operator = returns value. + + * Makefiles: default dir is /usr/gnu/... not /usr/local + + * setjmp.h: fixed constants for sun to match those in + sun /usr/include files, added ns32000 + + * BSTSet.ccP added new linear-time rebalancing algorithm + + * builtin.cc: SYSV versions of timing stuff from ron cole + + * File.{h,cc} fixed File::tell, added O_CREAT to exclusive + access open, added fill(), flush(char). + + * incorporated new streams: stream.{h,cc}, streambuf.{h, cc}, + libg++.texinfo + + +Sat May 20 07:42:11 1989 Doug Lea (dl at rocky.oswego.edu) + + * math.h,math-68881.h: incorporated Fyfe's fixes to extern "C" problems + +Tue May 16 05:52:33 1989 Doug Lea (dl at rocky.oswego.edu) + + * RNG.cc ifdef _IEEE_ fixed to if _IEEE == 1 + + * Installed Staelin's prototype Makefile updates + +Mon May 15 06:25:12 1989 Doug Lea (dl at rocky.oswego.edu) + + * BitString.h: g++ optimizer bug workaround in left_trim + + * math-68881.h - fgetman (not fgetmant) fix from widen + +Sat May 13 11:00:35 1989 Doug Lea (dl at rocky.oswego.edu) + + * changes from tiemann for constructs of form X::f() + changed to this->X::f(), necessary now that static members + are implemented. [postscript: no, it wasn't necessary] + + * libg++.texinfo: misc documentation updates + +Fri May 12 05:06:06 1989 Doug Lea (dl at rocky.oswego.edu) + + * (lots of places) added friends and other minor changes + to adapt to new ``correct'' (but losing) g++ interpretation + of `protected:' + + * re-inserted `overload' in .h files -- tiemann + says that gdb needs these for now + + * stream.cc: eatwhite was inline by mistake. fixed. + +Thu May 11 07:31:06 1989 Doug Lea (dl at rocky.oswego.edu) + + * List.ccP: initializer class for Nil, since can't always use + { ... } initializer. Also made `head' a synonym for `get', + per request. + + * installed changes to etc files from schmidt + + * String.cc Scopy: return &NilSrep, not 0 for null + + * added math-68881.h to g++-include (from grunwald) + +Sun May 7 08:38:10 1989 Doug Lea (dl at rocky.oswego.edu) + + * catch-up day!: + converted header files to use extern "C" and #pragma once + killed `overload' declarations everywhere + renamed test files + added the beginnings of SYSV (USG) support + included some useful stuff for Suns in top Makefile (from Guilmette) + cleaned up other Makefiles + added File::gets (from Schmidt) + moved gperf from etc to a top level subdir + added the useless char* chr(ch) to builtin.h + genclass puts dots in file names to use Staelins GNU Makefile stuff + (also added his `prepend-header' utility) + added Schmidt's getopt stuff into etc. + New versions of fixpoint classes from Baudendistel + (needed to change set_overflow_handler to + set_{FixXX}_overflow_handler + for each FixXX, since overloads clash on typedef'ed fn types) + Adapted Schmidt's new quicksort for Vec class + +Fri Apr 28 16:26:17 1989 Doug Lea (dl at rocky.oswego.edu) + + * ACG.cc: fixed ~ACG per grunwald + +Thu Apr 20 05:22:46 1989 Doug Lea (dl at rocky.oswego.edu) + + * List.hP: first for nil list now returns null Pix + + * Integer.cc: rshift fixed problem with 0 shifts + +Mon Apr 10 05:17:04 1989 Doug Lea (dl at rocky.oswego.edu) + + * stream.h, PlotFile.h added explicit `private' for subclasses + +Sat Mar 18 06:08:30 1989 Doug Lea (dl at rocky.oswego.edu) + + * String.[h,cc]: added Regex::match_info + +Fri Mar 17 14:37:12 1989 Doug Lea (dl at rocky.oswego.edu) + + * stream.h: istream >> char now eats whitespace. + + * builtin.h: overloaded `even', `odd' + +Thu Mar 9 06:43:43 1989 Doug Lea (dl at rocky.oswego.edu) + + * Map.ccP: typo in Map::contents => + + * stdio.h : inserted coercion in putc macro to avoid incorrect + sign extension. + +Tue Mar 7 05:35:52 1989 Doug Lea (dl at rocky.oswego.edu) + + * List.hP: List::push no longer incorrectly calls dereference + + * Inserted patches to etc stuff from Doug Schmidt + +Sun Mar 5 07:57:01 1989 Doug Lea (dl at rocky.oswego.edu) + + * stream.h: added File::check_state to public functions + + * BitSet.cc: longtoBitSet: Fixed typo + +Sat Mar 4 10:06:24 1989 Doug Lea (dl at rocky.oswego.edu) + + * installed CursesWindow files + + * miscellaneous corrections to test files in light of + g++-1.34 changes + +Fri Mar 3 06:07:37 1989 Doug Lea (dl at rocky.oswego.edu) + + * incorporated new version of Doug Schmidt's gperf + + * BitString.cc: fixed reverse searching + +Sun Feb 26 05:44:28 1989 Doug Lea (dl at rocky.oswego.edu) + + * assert : killed old assert.cc, adapted gcc assert.h + +Sat Feb 25 09:23:35 1989 Doug Lea (dl at rocky.oswego.edu) + + * tests, libg++.texinfo: miscellaneous updates + + * stddef.h NULL is now just `0', not (void*)0 + + * Makefile: added `prefix' as in g++ Makefile + + * put a new c++-mode.el from david detlefs in etc + + * BitString.[h,cc] BitSet[h,cc] now use unsigned short arrays instead + of unsigned longs to avoid long i; i >> 32, which does not + work on Sun4s and probably other machines. Simplified + a few shift & mask constructs accordingly. + + * values.h, libconfig.h: support for sequent from + Johan Widen + + * Fix.h: repaired type mismatches + + * String.[cc,h] gsub now returns number of matches + + * String.cc gsub(Regex...): repaired using patches + from kadmon!jason@mtxinu.com + + * stream.h scan didn't return *this if fail -- fixed. + + * File.cc get(char*...): get of an empty line not a _fail condition + + * RNG.[h,cc] installed new code from grunwald + + +Tue Feb 7 05:53:23 1989 Doug Lea (dl at rocky.oswego.edu) + + * Integer.h,cc Added optional base to atoI via code from per bothner + + * String.h,cc Added `freq' method in String to count occurrences + using code from john willis + +Mon Feb 6 07:25:06 1989 Doug Lea (dl at rocky.oswego.edu) + + * BitSet.cc:op <=, < now work if first arg shorter than second; + clear() fixed. + * stream.h, stream.cc: made ostream<<(char*) non-inline + +Sun Feb 5 05:31:36 1989 Doug Lea (dl at rocky.oswego.edu) + + * test19.cc: typo c.empty fixed to c.empty() + +Tue Jan 31 05:51:36 1989 Doug Lea (dl at rocky.oswego.edu) + + * String.h: contains(Regex) return fact that search returns >= 0, + not just raw result. + + * Fix.h: correct protection problem in op* + + * replace regex.c with emacs 18.52 version + +Fri Jan 27 06:29:20 1989 Doug Lea (dl at rocky.oswego.edu) + + * AVLSet.ccP, AVLMap.ccP - check to see if root + is null before trying to delete elements + + * libg++/Makefile - change install of libg++ to cd to src + +Sat Jan 14 06:03:33 1989 Doug Lea (dl at rocky.oswego.edu) + + * fixed info node pointers in libg++.texinfo + +Wed Jan 11 06:20:37 1989 Doug Lea (dl at rocky.oswego.edu) + + * libg++-1.32.0 released + * Starting to use ChangeLog as of today + + +Local Variables: +version-control: never +End: diff --git a/gnu/lib/libg++/libg++/Makefile.in b/gnu/lib/libg++/libg++/Makefile.in new file mode 100644 index 00000000000..e04c80f800d --- /dev/null +++ b/gnu/lib/libg++/libg++/Makefile.in @@ -0,0 +1,246 @@ +# Makefile for GNU C++ class library (libg++) +# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc. +# written by Doug Lea (dl@rocky.oswego.edu) + +#This file is part of GNU libg++. + +#GNU libg++ is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 1, or (at your option) +#any later version. + +#GNU libg++ is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 libg++; see the file COPYING. If not, write to the Free +#Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +srcdir = . + +# We specify exactly what we want to pass down; don't let GNU make +# 3.63 overload the command line. +MAKEOVERRIDES= + +###**###################################################################### +# +# Directories, paths, compilation flags and program names. +# +# If a macro needs to have a different value, then change it in the +# site/architecture specific makefile in the directory config ! +# +# This file contains the documentation for the macros and possible values. +# Don't remove them even, if they are only comments ! + +VERSION = 2.7.1 +LIBG++_DIST_VERSION = $(VERSION) + +# ------- System-dependent defines + +# g++ so specific flags +OSFLAG= + +# ld or ld++ os specific libraries +#OSLIBS = + +# Comment out the next line to disable incremental linking test +# (this test NOT included in 1.39.0, so don't re-enable) ??? H.S. +#TEST0=test0 +#TEST0= + +# targets for test-install +TEST_INSTALL = test-90S-then-clean # test-90D-then-clean +VERIFY_GXX_INSTALLATION = foo_main # dfoo_main + + +# You can override gperf to not build it at all +GPERF = gperf +NON_IO_SUBDIRS = genclass src $(GPERF) utils tests etc test-install +SUBDIRS = $(NON_IO_SUBDIRS) +ALL_SUBDIRS = $(NON_IO_SUBDIRS) old-stream no-stream + +UTILS = # utils + +# C++ compiler to use when testing that installation has succeeded. +INSTALLED_CXX=$(bindir)/gcc + +ARLIB = libg++.a +SHLIB = libg++.so.$(VERSION) +SHARLIB = libg++-sh.a +SHLINK = libg++.so +MSHLINK = foo +SHFLAGS = +SHCURSES= +SHDEPS = -L../libstdc++ -lstdc++ -lm $(SHCURSES) + +BUILD_LIBS = $(ARLIB) + +RX_OBJ = $(MULTITOP)/../librx/rx.o + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +tooldir = $(exec_prefix)/$(target) +INSTALLDIR = $(libdir) + +###**###################################################################### +# +# compilation actions + +.PHONY: rest-in-parallel in-src in-io +rest-in-parallel: .stmp-genclass .stmp-tests .stmp-etc .stmp-gperf .stmp-utils + +libs: $(BUILD_LIBS) + +# FIXME: Need to multilib librx. +list: src/libgxx.list $(RX_OBJ) + -rm -f tlist + touch tlist + for f in `cat src/libgxx.list`; do \ + echo "src/$$f" >> tlist ; \ + done + echo "$(RX_OBJ)" >> tlist + mv tlist list + +piclist: list + -rm -f tlist + if [ -z "$(SHCURSES)" ]; then \ + sed 's,src/CursesW.o,,' list > tlist; \ + else \ + cp list tlist; \ + fi + [ -z "$(PICFLAG)" ] || \ + (sed 's,\([0-9A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \ + mv tlist2 tlist) + mv tlist piclist + +$(ARLIB): list + -rm -f t$(ARLIB) + $(AR) $(AR_FLAGS) t$(ARLIB) `cat list` + mv t$(ARLIB) $(ARLIB) + $(RANLIB) $(ARLIB) + +$(SHLIB): piclist $(MULTITOP)/../libstdc++/piclist + $(CXX) $(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 -sf $(SHLIB) $(SHLINK) + +$(MSHLINK): + ln -sf $(SHLIB) $(MSHLINK) + +src/libgxx.list: in-src +in-src: + @rootme=`pwd`/ ; export rootme ; cd src ; \ + $(MAKE) $(FLAGS_TO_PASS) libgxx.list + +$(MULTITOP)/../librx/rx.o: $(srcdir)/../librx/rx.c + rootme=`pwd`/ ; export rootme ; cd $(MULTITOP)/../librx; \ + $(MAKE) $(FLAGS_TO_PASS) rx.o + +.PHONY: installcheck +installcheck: check + +.stmp-genclass: $(BUILD_LIBS) + @rootme=`pwd`/ ; export rootme ; cd genclass ; \ + $(MAKE) $(FLAGS_TO_PASS) "gxx_includedir=$(gxx_includedir)" + touch $@ + +.stmp-tests: $(BUILD_LIBS) + @if [ -f tests/Makefile ]; then \ + rootme=`pwd`/ ; export rootme ; cd tests ; \ + $(MAKE) $(FLAGS_TO_PASS); \ + else true; fi + touch $@ + +.stmp-etc: $(BUILD_LIBS) + @rootme=`pwd`/ ; export rootme ; cd etc ; \ + $(MAKE) $(FLAGS_TO_PASS) + touch $@ + +.stmp-gperf: $(BUILD_LIBS) + @if [ "x$(GPERF)" != "x" ]; then \ + rootme=`pwd`/ ; export rootme ; cd $(GPERF) ; \ + $(MAKE) $(FLAGS_TO_PASS); \ + else true; fi + touch $@ + +.stmp-utils: $(BUILD_LIBS) + @if [ "x$(UTILS)" != "x" ]; then \ + rootme=`pwd`/ ; export rootme ; cd $(UTILS) ; \ + $(MAKE) $(FLAGS_TO_PASS); \ + else true; fi + touch $@ + +# +# +# Installation +# + +.PHONY: install +install: + @if [ -f $(gxx_includedir)/unistd.h ] ; then echo; \ + echo '*** You seem to have files in $(gxx_includedir)/g++-include'; \ + echo '*** left over from an old release of libg++. These must be removed.'; \ + echo '*** Please see $(srcdir)/README for more information.'; \ + echo; \ + else \ + true; \ + fi + for FILE in $(BUILD_LIBS) ; do \ + rm -f $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + if [ $$FILE = $(SHLINK) ] || [ $$FILE = $(MSHLINK) ]; then \ + ln -sf $(INSTALLDIR)$(MULTISUBDIR)/$(SHLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + elif [ $$FILE = $(SHLIB) ]; then \ + $(INSTALL_PROGRAM) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + : On the HP, turning off write access improves performance ; \ + chmod a-w $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + else \ + $(INSTALL_DATA) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + $(RANLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + chmod a-x $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + fi ; \ + done + @for D in src genclass $(UTILS) ; do \ + if [ -d $$D ] ; then \ + (rootme=`pwd`/ ; export rootme ; cd $$D;\ + $(MAKE) $(FLAGS_TO_PASS) "gxx_includedir=$(gxx_includedir)" install) ; \ + else true ; \ + fi ; \ + done + if [ "x$(GPERF)" != "x" ]; then \ + rootme=`pwd`/ ; export rootme ; cd gperf ;\ + $(MAKE) $(FLAGS_TO_PASS) install; \ + else true; fi + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +installcheck: + if [ "x$(TEST_INSTALL)" != "x" ]; then \ + cd test-install; $(MAKE) $(TEST_INSTALL) \ + CXX=$(INSTALLED_CXX) "CXXFLAGS=$(CXXFLAGS)" \ + COMPILE_FLAGS="" LIBS=-lg++; \ + else true; fi + +DIST_NAME = libg++-$(LIBG++_DIST_VERSION) + +$(DIST_NAME).tar.gz: dist + +# Making a dist: +# cvs rtag libgxx-x-yy libg++ +# cvs co -r libgxx-x-yy libg++ +# Sanitize +# cd {HERE}/.. +# make -f Makefile.in libg++.tar.gz + +diststuff: info + +force: +.PHONY: $(SUBDIRS) dist diff --git a/gnu/lib/libg++/libg++/NEWS b/gnu/lib/libg++/libg++/NEWS new file mode 100644 index 00000000000..dbd578c66d5 --- /dev/null +++ b/gnu/lib/libg++/libg++/NEWS @@ -0,0 +1,560 @@ +SUMMARY OF RECENT MAJOR CHANGES to LIBG++. +(Also check ../libio/NEWS.) + +* Include the g++ FAQ. + +*** Major changes in libg++ version 2.6.2: + +* A first release of the "GNU Standard C++ Library" is in the libstdc++ +directory. Building it requires gcc-2.6.1. See ./README. This library +will contain classes and functions according to the ANSI/ISO standard. +The copyright conditions are those of libio, not those of libg++ proper. +[This was announced as being in 2.6.1, but got left out.] + +* The new libstc++ also includes a hacked-up version of the +HP's Standard Template Library. This will eventually replace the +container classes in libg++/src/gen. See ../libstdc++/stl/README. + +* Makefile support for building libg++ as a shared library. +See README.SHLIB. + +*** Major changes in libg++ version 2.6.1: + +* The Regex class no longer uses the old GNU regex functions. +Instead it uses the new GNU rx library (librx), written by Tom Lord. +(The rx library is also used in new versions of GNU sed.) +The rx library lazily constructs a deterministic finite-state +automaton, so it seldom has to do backtracking. + +*** Major changes in libg++ version 2.6: + +* There is a new set of bit*.c and bit*.h files in the src directory. +This is a preliminary version of language-independent library for +general low-level manipulation of bitstrings. The BitString class +has been (partially) re-written to use the new functions. +(What kind of copyright to use for this library has not been +decided yet. It will at least be OK to treat it as LGPL code.) + +*** Major changes in libg++ version 2.5: + +* The iostream directory is gone. It has been replaced by ../libio. +The latter is a major re-write. One major change is that libiostream.a +(which is built in ../libio) can be used independently of libg++, +which is interesting because you may find its licensing conditions +less onerous. See ../libio/README. + +Also, the guts of the code has been re-written in C instead of C++. +This is so that you can build a C stdio implementation without +a C++ compiler (as was needed before). However, this is not 100% done. + +* There is (preliminary) iostream manual (in ../libio/iostream.texi). + +* The files in libg++/g++-include are now obsolete. Instead, it +is the compiler's responsibility to generate "fixed" copies of your +existing C header files (such as /usr/include/stdio.h). These copies +(together with a g++ compiler modification) provide C++ access +to the standard C library. See the fixproto script in the gcc-2.5 +distribution. + +*** Major changes in libg++ version 2.4: + +* The configuration scheme has been largely re-vamped. +Instead of the definitions that are common to all (or many) of +the Makefiles being duplicated in each Makefile.in, they have +now been moved into a shell script libg++/config.shared, which +generates these standard definitions and rules. + +Most of libg++/tests/Makefile, which had a lot of regularity, +is now generated by the libg++/tests/Makefile.sh shell script. + +Also libg++ no longer uses configure's 'subdirs' mechanism. +Instead, it uses the 'configdirs' mechanism that most Cygnus +packages use. This means that each directory has its own +configure.in, and each directory can be independently re-configured. + +* Lots of fixes have been made so libg++ can be compiled by compilers +other than g++ (specifically cfront), though there are still lots of +warnings. You may still have to edit some Makefiles etc; this +will probably become easier in the next release. Many of the +changes involved not depending on g++ extensions. However, some changes +turned out to be that libg++ was depending on bugs in g++'s overload +resolution. These bugs in g++ are being fixed; this will cause some +difficulties for libg++. In some cases, we have decided that the +cleanest fix is removing some libg++ functionality. Specifically, +the coersions Integer::operator long and Integer::operator double +have been replaced by explicit methods Integer::as_long and +Integer::as_double. This means you may need to change your code. +Please let us know if this is problematial. + +*** Changes in libg++ version 2.3: + +* iostream classes use multiple inheritance and virtual base classes. +This is a little more complicated and slightly less efficient, +but saves a slight amount of code duplication. More importantly, +it improves compatibility with other iostream implementations. + +* A few of pseudo-template classes have been converted to use +real templates. The style used emphasizes sharing code for +multiple template instatiations at the cost of somewhat more +complex internal logic. No promise is implied about when/if +the remaining ones will be converted. Using the template classes +assumes gcc-2.3 or similar compiler. + +* Added stdiobuf class which provides a streambuf wrapper around +a stdio (FILE*). This can be useful when mixing C and C++ code. + +* streambuf sputn/sgetn virtuals have been made renamed to xsputn/xsgetn, +and sputn/sgetn addedas inline methods. This change is to be compatible +with AT&T and ANSI; it could require changes to user code if you have +written your own streambuf sub-classes. + +* New utils/c++-mode.el (for editing C++ in emacs). + +* Lots of little fixes all over. + +*** Changes in libg++ version 2.2: + +* Accurate input and output of floating-point numbers + +* 'make clean' and its variants have been made more consistent. + +* Improved portability (SVR4, NeXT, ...) + + +*** Changes in libg++ version 2.1: + +* "Class" include files in g++-include moved to src + +Those include files that are just wrappers around C header files +(e.g. signal.h) remain in g++-include, while the header files +that are specific to libg++ (or C++) have been moved to src. +If your system includes "C++-ready" C header files (as in SVR4 or +Linux), you don't need to use the wrappers in g++-include. + +* Portability + +A lot of effort has gone into making libg++ more portable. +Code that depends on internals of "traditional" implementations +had been made more portable. The 'libiberty' library is incorporated +into libg++; this supplies (if needed) many functions that may be +missing on particular hosts. + +* Auto-configuration + +New scripts automaticly figure out various properties of the +system (and compiler) you use. While these scripts are not +foolproof, the intent is that on most systems you will no longer +have to edit Makefiles or build special configuration files. + +* Iostream bug-fixes + +There have been numerous bug-fixes and enhancements in the +iostream code. Lots of rough edges in the streambuf and filebuf +classes have been fixed. + +There are still some rough edges of the protocol (as in what the +streambuf class should do, and what sub-classes such as filebuf +should handle). + +* iostream enhancements for lexing/parsing. + +You can now create a 'streammarker' object, which is a "remembered" +position is a streambuf. Later, you can backtrack to that position. +This is supposed to work, even if the streambuf is unbuffered and +otherwise unseekable, because the streambuffer never throws away +any data following an extant streammarker. This feature will be +used to build various scanning/parsing facilities (with backup). +(See iostream.texi for an example.) + +* stdio library + +Now supports all of ANSI's functionality. + +*** Changes in libg++ version 2.0: + +* iostream classes + +The major change is that input/output uses the new iostream library. +The design is based on (but not identical to) iostreams from +AT&T C++ release 2.x, and the ANSI X3J16/WG21 draft C++ standard. + +The iostream classes replace the old stream. The new +package provides some compatibility hooks. Including the +obsolete (or defining _STREAM_COMPAT) makes +more obsolete methods and features available. However, +you will probably have to change your code if you have used +any libg++-specific extensions (such as the File class). + +If you want stick with the old stream classes, change the +definition of IO_DIR in Make.defs (to old-stream). You will +also need to 'make depend' in directories that contain depend, +and then re-configure everything. Note that the old-stream +classes are *not* supported and *will* go away in a future release. + +* Use g++ version 2 features (if available) + +The main one is that an include file g++-include/FOO.h +that is a wrapper for a standard C include file will now +#include_next instead of #include "/usr/include/FOO.h". +This provides more flexibility wrt to using alternate C libraries +(such as GNU libc), but it is not without its own problems. +For example, if you compile libg++.a with a g++ that has old +incompatible g++-include files in its path, these will be +read (and then in turn read the /usr/include file). If there +are conflicts, you can remove the previously installed include files, +or try something like 'make XTRAFLAGS=-I/usr/include' (or whatever +include path gcc uses by default). + +* Major Makefile changes. +You can now 'make' from any subdirectory. + +* Use of 'configure'. + +* Copyrights changed to use the Library license version 2.0. +(Some files have not been updated yet; we'll try to finish it for 2.1.) + +* The prototype class SplayNode was put into a separate include file +(g++-include/gen/SplayNode.hP). This is to avoid duplication. +It will require you to generate the approriate SplayNode file +if you use SplayBag, SplaySet, or SplayPQ. + +* You can now use inline functions in header files without +having to use either -O or _DUSE_LIBGXX_INLINES. (The #ifdef +that depended on these has been removed, so inline functions +are inline independent of -O). + +* Numerous minor bug-fixes and enhancements. + +*** Changes in libg++-1.39.0 from libg++-1.37.0 + + * All files use the new g++ #pragma interface / #pragma implementation + convention, which minimies duplication of `outlined' inlines + and vtables. This also causes no inlines to be used at + all when not compiling with `-O', which speeds compilation + and simplifies debugging. + + * Many .h header file names had to be shortened so as to simulaneously + work with SYSV and with #pragma interface (since .h and .cc file + base names must match.) Sorry! + + * All genclass-able files have been moved to g++-include/gen. + + * various and sundry bug fixes, minor enhancements, and/or portability + improvements as described in the ChangeLog. + +*** changes from libg++-1.36.3 to libg++-1.37.0 + + * Most utility classes and functions are now in stand-alone .cc and/or .h + files. This should generate smaller exectuables, and, sometimes + faster compilation. In particular, istream.h, and ostream.h are + now separately includable. If you only need one, you don't have + to get the other. + + * The Plex classes now understand `const'. The `changes' and `changed' + member functions were removed, since it is now possible to + avoid changes in Plex structures by using const versions. + + * class RandomInteger is available, courtesy of John Reidl. + + * PlotFile3D, a 3D plot class is in libg++/etc. It will be + incorporated into libg++ proper for the next release, perhaps + with a few changes. Thanks to Tom Ngo. + + * various and sundry bug fixes, minor enhancements, and/or portability + improvements as described in the ChangeLog. + + * The file etc/HINTS is an emacs RMAIL file that contains recent + bug-lib-g++ list mail and related messages that may be useful. + + +*** changes from libg++-1.36.1 to libg++-1.36.3 + + * `Tmp' classes have been eliminated from Strings, Integers, etc. + (Via some retuning of the main classes, Tmp classes were found + to not significantly impact performance one way or the other, + so they were removed.) + + * There is now a version of malloc, directly supporting operator + new, etc. It may be faster and better suited to C++ applications + than your libc malloc. You should be able to use it unless you need + a special malloc for a distributed shared memory environment or + the like. If you can't use it, edit the appropriate flag in + the top-level Makefile. I would very much appreciate feedback + about whether this malloc makes any difference in time or space + efficiency than whatever you are now using. + + * By default, output is now line-buffered. Use the + NO_LINE_BUFFER_STREAMBUF define in the Makefile to override + + * Otherwise, the stream classes remain C++-1.2 compatible. + C++-2.0-compatible versions are still in the works. + + * various and sundry bug fixes, minor enhancements, and/or portability + improvements as described in the ChangeLog. + +*** changes from libg++-1.35.0 & 1.35.1 to 1.36.1 + + * various and sundry bug fixes, minor enhancements, and/or portability + improvements as described in the ChangeLog. + + * Most everything should now work on most SystemV machines. Let me + know if they don't. + + * genclass now allows an optional prefix to be used instead of type + name concatenation in order to help minimize filename + lengths for SYSV users. This is not a great solution, but + is A solution to filename length problems for SYSV users. + + * Some, but not all classes now behave well with respect to + the new 2.0 const specifications. Some uncertainties about + how g++ will interpret gcc-based const function qualifiers + (to indicate lack of side effects) versus C++-2.0 const member + functions has held up the conversion of some classes to use + const in either or both of these ways. + + * A version of etags suitable for use with c++ is in etc/ + (courtesy of J. Clark) + + * `graph', a unix graph(1) work-alike is in libg++/etc, courtesy + of Rich Murphey. + + * RAVLMap (Ranked AVLs) prototypes. + + * The GetOpt class & support has been moved from etc/ into libg++.a + + * Streams have been redone to be nearly 100% AT&T 1.2 compatible. + One minor possible incompatibility exists (ostream<< char) + that can be eliminated via #define NO_OUTPUT_CHAR at the + top of stream.h. This is probably necessary in order to + compile et++. See libg++.texinfo for more details. + + The new stream implementation is not particulary pretty. + Its main virtue is that it avoids some of the worst things + about both AT&T streams and old libg++ streams. A much + superior AT&T 2.0-iostream superset is in the works + for future release. + +*** changes from libg++-1.25.0 to libg++-1.32.0 + + * Nearly all data and methods previously declared as `private' + are now declared as `protected' to make subclassing from + library classes easier. + + * Most classes now contain a method `OK()' that checks to + make sure that an objects internal data is in a valid state. + See the documentation for further details + + * Mosts tests in ./tests now contain various kinds of assert + statements. If tests execute without assertion failures, + and without any other errors that cause aborted execution, + you may consider them successful. The test files now include + nearly all of my internal tests, which in turn have been + made more extensive. + + * Plex classes are available. + A bit of propaganda about these: + Plexes are very attractive replacements for arrays + in many contexts. Try them! + + * `shrink' and `contains' have been added to Obstack + + * Files and streams have not yet been revamped (a complete + reworking awaits the AT&T 2.0 stream specification), but + have been adjusted to provide slightly faster IO in some + cases, and now support the use of a user-supplied string + to read or write from instead of an actual IO source. + + * Rationals are now normalized when input via `>>'. + + * atoI is fixed. + + * variable-length representations in String, Integer, etc., are + now completely different. See the documentation for details. + + * New String functions: + * readline -- read in a line from an istream as a String + * prepend -- prepend stuff to a String + * through -- make a SubString from beginning to match point + * from -- make a SubString from match point to end + * s[i] -- now returns the char by reference + + * BitVec's are no longer supported, since their capabilities + are now incorporated in the revised BitString class. + + * stdarg.h and regex.h are revised to support the Sun4 + + * Several interesting and/or useful examples of libg++ + class use are in ./etc, mainly courtesy of Doug Schmidt. + + * .cc file names are now all less than 15 characters. Some + .h file names are longer, but this should not present + problems on SYSV systems. + + * pseudo-generic `proto' classes have been thoroughly revised: + * The prototype file names now end in `P', not `.proto' + and are in the g++-include directory + * A single, simple-to-use collection traversal mechanism + via pseudo-indices (`Pix') is used instead of particular + traversal friend classes. + * `Bag' prototypes are included + * Base classes are now supplied, so that all implementations + of Sets, Bags, are derived, allowing programmers to + mix and match implementations. + * They are now simpler to create: all comparison operators + and the like are now defined as macros in a `defs' file + which uses some reasonable defaults. + * The `Dictionary' versions of Set prototypes are not now + supported. Revised versions of such classes are forthcoming. + * Class prototypes previously labelled as `Assoc' are now + called `Maps', with slightly different capabilities. + + * Splay tree prototypes are available. + A bit more propaganda: Consider using Splay tree + based containers (Set, Bag, Map, PQ). They are often + the most efficient structures when performing mixtures + of operations (adds, deletes, searches...) + + * Fixed precision reals are available, courtesy of Kurt Baudendistel + + * An ordered hash Set prototype (VOHSet) is available, + courtesy of Doug Schmidt. + + * MLCG now allows access and modifications to the seeds. + + * The Normal random generator is fixed. + + * SampleStatistic now allows any prob value for confidence + intervals. + + * some simple timer routines are in builtin.cc, courtesy of Doug Schmidt + + * While the Vec class prototypes are still available, they are + currently undergoing revision in order to correspond to + the forthcoming Matrix package (which should be available + in the next libg++ release). + + * A C++ version of GPERF, a perfect hash function generator + program is also available in ./etc, courtesy of Doug Schmidt. + + +*** changes from libg++-1.22.2 to libg++-1.25.0 + + * All reported errors from the previous release are fixed, and many + suggested modifications have been performed. Thanks to all who + have sent bug reports and comments, including those with mail + addresses that I have not been able to reply to. (My mail connections + are sometimes more than a little fragile. If you send me mail and + I have not replied within a few days, you may want to try again. Sorry.) + + * A serious problem in the use of Obstacks by conversion functions + has been repaired. + + * A bug in maintaining reference counts on `find' and related operations + in List prototype classes has been fixed. + + * Strings now support self case manipulation in addition to the + functional versions. + + * Some new functions have been added to builtin.[h.cc]. All are now + documented in libg++.texinfo + + * Overload declarations are now performed in std.h and math.h, + rather than builtin.h, to eliminate some include file ordering + problems. + + * Random, RNG, and SampleStatistic classes are available, + thanks to Dirk Grunwald. + + * A BitVec class is available. + + * The are many new generic container class prototype files. These + support container classes based on elementary data structures + (and a couple of non-elementary ones). Please read the documentation. + + * Class prototype OSet has been modified and renamed OLSet. + + * The genclass utility has been modified + +*** changes from libg++-1.22.1 to 1.22.2 + + * Tests files are now in a separate directory. + + * Several minor errors (Complex unary -, several BitString functions) + have been repaired. + + * pow(0,0) returns 1 for all versions of pow. + + * An experimental generic class prototyping feature is provided, + including prototypes for lisp-style lists and ordered list-based sets. + + * several include files with the same names as those in AT&T CC + are provided. These simply #include other files. OOPS should now + compile using only g++-include files. See, however, the note + about struct exception in file math.h + + * Some rearrangement of files containing char* conversion has been + done to eliminate linking of unnecessary classes. + + * The inline-only-when-optimizing feature is still not supported. + +* New Random number generator classes are not yet available. Stubs for + these files are in this directory. They should be available for next + release. + +*** changes from libg++-1.21.1 to 1.22.0 + + * All documentation is in a stand-alone texinfo file, libg++.texinfo, + and is on its way to becoming a decent piece of documentation. + + * All reported errors from the previous release are fixed, and many + suggested modifications have been performed. Thanks to all who + have sent bug reports and comments, including those with mail + addresses that I have not been able to reply to. (My mail connections + are sometimes more than a little fragile. If you send me mail and + I have not replied within a few days, you may want to try again. Sorry.) + + * New Complex, BitSet, and BitString classes are available. You will + be performing a valuable service if you try these out and report + back any bugs/comments/suggestions about these or any other classes. + + * File `values.h' has been added. This contains various system + constants like the number of bits per long, etc. It contains + much of the same information as sun , although a + few names and things differ slightly. + + * Files `builtin.h', `builtin.cc', and `convert.cc' have been added. + `builtin' contains common inline and non-inline functions on + builtin types (like `abs'). `convert' contains code for performing + IO and char* conversions, mainly via Obstacks. Most of these + functions are not new -- they have been collected from other .h + and .cc files. + + * Files `std.h' and `math.h' now declare all libc.a C functions + in a way that allows any of them to be overloaded in C++. + + * Strings and Integers now perform expansion via realloc() -- + see libconfig.h about whether you should #define SHOULD_FREE_TO_REALLOC. + + * `eatwhite' is supported for istreams. + + * File::getline(String, ...) and get(String) have been removed in order to + maintain greater independence of different classes. + + * Strings now provide substring matching via new versions of + `contains' and `matches', `common_prefix' and `common_suffix'. + Also, there is more support for case operations via `fcompare', etc. + The versions of `decompose' that do not deal with Regexes have + been deleted since they provide little functionality over other + operations. Also, a few special case functions dealing with char*'s + have been deleted since the required constructors are necessary + anyway. Several other corrections have been made in String.cc, + including the elimination of a few aliasing problems. + + * The implementations of Integers and Rationals are now both much + more efficient and well-tested, while remaining machine independent. + A few minor visible features have been added and/or changed. + + * The `box' command in PlotFile is now simulated, whether or not + it is present in libplot.a + + * The inlining-only-if-optimizing feature is still not fully implemented. diff --git a/gnu/lib/libg++/libg++/README b/gnu/lib/libg++/libg++/README new file mode 100644 index 00000000000..d99d7a49353 --- /dev/null +++ b/gnu/lib/libg++/libg++/README @@ -0,0 +1,248 @@ +This is version 2.7.1 of libg++, the GNU C++ class library. +Release date November 1995 by Cygnus Support + +* Please skim through this once BEFORE attempting to make and install libg++. + +* You probably want to at least skim ./g++FAQ.txt. + +* Contents + + * g++ source files (with their include files) are in the ./src directory + * Some simple tests and demo programs are in ./tests + * documentation is in ./libg++.texi. + * A perfect hash function generator is in ./gperf. + * Some miscellaneous files of possible interest are in ./etc + (These files are not officially a part of the libg++ distribution, + and are subject to arbitrary changes, deletions, etc. from release + to release.) + +* Copyright restrictions + +The GNU Library General Public License (which is in the file +../COPYING.LIB) covers all libraries (specificly libg++.a) and +include files that get installed (by 'make install'). + +Other parts of the libg++ *distribution* that are not part the libg++ +*library* per se have the GNU General Public License (which is in the +file ../COPYING). + +Individual files should bear the appropriate Copyright (let us know +if you think there is a mistake). But specificly, if your application +only uses files that are installed by the normal build+install +procedure, then it is bound by the restrictions of the GNU Library +General Public License, but not those of the GNU General Public License. + +* Pre-installation + + * This version of libg++ requires gcc-2.7.0 or newer. + It assume that gcc is responsible for fixing standard C include + files (such as stdio.h) so that they are suitable for C++ + (Using the fixproto script that is part of gcc). + + * You can compile libg++ using a gcc that you haven't installed. + The most convenient way to do that is to make a symlink named + gcc in the top-level directory (i.e. libg++-2.7.1) that points to + the directory containing the new gcc. (You should end up with + libg++/../gcc/xgcc being a valid filename for the uninstalled gcc.) + + * With only trivial modifications (like changing file extensions, + etc.) most things should compile and run with any modern C++ compiler. + However, notice that libg++ may depend on recent (ANSI/ISO) changes + to C++. If libg++ depends on a g++ feature that is not specified + by the C++ draft standard *or* if there is a simple and clean + work-around that would make it more portable, please let me know. + +* Installation (see libg++.texi for more details) + + * For VMS, cd to ./vms, and read AAAREADME.TXT + [NOTE: The VMS support is obsolete. We need a volunteer to fix it.] + + * For Linux, things are complicated because the Linux C library is + based on ../libio. Unfortunately, there is no publicly available + version of libc that will work with this release of libg++ and libio. + To use libg++ 2.7.x, you will need to get the binary release + prepared by H.J.Lu, which has not been released as this was written. + To get these new releases, you need to get on the Linux Gcc developer's + mailing list; send mail to linux-gcc-request@vger.rutgers.edu. + You will also need libc version 5.1 or higher (from the same place). + + * To build shared libraries, see README.SHLIB. + + * Make sure your sed is *not* GNU sed version 1.12. + Most other versions (including GNU sed 1.13) should be OK. + + * Go to the directory *above* libg++ (i.e.. libg++-2.7.1). + + * Run './configure' to configure the tree and create Makefiles. + + Typical example: + ./configure [SYSTEM] --prefix=/usr/gnu + + The prefix says that installation should be into + /usr/gnu/lib, /usr/gnu/bin, etc as appropriate. + + The SYSTEM indicates what machine configuration you're + running on. If you don't specify it, the system can usually + guess a default. + + IMPORTANT: The configure options (including SYSTEM and + --prefix) must match those used to configure gcc, otherwise + g++ may fail to find libg++. + + See etc/cfg-paper.texi for more details. (This paper is + in texinfo format; see the section below on Installing + the Documentation on how to make it more readable.) + + * Type `make all "CC=gcc -O2"'. + (Builds libg++.a and some other things.) (The "CC=gcc -O2" + is optional. It forces use of gcc to compile C programs. + Set CXX to specify the C++ compiler, though it defaults to gcc.) + + * Optionally, type `make check' to make and run some tests/demos of libg++. + + * Before installing, if you have an old version that was installed + into the same directory(s), you should probably remove it. + (There is currently no clean mechanism to do that. + You should at least remove $(prefix)/lib/g++-include/*.h, + where $(prefix) is by default /usr/local.) + + If the previous version was libg++ 2.4 or older, you *must* remove + the old includes. Prior to version 2.5, libg++ installed its own + versions of certain standard headers for use on systems where the + vendor headers don't include prototypes. Versions 2.5 and later of + gcc add prototypes to vendor headers that don't have them, so + the libg++ versions are no longer useful, and are harmful when + they conflict with the vendor version. + + * Type `make install' to install + + libg++.a (from .) + include files (from src and ../libio) + prototype files (from src/gen) + gperf (from gperf) + some other stuff + + * Install the documentation + + If you are a systems administrator installing libg++ for others, + please make the documentation available to users! + + The libg++.texi file may be formatted as a paper document by + + * Get a copy of texinfo.tex. + This file defines various tex macros used in libg++.texi + One is in the gcc release. + You can temporarily copy it into the current directory. + * Run tex on libg++.texi + and do whatever you normally do from there to print it. + + It may be made into an emacs info file: + + * use the 'makeinfo' program (from the texinfo distribution). + + * Copy these files into your emacs info directory + (normally somewhere like /usr/gnu/emacs/info). + * If you have not done so before, edit the emacs/info/dir file + to add a libg++ node, by inserting a line like + + * Libg++: (libg++). The GNU C++ Library + + to the bottom of the file. + + * (Optional) Install, from ./utils + g++dep (a version of mkdep that understands c++) + +* Notes on compiling and running libg++/tests + +tCurses is not automatically run through `checktests'. +You must run it manually: + +tCurses attempts to place one of each curses library primitive (boxes, +strings, numbers...) on your screen, and asks for some input, to test +curses input routines. Since there is no way to describe the output +in a system- and terminal- independent way, you will have to be the +judge of whether it works acceptably. + +tCurses (and the curses-based classes generally) may fail on the +Sequent and perhaps other systems with unusual or old curses library +implementations if you do not end input with a instead of +the normal . + +It is a very good idea to also cd to the test directory and run tests +manually, to see what they do. + +Compiling and running the tests consumes a fair amount of time and +disk space! + +Some reported diffs may be perfectly reasonable, owing to things like +floating point precision differences: The expected.out file was created +on a Sun4/110. + + Some tRational and tFix results depend on floating point precision + and may generate slightly different output on different machines. + + tRandom seeds some random-numbers in a way that also relies on + floating-point representations -- Your output should be numerically + similar, but probably not identical. + +* Changes since previous versions(s). + + See the file NEWS. + +* Known bugs and problems + + * If "make install" fails with the error message: + + Static constructor test failed - see libg++.README + + this indicates an error in installing gcc. + C++ needs special linker support beyond that needed for C, to make + sure that static objects get initialized and destroyed properly. + Some linkers (including the GNU linker as well as linkers for + the Elf object file format) already provide the needed support. + In other cases, gcc (or g++) uses the "collect2" linker driver. + Gcc should by default do the right thing, but if you tell + gcc to assum the GNU linker (with the --with-gnu-linker option), + and then fail to correctly install GNU ld, you will lose. + +* Lots of other information is in the libg++.texi file. It really is + very important to actually read the documentation before using + library classes. Examination of the demo files in the test directory + may also be useful. (Note however, that the demo files are merely + designed to test examples of each class capability, + and are not especially good examples of client functions that might + use these classes.) + +* There is now a gnu libg++ mailing list (bug-lib-g++@prep.ai.mit.edu) and + associated usenet gnu news group (gnu.g++.lib.bug). (It is preferred + that messages be sent to the mailing list, rather than posted to + newsgroup.) To subscribe or unsubscribe to the mailing list, + send a request to bug-lib-g++-request@prep.ai.mit.edu. + +* You will be performing a valuable service if you use libg++ + classes and report back any comments, and suggestions, or bugs, + preferably to the bug-lib-g++ list. Your feedback is extremely + helpful in efforts to make libg++ as useful and reliable as possible. + +* We continue to solicit + + * bug reports. + * suggestions. + * comments. + * questions about installing and using libg++ + * other contributions to be incorporated into libg++. + * sample programs using libg++. + + Often, the best place to send such things is bug-lib-g++@prep.ai.mit.edu, + although direct mail is also welcome. + +* Good luck! + +Doug Lea designed and implemented most of the classes, +and was the original maintainer and "owner" of libg++. +He has handed over "ownership" to Cygnus Support. + +Per Bothner of Cygnus Support is now +maintaining libg++, with much help from the rest of the +Cygnus G++ team (Jason Merrill, Mike Stump, Brendan Kehoe). +Cygnus Support, 1937 Landings Drive, Mountain View, CA 94043 diff --git a/gnu/lib/libg++/libg++/README.SHLIB b/gnu/lib/libg++/libg++/README.SHLIB new file mode 100644 index 00000000000..9836a44345c --- /dev/null +++ b/gnu/lib/libg++/libg++/README.SHLIB @@ -0,0 +1,52 @@ +NOTES ON BUILDING LIBG++ AS A SHARED LIBRARY + +A shared library version of libg++-2.7.0 can be built using gcc-2.7.0 on +the following platforms: + +Linux (using the ELF toolchain) +Sparc running SunOS 4.x +Alpha running OSF/1 +SGI running IRIX 5.x +HPPA running HPUX 9.x +All SVR4 targets (tested on Sparc Solaris and i486 UnixWare) + +To build a shared version of libg++ on one of these platforms, pass the +--enable-shared flag to configure, and be sure to compile with gcc. + +In order to run a program built with your new shared library (including +gperf and the tests), you may have to set the environment variable +LD_LIBRARY_PATH to include the directory where it lives. + +If you are using an SVR4 system other than the ones mentioned above, please +try running make check and let me (jason@cygnus.com) know whether or not it +works. + +Discussion: +---------- + +Many shared library implementations have an idiosyncracy [bug ???] which +requires anything that is declared in a shared library to be defined even +if it isn't used. CursesW.o declares functions that are defined in +libcurses (and libtermcap under SunOS). If these libraries do not exist as +shared libraries (they do under Linux, OSF/1, IRIX, they do not on the +others) and CursesW.o is incorporated into the ".so" file, these two +libraries must be added to the link statement even when the CursesWindow +class is not being used. This situation can be alleviated by not including +CursesW.o in the .so file; just edit the 'piclist' file in the libg++ build +directory, remove CursesW.o, and run 'make' again. + +Under SunOS, you can add CursesW.o to a libg++.sa.2.7 file so that it will +still be included by -lg++; on SVR4 platforms, you will have to put it in +a separate library in order to access it. + +In addition, libstdc++.so and libg++.so contain a number of classes which +use the math library. Consequently, if a shared libm does not exist (it +does under Linux, OSF/1, IRIX and Solaris, but not the others), either the +math library must to added to the link command or you must compile with a +flag that tells the linker to ignore unresolved references +(-Wl,-assert,nodefinitions for SunOS, -Wl,-z,nodefs for SVR4). + + +Jason Merrill (jason@cygnus.com) +Thanks to Dr. Joseph E. Sacco (jsacco@ssl.com) for the original version of +this note. diff --git a/gnu/lib/libg++/libg++/TODO b/gnu/lib/libg++/libg++/TODO new file mode 100644 index 00000000000..c1e12b84b1c --- /dev/null +++ b/gnu/lib/libg++/libg++/TODO @@ -0,0 +1,13 @@ +* See iostream/TODO for iostream-specific issues + +* Update README. + +* Add 'return 0' to end of tests. +[Not needed, if ANSI makes that implicit.] + +* Undo gcc-2.3.2-specific kludge in test-install/bf.cc. + +* Remove use of _libgxx_io_ob from Fix.cc. + +* Since the libg++ include files in gxx_includedir aren't architecture + dependent, they belong under $(datadir) not $(libdir). diff --git a/gnu/lib/libg++/libg++/config.shared b/gnu/lib/libg++/libg++/config.shared new file mode 100644 index 00000000000..a3b96234469 --- /dev/null +++ b/gnu/lib/libg++/libg++/config.shared @@ -0,0 +1,7 @@ +# Significant variables: + +TO_TOPDIR=${TOLIBGXX}../ +DOING_LIBGXX=true +THIS_FILE="${srcdir}/${TOLIBGXX}config.shared" + +. ${srcdir}/${TO_TOPDIR}libio/config.shared diff --git a/gnu/lib/libg++/libg++/config/aix.ml b/gnu/lib/libg++/libg++/config/aix.ml new file mode 100644 index 00000000000..0e34742a2e7 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/aix.ml @@ -0,0 +1,7 @@ +# AIX has wierd shared/non-shared libraries. + +ARLIB = libg++-ar.a +SHLINK = libg++.a +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHDEPS = ../libstdc++/libstdc++.a -lm $(SHCURSES) +SHCURSES = -lcurses diff --git a/gnu/lib/libg++/libg++/config/dec-osf.ml b/gnu/lib/libg++/libg++/config/dec-osf.ml new file mode 100644 index 00000000000..1a75e59b2b1 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/dec-osf.ml @@ -0,0 +1,2 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHCURSES = -lcurses diff --git a/gnu/lib/libg++/libg++/config/elf.ml b/gnu/lib/libg++/libg++/config/elf.ml new file mode 100644 index 00000000000..37549ffc901 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/elf.ml @@ -0,0 +1,3 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +LIBS = -L./$(TOLIBGXX) -L./$(TOLIBGXX)../libstdc++ -lg++ -lstdc++ -lm diff --git a/gnu/lib/libg++/libg++/config/elfshlibm.ml b/gnu/lib/libg++/libg++/config/elfshlibm.ml new file mode 100644 index 00000000000..0f17e311488 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/elfshlibm.ml @@ -0,0 +1,3 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +SHDEPS = -lm diff --git a/gnu/lib/libg++/libg++/config/hpux.ml b/gnu/lib/libg++/libg++/config/hpux.ml new file mode 100644 index 00000000000..c8b4fb4ceee --- /dev/null +++ b/gnu/lib/libg++/libg++/config/hpux.ml @@ -0,0 +1,4 @@ +SHLIB = libg++.sl +BUILD_LIBS = $(ARLIB) $(SHLIB) +SHFLAGS = $(PICFLAG) +SHDEPS = diff --git a/gnu/lib/libg++/libg++/config/irix5.ml b/gnu/lib/libg++/libg++/config/irix5.ml new file mode 100644 index 00000000000..1a75e59b2b1 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/irix5.ml @@ -0,0 +1,2 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHCURSES = -lcurses diff --git a/gnu/lib/libg++/libg++/config/linux.ml b/gnu/lib/libg++/libg++/config/linux.ml new file mode 100644 index 00000000000..529e82fcca4 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/linux.ml @@ -0,0 +1,8 @@ +FULL_VERSION = 27.1.0 +MAJOR_VERSION = 27 + +SHLIB = libg++.so.$(FULL_VERSION) +MSHLINK = libg++.so.$(MAJOR_VERSION) +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) $(MSHLINK) +SHFLAGS = -Wl,-soname,$(MSHLINK) +SHCURSES = -lcurses diff --git a/gnu/lib/libg++/libg++/config/linux.mt b/gnu/lib/libg++/libg++/config/linux.mt new file mode 100644 index 00000000000..decadcec79b --- /dev/null +++ b/gnu/lib/libg++/libg++/config/linux.mt @@ -0,0 +1,12 @@ +# Needs some work. + +# Linux puts iostream in libc.a. +STREAM_OBJS = +REGEX_OBJ= +# IO_DIR=no-stream might be the right thing for Linux, but you need +# to re-run gendepend in libg++/utils first. There is also the problem +# that -nostdinc++ won't pick up the iostream include files ... +# IO_DIR=no-stream +G_CONFIG_ARGS = CONFIG_NM="nm -d" +# Don't include iostream files in libg++.a. +IO_OBJECTS_TO_GET = diff --git a/gnu/lib/libg++/libg++/config/sol2shm.ml b/gnu/lib/libg++/libg++/config/sol2shm.ml new file mode 100644 index 00000000000..0f17e311488 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/sol2shm.ml @@ -0,0 +1,3 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +SHDEPS = -lm diff --git a/gnu/lib/libg++/libg++/config/solaris2.mt b/gnu/lib/libg++/libg++/config/solaris2.mt new file mode 100644 index 00000000000..40030020773 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/solaris2.mt @@ -0,0 +1 @@ +RANLIB = true diff --git a/gnu/lib/libg++/libg++/config/sunos4.ml b/gnu/lib/libg++/libg++/config/sunos4.ml new file mode 100644 index 00000000000..6f9d154d473 --- /dev/null +++ b/gnu/lib/libg++/libg++/config/sunos4.ml @@ -0,0 +1,4 @@ +BUILD_LIBS = $(ARLIB) $(SHLIB) +LIBS = -L./$(TOLIBGXX) -L./$(TOLIBGXX)../libstdc++ -lg++ -lstdc++ -lm +SHFLAGS = $(PICFLAG) +SHDEPS = diff --git a/gnu/lib/libg++/libg++/configure.in b/gnu/lib/libg++/libg++/configure.in new file mode 100644 index 00000000000..156c6867c98 --- /dev/null +++ b/gnu/lib/libg++/libg++/configure.in @@ -0,0 +1,170 @@ +# 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. + +# We need multilib support. +. ${srcdir}/../cfg-ml-com.in + +configdirs="genclass no-stream old-stream src tests gperf utils etc test-install" +srctrigger=libg++.texi +srcname="GNU C++ Class Library" + +# per-host: + +# per-target: + +package_makefile_frag=Make.pack + + echo "# Warning this fragment is automatically generated" >temp.mt + rootme=`pwd` + export rootme +# CC=${CC-`if [ -f ${rootme}/../gcc/xgcc ] ; \ +# then echo ${rootme}/../gcc/xgcc -B${rootme}/../gcc/ ; \ +# else echo gcc ; fi`} + CONFIG_NM=${CONFIG_NM-nm} + + # The Bourne shell writes "command not found" to /dev/tty, so if we get + # a usage message on stderr, we have the program. + # + # ksh and zsh write "command not found" to stderr, but test -n does not + # want any output if there is no program. So we use the `type' builtin + # instead for them (and bash). + if test "$RANDOM" = "$RANDOM"; then + checkfor='test -n "`$checkprog $checkargs 2>&1`"' + else + checkfor='type $checkprog >/dev/null' + fi + + echo checking for ranlib + checkprog=ranlib checkargs=/dev/null + if [ -n "$RANLIB" ] ; then + echo "RANLIB = ${RANLIB}" >>temp.mt + elif (eval $checkfor) >/dev/null 2>&1 ; then + # Use default value set in Makefile + echo "# RANLIB = ranlib" >>temp.mt + else + echo "RANLIB = true" >>temp.mt + fi + + # Check if we have reasonable include files: +#cat >temp.c <<'EOF' +##include +##include +##include +##include +##include +#int call() { return 0; } +#int main() +#{ +# call(fclose); +# call(rename); +# return call(memcmp); +#} +#EOF +# if [ -s "`${CC} -o temp temp.c 2>&1`" ] ; then true +# else +# # Include files look tolerable +# echo 'WRAP_C_INCLUDES =' >>temp.mt +# fi + + # Some recent systems wrap extern "C" around function declarations + # in the system C header files. Unfortunately, some systems + # (such as Irix) miss the extern "C" in curses.h, say, + # though they have it in *most* of the header files, + # so it is hard to test for this automatically. +# echo "(checking if C include files have 'extern" '"C"'"')" +# echo '#include ' >temp.c +# if ${CC} -E -D__cplusplus temp.c | grep 'extern "C"' 2>&1 >/dev/null ; then +# echo 'WRAP_C_INCLUDES =' >>temp.mt +# else + + echo ' +# If the C include files are C++-ready (with extern "C"), uncomment next line: +# WRAP_C_INCLUDES =' >>temp.mt + +echo ' +# Flags to pass to gen-params when building _G_config.h. +# For example: G_CONFIG_ARGS = size_t="unsigned long" +G_CONFIG_ARGS =' >>temp.mt + +rm -f temp.c temp.o temp + +frags= +case "${target}" in + i[345]86-*-linux*) my_target=linux ;; + *-*-solaris) my_target=solaris2 ;; + *-*-*) my_target=${target_cpu} +esac + +# If they didn't specify --enable-shared, don't generate shared libs. +if [ "${enable_shared}" = "yes" ]; then + case "${target}" in + hppa*-*-*) frags=../../config/mh-papic ;; + i[345]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" ;; + *-*-irix5*) frags="${frags} irix5.ml" ;; + *-*-linux*aout*) ;; + *-*-linux*) frags="${frags} linux.ml" ;; + *-*-sysv4*) frags="${frags} elf.ml" ;; + *-*-solaris2*) frags="${frags} sol2shm.ml" ;; + *-*-solaris*) frags="${frags} elfshlibm.ml" ;; + *-*-sunos4*) frags="${frags} sunos4.ml" ;; + *-*-aix*) frags="${frags} aix.ml" ;; + esac +fi + +for frag in ${my_target}.mt ${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 + +TOLIBGXX= +ALL='libs rest-in-parallel' +MOSTLYCLEAN='*.o pic stamp-picdir piclist core \#* temp.c dummy.out dummy.[Cc] TMP a.out list' +CLEAN='.stmp-* _G_config.h $(BUILD_LIBS)' +DISTCLEAN='config.status Makefile target-mkfrag' +INFO_FILES=libg++ +INFO_SUBDIRS='$(SUBDIRS)' + +# If cross-compiling, don't configure gperf or test-install, since +# they do not work (gperf and utils will get built by the target +# compiler, which is confusing, and test-install will try to execute +# programs built by the target compiler, which can not be done). +if [ ${host} != ${target} ] ; then + configdirs=`echo ${configdirs} | sed -e 's/gperf//' -e 's/test-install//' -e 's/utils//'` +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 [ ${host} != ${target} ] ; then + sed \ + -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ + -e 's|GPERF.*=.*gperf|GPERF = # gperf|' \ + -e 's|TEST_INSTALL[ ]*=.*$|TEST_INSTALL = |' \ + -e 's|UTILS[ ]*=.*$|UTILS =|' \ + -e 's|LIBIBERTY =.*$|LIBIBERTY = xiberty|' \ + Makefile >Makefile.tem + mv -f Makefile.tem Makefile +fi + +rm -f ${package_makefile_frag} + +# We need multilib support. +. ${srcdir}/../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/Makefile.in b/gnu/lib/libg++/libg++/etc/ADT-examples/Makefile.in new file mode 100644 index 00000000000..763bd00ea24 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/Makefile.in @@ -0,0 +1,47 @@ +# A makefile for the stuff now in libg++/etc/ADT-examples + +srcdir = . + +TEST_PROGS = generic-q search keyhash tsort tsortinp genkey patricia kmp + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +check: $(TEST_PROGS) + -./generic-q < $(srcdir)/generic-q.cc + -./tsortinp 20 | ./tsort + -./keyhash < $(srcdir)/keyhash.cc + -./search 1000 + -./genkey 1000 200 > input + -./patricia ./input ./input | grep -v "is found" + +# -./dhrystone + +run_tests: check + +generic-q: generic-q.o + $(CXX) generic-q.o -o $@ $(LIBS) + +tsort: tsortinp tsort.o + $(CXX) tsort.o -o $@ $(LIBS) + +tsortinp: tsortinp.o + $(CXX) tsortinp.o -o $@ $(LIBS) + +keyhash: keyhash.o + $(CXX) keyhash.o -o $@ $(LIBS) + +search: search.o + $(CXX) search.o -o $@ $(LIBS) + +genkey: genPatkey.o + $(CXX) genPatkey.o -o $@ $(LIBS) + +Patricia.o: $(srcdir)/Patricia.h +Patmain.o: $(srcdir)/Patricia.h + +patricia: Patmain.o Patricia.o + $(CXX) Patmain.o Patricia.o -o $@ $(LIBS) + +kmp: kmp.o + $(CXX) kmp.o -o $@ $(LIBS) diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/Patmain.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/Patmain.cc new file mode 100644 index 00000000000..0313876942d --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/Patmain.cc @@ -0,0 +1,53 @@ +// Tests the Patricia tree + +#include +#include +#include +#include "Patricia.h" +#include + +const int MAX_KEY_LEN = 1000; + +main (int argc, char *argv[]) +{ + if (argc != 3) + { + cerr << "usage: " << argv [0] << " file1 file2\n"; + return 1; + } + else + { + if (!freopen (argv [1], "r", stdin)) + { + perror (argv [0]); + return 1; + } + + Patricia_Trie trie; + char key [MAX_KEY_LEN]; + + while (gets (key)) + trie.insert (key, 0); + + fclose (stdin); + if (! freopen (argv [2], "r", stdin)) + { + perror (argv [0]); + return 1; + } + + start_timer (); + + while (gets (key)) + { + Trie_Record *t = trie.find (key); + cout << key << ": " << (! strcmp (key, t->get_key ()) ? "is found!\n" : "is not found!\n"); + } + + double Elapsed_Time = return_elapsed_time (0.0); + cout << "Time = " << Elapsed_Time << "\n"; + fclose (stdin); + return 0; + } + +} diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.cc new file mode 100644 index 00000000000..94d397aaea4 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.cc @@ -0,0 +1,202 @@ +/* Implements the PATRICIA trie abstraction. */ + +#include +#include "Patricia.h" + +const int HI_WORD = 7; /* Hi-order bit, starting count from 0 */ +const int BIT_MASK = 07; /* WORD_SHIFT low-order bits enabled */ +const int WORD_BITS = 8; /* Number of Bits in a Block */ +const int WORD_SHIFT = 3; /* i.e. lg (WORD_BITS) */ + +/* Normalizes the ith Bit representation */ +inline int get_bit (int i) { return HI_WORD - i; } + +Trie_Node::Trie_Node (char *k, int len, CONTENTS new_contents, int b): + branch_bit (b) +{ + trie_rec.set_contents (new_contents); + + /* Dynamically compute the length, if it's not given */ + if (!len) + len = strlen (k) + 1; + trie_rec.set_key (strcpy (new char[len], k)); +} + +/* Recursively free tree memory via modified post-order traversal */ +void +Patricia_Trie::dispose_trie (Trie_Node *root) +{ + if (root->left->branch_bit <= root->branch_bit && + root->right->branch_bit <= root->branch_bit) + ; /* do nothing! */ + else if (root->left->branch_bit <= root->branch_bit) + dispose_trie (root->right); + else if (root->right->branch_bit <= root->branch_bit) + dispose_trie (root->left); + else + { + dispose_trie (root->left); + dispose_trie (root->right); + } + delete root; +} + +/* Initializes Patricia_Trie, using dummy header. */ + +Patricia_Trie::Patricia_Trie (void) +{ + root = new Trie_Node; + root->left = root; + root->right = root; +} + +/* Frees all dynamic memory in Patricia Trie */ +Patricia_Trie::~Patricia_Trie (void) +{ + dispose_trie (root->left); + delete root; +} + +/* Attempts to locate the record associated with Key. The basic + algorithm is abstractly similar to Sedgewick's description in his + Algorithm's book. However, I've modified things to speed up the Bit + comparisons greatly, as well as to run the Branch_Bit index from + 0..whatever, since this allows arbitrarily large keys (For some + strange reason Sedgewick goes from some predefined limit, + Max_Branch_Bit, *downto* 0!!). + + Most of the contortions below help manage a Bit cache, which + reduces the total amount of work required to test the next Branch_Bit. + Empirical tests revealed that this was main bottleneck in the Find + routine. To make the algorithm work I needed to have the first Bit in + the first word always be 0. Therefore, I've ordered the bits from + high-order Bit to low-order Bit (e.g., 8 .. 1), running from word 0 + to word K. This fits intuitively with how you might draw the bits onn + paper, but *not* with how it would work if you programmed it in the + normal way (i.e., running from bit 1 to 8, from word 0 to K). At + any rate, that's what the BIT macro is for, it normalizes my abstract + concept of bit-order with the actual bit-order. */ + +Trie_Record * +Patricia_Trie::find (char *key) +{ + + Trie_Node *parent; + Trie_Node *cur = root->left; /* Root is *always* a dummy node, skip it */ + char *block = key; /* Pointer to Current Block of Bits */ + int lower = 0; + + do + { + parent = cur; + int bit = cur->branch_bit - lower; + + /* Oh well, time to refill the Bit cache! + This loop gets executed infrequently, in general */ + if (bit >= WORD_BITS) + + while (lower + WORD_BITS <= cur->branch_bit) + { + lower += WORD_BITS; + ++block; + bit -= WORD_BITS; + } + + cur = (is_bit_set (*block, get_bit (bit)) ? cur->right : cur->left); + } + while (parent->branch_bit < cur->branch_bit); + + return &cur->trie_rec; /* Let calling routine worry whether Keys matched! */ +} + +/* Inserts a new KEY and its associated CONTENTS into the trie. */ + +void +Patricia_Trie::insert (char *key, CONTENTS contents, int key_len) +{ + Trie_Node *parent; + Trie_Node *cur = root; + char *block = key; + int lower = 0; + + /* This loop is essentially the same as in the Find routine. */ + + do + { + parent = cur; + int bit = cur->branch_bit - lower; + if (bit >= WORD_BITS) + while (lower + WORD_BITS <= cur->branch_bit) + { + lower += WORD_BITS; + ++block; + bit -= WORD_BITS; + } + cur = (is_bit_set (*block, get_bit (bit)) ? cur->right : cur->left); + } + while (parent->branch_bit < cur->branch_bit); + + /* Exclude duplicates */ + if (strcmp (key, cur->trie_rec.get_key ())) + { + char *key_block = key; + char *cur_block = cur->trie_rec.get_key (); + int first_bit_diff; + + /* Find the first word where Bits differ, skip common prefixes. */ + + for (first_bit_diff = 0; + *cur_block == *key_block; + first_bit_diff += WORD_BITS) + cur_block++, key_block++; + + /* Now, find location of that Bit, xor does us a favor here. */ + + for (int bit = *cur_block ^ *key_block; + !(bit & POW2 (HI_WORD)); + bit <<= 1) + first_bit_diff++; + + /* *Not* adding at a leaf node */ + if (parent->branch_bit > first_bit_diff) + { + + /* This is almost identical to the original Find above, however, we are */ + /* guaranteed to end up at an internal node, rather than a leaf. */ + + for (cur = root, lower = 0, cur_block = key; ;) + { + parent = cur; + int bit = cur->branch_bit - lower; + + if (bit >= WORD_BITS) + + while (lower + WORD_BITS <= cur->branch_bit) + { + lower += WORD_BITS; + ++cur_block; + bit -= WORD_BITS; + } + + cur = (is_bit_set (*cur_block, get_bit (bit)) ? cur->right : cur->left); + if (cur->branch_bit >= first_bit_diff) + break; + } + } + + Trie_Node *t = new Trie_Node (key, key_len, contents, first_bit_diff); + + /* Key_Block was saved from above, this avoids some costly recomputation. */ + if (is_bit_set (*key_block, get_bit (first_bit_diff & BIT_MASK))) + t->left = cur, t->right = t; + else + t->left = t, t->right = cur; + + /* Determine whether the new node goes to the left or right of its parent */ + block = key + (parent->branch_bit >> WORD_SHIFT); + + (is_bit_set (*block, get_bit (parent->branch_bit & BIT_MASK)) + ? parent->right : parent->left) = t; + } +} + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.h b/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.h new file mode 100644 index 00000000000..2123ddbccd1 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/Patricia.h @@ -0,0 +1,67 @@ +/* Implements the PATRICIA Trie ADT. PATRICIA stands for ``Practical + Algorithm to Retrieve Information Coded in Alphanumeric.'' PATRICIA + was developed by D.R. Morrison. The current implementation is + based upon Robert Sedgewick's description in his Algorithms book. + + Includes operations for + * Initialization + * Insertion + * Retrieval */ + +/* This could change, depending on what client wants */ +typedef void *CONTENTS; + +/* Record structure that *must* be visible to clients. */ + +class Trie_Record +{ +private: + char *key; /* Only works safely and easily for char *'s */ + CONTENTS contents; /* Pointer to record Contents referenced by Key */ + +public: + char *get_key (void) { return key; } + CONTENTS get_contents (void) { return contents; } + void set_key (char *k) { key = k; } + void set_contents (CONTENTS c) { contents = c; } +}; + +/* We globalized the class because this is done by g++ 1.40 anyway and with + * 1.9? this does not work at all (one has to prefix all members of the nested + * class with the name of the enclosing class.H.S. + */ + /* Nested class definition, should be invisible to clients with new C++ + scoping rules... */ + + struct Trie_Node + { + Trie_Record trie_rec; /* Stores data in the Trie */ + int branch_bit; /* Stores index of next Bit to compare */ + Trie_Node *left; /* Pointer to left child. */ + Trie_Node *right; /* Pointer to right child. */ + + Trie_Node (char *k = "", int len = 0, CONTENTS new_contents = 0, int b = 0); + }; + +class Patricia_Trie +{ +private: + + /* Root for the entire Patricia tree, (actually a dummy header!). */ + Trie_Node *root; + + /* Recursively free tree memory via modified post-order traversal. */ + void dispose_trie (Trie_Node *root); + + /* Returns 1 if bit is set. */ + inline int is_bit_set (int block, int shift) { return (block & (1 << shift)) != 0; } + + /* Return the ith power of 2. */ + inline int POW2 (int i) { return 1 << i; } + +public: + Patricia_Trie (void); + ~Patricia_Trie (void); + Trie_Record *find (char *key); + void insert (char *key, CONTENTS contents, int key_len = 0); +}; diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/configure.in b/gnu/lib/libg++/libg++/etc/ADT-examples/configure.in new file mode 100644 index 00000000000..c0a8b9acd21 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=Patricia.h +srcname="libg++/etc/ADT-examples" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core input $(TEST_PROGS)' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/depend b/gnu/lib/libg++/libg++/etc/ADT-examples/depend new file mode 100644 index 00000000000..2820e977df3 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/depend @@ -0,0 +1,39 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +Patmain.o : Patmain.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + Patricia.h +Patricia.o : Patricia.cc \ + Patricia.h +genPatkey.o : genPatkey.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +generic-q.o : generic-q.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +keyhash.o : keyhash.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +kmp.o : kmp.cc +search.o : search.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +tsort.o : tsort.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +tsortinp.o : tsortinp.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/genPatkey.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/genPatkey.cc new file mode 100644 index 00000000000..1b8b2985a4b --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/genPatkey.cc @@ -0,0 +1,31 @@ +// Generates random character strings +#include +#include +#include +#include + +main (int argc, char *argv[]) +{ + if (argc != 3) + { + cout << "usage: " << argv [0] << " number-of-keys length-of-keys\n"; + return 1; + } + else + { + int Key_Number = atoi (argv [1]); + int Key_Length = atoi (argv [2]); + + srand (getpid()); + + for (int j = 0; j < Key_Number; j++) + { + for (int i = 0; i < Key_Length - (rand () % 20); i++) + cout << char ('!' + rand () % (1+'~'-'!')); + cout << "\n"; + } + + return 0; + } + +} diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/generic-q.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/generic-q.cc new file mode 100644 index 00000000000..d78f15f4ac9 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/generic-q.cc @@ -0,0 +1,103 @@ +// From: "Douglas C. Schmidt" +// Date: Sun, 25 Sep 88 16:19:35 -0700 + +#include +#include +#include +#include +#include + +#define queue(type) name2(type,queue) +#define list(type) name2(type,list) +#define queuedeclare(type) \ +class queue(type) { \ + struct list(type) { \ + type item; \ + list(type) *next; \ + } *head; \ + int sz; \ +public: \ + queue(type)(void) {head = 0;sz = 0;} \ + ~queue(type)(void) { \ + list(type) *temp; \ + while (head) { \ + temp = head; \ + head = head->next; \ + delete temp; \ + } \ + } \ + int empty(void) {return(!head);} \ + int size(void) {return(sz);} \ + void enqueue(type new_item); \ + type front(void) { \ + return(head->next->item); \ + } \ + type dequeue(void); \ +}; + +#define queueimplement(type) \ +type queue(type)::dequeue(void) { \ + if (!head) \ + abort(); \ + type temp = head->next->item; \ + list(type) *temp_ptr; \ + if ((temp_ptr = head->next) == head) { \ + head = 0; \ + } \ + else { \ + head->next = temp_ptr->next; \ + } \ + delete temp_ptr; \ + sz--; \ + return(temp); \ +} \ +void queue(type)::enqueue(type new_item) { \ + if (!head) { \ + head = new list(type); \ + head->item = new_item; \ + head->next = head; \ + } \ + else { \ + list(type) *temp_node = new list(type); \ + temp_node->item = new_item; \ + temp_node->next = head->next; \ + head->next = temp_node; \ + head = temp_node; \ + } \ + sz++; \ +} + + +queuedeclare(String); +queueimplement(String); +queuedeclare(double); +queueimplement(double); + +main() { + String Buf; + queue(String) Q_String; + queue(double) Q_double; + + while (cin >> Buf) { + if (Buf.matches(RXalpha)) { + Q_String.enqueue(String(Buf)); + } + else if (Buf.matches(RXdouble)) { + Q_double.enqueue(atof(Buf)); + } + } + + while (!Q_String.empty()) { + cout << "Size = " << Q_String.size() << ",Item = " + << Q_String.front() << "\n"; + void(Q_String.dequeue()); + } + + while (!Q_double.empty()) { + cout << "Size = " << Q_double.size() << ",Item = " + << Q_double.front() << "\n"; + void(Q_double.dequeue()); + } + return (0); +} + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/keyhash.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/keyhash.cc new file mode 100644 index 00000000000..e260f3f31a6 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/keyhash.cc @@ -0,0 +1,165 @@ +// Date: Tue, 20 Sep 88 01:03:21 -0700 +// From: "Douglas C. Schmidt" +// +// +// The following is an Obstack-based program, which outputs all the GCC +// reserved words in an input file redirected from cin +// In addition, I found a neat use for +// derived types by defining a word-by-word input class that is based +// upon the class Obstack. Finally, there is the added bonus of seeing +// how the O (1) time GCC perfect hash function recognizer from GCC 1.35 +// works; I've incorporated the relevant code in this short routine. +// Feel free to fold, spindle, or mutilate this code. +// + +#include +#include +#include + +#define NIL(TYPE) ((TYPE *)0) + +class Word_Read : private Obstack +{ +public: + Obstack::free; // Allow the derived type to inherit only this member function. + + // Make the default something reasonable, like 80 columns. + Word_Read (int Default_Len = 80): Obstack(Default_Len) + { + ; + } + + // A very rudimentary method for carving out the next word + // from the input. Ignores most error conditions. All non- + // words are skipped entirely. A word is defined as a + // letter, followed by a sequence of letters, digits, and/or + // underbars `_'. + + char *operator ()(int& Len) + { + char c; + + while (cin.get (c) && !(isalpha (c) || c == '_')) + ; + + do + Obstack::grow (c); + while (cin.get (c) && (isalnum (c) || c == '_')); + + Len = Obstack::size (); + return cin.good () ? (char *)Obstack::finish (0) : 0; + } + + // Make the destructor print out something useful, like + // output a diagnostic. + + ~Word_Read () + { + cout << "chunk_size = " << Obstack::chunk_size () << "\n"; + cout << "size = " << Obstack::size () << "\n"; + cout << "room = " << Obstack::room () << "\n"; + } +}; + +// Provides a nice example of the perfect hash function used to recognize +// GCC reserved words in O(1) steps. + +const int MIN_WORD_SIZE = 2; +const int MAX_WORD_SIZE = 12; +const int MIN_KEY_SIZE = 4; +const int MAX_KEY_SIZE = 64; + +class Lookup_Table +{ +private: + static int Hash_Table[]; + + static char *Reswords[]; + + // And here it is.... Very simple, guaranteed to work! + + int Hash (char *Str,int Len) + { + switch (Len) + { + default: + case 3: + Len += Hash_Table[Str[2]]; + case 2: + case 1: + return Len + Hash_Table[Str[0]]; + } + } + +public: + + // Carries out the O (1) lookup for GCC reserved words! + int operator () (char *Str,int Len); +}; + +Lookup_Table::operator () (char *Str,int Len) +{ + if (Len <= MAX_WORD_SIZE && Len >= MIN_WORD_SIZE) + { + register int Key = Hash (Str,Len); + + if (Key >= MIN_KEY_SIZE && Key <= MAX_KEY_SIZE) + if (*Reswords[Key] == *Str && !strcmp (Reswords[Key] + 1,Str + 1)) + return 1; + } + return 0; +} + +int Lookup_Table::Hash_Table[] = + { + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 1, 64, 9, 17, 15, + 28, 19, 29, 15, 64, 2, 64, 64, 25, 4, + 16, 22, 40, 64, 11, 23, 1, 1, 16, 2, + 64, 64, 8, 64, 64, 64, 64, 64, +}; + +char * Lookup_Table::Reswords[] = +{ + "", "", "", "", "if", "", "int", "", "union", "while", "__typeof", + "__inline", "__typeof__", "__inline__", "auto", "__asm", "asm", "__asm__", + "return", "__alignof", "goto", "__alignof__", "void", "__const", + "enum", "__const__", "extern", "__volatile", "char", "__volatile__", + "do", "switch", "unsigned", "inline", "register", "double", "const", + "sizeof", "static", "continue", "struct", "break", "case", "for", + "signed", "long", "else", "typeof", "typedef", "volatile", "short", + "", "", "", "", "", "float", "", "", "", "", "", "", "", "default", +}; + + +static void Store_Buf (char *Buf) +{ + cout << "Storing reserved word " << Buf << "\n"; + // Just kidding! But you get the idea.... +} + +main (int argc, char *argv[]) +{ + Word_Read Get_Next_Word; + Lookup_Table Is_Reserved_Word; + char *Buf; + int Len; + + while (Buf = Get_Next_Word (Len)) + if (Is_Reserved_Word (Buf,Len)) + Store_Buf (Buf); // Keep reserved words + else + Get_Next_Word.free (Buf); // Discard non-reserved words + + return 0; +} + + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/kmp.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/kmp.cc new file mode 100644 index 00000000000..72511573598 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/kmp.cc @@ -0,0 +1,310 @@ +//From: "Douglas C. Schmidt" +//Date: Fri, 28 Jul 89 11:47:11 -0700 + +/* Nifty little program that illustrates an implementation of the Knuth, + Morris, Pratt string matching algorithm. + + This program has a user interface similar to fgrep, i.e., when + you provide it with a fixed pattern it prints out all the lines + from the standard input (or one user-specified input file) that + contain at least one substring that matches the provided pattern. + + Relevant options are: + + -i: Ignore case when performing comparisons. + -n: Print out lines numbers along with the matching lines. + -v: Print out lines that *don't* match the pattern. + + The code below is extensively commented. If these comments + distract you, run the code through g++ -E first ;-). */ + +#include +#include +#include + +/* This array is designed for mapping upper and lower case letter + together for a case independent comparison. The mappings are + based upon the ASCII character sequences. */ +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', +}; + +/* The list of available program options. */ +enum options +{ + DEBUG, FOLD_CASE, LINE_NUMBERS, INVERSE, OPTION_SIZE +}; + +/* Vector storing the enabled options (all initially disabled). */ +char option[OPTION_SIZE]; + +/* Data and function members necessary to implement the KMP algorithm. */ +class kmp +{ +private: + +#ifdef GNUG + const int RESET_PATTERN_FLAG = -1; +#else +#define RESET_PATTERN_FLAG -1 +#endif + + int *fail_trans_table; /* Stores the generated nfa used when matching. */ + char *pattern; /* Stores the user-supplied pattern. */ + int pattern_len; /* Pattern length. */ + + void print_fail_trans_table (void); + +public: + kmp (char *pattern, int pattern_len, int debug = 0); + ~kmp () { delete fail_trans_table; } + int operator ()(char *text, int text_len); +}; + +/* Provide a debugging dump of the failure function. Nothing fancy... */ + +void +kmp::print_fail_trans_table (void) +{ + int i; + + for (i = 0; i < pattern_len; i++) + printf ("%3d,", i); + + putchar ('\n'); + + for (i = 0; i < pattern_len; i++) + printf ("%3d,", fail_trans_table [i]); + + putchar ('\n'); +} + +/* This constructor builds the transition table that encodes the failure function + automaton. The table stores the PATTERN index we go to in the event of a + mismatch with the input text string. This generation process runs in time + linear to the pattern size. + + The terms SUFFIX and PREFIX used below are defined in terms of each other. + That is, at each state of the failure function we seek to determine the largest + pattern prefix that matches with the largest suffix in the actual input text. + This information informs us how far we can legitimately shift the pattern to the + right when a mismatch occurs during the string matching process. + + Stated more formally, this means that for all i (0 <= i <= (PATTERN_LEN - 1)) + FAIL_TRANS_TABLE (i) is the largest j < i, such that PATTERN[1..j - 1] + is a suffix of PATTERN[1..i - 1] and PATTERN[i] != PATTERN[j]. */ + +kmp::kmp (char *pat, int len, int debug): + pattern (pat), fail_trans_table (new int[len]), pattern_len (len) +{ + /* Points 1 beyond the rightmost potential *suffix* in the pattern (which is + actually simulating the behavior of an actual input text string. */ + int suffix_end = 0; + + /* Points 1 beyond the rightmost potential *prefix* in the pattern. */ + int prefix_end = fail_trans_table[suffix_end] = RESET_PATTERN_FLAG; + + do + { + /* This WHILE loop uses the precomputed failure function to look further + left into the pattern trying to find an index location where the pattern + prefix matches the pattern suffix. However, if/when we locate the + RESET_PATTERN_FLAG this means that we can just skip ahead to the next + character in the input text. */ + + while (prefix_end != RESET_PATTERN_FLAG + && pattern[suffix_end] != pattern[prefix_end]) + prefix_end = fail_trans_table[prefix_end]; + + /* Once SUFFIX_END and PREFIX_END are pre-incremented below we know that + the first PREFIX_END characters of PATTERN match the characters in + positions PATTERN[SUFFIX_END - PREFIX_END .. SUFFIX_END - 1], i.e., + the last PREFIX_END characters in the rightmost part of the first + SUFFIX_END - 1 characters in PATTERN. + + If the character at location PATTERN[SUFFIX_END] matches that at + PATTERN[PREFIX_END] it is silly to have the failure transition + jump to that pattern location (since it would immediately fail to + match, of course!). Instead, in that case we just ``borrow'' the + previously computed transition stored at FAIL_TRANS_TABLE[PREFIX_END] + and use it. */ + + if (pattern[++suffix_end] == pattern[++prefix_end]) + fail_trans_table[suffix_end] = fail_trans_table[prefix_end]; + else + fail_trans_table[suffix_end] = prefix_end; + } + /* Adding the extra 1 here is necessary since C strings are + indexed from 0 to pattern_len - 1... */ + + while (suffix_end + 1 < pattern_len); + + if (debug) + print_fail_trans_table (); +} + +/* Actually perform the KMP matching algorithm using the generated determinisitic + pattern matching match encoded in the failure transition table. This version + is optimized on the assumption that there will be more characters in the text + input that *don't* match the pattern than ones that do match it. Therefore, we + make a special effort to keep looping through the failure function as long as + the text and pattern don't match. */ + +int +kmp::operator ()(char *text, int text_len) +{ + int suffix_end = RESET_PATTERN_FLAG; + int prefix_end = RESET_PATTERN_FLAG; + + /* If TEXT length is shorted than PATTERN we'll bail out now... */ + if (text_len < pattern_len) + return 0; + + /* Split the following two cases so that we don't pay any + unnecessary overhead when case folding is not required. */ + if (option[FOLD_CASE]) + + /* Note how this main loop is almost identical with the + `failure transition table building' algorithm used above. */ + + do + { + /* Ignore case when matching and keep applying the failure function + until we get a match or are forced to restart the pattern (starting + with the *following* input text character, that is). */ + + while (prefix_end != RESET_PATTERN_FLAG + && charmap[text[suffix_end]] != charmap[pattern[prefix_end]]) + prefix_end = fail_trans_table[prefix_end]; + + if (prefix_end + 1 >= pattern_len) + return 1; + else + ++suffix_end, ++prefix_end; + } + + /* This conditional expression is used to terminate the search when it + becomes clear that we can't match the PATTERN since the TEXT has + fewer unexamined characters than the PATTERN length. */ + while (text_len - suffix_end >= pattern_len - prefix_end); + + else + + /* This loop is identical with the preceding one, except that we don't + bother to fold case... */ + + do + { + while (prefix_end != RESET_PATTERN_FLAG + && text[suffix_end] != pattern[prefix_end]) + prefix_end = fail_trans_table[prefix_end]; + + if (prefix_end + 1 >= pattern_len) + return 1; + else + ++suffix_end, ++prefix_end; + } + while (text_len - suffix_end >= pattern_len - prefix_end); + + return 0; +} + +/* The name sez it all! */ + +void +print_usage_and_die (char *prog_name) +{ + fprintf (stderr, "usage: %s [-inv] pattern [file]\n", prog_name); + exit (1); +} + +/* Main driver program. Emulates certain useful features of fgrep. */ + +int +main (int argc, char **argv) +{ + GetOpt getopt(argc, argv, "dinv"); + + if (argc == 1) + print_usage_and_die (argv[0]); + + /* A rather arbitrary limit... */ + const int MAX_LINE = 200; + char text[MAX_LINE]; + int c; + + /* Initialize any user-specified options. */ + + while ((c = getopt ()) != EOF) + switch (c) + { + case 'd': option[DEBUG] = 1; break; + case 'i': option[FOLD_CASE] = 1; break; + case 'n': option[LINE_NUMBERS] = 1; break; + case 'v': option[INVERSE] = 1; break; + default: print_usage_and_die (argv[0]); + } + + /* Call the constructor to build the failure function table. */ + kmp match (argv[getopt.optind], strlen (argv[getopt.optind]), option[DEBUG]); + + /* Handle a user-specified input file. */ + if (argv[++getopt.optind] && !freopen (argv[getopt.optind], "r", stdin)) + { + perror (argv[0]); return 1; + } + + /* Split the following into two separate cases to avoid overhead + when line numbers are not required. */ + if (option[LINE_NUMBERS]) + { + int line; + + for (line = 1; gets (text); line++) + if (match (text, strlen (text)) != option[INVERSE]) + printf ("%d:%s\n", line, text); + + } + else + { + + while (gets (text)) + if (match (text, strlen (text)) != option[INVERSE]) + puts (text); + + } + return 0; +} + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/search.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/search.cc new file mode 100644 index 00000000000..c0bd85fc71a --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/search.cc @@ -0,0 +1,220 @@ +// From: "Douglas C. Schmidt" +// Date: Sat, 29 Oct 88 14:11:51 -0700 + +#include +#include +#include + +/**********************************************************************/ +/**********************************************************************/ + +typedef int ITEM_TYPE; + +class Additive_Search +{ + + // Implements the binary search variation described on pages 138 and 139 + // of Tim Standish's ``Data Structure Techniques'' textbook. The big + // win here is that this version uses no division (or right shift), + // only addition, so it runs faster on most computers. + +private: + + ITEM_TYPE *Vector_Buffer; // Hold's copy of the initialized search structure + int Vector_Length; // Length of the user's input + static int Tree_Height; // Height of the implicit binary search tree + static ITEM_TYPE *Temp; // Temporary storage during initialization + + void Fill_Buffer (int h, int i); // Transforms sorted array into special + // representation that supports the + // additive binary search technique +public: + + Additive_Search (ITEM_TYPE *Array, int Len); + int Is_Member (ITEM_TYPE K); + ~Additive_Search (void); + +}; + +int Additive_Search::Tree_Height = 0; +ITEM_TYPE* Additive_Search::Temp = 0; + +/**********************************************************************/ + +void Additive_Search::Fill_Buffer (int Hgt, int Index) +{ + // Uses a very concise recursive routine to initialize the Vector_Buffer from + // the original sorted array (which must have been sorted, or else this + // *won't* work)! This magic sequence of statements transforms the original sorted + // array into an new array representing the level order traversal of a complete + // binary search tree. See Standish, page 138 for details... + + if ((Hgt <= Tree_Height) && (Index < Vector_Length)) + { + Fill_Buffer (Hgt + 1, (Index + Index) + 1); + Vector_Buffer [Index] = *Temp++; + Fill_Buffer (Hgt + 1, (Index + Index) + 2); + } + +} + +/**********************************************************************/ + +Additive_Search::Additive_Search (ITEM_TYPE *Array, int Len) +{ + Tree_Height = lg (Len); + Vector_Length = Len; + Temp = Array; + Vector_Buffer = new ITEM_TYPE [Len]; + Fill_Buffer (0, 0); // Tree_Height and Index both start off at 0 +} + +/**********************************************************************/ + +int +Additive_Search::Is_Member (ITEM_TYPE K) +{ + // Performs the additive binary search upon the initialized Vector_Buffer. + // Note that we perform no division or multiplication in this search. + // Such omissions generally yield faster running times on most machines. + + register int i = 0; + + while (i < Vector_Length) + { + register int Cmp = (Vector_Buffer [i] - K); + + if (Cmp == 0) + return 1; + else + { + i += i + 1; + if (Cmp < 0) + i++; + } + } + + return 0; +} + +/**********************************************************************/ + +Additive_Search::~Additive_Search (void) +{ + delete Vector_Buffer; +} + +/**********************************************************************/ +/**********************************************************************/ + +class Binary_Search +{ + // Performs the typical binary search algorithm. For comparison purposes only. +#define COPY(DESTTYPE,DEST,SRC,NB) {\ + register DESTTYPE a = (DEST); \ + register DESTTYPE b = (SRC);\ + register int i, j = (NB);\ + for (i = (j & 07)+1; --i;) *a++ = *b++;\ + for (i = (j>>3)+1; --i>0;) {\ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++;\ + *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++;\ +}} + +private: + ITEM_TYPE *Vector_Buffer; + int Vector_Length; + +public: + + Binary_Search (ITEM_TYPE *Array, int Len): Vector_Length (Len) + { + Vector_Buffer = new ITEM_TYPE [Len]; + + COPY (ITEM_TYPE*, Vector_Buffer, Array, Len); // The infamous Duff's Device! + } + + int Is_Member (ITEM_TYPE K) + { // Yawn, this looks familiar + register int hi; + register int lo; + + for (lo = 0, hi = Vector_Length - 1; lo <= hi ;) + { + register int mid = (lo + hi) >> 1; + + if (Vector_Buffer [mid] == K) + return 1; + else if (Vector_Buffer [mid] < K) + lo = mid + 1; + else + hi = mid - 1; + } + + return 0; + } + + ~Binary_Search (void) + { + delete Vector_Buffer; + } +}; + +/**********************************************************************/ + +static int Cmp (const void *A, const void *B) +{ // Too bad we lack lambdas! + return (*(ITEM_TYPE*)A < *(ITEM_TYPE*)B)? + -1 : + ((*(ITEM_TYPE*)A == *(ITEM_TYPE*)B) ? 0 : 1); +} + +/**********************************************************************/ + +double return_elapsed_time (double); +double start_timer (void); +void Gen_Rand (ITEM_TYPE Buf[], int Size); + +int main (int, char *argv[]) +{ + int Size = atoi (argv [1]); + int i; +#if defined (__GNUC__) && !defined (__STRICT_ANSI__) + ITEM_TYPE Buf [Size]; +#else + ITEM_TYPE *Buf = new ITEM_TYPE[Size]; +#endif + + Gen_Rand (Buf, Size); + qsort ((void *) Buf, Size, sizeof (ITEM_TYPE), Cmp); + + Additive_Search Foo (Buf, Size); + Binary_Search Bar (Buf, Size); + + start_timer (); + for (i = 0; i < Size ; i++) + if (! Bar.Is_Member (Buf [i])) + cout << "bad news, buf [" << i << "] = " << Buf [i] << "!\n"; + + double Elapsed_Time = return_elapsed_time (0.0); + cout << "Binary Time = " << Elapsed_Time << "\n"; + + start_timer (); + for (i = 0; i < Size ; i++) + if (! Foo.Is_Member (Buf [i])) + cout << "bad news, buf [" << i << "] = " << Buf [i] << "!\n"; + + Elapsed_Time = return_elapsed_time (0.0); + cout << "Additive Time = " << Elapsed_Time << "\n"; + + return 0; +} + +void Gen_Rand (ITEM_TYPE Buf[], int Size) +{ // Generates some random numbers + srand (getpid ()); + + for (int i = 0; i < Size; i++) + Buf [i] = ITEM_TYPE (rand ()); + +} + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/tsort.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/tsort.cc new file mode 100644 index 00000000000..626bc9f65a2 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/tsort.cc @@ -0,0 +1,300 @@ +/* Date: Sun, 18 Sep 88 15:57:31 -0700 + From: "Douglas C. Schmidt" + + The following tool performs topological sorting in O(n + m) average-time + (n == # of vertices, m == # of edges). + + If you happen to have Andrew Koenig's Summer USENIX '88 article on + Associative Arrays in C++ it is interesting to compare his solution to + mine. Basically, my version, which uses hashing as opposed to his AVL + trees, should be *much* faster on the average (it would be interesting + to compare the two). In fact, if you test the code below against the + standard UNIX tsort routine, you should be *amazed* at how much faster + it is (several orders of magnitude on large input files)! */ + +#include +#include +#include +#include + +/* Forward class decls. */ +class Vertex_Node; +class Assoc_Array; +class Assoc_Iter; + +/* Defines and implements the adjacency list abstraction that contains the list + of vertices that are incident to given vertex. Note that we store Vertex_Node + pointers here, rather than vertex *Names*. This allows us to find a particular + vertex in the Hash_Table in O(1) time, without having to perform the usual + hash lookup (compare this with Andrew Koenig's implementation from the Summer + USENIX '88 proceedings!) */ + +class Adjacency_Node +{ +private: + Vertex_Node *item_ptr; + Adjacency_Node *next_ptr; + +public: + + /* The constructor simply orders the adjacency list as a stack. */ + Adjacency_Node (Vertex_Node *new_item, Adjacency_Node *head): + item_ptr (new_item), next_ptr (head) {} + + Vertex_Node *item (void) + { + return item_ptr; + } + + Adjacency_Node *next (void) + { + return next_ptr; + } +}; + +/* The Hash_Table is composed of these Vertex_Nodes. Each Vertex_Node contains + an adjacency list of successor nodes, and an In_Degree count. Each operation + is extremely concise and self-explanatory, with the exception of the overloaded + ``+='' operator, which essentially means ``Add the successor node to the successor + list (OK, so this is an abuse of overloading!) */ + +class Vertex_Node +{ +friend class Assoc_Array; +friend class Assoc_Iter; + +private: + int in_degree; + String name; + Adjacency_Node *succ_list; + Vertex_Node *next; + +public: + Vertex_Node (String &item, Vertex_Node *n = 0): + in_degree (0), name (item), next (n), succ_list (0) {} + + int in_degree_count (void) + { + return in_degree; + } + + Adjacency_Node *get_succ_list (void) + { + return succ_list; + } + + Vertex_Node& operator++ (void) + { + in_degree++; + return *this; + } + + int operator-- (void) + { + return --in_degree; + } + + Vertex_Node& operator+= (Vertex_Node& succ_node) + { + succ_list = new Adjacency_Node (&succ_node,succ_list); + return *this; + } + + String &item (void) + { + return name; + } + + friend ostream& operator << (ostream& stream,Vertex_Node& output) + { + return stream << output.in_degree; + } + +}; + +/* Here's the main data structure. It is simply a Hash_Table of Vertex_Nodes. + I make use of hashpjw from the libg++ builtin library. Nothing too tricky + here.... I overload the [] operator to provide the classic ``associative + array'' touch. */ + +class Assoc_Array +{ +friend class Assoc_Iter; + +private: + int total_size; + int current_size; + Vertex_Node **hash_table; + +public: + Assoc_Array (int size): total_size (size), current_size (0) + { + hash_table = new Vertex_Node *[size]; + memset (hash_table, 0, size * sizeof *hash_table); + } + + Vertex_Node& operator[](String index) + { + int location = hashpjw (index) % total_size; + Vertex_Node *head = hash_table[location]; + + if (!head) + { + current_size++; + return *(hash_table[location] = new Vertex_Node (index)); + } + else + { + + for ( ; head; head = head->next) + if (head->name == index) + return *head; + + current_size++; + return *(hash_table[location] = new Vertex_Node (index, hash_table[location])); + } + } + + int array_size (void) + { + return current_size; + } + + int max_size (void) + { + return total_size; + } +}; + +/* This is a neat class, which implements an iterator for the Hash_Table used + for the associative array. It would be faster to search the table directly, + without using an iterator, but this is a neat feature of C++ that fits too + nicely into the overall abstraction to pass up! */ + +class Assoc_Iter +{ +private: + Vertex_Node *curr; + Assoc_Array *assoc; + int curr_table_pos; + +public: + Assoc_Iter (Assoc_Array& array,int items): + assoc (&array), curr (0), curr_table_pos (items - 1) {} + + Vertex_Node *operator() (void) + { + if (curr_table_pos <= 0) /* we're at the end of the table, quit. */ + return 0; + else if (!curr) + { /* need to find a new bucket list to search. */ + + while (curr_table_pos >= 0 && !assoc->hash_table[curr_table_pos]) + curr_table_pos--; + + if (curr_table_pos < 0) + return 0; + else + curr = assoc->hash_table[curr_table_pos]; + } + + Vertex_Node *temp = curr; + if (!(curr = curr->next)) /* try to update curr for next call. */ + curr_table_pos--; + return temp; + } +}; + +/* This is a very simple stack abstraction. Doesn't perform error checking. */ + +class Node_Stack +{ +private: + int top; + int max_node_stack_size; + Vertex_Node **node_stack_items; + +public: + Node_Stack (int size): top (size), max_node_stack_size (size) + { + node_stack_items = new Vertex_Node *[size]; + } + + int empty () + { + return top >= max_node_stack_size; + } + + void push (Vertex_Node *item) + { + node_stack_items[--top] = item; + } + + Vertex_Node *pop (void) + { + return node_stack_items[top++]; + } +}; + +const int DEFAULT_SIZE = 200; +const int BUF_SIZE = 200; + +main (int argc, char **argv) +{ + Assoc_Array assoc_array (argc > 1 ? atoi (argv[1]) : DEFAULT_SIZE); + String prev; + String succ; + + /* The use of ``+='' below is rather obscure. It simply means ``prepend the + address of A[Succ] to the adjacency list of A[Prev]. See the comment in + the member definition for class Vertex_Node. Note that the ++ operator + has also been overloaded. This allows concise, extremely efficient mechanism + to enter the Prev and Succ items into the associative array. */ + + while (cin >> prev >> succ) + if (prev == succ) /* Just record existence of identical tokens. */ + assoc_array[prev]; + else + assoc_array[prev] += ++assoc_array[succ]; + + Assoc_Iter next (assoc_array, assoc_array.max_size ()); + Node_Stack stack (assoc_array.array_size ()); + Vertex_Node *node_ptr; + + /* Iterate through all the items in the associative array, performing the + typical topological sort trick of pushing all ``sources'' onto a stack. + This gives us an order of magnitude win over the standard UNIX tsort + routine, which has quadratic average time complexity (in the number of + verticies!!!!). */ + + while (node_ptr = next ()) + if (node_ptr->in_degree_count () == 0) + stack.push (node_ptr); + + /* The following code is straight-forward, but the one line with the expression + --(*List->Item ()) == 0 is rather cryptic. It is simply dereferencing a pointer + to a Vertex_Node, and then passing this by reference to the overloaded -- + operator from the Vertex_Node class (yes, it *is* easy to abuse this + technique!). */ + + int items; + for (items = 0; !stack.empty (); items++) + { + node_ptr = stack.pop (); + cout << node_ptr->item () << "\n"; + + for (Adjacency_Node *list = node_ptr->get_succ_list (); list; list = list->next ()) + if (--*list->item () == 0) + stack.push (list->item ()); + + } + + if (items != assoc_array.array_size ()) + { + cerr << argv[0] << ": error, directed graph has a cycle!\n"; + return 1; + } + else + return 0; +} + diff --git a/gnu/lib/libg++/libg++/etc/ADT-examples/tsortinp.cc b/gnu/lib/libg++/libg++/etc/ADT-examples/tsortinp.cc new file mode 100644 index 00000000000..96b7cc26a27 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ADT-examples/tsortinp.cc @@ -0,0 +1,15 @@ +// Here's a short program that generates acyclic input to test this program +// against the UNIX tsort. + +#include +#include + +main(int argc,char *argv[]) +{ + int Dimension = atoi(argv[1]); + + for (int y = 1; y < Dimension; y++) + for (int x = 0; x < y; x++) + cout << dec(y,4) << dec(x,4) << "\n"; + +} diff --git a/gnu/lib/libg++/libg++/etc/ChangeLog b/gnu/lib/libg++/libg++/etc/ChangeLog new file mode 100644 index 00000000000..ad6f51dae5d --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/ChangeLog @@ -0,0 +1,176 @@ +Thu Sep 21 20:52:22 1995 Jeff Law (law@hurl.cygnus.com) + + * fib/Makefile.in (fib): Link with -lm. + +Mon May 8 11:15:21 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * ADT-examples/Patricia.cc (Patricia_Trie::insert): Move + first_bit_diff decl out of the for loop. + * ADT-examples/tsort.cc (main): Likewise for `items'. + * ADT-examples/search.cc (main): Likewise for `i'. + * lf/entry.cc (Entry_Handler::print_entries): Likewise for `row'. + * trie-gen/trie.cc (Trie::output): Likewise for `i'. + * trie-gen/compact.cc (Compact_Matrix::output_arrays): Likewise for + `i' and `field_width'. + (Compact_Matrix::bucket_sort): Likewise for `i'. + (Compact_Matrix::first_fit_decreasing): Likewise for `col_list'. + +Sat Nov 5 19:12:25 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * PlotFile3D/Makefile.in (LIBS): Remove. + +Mon Sep 19 14:34:28 1994 Jason Merrill (jason@deneb.cygnus.com) + + * ADT-examples/generic-q.cc (queueimplement): Remove trailing \. + +Fri May 13 20:53:08 1994 Jason Merrill (jason@deneb.cygnus.com) + + * various: Make things build with gcc -ansi -pedantic-errors. + +Fri May 13 14:20:47 1994 Mike Stump (mrs@cygnus.com) + + * PlotFile3D/*: Use true and false, instead of TRUE and FALSE. + +Fri May 13 14:01:38 1994 Jason Merrill (jason@deneb.cygnus.com) + + * fib/fib.cc: Add const as necessary to make conformant. + +Thu Apr 7 22:26:48 1994 Jason Merrill (jason@deneb.cygnus.com) + + * ADT-examples/search.cc (public): Fix argtypes of Cmp function. + +Sun Feb 6 12:32:52 1994 Jason Merrill (jason@deneb.cygnus.com) + + * fib/fib.cc: Add 'inline' to some friend declarations. + + * PlotFile3D/Vec3D.h: Remove prototypes for following inline functions. + +Mon Nov 1 17:59:01 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * ADT-examples/Patmain.cc: Get declarations of start_timer and + return_elapsed_time from #include . (They're + now extern "C".) + +Sun Apr 25 20:57:05 1993 Per Bothner (bothner@cygnus.com) + + Changes (mostly from Peter Schauer) to permit compilation + using cfront 3.0 and otherwise be ARM-conforming. + * fib/fib.cc: + They work around the used gcc compiler extensions and remove two + Integer operator * ambiguities. + I first tried to rewrite all the NRV constructs to use a macro, but + the result was so ugly that I decided to use the NO_NRV approach + unconditionally. + * Plotfile3D/{PlotFile3D.cc,PlotFile3D.h,Vec3D.h,tPlotFile3D}: + These work around the used gcc compiler extensions, remove an auto + aggregate initialization and compensate for one inability of cfront + to inline. Two type mismatch errors are also fixed. + +Fri Jan 15 18:29:14 1993 Per Bothner (bothner@cygnus.com) + + * ADT-examples/{Patmain.cc, Patricia.cc, Patricia.h, keyhash.cc, + search.cc, tsort.cc}: Portability fixes (for cfront compilation) + from . + +Tue Dec 29 08:57:24 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: pass $(FLAGS_TO_PASS) to all calls to make. + +Thu Dec 3 19:23:27 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Fix distclean, realclean to not delete + Makefile before recursing. + +Tue Nov 17 22:16:37 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Include 'fib' among the other SUBDIRS. + +Thu Aug 6 14:47:09 1992 Ian Lance Taylor (ian@tweedledumber.cygnus.com) + + * benchmarks/Makefile.in: removed unused MINUS_G variable. + +Mon Jul 20 16:10:03 1992 Mike Stump (mrs@cygnus.com) + + * ADT-examples/keyhash.cc (Word_Read::operator ()): Add a cast + from void * to char * since it is not a standard conversion. + * ADT-examples/keyhash.cc (Word_Read::Word_Read): Convert old + style base initialization to new style. + +Wed Jun 17 16:40:10 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in, */Makefile.in: Fix *clean rules. + * Makefile.in: Use FLAGS_TO_PASS to pass current + flags to subdirs. + * release.log: Removed and merged with ../WHATS.NEW. + * fib/Makefile.in: Use CFLAGS instead of old MINUS_G. + * ADT-examples/{genPatkey.cc,search.cc}: Use the + more portable rand/srand instead of srandom/random + (who cares if it is less random). + +Wed Jun 3 23:26:44 1992 Per Bothner (bothner@rtl.cygnus.com) + + * benchmarks/dhrystone.cc: Clean up calls to time(): + Use (_G_time_t*) instead of (long*) for argument casts. + Also #Include instead of bad K&R-style prototype. + +Fri May 29 12:35:48 1992 Per Bothner (bothner@rtl.cygnus.com) + + * lf/Dirent.cc, lf/Dirent.h, lf/directory.cc: Simplify to + assume Posix-style direct.h. (dirent.h fixed to compensate.) + * lf/directory.cc: Do The Right thing even if no symlinks. + * lf/directory.cc: More portable: Don't depend on d_namlen. + * benchmarks/dhrystone.cc: Fix to use _G_SYSV instead of USG. + +Thu May 14 15:01:54 1992 Per Bothner (bothner@rtl.cygnus.com) + + * lf/Makefile.in: Don't have 'make check' run ./lf - + it dies on Irix. FIXME. + * benchmarks/Makefile.in: Don't have 'make check' run ./byval - + it dies on Iris and DECstation. FIXME. + +Wed May 6 22:51:11 1992 Per Bothner (bothner@rtl.cygnus.com) + + * graph/graph.cc: Use ostrstream instead of deprecated dtoa. + +Fri Apr 17 14:56:51 1992 Per Bothner (bothner@cygnus.com) + + * lf directory: Shortened all file names (entry-handler.cc + to entry.cc etc), as a gradual migrartion to handle SYSV and DOS. + * Makefile.in, */Makefile.in: Common changes (see ../ChangeLog). + +Tue Mar 3 11:34:21 1992 Heinrich G. Seidl (hgs@rtl.cygnus.com) + + * Removed `rem-blank.awk' (now done in ../Make.defs with sed) + moved `etags.c', `c++-mode.el' and `g++dep.sh' into ../utils + moved `fib.cc' into `fib' (updated Makefile and Sanitize ...) + +Sun Mar 1 17:01:39 1992 Per Bothner (bothner@cygnus.com) + + * PlotFile3D/PlotFile3D.{h,cc}: Change error method + to return void, not volatile void. + * benchmarks/dhrystone.cc: Lexical fix to avoid warning. + * Makefile.in: Add 'check' rule. + Avoid duplicate work sub-directory scan for 'realclean'. + * {ADT-examples,PlotFile3D,benchmarks,graph,lf}/Makefile.in: + Add 'check' rule, following updates standards.text. + * graph/Makefile.in: Add stuff to 'clean' rule. + +Thu Feb 27 16:28:08 1992 Per Bothner (bothner@cygnus.com) + + * lf/Dirent.h: Fix prototypes for FOO_Dirent_error_handler. + +Mon Feb 3 15:04:05 1992 Per Bothner (bothner at cygnus.com) + + * PlotFile3 directory: Converted to use iostream functionality. + +Sun Feb 2 13:12:16 1992 Per Bothner (bothner at cygnus.com) + + * fib.cc: Add #include . + +Sun Jan 26 19:10:21 1992 Per Bothner (bothner at cygnus.com) + + * ADT-examples/{Patmain.cc,search.cc,tsort.cc}: + Add #includes that are needed due to reorganization. + * graph/{Makefile.in,configure.in, depend}: Use depend + rule in ../../Make.defs to generate separate depend file. + * trie/gen/main.cc (main): Use iostream package. diff --git a/gnu/lib/libg++/libg++/etc/HINTS b/gnu/lib/libg++/libg++/etc/HINTS new file mode 100644 index 00000000000..9e99636dc5c --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/HINTS @@ -0,0 +1,668 @@ +BABYL OPTIONS: +Version: 5 +Labels: +Note: This is the header of an rmail file. +Note: If you are seeing it in rmail, +Note: it means the file has no messages in it. + +1,, +Return-Path: +Received: from oswego.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0) + id AA08377; Sun, 11 Feb 90 21:33:40 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.21) + id AA00896; Sun, 11 Feb 90 21:33:18 EST +Received: from raid8.cs.purdue.edu by arthur.cs.purdue.edu (5.61/PURDUE_CS-1.2) + id ; Sun, 11 Feb 90 21:30:14 -0500 +Received: from localhost by raid8.cs.purdue.edu (5.61/PURDUE_CS-1.2) + id ; Sun, 11 Feb 90 21:30:08 -0500 +Message-Id: <9002120230.AA19140@raid8.cs.purdue.edu> +To: dl@oswego.oswego.edu +Subject: kudos for profiling and libg++ +In-Reply-To: Your message of Tue, 09 Jan 90 06:27:17 -0500. + <9001091127.AA09544@g.oswego.edu> +Date: Sun, 11 Feb 90 21:30:04 EST +From: riedl@cs.purdue.edu + +*** EOOH *** +Return-Path: +To: dl@oswego.oswego.edu +Subject: kudos for profiling and libg++ +In-Reply-To: Your message of Tue, 09 Jan 90 06:27:17 -0500. + <9001091127.AA09544@g.oswego.edu> +Date: Sun, 11 Feb 90 21:30:04 EST +From: riedl@cs.purdue.edu + +I was having some trouble with the performance of a concurrency +controller I had written, and am very pleased to report that g++ +support for profiling, and the excellent libg++ data structure support +saved the day! I include a detailed description of the problem and +solution below, which you are welcome to send to any of the involved +parties for encouragement, or to publish for bragging rights (:-). + +Nice job! +John +------ +The basic problem was that two concurrency controllers that I had +written, called T/O and Lock for short, should have had similar +performance characteristics, but didn't. After some days of work it +became clear that T/O was significantly slower than Lock, for reasons +that I couldn't understand. I profiled the two routines and found the +profiles to be very similar, as expected, with the exception of a +large number of calls to compare_item in T/O: + + calls to compare_item total time +T/O 118,112 0.43 10.76 seconds +LOCK 6601*[2-3] 0.09 seconds 9.02 seconds + +(The numbers involved are small because I did the run for 100 +transactions. Real runs will be for several orders of magnitude more +transactions.) + +(I don't have an exact number for the number of calls to compare item +for Lock for obscure reasons, but my understanding of the program +makes me confident that it was called 2-3 times for each call to its +parent, which was called 6601 times.) + +The additional 1.74 seconds spent in T/O could almost all be accounted +for by calls to compare_item and its parent, SLSet::seek. Since the +data structures involved were relatively small I expected that using a +fancier data structure wouldn't help, but I thought I should test the +potential. I determined that the data structures involved would grow +to about 300 items, and that items would be accessed much more often +than they would be inserted. So I timed versions using the linked +list and using AVL trees: + +program items accesses seconds (user time) +sl-set 300 10,000 7.70 +sl-set 300 10,000 7.61 +sl-set 3000 10,000 91.35 + +avl-set 300 1,000 0.18 +avl-set 300 10,000 0.68 +avl-set 300 100,000 6.15 +avl-set 3000 10,000 1.48 + +Clearly the AVL tree implementation was far superior, even for small +problem sizes. I installed the AVL sets in T/O and they solved the +performance problem I was having. Profiling shows that before the +change: + + calls to compare_item total time +T/O 118,112 0.43 10.76 seconds +LOCK 6601*[2-3] 0.09 seconds 9.02 seconds + +After the change locking is the same, but: + +T/O 16,048 0.10 seconds 9.08 seconds + +The lessons I take from this study are: + +1) Linked lists may cause performance problems even if the lists are +relatively short (< 100 items) if they are heavily used. + +2) The C++ library can be extremely advantageous. In this case, I +made a two line change to my program to change to AVL trees. + +3) Profiling is essential to understanding program performance. + +John Riedl + + +1,, +Return-Path: +Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0) + id AA03598; Thu, 8 Feb 90 05:50:05 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.21) + id AA08592; Thu, 8 Feb 90 05:47:12 EST +Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC) + id AA07649; Thu, 8 Feb 90 05:44:40 -0500 +Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA29896; Thu, 8 Feb 90 05:46:04 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.21) + id AA27161; Thu, 8 Feb 90 05:48:41 EST +Received: by g.oswego.edu (4.0/SMI-4.0) + id AA03595; Thu, 8 Feb 90 05:48:50 EST +Date: Thu, 8 Feb 90 05:48:50 EST +From: dl@g.oswego.edu (Doug Lea) +Message-Id: <9002081048.AA03595@g.oswego.edu> +To: jose@csserver.cs.msstate.edu +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Jose Cordova's message of Wed, 7 Feb 90 17:28:57 CST <9002072328.AA07167@CSServer.CS.MsState.Edu> +Subject: Run-time error when using 'get' with an istream object +Reply-To: dl@oswego.oswego.edu + +*** EOOH *** +Return-Path: +Date: Thu, 8 Feb 90 05:48:50 EST +From: dl@g.oswego.edu (Doug Lea) +To: jose@csserver.cs.msstate.edu +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Jose Cordova's message of Wed, 7 Feb 90 17:28:57 CST <9002072328.AA07167@CSServer.CS.MsState.Edu> +Subject: Run-time error when using 'get' with an istream object +Reply-To: dl@oswego.oswego.edu + + +> I am having trouble using the 'get' method for the 'istream' class. +> It generates a 'Segmentation fault' error at run-time. I know the +> 'istream' is being opened correctly because reading into a 'String' +> object with >> works fine. Am I doing something wrong ? +> The sample program and "data" illustrate the point: +> +> main() +> { +> istream from("data",io_readonly,a_useonly); +> char *line; +> +> from.get(line,15); +> cout << line; +> } +> +> Sample "data" file contents: +> word1 word2 +> word3 +> + +There are 3 istream functions for reading char*'s + + istream& get (char* s, int n, char terminator = '\n'); + istream& getline(char* s, int n, char terminator = '\n'); + istream& gets (char **s, char terminator = '\n'); + +The first two *require* an allocated char* (they differ only +in how the trailing terminator is handled.) To use them, you +must supply either a char[N] or an allocated char*. +The third automatically allocates space for you, that you should +later delete. + +For example, + +main() +{ + istream from("data",io_readonly,a_useonly); + char *line = new char[16]; // enough for string + null + char line2[16]; + char* line3 = 0; // `= 0' so delete'able even if never allocated -- + // Not necessary in this example. + + from.get(line,15); + from.get(line2,15); + from.gets(&line3,15); // pass in the addr of line3 + + cout << line; + cout << line2; + cout << line3; + + delete line; + delete line3; +} + +Using the String class is a very good way to avoid dealing with these +kinds of char* allocation and semantics issues. + +-Doug + + +1, answered,, +Return-Path: +Received: from aerospace.aero.org ([130.221.192.10]) by g.oswego.edu (4.0/SMI-4.0) + id AA03846; Mon, 5 Feb 90 16:10:27 EST +Received: from antares.aero.org by aerospace.aero.org with SMTP (5.61++/6.0.GT) + id AA24377 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:58 -0800 +Posted-Date: Mon, 5 Feb 90 13:06:50 PST +Received: from merlin.aero.org by antares.aero.org (4.1/SMI-3.2-A4ant) + id AA20056 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:55 PST +Message-Id: <9002052106.AA20056@antares.aero.org> +Received: by merlin.aero.org (4.1/SMI-3.2-A4) + id AA03654 for dl@g.oswego.edu; Mon, 5 Feb 90 13:06:50 PST +Date: Mon, 5 Feb 90 13:06:50 PST +From: chowkwan@aerospace.aero.org +To: dl@g.oswego.edu +Subject: Checklist for using Map class + +*** EOOH *** +Return-Path: +Posted-Date: Mon, 5 Feb 90 13:06:50 PST +Date: Mon, 5 Feb 90 13:06:50 PST +From: chowkwan@aerospace.aero.org +To: dl@g.oswego.edu +Subject: Checklist for using Map class + + +I found your last message of Jan 20 was enough to get me +started using the Map class. I'm attaching some notes +I made in LaTeX format which are intended to get new +users off and running quickly. It's pretty much in the +form of a checklist that they can just go down and follow. +I was thinking it might be useful to you as a standard +response to inquiries for help from neophytes like myself. + + 0 cut here 0 +----------------><--------------------------------><------------------ + 0 0 + +\documentstyle{article} +\title{Implementing Table Lookup Using the GNU Library} +\begin{document} +\section{Introduction} + +This note describes how to use the GNU class library Version 1.35.0 +to create lookup tables. +The advantage of using the GNU library is that +the code to implement tables can be quickly generated. +Hopefully, the code is also more reliable than +what we could write ourselves. +In addition, the library provides four different lookup +mechanisms. It is relatively easy to ``switch engines'' +and use the fastest one for our application. + +This note augments the ``User's Guide to GNU C++ Library'' +by filling in some gaps in the manual. +Therefore, it is intended to complement, rather than +replace the original manual. +Section \ref{sec:general} describes the general procedure +for creating a lookup table. +Section \ref{sec:specific} gives a working example, in this +case the creation of a lookup table for database objects. + + +\section{Using the GNU Library to Create a Lookup Table} +\label{sec:general} + +The GNU library provides four implementations of lookup tables: +threaded AVL trees, splay trees, resizable hash tables, and +chained hash tables. +The hash table implementations provide double hashing. +The class names for these implementations are shown below +in Table \ref{tab:imp}. +All four classes are subclasses of the {\tt Map} class. \\ +Therefore, to create a lookup table, you must define a table class based +on the abstract class {\tt Map} as well as one of the subclasses. +The script {\tt genclass}, provided +with the GNU library, automates this process. + +\begin{table}[htb] +\centering +\caption{\label{tab:imp} GNU Implementations of Lookup Tables} +\begin{tabular}{||l|l||} \hline +{\bf Class Name} & {\bf Implementation Method} \\ \hline +{\tt AVLMap} & Threaded AVL trees. \\ +{\tt SplayMap} & Splay trees. \\ +{\tt VHMap} & Resizable hash tables. \\ +{\tt CHMap} & Chained hash tables. \\ \hline +\end{tabular} \\ +\end{table} + + + +A {\sl key} refers to the index for the table +and {\sl base value} refers to the basic data +stored in the table that is returned upon +a keyed lookup. +You need to define a hashing function +and an equality function for the key. +Finally, if you use pointers as your base +value you need to typedef a name for the pointer. +The steps you need to take are shown below. +In these examples, {\tt $<$K$>$} is the name +of the key class, +{\tt $<$B$>$} the name of the class for the base value, +{\tt $<$BP$>$} the name of the type pointer to base value, +and {\tt $<$M$>$} the name of one of the four {\tt Map} subclasses. \\ + +\begin{tabular}{||r|l|l||} \hline +&& {\bf Name of } \\ +{\bf Step} & {\bf Action} & {\bf Affected File} \\ \hline +1 & Create functions {\tt $<$K$>$HASH} & {\tt $<$K$>$.defs.h} \\ + & and {\tt $<$K$>$EQ}. &{\tt $<$K$>$.defs.cc } \\ \hline +2 & Define {\tt DEFAULT\_INITIAL\_CAPACITY} & {\tt $<$K$>$.defs.h} \\ \hline +3 & Create typedef {\tt $<$BP$>$}. & {\tt $<$B$>$.h} \\ + & for pointer to base class. & \\ \hline +4 & Create abstract class with & {\tt $<$K$>$.$<$BP$>$.Map.h} \\ + & {\tt genclass -2 $<$K$>$ ref $<$BP$>$ val Map}& + {\tt $<$K$>$.$<$BP$>$.Map.cc} \\ \hline +5 & Edit {\tt $<$K$>$.$<$BP$>$.Map.h} to include &{\tt $<$K$>$.$<$BP$>$.Map.h} \\ + & {\tt $<$K$>$.defs.h} and {\tt $<$B$>$.h}. & \\ \hline +6 & Create table class for specific & {\tt $<$K$>$.$<$BP$>$.$<$M$>$.h} \\ + & lookup implementation method with & {\tt $<$K$>$.$<$BP$>$.$<$M$>$.cc} \\ + & {\tt genclass -2 $<$K$>$ ref $<$BP$>$ val $<$M$>$ } & \\ \hline +\end{tabular} \\ + +The {\tt $<$K$>$} and {\tt $<$BP$>$} arguments to {\tt genclass} +can be qualified by either {\tt val} or {\tt ref} depending on +whether the reference is by value or by reference. + +\section{Example: Table Lookup Class for Database Objects} +\label{sec:specific} + +In this example, we want to refer to objects from the +user-defined class {\tt Database} by their names so +the name of the database object is the key to the table. +To accommodate the {\tt Map} class need for hashing on the key, +the name is represented by a {\tt String} and the +hash function is the library {\tt hashpjw} function +declared in {\tt builtin.h} +Thus {\tt $<$K$>$} is {\tt String}, +{\tt $<$B$>$} is {\tt Database}, and +{\tt $<$BP$>$} is {\tt Databasep}. +For this example, the lookup mechanism used is resizable +hash tables which have type {\tt VHMap} so +{\tt $<$M$>$} is {\tt VHMap}. + +\begin{enumerate} +\item The {\tt Map} classes expect to get +a function called {\tt HStringHASH} +that takes an argument of type {\tt String} +so {\tt hashpjw} was wrapped inside +{\tt HStringHASH}. +Similarly, {\tt HStringEQ} is a wrapper +for the {\tt HString} class operator $=$. +(The $=$ operator is inherited from the {\tt String} +class). +The function headers +for {\tt HStringHASH} and {\tt HStringEQ} +go into {\tt HString.defs.h} +and the function bodies into {\tt HString.defs.cc}. + + +\item {\tt DEFAULT\_INITIAL\_CAPACITY} was set to {\tt 1021} +in {\tt HString.defs.h}. You must use the identifier +{\tt DEFAULT\_INITIAL\_CAPACITY} to be consistent with +the {\tt Map} classes. + +\item Define {\tt Databasep} as a pointer to class +{\tt Database} in {\tt Database.h}. +An identifier other than {\tt Databasep} would +also be acceptable. You just can't use {\tt Database*}. + +\item {\tt genclass -2 HString ref Databasep val Map} \\ +produces {\tt HString.Databasep.Map.h} and \\ +{\tt HString.Databasep.Map.cc}. + +\item Edit {\tt HString.Databasep.Map.h} to +include {\tt HString.defs.h} and \\ {\tt Database.h}. + +\item {\tt genclass -2 HString ref Databasep val VHMap} \\ +produces {\tt HString.Databasep.VHMap.h} and \\ +{\tt HString.Databasep.VHMap.cc}. +\end{enumerate} + + +\end{document} + + + + + + +1,, +Return-Path: +Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0) + id AA26086; Sat, 3 Feb 90 07:05:17 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.19) + id AA09020; Sat, 3 Feb 90 07:04:44 EST +Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC) + id AA24615; Sat, 3 Feb 90 07:00:07 -0500 +Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA04153; Sat, 3 Feb 90 07:00:15 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.19) + id AA16111; Sat, 3 Feb 90 07:02:52 EST +Received: by g.oswego.edu (4.0/SMI-4.0) + id AA26081; Sat, 3 Feb 90 07:03:03 EST +Date: Sat, 3 Feb 90 07:03:03 EST +From: dl@g.oswego.edu (Doug Lea) +Message-Id: <9002031203.AA26081@g.oswego.edu> +To: ngo%tammy@harvard.harvard.edu +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Tom Ngo's message of Fri, 2 Feb 90 23:42:54 EST <9002030548.AA00886@life.ai.mit.edu> +Subject: Should "operator =" be made to return *this, by convention? +Reply-To: dl@oswego.oswego.edu + +*** EOOH *** +Return-Path: +Date: Sat, 3 Feb 90 07:03:03 EST +From: dl@g.oswego.edu (Doug Lea) +To: ngo%tammy@harvard.harvard.edu +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Tom Ngo's message of Fri, 2 Feb 90 23:42:54 EST <9002030548.AA00886@life.ai.mit.edu> +Subject: Should "operator =" be made to return *this, by convention? +Reply-To: dl@oswego.oswego.edu + + +> +> C programmers are accustomed to expecting = to return the value +> assigned. However, in a few classes--for example, String, Integer +> and Rational-- operator == returns void. Is there a good reason +> for this? Could they be made to return String&, Integer& and +> Rational& *this without causing problems? +> + +The reason that X= (+=, -=, etc.) and = operators return void is to +facilitate simple subclassing. While `utility' classes like String, +Integer, etc., are not designed for extensive subclassing (since no +members are virtual (which, in turn is motivated by efficiency +considerations)), it is often convenient to create simple subclasses +like class Line : public String. If you do this, then it is most +desirable that inherited operators return void. Otherwise, unexpected +type matches often occur. For example, if operator << (ostream&, +Line&) were redefined for Line, but op += were inherited from String, +and had return value String&, then + { Line l; ...; cout << (l += "\n"); } +would invoke op << (ostream&, String&), which is probably not +what anyone would have in mind. This is avoided by having String::+= +return void, making this usage illegal. + +Problems like this outweigh the syntactic convenience of supporting +multiple right-associative uses of X= and =. A good rule of thumb +about all this is that no non-virtual member functions should +ever return *this by reference. (This rule is broken in a few places +in libg++ for various reasons though.) + +-Doug + + +1,, +Return-Path: +Received: from rocky.Oswego.EDU by g.oswego.edu (4.0/SMI-4.0) + id AA00741; Thu, 18 Jan 90 06:01:53 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.18) + id AA22159; Thu, 18 Jan 90 06:02:51 EST +Received: from life.ai.mit.edu by nisc.nyser.net (5.61/2.1-NYSERNet NISC) + id AA22988; Thu, 18 Jan 90 05:56:52 -0500 +Received: from oswego.Oswego.EDU by life.ai.mit.edu (4.0/AI-4.10) id AA00267; Thu, 18 Jan 90 05:58:24 EST +Received: by oswego.Oswego.EDU (5.57/Osw4.1.18) + id AA16327; Thu, 18 Jan 90 06:01:51 EST +Received: by g.oswego.edu (4.0/SMI-4.0) + id AA00738; Thu, 18 Jan 90 06:00:57 EST +Date: Thu, 18 Jan 90 06:00:57 EST +From: dl@g.oswego.edu (Doug Lea) +Message-Id: <9001181100.AA00738@g.oswego.edu> +To: allen@sscvx1.ssc.gov +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Michael Allen's message of Wed, 17 Jan 90 14:56:32 CST <9001172056.AA01056@mdtf05.gov> +Subject: compiling libg++-1.36.3 with g++-1.36.3 on sun4 +Reply-To: dl@oswego.oswego.edu + +*** EOOH *** +Return-Path: +Date: Thu, 18 Jan 90 06:00:57 EST +From: dl@g.oswego.edu (Doug Lea) +To: allen@sscvx1.ssc.gov +Cc: bug-lib-g++@prep.ai.mit.edu +In-Reply-To: Michael Allen's message of Wed, 17 Jan 90 14:56:32 CST <9001172056.AA01056@mdtf05.gov> +Subject: compiling libg++-1.36.3 with g++-1.36.3 on sun4 +Reply-To: dl@oswego.oswego.edu + + + +> 2) several files get flagged as a warning that a volatile funtion does +> return, which appears to be false. + +Not quite false, but deserving of explanation: + +libg++ does not (yet) use the experimental g++ exception handling +facilities (they are still too new: Too many things would have to be +redone if the EH features change). So the only exception strategy is +for error traps like Integer::error() to call the function pointed to +by lib_error_handler (see builtin.h). By default, this points to +default_two_arg_error_handler, which prints a message on stderr and +aborts. But it *can* be reset to do anything at all, and need not +abort execution. On the other hand, *some* (not all) error() member +functions are used in a way that preclude any kind of sensible +continuation even if error() returns. I mark these as `volatile', +since the compiler might as well act as if they cannot return: This is +defensible in that even if (*lib_error_handler) returns, things are +going so wrong that you are no worse off if the compiler generates +(usually faster) code assuming execution aborts. The compiler +correctly warns about these. + +Again, saner strategies will be employed when the C++ exception +handling situation stabilizes. + +-Doug + + + + +1,, +Summary-line: 8-Jul rocket!dove@uunet.UU.NET #install suggestions +Received: from uunet.uu.net by g.Oswego.EDU (4.0/Osw4.1.21) + id AA03815; Sun, 8 Jul 90 13:35:21 EDT +Received: from rocket.UUCP by uunet.uu.net (5.61/1.14) with UUCP + id AA04848; Sun, 8 Jul 90 13:30:17 -0400 +Received: from peach.sanders.com by rocket.sanders.com (4.0/SMI-4.0) + id AA08275; Sun, 8 Jul 90 13:26:44 EDT +Date: Sun, 8 Jul 90 13:26:44 EDT +From: rocket!dove@uunet.UU.NET (Webster Dove) +Message-Id: <9007081726.AA08275@rocket.sanders.com> +Received: by peach.sanders.com (4.0/SMI-4.0) + id AA02268; Sun, 8 Jul 90 13:26:43 EDT +To: uunet!g.oswego.edu!dl@uunet.UU.NET +In-Reply-To: Doug Lea's message of Sun, 8 Jul 90 09:16:05 EDT <9007081316.AA03717@g> +Subject: install suggestions + +*** EOOH *** +Date: Sun, 8 Jul 90 13:26:44 EDT +From: rocket!dove@uunet.UU.NET (Webster Dove) +To: uunet!g.oswego.edu!dl@uunet.UU.NET +In-Reply-To: Doug Lea's message of Sun, 8 Jul 90 09:16:05 EDT <9007081316.AA03717@g> +Subject: install suggestions + +The following are two scripts for making relative shadow trees. The +first is adapted from X11R3 to use relative rather than absolute paths +(so the stuff can be moved without breaking). The second is written +in csh because I know that better. + +In general, I take a GNU release and expand it in a directory. Then I +create subdirectory "src" and move everything into it. I backup +src/Makefile (mv Makefile{,-dist}) and make site/arch/os specific one +src/Makefile-sun3-os4. Then I make subdirectory build-sun3-os4 (e.g. +build-sun3-os4) parallel to src, and setup the shadow tree from inside +build-sun3-os4 using "lndir ../src". + +You can just setup your distributions to start at top level with ./src/, +README, ./lndir and ./lndir_make_links. + +The one thing I would like added is that site (e.g. pathnames) and +arch/os (compiler switches) specific things be included into the +Makefile with include rather than with direct modification. With that +approach, and docs on how to write the "make.site-include" and +make.archos-include" I could much more easily upgrade to a new release +and maintain the archos distinction. + +--- /local/bin/lndir (a shell script) --- +#!/bin/sh + +# +# lndir - create shadow link tree +# + +# If your master sources are located in /usr/src/X and you would like +# your link tree to be in /usr/local/src/new-X, do the following: +# +# % mkdir /usr/local/src/new-X +# % cd /usr/local/src/new-X +# % lndir ../X +# +# NOTES +# +# 7/19/89 dove +# use for relative links. Uses aux script lndir_make_links +# + +DIRFROM=$1 + +USAGE="Usage: cd todir; $0 fromdir" + +if [ ! $# = 1 ] ; then + echo "$USAGE" + exit 1 +fi + +if [ ! -d $DIRFROM ] +then + echo "$USAGE" + exit 1 +fi + +# +# Get the relative directory names +# +DIRLIST=`(cd $DIRFROM;find . \( -type d ! -name 'RCS' \) -print)` + +start_dir=`pwd` +# +# Make sure the src and dest are not the same. +# +pwd=`pwd` +if [ `(cd $DIRFROM; pwd)` = $pwd ] +then + echo "FROM and TO are identical!" + exit 1 +fi + +# +# build the tree of directories in the destination. +# +for dir in $DIRLIST +do + if [ ! $dir = . ] + then + mkdir $dir + fi +done + +echo lndir_make_links $DIRFROM +exec lndir_make_links $DIRFROM +---- /local/bin/lndir_make_links (csh script) --- +#!/bin/csh -f -b +# +# A secondary script called from lndir that actually links the +# files from the remote directory and recurses if necessary. +# +if ( $#argv != 1 ) then + echo "$0 error: args $*" + exit 1 +endif + +set fromdir = $argv[1] + +set pwd=`pwd` +if ( x`(cd $fromdir; pwd)` == x$pwd ) then + echo "FROM and TO are identical!" + exit 1 +endif + +foreach i ( `ls $fromdir` ) + if ( -f $fromdir/$i ) ln -s $fromdir/$i . +end + +set nonomatch +set next_dirs=`glob */.` +unset nonomatch + +if ( "$next_dirs" != "*/." ) then +# echo $next_dirs + foreach i ($next_dirs) + (cd $i;lndir_make_links ../$fromdir/$i) + end +endif + + \ No newline at end of file diff --git a/gnu/lib/libg++/libg++/etc/Makefile.in b/gnu/lib/libg++/libg++/etc/Makefile.in new file mode 100644 index 00000000000..7e5e7e9b037 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/Makefile.in @@ -0,0 +1,26 @@ +# Makefile for libg++.a + +# Copyright (C) 1988, 1992 Free Software Foundation +# written by Doug Lea (dl@rocky.oswego.edu) + +# This file is part of GNU CC. + +# GNU CC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY. No author or distributor +# accepts responsibility to anyone for the consequences of using it +# or for whether it serves any particular purpose or works at all, +# unless he says so in writing. Refer to the GNU CC General Public +# License for full details. + +# Everyone is granted permission to copy, modify and redistribute +# GNU CC, but only under the conditions described in the +# GNU CC General Public License. A copy of this license is +# supposed to have been given to you along with GNU CC so you +# can know your rights and responsibilities. It should be in a +# file named COPYING. Among other things, the copyright notice +# and this notice must be preserved on all copies. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/Makefile.in b/gnu/lib/libg++/libg++/etc/PlotFile3D/Makefile.in new file mode 100644 index 00000000000..d8e5cabbc02 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/Makefile.in @@ -0,0 +1,15 @@ +# A makefile for the stuff now in libg++/etc + +srcdir = . + +DEPEND_SOURCES = $(srcdir)/*.cc + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +check: tPlotFile3D + ./tPlotFile3D + @echo use plot to look at the plot file test.pl + +tPlotFile3D: PlotFile3D.o tPlotFile3D.o + $(CXX) tPlotFile3D.o PlotFile3D.o $(LIBS) -lm -o $@ diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.cc b/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.cc new file mode 100644 index 00000000000..bdf624fe4f0 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.cc @@ -0,0 +1,501 @@ +// Source file for PlotFile3D class -*- C++ -*- +/* +Copyright (C) 1990 Free Software Foundation + written by J. Thomas Ngo, Harvard University + +This file is part of the GNU C++ Library. + +The GNU C++ Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor accepts +responsibility to anyone for the consequences of using it or for +whether it serves any particular purpose or works at all, unless he +says so in writing. Refer to the GNU General Public License for full +details. + +Everyone is granted permission to copy, modify and redistribute The +GNU C++ Library, but only under the conditions described in the GNU +General Public License. A copy of this license is supposed to have +been given to you along with The GNU C++ Library so you can know your +rights and responsibilities. It should be in a file named COPYING. +Among other things, the copyright notice and this notice must be +preserved on all copies. +*/ + +// An analog of the PlotFile class, but written for 3D graphics. In +// the initializer you specify a camera location, and decide whether +// you want stereo viewing. Most other methods are analogous to the +// unix plot(3) commands, except that they take 3D positions. + +#ifdef __GNUG__ +#pragma implementation +#endif +#include "PlotFile3D.h" + +// Error handling +void PlotFile3D::error(const char* s) const +{ + (*lib_error_handler)("PlotFile3D",s); +} + +//=========================================================================== +// Constructor +//=========================================================================== + +static void _find_basis(Vec3D& u, Vec3D& v, Vec3D& w, + const double th, const double ph) +{ + double sth = sin(th), cth = cos(th); + double sph = sin(ph), cph = cos(ph); + u = Vec3D( sph, cph, 0 ); + v = Vec3D( -sth * cph, sth * sph, cth ); + w = u ^ v; +} + +void PlotFile3D::initialize(bool st, double th, double ph) +{ + stereo = st; + ppq = 0; + valid3D = false; + if( stereo ) { + const double stereo_separation = 2.5 * M_PI / 180.0; + _find_basis( ul,vl,wl, th, ph-stereo_separation ); + _find_basis( ur,vr,wr, th, ph+stereo_separation ); + } else { + _find_basis( ul,vl,wl, th, ph ); + ur = ul; vr = vl; wr = wl; + } + undefine3D(); +} + +// destructor + +PlotFile3D::~PlotFile3D() +{ + if (ppq != 0) { delete sintab; delete costab; } +} + +//=========================================================================== +// Set plot limits via space() +//=========================================================================== + +PlotFile3D& PlotFile3D::space(const Vec3D& pt0, const Vec3D& pt1) +{ + // Set up 2D plot package + PlotFile::space(umini,vmini,umaxi,vmaxi); + + // Find 2D rectangle bounding the box specified by user + +#if defined (__GNUC__) && ! defined (__STRICT_ANSI__) + double umin = (pt0.x() * ul.x()) ? (pt0.x() * ur.x()) + >? (pt1.x() * ul.x()) >? (pt1.x() * ur.x()); + double vmin = (pt0.x() * vl.x()) ? (pt0.x() * vr.x()) + >? (pt1.x() * vl.x()) >? (pt1.x() * vr.x()); + + umin += (pt0.y() * ul.y()) ? (pt0.y() * ur.y()) + >? (pt1.y() * ul.y()) >? (pt1.y() * ur.y()); + vmin += (pt0.y() * vl.y()) ? (pt0.y() * vr.y()) + >? (pt1.y() * vl.y()) >? (pt1.y() * vr.y()); + + umin += (pt0.z() * ul.z()) ? (pt0.z() * ur.z()) + >? (pt1.z() * ul.z()) >? (pt1.z() * ur.z()); + vmin += (pt0.z() * vl.z()) ? (pt0.z() * vr.z()) + >? (pt1.z() * vl.z()) >? (pt1.z() * vr.z()); +#else + double tmin, tmax, tmp; + + tmin = tmax = pt0.x() * ul.x(); + tmp = pt0.x() * ur.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.x() * ul.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.x() * ur.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + double umin = tmin; + double umax = tmax; + + tmin = tmax = pt0.x() * vl.x(); + tmp = pt0.x() * vr.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.x() * vl.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.x() * vr.x(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + double vmin = tmin; + double vmax = tmax; + + tmin = tmax = pt0.y() * ul.y(); + tmp = pt0.y() * ur.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.y() * ul.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.y() * ur.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + umin += tmin; + umax += tmax; + + tmin = tmax = pt0.y() * vl.y(); + tmp = pt0.y() * vr.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.y() * vl.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.y() * vr.y(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + vmin += tmin; + vmax += tmax; + + tmin = tmax = pt0.z() * ul.z(); + tmp = pt0.z() * ur.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.z() * ul.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.z() * ur.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + umin += tmin; + umax += tmax; + + tmin = tmax = pt0.z() * vl.z(); + tmp = pt0.z() * vr.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.z() * vl.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + tmp = pt1.z() * vr.z(); + if (tmp < tmin) tmin = tmp; + if (tmp > tmax) tmax = tmp; + + vmin += tmin; + vmax += tmax; +#endif + + // Map this rectangle on to umini et al. using as much space as + // possible and centering. Also, if stereo was requested, split + // the window right down the middle and try to fit the picture in. + int pixwidth = umaxi - umini; + int pixheight = vmaxi - vmini; + if (stereo) pixwidth /= 2; + double uscale = pixwidth / (umax-umin); + double vscale = pixheight / (vmax-vmin); + if (uscale <= vscale) scale = uscale; + else { scale = vscale; pixwidth = int(pixwidth * vscale/uscale); } + scale *= margin; + uorig = 0.5 * (pixwidth - scale*(umin+umax)); + vorig = 0.5 * (pixheight - scale*(vmin+vmax)); + if (stereo) stereo_offset = pixwidth; + + // Set state appropriately + return home(); +} + + +//=========================================================================== +// move() and cont() are used as primitives by the other routines +//=========================================================================== + +PlotFile3D& PlotFile3D::move(const Vec3D& p) +{ + intp = p; + define3D(); + return *this; +} + + +void PlotFile3D::project(int& ui,int& vi, const Vec3D& u, const Vec3D& v, + const Vec3D& rel) const +{ + ui = int(rel * u * scale + uorig); + vi = int(rel * v * scale + vorig); +} + +static +#ifdef __GNUC__ +inline +#endif +bool _clip(int& a, const int amin, const int amax, + int& b, const int afar, const int bfar) +{ + double frac = 0; + if( a < amin ) { + if( afar <= amin ) return false; + frac = ((double)amin-a)/(afar-a); + a = amin; + } else if( a > amax ) { + if( afar >= amax ) return false; + frac = ((double)amax-a)/(afar-a); + a = amax; + } + if( frac != 0 ) b += int(frac*(bfar-b)); + return true; +} + +void PlotFile3D::line2D(int u0, int v0, int u1, int v1) +{ + // Clip against each edge in turn + if( !_clip(u0,umini,umaxi,v0,u1,v1) ) return; + if( !_clip(v0,vmini,vmaxi,u0,v1,u1) ) return; + if( !_clip(u1,umini,umaxi,v1,u0,v0) ) return; + if( !_clip(v1,vmini,vmaxi,u1,v0,u0) ) return; + + // Draw clipped segment + PlotFile::move(u0,v0); PlotFile::cont(u1,v1); +} + + +PlotFile3D& PlotFile3D::cont(const Vec3D& p) +{ + must_be_valid3D(); + int u0, v0, u1, v1; + if (stereo) { + project(u0,v0, ul,vl, intp); + project(u1,v1, ul,vl, p); + line2D(u0,v0,u1,v1); + project(u0,v0, ur,vr, intp); u0 += stereo_offset; + project(u1,v1, ur,vr, p); u1 += stereo_offset; + line2D(u0,v0,u1,v1); + } else { + project(u0,v0, ul,vl, intp); + project(u1,v1, ul,vl, p); + line2D(u0,v0,u1,v1); + } + intp = p; + return *this; +} + + +//=========================================================================== +// These last commands are generated by sequences of move() and cont() +//=========================================================================== + + +PlotFile3D& PlotFile3D::box(const Vec3D& p0, const Vec3D& p1) +{ + // The corners: + Vec3D x0y0z1 (p0.x(),p0.y(),p1.z()); + Vec3D x0y1z0 (p0.x(),p1.y(),p0.z()); + Vec3D x0y1z1 (p0.x(),p1.y(),p1.z()); + Vec3D x1y0z0 (p1.x(),p0.y(),p0.z()); + Vec3D x1y0z1 (p1.x(),p0.y(),p1.z()); + Vec3D x1y1z0 (p1.x(),p1.y(),p0.z()); + + // Bottom rectangle + move(p0); + cont(x1y0z0); + cont(x1y1z0); + cont(x0y1z0); + cont(p0); + + // One leg + cont(x0y0z1); + + // Top rectangle + cont(x1y0z1); + cont(p1); + cont(x0y1z1); + cont(x0y0z1); + + // Three other legs + line(x1y0z0, x1y0z1); + line(x1y1z0, p1); + line(x0y1z0, x0y1z1); + + // Set state + undefine3D(); + return *this; +} + + +PlotFile3D& PlotFile3D::circle(const Vec3D& center, const Vec3D& rad, + const int points_per_quadrant ) +{ + int i; + + // Build trig lookup table if necessary + + if( ppq != points_per_quadrant ) + { + if( ppq != 0 ) { delete sintab; delete costab; } + ppq = points_per_quadrant; + sintab = new double[ppq]; costab = new double[ppq]; + for( i=0; i +main() +{ + PlotFile3D foo(fopen("test.pl", "w")); + foo.space(-1000,-1000,-1000,1000,1000,1000).erase(); + + // Draw and label + foo.linemod("longdashed").box(-1000,-1000,-1500,1000,1000,0); + foo.linemod("solid").sphere(0,0,500,0,0,500,30); + foo.linemod("dotted").circle(0,0,500,0,0,800,50); + char title[] = "Test of PlotFile3D package"; + foo.home().label(title); + +} +#endif diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.h b/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.h new file mode 100644 index 00000000000..8a28aa9eaeb --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/PlotFile3D.h @@ -0,0 +1,223 @@ +// Header file for PlotFile3D class -*- C++ -*- +/* +Copyright (C) 1990 Free Software Foundation + written by J. Thomas Ngo, Harvard University + +This file is part of the GNU C++ Library. + +The GNU C++ Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor accepts +responsibility to anyone for the consequences of using it or for +whether it serves any particular purpose or works at all, unless he +says so in writing. Refer to the GNU General Public License for full +details. + +Everyone is granted permission to copy, modify and redistribute The +GNU C++ Library, but only under the conditions described in the GNU +General Public License. A copy of this license is supposed to have +been given to you along with The GNU C++ Library so you can know your +rights and responsibilities. It should be in a file named COPYING. +Among other things, the copyright notice and this notice must be +preserved on all copies. +*/ + + +#ifndef _PlotFile3D_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _PlotFile3D_h 1 + +//=========================================================================== +// Top-level declarations +//=========================================================================== + +#include +#include +#include +#include +#include "Vec3D.h" + +// constant implementation parameters + +const int umini = 0; // Plot limits to send to 2D package +const int vmini = 0; +const int umaxi = 3120; +const int vmaxi = 3120; + +const double margin = 0.9; // How much leeway to give on edge of pic + +class PlotFile3D : private PlotFile +{ +protected: + + // internal state + + Vec3D intp; // Internal idea of where cursor is in 3D + bool valid3D; // true if 3D cursor valid + + bool stereo; // true for stereo images + int stereo_offset; // Stereo separation in pixels (computed) + + Vec3D ul,vl,wl; // Basis vectors for the left or main image + Vec3D ur,vr,wr; // Basis for alternate image, if stereo + + double scale; // Amount by which to stretch u,v to fit + double uorig, vorig; // Offset for scaled u, v + + double* sintab; // tables, needed by circle, sphere + double* costab; + int ppq; // points per quadrant in current table + + // helper functions + + // project 3D into 2D + + void project(int&, int&, const Vec3D&, const Vec3D&, + const Vec3D& rel) const; + + // All clipping handled here + + void line2D(int u0, int v0, int u1, int v1); + + // Methods to handle state of 3D cursor: defined or undefined + + void define3D(); + void undefine3D(); + void must_be_valid3D(); + + void initialize(bool stereo, double th, double ph); + +public: + + PlotFile3D(bool st=false, double th=M_PI/12, double ph=M_PI/3) + : PlotFile() { initialize(st, th, ph); } + PlotFile3D(int fd, bool st=false, double th=M_PI/12,double ph=M_PI/3) + : PlotFile(fd) { initialize(st, th, ph); } + PlotFile3D(const char *name, + bool st=false, double th=M_PI/12,double ph=M_PI/3) + : PlotFile(name) { initialize(st, th, ph); } +#ifdef _OLD_STREAMS + PlotFile3D(FILE* fp, bool st=false, double th=M_PI/12,double ph=M_PI/3) + : PlotFile(fp) { initialize(st, th, ph); } +#endif + ~PlotFile3D(); + + // plot commands taking Vec3D args + + PlotFile3D& space (const Vec3D& p0, const Vec3D& p1); + + PlotFile3D& move (const Vec3D& p); + PlotFile3D& cont (const Vec3D& p); + PlotFile3D& line (const Vec3D& p0, const Vec3D& p1); + PlotFile3D& point (const Vec3D& p); + + PlotFile3D& box (const Vec3D& p0, const Vec3D& p1); + PlotFile3D& circle(const Vec3D& center, const Vec3D& radius, + const int points_per_quadrant =10 ); + + // This one has no PlotFile analog + PlotFile3D& sphere(const Vec3D& center, const Vec3D& radius, + const int points_per_quadrant =10 ); + + // versions taking raw coordinates + + PlotFile3D& space (const double x0, const double y0, const double z0, + const double x1, const double y1, const double z1); + PlotFile3D& move (const double xi, const double yi, const double zi); + PlotFile3D& cont (const double xi, const double yi, const double zi); + PlotFile3D& line (const double x0, const double y0, const double z0, + const double x1, const double y1, const double z1); + PlotFile3D& point (const double xi, const double yi, const double zi); + PlotFile3D& box (const double x0, const double y0, const double z0, + const double x1, const double y1, const double z1); + PlotFile3D& circle(const double cx, const double cy, const double cz, + const double rx, const double ry, const double rz, + const int points_per_quadrant =10 ); + PlotFile3D& sphere(const double cx, const double cy, const double cz, + const double rx, const double ry, const double rz, + const int points_per_quadrant =10 ); + + // For convenience + + PlotFile3D& home(); // Move cursor to upper left, out of the way + + // These plot commands get passed right to PlotFile + + PlotFile3D& erase(); + PlotFile3D& label(const char* s); + PlotFile3D& linemod(const char* s); + + // Error handling + void error(const char* s) const; +}; + +// Handling of valid3D + +inline void PlotFile3D::define3D() +{ + valid3D = true; +} + +inline void PlotFile3D::undefine3D() +{ + valid3D = false; +} + +inline void PlotFile3D::must_be_valid3D() +{ + assert(valid3D); +} + +// Versions of routines that take coordinates as Vec3D + +inline PlotFile3D& PlotFile3D::line(const Vec3D& p0, const Vec3D& p1) +{ + move(p0); return cont(p1); +} + +inline PlotFile3D& PlotFile3D::point(const Vec3D& p) +{ + return line(p, p); +} + +// Versions of routines that take coordinates as doubles + +inline PlotFile3D& PlotFile3D::line(const double x0, const double y0, + const double z0, + const double x1, const double y1, + const double z1) +{ + Vec3D p0(x0, y0, z0); + Vec3D p1(x1, y1, z1); + move(p0); + return cont(p1); +} + +inline PlotFile3D& PlotFile3D::point(const double xi, const double yi, + const double zi) +{ + Vec3D p(xi, yi, zi); + return line(p, p); +} + +// Versions of routines that take no coordinates + +inline PlotFile3D& PlotFile3D::erase() +{ + PlotFile::erase(); return home(); +} + +inline PlotFile3D& PlotFile3D::label(const char* s) +{ + PlotFile::label(s); return home(); + +} + +inline PlotFile3D& PlotFile3D::linemod(const char* s) +{ + PlotFile::linemod(s); return *this; +} + + +#endif // _PlotFile3D_h diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/README b/gnu/lib/libg++/libg++/etc/PlotFile3D/README new file mode 100644 index 00000000000..04724bb47da --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/README @@ -0,0 +1,117 @@ + +INFO ABOUT PlotFile3D: + +The `PlotFile3D' class is similar to the `PlotFile' class, except that +it draws 3D pictures using a simple orthogonal projection. Here are +some features and limitations: + + + mono and stereo modes + + viewport clipping of all lines and curves (but not text) + - static wireframes only; no real-time rotation or hidden-line removal + +For the most part, the methods of PlotFile3D are extensions of their +2D counterparts in PlotFile, with x,y,z arguments substituted for x,y +arguments where appropriate. Unlike coordinates in the 2D class, +which (by imitation of the standard Unix plot(3) library) are all of +type `int', the coordinates in PlotFile3D are of type double. As with +the PlotFile class, all user-visible methods return *this. + +Exceptions to these rules of thumb are listed in the remainder of this +section. + +Constructor +=========== + +PlotFile3D(FILE *fp, + const bool stereo =false, + const double th =PI/12, const double ph =PI/3) + + fp obtained via fopen() or popen() + th elevation of camera above xy plane (in radians) + ph rotation of 3D scene about the z axis (in radians) + stereo true if you want a pair of stereo images, side by side + + Once specified, the camera's location cannot be changed. + +Specification of picture dimensions +=================================== + +space(const double x0, const double y0, const double z0 + const double x1, const double y1, const double z1) + + These six coordinates specify a box which would bound the picture + in 3D space. PlotFile3D uses this to compute a transformation + that makes the picture fit nicely in the square 2D viewing frame. + +Shape specifications +==================== + +The methods arc() and dot(), which are available in the PlotFile +class, are not available in PlotFile3D. + +The parameter list of circle() is modified to accommodate three +dimensions: + +circle(const double cx, const double cy, const double cz, + const double rx, const double ry, const double rz, + const int points_per_quadrant =10) + + cx,cy,cz specify the center of the circle + rx,ry,rz form a vector whose direction is normal to the plane of + the circle and whose magnitude is its radius + + The final optional parameter specifies the number of points to be + computed in each quadrant. If (points_per_quadrant == n), then + the circle that is drawn is a regular (4*n)-gon. + +Two of the methods in PlotFile3D have no counterpart in PlotFile. (Yet +more might be added if it seems appropriate to break with the PlotFile +class philosophy of providing a no-frills package that mirrors the +Unix plot(3) package as closely as possible.) These are: + +sphere(const double cx, const double cy, const double cz, + const double rx, const double ry, const double rz, + const int points_per_quadrant =10) + + These arguments are identical to those expected by circle(). The + circle specified is the equator of the sphere, which is all that + is needed to specify it completely. + +home() + + Moves the cursor to a location close to the upper left corner of + the viewing frame. Is automatically called by the constructor and + by space() and erase(). + + This method is useful when plotting on devices which leave a + visible cursor at the point most recently drawn. It may also be + used to place a title label. It should not be used to specify a + starting point for a cont() operation since it leaves the 3D + cursor location undefined. + +The remaining methods are completely analogous to their 2D +counterparts in the PlotFile class: move(), cont(), line(), point(), +box(), erase(), linemod(), label(). + + +When the 3D cursor location is defined +====================================== + +The cont() and label() methods start drawing at PlotFile3D's internal +notion of the "current" location in three dimensions. In many +situations, this 3D cursor location is undefined. + + * It is UNDEFINED immediately after construction, space() and erase(). + * It is DEFINED immediately after move(), cont(), line() and point(). + * It is UNDEFINED immediately after box(), circle() and sphere() + because the manner in which such shapes are drawn is + implementation-dependent. + * It is UNDEFINED immediately after home() and label() because + those are fundamentally 2D operations. + * It is unaffected after linemod(). + +The 3D cursor location must be defined before any cont() operation. +If defined, the 3D cursor location determines the location of any text +drawn by label(). + + diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/Vec3D.h b/gnu/lib/libg++/libg++/etc/PlotFile3D/Vec3D.h new file mode 100644 index 00000000000..d659c319683 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/Vec3D.h @@ -0,0 +1,197 @@ +// Header file for Vec3D class -*- C++ -*- +/* +Copyright (C) 1990 Free Software Foundation + written by J. Thomas Ngo, Harvard University + +This file is part of the GNU C++ Library. + +The GNU C++ Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor accepts +responsibility to anyone for the consequences of using it or for +whether it serves any particular purpose or works at all, unless he +says so in writing. Refer to the GNU General Public License for full +details. + +Everyone is granted permission to copy, modify and redistribute The +GNU C++ Library, but only under the conditions described in the GNU +General Public License. A copy of this license is supposed to have +been given to you along with The GNU C++ Library so you can know your +rights and responsibilities. It should be in a file named COPYING. +Among other things, the copyright notice and this notice must be +preserved on all copies. +*/ + + +#ifndef _Vec3D_h +#define _Vec3D_h 1 + +#include +#include + +//=========================================================================== +// This class is used by PlotFile3D +//=========================================================================== + +class Vec3D +{ +protected: + double n[3]; + +public: + + // Constructors and destructor + + Vec3D(); // initialize to (0,0,0) + Vec3D(const double x, const double y, const double z); + Vec3D(const Vec3D& that); + + ~Vec3D(); + + // Assignment operators + + Vec3D& operator = ( const Vec3D& that ); + Vec3D& operator += ( const Vec3D& that ); + Vec3D& operator -= ( const Vec3D& that ); + Vec3D& operator *= ( const double that ); + Vec3D& operator /= ( const double that ); + + // You can read, but not set coordinates individually: + + double operator [] (const int i) const; // Vector notation + + double x() const; // Point notation + double y() const; + double z() const; + + // Error handling + volatile void error(const char* s) const; +}; + +// Error handling + +inline volatile void Vec3D::error(const char* s) const +{ + (*lib_error_handler)("Vec3D",s); +} + +// associated operators defined inline below + +inline Vec3D::Vec3D() +{ + n[0] = n[1] = n[2] = 0; +} + +inline Vec3D::Vec3D(const double x, const double y, const double z) +{ + n[0]=x; n[1]=y; n[2]=z; +} + + +inline Vec3D::Vec3D(const Vec3D& that) +{ + n[0] = that.n[0]; n[1] = that.n[1]; n[2] = that.n[2]; +} + +inline Vec3D::~Vec3D() {} + +inline Vec3D& Vec3D::operator = (const Vec3D& that) +{ + n[0] = that.n[0]; n[1] = that.n[1]; n[2] = that.n[2]; + return *this; +} + +inline double Vec3D::operator [] (const int i) const +{ + if( i<0 || i>2 ) error("index out of range"); + return n[i]; +} + +inline double Vec3D::x() const +{ + return n[0]; +} + +inline double Vec3D::y() const +{ + return n[1]; +} + +inline double Vec3D::z() const +{ + return n[2]; +} + + +inline Vec3D operator - (const Vec3D& a) +{ + return Vec3D( -a.x(), -a.y(), -a.z() ); +} + +inline double mod(const Vec3D& p) +{ + return sqrt(sqr(p.x()) + sqr(p.y()) + sqr(p.z())); +} + +inline Vec3D operator + (const Vec3D& a, const Vec3D& b) +{ + return Vec3D( a.x()+b.x(), a.y()+b.y(), a.z()+b.z() ); +} + +inline Vec3D operator - (const Vec3D& a, const Vec3D& b) +{ + return Vec3D( a.x()-b.x(), a.y()-b.y(), a.z()-b.z() ); +} + +inline Vec3D operator * (const Vec3D& a, const double sc) // scale +{ + return Vec3D( a.x()*sc, a.y()*sc, a.z()*sc ); +} + +inline double operator * (const Vec3D& a, const Vec3D& b) // dot +{ + return a.x()*b.x() + a.y()*b.y() + a.z()*b.z(); +} + +inline Vec3D operator ^ (const Vec3D& a, const Vec3D& b) // cross +{ + return Vec3D(a.y()*b.z() - a.z()*b.y(), // UK style + a.z()*b.x() - a.x()*b.z(), // notation + a.x()*b.y() - a.y()*b.x()); +} + +inline Vec3D& Vec3D::operator += ( const Vec3D& that ) +{ + n[0] += that.x(); n[1] += that.y(); n[2] += that.z(); + return *this; +} + +inline Vec3D& Vec3D::operator -= ( const Vec3D& that ) +{ + n[0] -= that.x(); n[1] -= that.y(); n[2] -= that.z(); + return *this; +} + +inline Vec3D& Vec3D::operator *= ( const double that ) +{ + n[0] *= that; n[1] *= that; n[2] *= that; + return *this; +} + +inline Vec3D& Vec3D::operator /= ( const double that ) +{ + n[0] /= that; n[1] /= that; n[2] /= that; + return *this; +} + +inline int operator == (const Vec3D& a, const Vec3D& b) +{ + return a.x() == b.x() && a.y() == b.y() && a.z() == b.z(); +} + +inline int operator != (const Vec3D& a, const Vec3D& b) +{ + return !(a == b); +} + + +#endif // _Vec3D_h diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/configure.in b/gnu/lib/libg++/libg++/etc/PlotFile3D/configure.in new file mode 100644 index 00000000000..46c2fde5f16 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=PlotFile3D.h +srcname="libg++/etc/PlotFile3D" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core tPlotFile3D test.pl' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/depend b/gnu/lib/libg++/libg++/etc/PlotFile3D/depend new file mode 100644 index 00000000000..05f16450433 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/depend @@ -0,0 +1,21 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +PlotFile3D.o : PlotFile3D.cc \ + PlotFile3D.h \ + $(srcdir)/../../$(IO_DIR)/PlotFile.h \ + $(srcdir)/../../$(IO_DIR)/fstream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + Vec3D.h +tPlotFile3D.o : tPlotFile3D.cc \ + PlotFile3D.h \ + $(srcdir)/../../$(IO_DIR)/PlotFile.h \ + $(srcdir)/../../$(IO_DIR)/fstream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + Vec3D.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/PlotFile3D/tPlotFile3D.cc b/gnu/lib/libg++/libg++/etc/PlotFile3D/tPlotFile3D.cc new file mode 100644 index 00000000000..87b947cb386 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/PlotFile3D/tPlotFile3D.cc @@ -0,0 +1,14 @@ +#include +main() +{ + PlotFile3D foo("test.pl"); + foo.space(-1000,-1000,-1000,1000,1000,1000).erase(); + + // Draw and label + foo.linemod("longdashed").box(-1000,-1000,-1500,1000,1000,0); + foo.linemod("solid").sphere(0,0,500,0,0,500,30); + foo.linemod("dotted").circle(0,0,500,0,0,800,50); + char *title = "Test of PlotFile3D package"; + foo.home().label(title); + +} diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/ChangeLog b/gnu/lib/libg++/libg++/etc/benchmarks/ChangeLog new file mode 100644 index 00000000000..378c8371872 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/ChangeLog @@ -0,0 +1,33 @@ +Fri Jun 16 16:45:09 1995 Jason Merrill + + * Char.h: Declare all member functions INLINE. + * Int.h: Ditto. + +Thu Feb 16 02:23:38 1995 Jason Merrill + + * Makefile.in: Restore disabled tests, add virtual + non-inline test. + +Sat Nov 20 23:42:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * dhrystone.cc (boolean): Rename to dhry_boolean, to avoid + conflicts with any `boolean' declared in system headers, now that + we get them. + +Wed Jun 23 14:58:33 1993 Per Bothner (bothner@rtl.cygnus.com) + + * dhrystone.cc (Proc0): Guard against division by zero. + +Tue Jun 1 16:59:49 1993 Per Bothner (bothner@rtl.cygnus.com) + + * dhrystone.cc: Assume NOSTRUCTASSIGN unless g++. + * Makefile.in (C_FLAGS): Include $(QUICK), to speed things up. + +Mon Apr 19 00:39:38 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in, configure.in: Re-vamped configure scheme. + +Sat Jan 23 18:11:25 1993 Per Bothner (bothner@cygnus.com) + + * Char.h, Int.h: Delete operator= that assign to char/int; + the ARM says operator= must be a member function. + * dhrystone.cc: Remove memcpy(). Not needed. diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/Char.h b/gnu/lib/libg++/libg++/etc/benchmarks/Char.h new file mode 100644 index 00000000000..4e491ba12c2 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/Char.h @@ -0,0 +1,403 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _Char_h +#define _Char_h 1 + +/* compile with + + -DBUILTIN - to get standard chars + -DCALL - to get calls instead of inlines + (in which case don't use -finline-functions!) + -DVIRT - to make all members virtual + -DBYVAL - to use call-by-value, not by-reference + (-DNO_GNU_CONST - to eliminate calling const functions const + **** REMOVED, NO LONGER SUPPORTED IN G++ *****) + -DNO_GNU_CONST - to eliminate calling const functions const + -DCONVERT - to eliminate mixed mode fns that avoid constructors + -DNO_NRV - to eliminate use of named return values + -DFAKEVPTR - to get one pocharer per object padding + -DRETREF - to make =, +=, etc. return *this, not void +*/ + +#ifdef BUILTIN +typedef char Char; +#else + +#ifdef CALL +#define INLINE +#else +#define INLINE inline +#endif + +#ifndef VIRT +#define VIRTUAL +#else +#define VIRTUAL virtual +#endif + +#ifdef BYVAL +#define REF +#else +#define REF & +#endif + + +#ifndef CONVERT +#define EXPLICIT +#endif + +#ifndef RETREF +#define CharR void +#define ReturnCharR +#else +#define CharR Char& +#define ReturnCharr return *this +#endif + +class Char +{ +protected: + char rep; +#ifdef FAKEVPTR + void* fake_vptr; +#endif +public: + INLINE Char (); + INLINE Char (const char b); + INLINE Char (const Char& b); + INLINE VIRTUAL ~Char(); + + INLINE operator char() const; + + INLINE VIRTUAL char val() const; + + INLINE VIRTUAL CharR operator = (const char); + INLINE VIRTUAL CharR operator = (const Char&); + + INLINE VIRTUAL CharR negate(); + INLINE VIRTUAL CharR complement(); + INLINE VIRTUAL CharR operator ++ (); + INLINE VIRTUAL CharR operator -- (); + + INLINE VIRTUAL CharR operator += (const Char REF ); + INLINE VIRTUAL CharR operator -= (const Char REF ); + INLINE VIRTUAL CharR operator *= (const Char REF ); + INLINE VIRTUAL CharR operator /= (const Char REF ); + INLINE VIRTUAL CharR operator %= (const Char REF ); + INLINE VIRTUAL CharR operator |= (const Char REF ); + INLINE VIRTUAL CharR operator &= (const Char REF ); + INLINE VIRTUAL CharR operator ^= (const Char REF ); + INLINE VIRTUAL CharR operator <<=(const Char REF ); + INLINE VIRTUAL CharR operator >>=(const Char REF ); + +#ifdef EXPLICIT + INLINE VIRTUAL CharR operator += (const char); + INLINE VIRTUAL CharR operator -= (const char); + INLINE VIRTUAL CharR operator *= (const char); + INLINE VIRTUAL CharR operator /= (const char); + INLINE VIRTUAL CharR operator %= (const char); + INLINE VIRTUAL CharR operator |= (const char); + INLINE VIRTUAL CharR operator &= (const char); + INLINE VIRTUAL CharR operator ^= (const char); + INLINE VIRTUAL CharR operator <<=(const char); + INLINE VIRTUAL CharR operator >>=(const char); + +#endif +}; + +INLINE char Char::val() const { return rep; } +INLINE Char::operator char() const { return val(); } + +INLINE Char::Char () :rep(0) {} +INLINE Char::Char (const char b) :rep(b) {} +INLINE Char::Char (const Char& b) :rep(b.Char::val()) {} +INLINE Char::~Char() {} + +INLINE CharR Char::operator = (const char b) +{ rep = b; ReturnCharR; } +INLINE CharR Char::operator = (const Char& b) +{ rep = b.Char::val(); ReturnCharR; } + +INLINE CharR Char::complement() +{ rep = ~rep; ReturnCharR; } +INLINE CharR Char::negate() +{ rep = -rep; ReturnCharR; } +INLINE CharR Char::operator ++ () +{ ++rep; ReturnCharR; } +INLINE CharR Char::operator -- () +{ --rep; ReturnCharR; } + +INLINE CharR Char::operator += (const Char REF b) +{ rep += b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator -= (const Char REF b) +{ rep -= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator *= (const Char REF b) +{ rep *= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator /= (const Char REF b) +{ rep /= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator %= (const Char REF b) +{ rep %= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator |= (const Char REF b) +{ rep |= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator &= (const Char REF b) +{ rep &= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator ^= (const Char REF b) +{ rep ^= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator <<=(const Char REF b) +{ rep <<= b.Char::val(); ReturnCharR; } +INLINE CharR Char::operator >>=(const Char REF b) +{ rep >>= b.Char::val(); ReturnCharR; } + +#ifdef EXPLICIT + +INLINE CharR Char::operator += (const char b) +{ rep += b; ReturnCharR; } +INLINE CharR Char::operator -= (const char b) +{ rep -= b; ReturnCharR; } +INLINE CharR Char::operator *= (const char b) +{ rep *= b; ReturnCharR; } +INLINE CharR Char::operator /= (const char b) +{ rep /= b; ReturnCharR; } +INLINE CharR Char::operator %= (const char b) +{ rep %= b; ReturnCharR; } +INLINE CharR Char::operator |= (const char b) +{ rep |= b; ReturnCharR; } +INLINE CharR Char::operator &= (const char b) +{ rep &= b; ReturnCharR; } +INLINE CharR Char::operator ^= (const char b) +{ rep ^= b; ReturnCharR; } +INLINE CharR Char::operator <<=(const char b) +{ rep <<= b; ReturnCharR; } +INLINE CharR Char::operator >>=(const char b) +{ rep >>= b; ReturnCharR; } + + +INLINE char& operator += (char& a, const Char REF b) +{ a += b.Char::val(); return a; } +INLINE char& operator -= (char& a, const Char REF b) +{ a -= b.Char::val(); return a;} +INLINE char& operator *= (char& a, const Char REF b) +{ a *= b.Char::val(); return a;} +INLINE char& operator /= (char& a, const Char REF b) +{ a /= b.Char::val(); return a;} +INLINE char& operator %= (char& a, const Char REF b) +{ a %= b.Char::val(); return a;} +INLINE char& operator |= (char& a, const Char REF b) +{ a |= b.Char::val(); return a;} +INLINE char& operator &= (char& a, const Char REF b) +{ a &= b.Char::val(); return a;} +INLINE char& operator ^= (char& a, const Char REF b) +{ a ^= b.Char::val(); return a;} +INLINE char& operator <<=(char& a, const Char REF b) +{ a <<= b.Char::val(); return a;} +INLINE char& operator >>=(char& a, const Char REF b) +{ a >>= b.Char::val(); return a;} + +#endif + +#ifdef _G_NO_NRV + +INLINE Char operator - (const Char REF a) +{ Char r(a); r.negate(); return r; } +INLINE Char operator ~ (const Char REF a) +{ Char r(a); r.complement(); return r; } + +INLINE Char operator + (const Char REF a, const Char REF b) +{ Char r(a); r += b.Char::val(); return r; } +INLINE Char operator - (const Char REF a, const Char REF b) +{ Char r(a); r -= b.Char::val(); return r; } +INLINE Char operator * (const Char REF a, const Char REF b) +{ Char r(a); r *= b.Char::val(); return r; } +INLINE Char operator / (const Char REF a, const Char REF b) +{ Char r(a); r /= b.Char::val(); return r; } +INLINE Char operator % (const Char REF a, const Char REF b) +{ Char r(a); r %= b.Char::val(); return r; } +INLINE Char operator << (const Char REF a, const Char REF b) +{ Char r(a); r <<= b.Char::val(); return r; } +INLINE Char operator >> (const Char REF a, const Char REF b) +{ Char r(a); r >>= b.Char::val(); return r; } +INLINE Char operator & (const Char REF a, const Char REF b) +{ Char r(a); r &= b.Char::val(); return r; } +INLINE Char operator | (const Char REF a, const Char REF b) +{ Char r(a); r |= b.Char::val(); return r; } +INLINE Char operator ^ (const Char REF a, const Char REF b) +{ Char r(a); r ^= b.Char::val(); return r; } + +INLINE Char operator + (const Char REF a, const char b) +{ Char r(a); r += b; return r; } +INLINE Char operator - (const Char REF a, const char b) +{ Char r(a); r -= b; return r; } +INLINE Char operator * (const Char REF a, const char b) +{ Char r(a); r *= b; return r; } +INLINE Char operator / (const Char REF a, const char b) +{ Char r(a); r /= b; return r; } +INLINE Char operator % (const Char REF a, const char b) +{ Char r(a); r %= b; return r; } +INLINE Char operator << (const Char REF a, const char b) +{ Char r(a); r <<= b; return r; } +INLINE Char operator >> (const Char REF a, const char b) +{ Char r(a); r >>= b; return r; } +INLINE Char operator & (const Char REF a, const char b) +{ Char r(a); r &= b; return r; } +INLINE Char operator | (const Char REF a, const char b) +{ Char r(a); r |= b; return r; } +INLINE Char operator ^ (const Char REF a, const char b) +{ Char r(a); r ^= b; return r; } + +INLINE Char operator + (const char a, const Char REF b) +{ Char r(a); r += b.Char::val(); return r; } +INLINE Char operator - (const char a, const Char REF b) +{ Char r(a); r -= b.Char::val(); return r; } +INLINE Char operator * (const char a, const Char REF b) +{ Char r(a); r *= b.Char::val(); return r; } +INLINE Char operator / (const char a, const Char REF b) +{ Char r(a); r /= b.Char::val(); return r; } +INLINE Char operator % (const char a, const Char REF b) +{ Char r(a); r %= b.Char::val(); return r; } +INLINE Char operator << (const char a, const Char REF b) +{ Char r(a); r <<= b.Char::val(); return r; } +INLINE Char operator >> (const char a, const Char REF b) +{ Char r(a); r >>= b.Char::val(); return r; } +INLINE Char operator & (const char a, const Char REF b) +{ Char r(a); r &= b.Char::val(); return r; } +INLINE Char operator | (const char a, const Char REF b) +{ Char r(a); r |= b.Char::val(); return r; } +INLINE Char operator ^ (const char a, const Char REF b) +{ Char r(a); r ^= b.Char::val(); return r; } + +#else + +INLINE Char operator - (const Char REF a) return r(a) +{ r.negate(); } +INLINE Char operator ~ (const Char REF a) return r(a) +{ r.complement(); } + +INLINE Char operator + (const Char REF a, const Char REF b) return r(a) +{ r += b.Char::val(); } +INLINE Char operator - (const Char REF a, const Char REF b) return r(a) +{ r -= b.Char::val(); } +INLINE Char operator * (const Char REF a, const Char REF b) return r(a) +{ r *= b.Char::val(); } +INLINE Char operator / (const Char REF a, const Char REF b) return r(a) +{ r /= b.Char::val(); } +INLINE Char operator % (const Char REF a, const Char REF b) return r(a) +{ r %= b.Char::val(); } +INLINE Char operator << (const Char REF a, const Char REF b) return r(a) +{ r <<= b.Char::val(); } +INLINE Char operator >> (const Char REF a, const Char REF b) return r(a) +{ r >>= b.Char::val(); } +INLINE Char operator & (const Char REF a, const Char REF b) return r(a) +{ r &= b.Char::val(); } +INLINE Char operator | (const Char REF a, const Char REF b) return r(a) +{ r |= b.Char::val(); } +INLINE Char operator ^ (const Char REF a, const Char REF b) return r(a) +{ r ^= b.Char::val(); } + +INLINE Char operator + (const Char REF a, const char b) return r(a) +{ r += b; } +INLINE Char operator - (const Char REF a, const char b) return r(a) +{ r -= b; } +INLINE Char operator * (const Char REF a, const char b) return r(a) +{ r *= b; } +INLINE Char operator / (const Char REF a, const char b) return r(a) +{ r /= b; } +INLINE Char operator % (const Char REF a, const char b) return r(a) +{ r %= b; } +INLINE Char operator << (const Char REF a, const char b) return r(a) +{ r <<= b; } +INLINE Char operator >> (const Char REF a, const char b) return r(a) +{ r >>= b; } +INLINE Char operator & (const Char REF a, const char b) return r(a) +{ r &= b; } +INLINE Char operator | (const Char REF a, const char b) return r(a) +{ r |= b; } +INLINE Char operator ^ (const Char REF a, const char b) return r(a) +{ r ^= b; } + +INLINE Char operator + (const char a, const Char REF b) return r(a) +{ r += b.Char::val(); } +INLINE Char operator - (const char a, const Char REF b) return r(a) +{ r -= b.Char::val(); } +INLINE Char operator * (const char a, const Char REF b) return r(a) +{ r *= b.Char::val(); } +INLINE Char operator / (const char a, const Char REF b) return r(a) +{ r /= b.Char::val(); } +INLINE Char operator % (const char a, const Char REF b) return r(a) +{ r %= b.Char::val(); } +INLINE Char operator << (const char a, const Char REF b) return r(a) +{ r <<= b.Char::val(); } +INLINE Char operator >> (const char a, const Char REF b) return r(a) +{ r >>= b.Char::val(); } +INLINE Char operator & (const char a, const Char REF b) return r(a) +{ r &= b.Char::val(); } +INLINE Char operator | (const char a, const Char REF b) return r(a) +{ r |= b.Char::val(); } +INLINE Char operator ^ (const char a, const Char REF b) return r(a) +{ r ^= b.Char::val(); } + +#endif + +INLINE char operator ! (const Char REF a) { return !a.Char::val(); } + +INLINE char operator == (const Char REF a, const Char REF b) +{ return a.Char::val() == b.Char::val(); } +INLINE char operator != (const Char REF a, const Char REF b) +{ return a.Char::val() != b.Char::val(); } +INLINE char operator < (const Char REF a, const Char REF b) +{ return a.Char::val() < b.Char::val(); } +INLINE char operator <= (const Char REF a, const Char REF b) +{ return a.Char::val() <= b.Char::val(); } +INLINE char operator > (const Char REF a, const Char REF b) +{ return a.Char::val() > b.Char::val(); } +INLINE char operator >= (const Char REF a, const Char REF b) +{ return a.Char::val() >= b.Char::val(); } + +INLINE char operator == (const Char REF a, const char b) +{ return a.Char::val() == b; } +INLINE char operator != (const Char REF a, const char b) +{ return a.Char::val() != b; } +INLINE char operator < (const Char REF a, const char b) +{ return a.Char::val() < b; } +INLINE char operator <= (const Char REF a, const char b) +{ return a.Char::val() <= b; } +INLINE char operator > (const Char REF a, const char b) +{ return a.Char::val() > b; } +INLINE char operator >= (const Char REF a, const char b) +{ return a.Char::val() >= b; } + +INLINE char operator == (const char a, const Char REF b) +{ return a == b.Char::val(); } +INLINE char operator != (const char a, const Char REF b) +{ return a != b.Char::val(); } +INLINE char operator < (const char a, const Char REF b) +{ return a < b.Char::val(); } +INLINE char operator <= (const char a, const Char REF b) +{ return a <= b.Char::val(); } +INLINE char operator > (const char a, const Char REF b) +{ return a > b.Char::val(); } +INLINE char operator >= (const char a, const Char REF b) +{ return a >= b.Char::val(); } + +#endif +#endif diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/Int.h b/gnu/lib/libg++/libg++/etc/benchmarks/Int.h new file mode 100644 index 00000000000..8993e7cfd77 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/Int.h @@ -0,0 +1,401 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _Int_h +#define _Int_h 1 + +/* compile with + + -DBUILTIN - to get standard ints + -DCALL - to get calls instead of inlines + (in which case don't use -finline-functions!) + -DVIRT - to make all members virtual + -DBYVAL - to use call-by-value, not by-reference + (-DNO_GNU_CONST - to eliminate calling const functions const + **** REMOVED, NO LONGER SUPPORTED IN g++ ***** ) + -DCONVERT - to eliminate mixed mode fns that avoid constructors + -DNO_NRV - to eliminate use of named return values + -DFAKEVPTR - to get one pointer per object padding + -DRETREF - to make =, +=, etc. return *this, not void +*/ + +#ifdef BUILTIN +typedef int Int; +#else + +#ifdef CALL +#define INLINE +#else +#define INLINE inline +#endif + +#ifndef VIRT +#define VIRTUAL +#else +#define VIRTUAL virtual +#endif + +#ifdef BYVAL +#define REF +#else +#define REF & +#endif + +#ifndef CONVERT +#define EXPLICIT +#endif + +#ifndef RETREF +#define IntR void +#define ReturnIntR +#else +#define IntR Int& +#define ReturnIntr return *this +#endif + +class Int +{ +protected: + int rep; +#ifdef FAKEVPTR + void* fake_vptr; +#endif +public: + INLINE Int (); + INLINE Int (const int b); + INLINE Int (const Int& b); + INLINE VIRTUAL ~Int(); + + INLINE operator int() const; + + INLINE VIRTUAL int val() const; + + INLINE VIRTUAL IntR operator = (const int); + INLINE VIRTUAL IntR operator = (const Int&); + + INLINE VIRTUAL IntR negate(); + INLINE VIRTUAL IntR complement(); + INLINE VIRTUAL IntR operator ++ (); + INLINE VIRTUAL IntR operator -- (); + + INLINE VIRTUAL IntR operator += (const Int REF ); + INLINE VIRTUAL IntR operator -= (const Int REF ); + INLINE VIRTUAL IntR operator *= (const Int REF ); + INLINE VIRTUAL IntR operator /= (const Int REF ); + INLINE VIRTUAL IntR operator %= (const Int REF ); + INLINE VIRTUAL IntR operator |= (const Int REF ); + INLINE VIRTUAL IntR operator &= (const Int REF ); + INLINE VIRTUAL IntR operator ^= (const Int REF ); + INLINE VIRTUAL IntR operator <<=(const Int REF ); + INLINE VIRTUAL IntR operator >>=(const Int REF ); + +#ifdef EXPLICIT + INLINE VIRTUAL IntR operator += (const int); + INLINE VIRTUAL IntR operator -= (const int); + INLINE VIRTUAL IntR operator *= (const int); + INLINE VIRTUAL IntR operator /= (const int); + INLINE VIRTUAL IntR operator %= (const int); + INLINE VIRTUAL IntR operator |= (const int); + INLINE VIRTUAL IntR operator &= (const int); + INLINE VIRTUAL IntR operator ^= (const int); + INLINE VIRTUAL IntR operator <<=(const int); + INLINE VIRTUAL IntR operator >>=(const int); + +#endif +}; + +INLINE int Int::val() const { return rep; } +INLINE Int::operator int() const { return val(); } + +INLINE Int::Int () :rep(0) {} +INLINE Int::Int (const int b) :rep(b) {} +INLINE Int::Int (const Int& b) :rep(b.Int::val()) {} +INLINE Int::~Int() {} + +INLINE IntR Int::operator = (const int b) +{ rep = b; ReturnIntR; } +INLINE IntR Int::operator = (const Int& b) +{ rep = b.Int::val(); ReturnIntR; } + +INLINE IntR Int::complement() +{ rep = ~rep; ReturnIntR; } +INLINE IntR Int::negate() +{ rep = -rep; ReturnIntR; } +INLINE IntR Int::operator ++ () +{ ++rep; ReturnIntR; } +INLINE IntR Int::operator -- () +{ --rep; ReturnIntR; } + +INLINE IntR Int::operator += (const Int REF b) +{ rep += b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator -= (const Int REF b) +{ rep -= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator *= (const Int REF b) +{ rep *= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator /= (const Int REF b) +{ rep /= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator %= (const Int REF b) +{ rep %= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator |= (const Int REF b) +{ rep |= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator &= (const Int REF b) +{ rep &= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator ^= (const Int REF b) +{ rep ^= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator <<=(const Int REF b) +{ rep <<= b.Int::val(); ReturnIntR; } +INLINE IntR Int::operator >>=(const Int REF b) +{ rep >>= b.Int::val(); ReturnIntR; } + +#ifdef EXPLICIT + +INLINE IntR Int::operator += (const int b) +{ rep += b; ReturnIntR; } +INLINE IntR Int::operator -= (const int b) +{ rep -= b; ReturnIntR; } +INLINE IntR Int::operator *= (const int b) +{ rep *= b; ReturnIntR; } +INLINE IntR Int::operator /= (const int b) +{ rep /= b; ReturnIntR; } +INLINE IntR Int::operator %= (const int b) +{ rep %= b; ReturnIntR; } +INLINE IntR Int::operator |= (const int b) +{ rep |= b; ReturnIntR; } +INLINE IntR Int::operator &= (const int b) +{ rep &= b; ReturnIntR; } +INLINE IntR Int::operator ^= (const int b) +{ rep ^= b; ReturnIntR; } +INLINE IntR Int::operator <<=(const int b) +{ rep <<= b; ReturnIntR; } +INLINE IntR Int::operator >>=(const int b) +{ rep >>= b; ReturnIntR; } + + +INLINE int& operator += (int& a, const Int REF b) +{ a += b.Int::val(); return a; } +INLINE int& operator -= (int& a, const Int REF b) +{ a -= b.Int::val(); return a;} +INLINE int& operator *= (int& a, const Int REF b) +{ a *= b.Int::val(); return a;} +INLINE int& operator /= (int& a, const Int REF b) +{ a /= b.Int::val(); return a;} +INLINE int& operator %= (int& a, const Int REF b) +{ a %= b.Int::val(); return a;} +INLINE int& operator |= (int& a, const Int REF b) +{ a |= b.Int::val(); return a;} +INLINE int& operator &= (int& a, const Int REF b) +{ a &= b.Int::val(); return a;} +INLINE int& operator ^= (int& a, const Int REF b) +{ a ^= b.Int::val(); return a;} +INLINE int& operator <<=(int& a, const Int REF b) +{ a <<= b.Int::val(); return a;} +INLINE int& operator >>=(int& a, const Int REF b) +{ a >>= b.Int::val(); return a;} + +#endif + +#ifdef _G_NO_NRV + +INLINE Int operator - (const Int REF a) +{ Int r(a); r.negate(); return r; } +INLINE Int operator ~ (const Int REF a) +{ Int r(a); r.complement(); return r; } + +INLINE Int operator + (const Int REF a, const Int REF b) +{ Int r(a); r += b.Int::val(); return r; } +INLINE Int operator - (const Int REF a, const Int REF b) +{ Int r(a); r -= b.Int::val(); return r; } +INLINE Int operator * (const Int REF a, const Int REF b) +{ Int r(a); r *= b.Int::val(); return r; } +INLINE Int operator / (const Int REF a, const Int REF b) +{ Int r(a); r /= b.Int::val(); return r; } +INLINE Int operator % (const Int REF a, const Int REF b) +{ Int r(a); r %= b.Int::val(); return r; } +INLINE Int operator << (const Int REF a, const Int REF b) +{ Int r(a); r <<= b.Int::val(); return r; } +INLINE Int operator >> (const Int REF a, const Int REF b) +{ Int r(a); r >>= b.Int::val(); return r; } +INLINE Int operator & (const Int REF a, const Int REF b) +{ Int r(a); r &= b.Int::val(); return r; } +INLINE Int operator | (const Int REF a, const Int REF b) +{ Int r(a); r |= b.Int::val(); return r; } +INLINE Int operator ^ (const Int REF a, const Int REF b) +{ Int r(a); r ^= b.Int::val(); return r; } + +INLINE Int operator + (const Int REF a, const int b) +{ Int r(a); r += b; return r; } +INLINE Int operator - (const Int REF a, const int b) +{ Int r(a); r -= b; return r; } +INLINE Int operator * (const Int REF a, const int b) +{ Int r(a); r *= b; return r; } +INLINE Int operator / (const Int REF a, const int b) +{ Int r(a); r /= b; return r; } +INLINE Int operator % (const Int REF a, const int b) +{ Int r(a); r %= b; return r; } +INLINE Int operator << (const Int REF a, const int b) +{ Int r(a); r <<= b; return r; } +INLINE Int operator >> (const Int REF a, const int b) +{ Int r(a); r >>= b; return r; } +INLINE Int operator & (const Int REF a, const int b) +{ Int r(a); r &= b; return r; } +INLINE Int operator | (const Int REF a, const int b) +{ Int r(a); r |= b; return r; } +INLINE Int operator ^ (const Int REF a, const int b) +{ Int r(a); r ^= b; return r; } + +INLINE Int operator + (const int a, const Int REF b) +{ Int r(a); r += b.Int::val(); return r; } +INLINE Int operator - (const int a, const Int REF b) +{ Int r(a); r -= b.Int::val(); return r; } +INLINE Int operator * (const int a, const Int REF b) +{ Int r(a); r *= b.Int::val(); return r; } +INLINE Int operator / (const int a, const Int REF b) +{ Int r(a); r /= b.Int::val(); return r; } +INLINE Int operator % (const int a, const Int REF b) +{ Int r(a); r %= b.Int::val(); return r; } +INLINE Int operator << (const int a, const Int REF b) +{ Int r(a); r <<= b.Int::val(); return r; } +INLINE Int operator >> (const int a, const Int REF b) +{ Int r(a); r >>= b.Int::val(); return r; } +INLINE Int operator & (const int a, const Int REF b) +{ Int r(a); r &= b.Int::val(); return r; } +INLINE Int operator | (const int a, const Int REF b) +{ Int r(a); r |= b.Int::val(); return r; } +INLINE Int operator ^ (const int a, const Int REF b) +{ Int r(a); r ^= b.Int::val(); return r; } + +#else + +INLINE Int operator - (const Int REF a) return r(a) +{ r.negate(); } +INLINE Int operator ~ (const Int REF a) return r(a) +{ r.complement(); } + +INLINE Int operator + (const Int REF a, const Int REF b) return r(a) +{ r += b.Int::val(); } +INLINE Int operator - (const Int REF a, const Int REF b) return r(a) +{ r -= b.Int::val(); } +INLINE Int operator * (const Int REF a, const Int REF b) return r(a) +{ r *= b.Int::val(); } +INLINE Int operator / (const Int REF a, const Int REF b) return r(a) +{ r /= b.Int::val(); } +INLINE Int operator % (const Int REF a, const Int REF b) return r(a) +{ r %= b.Int::val(); } +INLINE Int operator << (const Int REF a, const Int REF b) return r(a) +{ r <<= b.Int::val(); } +INLINE Int operator >> (const Int REF a, const Int REF b) return r(a) +{ r >>= b.Int::val(); } +INLINE Int operator & (const Int REF a, const Int REF b) return r(a) +{ r &= b.Int::val(); } +INLINE Int operator | (const Int REF a, const Int REF b) return r(a) +{ r |= b.Int::val(); } +INLINE Int operator ^ (const Int REF a, const Int REF b) return r(a) +{ r ^= b.Int::val(); } + +INLINE Int operator + (const Int REF a, const int b) return r(a) +{ r += b; } +INLINE Int operator - (const Int REF a, const int b) return r(a) +{ r -= b; } +INLINE Int operator * (const Int REF a, const int b) return r(a) +{ r *= b; } +INLINE Int operator / (const Int REF a, const int b) return r(a) +{ r /= b; } +INLINE Int operator % (const Int REF a, const int b) return r(a) +{ r %= b; } +INLINE Int operator << (const Int REF a, const int b) return r(a) +{ r <<= b; } +INLINE Int operator >> (const Int REF a, const int b) return r(a) +{ r >>= b; } +INLINE Int operator & (const Int REF a, const int b) return r(a) +{ r &= b; } +INLINE Int operator | (const Int REF a, const int b) return r(a) +{ r |= b; } +INLINE Int operator ^ (const Int REF a, const int b) return r(a) +{ r ^= b; } + +INLINE Int operator + (const int a, const Int REF b) return r(a) +{ r += b.Int::val(); } +INLINE Int operator - (const int a, const Int REF b) return r(a) +{ r -= b.Int::val(); } +INLINE Int operator * (const int a, const Int REF b) return r(a) +{ r *= b.Int::val(); } +INLINE Int operator / (const int a, const Int REF b) return r(a) +{ r /= b.Int::val(); } +INLINE Int operator % (const int a, const Int REF b) return r(a) +{ r %= b.Int::val(); } +INLINE Int operator << (const int a, const Int REF b) return r(a) +{ r <<= b.Int::val(); } +INLINE Int operator >> (const int a, const Int REF b) return r(a) +{ r >>= b.Int::val(); } +INLINE Int operator & (const int a, const Int REF b) return r(a) +{ r &= b.Int::val(); } +INLINE Int operator | (const int a, const Int REF b) return r(a) +{ r |= b.Int::val(); } +INLINE Int operator ^ (const int a, const Int REF b) return r(a) +{ r ^= b.Int::val(); } + +#endif + +INLINE int operator ! (const Int REF a) { return !a.Int::val(); } + +INLINE int operator == (const Int REF a, const Int REF b) +{ return a.Int::val() == b.Int::val(); } +INLINE int operator != (const Int REF a, const Int REF b) +{ return a.Int::val() != b.Int::val(); } +INLINE int operator < (const Int REF a, const Int REF b) +{ return a.Int::val() < b.Int::val(); } +INLINE int operator <= (const Int REF a, const Int REF b) +{ return a.Int::val() <= b.Int::val(); } +INLINE int operator > (const Int REF a, const Int REF b) +{ return a.Int::val() > b.Int::val(); } +INLINE int operator >= (const Int REF a, const Int REF b) +{ return a.Int::val() >= b.Int::val(); } + +INLINE int operator == (const Int REF a, const int b) +{ return a.Int::val() == b; } +INLINE int operator != (const Int REF a, const int b) +{ return a.Int::val() != b; } +INLINE int operator < (const Int REF a, const int b) +{ return a.Int::val() < b; } +INLINE int operator <= (const Int REF a, const int b) +{ return a.Int::val() <= b; } +INLINE int operator > (const Int REF a, const int b) +{ return a.Int::val() > b; } +INLINE int operator >= (const Int REF a, const int b) +{ return a.Int::val() >= b; } + +INLINE int operator == (const int a, const Int REF b) +{ return a == b.Int::val(); } +INLINE int operator != (const int a, const Int REF b) +{ return a != b.Int::val(); } +INLINE int operator < (const int a, const Int REF b) +{ return a < b.Int::val(); } +INLINE int operator <= (const int a, const Int REF b) +{ return a <= b.Int::val(); } +INLINE int operator > (const int a, const Int REF b) +{ return a > b.Int::val(); } +INLINE int operator >= (const int a, const Int REF b) +{ return a >= b.Int::val(); } + +#endif +#endif diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/Makefile.in b/gnu/lib/libg++/libg++/etc/benchmarks/Makefile.in new file mode 100644 index 00000000000..cec76ede172 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/Makefile.in @@ -0,0 +1,75 @@ +# A makefile for the stuff now in libg++/etc/benchmarks + +srcdir = . + +prefix = /usr/local + + +# select QUICK= -DQUICK to get 50000 instead of 500000 iterations +QUICK= -DQUICK +#QUICK= + +TEST_PROGS= builtin class virt no_nrv byval call convert call-var virt-var virt-call + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +$(TEST_PROGS) : Int.h Char.h dhrystone.cc +test_progs: $(TEST_PROGS) + +C_FLAGS = $(CXXFLAGS) $(CXXINCLUDES) $(QUICK) + +check: $(TEST_PROGS) + @echo "dhrystone with builtin int and char types:" + @./builtin + @echo "Using classes Int and Char:" + @./class + @echo "Without mixed mode operators (forcing coercions):" + @./convert + @echo "Using by-value, rather than by-reference calling conventions:" + @./byval + @echo "Without using named return values:" + @./no_nrv + @echo "Using calls instead of inline functions:" + @./call + @echo "Using calls, with -fthis-is-variable:" + @./call-var + @echo "With all member functions virtual:" + @./virt + @echo "With all member functions virtual, and -fthis-is-variable:" + @./virt-var + @echo "With all member functions virtual, using calls:" + @./virt-call + @echo "(Try other permutations/switches -- See Int.h.)" + +run_tests: check + +builtin: + $(CXX) $(C_FLAGS) -DBUILTIN $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +class: + $(CXX) $(C_FLAGS) $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +call: + $(CXX) $(C_FLAGS) -DCALL $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +call-var: + $(CXX) $(C_FLAGS) -fthis-is-variable -DCALL $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +convert: + $(CXX) $(C_FLAGS) -DCONVERT $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +no_nrv: + $(CXX) $(C_FLAGS) -D_G_NO_NRV $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +byval: + $(CXX) $(C_FLAGS) -DBYVAL $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +virt: + $(CXX) $(C_FLAGS) -DVIRT $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +virt-var: + $(CXX) $(C_FLAGS) -fthis-is-variable -DVIRT $(srcdir)/dhrystone.cc $(LIBS) -o $@ + +virt-call: + $(CXX) $(C_FLAGS) -DVIRT -DCALL $(srcdir)/dhrystone.cc $(LIBS) -o $@ diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/configure.in b/gnu/lib/libg++/libg++/etc/benchmarks/configure.in new file mode 100644 index 00000000000..58ebb210c1f --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=dhrystone.cc +srcname="libg++/etc/benchmarks" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core $(TEST_PROGS)' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/benchmarks/dhrystone.cc b/gnu/lib/libg++/libg++/etc/benchmarks/dhrystone.cc new file mode 100644 index 00000000000..01845a93d48 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/benchmarks/dhrystone.cc @@ -0,0 +1,701 @@ +/****** A Version of the famous dhrystone benchmark ******* */ +/* + Sun Oct 1 10:40:53 1989 Doug Lea (dl at g.oswego.edu) + Changes made to the standard version to run under C++: + + * include standard prototypes for printf and exit + * include Int.h and Char.h + * convert all `int' and `char' to `Int' and `Char' + (except those needed for timing) + * predeclare all functions + * convert all function headers from old-C + * Change name of struct tms tms to Tms + * wrote mystrcpy and mystrcmp to handle Chars, not chars + * added coercion to bad-looking Proc3 call in Proc1 + * initialized String1Loc in Proc0 + * use `new' instead of malloc + + +This program is marginally useful in looking at the effects of various +C++ constructs when defining a heavily constructive class like +Int and Char. The Int.h and Char.h files can be compiled several +ways, as listed at the top of each + +*/ + +#include <_G_config.h> +#include "Int.h" +#include "Char.h" + +/* + * "DHRYSTONE" Benchmark Program + * + * Version: C/1, 12/01/84 + * + * Date: PROGRAM updated 11/02/85, RESULTS updated 12/13/85 + * + * Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013 + * Translated from ADA by Rick Richardson + * Every method to preserve ADA-likeness has been used, + * at the expense of C-ness. + * + * Compile: cc -O dry.c -o drynr : No registers + * cc -O -DREG=register dry.c -o dryr : Registers + * + * Defines: Defines are provided for old C compiler's + * which don't have enums, and can't assign structures. + * The time(2) function is library dependant; Most + * return the time in seconds, but beware of some, like + * Aztec C, which return other units. + * The LOOPS define is initially set for 50000 loops. + * If you have a machine with large integers and is + * very fast, please change this number to 500000 to + * get better accuracy. Please select the way to + * measure the execution time using the TIME define. + * For single user machines, time(2) is adequate. For + * multi-user machines where you cannot get single-user + * access, use the times(2) function. If you have + * neither, use a stopwatch in the dead of night. + * Use a "printf" at the point marked "start timer" + * to begin your timings. DO NOT use the UNIX "time(1)" + * command, as this will measure the total time to + * run this program, which will (erroneously) include + * the time to malloc(3) storage and to compute the + * time it takes to do nothing. + * + * Run: drynr; dryr + * + * Results: If you get any new machine/OS results, please send to: + * + * {ihnp4,vax135,..}!houxm!castor!pcrat!rer + * + * and thanks to all that do. Space prevents listing + * the names of those who have provided some of these + * results. + * + * Note: I order the list in increasing performance of the + * "with registers" benchmark. If the compiler doesn't + * provide register variables, then the benchmark + * is the same for both REG and NOREG. I'm not going + * to list a compiler in a better place because if it + * had register variables it might do better. No + * register variables is a big loss in my book. + * + * PLEASE: Send complete information about the machine type, + * clock speed, OS and C manufacturer/version. If + * the machine is modified, tell me what was done. + * On UNIX, execute uname -a and cc -V to get this info. + * + * 80x8x NOTE: 80x8x benchers: please try to do all memory models + * for a particular compiler. + * + *--------------------------------RESULTS BEGIN-------------------------------- + * + * MACHINE MICROPROCESSOR OPERATING COMPILER DHRYSTONES/SEC. + * TYPE SYSTEM NO REG REGS + * -------------------------- ------------ ----------- --------------- + * Commodore 64 6510-1MHz C64 ROM C Power 2.8 36 36 + * HP-110 8086-5.33Mhz MSDOS 2.11 Lattice 2.14 284 284 + * IBM PC/XT 8088-4.77Mhz PC/IX cc 257 287 + * P-E 3205 ? Xelos(SVR2) cc 279 296 + * Perq-II 2901 bitslice Accent S5c cc (CMU) 301 301 + * IBM PC/XT 8088-4.77Mhz COHERENT 2.3.43 MarkWilliams cc 296 317 + * Cosmos 68000-8Mhz UniSoft cc 305 322 + * IBM PC/XT 8088-4.77Mhz Venix/86 2.0 cc 297 324 + * DEC PRO 350 11/23 Venix/PRO SVR2 cc 299 325 + * PC/XT 8088-4.77Mhz Venix/86 SYS V cc 339 377 + * IBM PC 8088-4.77Mhz MSDOS 2.0 b16cc 2.0 310 340 + * Commodore Amiga ? Lattice 3.02 368 371 + * IBM PC 8088-4.77Mhz MSDOS 2.0 CI-C86 2.20M 390 390 + * IBM PC/XT 8088-4.77Mhz PCDOS 2.1 Wizard 2.1 367 403 + * IBM PC/XT 8088-4.77Mhz PCDOS 3.1 Lattice 2.15 403 403 @ + * IBM PC 8088-4.77Mhz PCDOS 3.1 Datalight 1.10 416 416 + * IBM PC/XT 8088-4.77Mhz PCDOS 2.1 Microsoft 3.0 390 427 + * PDP-11/34 - UNIX V7M cc 387 438 + * IBM PC 8088, 4.77mhz PC-DOS 2.1 Aztec C v3.2d 423 454 + * Tandy 1000 V20, 4.77mhz MS-DOS 2.11 Aztec C v3.2d 423 458 + * PDP-11/34 - RSTS/E decus c 438 495 + * Onyx C8002 Z8000-4Mhz IS/1 1.1 (V7) cc 476 511 + * Perkin-Elmer 3230 Xelos (SysV.2) cc 507 565 + * DEC PRO 380 11/73 Venix/PRO SVR2 cc 577 628 + * FHL QT+ 68000-10Mhz Os9/68000 version 1.3 603 649 FH + * Apollo DN550 68010-?Mhz AegisSR9/IX cc 3.12 666 666 + * HP-110 8086-5.33Mhz MSDOS 2.11 Aztec-C 641 676 + * ATT PC6300 8086-8Mhz MSDOS 2.11 b16cc 2.0 632 684 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.1 666 684 + * Tandy 6000 68000-8Mhz Xenix 3.0 cc 694 694 + * IBM PC/AT 80286-6Mhz Xenix 3.0 cc 684 704 MM + * Macintosh 68000-7.8Mhz 2M Mac Rom Mac C 32 bit int 694 704 + * Macintosh 68000-7.7Mhz - MegaMax C 2.0 661 709 + * IBM PC/AT 80286-6Mhz Xenix 3.0 cc 704 714 LM + * Codata 3300 68000-8Mhz UniPlus+ (v7) cc 678 725 + * Cadmus 9000 68010-10Mhz UNIX cc 714 735 + * AT&T 6300 8086-8Mhz Venix/86 SVR2 cc 668 743 + * Cadmus 9790 68010-10Mhz 1MB SVR0,Cadmus3.7 cc 720 747 + * NEC PC9801F 8086-8Mhz PCDOS 2.11 Lattice 2.15 768 - @ + * ATT PC6300 8086-8Mhz MSDOS 2.11 CI-C86 2.20M 769 769 + * Burroughs XE550 68010-10Mhz Centix 2.10 cc 769 769 CT1 + * EAGLE/TURBO 8086-8Mhz Venix/86 SVR2 cc 696 779 + * ALTOS 586 8086-10Mhz Xenix 3.0b cc 724 793 + * DEC 11/73 J-11 micro Ultrix-11 V3.0 System V 735 793 + * ATT 3B2/300 WE32000-?Mhz UNIX 5.0.2 cc 735 806 + * Apollo DN320 68010-?Mhz AegisSR9/IX cc 3.12 806 806 + * IRIS-2400 68010-10Mhz UNIX System V cc 772 829 + * Atari 520ST 68000-8Mhz TOS DigResearch 839 846 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(large) 833 847 LM + * VAX 11/750 - Ultrix 1.1 4.2BSD cc 781 862 + * P-E 7350A 68000-8MHz UniSoft V.2 cc 821 875 + * VAX 11/750 - UNIX 4.2bsd cc 862 877 + * Fast Mac 68000-7.7Mhz - MegaMax C 2.0 839 904 + + * IBM PC/XT 8086-9.54Mhz PCDOS 3.1 Microsoft 3.0 833 909 C1 + * DEC 11/44 Ultrix-11 V3.0 System V 862 909 + * Macintosh 68000-7.8Mhz 2M Mac Rom Mac C 16 bit int 877 909 S + * P-E 3210 ? Xelos R01(SVR2) cc 849 924 + * P-E 3220 ? Ed. 7 v2.3 cc 892 925 + * IBM PC/AT 80286-6Mhz Xenix 3.0 cc -i 909 925 + * AT&T 6300 8086, 8mhz MS-DOS 2.11 Aztec C v3.2d 862 943 + * IBM PC/AT 80286-6Mhz Xenix 3.0 cc 892 961 + * VAX 11/750 w/FPA Eunice 3.2 cc 914 976 + * IBM PC/XT 8086-9.54Mhz PCDOS 3.1 Wizard 2.1 892 980 C1 + * IBM PC/XT 8086-9.54Mhz PCDOS 3.1 Lattice 2.15 980 980 C1 + * Plexus P35 68000-10Mhz UNIX System III cc 984 980 + * PDP-11/73 KDJ11-AA 15Mhz UNIX V7M 2.1 cc 862 981 + * VAX 11/750 w/FPA UNIX 4.3bsd cc 994 997 + * IRIS-1400 68010-10Mhz UNIX System V cc 909 1000 + * IBM PC/AT 80286-6Mhz Venix/86 2.1 cc 961 1000 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 b16cc 2.0 943 1063 + * Zilog S8000/11 Z8001-5.5Mhz Zeus 3.2 cc 1011 1084 + * NSC ICM-3216 NSC 32016-10Mhz UNIX SVR2 cc 1041 1084 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(small) 1063 1086 + * VAX 11/750 w/FPA VMS VAX-11 C 2.0 958 1091 + * Stride 68000-10Mhz System-V/68 cc 1041 1111 + * ATT PC7300 68010-10Mhz UNIX 5.2 cc 1041 1111 + * P-E 3230 ? Xelos R01(SVR2) cc 1040 1126 + * Stride 68000-12Mhz System-V/68 cc 1063 1136 + * IBM PC/AT 80286-6Mhz Venix/286 SVR2 cc 1056 1149 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 Datalight 1.10 1190 1190 + * ATT PC6300+ 80286-6Mhz MSDOS 3.1 b16cc 2.0 1111 1219 + * IBM PC/AT 80286-6Mhz PCDOS 3.1 Wizard 2.1 1136 1219 + * Sun2/120 68010-10Mhz Sun 4.2BSD cc 1136 1219 + * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.20M 1219 1219 + * MASSCOMP 500 68010-10MHz RTU V3.0 cc (V3.2) 1156 1238 + * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1162 1250 + * PDP 11/70 - UNIX 5.2 cc 1162 1250 + * IBM PC/AT 80286-6Mhz PCDOS 3.1 Lattice 2.15 1250 1250 + * IBM PC/AT 80286-7.5Mhz Venix/86 2.1 cc 1190 1315 *15 + * Sun2/120 68010-10Mhz Standalone cc 1219 1315 + * Intel 380 80286-8Mhz Xenix R3.0up1 cc 1250 1315 *16 + * ATT 3B2/400 WE32100-?Mhz UNIX 5.2 cc 1315 1315 + * P-E 3250XP - Xelos R01(SVR2) cc 1215 1318 + * DG MV4000 - AOS/VS 5.00 cc 1333 1333 + * IBM PC/AT 80286-8Mhz Venix/86 2.1 cc 1275 1380 *16 + * IBM PC/AT 80286-6Mhz MSDOS 3.0 Microsoft 3.0 1250 1388 + * ATT PC6300+ 80286-6Mhz MSDOS 3.1 CI-C86 2.20M 1428 1428 + * COMPAQ/286 80286-8Mhz Venix/286 SVR2 cc 1326 1443 + * IBM PC/AT 80286-7.5Mhz Venix/286 SVR2 cc 1333 1449 *15 + * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1470 1562 S + * VAX 11/780 - UNIX 5.2 cc 1515 1562 + * MicroVAX-II - - - 1562 1612 + * VAX 11/780 - UNIX 4.3bsd cc 1646 1662 + * Apollo DN660 - AegisSR9/IX cc 3.12 1666 1666 + * ATT 3B20 - UNIX 5.2 cc 1515 1724 + * NEC PC-98XA 80286-8Mhz PCDOS 3.1 Lattice 2.15 1724 1724 @ + * HP9000-500 B series CPU HP-UX 4.02 cc 1724 - + * IBM PC/STD 80286-8Mhz MSDOS 3.0 Microsoft 3.0 1724 1785 C2 + * DEC-2065 KL10-Model B TOPS-20 6.1FT5 Port. C Comp. 1937 1946 + * Gould PN6005 - UTX 1.1(4.2BSD) cc 1675 1964 + * DEC2060 KL-10 TOPS-20 cc 2000 2000 & + * VAX 11/785 - UNIX 5.2 cc 2083 2083 + * VAX 11/785 - VMS VAX-11 C 2.0 2083 2083 + * VAX 11/785 - UNIX SVR2 cc 2123 2083 + * VAX 11/785 - UNIX 4.3bsd cc 2135 2136 + * Pyramid 90x - OSx 2.3 cc 2272 2272 + * Pyramid 90x FPA,cache,4Mb OSx 2.5 cc no -O 2777 2777 + * Alliant FX-8 CE ? ? 2622 2901 FX + * Pyramid 90x w/cache OSx 2.5 cc w/-O 3333 3333 + * IBM-4341-II - VM/SP3 Waterloo C 1.2 3333 3333 + * IRIS-2400T 68020-16.67Mhz UNIX System V cc 3105 3401 + * SUN 3/75 68020-16.67Mhz SUN 4.2 V3 cc 3333 3571 + * IBM-4341 Model 12 UTS 5.0 ? 3685 3685 + * SUN-3/160 68020-16.67Mhz Sun 4.2 V3.0A cc 3381 3764 + * Sun 3/180 68020-16.67Mhz Sun 4.2 cc 3333 3846 + * IBM-4341 Model 12 UTS 5.0 ? 3910 3910 MN + * MC 5400 68020-16.67MHz RTU V3.0 cc (V4.0) 3952 4054 + * NCR Tower32 68020-16.67Mhz SYS 5.0 Rel 2.0 cc 3846 4545 + * Gould PN9080 - UTX-32 1.1c cc - 4629 + * MC 5600/5700 68020-16.67MHz RTU V3.0 cc (V4.0) 4504 4746 % + * Gould 1460-342 ECL proc UTX/32 1.1/c cc 5342 5677 G1 + * VAX 8600 - UNIX 4.3bsd cc 7024 7088 + * VAX 8600 - VMS VAX-11 C 2.0 7142 7142 + * CCI POWER 6/32 COS(SV+4.2) cc 7500 7800 + * CCI POWER 6/32 POWER 6 UNIX/V cc 8236 8498 + * CCI POWER 6/32 4.2 Rel. 1.2b cc 8963 9544 + * Sperry (CCI Power 6) 4.2BSD cc 9345 10000 + * CRAY-X-MP/12 105Mhz COS 1.14 Cray C 10204 10204 + * IBM-3083 - UTS 5.0 Rel 1 cc 16666 12500 + * CRAY-1A 80Mhz CTSS Cray C 2.0 12100 13888 + * IBM-3083 - VM/CMS HPO 3.4 Waterloo C 1.2 13889 13889 + * Amdahl 470 V/8 UTS/V 5.2 cc v1.23 15560 15560 + * CRAY-X-MP/48 105Mhz CTSS Cray C 2.0 15625 17857 + * Amdahl 580 - UTS 5.0 Rel 1.2 cc v1.5 23076 23076 + * Amdahl 5860 UTS/V 5.2 cc v1.23 28970 28970 + * + * * Crystal changed from 'stock' to listed value. + * + This Macintosh was upgraded from 128K to 512K in such a way that + * the new 384K of memory is not slowed down by video generator accesses. + * % Single processor; MC == MASSCOMP + * & A version 7 C compiler written at New Mexico Tech. + * @ vanilla Lattice compiler used with MicroPro standard library + * S Shorts used instead of ints + * LM Large Memory Model. (Otherwise, all 80x8x results are small model) + * MM Medium Memory Model. (Otherwise, all 80x8x results are small model) + * C1 Univation PC TURBO Co-processor; 9.54Mhz 8086, 640K RAM + * C2 Seattle Telecom STD-286 board + * C? Unknown co-processor board? + * CT1 Convergent Technologies MegaFrame, 1 processor. + * MN Using Mike Newtons 'optimizer' (see net.sources). + * G1 This Gould machine has 2 processors and was able to run 2 dhrystone + * Benchmarks in parallel with no slowdown. + * FH FHC == Frank Hogg Labs (Hazelwood Uniquad 2 in an FHL box). + * FX The FX-8 has two kinds of processors. This figure is for CE's + * (computation engines). The other processor type is an IP (interactive + * processor) which is a 68010-12Mhz. Figures were not precisely + * determined for the IP. + * ? I don't trust results marked with '?'. These were sent to me with + * either incomplete info, or with times that just don't make sense. + * ?? means I think the performance is too poor, ?! means too good. + * If anybody can confirm these figures, please respond. + * + *--------------------------------RESULTS END---------------------------------- + * + * The following program contains statements of a high-level programming + * language (C) in a distribution considered representative: + * + * assignments 53% + * control statements 32% + * procedure, function calls 15% + * + * 100 statements are dynamically executed. The program is balanced with + * respect to the three aspects: + * - statement type + * - operand type (for simple data types) + * - operand access + * operand global, local, parameter, or constant. + * + * The combination of these three aspects is balanced only approximately. + * + * The program does not compute anything meaningfull, but it is + * syntactically and semantically correct. + * + */ + +/* Accuracy of timings and human fatigue controlled by next two lines */ +#ifdef QUICK +#define LOOPS 50000 /* Use this for slow or 16 bit machines */ +#else +#define LOOPS 500000 /* Use this for faster machines */ +#endif + +/* Compiler dependent options */ +#undef NOENUM /* Define if compiler has no enum's */ +#undef NOSTRUCTASSIGN /* Define if compiler can't assign structures */ +/* cfront 3.0 can't handle the assignments */ +#ifndef __GNUG__ +#define NOSTRUCTASSIGN +#endif + + +/* define only one of the next two defines */ +#ifndef _G_SYSV +#define TIMES /* Use times(2) time function */ +#else +#define TIME /* Use time(2) time function */ +#endif + +#ifdef TIMES +#include +#include +#endif +#ifdef TIME +#include +#endif + +/* define the granularity of your times(2) function (when used) */ +#ifndef HZ +#if 1 +#define HZ 60 /* times(2) returns 1/60 second (most) */ +#else +#define HZ 100 /* times(2) returns 1/100 second (WECo) */ +#endif +#endif + + +#ifdef NOSTRUCTASSIGN +#include +#define structassign(d, s) memcpy(&(d), &(s), sizeof(d)) +#else +#define structassign(d, s) d = s +#endif + +#ifdef NOENUM +#define Ident1 1 +#define Ident2 2 +#define Ident3 3 +#define Ident4 4 +#define Ident5 5 +typedef int Enumeration; +#else +typedef enum {Ident1, Ident2, Ident3, Ident4, Ident5} Enumeration; +#endif + + + +typedef Int OneToThirty; +typedef Int OneToFifty; +typedef Char CapitalLetter; +typedef Char String30[31]; +typedef Int Array1Dim[51]; +typedef Int Array2Dim[51][51]; + +struct Record +{ + struct Record *PtrComp; + Enumeration Discr; + Enumeration EnumComp; + OneToFifty IntComp; + String30 StringComp; +}; + +typedef struct Record RecordType; +typedef RecordType * RecordPtr; +typedef int dhry_boolean; + +#define TRUE 1 +#define FALSE 0 + +#ifndef REG +#define REG +#endif + + +/* added: - dl */ + +extern "C" { +extern int printf(const char* ...); +extern void exit(int); +} + +void Proc0(); +void Proc1(RecordPtr PtrParIn); +void Proc2(OneToFifty *IntParIO); +void Proc3(RecordPtr *PtrParOut); +void Proc4(); +void Proc5(); +dhry_boolean Func3(Enumeration EnumParIn); +void Proc6(REG Enumeration EnumParIn, REG Enumeration *EnumParOut); +void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut); +void Proc8(Array1Dim Array1Par, + Array2Dim Array2Par, + OneToFifty IntParI1, + OneToFifty IntParI2); +Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2); +dhry_boolean Func2(String30 StrParI1, String30 StrParI2); +dhry_boolean Func3(Enumeration EnumParIn); + +void mystrcpy(String30 s, char* t) +{ + for (; *t != '\0'; ++s, ++t) *s = *t; + *s = '\0'; +} + +char mystrcmp(String30 s, String30 t) +{ + for (; *s == *t; ++s, ++t) if (*s == '\0') return 0; + return char(*s - *t); +} + +/*end - dl */ + +main() +{ + Proc0(); + exit(0); +} + +/* + * Package 1 + */ +Int IntGlob; +dhry_boolean BoolGlob; +char Char1Glob; +char Char2Glob; +Array1Dim Array1Glob; +Array2Dim Array2Glob; +RecordPtr PtrGlb; +RecordPtr PtrGlbNext; + +void Proc0() +{ + OneToFifty IntLoc1; + REG OneToFifty IntLoc2; + OneToFifty IntLoc3; + REG char CharLoc; + REG char CharIndex; + Enumeration EnumLoc; + String30 String1Loc; + String30 String2Loc; + +#ifdef TIME + long starttime; + long benchtime; + long nulltime; + register unsigned int i; + + starttime = time( (_G_time_t *) 0); + for (i = 0; i < LOOPS; ++i); + nulltime = time( (_G_time_t*) 0) - starttime; /* Computes o'head of loop */ +#endif +#ifdef TIMES + time_t starttime; + time_t benchtime; + time_t nulltime; + struct tms Tms; + register unsigned int i; + + times(&Tms); starttime = Tms.tms_utime; + for (i = 0; i < LOOPS; ++i); + times(&Tms); + nulltime = Tms.tms_utime - starttime; /* Computes overhead of looping */ +#endif + + PtrGlbNext = new Record; + PtrGlb = new Record; + PtrGlb->PtrComp = PtrGlbNext; + PtrGlb->Discr = Ident1; + PtrGlb->EnumComp = Ident3; + PtrGlb->IntComp = 40; + mystrcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING"); + mystrcpy(String1Loc, "JUST INITIALIZED TO SOME JUNK."); + +/***************** +-- Start Timer -- +*****************/ +#ifdef TIME + starttime = time( (_G_time_t*) 0); +#endif +#ifdef TIMES + times(&Tms); starttime = Tms.tms_utime; +#endif + for (i = 0; i < LOOPS; ++i) + { + + Proc5(); + Proc4(); + IntLoc1 = 2; + IntLoc2 = 3; + mystrcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); + EnumLoc = Ident2; + BoolGlob = ! Func2(String1Loc, String2Loc); + while (IntLoc1 < IntLoc2) + { + IntLoc3 = 5 * IntLoc1 - IntLoc2; + Proc7(IntLoc1, IntLoc2, &IntLoc3); + ++IntLoc1; + } + Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3); + Proc1(PtrGlb); + for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex) + if (EnumLoc == Func1(CharIndex, 'C')) + Proc6(Ident1, &EnumLoc); + IntLoc3 = IntLoc2 * IntLoc1; + IntLoc2 = IntLoc3 / IntLoc1; + IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1; + Proc2(&IntLoc1); + } + +/***************** +-- Stop Timer -- +*****************/ + +#ifdef TIME + benchtime = time( (_G_time_t *) 0) - starttime - nulltime; + printf("Dhrystone time for %ld passes = %ld\n", + (long) LOOPS, benchtime); + if (benchtime) + printf("This machine benchmarks at %ld dhrystones/second\n", + ((long) LOOPS) / benchtime); +#endif +#ifdef TIMES + times(&Tms); + benchtime = Tms.tms_utime - starttime - nulltime; + printf("Dhrystone time for %ld passes = %ld\n", + (long) LOOPS, benchtime/HZ); + if (benchtime) + printf("This machine benchmarks at %ld dhrystones/second\n", + ((long) LOOPS) * HZ / benchtime); +#endif + +} + +void Proc1(RecordPtr PtrParIn) +{ +#define NextRecord (*(PtrParIn->PtrComp)) + + structassign(NextRecord, *PtrGlb); + PtrParIn->IntComp = 5; + NextRecord.IntComp = PtrParIn->IntComp; + NextRecord.PtrComp = PtrParIn->PtrComp; +/* - added coercion (glossing over error in original code) - dl */ + Proc3(&(NextRecord.PtrComp)); + if (NextRecord.Discr == Ident1) + { + NextRecord.IntComp = 6; + Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp); + NextRecord.PtrComp = PtrGlb->PtrComp; + Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp); + } + else + structassign(*PtrParIn, NextRecord); + +#undef NextRecord +} + +void Proc2(OneToFifty *IntParIO) +{ + REG OneToFifty IntLoc; + REG Enumeration EnumLoc; + + IntLoc = *IntParIO + 10; + for(;;) + { + if (Char1Glob == 'A') + { + --IntLoc; + *IntParIO = IntLoc - IntGlob; + EnumLoc = Ident1; + } + if (EnumLoc == Ident1) + break; + } +} + +void Proc3(RecordPtr *PtrParOut) +{ + if (PtrGlb) + *PtrParOut = PtrGlb->PtrComp; + else + IntGlob = 100; + Proc7(10, IntGlob, &PtrGlb->IntComp); +} + +void Proc4() +{ + REG dhry_boolean BoolLoc; + + BoolLoc = Char1Glob == 'A'; + BoolLoc |= BoolGlob; + Char2Glob = 'B'; +} + +void Proc5() +{ + Char1Glob = 'A'; + BoolGlob = FALSE; +} + + + + +void Proc6(REG Enumeration EnumParIn, REG Enumeration *EnumParOut) +{ + *EnumParOut = EnumParIn; + if (! Func3(EnumParIn) ) + *EnumParOut = Ident4; + switch (EnumParIn) + { + case Ident1: *EnumParOut = Ident1; break; + case Ident2: if (IntGlob > 100) *EnumParOut = Ident1; + else *EnumParOut = Ident4; + break; + case Ident3: *EnumParOut = Ident2; break; + case Ident4: break; + case Ident5: *EnumParOut = Ident3; + } +} + +void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut) +{ + REG OneToFifty IntLoc; + + IntLoc = IntParI1 + 2; + *IntParOut = IntParI2 + IntLoc; +} + +void Proc8(Array1Dim Array1Par, + Array2Dim Array2Par, + OneToFifty IntParI1, + OneToFifty IntParI2) +{ + REG OneToFifty IntLoc; + REG OneToFifty IntIndex; + + IntLoc = IntParI1 + 5; + Array1Par[IntLoc] = IntParI2; + Array1Par[IntLoc+1] = Array1Par[IntLoc]; + Array1Par[IntLoc+30] = IntLoc; + for (IntIndex = IntLoc; IntIndex <= (IntLoc+1); ++IntIndex) + Array2Par[IntLoc][IntIndex] = IntLoc; + ++Array2Par[IntLoc][IntLoc-1]; + Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]; + IntGlob = 5; +} + +Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2) +{ + REG CapitalLetter CharLoc1; + REG CapitalLetter CharLoc2; + + CharLoc1 = CharPar1; + CharLoc2 = CharLoc1; + if (CharLoc2 != CharPar2) + return (Ident1); + else + return (Ident2); +} + +dhry_boolean Func2(String30 StrParI1, String30 StrParI2) +{ + REG OneToThirty IntLoc; + REG CapitalLetter CharLoc; + + IntLoc = 1; + while (IntLoc <= 1) + if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1) + { + CharLoc = 'A'; + ++IntLoc; + } + if (CharLoc >= 'W' && CharLoc <= 'Z') + IntLoc = 7; + if (CharLoc == 'X') + return(TRUE); + else + { + if (mystrcmp(StrParI1, StrParI2) > 0) + { + IntLoc += 7; + return (TRUE); + } + else + return (FALSE); + } +} + +dhry_boolean Func3(Enumeration EnumParIn) +{ + REG Enumeration EnumLoc; + + EnumLoc = EnumParIn; + if (EnumLoc == Ident3) return (TRUE); + return (FALSE); +} diff --git a/gnu/lib/libg++/libg++/etc/configure.in b/gnu/lib/libg++/libg++/etc/configure.in new file mode 100644 index 00000000000..65663c8a175 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/configure.in @@ -0,0 +1,24 @@ +# 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. + +configdirs="graph ADT-examples benchmarks PlotFile3D lf trie-gen fib" +srctrigger=HINTS +srcname="Miscellaneous g++ examples" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +ALL='$(NOTHING)' + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/fib/Makefile.in b/gnu/lib/libg++/libg++/etc/fib/Makefile.in new file mode 100644 index 00000000000..6d54fcfd19a --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/fib/Makefile.in @@ -0,0 +1,32 @@ +# Makefile for libg++.a + +# Copyright (C) 1988, 1992, 1993 Free Software Foundation +# written by Doug Lea (dl@rocky.oswego.edu) + +# This file is part of GNU CC. + +# GNU CC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY. No author or distributor +# accepts responsibility to anyone for the consequences of using it +# or for whether it serves any particular purpose or works at all, +# unless he says so in writing. Refer to the GNU CC General Public +# License for full details. + +# Everyone is granted permission to copy, modify and redistribute +# GNU CC, but only under the conditions described in the +# GNU CC General Public License. A copy of this license is +# supposed to have been given to you along with GNU CC so you +# can know your rights and responsibilities. It should be in a +# file named COPYING. Among other things, the copyright notice +# and this notice must be preserved on all copies. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +check: fib + -./fib 1000 + +fib: fib.o + $(CXX) -o fib fib.o $(LIBS) -lm diff --git a/gnu/lib/libg++/libg++/etc/fib/configure.in b/gnu/lib/libg++/libg++/etc/fib/configure.in new file mode 100644 index 00000000000..b89c671610c --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/fib/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=fib.cc +srcname="libg++/etc/fib" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o *~ \#* fib' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/fib/fib.cc b/gnu/lib/libg++/libg++/etc/fib/fib.cc new file mode 100644 index 00000000000..101dc2ffcbb --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/fib/fib.cc @@ -0,0 +1,615 @@ +#include +#include +#include + +// Fun and games with the Fibonacci function. +// Also demonstrates use of the `named return value' extension. + +// fib1 and fib2 from Doug Lea, others from Doug Schmidt. + +/**********************************************************************/ + +// Standard iterative version: + +// Schmidt uses convention that fib(0) = 1, not fib(0) = 0; +// so I just increment n here. + +Integer +fib1(int n) +{ + ++n; + if (n <= 0) + return 0; + else + { + Integer f = 1; + Integer prev = 0; + + while (n > 1) + { + Integer tmp = f; + f += prev; + prev = tmp; + --n; + } + + return f; + } +} + +/**********************************************************************/ + +// n +// via transformed matrix multiplication of ( 0 1 ) +// ( 1 1 ) +// simplified knowing that the matrix is always of +// the form (a b) +// (b c) +// (where (a, b) and (b, c) are conseq pairs of conseq fib's; +// further simplified by realizing that c = a+b, so c is only +// calculated implicitly. +// Given all this, do the power via the standard russian +// peasant divide-and-conquer algorithm, with +// the current multiplier held in (p q) +// (q -) +// +// This example also shows that using procedure calls instead of operators +// can be faster for Integers + + +// operator version + +Integer +fib2(int n) +{ + ++n; // 1-based for compatability; see above + Integer a = 0; + if (n <= 0) + return a; + else + { + Integer b = 1; + Integer p = 0; + Integer q = 1; + + for(;;) + { + if (n == 1) + return a * p + b * q; + else if (odd (n)) + { + Integer aq = a * q; + Integer bq = b * q; + a = a * p + bq; + b = b * p + aq + bq; + } + Integer qq = q * q; + q = (q * p) * 2L + qq; + p = (p * p) + qq; + n >>= 1; + } + } +} + +// with all expressions named, including return value + +Integer +fib2a(int n) +{ + Integer a = 0; + ++n; + if (n <= 0) + return a; + else + { + Integer b = 1; + Integer p = 0; + Integer q = 1; + + for(;;) + { + if (n == 1) + { + Integer bq = b * q; + a *= p ; + a += bq; + return a; + } + else if (odd (n)) + { + Integer aq = a * q; + Integer bq = b * q; + a *= p; + a += bq; + b *= p; + b += bq; + b += aq; + } + Integer qq = q * q; + Integer pp = p * p; + Integer pq = p * q; + q = pq; + q += pq; + q += qq; + p = pp; + p += qq; + n >>= 1; + } + } +} + +// procedure call version + +Integer +fib2b(int n) +{ + Integer a = 0; + ++n; + + if (n <= 0) + return a; + else + { + Integer b = 1; + Integer p = 0; + Integer q = 1; + + for(;;) + { + if (n == 1) + { + Integer bq; mul(b, q, bq); + mul(a, p, a); + add(a, bq, a); + return a; + } + else if (odd (n)) + { + Integer aq; mul(a, q, aq); + Integer bq; mul(b, q, bq); + mul(a, p, a); + mul(b, p, b); + add(a, bq, a); + add(b, bq, b); + add(b, aq, b); + } + Integer qq; mul(q, q, qq); + Integer pp; mul(p, p, pp); + Integer pq; mul(p, q, pq); + add(pq, pq, q); + add(q, qq, q); + add(pp, qq, p); + n >>= 1; + } + } +} + +// procedure call version, reusing variables + +Integer +fib2c(int n) +{ + Integer a = 0; + ++n; + + if (n <= 0) + return a; + else + { + Integer b = 1; + Integer p = 0; + Integer q = 1; + Integer bq, aq, qq, pp, pq; + for(;;) + { + if (n == 1) + { + mul(b, q, bq); + mul(a, p, a); + add(a, bq, a); + return a; + } + else if (odd (n)) + { + mul(a, q, aq); + mul(b, q, bq); + mul(a, p, a); + mul(b, p, b); + add(a, bq, a); + add(b, bq, b); + add(b, aq, b); + } + mul(q, q, qq); + mul(p, p, pp); + mul(p, q, pq); + add(pq, pq, q); + add(q, qq, q); + add(pp, qq, p); + n >>= 1; + } + } +} + +/**********************************************************************/ +// Ullman memoizers: + +class Ullman_Array +{ + // Ullman's array implementation allows Initialization, Store, and Fetch + // in O(1) time. Although it takes O(n) space the time to initialize enables + // us to compute a Fibonacci number in O(log n) time! + // The basic concept of Ullman's array implementation is the use of a + // Hand_Shake_Array and an Index_Array. An Index location in the array is + // only considered initialized if the contents in the Hand_Shake_Array and + // Index_Array point to each other, i.e. they ``shake hands!'' + +private: + int max_array_range; + int max_set_size; + int *index_array; + int *hand_shake_array; + Integer *storage_array; + int current_max; + +public: + Integer uninitialized; + + Ullman_Array (int array_range, int set_size); + void store (int index, const Integer &item); + Integer fetch (int index); + +}; + +inline +Ullman_Array::Ullman_Array (int array_range, int set_size) +{ + max_array_range = array_range; + max_set_size = set_size; + index_array = new int[max_array_range + 1]; + hand_shake_array = new int[max_set_size]; + storage_array = new Integer[max_set_size]; + current_max = -1; + uninitialized = 0; // No fibonacci number has value of 0. +} + +// Store Item at the proper Index of the Ullman array. +// The Hand_Shake_Array determines whether the Index has already +// been stored into. If it has NOT, then a new location for it +// is set up in the Storage_Array and the Hand_Shake_Array and Index_Array +// are set to point at each other. + +inline void +Ullman_Array::store (int index, const Integer &item) +{ + int hand_shake_index = index_array[index]; + + if (hand_shake_index > current_max || hand_shake_index < 0 + || index != hand_shake_array[hand_shake_index]) + { + hand_shake_index = ++current_max; + hand_shake_array[hand_shake_index] = index; + index_array[index] = hand_shake_index; + } + storage_array[hand_shake_index] = item; +} + +// Returns uninitialized if not initialized, else returns Item at Index. + +inline Integer +Ullman_Array::fetch(int index) +{ + int hand_shake_index = index_array[index]; + + if (hand_shake_index > current_max || hand_shake_index < 0 + || index != hand_shake_array[hand_shake_index]) + return uninitialized; + else + return storage_array[hand_shake_index]; +} + +/**********************************************************************/ + +class Memo_Fib : public Ullman_Array +{ +public: + Memo_Fib (int fib_num); + Integer fib3 (int n); + Integer fib3a (int n); +}; + + +// The total number of Items computed by the Fib routine is bounded by +// 4 * ceiling of log base 2 of Fib_Num. Of course, the basis of the +// recurrence is Fib(0) == 1 and Fib(1) == 1! + +Memo_Fib::Memo_Fib (int fib_num) : Ullman_Array(fib_num, (4 * lg (fib_num))) +{ + store (0, 1); + store (1, 1); +} + +// Uses the memoization technique to reduce the time complexity to calculate +// the nth Fibonacci number in O(log n) time. If the value of ``n'' is +// already in the table we return it in O(1) time. Otherwise, we use the +// super-nifty divide-and-conquer algorithm to break the problem up into +// 4 pieces of roughly size n/2 and solve them recursively. Although this +// looks like an O(n^2) recurrence the memoization reduces the number of +// recursive calls to O(log n)! + +Integer +Memo_Fib::fib3 (int n) +{ + Integer fib = fetch(n); + if (fib == uninitialized) + { + int m = n >> 1; + + fib = fib3 (m) * fib3 (n - m) + fib3 (m - 1) * fib3 (n - m - 1); + store (n, fib); + } + return fib; +} + +// The same, with procedure calls instead of operators + +Integer +Memo_Fib::fib3a (int n) +{ + Integer fib = fetch(n); + if (fib == uninitialized) + { + int m = n >> 1; + Integer tmp; + mul(fib3a(m), fib3a(n - m), fib); + mul(fib3a(m - 1), fib3a(n - m - 1), tmp); + add(fib, tmp, fib); + store (n, fib); + } + return fib; +} + +/**********************************************************************/ + +// Here's a linear-time dynamic programming solution to the same problem. +// It makes use of G++/GCC dynamic arrays to build a table of ``n'' partial +// solutions. Naturally, there is an O(1) space solution, but this O(n) +// approach is somewhat more intuitive and follows the ``original'' recurrence +// more closely. + +Integer +fib4 (int n) +{ +#if defined (__GNUC__) && !defined (__STRICT_ANSI__) + Integer table[n + 1]; +#else + Integer *table = new Integer[n + 1]; +#endif + table[0] = 1; + table[1] = 1; + + for (int i = 2; i <= n; i++) + table[i] = table[i - 1] + table[i - 2]; + +#ifdef __GNUC__ + return table[n]; +#else + Integer tmp = table[n]; + delete [] table; + return tmp; +#endif +} + +/**********************************************************************/ + +// The extended integers provide numbers of the form: +// (base+sqrt(5)*Rad_5)/2^Pow_2 +// These are used to find the solution to the closed form of fib(n). + +struct Extended_Int +{ + Integer base; + Integer rad_5; + int pow_2; + + Extended_Int (const Integer ¶m1, const Integer ¶m2, int param3); + Extended_Int (const Extended_Int& param); + Extended_Int (void) {} + + friend inline Extended_Int operator- (const Extended_Int ¶m1, + const Extended_Int ¶m2); + friend Extended_Int operator* (const Extended_Int ¶m1, + const Extended_Int ¶m2); + friend inline Extended_Int sqrt (const Extended_Int ¶m1); + friend Extended_Int pow (const Extended_Int ¶m1, int num); +}; + +inline +Extended_Int::Extended_Int (const Integer ¶m1, const Integer ¶m2, + int param3) +{ + base = param1; + rad_5 = param2; + pow_2 = param3; +} + +inline +Extended_Int::Extended_Int (const Extended_Int ¶m) +{ + base = param.base; + rad_5 = param.rad_5; + pow_2 = param.pow_2; +} + +inline Extended_Int +operator- (const Extended_Int ¶m1, const Extended_Int ¶m2) +{ + Extended_Int temp; + temp.base = param1.base - param2.base; + temp.rad_5 = param1.rad_5 - param2.rad_5; + temp.pow_2 = param1.pow_2; + return temp; +} + +Extended_Int +operator* (const Extended_Int ¶m1, const Extended_Int ¶m2) +{ + Extended_Int temp; + temp.base = param1.base * param2.base + 5L * param1.rad_5 * param2.rad_5; + temp.rad_5 = param1.base * param2.rad_5 + param1.rad_5 * param2.base; + temp.pow_2 = param1.pow_2 + param2.pow_2; + + while (temp.pow_2 > 0 && !(odd (temp.base) || odd (temp.rad_5))) + { + temp.base >>= 1; + temp.rad_5 >>= 1; + temp.pow_2--; + } + + return temp; +} + +inline Extended_Int +sqrt (const Extended_Int ¶m1) +{ + return param1 * param1; +} + +Extended_Int +pow (const Extended_Int ¶m1, int num) +{ + if (num > 1) + return odd (num) + ? param1 * sqrt (pow (param1, num >> 1)) : sqrt (pow (param1, num >> 1)); + else + return param1; +} + +/**********************************************************************/ + +// Calculates fib (n) by solving the closed form of the recurrence. + +class Closed_Form : private Extended_Int +{ +private: + Extended_Int cons1; + Extended_Int cons2; + +public: + Closed_Form (void): cons1 (1, 1, 1), cons2 (1, -1, 1) {} + Integer fib5 (int n); +}; + +Integer +Closed_Form::fib5 (int num) +{ + Extended_Int temp = pow (cons1, num + 1) - pow (cons2, num + 1); + + while (temp.pow_2 > 0 && !(odd (temp.base) || odd (temp.rad_5))) + { + temp.base >>= 1; + temp.rad_5 >>= 1; + temp.pow_2--; + } + + return temp.rad_5; +} + +/**********************************************************************/ + +static const int DEFAULT_SIZE = 10000; + + +void dofib1(int fib_num) +{ + start_timer (); + Integer result = fib1 (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib1 = " << result << ". Time = " << time << "\n"; +} + +void dofib2(int fib_num) +{ + start_timer (); + Integer result = fib2 (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib2 = " << result << ". Time = " << time << "\n"; +} + +void dofib2a(int fib_num) +{ + start_timer (); + Integer result = fib2a(fib_num); + double time = return_elapsed_time(0.0); + cout << "fib2a = " << result << ". Time = " << time << "\n"; +} + +void dofib2b(int fib_num) +{ + start_timer (); + Integer result = fib2b(fib_num); + double time = return_elapsed_time(0.0); + cout << "fib2b = " << result << ". Time = " << time << "\n"; +} + +void dofib2c(int fib_num) +{ + start_timer (); + Integer result = fib2c(fib_num); + double time = return_elapsed_time(0.0); + cout << "fib2c = " << result << ". Time = " << time << "\n"; +} + +void dofib3(int fib_num) +{ + start_timer (); + Memo_Fib Memo_Test (fib_num); + Integer result = Memo_Test.fib3 (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib3 = " << result << ". Time = " << time << "\n"; +} + +void dofib3a(int fib_num) +{ + start_timer (); + Memo_Fib Memo_Test (fib_num); + Integer result = Memo_Test.fib3a (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib3a = " << result << ". Time = " << time << "\n"; +} + +void dofib4(int fib_num) +{ + start_timer (); + Integer result = fib4 (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib4 = " << result << ". Time = " << time << "\n"; +} + +void dofib5(int fib_num) +{ + Closed_Form Rec_Test; + Integer result = Rec_Test.fib5 (fib_num); + double time = return_elapsed_time(0.0); + cout << "fib5 = " << result << ". Time = " << time << "\n"; +} + + +int +main (int argc, char *argv[]) +{ + int fib_num = (argc > 1) ? atoi (argv[1]) : DEFAULT_SIZE; + + cout << "Results for fib(" << fib_num << "):\n\n"; + + dofib1(fib_num); + dofib2(fib_num); + dofib2a(fib_num); + dofib2b(fib_num); + dofib2c(fib_num); + dofib3(fib_num); + dofib3a(fib_num); +// dofib4(fib_num); // This uses too much mem for large n! + dofib5(fib_num); + return 0; +} + diff --git a/gnu/lib/libg++/libg++/etc/graph/ChangeLog b/gnu/lib/libg++/libg++/etc/graph/ChangeLog new file mode 100644 index 00000000000..ec8dbe4f772 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/ChangeLog @@ -0,0 +1,133 @@ +Wed Apr 28 13:15:20 1993 Per Bothner (bothner@cygnus.com) + + Changes (mostly from Peter Schauer) to permit compilation + using cfront 3.0 and otherwise be ARM-conforming. + * graph.cc (clip, main): + Don't use non-standard >?= operator. + * graph.cc (main): Fix brace error, fixing -My option. + * ePlotFile.h, ePlotFile.cc (ePlotFile::alabel): + Make string parameter be const, + +Tue Jan 19 13:25:39 1993 Per Bothner (bothner@cygnus.com) + + * read_data.h: Remove #define of HUGE. + Add #include , to get DBL_MAX. + * read_data.cc, graph.cc: Replace HUGE by more portable DBL_MAX. + +Tue Nov 17 22:13:11 1992 Per Bothner (bothner@rtl.cygnus.com) + + * graph.c (main): exit(-1) on bad args. + +Fri Jun 26 11:36:15 1992 Per Bothner (bothner@rtl.cygnus.com) + + * read_data.cc: istream::get(char&) can never set the char + to EOF (except accidentally), so don't compare the char to EOF. + The istream::good() test subsumes it anyway. Also, use + standard istream::putback instead of non-standard unget(). + +Thu May 14 12:38:57 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tick_interval.{cc,h}: Renamed to tick_intvl.{cc,h} to + fit in 14 characters. + * Makefile.in, graph.cc, ...: Update correspondingly. + +Sat Feb 1 12:55:13 1992 Per Bothner (bothner at cygnus.com) + + * graph.cc, ePlotFile.h, read_data.{C,h}: + Convert to using iostreams facility. + * Makefile.in: + * read_data.cc, read_data.h: Combine overloaded read_data() + function into a single function. + Pass extra filename parameter to read_data (for error + messages, since istream::name() is no longer supported). + * graph.cc: Combine to use the single read_data() function. + * Makefile.in: Add $(srcdir)/ as appropriate. + +Fri Oct 5 12:29:03 1990 Richard Murphey (rich at kappa) + + * graph.cc: added the option `-S -1' (i.e. symbol_number == -1) + which specifies that symbols are not to be drawn. This is a slight + change from the old convention, but is not consistent with the way + line_mode is handled, and both will behave better when `-K' or + `-M' are chosen respecively. + +Thu Oct 4 15:59:19 1990 Richard Murphey (rich at taj) + + * graph.cc: the option `-m -1' (i.e. line_style == -1) means that + lines are not drawn between points. This allows you to plot + symbols alone at each point. + +Tue Jan 16 14:44:46 1990 Rich Murphey (rich at kalliope) + + * graph.cc: added ability to specify the position of the labels + on the x and y axes using the letters R or L and T or B to indicate + whether the labels appear on the left or right and top or bottom + of the plot. Also added a description of this to graph.tex. + + * graph.cc: added command line options to specify that the + line style (-L) or symbol (-K) changes whenever the abcissal + data decreases in value. + + * graph.tex: added description of -K and -L options. + +Wed Jan 3 12:43:46 1990 Doug Lea (dl at g.oswego.edu) + + * graph.cc: replaced sprintf calls with dtoa, since sprintf + is apparently pretty broken on some systems. + + * eGetOpt, ePlotFile: explicilty list constructrs, since g++ + no longer allows inheritence of ctors. + +Sun Dec 3 21:21:17 1989 Carey R. Murphey (rich at kalliope) + + * graph.cc: add margins beteen edges of the data and the box + only if the scale is not logarithmic. Otherwise the + additional margin could cause the value at the end of the + axis to be negative. + +Wed Nov 8 20:59:38 1989 Carey R. Murphey (rich at kalliope) + + * The -c option was incompatible with other versions of graph. + Changed graph.cc to use this option to specify a default + label to be printed at each data point. Symbols can be + specified now using the `-S' option. + + * Added the option `-z' to prevent graph from reading the standard + input. + + * split out read_data, tick_interval, eGetOpt, and ePlotFile + into separate files. Had to change the arguments to read_data + to include what used to be passed through global data. + + * graph.cc: changed expressions using ?: to use >? or test2.pl + ./graph -d <$(srcdir)/test.dat >test.pl + @echo use plot to look at the plot files test.pl and test2.pl +run_tests: check + +OBJECTS = pPlex.o pXPlex.o eGetOpt.o ePlotFile.o read_data.o tick_intrvl.o +DEPEND_SOURCES = $(srcdir)/*.cc + +libgraph.a : $(OBJECTS) + rm -f libgraph.a + $(AR) $(AR_FLAGS) libgraph.a $(OBJECTS) + $(RANLIB) libgraph.a + +graph : graph.o libgraph.a + $(CXX) graph.o libgraph.a $(LIBS) -lm -o $@ + +graph.o: pXPlex.h pPlex.h + +pXPlex.h pXPlex.cc: + PROTODIR=$(PROTODIR); export PROTODIR; ../../genclass/genclass point val XPlex p +pPlex.h pPlex.cc: + PROTODIR=$(PROTODIR); export PROTODIR; ../../genclass/genclass point val Plex p + +# GNU tail doesn't handle -r - use the 'tac' program instead. +REVERSE_LINES = tail -r +#REVERSE_LINES = tac + +$(srcdir)/test.dat: + -echo 0 0 1 1 2 0 | spline | $(REVERSE_LINES) > $(srcdir)/test.dat + +$(srcdir)/test2.dat: + echo 0 0 >$(srcdir)/test2.dat + echo 1 1 "label for 1 1" >>$(srcdir)/test2.dat + echo 2 2 >>$(srcdir)/test2.dat + echo 3 3 "label for 3 3" >>$(srcdir)/test2.dat + echo 4 4 >>$(srcdir)/test2.dat + +DIST = Makefile graph.tex ChangeLog \ +eGetOpt.cc read_data.cc \ +eGetOpt.h read_data.h \ +ePlotFile.cc tick_intrvl.cc \ +ePlotFile.h tick_intrvl.h \ +graph.cc pdefs.h + +graph.tar.Z : $(DIST) CHECKSUMS + tar cfz $@ $^ CHECKSUMS + +CHECKSUMS : $(DIST) + sum $(DIST) >CHECKSUMS + +dist : graph-dist.tar.Z + +graph-dist.tar.Z : $(DIST) + -rm -rf graph-dist + mkdir graph-dist + ln $(DIST) graph-dist + tar cfz graph-dist.tar.Z $(DIST) + rm -rf graph-dist + +graph.shar : pdefs.h graph.cc Makefile graph.texinfo + shar pdefs.h graph.cc Makefile graph.texinfo > $@ diff --git a/gnu/lib/libg++/libg++/etc/graph/configure.in b/gnu/lib/libg++/libg++/etc/graph/configure.in new file mode 100644 index 00000000000..4c15d3c1a0f --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/configure.in @@ -0,0 +1,27 @@ +# 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. + +configdirs="" +srctrigger=read_data.h +srcname="libg++/etc/graph" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core pXPlex* pPlex* test.pl test2.pl' +CLEAN='graph graph.shar libgraph.a ' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/graph/depend b/gnu/lib/libg++/libg++/etc/graph/depend new file mode 100644 index 00000000000..5962c79e804 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/depend @@ -0,0 +1,38 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +eGetOpt.o : eGetOpt.cc \ + eGetOpt.h \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +ePlotFile.o : ePlotFile.cc \ + ePlotFile.h \ + $(srcdir)/../../$(IO_DIR)/PlotFile.h \ + $(srcdir)/../../$(IO_DIR)/fstream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h +graph.o : graph.cc \ + read_data.h \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + pXPlex.h \ + eGetOpt.h \ + ePlotFile.h \ + $(srcdir)/../../$(IO_DIR)/PlotFile.h \ + $(srcdir)/../../$(IO_DIR)/fstream.h \ + tick_intrvl.h \ + $(srcdir)/../../$(IO_DIR)/strstream.h +read_data.o : read_data.cc \ + read_data.h \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + pXPlex.h +tick_intrvl.o : tick_intrvl.cc \ + tick_intrvl.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/graph/eGetOpt.cc b/gnu/lib/libg++/libg++/etc/graph/eGetOpt.cc new file mode 100644 index 00000000000..036e5326829 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/eGetOpt.cc @@ -0,0 +1,43 @@ +#pragma implementation +#include "eGetOpt.h" + +int +eGetOpt :: next_arg (int &i) +{ + int tmp; + if (0 < sscanf (nargv[optind], "%d", &tmp)) + { + i = tmp; + optind++; + return 1; + } + else + return 0; +} + +int +eGetOpt :: next_arg (double &d) +{ + double tmp; + if (0 < sscanf (nargv[optind], "%lf", &tmp)) + { + d = tmp; + optind++; + return 1; + } + else + return 0; +} + +int +eGetOpt :: next_arg (String &s) +{ + if ('-' != nargv[optind][0]) + { + s = nargv[optind]; + optind++; + return 1; + } + else + return 0; +} diff --git a/gnu/lib/libg++/libg++/etc/graph/eGetOpt.h b/gnu/lib/libg++/libg++/etc/graph/eGetOpt.h new file mode 100644 index 00000000000..ac6912dcba9 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/eGetOpt.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +#ifndef eGetOpt_h +#pragma interface +#define eGetOpt_h 1 + +#include +#include + +// eGetOpt is a subclass of GetOpt which provides functions for +// handling arguments to the options. + +class eGetOpt : public GetOpt +{ +public: + eGetOpt (int argc, char **argv, char *optstring) + : GetOpt(argc,argv,optstring) {} + + // first_char returns the first character of the argument. + + int first_char () { return nargv[optind][0];}; + + // next_arg looks at next argument for an interger, double or string + // depending on the type of argument given to it. If the correct type is + // found, the value is set and next_arg returns 1. If the type is not + // correct, next_arg returns 0. + + // double arguments start with a digit, plus, minus or period. + // integer arguments start with a digit. + // String arguments have no restriction. + + // If the next argument is an integer, set the reference variable to it + // and increment the index to the options. Return 1 if an integer is + // found, else return 0. + + int next_arg (int &i); + int next_arg (double &d); + int next_arg (String &s); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/etc/graph/ePlotFile.cc b/gnu/lib/libg++/libg++/etc/graph/ePlotFile.cc new file mode 100644 index 00000000000..9d95fd897dd --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/ePlotFile.cc @@ -0,0 +1,13 @@ +#pragma implementation +#include "ePlotFile.h" + +ePlotFile& ePlotFile:: alabel (alabel_xadj x_adjust, + alabel_yadj y_adjust, const char *s) +{ + cmd ('T'); + cmd (x_adjust); + cmd (y_adjust); + *this << s; + *this << "\n"; + return *this; +}; diff --git a/gnu/lib/libg++/libg++/etc/graph/ePlotFile.h b/gnu/lib/libg++/libg++/etc/graph/ePlotFile.h new file mode 100644 index 00000000000..32c848c4ee0 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/ePlotFile.h @@ -0,0 +1,40 @@ + +#ifndef ePlotFile_h +#pragma interface +#define ePlotFile_h 1 + +#include + +// ePlotFile is an extended plot file class which has adjusted labels. + +// put the left center or right edge of the text at the current point. +typedef enum alabel_xadj +{ LEFT_JUSTIFY = 'l', CENTER_JUSTIFY = 'c', RIGHT_JUSTIFY = 'r'}; + +// put the top center or bottom edge of the text at the current point. +typedef enum alabel_yadj +{ BOTTOM_FLUSH = 'b', CENTER_FLUSH = 'c', TOP_FLUSH = 't' }; + +class ePlotFile : public PlotFile +{ +public: + ePlotFile() : PlotFile() {} +#ifndef _OLD_STREAMS + ePlotFile(int fd) : PlotFile(fd) { } + ePlotFile(const char *name, int mode=ios::out, int prot=0664) + : PlotFile(name, mode, prot) { } +#else + ePlotFile(const char* filename, io_mode m, access_mode a) + :PlotFile(filename, m, a) {} + ePlotFile(const char* filename, const char* m) + :PlotFile(filename, m) {} + ePlotFile(int filedesc, io_mode m = io_writeonly) + :PlotFile(filedesc, m) {} + ePlotFile(FILE* fileptr) : PlotFile(fileptr) {} +#endif + + ePlotFile& alabel (alabel_xadj x_adjust, + alabel_yadj y_adjust, const char *s); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/etc/graph/graph.cc b/gnu/lib/libg++/libg++/etc/graph/graph.cc new file mode 100644 index 00000000000..f018d9e5a3f --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/graph.cc @@ -0,0 +1,697 @@ +// graph.cc --- graph reads data and writes out a plot file. + +const char *copyright_notice = "\ +Copyright (C) 1989 Free Software Foundation \n\ + \n\ +This file is part of GNU CC. \n\ + \n\ +GNU CC is distributed in the hope that it will be useful, \n\ +but WITHOUT ANY WARRANTY. No author or distributor \n\ +accepts responsibility to anyone for the consequences of using it \n\ +or for whether it serves any particular purpose or works at all, \n\ +unless he says so in writing. Refer to the GNU CC General Public \n\ +License for full details. \n\ + \n\ +Everyone is granted permission to copy, modify and redistribute \n\ +GNU CC, but only under the conditions described in the \n\ +GNU CC General Public License. A copy of this license is \n\ +supposed to have been given to you along with GNU CC so you \n\ +can know your rights and responsibilities. It should be in a \n\ +file named COPYING. Among other things, the copyright notice \n\ +and this notice must be preserved on all copies. \n\ +"; + +#include "read_data.h" +#include "eGetOpt.h" +#include "ePlotFile.h" +#include "tick_intrvl.h" +#include +#include + +const char *usage_message = "\ + [options...]\n\ +\n\ + Option: Description:\n\ + -C print copyright notice\n\ + -D binary double precision data\n\ + -E use extended plot file format\n\ + -H CHARACTER_HEIGHT fractional height of characters\n\ + -I binary integer data\n\ + -K switch symbol for each new line\n\ + -L switch line style for each new line\n\ + -M [x|y] MARGIN margin between data and edges of box\n\ + -N TICKS number of tick marks on each axis\n\ + -P SIZE plot file coordinate range\n\ + -S SYMBOL_NUMBER SYMBOL_SIZE draw symbols at each point\n\ + -T TICK_SIZE fractional size of tick marks\n\ + -W CHARACTER_WIDTH fractional width of characters\n\ + -X X_LABEL label printed below the x axis\n\ + -Y Y_LABEL label printed right of the y axis\n\ + -a STEP_SIZE LOWER_LIMIT generate abcissa, read only y values\n\ + -b break lines whenever x decreases\n\ + -c POINT_LABEL default label printed at each point\n\ + -d print debugging information\n\ + -g GRID_STYLE draw a grid in the plot\n\ + -h HEIGHT fractional height of the plot\n\ + -l TOP_LABEL label printed above the plot\n\ + -m LINE_MODE solid and dashed lines\n\ + -r RIGHT move plot right by fractional ammount\n\ + -s save the screen - do not erase\n\ + -t transpose x ans y axes\n\ + -u UP move plot up by fractional ammount\n\ + -w WIDTH fractional width of the plot\n\ + -x [lTB] LOWER_LIMIT UPPER_LIMIT log scale, axis limits\n\ + -y [lLR] LOWER_LIMIT UPPER_LIMIT log scale, axis limits\n\ + -z do not read data from standard input\n\ +"; + +// Here are the command line option data and flags: + +String default_label; // default label at each point. +String top_label; // label above the plot. +String x_label; // x axis label +String y_label; // y axis label +data_type input_data = ASCII; // the type of data to be read in. +double char_height = .03; // fractional height of printed characters +double char_width = .02; // fractional width of printed characters +double height = .8; // fraction height of the plot. +double lower_limit = 0.; // lower limit in x for generated values +double no_of_ticks = 5.; // number of tick marks on the axes. +double right = .1; // the fractional margin on the right side. +double size_of_ticks = .01; // fractional size of the tick marks. +double spacing = 1.; // stepsize for equally spaced generated values +double symbol_size = .01; // index of symbol drawn at each point. +double up = .1; // the fractional margin above the plot. +double width = .8; // fraction width of the plot. +double x_lower_limit = DBL_MAX; // DBL_MAX means get it from the data +double x_margin = 0.0; // fractional margin between data and box +double x_upper_limit = DBL_MAX; // DBL_MAX means get it from the data +double y_lower_limit = DBL_MAX; // DBL_MAX means get it from the data +double y_margin = 0.05; // fractional margin between data and box +double y_upper_limit = DBL_MAX; // DBL_MAX means get it from the data +int abcissa_flag = 0; // nonzero means generate x axiz values +int break_flag = 0; // break the line whenever x decreases. +int debug_flag = 0; // verbose debugging output. +int extended_plot_format = 0; // nonzero means use adjusted labels. +int grid_style = 1; // style of box and or axes. +int line_style = 0; // the type of line drawn to connect points. +int no_standard_input = 0; // nonzero means do not read from standard input +int plot_size = 4096; // upper limit of plot file coordinates +int save_screen_flag = 0; // nonzero means do not erase before plotting. +int switch_style = 0; // switch line style for each new curve +int switch_symbols = 0; // switch symbols when starting each new curve +int symbol_number = -1; // index of symbol drawn at each point. +int transpose_axes_flag = 0; // nonzero means interchange x and y axes. +int x_label_on_top = 0; // nonzero means label tick marks on right side +int x_log_scale = 0; // the x axis is log scale +int y_label_on_right = 0; // nonzero means label tick marks on top +int y_log_scale = 0; // the y axis is log scale + +// the names of line styles recognized in the unix plot file convention. +char *line_style_name[] = +{ + "solid", + "longdashed", + "dotted", + "disconnected", + "dotdashed", + "shortdashed" + }; +const int no_of_line_styles = sizeof(line_style_name)/sizeof(line_style_name[0]); + +// This is all the data describing how to draw the symbols. + +typedef enum op {END, CONT, MOVE, CIRCLE}; // a graphic operation + +struct coord // a component coordintate within a symbol +{ + double x, y; // fractional coordinates + op operation; // the type of graphic +}; + +struct coord symbol[][10] = // set of symbols +{ + { // plus sign + { -.5, .0, MOVE}, + { .5, .0, CONT}, + { .0, -.5, MOVE}, + { .0, .5, CONT}, + { .0, .0, END} + }, { // cross + { -.5, -.5, MOVE}, + { .5, .5, CONT}, + { .5, -.5, MOVE}, + { -.5, .5, CONT}, + { .0, .0, END} + }, { // diamond + { -.5, .0, MOVE}, + { .0, .5, CONT}, + { .5, .0, CONT}, + { .0, -.5, CONT}, + { -.5, .0, CONT}, + { .0, .0, END} + }, { // square + { -.5, -.5, MOVE}, + { -.5, .5, CONT}, + { .5, .5, CONT}, + { .5, -.5, CONT}, + { -.5, -.5, CONT}, + { .0, .0, END} + }, { // triangle + { -.5, -.5, MOVE}, + { .0, .86603, CONT}, + { .5, -.5, CONT}, + { -.5, -.5, CONT}, + { .0, .0, END} + }, { // circle + { .5, .0, CIRCLE}, + { .0, .0, END} + }, { // circle with a line through it + { .5, .0, CIRCLE}, + { .0, -.5, MOVE}, + { .0, .5, CONT}, + { .0, .0, END} + } // add more symbols here... +}; +const int no_of_symbols = sizeof(symbol) / sizeof(symbol[0]); + +// Here are the functions for transforming and clipping. + +inline int px (double t) // transform fractional x to plot x +{ + return (int) (plot_size * (width * t + right)); // should we round rather than + // truncate here? +} + +inline int py (double t) // transform fractional x to plot x +{ + return (int) (plot_size * (height * t + up)); +} + +inline double clip (double t) +{ + double tmp = ( t > 0.0) ? t : 0.0; + return (tmp < 1.0) ? tmp : 1.0; +} + +// uppper and lower bounds on the data +double xmin = DBL_MAX, ymin = DBL_MAX, xmax = -DBL_MAX, ymax = -DBL_MAX; +double log_xmin, log_ymin, log_xmax, log_ymax; + +inline double fx (double t) // transform data x to fractional x +{ + return x_log_scale ? + (log (t) - log_xmin) / (log_xmax - log_xmin) : + (t - xmin) / (xmax - xmin); +} + +inline double fy (double t) // transform data y to fractional y +{ + return y_log_scale ? + (log (t) - log_ymin) / (log_ymax - log_ymin) : + (t - ymin) / (ymax - ymin); +} + +inline int in_box (double x, double y) // return 1 if point is inside box +{ + return (x >= xmin) && (x <= xmax) && (y >= ymin) && (y <= ymax); +} + +int +main (int argc, char **argv) +{ + eGetOpt getopt + (argc, argv, + "CDEH::IJKLM::N::P::ST::W::X::Y::a::bc::dg::h::l::m::r::stu::vw::x::y::z"); + int option_char; + int error_occurred = 0; // non zero for a bad command line option + + while (EOF != (option_char = getopt ())) + switch (option_char) + { + case 'C': + cerr << copyright_notice; break; + case 'D': input_data = DOUBLE; break; + case 'E': extended_plot_format++; break; + case 'H': getopt.next_arg (char_height); break; + case 'I': input_data = INT; break; + case 'K': switch_symbols++; break; + case 'L': switch_style++; break; + case 'M': + if ('x' == getopt.first_char()) + {getopt.optind++; getopt.next_arg (x_margin); break;} + if ('y' == getopt.first_char()) + {getopt.optind++; getopt.next_arg (y_margin);} break; + case 'N': getopt.next_arg (no_of_ticks); break; + case 'P': getopt.next_arg (plot_size); break; + case 'S': getopt.next_arg (symbol_number); + getopt.next_arg (symbol_size); break; + case 'T': getopt.next_arg (size_of_ticks); break; + case 'W': getopt.next_arg (char_width); break; + case 'X': getopt.next_arg (x_label); break; + case 'Y': getopt.next_arg (y_label); break; + case 'a': abcissa_flag++; getopt.next_arg (spacing); + getopt.next_arg (lower_limit); break; + case 'b': break_flag++; break; + case 'c': getopt.next_arg (default_label); break; + case 'd': debug_flag++; break; + case 'g': getopt.next_arg (grid_style); break; + case 'h': getopt.next_arg (height); break; + case 'l': getopt.next_arg (top_label); break; + case 'm': getopt.next_arg (line_style); break; + case 'r': getopt.next_arg (right); break; + case 's': save_screen_flag++; break; + case 't': transpose_axes_flag++; break; + case 'u': getopt.next_arg (up); break; + case 'v': cerr << "graph version 0.\n"; break; + case 'w': getopt.next_arg (width); break; + case 'x': + while (isalpha (getopt.first_char())) + { + switch (getopt.first_char()) + { + case 'T': x_label_on_top++; getopt.optind++; break; + case 'B': x_label_on_top=0; getopt.optind++; break; + case 'l': x_log_scale++; getopt.optind++; break; + } + } + getopt.next_arg (x_lower_limit); getopt.next_arg (x_upper_limit); break; + case 'y': + while (isalpha (getopt.first_char())) + { + switch (getopt.first_char()) + { + case 'L': y_label_on_right=0; getopt.optind++; break; + case 'R': y_label_on_right++; getopt.optind++; break; + case 'l': y_log_scale++; getopt.optind++; break; + } + } + getopt.next_arg (y_lower_limit); getopt.next_arg (y_upper_limit); break; + case 'z': no_standard_input++; break; + case '?': error_occurred++; + } + if (error_occurred) { + cerr << "usage" sp argv[0] sp usage_message; + exit (-1); + } + // Complain if the plot does not fits on page + if (up < 0.) cerr << + "Warning: the plot may extend below the bottom of the page.\n"; + if (up + height > 1.) cerr << + "Warning: the plot may extend above the top of the page.\n"; + if (right < 0.) cerr << + "Warning: the plot may extend beyond the left edge of the page.\n"; + if (right + width > 1.) cerr << + "Warning: the plot may extend beyond the right edge of the page.\n"; + + // now we start reading in all the data. + pointXPlex point; // all the data is held in an array of points + + // read data from standard input. + if (! no_standard_input) + read_data (cin, "(stdard input)", point, abcissa_flag, + lower_limit, spacing, symbol_number, + input_data, switch_symbols); + + // read data files specified on command line. + int i; + for (i=getopt.optind; i point[i].x) xmin = point[i].x; + if (ymin > point[i].y) ymin = point[i].y; + if (xmax < point[i].x) xmax = point[i].x; + if (ymax < point[i].y) ymax = point[i].y; + } + // add margins beteen edges of the data and box if range is nonzero and + // the scale is not logarithmic. + if (!y_log_scale) + { + double tmp = (ymax - ymin); + ymax += y_margin * tmp; + ymin -= y_margin * tmp; + } + if (!x_log_scale) + { + double tmp = (xmax - xmin); + xmax += x_margin * tmp; + xmin -= x_margin * tmp; + } + } + + // use limits specified on the command line if present. + if (x_lower_limit != DBL_MAX) xmin = x_lower_limit; + if (y_lower_limit != DBL_MAX) ymin = y_lower_limit; + if (x_upper_limit != DBL_MAX) xmax = x_upper_limit; + if (y_upper_limit != DBL_MAX) ymax = y_upper_limit; + + // make sure that 0 is not in range if we are using a log scale. + if ( (x_log_scale + && (xmin <= 0.) + && (xmax >= 0.)) + || (y_log_scale + && (ymin <= 0.) + && (ymax >= 0.))) + { + cerr << "the lower bound on x is" sp xmin nl; + cerr << "the upper bound on x is" sp xmax nl; + cerr << "the lower bound on y is" sp ymin nl; + cerr << "the upper bound on y is" sp ymax nl; + cerr << "Zero cannot lie between an upper and lower bound" nl + "if you use a log scale." nl; + exit (-1); + } + if (x_log_scale) + { + log_xmin = log (xmin); + log_xmax = log (xmax); + } + if (y_log_scale) + { + log_ymin = log (ymin); + log_ymax = log (ymax); + } + // We have the limits, Now plot. + plot_file.space (0, 0, plot_size, plot_size); + // draw a box around the data. + plot_file.linemod ("solid"); + if (grid_style) + plot_file.box (px (0.), py (0.), px (1.), py (1.)); + + char tick_label[32]; // tick lables are less than 16 digits long. +#ifdef _OLD_STREAMS +#define SET_TICK_LABEL(x) strcpy(tick_label, dtoa(x)) +#else + ostrstream tick_stream(tick_label, 32); +#define SET_TICK_LABEL(x) tick_stream.seekp(0), tick_stream << (x) << ends +#endif + // draw x tick marks. + if (grid_style) + { + // draw labels and ticks on x axis. + double x_tick, x_tick_value; + + if (x_log_scale) + { + double logmin = log10 (xmin); + double logmax = log10 (xmax); + x_tick = tick_interval (no_of_ticks, logmin, logmax); + x_tick_value = + pow (10., x_tick * (x_tick > 0. + ? ceil (logmin * A_HAIR_MORE / x_tick) + : floor (logmin * A_HAIR_MORE / x_tick))); + } + else + { + x_tick = tick_interval (no_of_ticks, xmin, xmax); + x_tick_value = x_tick + * (x_tick > 0. ? ceil (xmin * A_HAIR_MORE / x_tick) + : floor (xmin * A_HAIR_MORE / x_tick)); + } + while (x_tick_value <= xmax * A_HAIR_MORE) + { // tick marks on axes. + plot_file.line + (px (fx (x_tick_value)), py (0.), + px (fx (x_tick_value)), py (-1. * size_of_ticks)); + plot_file.line + (px (fx (x_tick_value)), py (1.), + px (fx (x_tick_value)), py (1. + size_of_ticks)); + SET_TICK_LABEL(x_tick_value); + plot_file.move + (px (fx (x_tick_value) - (extended_plot_format ? 0 : + .5 * char_width * strlen (tick_label))), + py ((x_label_on_top ? 1. : (extended_plot_format ? 0 : -1. + * char_height)) + + (x_label_on_top ? 1. : -1.) * ((size_of_ticks < 0.) ? 0. : size_of_ticks))); + if (extended_plot_format) + plot_file.alabel (CENTER_JUSTIFY, x_label_on_top ? BOTTOM_FLUSH + : TOP_FLUSH, tick_label); + else + plot_file.label (tick_label); + if (grid_style == 2) + { // grid across box. + plot_file.linemod ("shortdashed"); + plot_file.line + (px (fx (x_tick_value)), py (0.), + px (fx (x_tick_value)), py (1.)); + plot_file.linemod ("solid"); + } + if ((.5 < fx (x_log_scale ? pow (10., log10 (x_tick_value) + x_tick) + : x_tick_value + x_tick)) + && x_label.length ()) + { // put the label between tick marks + plot_file.move + (px (fx ((x_log_scale ? pow (10., log10 (x_tick_value)+x_tick/2.) + : x_tick_value + x_tick / 2.) + - (extended_plot_format ? 0 : + .5 * char_width * x_label.length ()))), + py ((x_label_on_top ? 1. : (extended_plot_format ? 0 : -1. + * char_height) + + (x_label_on_top ? 1. : -1.) * ((size_of_ticks < 0.) ? 0. : size_of_ticks)))); + if (extended_plot_format) + plot_file.alabel (CENTER_JUSTIFY, x_label_on_top ? BOTTOM_FLUSH + : TOP_FLUSH, x_label); + else + plot_file.label (x_label); + x_label = ""; + } + if (x_log_scale) + x_tick_value *= pow (10., x_tick); + else + x_tick_value += x_tick; + if (!x_log_scale && fabs (x_tick_value / x_tick) < 1e-7) + x_tick_value = 0.; + } + // draw labels and ticks on y axis. + double y_tick = tick_interval (no_of_ticks, ymin, ymax); + double y_tick_value = y_tick + * (y_tick > 0. ? ceil (ymin * A_HAIR_MORE / y_tick) + : floor (ymin * A_HAIR_MORE / y_tick)); + while (y_tick_value <= ymax * A_HAIR_MORE) + { // draw tick marks on axes + plot_file.line + (px (0.), py (fy (y_tick_value)), + px (-1. * size_of_ticks), py (fy (y_tick_value))); + plot_file.line + (px (1.), py (fy (y_tick_value)), + px (1. + size_of_ticks), py (fy (y_tick_value))); + SET_TICK_LABEL(y_tick_value); + plot_file.move + (px ((y_label_on_right ? 1. : (extended_plot_format ? 0 : -1. + * char_width * strlen(tick_label))) + + (y_label_on_right ? 1. : -1.) * ((size_of_ticks < 0.) ? 0. : size_of_ticks)), + py (fy (y_tick_value) - .5 + * (extended_plot_format ? 0 : char_height))); + if (extended_plot_format) + plot_file.alabel (y_label_on_right ? LEFT_JUSTIFY : RIGHT_JUSTIFY, + CENTER_FLUSH, tick_label); + else + { + SET_TICK_LABEL(y_tick_value); + plot_file.label (tick_label); + } + if (grid_style == 2) + { // draw grid within box. + plot_file.linemod ("shortdashed"); + plot_file.line + (px (0.), py (fy (y_tick_value)), + px (1.), py (fy (y_tick_value))); + plot_file.linemod ("solid"); + } + if ((.5 < fy (y_tick_value + y_tick)) + && y_label.length ()) + { // put the label between tick marks + plot_file.move + (px ((y_label_on_right ? 1. : (extended_plot_format ? 0 : -1. + * char_width * strlen (y_label))) + + (y_label_on_right ? 1. : -1.) * ((size_of_ticks < 0.) ? 0. : size_of_ticks)), + py (fy (y_tick_value + y_tick / 2.))); + if (extended_plot_format) + plot_file.alabel (y_label_on_right ? LEFT_JUSTIFY + : RIGHT_JUSTIFY, CENTER_FLUSH, y_label); + else + plot_file.label (y_label); + y_label = ""; + } + y_tick_value += y_tick; + if (fabs (y_tick_value / y_tick) < 1e-7) y_tick_value = 0.; + } + if (top_label.length ()) // put label above plot. + { + plot_file.move + (px (.5 - (extended_plot_format ? 0 : + .5 * char_width * top_label.length ())), + py (1. + size_of_ticks)); + if (extended_plot_format) + plot_file.alabel (CENTER_JUSTIFY, BOTTOM_FLUSH, top_label); + else + plot_file.label (top_label); + } + } + + if (line_style >= 0) // set style of lines connecting data points. + plot_file.linemod (line_style_name[line_style % no_of_line_styles]); + + // draw all the points + if (point.length () <= 0) + return 0; // exit if there is no data. + i = point.low (); + int move = 1; // 1 means move to first point + double prev_x = point[i].x; + int clipped = 0; // 1 means we were outside the box. + if (line_style >= 0) // line_style == -1 means omit lines between points + while (i < point.fence ()) + { // break line if flag set and x < last x + if (point[i].x < prev_x) + { + if (switch_style) + { + line_style = line_style++; + plot_file.linemod (line_style_name[line_style % no_of_line_styles]); + } + if (break_flag) + move = 1; + } + if (in_box (point[i].x, point[i].y)) // clip out points outside the box + { + if (move) + { + move = 0; // only move once for the first point + plot_file.move (px (fx (point[i].x)), py (fy (point[i].y))); + } + else + if (clipped) + { + clipped = 0; + plot_file.move (px (clip (fx (point[i-1].x))), + py (clip (fy (point[i-1].y)))); + plot_file.cont (px (fx (point[i].x)), py (fy (point[i].y))); + } + else + plot_file.cont (px (fx (point[i].x)), py (fy (point[i].y))); + } + else + { + if (!clipped) + { + clipped = 1; + if (move) + { + move = 0; + plot_file.move (px (clip (fx (point[i].x))), + py (clip (fy (point[i].y)))); + } + else + plot_file.cont (px (clip (fx (point[i].x))), + py (clip (fy (point[i].y)))); + } + } + prev_x = point[i].x; + point.next (i); + } + // now draw all the symbols and data labels + plot_file.linemod ("solid"); + for (i = point.low (); i < point.fence (); point.next (i)) + { + if (in_box (point[i].x, point[i].y)) + { + if (point[i].label) + { + plot_file.move + (px (fx (point[i].x)), py (fy (point[i].y))); + if (extended_plot_format) + plot_file.alabel (CENTER_JUSTIFY, CENTER_FLUSH, point[i].label); + else + plot_file.label (point[i].label); + } + else if (default_label.length ()) + { + plot_file.move + (px (fx (point[i].x)), py (fy (point[i].y))); + if (extended_plot_format) + plot_file.alabel (CENTER_JUSTIFY, CENTER_FLUSH, default_label); + else + plot_file.label (default_label); + } + if (point[i].symbol >= 0) + { + point[i].symbol %= no_of_symbols; + for (int j=0; (END != symbol[point[i].symbol][j].operation); j++) + switch (symbol[point[i].symbol][j].operation) + { + case CONT: + plot_file.cont + (px (fx (point[i].x) + + symbol_size * symbol[point[i].symbol][j].x), + py (fy (point[i].y) + + symbol_size * symbol[point[i].symbol][j].y)); + break; + case MOVE: + plot_file.move + (px (fx (point[i].x) + + symbol_size * symbol[point[i].symbol][j].x), + py (fy (point[i].y) + + symbol_size * symbol[point[i].symbol][j].y)); + break; + case CIRCLE: + plot_file.circle + (px (fx (point[i].x)), py (fy (point[i].y)), + (int) (plot_size * width * symbol_size + * symbol[point[i].symbol][j].x)); + break; + case END: + ; + } + } + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/etc/graph/graph.tex b/gnu/lib/libg++/libg++/etc/graph/graph.tex new file mode 100644 index 00000000000..4d2c834d57d --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/graph.tex @@ -0,0 +1,401 @@ +\input texinfo @c -*-texinfo-*- +@setfilename graph.info +@settitle graph + +@ifinfo +This file documents graph, a utility for creating plot files. + +Copyright @copyright{} 1989 Free Software Foundation, Inc. +@end ifinfo + +@titlepage +@sp 10 +@center @titlefont{graph} +@sp 2 +@center A utility for creating plot files +@sp 2 +@vskip 0pt plus 1filll +Copyright @copyright{} 1989 Free Software Foundation +@end titlepage + +@node Top, Options, , (dir) +@chapter The @code{graph} Utility + +@code{graph} is a utility for creating plots from data. It reads ascii +data and writes a plot with axes and labels. You can specify labels and +ranges for the axes, and you can set the sizes and position of the plot +on the page. Each invocations of graph produces a single box with a set +of axes and data draw within. You can place an arbitrary number of +plots on the page by concatenating the plot output of each +invocation.@refill + +@menu +* Options:: Command line options for graph. +* Graph Examples:: How to use graph. +* plot2ps:: A GNU plot to postscript conversion utility. +@end menu + +@chapter Options at a glance +@table @samp +@item Option: +Description: + +@item -C +print copyright notice + +@item -D +binary double precision data + +@item -E +use extended plot file format + +@item -H CHARACTER_HEIGHT +fractional height of characters + +@item -I +binary integer data + +@item -K +Change symbol when each new line is stared. + +@item -L +Change line style when each new line is stared. + +@item -M [x|y] MARGIN +amount of margin between data and x or y axes. + +@item -N TICKS +number of tick marks on each axis + +@item -P SIZE +plot file coordinate range + +@item -S SYMBOL_NUMBER SYMBOL_SIZE +draw symbols at each point + +@item -T TICK_SIZE +fractional size of tick marks + +@item -W CHARACTER_WIDTH +fractional width of characters + +@item -X X_LABEL +label printed below the x axis + +@item -Y Y_LABEL +label printed right of the y axis + +@item -a STEP_SIZE LOWER_LIMIT +generate abscissa, read only y values + +@item -b +break lines whenever x decreases + +@item -c POINT_LABEL +default label printed at each point + +@item -d +print debugging information + +@item -g GRID_STYLE +draw a grid in the plot + +@item -h HEIGHT +fractional height of the plot + +@item -l TOP_LABEL +label printed above the plot + +@item -m LINE_MODE +solid and dashed lines + +@item -r RIGHT +move plot right by fractional amount + +@item -s +save the screen - do not erase + +@item -t +transpose x and y axes + +@item -u UP +move plot up by fractional amount + +@item -w WIDTH +fractional width of the plot + +@item -x [BTl] LOWER_LIMIT UPPER_LIMIT +labels on bottom or top, log scale, axis limits + +@item -y [LRl] LOWER_LIMIT UPPER_LIMIT +labels on left or right, log scale, axis limits + +@item -z +do not read data from standard input +@end table + +@node Options, Graph Examples, Top, Top +@chapter Command Line Options +The following table describes each of the command line arguments to graph. +Each option which takes an argument is followed by the type and default +values of the argument in parentheses. + +@table @samp +@item -C +Print out the GNU copyright notice.@refill +@item -D +Read double precision binary data rather than ascii data. +Since @code{graph} is generally I/O bound, this can decrease execution +time.@refill +@item -E +Use an extended plot file format. This provides automatic adjustment of +labels with respect to tick marks. The @samp{-H} and @samp{-W} options +are ignored if @samp{-E} is specified. You will need the GNU plot +utility @code{plot2ps} in oder to print the output.@refill +@item -H +(double, default .03) The fractional height of printed characters. This +value is used to adjust location of labels with respect to the tick +marks.@refill +@item -I +Read integer binary data rather than ascii data.@refill +@item -K +Change symbol when each new line is stared. A new line is started +whenever the abscissal (x) value decreases and the @samp{-b} option is +specified. The symbol number is incremented through the values show in +the table below (see @samp{-S}).@refill +@item -L +Change line style when each new line is stared. As in @samp{-K}, the +line style number is incremented through the values shown in the table +below (see @samp{-m}).@refill +@item -M @samp{[x|y]} @var{margin} +(double, default 0 for x and .05 for y) @var{margin} is the fractional +amount of margin between the data and the horizontal or vertical edges +of the box. A value of .05 for y produces a space which is 5% of the +height of the box, placed above and below the data.@refill +@item -M +amount of margin between data and x or y axes. +@item -N @var{ticks} +(integer, default 5) @var{ticks} is the minimum number of tick marks for +each axis. @code{graph} tries to pick as few digits as possible for +tick mark labels and uses at least this many tick marks.@refill +@item -P @var{size} +(integer, default 4096) @var{size} is the upper limit on coordinate +values in the plot file @code{graph} creates. For devices with higher +resolution, this value can be increased. A value of 4096 is sufficient +for 300 dot per inch devices such as laser writers. This limit on the +values of coordinates (0 to @var{size}) output by @code{graph} is +rigidly enforced to prevent unpredictable behaviors by device drivers +such as @code{plot}.@refill +@item -S @var{symbol_number} @var{symbol_size} +(integer and float, defaults -1 and 0.01) Draw a symbol at each point in +the data. @var{symbol_number} specifies the shape of the symbol +according to the following table and @var{symbol_size} specifies the +fractional size of the symbol with respect to the height and width of +the plot. Note that you can specify sybols to be drawn without any line +connecting them by specifying the option @code{-m -1}.@refill +@table @asis +@item -1 no symbol at all +@item 0 plus sign +@item 1 cross +@item 2 diamond +@item 3 square +@item 4 triangle +@item 5 circle +@item 6 circle with a line through it +@end table +@item -T @var{tick_size} +(float, default .01) @var{tick_size} is the fractional size of the tick +marks on each axis. A value of 1.0 produces tick marks on the x (y) +axis whose length is equal to the width (height) of the plot.@refill +@item -W +(double, default .02) The fractional width of printed characters. Like +the @samp{-H} option, this value is used to adjust location of labels +with respect to the tick marks.@refill +@item -X @var{x_label} +(string, default blank) @var{x_label} is a label printed below the x +axis.@refill +@item -Y @var{y_label} +(string, default blank) @var{y_label} is a label printed to the right of +the y axis.@refill +@item -a @var{step_size} @var{lower_limit} +(floats, defaults 1 and 0) Automaticly generate abscissa (x) values. +This option specifies that the data contains only ordinate (y) values. +@var{step_size} specifies the interval between neighboring points and +@var{lower_limit} specifies the first abscissa (x) value.@refill +@item -b +Break the lines in the graph whenever the abscissa (x) values +decrease. Several curves with monotonically increasing abscissa +values can be concatenated and fed to graph using this option.@refill +@item -c @var{point_label} +(string, default blank) @var{point_label} is the default label placed at +each point in the plot when none is read from the input for that point. +That is, labels read from the input are printed instead of the default +whenever they are present.@refill +@item -d +Debugging information, including the data read in, is sent to the +standard error output. This is useful for double checking binary data +files.@refill +@item -g @var{grid_style} +(integer, default 1) @var{grid_style} specifies the type of box framing +the plot and whether grid lines are drawn inside the box.@refill +@table @asis +@item 0 no box around plot, no axes, no labels. +@item 1 box around plot, axes with tick marks and labels. +@item 2 box containing a grid and axes with tick marks and labels. +@end table +@item -h @var{height} +(float, default 0.8) @var{height} specifies the fractional height of the +plot with respect to the height of the plotting area. A value of 1.0 +will produce a box which fills the available area. Note that the tick +marks and labels are outside this area so that values less than 1.0 are +generally used.@refill +@item -l @var{top_label} +(string, default blank) @var{top_label} is a label placed above the +plot.@refill +@item -m @var{line_mode} +(integer, default 0) @var{line_mode} specifies the mode (or style) of +lines drawn between data points.@refill +@table @asis +@item -1 no line at all +@item 0 solid +@item 1 longdashed +@item 2 dotted +@item 3 disconnected +@item 4 dotdashed +@item 5 shortdashed +@end table +@item -r @var{right} +(float, default 0.1) Move the plot to the right by a fractional amount +@var{right} with respect to the width of the plotting area. This +produces a margin on the left hand side of the plot. A value of 0.5 +will produce a margin half the width of the available area. Note that +the tick marks and labels are drawn in the margin.@refill +@item -s +Save the screen. This option prevent graph from erasing the previous +contents of the graphics window or device.@refill +@item -t +Transpose the axes and axis labels. This option flips the plot over by +interchanging x and y values and labels.@refill +@item -u @var{up} +(float, default 0.1) Move the plot up by a fractional amount @var{up} +with respect to the height of the plotting area. This produces a margin +below the plot. A value of 0.5 will produce a margin half the height of +the available area. Note that the tick marks and labels are drawn in +the margin.@refill +@item -w @var{width} +(float, default 0.8) @var{width} specifies the fractional width of the +plot with respect to the width of the plotting area. A value of 1.0 +will produce a box which fills the available area. Note that the tick +marks and labels are outside this area, so values less than 1.0 are +generally used.@refill +@item -x @samp{[BTl]} @var{lower_limit} @var{upper_limit} +(char, floats) Labels for the tick marks are placed on the top or bottom +of the plot when @samp{B} or @samp{T} are specified respectively. The +default position is the bottom. @samp{l} is optional and specifies that +a logarithmic scale be used for the x axis, by default a linear scale is +used. Each of these option letters must be listed seperately, and +seperated from the other letters or options by white space characters. +The arguments @var{lower_limit} and @var{upper_limit} specify the limits +of the x axis. By default the upper and lower limits are taken from the +data.@refill +@item -y @samp{[LRl]} @var{lower_limit} @var{upper_limit} +Labels for the tick marks are placed on the left or right of the plot +when @samp{L} or @samp{R} are specified respectively. The default +position is the right. The other arguments specify the scale and limits +of the y axis as those do for the x axis above.@refill +@item -z +Do not read data from the standard input. You can specify input files +on the command line. @code{graph} prints the file names and point +numbers when it encounters error in ascii input files. If input files are +named and contain one coordinate per line in the file axis whose length +is equal to the width (height) of the plot you can use the emacs +@code{next-error} function to locate the source of the error.@refill +@end table + +@node Graph Examples, plot2ps, Options, Top +@chapter @code{graph} Examples + +@section The format of input to @code{graph} +@code{graph} reads in ascii data. Most often, the data is in the form +of pairs of x and y values:@refill +@example +0.0 0.0 +1.0 0.2 +2.0 0.0 +3.0 0.4 +4.0 0.2 +5.0 0.6 +@end example + +You can add labels to specific data points by appending a string after +the y coordinate. The label ends at the end of the line:@refill +@example +3.0 0.4 this is a label for point (3.0, 0.4). +@end example + +Using the @samp{-b} option, you can put more than one data set in the +input as long as each is monotonic in x values and decreases from the +end of one set to the start of the next:@refill +@example +0.0 0.0 first data set +2.0 0.0 +4.0 0.2 +0.0 0.1 second data set +2.0 0.2 +4.0 0.3 +@end example + +If your data contains only y values which are equally sampled along the x +axis, you can use the @samp{-a} option to specify the x axis values +implicitly.@refill +@example +0.0 +0.1 +0.2 label for point (2.0, 0.2) +0.3 +0.2 +0.3 +@end example + +@section How to put multiple plots on one page + +The command +@example +graph -h .4 -w .4 -r .1 -u .1 < ascii_data_file_1 > plot_file +@end example + +will put a single box containing the plot in the lower left hand +quarter of the page. You can add another plot to the upper left hand +corner of the page using the command +@example +graph -h .4 -w .4 -r .1 -u .6 < ascii_data_file_2 >> plot_file +@end example + +Likewise you can add plots to the right hand side of the page using +@example +graph -h .4 -w .4 -r .6 -u .1 < ascii_data_file_3 >> plot_file +graph -h .4 -w .4 -r .6 -u .6 < ascii_data_file_4 >> plot_file +@end example + +The tick marks can be moved inside the box and labels moved to the +opposite sides using +@example +graph -T -.005 -x T -y L < ascii_data_file >> plot_file +@end example + +@node plot2ps,, Graph Examples, Top +@section The @code{plot2ps} Utility + +@code{plot2ps} is a utility for converting Unix plot files into +postscript. The @code{plot2ps} utility reads plotting commands from +named files or the standard input and writes postscript to the standard +output. You can then print the postscript output on a printer, or edit +it using the @code{idraw} graphics editor. You can also easily include +the output in LaTeX documents using the @code{dvi2ps} utility and the +LaTeX command @code{psfig}.@refill + +The source code and documentation for @code{plot2ps} and a more complete +description of this are available via anonymous ftp from qed.rice.edu +(128.42.4.38) in the directory @file{/pub}. +@contents +@bye diff --git a/gnu/lib/libg++/libg++/etc/graph/pdefs.h b/gnu/lib/libg++/libg++/etc/graph/pdefs.h new file mode 100644 index 00000000000..725c88cdfd1 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/pdefs.h @@ -0,0 +1,9 @@ +// -*- C++ -*- +struct point +{ + double x, y; // x and y coordinates + char *label; // label attched to coordinates. + int symbol; // index of symbol drawn at corrdinates. +}; + +#define DEFAULT_INITIAL_CAPACITY 1024 diff --git a/gnu/lib/libg++/libg++/etc/graph/read_data.cc b/gnu/lib/libg++/libg++/etc/graph/read_data.cc new file mode 100644 index 00000000000..25aa739aa71 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/read_data.cc @@ -0,0 +1,114 @@ +#include "read_data.h" + +// READ_DATA reads ascii (or binary) data from an istream of +// coordinates and labels. It passes back the array of points (x, y, +// and label) containing the data. + +void +read_data (istream& in, char* in_filename, pointXPlex &pplex, + int auto_abscissa, double x_start, + double delta_x, int &symbol_number, + data_type input_data, int switch_symbols) +{ + char next_char; // next character to be read + point p; // the point we are currently reading in. + p.label = (char *) 0; // binary files contain no labels. + double prev_x = -DBL_MAX; // the previous x value. + + if (auto_abscissa) + x_start -= delta_x; + + if (input_data == ASCII) + { // input contains ascii data + while (in.good ()) + { + if (auto_abscissa) + p.x = x_start = x_start + delta_x; + else + in >> p.x >> WS; + if (switch_symbols && (p.x < prev_x)) + symbol_number++; + prev_x = p.x; + + in >> p.y; + if (!in.good ()) // if we read x but not y complain. + { + char *input_line; + in.clear (); + in.gets (&input_line); + // if the input contains one coordinate per line + // you win here --- emacs can find the source + // line from this error message. + cerr << in_filename << ":" << 2 + pplex.high() + << ": unable to read the" sp 2 + pplex.high() + << ((2 + pplex.high() == 1) ? "st" : "th") + << " y coordiate.\n"; + if (input_line) + if (strlen (input_line)) + cerr << in_filename << ":" << 2 + pplex.high() + << ": unexpected `" << input_line << "'\n"; + break; + } + in >> WS; // skip white space after y coordinate + p.label = (char *) 0; // by default there is no label + in.get (next_char); // look ahead for a label + if (in.good ()) + { + in.putback (next_char); + if (!isdigit (next_char) // if a lable is found + && (next_char != '.') + && (next_char != '+') + && (next_char != '-')) + { + in.gets (&p.label); // store it with x and y + } + in >> WS; // skip white space after label + } + p.symbol = symbol_number; + pplex.add_high (p); + } + return; + } + + if (input_data == DOUBLE) + { // input contains binary double precision + while (in.good ()) + { + if (auto_abscissa) + p.x = x_start = x_start + delta_x; + else + { + in.read (&p.x, sizeof(p.x)); + if (switch_symbols && (p.x < prev_x)) + symbol_number++; + prev_x = p.x; + } + in.read (&p.y, sizeof(p.y)); + p.symbol = symbol_number; + if (in.good ()) + pplex.add_high (p); + } + } + if (input_data == INT) + { // input contains binary integers + int i; + while (in.good ()) + { + if (auto_abscissa) + p.x = x_start = x_start + delta_x; + else + { + in.read (&i, sizeof(i)); + p.x = i; + if (switch_symbols && (p.x < prev_x)) + symbol_number++; + prev_x = p.x; + } + in.read (&p.y, sizeof(p.y)); + p.symbol = symbol_number; + if (in.good ()) + pplex.add_high (p); + } + } + return; +} diff --git a/gnu/lib/libg++/libg++/etc/graph/read_data.h b/gnu/lib/libg++/libg++/etc/graph/read_data.h new file mode 100644 index 00000000000..fe5990b2555 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/read_data.h @@ -0,0 +1,27 @@ +// -*- C++ -*- +// READ_DATA reads ascii (or binary) data from an istream (or File) of +// coordinates and labels. It passes back the array of points (x, y, +// and label) containing the data. + +#ifndef read_data_h +#define read_data_h 1 + +#include +#include +#include +#include "pXPlex.h" +#include + +#define sp <<" "<< +#define nl <<"\n" + +// data_type value indicates the type of data present in the input files. +typedef enum { ASCII, DOUBLE, INT } data_type; + +// read ascii binary data from a file +void +read_data (istream& in, char* in_filename, pointXPlex &pplex, + int auto_abscissa, double x_start, + double delta_x, int &symbol_number, + data_type input_data, int switch_symbols); +#endif diff --git a/gnu/lib/libg++/libg++/etc/graph/test.dat b/gnu/lib/libg++/libg++/etc/graph/test.dat new file mode 100644 index 00000000000..698e2d4bc51 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/test.dat @@ -0,0 +1,99 @@ +0.020000 0.029996 +0.040000 0.059968 +0.060000 0.089892 +0.080000 0.119744 +0.100000 0.149500 +0.120000 0.179136 +0.140000 0.208628 +0.160000 0.237952 +0.180000 0.267084 +0.200000 0.296000 +0.220000 0.324676 +0.240000 0.353088 +0.260000 0.381212 +0.280000 0.409024 +0.300000 0.436500 +0.320000 0.463616 +0.340000 0.490348 +0.360000 0.516672 +0.380000 0.542564 +0.400000 0.568000 +0.420000 0.592956 +0.440000 0.617408 +0.460000 0.641332 +0.480000 0.664704 +0.500000 0.687500 +0.520000 0.709696 +0.540000 0.731268 +0.560000 0.752192 +0.580000 0.772444 +0.600000 0.792000 +0.620000 0.810836 +0.640000 0.828928 +0.660000 0.846252 +0.680000 0.862784 +0.700000 0.878500 +0.720000 0.893376 +0.740000 0.907388 +0.760000 0.920512 +0.780000 0.932724 +0.800000 0.944000 +0.820000 0.954316 +0.840000 0.963648 +0.860000 0.971972 +0.880000 0.979264 +0.900000 0.985500 +0.920000 0.990656 +0.940000 0.994708 +0.960000 0.997632 +0.980000 0.999404 +1.000000 1.000000 +1.020000 0.999404 +1.040000 0.997632 +1.060000 0.994708 +1.080000 0.990656 +1.100000 0.985500 +1.120000 0.979264 +1.140000 0.971972 +1.160000 0.963648 +1.180000 0.954316 +1.200000 0.944000 +1.220000 0.932724 +1.240000 0.920512 +1.260000 0.907388 +1.280000 0.893376 +1.300000 0.878500 +1.320000 0.862784 +1.340000 0.846252 +1.360000 0.828928 +1.380000 0.810836 +1.400000 0.792000 +1.420000 0.772444 +1.440000 0.752192 +1.460000 0.731268 +1.480000 0.709696 +1.500000 0.687500 +1.520000 0.664704 +1.540000 0.641332 +1.560000 0.617408 +1.580000 0.592956 +1.600000 0.568000 +1.620000 0.542564 +1.640000 0.516672 +1.660000 0.490348 +1.680000 0.463616 +1.700000 0.436500 +1.720000 0.409024 +1.740000 0.381212 +1.760000 0.353088 +1.780000 0.324676 +1.800000 0.296000 +1.820000 0.267084 +1.840000 0.237952 +1.860000 0.208628 +1.880000 0.179136 +1.900000 0.149500 +1.920000 0.119744 +1.940000 0.089892 +1.960000 0.059968 +1.980000 0.029996 diff --git a/gnu/lib/libg++/libg++/etc/graph/test2.dat b/gnu/lib/libg++/libg++/etc/graph/test2.dat new file mode 100644 index 00000000000..036723ebeba --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/test2.dat @@ -0,0 +1,5 @@ +0 0 +1 1 label for 1 1 +2 2 +3 3 label for 3 3 +4 4 diff --git a/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.cc b/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.cc new file mode 100644 index 00000000000..50773f9f1d6 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.cc @@ -0,0 +1,39 @@ +#include "tick_intrvl.h" + +// TICK_INTERVAL returns the step size which can be used to put a +// specified NO_OF_TICKS beteen the specified UPPER_LIMIT and LOWER_LIMIT. + +double +tick_interval (double no_of_ticks, double &lower_limit, double &upper_limit) +{ + if (lower_limit == upper_limit) + { // make sure the range is nonzero. + if (lower_limit == 0.) + { + lower_limit = -1.; // this is the traditional behavior of graph. + upper_limit = 1.; + } + else + { + lower_limit *= .9; + upper_limit *= 1.1; + } + } + // compute interval for tick marks. + double exp = 1.; + int i = (int) floor (log10 (fabs (upper_limit - lower_limit)) * A_HAIR_MORE); + for (; 0 < i; i--) exp *= 10.; + for (; 0 > i; i++) exp /= 10.; + double mant = (upper_limit - lower_limit) / exp; + + double interval = 10.; + double stepsize = 1.; + while (interval * (no_of_ticks - 1.) > fabs (mant) * A_HAIR_MORE) + { + if (interval - stepsize <= 0.) stepsize /= 10.; + interval -= stepsize; + } + interval *= exp; + if (mant < 0.) interval = - interval; + return interval; +} diff --git a/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.h b/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.h new file mode 100644 index 00000000000..d004848a662 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/graph/tick_intrvl.h @@ -0,0 +1,12 @@ +#include "math.h" + +// The resolution of the output device is much less than seven digits. +// A_HAIR_MORE is used to ingore the effects of round off error which should +// occur in the last few of the 16 digits. +#define A_HAIR_MORE 1.0000001 + +// TICK_INTERVAL returns the step size which can be used to put a +// specified NO_OF_TICKS beteen the specified UPPER_LIMIT and LOWER_LIMIT. + +double +tick_interval (double no_of_ticks, double &lower_limit, double &upper_limit); diff --git a/gnu/lib/libg++/libg++/etc/lf/ChangeLog b/gnu/lib/libg++/libg++/etc/lf/ChangeLog new file mode 100644 index 00000000000..b9193de1b19 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/ChangeLog @@ -0,0 +1,59 @@ +Tue Oct 18 17:49:35 1994 Per Bothner + + * scrren.c: Don't define termcap functions #ifdef __linux__. + +Tue Oct 4 16:34:51 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * screen.cc: Remove use of tputs (portability problems). + +Sun Feb 6 22:13:48 1994 Jason Merrill (jason@deneb.cygnus.com) + + * entry.cc (new): Don't define reallocish new. + + * entry.h (new): Define reallocish new. + +Sun Apr 25 20:28:33 1993 Per Bothner (bothner@cygnus.com) + + Changes (mostly from Peter Schauer) to permit compilation + using cfront 3.0 and otherwise be ARM-conforming. + * directory.cc (Directory_Handler::print): Use integer as + loop variable, not enum. + * entry.cc (Entry_Handler::print_entries): + Don't depend on gcc-specific variable-sized auto arrays. + * entry.cc (Entry_Handler::add_entry): Fix to use new-style + 'new' placement syntax. + * entry.cc (Entry_Handler::add_entry), sort.cc (insert_sort): + Don't use non-standard >?= operator. + * entry.h, entry.cc (Entry_Handler::default_entries): Always + make static, independent of gcc-version. + * entry.cc (operator new): Don't define if not gcc. + +Nov 17 22:10:32 1992 Per Bothner (bothner@rtl.cygnus.com) + + * screen.cc: If hpux, don't declare termcap functions (i.e. + tgetent()) - conflicting definitions get pulled in by curses.h. + +Thu Nov 5 21:40:50 1992 Per Bothner (bothner@rtl.cygnus.com) + + * directory.[h,cc}: Renmamed UNKNOWN enum -> UNKNOWN_FILE, + to avoid conflict with UNKNOWN in svr3 curses.h. + +Sun Nov 1 16:02:13 1992 Per Bothner (bothner@cygnus.com) + + * entry.h: Use "new" placement syntax (as in + 'new (ARGS) TYPE'), unless _G_OLD_PLACEMENT. + +Thu Aug 6 12:45:46 1992 Per Bothner (bothner@rtl.cygnus.com) + + * directory.h (enum Directory_Handler::file_types), + directory.cc (Directory_Handler::class_name and + Directory_Handler constructor): Added UNKNOWN file type. + * directory.cc (Directory_Handler constructor): Make + more portable, including compatibility with Posix. + +Fri Jun 26 11:41:54 1992 Per Bothner (bothner@rtl.cygnus.com) + + * screen.h, screen.cc: Change fputchar from static + method to normal function, since it is passed to tputs. + Remove duplicateted method definitions (that used to depend + on __OPTIMIZE__). Add prototypes for termcap functions. diff --git a/gnu/lib/libg++/libg++/etc/lf/Dirent.cc b/gnu/lib/libg++/libg++/etc/lf/Dirent.cc new file mode 100644 index 00000000000..73bcbc721c5 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/Dirent.cc @@ -0,0 +1,107 @@ +/* Define a portable UNIX directory-entry manipulation interface. + + This code is heavily based upon Doug Gwyn's public domain directory-access + routines written in C. Hacked into C++ conformance for the GNU libg++ + library by Douglas C. Schmidt (schmidt@ics.uci.edu). */ + +#include +#include "Dirent.h" + +// error handlers + +void verbose_Dirent_error_handler(const char* msg) +{ + perror(msg); + errno = 0; +} + +void quiet_Dirent_error_handler(const char*) +{ + errno = 0; +} + +void fatal_Dirent_error_handler(const char* msg) +{ + perror(msg); + exit(1); +} + +one_arg_error_handler_t Dirent_error_handler = verbose_Dirent_error_handler; + + +one_arg_error_handler_t set_Dirent_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = Dirent_error_handler; + Dirent_error_handler = f; + return old; +} + +#ifndef __OPTIMIZE__ + +/* Initialize the directory-entry control block from the given DIRNAME. + Equivalent to opendir (). */ + +Dirent::Dirent (char *dirname) +{ + if ((dirp = ::opendir (dirname)) == 0) + (*Dirent_error_handler) ("Dirent::Dirent"); +} + +/* Frees up the dynamically allocated buffer. */ + +Dirent::~Dirent (void) +{ + ::closedir (dirp); +} + +/* Re-initialize the directory-entry control block from the given DIRNAME. + Equivalent to opendir (). */ + +void +Dirent::opendir (char *dirname) +{ + if ((dirp = ::opendir (dirname)) == 0) + (*Dirent_error_handler) ("Dirent::Dirent"); +} + +/* Read next entry from a directory stream. */ + +struct dirent * +Dirent::readdir (void) +{ + return ::readdir (dirp); +} + +/* Close a directory stream. */ + +void +Dirent::closedir (void) +{ + ::closedir (dirp); +} + +/* Rewind a directory stream. */ + +void +Dirent::rewinddir (void) +{ + ::seekdir (dirp, long (0)); +} + +/* Reposition a directory stream. */ + +void +Dirent::seekdir (long loc) +{ + ::seekdir (dirp, loc); +} + +/* Report directory stream position. */ + +long +Dirent::telldir (void) +{ + return ::telldir (dirp); +} + +#endif // __OPTIMIZE__ diff --git a/gnu/lib/libg++/libg++/etc/lf/Dirent.h b/gnu/lib/libg++/libg++/etc/lf/Dirent.h new file mode 100644 index 00000000000..65606331ab9 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/Dirent.h @@ -0,0 +1,93 @@ +/* Define a portable UNIX directory-entry manipulation interface. + + This code is heavily based upon Doug Gwyn's public domain directory-access + routines. Hacked into C++ conformance by Doug Schmidt (schmidt@ics.uci.edu). */ + +#include +#include +#include +#include + +#ifdef rewinddir +#undef rewinddir +#endif + +class Dirent +{ +private: + DIR *dirp; + +public: + Dirent (char *dirname); + ~Dirent (void); + struct dirent *readdir (void); + void opendir (char *filename); + void closedir (void); + long telldir (void); + void seekdir (long loc); + void rewinddir (void); +}; + +// error handlers + +extern void verbose_Dirent_error_handler(const char*); +extern void quiet_Dirent_error_handler(const char*); +extern void fatal_Dirent_error_handler(const char*); +extern one_arg_error_handler_t Dirent_error_handler; +extern one_arg_error_handler_t set_Dirent_error_handler(one_arg_error_handler_t); + +// OPTIMIZE + +#ifdef __OPTIMIZE__ + +inline +Dirent::Dirent (char *dirname) +{ + if ((dirp = ::opendir (dirname)) == 0) + (*Dirent_error_handler) ("Dirent::Dirent"); +} + +inline +Dirent::~Dirent (void) +{ + ::closedir (dirp); +} + +inline void +Dirent::opendir (char *dirname) +{ + if ((dirp = ::opendir (dirname)) == 0) + (*Dirent_error_handler) ("Dirent::Dirent"); +} + +inline struct dirent * +Dirent::readdir (void) +{ + return ::readdir (dirp); +} + +inline void +Dirent::closedir (void) +{ + ::closedir (dirp); +} + +inline void +Dirent::rewinddir (void) +{ + ::seekdir (dirp, long (0)); +} + +inline void +Dirent::seekdir (long loc) +{ + ::seekdir (dirp, loc); +} + +inline long +Dirent::telldir (void) +{ + return ::telldir (dirp); +} + +#endif // __OPTIMIZE__ diff --git a/gnu/lib/libg++/libg++/etc/lf/Makefile.in b/gnu/lib/libg++/libg++/etc/lf/Makefile.in new file mode 100644 index 00000000000..1fafbdd1f0b --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/Makefile.in @@ -0,0 +1,29 @@ +# +# Makefile for lf +# +# If you move this makefile, update the variable below +# or else depend won't work. + +MAKEFILE = Makefile + +CFILES = lf.cc entry.cc screen.cc option.cc \ + directory.cc sort.cc Dirent.cc +HFILES = entry.h screen.h option.h \ + directory.h Dirent.h +OFILES = lf.o entry.o screen.o option.o \ + directory.o sort.o Dirent.o +PROGRAM = lf +DEPEND_SOURCES = $(srcdir)/*.cc + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +$(PROGRAM): $(OFILES) + $(CXX) $(OFILES) -o $(PROGRAM) $(LIBS) -ltermcap + +check: lf + @true +# lf dies on Irix. Perhaps incompatible directory routines? +# ./lf + +run_tests: check diff --git a/gnu/lib/libg++/libg++/etc/lf/configure.in b/gnu/lib/libg++/libg++/etc/lf/configure.in new file mode 100644 index 00000000000..5ae26d6b2dc --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=directory.h +srcname="libg++/etc/lf" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core lf' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/lf/depend b/gnu/lib/libg++/libg++/etc/lf/depend new file mode 100644 index 00000000000..475f7c71793 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/depend @@ -0,0 +1,28 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +Dirent.o : Dirent.cc \ + Dirent.h +directory.o : directory.cc \ + Dirent.h \ + option.h \ + entry.h \ + screen.h \ + directory.h +entry.o : entry.cc \ + entry.h \ + screen.h +lf.o : lf.cc \ + option.h \ + screen.h \ + directory.h \ + entry.h +option.o : option.cc \ + option.h +screen.o : screen.cc \ + screen.h +sort.o : sort.cc + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/lf/directory.cc b/gnu/lib/libg++/libg++/etc/lf/directory.cc new file mode 100644 index 00000000000..ac579ad1cf1 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/directory.cc @@ -0,0 +1,97 @@ +#include +#include +#include "Dirent.h" +#include "option.h" +#include "entry.h" +#include "directory.h" + +/* Provided in the main driver program. */ +extern Option_Handler option; + +/* Names used to print out various file classes. */ +char *Directory_Handler::class_name[Directory_Handler::MAX_TYPES] = +{ + "Directory", "Regular", "Executable", "Directory Link", "File Link", "Symbolic Link", "Unknown" +}; + +/* Read each file in the current directory, and enter it into + the correct file class according to its file type. + Then, for each file class, sort the class entries by + name and print them to the standard output. */ + +Directory_Handler::Directory_Handler (void) +{ + Dirent directory ("."); + file_types file_type; + + /* "." always works, since a chdir is performed earlier if a + user-specified directory was supplied on the command-line. */ + + if (!option[HIDDEN]) + { + /* Skip the first two directory entries ("." and ".."). This + is fast, but potentially non-portable. Does this fail + on anyone's system? If so, I'll change it (barf). */ + directory.readdir (); + directory.readdir (); + } + + /* Main loop in program. Read each directory entry, classify it + according to its type, then enter it into the appropriate table slot. */ + + for (struct dirent *dir_buf; dir_buf = directory.readdir (); ) + { + if (!option[HIDDEN] && *dir_buf->d_name == '.') + continue; + + struct stat stat_buf; + +#if !defined(S_ISLNK) && defined(S_IFLNK) +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#endif +#ifndef S_ISLNK +#define lstat stat +#endif + lstat (dir_buf->d_name, &stat_buf); + if (S_ISREG(stat_buf.st_mode)) + { +#ifdef S_IEXEC + if (stat_buf.st_mode & S_IEXEC) + file_type = EXECS; + else +#endif + file_type = FILES; + } +#ifdef S_ISLNK + else if (S_ISLNK(stat_buf.st_mode)) { + if (option[LINK]) // Either a file or directory link + { + stat (dir_buf->d_name, &stat_buf); + file_type = S_ISDIR(stat_buf.st_mode) ? DLINKS : FLINKS; + } + else + file_type = LINKS; + } +#endif + else if (S_ISDIR(stat_buf.st_mode)) + file_type = DIRS; + else + file_type = UNKNOWN_FILE; + + file_class[file_type].add_entry (dir_buf->d_name, + strlen (dir_buf->d_name)); + } +} + +/* Sort file class entries and print them to stdout. */ + +void +Directory_Handler::print (void) +{ + for (int i = 0; i < MAX_TYPES; i++) + if (file_class[i].entry_number () > 0) + { + file_class[i].sort_entries (); + file_class[i].print_entries (class_name[i]); + } +} diff --git a/gnu/lib/libg++/libg++/etc/lf/directory.h b/gnu/lib/libg++/libg++/etc/lf/directory.h new file mode 100644 index 00000000000..0652b9907b6 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/directory.h @@ -0,0 +1,33 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* Manipulate all directory entries for all file classes. */ +#ifndef directory_h +#define directory_h 1 +#include "entry.h" + +class Directory_Handler +{ +public: + /* There are five major types of files in the UNIX system. */ + enum file_types + { + DIRS, /* Subdirectories. */ + FILES, /* Regular files. */ + EXECS, /* Executable files. */ + DLINKS, /* Directory links (if -l option is enabled). */ + FLINKS, /* File links (if -l option is enabled). */ + LINKS, /* File *and* directory links (if -l option is *not* enabled). */ + UNKNOWN_FILE, /* E.g. Fifo */ + MAX_TYPES + }; + + Directory_Handler (void); /* Formats the current directory files. */ + void print (void); /* Lists the current directory files. */ + + private: + +/* static */ Entry_Handler file_class[MAX_TYPES]; /* File class array. */ + static char *class_name[MAX_TYPES]; /* String naem for each file class. */ + +}; +#endif diff --git a/gnu/lib/libg++/libg++/etc/lf/entry.cc b/gnu/lib/libg++/libg++/etc/lf/entry.cc new file mode 100644 index 00000000000..0aaf6db07c1 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/entry.cc @@ -0,0 +1,94 @@ +/* Manipulate directory entries of a particular file class. */ +#include +#include "entry.h" + +/* Initially provide a medium-sized file entry size. */ +const int Entry_Handler::default_entries = 50; + +/* Print entries to standard output. The algorithm used to format the files + in columns is subtle, and worth studying in some detail. */ + +void +Entry_Handler::print_entries (char *class_name) +{ + const int width = Screen_Handler::screen_width (); + const int ncols = width / (max_entry_length + 1); + const int nrows = (entries + ncols - 1) / ncols; + const int max = nrows * (entries - (nrows - 1) * ncols); +#if defined (__GNUC__) && ! defined (__STRICT_ANSI__) + char buffer[width]; +#else + char *buffer = new char[width]; +#endif + int row; + + /* Print out the file class name, nicely centered and in inverse video. */ + sprintf (buffer, "[ %d %s File%s ]", entries, class_name, entries == 1 ? "" : "s"); + Screen_Handler::print_inverse_centered (buffer); + +#ifndef __GNUC__ + delete [] buffer; +#endif + + /* Take care of everything but the (possibly non-existent) final row. */ + + for (row = 0; row < nrows - 1; row++) + { + /* This loop is subtle, since we don't want to process too many entries.... */ + + for (int col = row; col < entries; col += col < max ? nrows : nrows - 1) + printf ("%-*s", max_entry_length + 1, buf[col]); + + putchar ('\n'); + } + /* Treat the final row specially, if it exists. */ + + for (; row < max; row += nrows) + printf ("%-*s", max_entry_length + 1, buf[row]); + + putchar ('\n'); +} + +/* Only compile these functions if -O is *not* enabled. */ + +#ifndef __OPTIMIZE__ + +/* Initialize a new file class. */ + +Entry_Handler::Entry_Handler (void) +{ + entries = max_entry_length = 0; + total_entries = default_entries; + buf = new char *[default_entries]; +} + +/* Current number of file entries. */ + +int +Entry_Handler::entry_number (void) +{ + return entries; +} + +/* Add an entry to the file class. */ + +void +Entry_Handler::add_entry (char *entry_name, int length) +{ + /* Grow the buffer on overflow. */ + if (entries >= total_entries) + buf = new (buf, total_entries *= 2) char *; + if (max_entry_length < length) + max_entry_length = length; + buf[entries++] = strcpy (new char[length + 1], entry_name); +} + +/* Sort entries by filename. */ + +void +Entry_Handler::sort_entries (void) +{ + sort (buf, entries); +} + +#endif // __OPTIMIZE__ diff --git a/gnu/lib/libg++/libg++/etc/lf/entry.h b/gnu/lib/libg++/libg++/etc/lf/entry.h new file mode 100644 index 00000000000..12c701e3217 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/entry.h @@ -0,0 +1,81 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* Manipulate directory entries of a particular file class. */ +#ifndef entry_h +#define entry_h 1 +#include +#include +#include "screen.h" + +/* Defined in sort.cc. */ +void sort (char **base_ptr, int total_elems); + +class Entry_Handler +{ + +private: + /* Initial number of file entries per class. */ + static const int default_entries; + + int max_entry_length; /* Size of largest filename. */ + int total_entries; /* Total number of filenames. */ + int entries; /* Current number of filenames. */ + char **buf; /* Buffer containing filenames for this file class. */ + +public: + Entry_Handler (void); /* Initialize a new file class. */ + int entry_number (void); /* Current number of entries. */ + void add_entry (char *entry_name, int length); /* Add an entry to the class. */ + void sort_entries (void); /* Sort entries by filename. */ + void print_entries (char *class_name); /* Print file entries. */ +}; + +/* See comments in the .cc file for the following inline functions */ + +#ifdef __OPTIMIZE__ +inline +Entry_Handler::Entry_Handler (void) +{ + entries = max_entry_length = 0; + total_entries = default_entries; + buf = new char *[default_entries]; +} + +inline int +Entry_Handler::entry_number (void) +{ + return entries; +} + +inline void * +operator new (size_t size, void *orig, int number) +{ + return realloc (orig, size * number); +} + +inline void +Entry_Handler::add_entry (char *entry_name, int length) +{ + if (entries >= total_entries) +#ifdef _G_OLD_PLACEMENT + buf = new {buf, total_entries *= 2} char *; +#else + buf = new (buf, total_entries *= 2) char *; +#endif +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + max_entry_length >?= length; +#else + if (length > max_entry_length) + max_entry_length = length; +#endif + buf[entries++] = strcpy (new char[length + 1], entry_name); +} + +inline void +Entry_Handler::sort_entries (void) +{ + sort (buf, entries); +} + +#endif // __OPTIMIZE__ +#endif diff --git a/gnu/lib/libg++/libg++/etc/lf/lf.cc b/gnu/lib/libg++/libg++/etc/lf/lf.cc new file mode 100644 index 00000000000..5d2df9b8a2f --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/lf.cc @@ -0,0 +1,23 @@ +/* Driver program for directory listing facility. */ +/* Type the -h option for program usage information. */ +#include "option.h" +#include "screen.h" +#include "directory.h" + +/* Manages program options, globally visible to other modules. */ +Option_Handler option; + +/* Initializes the screen object. */ +Screen_Handler screen; + +/* Set the program options and turn over the dirty work + to the main directory handling module. */ + +int +main (int argc, char *argv[]) +{ + option (argc, argv); + Directory_Handler files; + files.print (); + return 0; +} diff --git a/gnu/lib/libg++/libg++/etc/lf/option.cc b/gnu/lib/libg++/libg++/etc/lf/option.cc new file mode 100644 index 00000000000..e7ce1f7b259 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/option.cc @@ -0,0 +1,65 @@ +/* Process directory listing program options. */ +#include +#include +#include +#include "option.h" + +/* Initialize the program options. */ + +unsigned Option_Handler::option_word; +char * Option_Handler::program_name; + +Option_Handler::Option_Handler (void) +{ + option_word = 0; +} + +/* Prints program usage to standard error stream, then exits. */ + +void +Option_Handler::usage (void) +{ + fprintf (stderr, "usage: %s [-ahl] [directory]\n", program_name); + exit (1); +} + +/* Sets the program options. */ + +void +Option_Handler::operator () (int argc, char *argv[]) +{ + GetOpt getopt (argc, argv, "ahl"); + int option_char; + + program_name = argv[0]; + + while ((option_char = getopt ()) != EOF) + switch (option_char) + { + case 'a': /* Print out hidden files (those starting with '.'). */ + option_word |= HIDDEN; + break; + case 'l': + option_word |= LINK; + break; + case 'h': /* Print help message and exit. */ + default: + usage (); + } + + /* Change the working directory if default is not ".". This saves + time during the directory entry decoding phase. */ + + if (argv[getopt.optind]) + chdir (argv[getopt.optind]); +} + +#ifndef __OPTIMIZE__ +/* TRUE if OPTION enable, else FALSE. */ + +int +Option_Handler::operator[] (option_type option) +{ + return option_word & option; +} +#endif // __OPTIMIZE__ diff --git a/gnu/lib/libg++/libg++/etc/lf/option.h b/gnu/lib/libg++/libg++/etc/lf/option.h new file mode 100644 index 00000000000..d0e51d0d833 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/option.h @@ -0,0 +1,35 @@ +// This may look like C code, but it is really -*- C++ -*- +#ifndef option_h +#define option_h 1 + +/* Process directory listing program options. */ + +/* Enumeration of all directory listing options. */ +enum option_type +{ + HIDDEN = 01, /* Print hidden files (those beginning with '.') */ + LINK = 02 /* Distinguish between directory and file links. */ +}; + +class Option_Handler +{ +private: + static unsigned option_word; /* Compact bitwise-storage for program options. */ + static char *program_name; /* Name of listing program. */ + static void usage (void); /* Prints usage then exits. */ + +public: + Option_Handler (void); /* Initialize options. */ + void operator() (int argc, char *argv[]); /* Process command-line options. */ + int operator[] (option_type option); /* Check if option is enabled. */ +}; + +/* Speed things up a bit if we're optimizing. */ +#ifdef __OPTIMIZE__ +inline int +Option_Handler::operator[] (option_type option) +{ + return option_word & option; +} +#endif // __OPTIMIZE__ +#endif diff --git a/gnu/lib/libg++/libg++/etc/lf/screen.cc b/gnu/lib/libg++/libg++/etc/lf/screen.cc new file mode 100644 index 00000000000..8bcf6e8ce8c --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/screen.cc @@ -0,0 +1,61 @@ +/* Handles screen manipulations for screen width and inverse mode. */ +#include "screen.h" + +#if !defined(hpux) && !defined(__linux__) +extern "C" int tgetent(void *, const char *); +extern "C" int tgetnum(const char*); +extern "C" char *tgetstr(const char *, char**); +#endif + +/* Initializes the current screen width via + the terminal independent operation routines. */ + +char Screen_Handler::term_entry[1024]; +char Screen_Handler::temp_buf[100]; +int Screen_Handler::width; +char * Screen_Handler::current_ptr; +char * Screen_Handler::inverse_start; +char * Screen_Handler::inverse_end; + +Screen_Handler::Screen_Handler (void) +{ + if (tgetent (term_entry, getenv ("TERM")) != 1) + { + perror ("main"); + exit (1); + } + else + { + width = tgetnum ("co") - 1; + current_ptr = temp_buf; + inverse_start = tgetstr("so", ¤t_ptr); + inverse_end = tgetstr("se", ¤t_ptr); + } +} + + +/* Prints out leading blanks so as to center buf + assuming a screen width of width. */ + +void +Screen_Handler::center (char *buf) +{ + int offset; + int len = strlen (buf); + + offset = width - len >> 1; + + for (int i = 0; i < offset; i++) + putchar (' '); +} + +/* Centers, ``inverse-videos'' and prints buf. */ + +void +Screen_Handler::print_inverse_centered (char *buf) +{ + putchar ('\n'); + center (buf); + /* Should use tputs, but some systems have a bad prototype for it. */ + printf ("%s%s%s\n\n", inverse_start, buf, inverse_end); +} diff --git a/gnu/lib/libg++/libg++/etc/lf/screen.h b/gnu/lib/libg++/libg++/etc/lf/screen.h new file mode 100644 index 00000000000..a5ecb5c02ab --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/screen.h @@ -0,0 +1,37 @@ +// This may look like C code, but it is really -*- C++ -*- +#ifndef screen_h +#define screen_h 1 +#include +#include +#include + + + +/* Handles necessary screen-manipultations. */ +class Screen_Handler +{ + private: + static char term_entry[1024]; /* Holds termcap entry for current terminal. */ + static char temp_buf[100]; /* Holds inverse screen attributes. */ + static int width; /* Current screen width, needed to format output. */ + static char *current_ptr; /* Pointer to current position in temp_buf. */ + static char *inverse_start; /* Control sequence beginning inverse mode. */ + static char *inverse_end; /* Control sequence ending inverse mode. */ + + static void center (char *buf); /* Prints out leading spaces to center BUF. */ + +public: + Screen_Handler (void); /* Initialize the screen width. */ + static int screen_width (void); /* Return current screen width. */ + static void print_inverse_centered (char *buf); /* Centers, inverts, and prints BUF. */ +}; + +/* See comments in .cc file for inline functions. */ + +/* Returns current screen width. */ +inline int +Screen_Handler::screen_width (void) +{ + return width; +} +#endif diff --git a/gnu/lib/libg++/libg++/etc/lf/sort.cc b/gnu/lib/libg++/libg++/etc/lf/sort.cc new file mode 100644 index 00000000000..f45b1b99e93 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/lf/sort.cc @@ -0,0 +1,181 @@ +#include +#include +#include + +/* the next 6 #defines implement a very fast in-line stack abstraction */ + +#define MAX_STACK_SIZE 32 +#define DISPOSE_STACK(S) (free(S)) +#define PUSH(LOW,HIGH) do {top->lo = LOW;top++->hi = HIGH;} while (0) +#define POP(LOW,HIGH) do {LOW = (--top)->lo;HIGH = top->hi;} while (0) +#define STACK_NOT_EMPTY (stack < top) +#define SWAP(A,B) do {char *_temp = (A);(A) = (B);(B) = _temp;} while (0) + +/* Discontinue quicksort algorithm when partition gets below this size. + This particular magic number was chosen to work best on a Sun 4/260. */ +#define MAX_THRESH 30 + +/* Data structure for stack of unfulfilled obligations. */ +typedef struct +{ + char **lo; + char **hi; +} stack_node; + +/* Once main array is partially sorted by quicksort the remainder is + completely sorted using insertion sort, since this is efficient + for partitions below MAX_THRESH size. BASE points to the beginning + of the array to sort, and END_PTR points at the very last element in + the array (*not* one beyond it!). */ + +inline static void +insert_sort (char **base_ptr, char **end_ptr) +{ + char **run_ptr; + char **tmp_ptr = base_ptr; +#if defined (__GNUC__) && ! defined (__STRICT_ANSI__) + char **thresh = end_ptr end_ptr) + thresh = end_ptr; +#endif + + /* Find the smallest element in the first threshold and put it at the + end of the array. This is guaranteed to be the smallest element in + the array, and it speeds up the inner loop of insertion sort. */ + + for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr++) + if (strcmp (*run_ptr, *tmp_ptr) < 0) + tmp_ptr = run_ptr; + + SWAP (*tmp_ptr, *base_ptr); + + /* Typical insertion sort, but we run from the `right-hand-side' + downto the `left-hand-side.' */ + + for (run_ptr = base_ptr + 1; run_ptr < end_ptr; run_ptr++) + { + char *temp = *(tmp_ptr = run_ptr + 1); + + /* Select the correct location for the new element, + by sliding everyone down by 1 to make room! */ + + while (strcmp (temp, *--tmp_ptr) < 0) + tmp_ptr[1] = *tmp_ptr; + + tmp_ptr[1] = temp; + } +} + +/* Return the median value selected from among the + LOW, MIDDLE, and HIGH. Rearrange LOW and HIGH so + the three values are sorted amongst themselves. + This speeds up later work... */ + +inline static char * +find_pivot (char **low, char **high) +{ + char **middle = low + ((high - low ) >> 1); + + if (strcmp (*middle, *low) < 0) + SWAP (*middle, *low); + if (strcmp (*high, *middle) < 0) + SWAP (*middle, *high); + else + return *middle; + + if (strcmp (*middle, *low) < 0) + SWAP (*middle, *low); + + return *middle; +} + +/* Order elements using quicksort. This implementation incorporates + 4 optimizations discussed in Sedgewick: + + 1. Non-recursive, using an explicit stack of log (n) pointers that + indicate the next array partition to sort. + + 2. Choses the pivot element to be the median-of-three, reducing + the probability of selecting a bad pivot value. + + 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving + insertion sort to sort within the partitions. This is a + big win, since insertion sort is faster for small, mostly + sorted array segements. + + 4. The larger of the 2 sub-partitions are always pushed onto the + stack first, with the algorithm then concentrating on the + smaller partition. This *guarantees* no more than log (n) + stack size is needed! */ + +void +sort (char **base_ptr, int total_elems) +{ + if (total_elems > MAX_THRESH) + { + char **lo = base_ptr; + char **hi = lo + (total_elems - 1); + char **left_ptr; + char **right_ptr; + stack_node stack[MAX_STACK_SIZE]; + stack_node *top = stack + 1; + + while (STACK_NOT_EMPTY) + { + /* Select the median-of-three here. This allows us to + skip forward for the LEFT_PTR and RIGHT_PTR. */ + char *pivot = find_pivot (lo, hi); + left_ptr = lo + 1; + right_ptr = hi - 1; + + /* Here's the famous ``collapse the walls'' section of + quicksort. Gotta like those tight inner loops! */ + do + { + while (strcmp (*left_ptr, pivot) < 0) + left_ptr++; + + while (strcmp (pivot, *right_ptr) < 0) + right_ptr--; + + if (left_ptr < right_ptr) + { + SWAP (*left_ptr, *right_ptr); + left_ptr++; + right_ptr--; + } + else if (left_ptr == right_ptr) + { + left_ptr++; + right_ptr--; + break; + } + } + while (left_ptr <= right_ptr); + + if ((right_ptr - lo) <= MAX_THRESH) + { + if ((hi - left_ptr) <= MAX_THRESH) /* ignore both small tables */ + POP (lo, hi); + else /* ignore small left table */ + lo = left_ptr; + } + else if ((hi - left_ptr) <= MAX_THRESH) /* ignore small right table */ + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) + { /* push larger left table */ + PUSH (lo, right_ptr); + lo = left_ptr; + } + else + { /* push larger right table */ + PUSH (left_ptr, hi); + hi = right_ptr; + } + } + } + + insert_sort (base_ptr, base_ptr + (total_elems - 1)); +} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/ChangeLog b/gnu/lib/libg++/libg++/etc/trie-gen/ChangeLog new file mode 100644 index 00000000000..4d1eb2edb74 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/ChangeLog @@ -0,0 +1,132 @@ +Wed Apr 26 17:08:49 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * options.cc (report_error): Wrap the init of `callback' with braces. + +Fri May 13 19:07:25 1994 Jason Merrill (jason@deneb.cygnus.com) + + * trie.cc (Trie::sort): add `const' as needed to make conformant. + +Sun Feb 6 22:22:09 1994 Jason Merrill (jason@deneb.cygnus.com) + + * compact.cc: Include renew.h + * trie.cc: Ditto. + + * renew.h (new): Define reallocish new. + +Mon Oct 25 18:51:56 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * main.cc: Don't bother increasing the stack size. + +Tue Sep 28 15:54:48 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * main.cc: #include before . + (Problem reported by Jeffrey A Law .) + +Fri Jun 4 18:42:24 1993 Per Bothner (bothner@cygnus.com) + + * compact.cc, trie.cc: If 'char' is unsigned, write + explicit 'signed char' for tables of signed chars. + +Sun Apr 25 20:04:18 1993 Per Bothner (bothner@cygnus.com) + + Changes (mostly from Peter Schauer) to permit compilation + using cfront 3.0 and otherwise be ARM-conforming. + * compact.cc (operator new): Don't depend on gcc-specific + pointer arithmetic on (void*). + * compact.{h,cc}, trie.{h,cc}: Replace MAX_UNSIGNED_CHAR, + MAX_UNSIGNED_SHORT, MAX_SIGNED_CHAR, and MAX_SIGNED_SHORT + by CHAR_MAX, USHRT_MAX, SCHAR_MAX, and SHRT_MAX from . + * compact.cc, trie.cc: Removed _G_OLD_PLACEMENT (old-style + 'new' placement syntax) support. + * compact.cc: Remove dependency on gcc-specific >? (max) + operator. + * trie.h (Trie::MAX_ASCII): Replaced by global in trie.cc. + * compact.h, compat.cc: Ditto for MAX_ASCII_RANGE. + * compact.h: Removed MAX_INT. + * trie.h (Trie::Trie): Gave default value for parameter, + allowing us to get rid of the const field DEFAULT_SIZE. + * main.cc (main): Renamed variable Trie to trie. + * test.cc: Add #include (for strlen). + +Wed Dec 30 16:48:08 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Don't pass -1 flag to 'ls' (unless LS_1 + is overridden), as some versions of ls don't support it, + and those that do don't seem to need it. + * main.cc: Use _G_HAVE_SYS_RESOURCE before including + and doing the rlimit stuff. + +Mon Dec 21 18:12:31 1992 Per Bothner (bothner@rtl.cygnus.com) + + * compact.cc: Fix to avoid evaluation order dependencies. + +Mon Nov 30 16:51:33 1992 Per Bothner (bothner@cygnus.com) + + * trie.h (class Trie), compact.h (class Compact_Matrix, + class Compact_Matrix::Row_Node), compact.cc (new method + Compact_Matrix::init): Don't use no-longer-allowed + initialized non-const fields; use constructors instead. + +Tue Nov 17 22:00:15 1992 Per Bothner (bothner@rtl.cygnus.com) + + * compact.cc: ANSIfy: bcopy->memcpy, bzero->memset, + * compact.cc (Compact_Matrix::first_fit_decreasing): Re-write + dubious memory allocation using alloca to use + malloc/realloc/free. This supposedly fixes an HPUX problem. + * trie.cc (Trie::output): Fix to avoid const/non-const + warning when compiling generated output. + +Sun Nov 1 15:58:19 1992 Per Bothner (bothner@cygnus.com) + + * trie.cc, compact.cc: Use "new" placement syntax + (as in 'new (ARGS) TYPE'), unless _G_OLD_PLACEMENT. + * compact.cc: ANSI-fy: bcopy->memcpy etc. + * Makefile.in: Minor fixes related to using $(C++). + +Sat Mar 7 08:48:53 1992 Michael Tiemann (tiemann@cygnus.com) + + * options.c: Several methods of the class `Options' remained from + an earlier implementation. They have now been removed. + +Sun Mar 1 17:03:43 1992 Per Bothner (bothner@cygnus.com) + + * trie.h (Trie::Trie): Initialize current_size field. + * Makefile.in: Add 'check' rule. + +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 1 13:40:04 1992 Per Bothner (bothner at cygnus.com) + + * Rename test.c to test.cc (avoids some problems in + getting the wrong include files). + +Fri Feb 23 19:44:10 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Added the `-h' option to print out a verbose help message. + + * Added a check in Trie::output that ensures the program doesn't + crash if no keywords are given! + + * Implemented the -f (generate full trie) option. This is useful + to generate another example program for my USENIX C++ paper! + + * Removed the member field `compact_output' from class Trie. + Changed all uses of this variable to option[COMPACT]. Why + was it ever done the other way anyhow?! + + * Added the `-C' CONST option so that user's can declare strings in + the generated lookup table to be readonly. + +Fri Feb 16 10:47:02 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Killed some debugging code in compact.cc (operator new). + +Thu Feb 15 23:20:44 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Fixed a bunch of incredibly stupid errors. (I can't believe + this thing even worked before...). That's what happens when you + don't hack for 2 months ;-( diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/Makefile.in b/gnu/lib/libg++/libg++/etc/trie-gen/Makefile.in new file mode 100644 index 00000000000..22037eb8f63 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/Makefile.in @@ -0,0 +1,56 @@ +# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc. +# written by Douglas C. Schmidt (schmidt@ics.uci.edu) +# +# This file is part of GNU TRIE-GEN. +# +# GNU TRIE-GEN is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GNU trie-gen is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +srcdir = . + +OBJS = trie.o compact.o main.o version.o options.o +DEPEND_SOURCES = $(srcdir)/*.cc + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +trie-gen: $(OBJS) + $(CXX) -o $@ $(OBJS) $(LIBS) + +LS_1 = /bin/ls # -1 default on most systems, not supported on all. + +out.cc: trie-gen + @echo "Generating a compacted minimal-prefix trie for files in /bin" + $(LS_1) /bin | ./trie-gen -c > out.cc + +check: out.o test.o + $(CXX) out.o test.o $(LIBS) + $(LS_1) /bin | ./a.out -v + +run_tests: check + +distrib: + (cd ..; rm -f trie-gen.tar.Z; tar cvf trie-gen.tar trie-gen; \ + compress trie-gen.tar) + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +compact.o : $(srcdir)/compact.cc $(srcdir)/compact.h +main.o : $(srcdir)/main.cc $(srcdir)/options.h $(srcdir)/trie.h $(srcdir)/compact.h +options.o : $(srcdir)/options.cc $(srcdir)/options.h +trie.o : $(srcdir)/trie.cc $(srcdir)/trie.h $(srcdir)/compact.h +version.o : $(srcdir)/version.cc + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/compact.cc b/gnu/lib/libg++/libg++/etc/trie-gen/compact.cc new file mode 100644 index 00000000000..21c5c004012 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/compact.cc @@ -0,0 +1,405 @@ +/* Compact a sparse 2-D matrix. Uses the Tarjan and Yao algorithm + taken from the article ``Storing a Sparse Table'' in CACM, 1979. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include "renew.h" +#include "compact.h" + +/* Essentially provides the functionality of `calloc.' */ + +static inline void * +operator new (size_t elem_size, int size) +{ + void *temp = new char[elem_size * size]; + memset (temp, 0, elem_size * size); + return temp; +} + +/* Essentially combines the functionality of `realloc' and `calloc'. */ + +static inline void * +operator new (size_t elem_size, void *old_ptr, int old_size, int new_size) +{ + old_ptr = new (old_ptr, new_size * elem_size) char; + memset ((char*)old_ptr + old_size * elem_size, 0, + (new_size - old_size) * elem_size); + return old_ptr; +} + +/* Initializes the internal form in the case that the user passes + in a pointer to an already existing 2-dimensional matrix. Note + that by declaring the matrix to be a 1-dimensional array we + can perform the col and row offset calculations ourselves and + handle matrices with fixed, but arbitrary-sized columns and rows. */ + +Compact_Matrix::Compact_Matrix (ITEM_TYPE *mat, int rows, int cols): + matrix (mat), max_rows (rows), total_cols (cols), current_rows (rows) +{ + init (rows); + + for (int i = 0; i < max_rows; i++) + for (int j = 0; j < total_cols; j++) + if (matrix[i * total_cols + j] != 0) + { + ITEM_TYPE value = matrix[i * total_cols + j]; + total_entries++; + row_vec[i].count++; + row_vec[i].col_list = new Column_Node (row_vec[i].col_list, j, value); + } +} + +/* Initializer for the case where we don't have a previously created + matrix to play with. DEFAULT_ROWS represents the best first + approximation as to the number of rows in the matrix. However, this + buffer is resized as needed, so the algorithm isn't overly penalized + for a bad first guess. */ + +Compact_Matrix::Compact_Matrix (int default_rows): max_rows (default_rows) +{ + current_rows = 0; + total_cols = 0; + matrix = 0; + + init (default_rows); +} + +void Compact_Matrix::init(int rows) +{ + max_col_count = 0; + total_entries = 0; + compressed_len = -1; + row_offsets = 0; + checks = 0; + bucket_vec = 0; + values = 0; + + row_vec = rows ? new Row_Node[rows] : 0; +} + +/* Returns the `matrix[i][j]' item in the sparse 2-dimensional matrix. + Note that if the matrix is very sparse the number of items in each + COL_LIST will be very short, hence linear search is not too inefficent. */ + +ITEM_TYPE +Compact_Matrix::operator () (int i, int j) +{ + assert (i >= 0 && i < current_rows && j >= 0); + + for (Column_Node *col_list = row_vec[i].col_list; col_list; col_list = col_list->next) + if (col_list->index == j) + return col_list->value; + + return 0; +} + +/* Sets `matrix[i][j]' to VALUE. ROW_VEC is dynamically resized, if + necessary. At the moment the new entry is simply pushed onto the + linked list of COL_LIST entries. If there aren't many elements then + this will not be too inefficient for later retrieval. */ + +void +Compact_Matrix::operator () (int i, int j, ITEM_TYPE value) +{ + if (i >= max_rows) + resize (((max_rows * 2) > (i + 1)) ? (max_rows * 2) : (i + 1)); + row_vec[i].col_list = new Column_Node (row_vec[i].col_list, j, value); + total_entries++; + row_vec[i].count++; + if (current_rows < (i + 1)) + current_rows = i + 1; +} + +/* Enlarges the ROW_VEC from CURR_ROWS to NEW_SIZE. */ + +void +Compact_Matrix::resize (int new_size) +{ + Row_Node *temp = new Row_Node[max_rows = new_size]; + + memcpy ((void *) temp, (void *) row_vec, current_rows * sizeof *row_vec); + delete row_vec; + row_vec = temp; +} + +/* Calls the functions that compact the table and generate the resulting + lookup scheme. */ + +void +Compact_Matrix::output (void) +{ + bucket_sort (); + first_fit_decreasing (); + output_arrays (); + output_lookup (); +} + +/* Performs a bucket sort so that all rows with the same number of non-null + entries are treated as part of the same equivalence class. This + operation is very fast! */ + +void +Compact_Matrix::bucket_sort (void) +{ + int i; + for (i = 0; i < current_rows; i++) + { + if (max_col_count < row_vec[i].count) + max_col_count = row_vec[i].count; + } + + bucket_vec = new (max_col_count + 1) Column_Node *; + + for (i = 0; i < current_rows; i++) + bucket_vec[row_vec[i].count] = new Column_Node (bucket_vec[row_vec[i].count], i, 0); +} + +/* Useful macros to clarify subsequent code. They should probably be made + into member functions... */ +#define STARTING_ROW_OFFSET(X) (row_offsets[(X)]) +#define LARGEST_COL_VALUE(X) (row_vec[(X)].col_list->index) +#define COL_LIST(X) (row_vec[(X)].col_list) +#define COL_COUNT(X) (row_vec[(X)].count) +#define COL_INDEX(X) ((X)->index) +#define ROW_INDEX(X) ((X)->index) + +const int MAX_ASCII_RANGE = 128; + +/* Performs sparse 2-dimensional array compaction suitable for use with the + `double-offset indexing' (used by Bison and FLEX to compact the size of + the sparse LR parsing tables and DFA's). This function implements the + `first fit decreasing' heuristic described in Tarjan and Yao's paper + ``Storing a Sparse Table'' in CACM, 1979. */ + +void +Compact_Matrix::first_fit_decreasing (void) +{ + /* Bit-vector and counter that records if a row/col location is already set. */ + int current_max = current_rows + + ((total_cols > MAX_ASCII_RANGE) ? total_cols : MAX_ASCII_RANGE); + char *already_assigned = (char *) malloc (current_max); + + memset (already_assigned, 0, current_max); + row_offsets = new (current_rows) int; + values = new (current_max) ITEM_TYPE; + checks = new (current_max) int; + + for (int row_index = max_col_count; row_index >= 0; row_index--) + if (bucket_vec[row_index]) + + /* Process every row in the `equivalence class' of rows containing the + same number of non-null column entries. */ + + for (Column_Node *rows_list = bucket_vec[row_index]; rows_list; rows_list = rows_list->next) + { + int row = ROW_INDEX (rows_list); + int row_offset = STARTING_ROW_OFFSET (row); + Column_Node *col_list; + + /* Process every column index in the current row. */ + + for (col_list = COL_LIST (row); ;) + { + int col = COL_INDEX (col_list); + + /* If we exceed the boundaries it's time to resize various buffers. */ + if (row_offset + col >= current_max) + { + int new_size = ((current_max > (row_offset + col)) ? current_max : (row_offset + col)) * 2; + already_assigned = + (char *) realloc (already_assigned, new_size); + + memset (already_assigned + current_max, 0, + new_size - current_max); + values = new (values, current_max, new_size) int; + checks = new (checks, current_max, new_size) int; + current_max *= 2; + } + if (already_assigned[row_offset + col]) + { + /* Efficiency hack to skip over obvious collisions. */ + + while (++row_offset + col < current_max && already_assigned[row_offset + col]) + ; + + /* Reset col_list and begin again (with new row offset). */ + col_list = COL_LIST (row); + } + else if ((col_list = col_list->next) == 0) + break; + } + + /* No more collisions exist. Record the positions for the next round. */ + + for (col_list = COL_LIST (row); col_list; col_list = col_list->next) + { + int offset = row_offset + COL_INDEX (col_list); + + already_assigned[offset] = 1; + if (compressed_len < offset) + compressed_len = offset; + values[offset] = col_list->value; + checks[offset] = row; + } + + /* Need to reset this once all is said and done! */ + STARTING_ROW_OFFSET (row) = row_offset; + } + free(already_assigned); +} + +/* Generates the three arrays that comprise the `double-offset index' + scheme. This is a bit messy, since I'm trying to neatly format + the generated tables and also determine the smallest (in bytes) + type declarations necessary to represent the elements of the tables. */ + +void +Compact_Matrix::output_arrays () +{ + const int COL_WIDTH = 12; + int max_number = 0; + int count; + int i; + int field_width; + + printf ("#if !defined(__STDC__) && !defined(__cplusplus)\n"); + printf ("#define const\n"); + printf ("#define signed\n"); + printf ("#endif\n\n"); + printf ("#define YY_LAST %d\n", compressed_len); + + for (i = 0; i < current_rows; i++) + { + if (max_number < row_offsets[i]) + max_number = row_offsets[i]; + } + + count = max_number; + for (field_width = 1; (count /= 10) > 0; field_width++) + ; + + printf ("\nstatic const unsigned %s yy_rows[%d] = \n{\n ", + max_number < UCHAR_MAX ? "char" : max_number < USHRT_MAX ? "short" : "int", + current_rows); + + for (i = 0; i < current_rows; i++) + printf ("%*d,%s", field_width, row_offsets[i], (i + 1) % COL_WIDTH ? " " : "\n "); + + max_number = 0; + + for (i = 0; i < compressed_len + 1; i++) + { + if (max_number < checks[i]) + max_number = checks[i]; + } + + count = max_number; + for (field_width = 1; (count /= 10) > 0; field_width++) + ; + + printf ("\n};\n\nstatic const unsigned %s yy_check[%d] = \n{\n ", + max_number < UCHAR_MAX ? "char" : max_number < USHRT_MAX ? "short" : "int", + compressed_len + 1); + + for (i = 0; i < compressed_len + 1; i++) + printf ("%*d,%s", field_width, checks[i], (i + 1) % COL_WIDTH ? " " : "\n "); + + max_number = 0; + + for (i = 0; i < compressed_len + 1; i++) +#ifdef __GNUC__ + max_number >?= abs (values[i]); +#else + { + int tmp = abs (values[i]); + if (max_number < tmp) + max_number = tmp; + } +#endif + + count = max_number; + for (field_width = 2; (count /= 10) > 0; field_width++) + ; + + printf ("\n};\n\nstatic const %s yy_next[%d] = \n{\n ", + max_number < SCHAR_MAX ? (CHAR_MIN == 0 ? "signed char" : "char") + : max_number < SHRT_MAX ? "short" : "int", + compressed_len + 1); + + for (i = 0; i <= compressed_len; i++) + printf ("%*d,%s", field_width, values[i], (i + 1) % COL_WIDTH ? " " : "\n "); + + printf ("\n};\n\n"); +} + +/* Generates the `double-offset index' function, that provides the + value stored in the location referenced by parameters ROW and COL. */ + +void +Compact_Matrix::output_lookup (void) +{ + printf ("static inline int\nnext_state " + "(int row, int col)\n{\n int state_index = yy_rows[row] + col;\n\n" + " if (state_index > YY_LAST || yy_check[state_index] != row)\n " + "return 0;\n else\n return yy_next[state_index];\n}\n"); +} + +/* Useful debugging routine. */ + +void +Compact_Matrix::dump_entries (void) +{ + for (int i = 0; i < current_rows; i++) + if (row_vec[i].col_list) + { + Column_Node *temp = row_vec[i].col_list; + + fprintf (stderr, "row %d's count = %d, cols = ", i, row_vec[i].count); + + do { fprintf (stderr, "%d ", temp->index); } while (temp = temp->next); + + putc ('\n', stderr); + } +} + +/* Useful debugging routine. */ + +void +Compact_Matrix::dump_bucket (void) +{ + for (int i = 0; i < total_entries; i++) + if (bucket_vec[i]) + { + Column_Node *temp = bucket_vec[i]; + + fprintf (stderr, "bucket %d = ", i); + + do { fprintf (stderr, "%d ", temp->index); } while (temp = temp->next); + + putc ('\n', stderr); + } +} + diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/compact.h b/gnu/lib/libg++/libg++/etc/trie-gen/compact.h new file mode 100644 index 00000000000..5175424f279 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/compact.h @@ -0,0 +1,78 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Compact a sparse 2-D matrix. Uses the Tarjan and Yao algorithm + taken from the article ``Storing a Sparse Table'' in CACM, 1979. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This really should go in the class scope, but alas g++ doesn't like that... */ +typedef int ITEM_TYPE; + +class Compact_Matrix +{ +public: + Compact_Matrix (ITEM_TYPE *mat, int rows, int cols); + Compact_Matrix (int default_rows = 0); + ITEM_TYPE operator () (int i, int j); + void operator () (int i, int j, ITEM_TYPE value); + void output (void); + +private: + + void init(int rows); + + struct Column_Node + { + int index; /* Actual column index in the current row. */ + ITEM_TYPE value; /* Value at this index location. */ + Column_Node *next; /* Pointer to next column in the row. */ + + Column_Node (Column_Node *p, int i, ITEM_TYPE v) + : index (i), value (v), next (p) { } + }; + + struct Row_Node + { + Column_Node *col_list; // List of column index values for this row. + int count; // Count of total number of columns in the list. + Row_Node() { col_list = 0; count = 0; } + }; + + int max_col_count; /* Total number of columns in largest row. */ + int total_cols; /* Total number of columns in the matrix (if applicable). */ + int total_entries; /* Total number of non-null entries in the matrix. */ + int compressed_len; /* Size of the compacted matrix buffer. */ + int *row_offsets; /* Dynamic buffer used for double-offset indexing. */ + int *checks; /* Dynamic buffer used for double-offset indexing. */ + int current_rows; /* Current items in ROW_VEC, at this point. */ + int max_rows; /* Maximum size of ROW_VEC, at this point. */ + Row_Node *row_vec; /* Dynamic buffer indexed by row number. */ + Column_Node **bucket_vec; /* Dynamic buffer used to sort by column count. */ + ITEM_TYPE *values; /* Dynamic buffer containing non-null matrix values. */ + ITEM_TYPE *matrix; /* Pointer to 2-D matrix (if appropriate). */ + + void resize (int new_size); + void first_fit_decreasing (void); + void bucket_sort (void); + void output_lookup (void); + void output_arrays (void); + void dump_entries (void); + void dump_bucket (void); +}; diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/configure.in b/gnu/lib/libg++/libg++/etc/trie-gen/configure.in new file mode 100644 index 00000000000..ac824bcc30d --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=trie.h +srcname="libg++/etc/trie-gen" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core trie-gen out.cc a.out' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/depend b/gnu/lib/libg++/libg++/etc/trie-gen/depend new file mode 100644 index 00000000000..719acb15798 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/depend @@ -0,0 +1,25 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +compact.o : compact.cc \ + compact.h +main.o : main.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + options.h \ + trie.h \ + compact.h +options.o : options.cc \ + options.h +test.o : test.cc +trie.o : trie.cc \ + options.h \ + trie.h \ + compact.h +version.o : version.cc \ + version.cc + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/main.cc b/gnu/lib/libg++/libg++/etc/trie-gen/main.cc new file mode 100644 index 00000000000..71d253e3cd5 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/main.cc @@ -0,0 +1,39 @@ +/* Driver routine for the minimal-prefix trie generator. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <_G_config.h> +#include +#include "options.h" +#include "trie.h" + +int +main (int argc, char **argv) +{ + option (argc, argv); + + Trie trie; + char *buf; + + for (int i = 0; cin.gets (&buf); i++) + trie.insert (buf, cin.gcount ()); + + trie.output (); +} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/options.cc b/gnu/lib/libg++/libg++/etc/trie-gen/options.cc new file mode 100644 index 00000000000..098a4a69286 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/options.cc @@ -0,0 +1,208 @@ +/* Handles parsing the Options provided to the user. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU TRIE-GEN. + +GNU TRIE-GEN is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU TRIE-GEN is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 TRIE-GEN; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include "options.h" + +/* Global option coordinator for the entire program. */ +Options option; + +/* Current program version. */ +extern char *version_string; + +static void +report_error (const char *format, ...) +{ + va_list args; + va_start (args, format); + char c; + + while (c = *format++) + { + if (c=='%') + switch (c = *format++) + { + case 'a': + exit (1); + case 'n': + fputs (option.program_name (), stderr); + break; + case 'e': + { + typedef void (*CallbackT) (void); + CallbackT callback = va_arg (args, CallbackT); + (*callback) (); + } + break; + case 's': + fputs (va_arg (args, const char *), stderr); + break; + default: + fputc (c, stderr); + } + else + fputc (c, stderr); + } + va_end (args); +} + +/* Prints program usage to standard error stream. */ + +inline void +Options::usage (void) +{ + report_error ("Usage: %n [-cdf] (type %n -h for help)\n"); +} + +/* Output command-line Options. */ + +void +Options::print_options (void) +{ + int i; + + printf ("/* Command-line: "); + + for (i = 0; i < argument_count; i++) + printf ("%s ", argument_vector[i]); + + printf (" */"); +} +/* Sets the default Options. */ + +int Options::option_word = 0; +int Options::argument_count = 0; +char ** Options::argument_vector = 0; + +Options::Options (void) +{ + option_word = 0; +} + +/* Dumps option status when debug is set. */ + +Options::~Options (void) +{ + if (option_word & DEBUG) + { + fprintf (stderr, "\ndumping Options:\nCOMPACT is.......: %s\nDEBUG is.......: %s" + "\nFULL is........: %s\nCONST is.......: %s", + option_word & COMPACT ? "enabled" : "disabled", + option_word & DEBUG ? "enabled" : "disabled", + option_word & FULL ? "enabled" : "disabled", + option_word & CONST ? "enabled" : "disabled"); + + fprintf (stderr, "\nfinished dumping Options\n"); + } +} + + +/* Parses the command line Options and sets appropriate flags in option_word. */ + +void +Options::operator () (int argc, char *argv[]) +{ + GetOpt getopt (argc, argv, "cCdfh"); + int option_char; + + argument_count = argc; + argument_vector = argv; + + while ((option_char = getopt ()) != EOF) + { + switch (option_char) + { + case 'c': /* Compact the output tables. */ + { + option_word |= COMPACT; + break; + } + case 'C': /* Make the generated tables readonly (const). */ + { + option_word |= CONST; + break; + } + case 'd': /* Enable debugging option. */ + { + option_word |= DEBUG; + report_error ("Starting program %n, version %s, with debuggin on.\n", + version_string); + break; + } + case 'f': /* Generate a full table */ + { + option_word |= FULL; + break; + } + case 'h': + { + report_error ("-c\tCompact the generated trie.\n" + "-C\tMake strings in the generated lookup table constant, i.e., readonly.\n" + "-d\tEnable debugging (produces verbose output to standard error).\n" + "-f\tGenerates a `full' trie rather than a minimal-prefix trie.\n" + "-h\tPrints out the help diagnostic.\n%a"); + } + default: + report_error ("%e%a", usage); + } + } + + if (argv[getopt.optind] && ! freopen (argv[getopt.optind], "r", stdin)) + report_error ("Unable to read key word file %s.\n%e%a", argv[getopt.optind], usage); + + if (++getopt.optind < argc) + report_error ("Extra trailing arguments to %n.\n%e%a", usage); +} + +#ifndef __OPTIMIZE__ +const char * +Options::program_name (void) +{ + return argument_vector[0]; +} + +/* TRUE if option enable, else FALSE. */ +int +Options::operator[] (Option_Type option) +{ + return option_word & option; +} + +/* Enables option OPT. */ +void +Options::operator= (enum Option_Type opt) +{ + option_word |= opt; +} + +/* Disables option OPT. */ +void +Options::operator!= (enum Option_Type opt) +{ + option_word &= ~opt; +} + +#endif /* not defined __OPTIMIZE__ */ + + diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/options.h b/gnu/lib/libg++/libg++/etc/trie-gen/options.h new file mode 100644 index 00000000000..efb188af7a0 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/options.h @@ -0,0 +1,93 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Handles parsing the Options provided to the user. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU TRIE-GEN. + +GNU TRIE-GEN is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU TRIE-GEN is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 TRIE-GEN; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This module provides a uniform interface to the various options available + to a user of the minimal-prefix trie generator. + The overall design of this module was an experiment in using C++ + classes as a mechanism to enhance centralization of option and + and error handling, which tend to get out of hand in a C program. */ + +#ifndef options_h +#define options_h 1 + +/* Enumerate the potential debugging Options. */ + +enum Option_Type +{ + DEBUG = 01, /* Enable debugging option. */ + COMPACT = 02, /* Compact the output tables. */ + FULL = 04, /* Generate a full table. */ + CONST = 010 /* Make the generated tables readonly (const). */ +}; + +/* Class manager for program options. */ + +class Options +{ +public: + Options (void); + ~Options (void); + const char *program_name (void); + int operator[] (Option_Type option); + void operator() (int argc, char *argv[]); + void operator= (enum Option_Type); + void operator!= (enum Option_Type); + static void print_options (void); + +private: + static int option_word; /* Holds the user-specified Options. */ + static int argument_count; + static char **argument_vector; + static void usage (void); /* Prints proper program usage. */ +}; + +/* Global option coordinator for the entire program. */ +extern Options option; + +#ifdef __OPTIMIZE__ +inline const char * +Options::program_name (void) +{ + return argument_vector[0]; +} + +inline int +Options::operator[] (Option_Type option) /* True if option enable, else false. */ +{ + return option_word & option; +} + +inline void +Options::operator = (enum Option_Type opt) /* Enables option OPT. */ +{ + option_word |= opt; +} + +inline void +Options::operator != (enum Option_Type opt) /* Disables option OPT. */ +{ + option_word &= ~opt; +} + +#endif +#endif diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/renew.h b/gnu/lib/libg++/libg++/etc/trie-gen/renew.h new file mode 100644 index 00000000000..f0809764f9c --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/renew.h @@ -0,0 +1,24 @@ +/* Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +inline void * +operator new (size_t size, void *orig, int number) +{ + return realloc (orig, size * number); +} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/test.cc b/gnu/lib/libg++/libg++/etc/trie-gen/test.cc new file mode 100644 index 00000000000..adfd0c9787b --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/test.cc @@ -0,0 +1,28 @@ +/* + Tests the generated perfect has function. + The -v option prints diagnostics as to whether a word is in + the set or not. Without -v the program is useful for timing. +*/ + +#include +#include + +#define MAX_LEN 200 + +char *in_word_set (const char *, int); + +int +main (int argc, char **argv) +{ + int verbose = argc > 1 ? 1 : 0; + char buf[MAX_LEN]; + char *s; + + while (gets (buf)) + if ((s = in_word_set (buf, strlen (buf))) && verbose) + printf ("%s is prefix for %s\n", buf, s); + else if (verbose) + printf ("NOT in word set %s\n", buf); + + return 0; +} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/trie-gen.1 b/gnu/lib/libg++/libg++/etc/trie-gen/trie-gen.1 new file mode 100644 index 00000000000..4eac48ef995 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/trie-gen.1 @@ -0,0 +1,113 @@ +.TH TRIE-GEN 1 "12 December 1989" "Version 1.0" +.de BP +.sp +.ti -.2i +\(** +.. +.SH NAME +trie-gen \- generate a minimal-prefix trie +.SH SYNOPSIS +.B trie-gen +[ +.B \-c +] < keyfile +.SH DESCRIPTION +.I TRIE-GEN +is a program that reads a user-specified set of keywords from standard +input and generates a minimal-prefix trie. Minimal-prefix tries have +several useful properties that make them efficient implementations for +static search sets. The table-driven trie generated by TRIE-GEN +recognizes keywords in the search set in time proportional to the +length of the shortest unambiguous prefix for a given keyword. + +Consider a command interpreter for an interactive debugger or +operating system shell (e.g., gdb or VMS). It is frequently nice to +allow users to type the `minimal unambiguous prefix' for any command +in the set of built-in keywords. For example, given the following +complete list of system commands: + +.nf +---------------------------------------- +bash +bison +diff +diff3 +egrep +flex +g++ +gawk +gcc +gdb +genclass +gnuchess +gnuplot +gperf +grep +indent +make +sed +---------------------------------------- +.fi + +and assuming these are the only available commands, a user could +invoke the egrep program simply by entering a single `e', but would +need to enter `ba' to run bash or `gnuc' to run gnuchess. + +.I TRIE-GEN +generates several static lookup tables and two functions that allow +client programs to either interpret standard input one character at a +time or, given a prefix string, to determine which keyword in the +static search set this prefix string matches. + +The trie generation algorithm runs in time proportional to O(n * k), +where +.I n +is the number of user-specified keywords from the standard input and +.I k +is the length of the longest common prefix between any words in the +keyword set. + +The table compaction algorithm, invoked by giving the `-c' option, +runs in time proportional to O(r * e * 128), where +.I r +is the total number of rows in the generated trie, +.I e +is the maximum number of non-null entries in each row, and 128 is the +size of the ASCII character set used to index into the trie. + +.SH OPTIONS + +.TP +.B \-c +Compact the generated trie using a technique called `double-offset +indexing,' which is used in Bison and FLEX (also described in Tarjan +and Yao's article ``Storing a Sparse Table'' in CACM, 1979). +.B \-f +Generates a `full' trie rather than a minimal-prefix trie. +.SH "SEE ALSO" +gperf (the GNU perfect hash function generator) +.SH BUGS +None known at this time, though there is much work to be done with the +user interface and program options... Bugs should be reported to +.BR schmidt@ics.uci.edu . +Bugs tend actually to be fixed if they can be isolated, so it is in your +interest to report them in such a way that they can be easily reproduced. +.SH COPYING +Copyright (c) 1989 Free Software Foundation, Inc. +.P +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. +.P +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. +.P +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 included in +translations approved by the Free Software Foundation instead of in +the original English. +.SH AUTHORS +Douglas C. Schmidt (schmidt@ics.uci.edu) diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/trie.cc b/gnu/lib/libg++/libg++/etc/trie-gen/trie.cc new file mode 100644 index 00000000000..0acceb3efa8 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/trie.cc @@ -0,0 +1,200 @@ +/* Generates a minimal-prefix trie for a user-specified set of keywords. + + Copyright (C) 1989, 1993 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include "renew.h" +#include "options.h" +#include "trie.h" + +const int MAX_ASCII = 128; + +/* Insert a new keyword into the data structure, possibly growing the + keyword table to accomodate the new entry. Space for STR has already + been allocated in the caller. In addition, the MAX_KEY_LEN is updated + if the current LEN is larger than the previous max. This information + is needed later on when dynamically allocating the TRIE table. */ + +void +Trie::insert (char *str, int len) +{ + if (current_size >= total_size) + resize (total_size * 2); + keys[current_size++] = str; + if (max_key_len < len) + max_key_len = len; +} + +/* Grow the KEYS table to allow a maximum of NEW_SIZE entries. + Old keys are copied into the new buffer. */ + +void +Trie::resize (int new_size) +{ + keys = new (keys, total_size = new_size) char *; +} + +/* Write the generated TRIE out as a static table. Compaction is + performed if the user requests it, otherwise the table is + not compacted at all! (this leads to ridiculously large tables; perhaps + compaction should be the default?) */ + +void +Trie::output (void) +{ + int i; + + if (current_size <= 0) + return; + else + { + sort (); + + fputs ("#include \n#define MAX_ASCII 128\n\nstatic", stdout); + if (option[CONST]) + fputs (" const", stdout); + fputs (" char *const word_list[] = \n{\n \"\",\n", stdout); + + for (i = 0; i < current_size; i++) + printf (" \"%s\",\n", keys[i]); + + fflush (stdout); + fputs ("};\n\n", stdout); + build (current_size); + + if (option[COMPACT]) + matrix.output (); + else + { + const int MAX_NUMBER + = (current_size > max_row) ? current_size : max_row; + int field_width; + int count = MAX_NUMBER; + + for (field_width = 2; (count /= 10) > 0; field_width++) + ; + + printf ("static const %s trie_array[][MAX_ASCII] = \n{", + MAX_NUMBER < SCHAR_MAX ? + (CHAR_MIN == 0 ? "signed char" : "char") : + MAX_NUMBER < SHRT_MAX ? "short" : "int"); + + for (i = 0; i < max_row; i++) + { + fputs ("\n ", stdout); + + for (int j = 0; j < MAX_ASCII; j++) + printf ("%*d,", field_width, matrix (i, j)); + } + fputs ("\n};\n", stdout); + } + + printf ("\n%schar *\nin_word_set (const char *str, int len)\n{\n" + " %schar *s = %sstr;\n int i = 0;\n\n" + " while ((i = %s) > 0)\n ;\n\n" + " return i == 0 || strncmp (s = word_list[-i], str, len)" + " ? 0 : s;\n}\n", + option[CONST] ? "const " : "", + option[CONST] ? "const " : "", + option[CONST] ? "" : "(char*)", + option[COMPACT] ? "next_state(i, *s++)" : "trie_array[i][*s++]"); + } +} + +/* Comparison routine called by qsort. */ +int +Trie::cmp (char **s1, char **s2) +{ + return strcmp (*s1, *s2); +} + +/* Sort the keys by lexicographical order. */ + +void +Trie::sort (void) +{ + typedef int (*PTF)(const void *, const void *); + qsort ((void *) keys, current_size, sizeof *keys, PTF (cmp)); +} + +/* Generate the trie, using recursive calls if necessary to handle + duplicate keyword index positions. */ + +void +Trie::build (int hi, int lo, int col) +{ + if (option[FULL]) + { + int row = max_row - 1; + + /* Process each key in the range lo..hi, possibly calling the function + recursively when duplicate consecutive characters are found (that's + why it is important to sort the keywords first!). Note that calls + to member function MATRIX build the internal form used to generate + the compacted sparse array. Positive values indicate the next row + (which really encodes DFA states) to consider; negative values + are flags that provide (when negated) the correct offset into a generated + array of strings. */ + + for (int i = lo; i < hi; i++) + if (keys[i][col] == '\0') + matrix (row, keys[i][col], -i - 1); + else + { + /* Location the end of the duplicate characters in the current column. */ + + for (lo = i; i < hi - 1 && keys[i][col] == keys[i + 1][col]; i++) + ; + + matrix (row, keys[lo][col], max_row++); + build (i + 1, lo, col + 1); + } + } + else + { + int row = max_row - 1; + + /* Process each key in the range lo..hi, possibly calling the function + recursively when duplicate consecutive characters are found (that's + why it is important to sort the keywords first!). Note that calls + to member function MATRIX build the internal form used to generate + the compacted sparse array. Positive values indicate the next row + (which really encodes DFA states) to consider; negative values + are flags that provide (when negated) the correct offset into a generated + array of strings. */ + + for (int i = lo; i < hi; i++) + if (keys[i][col] == '\0' || i == hi - 1 || keys[i][col] != keys[i + 1][col]) + matrix (row, keys[i][col], -i - 1); + else + { + /* Location the end of the duplicate characters in the current column. */ + + for (lo = i; i < hi - 1 && keys[i][col] == keys[i + 1][col]; i++) + ; + + matrix (row, keys[lo][col], max_row++); + build (i + 1, lo, col + 1); + } + } +} diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/trie.h b/gnu/lib/libg++/libg++/etc/trie-gen/trie.h new file mode 100644 index 00000000000..2ea76710d98 --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/trie.h @@ -0,0 +1,49 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Data and member functions for generating a minimal-prefix trie. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + + This file is part of GNU TRIE-GEN. + + GNU TRIE-GEN is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GNU TRIE-GEN is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 trie-gen; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "compact.h" + +class Trie +{ +public: + /* N is a guess on the total number of keys. */ + Trie (int n = 1000): matrix (n), total_size (n) { + keys = new char *[n]; current_size = 0; + max_key_len = 0; max_row = 1; } + void insert (char *str, int len); + void output (void); + void sort (void); + +private: + Compact_Matrix matrix; /* Dynamic table encoding the trie DFA. */ + char **keys; /* Dynamic resizable table to store input keys. */ + int total_size; /* Total size of the keyword table. */ + int current_size; /* Current size of the keyword table. */ + int max_row; /* Largest row in the trie so far. */ + int max_key_len; /* Length of the longest keyword. */ + + void resize (int new_size); + void build (int hi, int lo = 0, int col = 0); + static int cmp (char **s1, char **s2); +}; + diff --git a/gnu/lib/libg++/libg++/etc/trie-gen/version.cc b/gnu/lib/libg++/libg++/etc/trie-gen/version.cc new file mode 100644 index 00000000000..5c7c9aa37db --- /dev/null +++ b/gnu/lib/libg++/libg++/etc/trie-gen/version.cc @@ -0,0 +1,22 @@ +/* Current program version number. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU TRIE-GEN. + +GNU TRIE-GEN is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU TRIE-GEN is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 TRIE-GEN; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +char *version_string = "1.1"; diff --git a/gnu/lib/libg++/libg++/g++FAQ.texi b/gnu/lib/libg++/libg++/g++FAQ.texi new file mode 100644 index 00000000000..55ccf91d3bd --- /dev/null +++ b/gnu/lib/libg++/libg++/g++FAQ.texi @@ -0,0 +1,1781 @@ +\input texinfo.tex @c -*-texinfo-*- +@c %**start of header +@setfilename g++FAQ.info +@settitle Frequently asked questions about the GNU C++ compiler +@setchapternewpage off +@c version: @(#)g++FAQ.texi 1.35 9/15/95 +@c %**end of header + +@iftex +@finalout +@end iftex +@titlepage +@title G++ FAQ +@subtitle Frequently asked questions about the GNU C++ compiler +@subtitle September 15, 1995 +@sp 1 +@author Joe Buck +@page +@end titlepage + +@ifinfo +@node Top, new stuff, (dir), (dir) +@top +@unnumbered Preface +@cindex FAQ for g++, latest version +@cindex Archive site for FAQ lists +@cindex rtfm.mit.edu +@cindex Joe Buck +@cindex FAQ for C++ +@cindex Marshall Cline [FAQ for comp.lang.c++] +@end ifinfo + +This is a list of frequently asked questions (FAQ) for g++ users; thanks to +all those who sent suggestions for improvements. Thanks to Marcus Speh +for doing the index. + +Please send updates and corrections to the FAQ to +@code{jbuck@@synopsys.com}. Please do @emph{not} use me as a resource +to get your questions answered; that's what gnu.g++.help is for and I +don't have the time to support the net's use of g++. + +Many FAQs, including this one, are available on the archive site +rtfm.mit.edu, in the directory @file{pub/usenet/news.answers}. +This FAQ may be found in the subdirectory g++-FAQ. + +This FAQ is intended to supplement, not replace, Marshall Cline's +excellent FAQ for the C++ language and for the newsgroup +comp.lang.c++. Especially if g++ is the first C++ +compiler you've ever used, the question ``How do I do with g++?'' +is probably really ``How do I do in C++?''. +You can find this FAQ on rtfm.mit.edu under @file{pub/usenet/comp.lang.c++}. + +@menu +* new stuff:: The latest poop -- gcc-2.7.0 +* getting g++:: Obtaining Source Code +* installation:: Installation Issues and Problems +* User Problems:: User Problems +* legalities:: What are the rules for shipping code built with g++ and libg++? +* index:: Concept Index + + --- The Detailed Node Listing --- + +New Stuff: The Latest Poop -- Gcc-2.7.0 + +* for scope:: gcc-2.7.0 breaks declarations in "for" statements! +* version 2.7:: What's new in version 2.7.x of gcc/g++ +* repository:: How do I use the new template repository code? +* libstdc++:: The GNU Standard C++ Library + +Obtaining Source Code + +* latest versions:: What is the latest version of gcc, g++, and libg++? +* g++ for Unix:: How do I get a copy of g++ for Unix? +* g++ for HP:: Getting gcc/g++ for the HP Precision Architecture +* g++ for Solaris 2.x:: Getting gcc/g++ binaries for Solaris 2.x +* g++ for other platforms:: How do I get a copy of g++ for (some other platform)? +* 1.x vs 2.x versions:: But I can only find g++-1.42! + +Installation Issues and Problems + +* gcc-2 + g++-1:: I can't build g++ 1.x.y with gcc-2.x.y! +* what else do I need?:: OK, I've obtained gcc; what else do I need? +* use GNU linker?:: Should I use the GNU linker, or should I use "collect"? +* Use GNU assembler?:: Should I use the GNU assembler, or my vendor's assembler? +* Use GNU C library?:: Should I use the GNU C library? +* Global constructor problems:: Global constructors aren't being called +* Strange assembler errors:: Strange assembler errors when linking C++ programs +* Other problems building libg++:: +* Rebuild libg++?:: Do I need to rebuild libg++ to go with my new g++? + +User Problems + +* unused parameter warnings:: How to silence ``unused parameter'' warnings +* jump crosses initialization:: g++ objects to a declaration in a case statement +* 2.5.x changes in overloading:: Changes in function overloading +* Demangler:: Where can I find a demangler? +* etags for C++:: Where can I find a version of etags for C++? +* static data members:: Linker reports undefined symbols for static data members +* internal compiler error:: What does ``internal compiler error'' mean? +* bug reports:: I think I have found a bug in g++. +* porting to g++:: Porting programs from other compilers to g++ +* name mangling:: Why does g++ mangle names differently from other C++ compilers? +* problems linking with other libraries:: Why can't g++ code link with code from other C++ compilers? +* documentation:: What documentation exists for g++ 2.x? +* templates:: Problems with the template implementation +* undefined templates:: I get undefined symbols when using templates +* redundant templates:: I get multiply defined symbols when using templates +* Standard Template Library:: Does g++ support the Standard Template Library? +* agreement with standards:: What are the differences between g++ and the ARM specification of C++? +* compiling standard libraries:: Will g++ compile InterViews? The NIH class library? +* debugging on SVR4 systems:: Debugging on SVR4 systems +* X11 conflicts with libg++:: Conflict over meaning of String +* assignment to streams:: Why can't I assign one stream to another? +@end menu + +@node new stuff, getting g++, Top, Top +@chapter The latest poop -- gcc-2.7.0 + +This section is intended to describe more recent changes to g++, libg++, +and such. Some things in this section will eventually move elsewhere. + +The big news is that version 2.7.0 has just been released. This, of +course, means new FAQs. I haven't had a lot of time to whip out this +section yet, so suggestions for improvement are welcome. + +@menu +* for scope:: gcc-2.7.0 breaks declarations in "for" statements! +* version 2.7:: What's new in version 2.7.x of gcc/g++ +* repository:: How do I use the new template repository code? +* libstdc++:: The GNU Standard C++ Library +@end menu + +@node for scope, version 2.7, new stuff, new stuff +@section gcc-2.7.0 breaks declarations in "for" statements! + +@cindex declarations in for statements +@cindex for statements: declarations + +gcc-2.7.0 implements the new ANSI/ISO rule on the scope of variables +declared in for loops. + +@example +for (int i = 1; i <= 10; i++) @{ + // do something here +@} +foo(i); +@end example + +In the above example, most existing C++ compilers would pass the +value 11 to the function @code{foo}. In gcc 2.7 and in the ANSI/ISO +working paper, the scope of @code{i} is only the for loop body, so +this is an error. So that old code can be compiled, the new gcc has +a flag @code{-fno-for-scope} that causes the old rule to be used. +@cindex -fno-for-scope + +@node version 2.7, repository, for scope, new stuff +@section What's new in version 2.7.0 of gcc/g++ + +The long-awaited version 2.7.0 of gcc/g++ (along with a matching version +of libg++) have now been released. This represents a great deal +of work on the part of the g++ maintainers to fix outstanding bugs and +move the compiler closer to the current ANSI/ISO standards committee's +working paper, including supporting many of the new features that have +been added to the language. I recommend that everyone read the NEWS +file contained in the distribution (and that system administrators make +the file available to their users). I've borrowed liberally from this +file here. + +@cindex C++ working paper +If any features seem unfamiliar, you will probably want to +look at the recently-released public review copy of the C++ Working +Paper. For PostScript and PDF (Adobe Acrobat) versions, see the +archive at ftp://research.att.com/dist/stdc++/WP. For HTML and ASCII +versions, see ftp://ftp.cygnus.com/pub/g++. On the World Wide Web, see +http://www.cygnus.com/~mrs/wp-draft. + +@itemize @bullet +@item +@cindex for scope +As described above, the scope of variables declared in the +initialization part of a for statement has been changed; such variables +are now visible only in the loop body. Use @code{-fno-for-scope} to get +the old behavior. You'll need this flag to build groff version 1.09, +Ptolemy, and many others. + +@item +@cindex vtable duplication +Code that does not use #pragma interface/implementation will most +likely shrink dramatically, as g++ now only emits the vtable for a +class in the translation unit where its first non-inline, non-abstract +virtual function is defined. + +@item +@cindex automatic template instantiation +Support for automatic template instantiation has @emph{not} been enabled +in the official distribution, due to a disagreement over design philosophies. +But you can get a patch from Cygnus to turn it on; retrieve the patch +from @file{ftp://ftp.cygnus.com/pub/g++/gcc-2.7.0-repo.gz}. + +@item +@cindex exception handling, 2.7.0 +Support for exception handling has been improved; more targets are now +supported, and throws will use the RTTI mechanism to match against the +catch parameter type. You must give the @code{-fhandle-exceptions} to +turn it on. Optimization is @emph{not supported} with +@code{-fhandle-exceptions}; no need to report this as a bug. You'll +probably get an internal compiler error if you try it. + +For exception handling to work your CPU must be a SPARC, RS6000/PowerPC, +386/486/Pentium, or ARM. Other platforms are missing the function to +unwind the stack. + +@item +@cindex run-time type identification +Support for Run-Time Type Identification has been added with @code{-frtti}. +This support is still in alpha; one major restriction is that any file +compiled with @code{-frtti} must include @code{} (@emph{not} +@code{typeinfo.h} as the NEWS file says). +Also, all code you link with (including libg++) has to be built with +@code{-frtti}, so it's still tricky to use. + +@item +@cindex compiler-generated operators +Synthesis of compiler-generated constructors, destructors and +assignment operators is now deferred until the functions are used. + +@item +@cindex assignment in conditional expressions +The parsing of expressions such as @code{a ? b : c = 1} +has changed from +@code{(a ? b : c) = 1} to @code{a : b ? (c = 1)}. This is a new C/C++ +incompatibility brought to you by the ANSI/ISO standards committee. + +@item +@cindex new operator keywords +The operator keywords and, and_eq, bitand, bitor, compl, not, not_eq, +or, or_eq, xor and xor_eq are now supported. Use @code{-ansi} or +@code{-foperator-names} to enable them. + +@item +@cindex explicit keyword +The @code{explicit} keyword is now supported. @code{explicit} is used to mark +constructors and type conversion operators that should not be used +implicitly. + +@item +@cindex user-defined type conversion +Handling of user-defined type conversion has been improved. + +@item +@cindex explicit template instantiation +Explicit instantiation of template methods is now supported. Also, +@code{inline template class foo;} +can be used to emit only the vtable +for a template class. + +@item +@cindex -fcheck-new +With -fcheck-new, g++ will check the return value of all calls to +operator new, and not attempt to modify a returned null pointer. + +@item +collect2 now demangles linker output, and c++filt has become part of +the gcc distribution. + +@item +Improvements to template instantiation: only members actually used +are instantiated. +@end itemize + +@node repository, libstdc++, version 2.7, new stuff +@section How do I use the new repository code? + +Because there is some disagreement about the details of the template +repository mechanism, you'll need to obtain a patch from Cygnus Support +to enable the 2.7.0 repository code. You can obtain the patch by +anonymous FTP: @file{ftp://ftp.cygnus.com/pub/g++/gcc-2.7.0-repo.gz}. + +After you've applied the patch, the @code{-frepo} flag will enable the +repository mechanism. The flag works much like the existing +@code{-fno-implicit-templates} flag, except that auxiliary files, with +an @file{.rpo} extension, are built that specify what template +expansions are needed. At link time, the (patched) collect program +detects missing templates and recompiles some of the object files +so that the required templates are expanded. + +Note that the mechanism differs from that of cfront in that template +definitions still must be visible at the point where they are to be +expanded. No assumption is made that @file{foo.C} contains template +definitions corresponding to template declarations in @file{foo.h}. + +Jason Merrill writes: ``To perform closure on a set of objects, just try +to link them together. It will fail, but as a side effect all needed +instances will be generated in the objects.'' + +@node libstdc++, , repository, new stuff +@section The GNU Standard C++ Library + +The GNU Standard C++ Library (also called the ``GNU ANSI C++ Library'' +in places in the code) is not libg++, though it is included in the +libg++ distribution. Rather, it contains classes and functions +required by the ANSI/ISO standard. The copyright conditions are the +same as those for for the iostreams classes; the LGPL is not used. See +@xref{legalities}. + +This library, libstdc++, is in the libg++ distribution in versions 2.6.2 +and later. It requires at least gcc 2.6.3 to build the libg++-2.6.2 +version; use at least gcc 2.7.0 to build the libg++ 2.7.0 version. It +contains a hacked-up version of HP's implementation of the Standard +Template Library (see @xref{Standard Template Library}). I've +successfully used this Standard Template Library version to build +a number of the demos you'll see on various web pages. + +As of version 2.7.0, the streams classes are now in libstdc++ instead of +libg++, and libiostream is being phased out (don't use it). The g++ +program searches this library. + +@node getting g++, installation, new stuff, Top +@chapter Obtaining Source Code +@cindex Source code + +@menu +* latest versions:: What is the latest version of gcc, g++, and libg++? +* g++ for Unix:: How do I get a copy of g++ for Unix? +* g++ for HP:: Getting gcc/g++ for the HP Precision Architecture +* g++ for Solaris 2.x:: Getting gcc/g++ binaries for Solaris 2.x +* g++ for other platforms:: How do I get a copy of g++ for (some other platform)? +* 1.x vs 2.x versions:: But I can only find g++-1.42! +@end menu + +@node latest versions, g++ for Unix, , getting g++ +@section What is the latest version of gcc, g++, and libg++? + +@cindex gcc/g++, version date +The latest "2.x" version of gcc/g++ is 2.7.0, released June 16, 1995. +The latest version of libg++ is 2.7.0a, released June 19, 1995 (2.7.0 +had an error in a makefile and was almost immediately replaced). +. +Don't use 2.5.x, with x less than 5, for C++ code; there were some +serious bugs that didn't have easy workarounds. 2.5.8 is the most +solid 2.5.x release. 2.6.3 is the most solid 2.6.x release. + +For some non-Unix platforms, the latest port of gcc may be an earlier +version (2.5.8, say). You'll need to use a version of libg++ that +has the same first two digits as the compiler version, e.g. use libg++ +2.5.x (for the latest x you can find) with gcc version 2.5.8. + +The latest "1.x" version of gcc is 1.42, and the latest "1.x" version of +g++ is 1.42.0. +While gcc 1.42 is quite usable for C programs, +I recommend against using g++ 1.x except in special circumstances +(and I can't think of any such circumstances). + +@node g++ for Unix, g++ for HP, latest versions, getting g++ +@section How do I get a copy of g++ for Unix? + +First, you may already have it if you have gcc for your platform; +g++ and gcc are combined now (as of gcc version 2.0). +@cindex GNU gcc, version +@cindex GNU g++ and gcc + +You can get g++ from a friend who has a copy, by anonymous FTP or +UUCP, or by ordering a tape or CD-ROM from the Free Software +Foundation. +@cindex g++, ordering +@cindex g++, getting a copy + +The Free Software Foundation is a nonprofit organization that +distributes software and manuals to raise funds for more GNU +development. Getting your copy from the FSF contributes directly to +paying staff to develop GNU software. CD-ROMs cost $400 if an +organization is buying, or $100 if an individual is buying. Tapes +cost around $200 depending on media type. I recommend asking for +version 2, not version 1, of g++. +@cindex FSF [Free Software Foundation] +@cindex GNU [GNU's not unix] + +For more information about ordering from the FSF, contact +gnu@@prep.ai.mit.edu, phone (617) 542-5942 or anonymous ftp file +@file{ftp://prep.ai.mit.edu/pub/gnu/GNUinfo/ORDERS} (you can +also use one of the sites listed below if you can't get into ``prep''). + +@cindex FSF, contact + +Here is a list of anonymous FTP archive sites for GNU software. +If no directory is given, look in @file{/pub/gnu}. + +@cindex GNUware, anonymous FTP sites + +@example +ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep, +cair.kaist.ac.kr, ftp.nectec.or.th:/pub/mirrors/gnu + +AUSTRALIA: archie.oz.au:/gnu (archie.oz or archie.oz.au for ACSnet) + +AFRICA: ftp.sun.ac.za + +MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu + +EUROPE: irisa.irisa.fr, ftp.univ-lyon1.fr:, ftp.mcc.ac.uk, +unix.hensa.ac.uk:/pub/uunet/systems/gnu, ftp.denet.dk, +src.doc.ic.ac.uk:/gnu, ftp.eunet.ch, nic.switch.ch:/mirror/gnu, +ftp.informatik.rwth-aachen.de, ftp.informatik.tu-muenchen.de, +ftp.win.tue.nl, ftp.funet.fi, ftp.stacken.kth.se, isy.liu.se, +ftp.luth.se:/pub/unix/gnu, ftp.sunet.se, archive.eu.net + +SOUTH AMERICA: ftp.unicamp.br, ftp.inf.utfsm.cl + +WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu + +USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu, +ftp.digex.net, ftp.kpc.com:/pub/mirror/gnu, +f.ms.uky.edu:/pub3/gnu, jaguar.utah.edu:/gnustuff, +ftp.hawaii.edu:/mirrors/gnu, vixen.cso.uiuc.edu:/gnu, +mrcnext.cso.uiuc.edu, ftp.cs.columbia.edu:/archives/gnu/prep, +col.hp.com:/mirrors/gnu, gatekeeper.dec.com:/pub/GNU, +ftp.uu.net:/systems/gnu + +@end example + +The ``official site'' is prep.ai.mit.edu, but your transfer will probably +go faster if you use one of the above machines. + +@cindex gzip +Most GNU utilities are compressed with ``gzip'', the GNU compression +utility. All GNU archive sites should have a copy of this program, +which you will need to uncompress the distributions. + +@cindex UUNET +@cindex UUCP +UUNET customers can get GNU sources from UUNET via UUCP. +UUCP-only sites can get GNU sources by ``anonymous UUCP'' from site +"osu-cis" at Ohio State University. You pay for the long-distance call +to OSU; the price isn't too bad on weekends at 9600 bps. Send mail to +uucp@@cis.ohio-state.edu or osu-cis!uucp for more information. + +OSU lines are often busy. If you're in the USA, and are willing to spend +more money, you can get sources via UUCP from UUNET using their 900 number: +1-900-GOT-SRCS (900 numbers don't work internationally). You will be +billed $0.50/minute by your phone company. + +@cindex libg++ +Don't forget to retrieve libg++ as well! + +@node g++ for HP, g++ for Solaris 2.x, g++ for Unix, getting g++ +@section Getting gcc/g++ for the HP Precision Architecture + +@cindex HP Precision Architecture +@cindex Hewlett-Packard +@cindex GNU GAS +@cindex GNU gdb + +If you use the HP Precision Architecture (HP-9000/7xx and HP-9000/8xx) +and you want to use debugging, you'll need to use the GNU assembler, GAS +(version 2.3 or later). If you build from source, you must tell the +configure program that you are using GAS or you won't get debugging +support. A non-standard debug format is used, since until recently HP +considered their debug format a trade secret. Thanks to the work of +lots of good folks both inside and outside HP, the company has seen the +error of its ways and has now released the required information. The +team at the University of Utah that did the gcc port now has code that +understands the native HP format. + +Some enhancements for the HP that haven't been integrated back into the +official GCC are available from the University of Utah, site +jaguar.cs.utah.edu. You can retrieve sources and prebuilt binaries for +GCC, GDB, binutils,and libg++; see the directory @file{/dist}. + +The libg++ version is actually the same as the FSF 2.6. The Utah +version of GDB can now understand both the GCC and HP C compiler debug +formats, so it is no longer necessary to have two different GDB versions. + +I recommend that HP users use the Utah versions of the tools (see +above), though at this point the standard FSF versions will work well. + +HP GNU users can also find useful stuff on the site geod.emr.ca in the +@file{/pub/UNIX/GNU-HP} directory. + +Jeff Law is leaving the University of Utah, so the Utah prebuilt +binaries may be discontinued. + +@node g++ for Solaris 2.x, g++ for other platforms, g++ for HP, getting g++ +@section Getting gcc/g++ binaries for Solaris 2.x + +``Sun took the C compiler out of Solaris 2.x. Am I stuck?'' + +@cindex Solaris +@cindex gcc/g++ binaries for Solaris + +No; prep.ai.mit.edu and its mirror sites provide GCC binaries for +Solaris. As a rule, these binaries are not updated as often as the +sources are, so if you want the very latest version of gcc/g++, you +may need to grab and install binaries for an older version and use it to +bootstrap the latest version from source. + +@cindex gzip +The latest gcc binaries on prep.ai.mit.edu and its mirror sites are for +version 2.5.6 for Solaris on the Sparc, and version 2.4.5 for Solaris on +Intel 386/486 machines. +There are also binaries for ``gzip'', the GNU compression utility, which +you'll need for uncompressing the binary distribution. On any GNU +archive site, look in subdirectories @file{i486-sun-solaris2} or +@file{sparc-sun-solaris2}. + +@cindex Solaris pkgadd utility +The ftp directory /pub/GNU on site ftp.quintus.com contains various +GNU and freeware programs for Solaris2.X running on the sparc. These are +packaged to enable installation using the Solaris ``pkgadd'' utility. +These include GNU emacs 19.27, gcc (and g++) 2.6.0, Perl 4.036, and others. + +@node g++ for other platforms, 1.x vs 2.x versions, g++ for Solaris 2.x, getting g++ +@section How do I get a copy of g++ for (some other platform)? + +@cindex VMS support +@cindex VAX +@cindex VMS, g++/libg++ precompiled +The standard gcc/g++ distribution includes VMS support. Since the +FSF people don't use VMS, it's likely to be somewhat less solid than +the Unix version. Precompiled copies of g++ and libg++ in VMS-installable +form are available by FTP from mango.rsmas.miami.edu. See also +the site ftp.stacken.kth.se (in Sweden), directory /pub/GNU-VMS/contrib, +which has gcc-2.5.8 and libg++-2.5.3. + +@cindex MS-DOS support +@cindex Delorie's gcc/g++ +@cindex DJGPP +@cindex EMX +There are two different versions of gcc/g++ for MS-DOS: EMX and DJGPP. +EMX also works for OS/2 and is described later. +DJGPP is DJ Delorie's port. It can be found on many FTP archive +sites; its "home" is on oak.oakland.edu, directory @file{~ftp/pub/msdos/djgpp}. + +The latest version of DJGPP is 1.12.maint1. This version runs under +Windows 3.x. It includes a port of gcc 2.6.0, plus support software. + +FSF sells floppies with DJGPP on them; see above for ordering software +from the FSF. + +A new Usenet group, @code{comp.os.msdos.djgpp}, has recently been +created. + +@cindex Amiga support +For information on Amiga ports of gcc/g++, retrieve the file +@file{/pub/gnu/MicrosPorts/Amiga} from prep.ai.mit.edu, or write +to Markus M. Wild , who I hope won't be too upset +that I mentioned his name here. + +@cindex Atari ST support +A port of gcc to the Atari ST can be found on the site +``atari.archive.umich.edu'', under @file{/atari/Gnustuff/Tos}, along with many +other GNU programs. This version is usually the same as the latest FSF +release. See the ``Software FAQ'' for the Usenet group +``comp.sys.atari.st'' for more information. + +@cindex EMX port +@cindex gcc/2 +@cindex OS/2 support + +There are two different ports of gcc to OS/2, the +so-called EMX port (which also runs on MS-DOS), and a port called +``gcc/2''. The latter port is no longer supported, since the EMX +port includes all of its functionality. +The EMX port's C library attempts to provide a Unix-like environment. +For more information ask around on ``comp.os.os2.programmer.misc''. + +The EMX port is available by FTP from + +@example +ftp.uni-stuttgart.de(129.69.1.12) in /pub/systems/os2/emx-0.9a +src.doc.ic.ac.uk(146.169.2.1) in /pub/packages/os2/unix/emx09a +ftp.informatik.tu-muenchen.de(131.159.0.198) in + /pub/comp/os/os2/devtools/emx+gcc +@end example + +Eberhard Mattes did the EMX port. His address is +mattes@@azu.informatik.uni-stuttgart.de. + +@cindex Apple support +@cindex Macintosh support + +I'm looking for more information on gcc/g++ support on the Apple +Macintosh. Until recently, this FAQ did not provide such information, +but FSF is no longer boycotting Apple as the League for Programming +Freedom boycott has been dropped. + +Mike White (cons116@@twain.oit.umass.edu) says: +``Versions 1.37.1 and 2.3.3 of gcc were ported by Stan Shebs and are available +at ftp.cygnus.com under /pub/shebs. They are both interfaced to MPW. +Shebs is apparently working on a cross compiler of 2.6.3 to create +Mac apps from Unix boxes.'' + +I don't know anything about more recent versions. + +@node 1.x vs 2.x versions, ,g++ for other platforms, getting g++ +@section But I can only find g++-1.42! + +``I keep hearing people talking about g++ 2.5.8 (or some other number +starting with 2), but the latest version I can find is g++ 1.42. +Where is it?'' + +@cindex Objective-C +@cindex g++, version number +As of gcc 2.0, C, C++, and Objective-C as well are all combined into a +single distribution called gcc. If you get gcc you already have g++. The +standard installation procedure for any gcc version 2 compiler will +install the C++ compiler as well. + +One could argue that we shouldn't even refer to "g++-2.x.y" but it's a +convention. It means ``the C++ compiler included with gcc-2.x.y.'' + +@node installation, User Problems, getting g++, Top +@chapter Installation Issues and Problems + +@menu +* gcc-2 + g++-1:: I can't build g++ 1.x.y with gcc-2.x.y! +* what else do I need?:: OK, I've obtained gcc; what else do I need? +* use GNU linker?:: Should I use the GNU linker, or should I use "collect"? +* Use GNU assembler?:: Should I use the GNU assembler, or my vendor's assembler? +* Use GNU C library?:: Should I use the GNU C library? +* Global constructor problems:: Global constructors aren't being called +* Strange assembler errors:: Strange assembler errors when linking C++ programs +* Other problems building libg++:: Other problems building libg++ +* More size_t problems:: But I'm still having problems with size_t! +* Rebuild libg++?:: Rebuild libg++ to go with my new g++? +@end menu + +@node gcc-2 + g++-1, what else do I need?, , installation +@section I can't build g++ 1.x.y with gcc-2.x.y! + +``I obtained gcc-2.x.y and g++ 1.x.y and I'm trying to build it, but +I'm having major problems. What's going on?'' + +@cindex g++, building +If you wish to build g++-1.42, you must obtain gcc-1.42 first. The +installation instructions for g++ version 1 leave a lot to be desired, +unfortunately, and I would recommend that, unless you have a special +reason for needing the 1.x compiler, that C++ users use the latest +g++-2.x version, as it +is the version that is being actively maintained. + +@cindex g++, template support +@cindex Templates +@cindex ANSI draft standard +There is no template support in g++-1.x, and it is generally much further +away from the ANSI draft standard than g++-2.x is. + +@node what else do I need?, use GNU linker?, gcc-2 + g++-1, installation +@section OK, I've obtained gcc; what else do I need? + +@cindex libg++ +First off, you'll want libg++ as you can do almost nothing without it +(unless you replace it with some other class library). + +@cindex GNU GAS +@cindex GNU GAS [assembler] +Second, depending on your platform, you may need "GAS", the GNU assembler, +or the GNU linker (see next question). + +@cindex GNU gdb +Finally, while it is not required, you'll almost certainly want the GNU +debugger, gdb. The latest version is 4.14, released March 2, 1995. Other +debuggers (like dbx, for example) will normally not be able to +understand at least some of the debug information produced by g++. + +@node use GNU linker?, Use GNU assembler?, what else do I need?, installation +@section Should I use the GNU linker, or should I use "collect"? + +@cindex Linker +@cindex System VR3, linker +@cindex System VR4, linker +First off, for novices: special measures must be taken with C++ to arrange +for the calling of constructors for global or static objects before the +execution of your program, and for the calling of destructors at the end. +(Exception: System VR3 and System VR4 linkers, Linux/ELF, and some other +systems support user-defined +segments; g++ on these systems requires neither the GNU linker nor +collect. So if you have such a system, the answer is that you don't +need either one). + +@cindex AT&T cfront +@cindex Cfront-end +@cindex collect program +@cindex GNU linker +@cindex GNU binutils +If you have experience with AT&T's "cfront", this function is performed +there by programs named "patch" or "munch". With GNU C++, it is performed +either by the GNU linker or by a program known as "collect". The collect +program is part of the gcc-2.x distribution; you can obtain the GNU linker +separately as part of the "binutils" package. The latest version of +binutils is 2.5.2, released November 2, 1994. + +(To be technical, it's "collect2"; there were originally several +alternative versions of collect, and this is the one that survived). + +There are advantages and disadvantages to either choice. + +Advantages of the GNU linker: +@cindex GNU linker, advantages +@cindex GNU ld +@cindex ld [GNU linker] + +It's faster than using collect -- collect basically runs the standard Unix +linker on your program twice, inserting some extra code after the first +pass to call the constructors. This is a sizable time penalty for large +programs. The GNU linker does not require this extra pass. + +GNU ld reports undefined symbols using their true names, not the mangled +names (but as of 2.7.0 so does collect). + +If there are undefined symbols, GNU ld reports which object file(s) refer to +the undefined symbol(s). + +As of binutils version 2.2, on systems that use the so-called "a.out" +debug format (e.g. Suns running SunOS 4.x), the GNU linker compresses +the debug symbol table considerably. + +@cindex collect linker, advantages +Advantages of collect: + +@cindex Shared libraries +If your native linker supports shared libraries, you can use shared +libraries with collect. This used to be a strong reason @emph{not} +to use the GNU linker, but recent versions of GNU ld support linking +with shared libraries on many platforms, and creating shared libraries +on a few (such as Intel x86 systems that use ELF object format). + +Note: using existing shared libraries (X and libc, for example) works +very nicely. Generating shared libraries from g++-compiled code is +another matter, generally requiring OS-dependent tricks if it is +possible at all. But progress has been made recently. + +As of 2.7.0, building C++ shared libraries should work fine on supported +platforms (HPUX 9+, IRIX 5+, DEC UNIX (formerly OSF/1), SunOS 4, and all +targets using SVR4-style ELF shared libraries). + +@cindex Shared version of libg++ +However, as of libg++ 2.6.2, the libg++ distribution contains some +patches to build libg++ as a shared library on some OSes (those listed +above). Check the file @file{README.SHLIB} from that distribution. + +@cindex GNU linker, porting +The GNU linker has not been ported to as many platforms as g++ has, so you +may be forced to use collect. + +If you use collect, you don't need to get something extra and figure out +how to install it; the standard gcc installation procedure will do it for you. + +In conclusion, I don't see a clear win for either alternative at this +point. Take your pick. + +@node Use GNU assembler?, Use GNU C library?, use GNU linker?, installation +@section Should I use the GNU assembler, or my vendor's assembler? + +@cindex Assembler +@cindex GNU GAS +This depends on your platform and your decision about the GNU linker. For +most platforms, you'll need to use GAS if you use the GNU linker. For +some platforms, you have no choice; check the gcc installation notes to +see whether you must use GAS. But you can usually use the vendor's +assembler if you don't use the GNU linker. + +The GNU assembler assembles faster than many native assemblers; however, +on many platforms it cannot support the local debugging format. + +If you want to build shared libraries from gcc/g++ output and you are on +a Sun, you must @emph{not} use GNU as, as it cannot do +position-independent code correctly yet. + +On HPUX or IRIX, you must use GAS (and configure gcc with the +@code{--with-gnu-as} option) to debug your programs. GAS is +strongly recommended particularly on the HP platform because of +limitations in the HP assembler. + +The GAS distribution has recently been merged with the binutils +distribution, so the GNU assembler and linker are now together in +this package (as of binutils version 2.5.1). + +@node Use GNU C library?, Global constructor problems, Use GNU assembler?, installation +@section Should I use the GNU C library? + +@cindex GNU C library +@cindex libg++ +At this point in time, no. The GNU C library is still very young, and +libg++ still conflicts with it in some places. Use your native C library +unless you know a lot about the gory details of libg++ and gnu-libc. This +will probably change in the future. + +@node Global constructor problems, Strange assembler errors, Use GNU C library?, installation +@section Global constructors aren't being called + +@cindex global constructors +``I've installed gcc and it almost works, but constructors and +destructors for global objects and objects at file scope aren't being +called. What did I do wrong?'' + +@cindex collect program +It appears that you are running on a platform that requires you to +install either "collect2" or the GNU linker, and you have done neither. +For more information, see the section discussing the GNU linker +(@xref{use GNU linker?}). + +@cindex constructor problems on Solaris +@cindex Solaris, constructor problems +On Solaris 2.x, you shouldn't need a collect program and GNU ld doesn't run. +If your global constructors aren't being called, you may need to install +a patch, available from Sun, to fix your linker. The number of the +``jumbo patch'' that applies is 101409-03. Thanks to Russell Street +(r.street@@auckland.ac.nz) for this info. + +@cindex IRIX, installing collect +It appears that on IRIX, the collect2 program is not being installed +by default during the installation process, though it is required; +you can install it manually by executing + +@example +make install-collect2 +@end example + +from the gcc source directory after installing the compiler. (I'm +not certain for which versions of gcc this problem occurs, and whether +it is still present). + +@node Strange assembler errors, Other problems building libg++, Global constructor problems, installation +@section Strange assembler errors when linking C++ programs + +``I've installed gcc and it seemed to go OK, but when I attempt to link +any C++ program, I'm getting strange errors from the assembler! How +can that be?'' + +The messages in question might look something like + +@example +as: "/usr/tmp/cca14605.s", line 8: error: statement syntax +as: "/usr/tmp/cca14605.s", line 14: error: statement syntax +@end example + +(on a Sun, different on other platforms). The important thing is that +the errors come out at the link step, @emph{not} when a C++ file is +being compiled. + +@cindex nm program +@cindex GNU nm program +Here's what's going on: the collect2 program uses the Unix ``nm'' +program to obtain a list of symbols for the global constructors and +destructors, and it builds a little assembly language module that +will permit them all to be called. If you're seeing this symptom, +you have an old version of GNU nm somewhere on your path. This old +version prints out symbol names in a format that the collect2 program +does not expect, so bad assembly code is generated. + +The solution is either to remove the old version of GNU nm from your +path (and that of everyone else who uses g++), or to install a newer +version (it is part of the GNU "binutils" package). Recent versions +of GNU nm do not have this problem. + +@node Other problems building libg++, More size_t problems, Strange assembler errors, installation +@section Other problems building libg++ +@cindex libg++ on Ultrix +@cindex libg++ on SunOS + +``I am having trouble building libg++. Help!'' + +On some platforms (for example, Ultrix), you may see errors complaining +about being unable to open dummy.o. On other platforms (for example, +SunOS), you may see problems having to do with the type of size_t. +The fix for these problems is to make libg++ by saying "make CC=gcc". +According to Per Bothner, it should no longer be necessary to specify +"CC=gcc" for libg++-2.3.1 or later. + +``I built and installed libg++, but g++ can't find it. Help!'' + +The string given to @file{configure} that identifies your system must +be the same when you install libg++ as it was when you installed gcc. +Also, if you used the @code{--prefix} option to install gcc somewhere +other than @file{/usr/local}, you must use the same value for +@code{--prefix} when installing libg++, or else g++ will not be able +to find libg++. + +@cindex patch for libg++-2.6.2 + +The toplevel Makefile in the libg++ 2.6.2 distribution is broken, which +along with a bug in g++ 2.6.3 causes problems linking programs that use the +libstdc++ complex classes. A patch for this is available from +@file{ftp.cygnus.com:pub/g++/libg++-2.6.2-fix.gz}. + +@node More size_t problems, Rebuild libg++?, Other problems building libg++, installation +@section But I'm @emph{still} having problems with @code{size_t}! + +@cindex Type of size_t +``I did all that, and I'm @emph{still} having problems with disagreeing +definitions of size_t, SIZE_TYPE, and the type of functions like +@code{strlen}.'' + +@cindex _G_config.h +The problem may be that you have an old version of @file{_G_config.h} +lying around. As of libg++ version 2.4, @file{_G_config.h}, since it is +platform-specific, is inserted into a different directory; most include +files are in @file{$prefix/lib/g++-include}, but this file now lives in +@file{$prefix/$arch/include}. If, after upgrading your libg++, you find that +there is an old copy of @file{_G_config.h} left around, remove it, +otherwise g++ will find the old one first. + +@node Rebuild libg++?, , More size_t problems, installation +@section Do I need to rebuild libg++ to go with my new g++? + +``After I upgraded g++ to the latest version, I'm seeing undefined +symbols.'' + +or + +``If I upgrade to a new version of g++, do I need to reinstall libg++?'' + +@cindex Incompatibilities between g++ versions + +As a rule, the first two digits of your g++ and libg++ should be the +same. Normally when you do an upgrade in the ``minor version number'' +(2.5.7 to 2.5.8, say) there isn't a need to rebuild libg++, but there +have been a couple of exceptions in the past. + +@node User Problems, legalities, installation, Top +@chapter User Problems + +@menu +* unused parameter warnings:: How to silence ``unused parameter'' warnings +* jump crosses initialization:: g++ objects to a declaration in a case statement +* 2.5.x changes in overloading:: Changes in function overloading +* Demangler:: Where can I find a demangler? +* etags for C++:: Where can I find a version of etags for C++? +* static data members:: Linker reports undefined symbols for static data members +* internal compiler error:: What does ``internal compiler error'' mean? +* bug reports:: I think I have found a bug in g++. +* porting to g++:: Porting programs from other compilers to g++ +* name mangling:: Why does g++ mangle names differently from other C++ compilers? +* problems linking with other libraries:: Why can't g++ code link with code from other C++ compilers? +* documentation:: What documentation exists for g++ 2.x? +* templates:: Problems with the template implementation +* undefined templates:: I get undefined symbols when using templates +* redundant templates:: I get multiply defined symbols when using templates +* Standard Template Library:: Does g++ support the Standard Template Library? +* agreement with standards:: What are the differences between g++ and the ARM specification of C++? +* compiling standard libraries:: Will g++ compile InterViews? The NIH class library? +* debugging on SVR4 systems:: Debugging on SVR4 systems +* X11 conflicts with libg++:: Conflict over meaning of String +* assignment to streams:: Why can't I assign one stream to another? +@end menu + +@node unused parameter warnings, jump crosses initialization, ,User Problems +@section How to silence ``unused parameter'' warnings + +@cindex -Wall +@cindex -Wunused + +``When I use @code{-Wall} (or @code{-Wunused}), g++ warns about +unused parameters. But the parameters have to be there, for use +in derived class functions. How do I get g++ to stop complaining?'' + +The answer is to simply omit the names of the unused parameters when +defining the function. This makes clear, both to g++ and to readers +of your code, that the parameter is unused. For example: + +@example +int Foo::bar(int arg) @{ return 0; @} +@end example + +will give a warning for the unused parameter @code{arg}. To suppress +the warning write + +@example +int Foo::bar(int) @{ return 0; @} +@end example + +@node jump crosses initialization, 2.5.x changes in overloading, unused parameter warnings, User Problems +@section g++ objects to a declaration in a case statement + +``The compiler objects to my declaring a variable in one of the branches +of a case statement. Earlier versions used to accept this code. Why?'' + +The draft standard does not allow a goto or a jump to a case label to +skip over an initialization of a variable or a class object. For +example: + +@example + switch ( i ) + @{ + case 1: + Object obj(0); + ... + break; + case 2: + ... + break; + @} +@end example + +The reason is that @code{obj} is also in scope in the rest of the switch +statement. + +As of version 2.7.0, the compiler will object that the jump to the +second case level crosses the initialization of @code{obj}. Older +compiler versions would object only if class Object has a destructor. +In either case, the solution is to add a set of curly braces around +the case branch: + +@example + case 1: + @{ + Object obj(0); + ... + break; + @} +@end example + +@node 2.5.x changes in overloading, Demangler, jump crosses initialization, User Problems +@section gcc 2.5.x broke my code! Changes in function overloading + +``I have a program that worked just fine with older g++ versions, but as +of version 2.5.x it doesn't work anymore. Help!'' + +@cindex hiding rule +While it's always possible that a new bug has been introduced into the +compiler, it's also possible that you have been relying on bugs in older +versions of g++. For example, version 2.5.0 was the first version of +g++ to correctly implement the ``hiding rule.'' That is, if you have +an overloaded function in a base class, and in a derived class you +redefine one of the names, the other names are effectively ``hidden''. +@emph{All} the names from the baseclass need to be redefined in the +derived class. See section 13.1 of the ARM: ``A function member of +a derived class is @emph{not} in the same scope as a function member of +the same name in a base class''. + +Here's an example that is handled incorrectly by g++ versions before 2.5.0 +and correctly by newer versions: + +@example +class Base @{ +public: + void foo(int); +@}; + +class Derived : public Base @{ +public: + void foo(double); // @emph{note that Base::foo(int) is hidden} +@}; + +main() @{ + Derived d; + d.foo(2); // @emph{Derived::foo(double), not Base::foo(int), is called} +@} +@end example + +@node Demangler, etags for C++, 2.5.x changes in overloading, User Problems +@section Where can I find a demangler? + +@cindex demangler program +A g++-compatible demangler named @code{c++filt} can be found in the +@file{binutils} distribution. This distribution (which also contains +the GNU linker) can be found at any GNU archive site. + +As of version 2.7.0, @code{c++filt} is included with gcc and is +installed automatically. Even better, it is used by the @code{collect} +linker, so you don't see mangled symbols anymore. + +@node etags for C++, static data members, Demangler, User Problems +@section Where can I find a version of etags for C++? + +@cindex etags +The libg++ distribution contains a version of etags that works for C++ +code. Look in @file{libg++/utils}. It's not built by default when you +install libg++, but you can cd to that directory and type + +@example +make etags +@end example + +after you've installed libg++. + +@node static data members, internal compiler error, etags for C++, User Problems +@section Linker reports undefined symbols for static data members + +@cindex Static data members +``g++ reports undefined symbols for all my static data members when I link, +even though the program works correctly for compiler XYZ. What's going on?'' + +The problem is almost certainly that you don't give definitions for +your static data members. If you have + +@example +class Foo @{ + ... + void method(); + static int bar; +@}; +@end example + +you have only declared that there is an int named Foo::bar and a member +function named Foo::method that is defined somewhere. You still need to +defined BOTH method() and bar in some source file. According to the draft +ANSI standard, you must supply an initializer, such as + +@example +int Foo::bar = 0; +@end example + +@noindent +in one (and only one) source file. + +@node internal compiler error, bug reports, static data members, User Problems +@section What does ``Internal compiler error'' mean? + +It means that the compiler has detected a bug in itself. Unfortunately, +g++ still has many bugs, though it is a lot better than it used to be. +If you see this message, please send in a complete bug report (see next +section). + +@node bug reports, porting to g++, internal compiler error, User Problems +@section I think I have found a bug in g++. + +@cindex Bug in g++, newly found +``I think I have found a bug in g++, but I'm not sure. How do I know, +and who should I tell?'' + +@cindex Manual, for gcc +First, see the excellent section on bugs and bug reports in the gcc manual +(which is included in the gcc distribution). As a short summary of that +section: if the compiler gets a fatal signal, for any input, it's a bug +(newer versions of g++ will ask you to send in a bug report when they +detect an error in themselves). Same thing for producing invalid +assembly code. + +When you report a bug, make sure to describe your platform (the type of +computer, and the version of the operating system it is running) and the +version of the compiler that you are running. See the output of the +command @code{g++ -v} if you aren't sure. Also provide enough code +so that the g++ maintainers can duplicate your bug. Remember that the +maintainers won't have your header files; one possibility is to send +the output of the preprocessor (use @code{g++ -E} to get this). This +is what a ``complete bug report'' means. + +I will add some extra notes that are C++-specific, since the notes from +the gcc documentation are generally C-specific. + +@cindex g++ bug report +First, mail your bug report to "bug-g++@@prep.ai.mit.edu". You may also +post to gnu.g++.bug, but it's better to use mail, particularly if you +have any doubt as to whether your news software generates correct reply +addresses. Don't mail C++ bugs to bug-gcc@@prep.ai.mit.edu. + +@cindex libg++ bug report +If your bug involves libg++ rather than the compiler, mail to +bug-lib-g++@@prep.ai.mit.edu. If you're not sure, choose one, and if you +guessed wrong, the maintainers will forward it to the other list. + +@cindex C++, reference books +@cindex ARM [Annotated C++ Ref Manual] +Second, if your program does one thing, and you think it should do +something else, it is best to consult a good reference if in doubt. +The standard reference is the draft working paper from the ANSI/ISO +C++ standardization committee, which you can get on the net. +For PostScript and PDF (Adobe Acrobat) versions, see the +archive at ftp://research.att.com/dist/stdc++/WP. For HTML and ASCII +versions, see ftp://ftp.cygnus.com/pub/g++. On the World Wide Web, see +http://www.cygnus.com/~mrs/wp-draft. + +An older +standard reference is "The Annotated C++ Reference Manual", by Ellis and +Stroustrup (copyright 1990, ISBN #0-201-51459-1). This is what they're +talking about on the net when they refer to ``the ARM''. But you should +know that changes have been made to the language since then. + +The ANSI/ISO C++ standards committee have adopted some changes to the +C++ language since the publication of the original ARM, and newer +versions of g++ (2.5.x and later) support some of these changes, notably +the mutable keyword (added in 2.5.0), the bool type (added in 2.6.0), +and changes in the scope of variables defined in for statements (added +in 2.7.0). +You can obtain an addendum to the ARM explaining these changes by FTP +from ftp.std.com in @file{/AW/stroustrup2e/new_iso.ps}. + +@cindex AT&T cfront +Note that the behavior of (any version of) AT&T's "cfront" compiler is +NOT the standard for the language. + +@node porting to g++, name mangling, bug reports, User Problems +@section Porting programs from other compilers to g++ + +``I have a program that runs on , and I want +to get it running under g++. Is there anything I should watch out +for?'' + +@cindex Porting to g++ + +Note that g++ supports many of the newer keywords that have recently +been added to the language. Your other C++ compiler may not support +them, so you may need to rename variables and members that conflict +with these keywords. + +There are two other reasons why a program that worked under one compiler +might fail under another: your program may depend on the order of +evaluation of side effects in an expression, or it may depend on the +lifetime of a temporary (you may be assuming that a temporary object +"lives" longer than the standard guarantees). As an example of the +first: + +@example +void func(int,int); + +int i = 3; +func(i++,i++); +@end example + +@cindex Order of evaluation, problems in porting +Novice programmers think that the increments will be evaluated in strict +left-to-right order. Neither C nor C++ guarantees this; the second +increment might happen first, for example. func might get 3,4, or it +might get 4,3. + +@cindex Classes, problems in porting +@cindex Problems in porting, class +The second problem often happens with classes like the libg++ String +class. Let's say I have + +@example +String func1(); +void func2(const char*); +@end example + +and I say + +@example +func2(func1()); +@end example + +because I know that class String has an "operator const char*". So what +really happens is + +@example +func2(func1().convert()); +@end example + +@cindex temporaries +where I'm pretending I have a convert() method that is the same as the +cast. This is unsafe in g++ versions before 2.6.0, because the +temporary String object may be deleted after its last use (the call to +the conversion function), leaving the pointer pointing to garbage, so by +the time func2 is called, it gets an invalid argument. + +@cindex ANSI draft standard +Both the cfront and the old g++ behaviors are legal according to the ARM, +but the powers that be have decided that compiler writers were given +too much freedom here. + +The ANSI C++ committee has now come to a resolution of the lifetime of +temporaries problem: they specify that temporaries should be deleted at +end-of-statement (and at a couple of other points). This means that g++ +versions before 2.6.0 now delete temporaries too early, and cfront +deletes temporaries too late. As of version 2.6.0, g++ does things +according to the new standard. + +@cindex Scope, problems in porting +@cindex Problems in porting, scope +For now, the safe way to write such code is to give the temporary a name, +which forces it to live until the end of the scope of the name. For +example: + +@example +String& tmp = func1(); +func2(tmp); +@end example + +Finally, like all compilers (but especially C++ compilers, it seems), +g++ has bugs, and you may have tweaked one. If so, please file a bug +report (after checking the above issues). + +@node name mangling, problems linking with other libraries, porting to g++, User Problems +@section Why does g++ mangle names differently from other C++ compilers? + +See the answer to the next question. +@cindex Mangling names + +@node problems linking with other libraries, documentation, name mangling, User Problems +@section Why can't g++ code link with code from other C++ compilers? + +``Why can't I link g++-compiled programs against libraries compiled by +some other C++ compiler?'' + +@cindex Mangling names +@cindex Cygnus Support +Some people think that, +if only the FSF and Cygnus Support folks would stop being +stubborn and mangle names the same way that, say, cfront does, then any +g++-compiled program would link successfully against any cfront-compiled +library and vice versa. Name mangling is the least of the problems. +Compilers differ as to how objects are laid out, how multiple inheritance +is implemented, how virtual function calls are handled, and so on, so if +the name mangling were made the same, your programs would link against +libraries provided from other compilers but then crash when run. For this +reason, the ARM @emph{encourages} compiler writers to make their name mangling +different from that of other compilers for the same platform. +Incompatible libraries are then detected at link time, rather than at run +time. +@cindex ARM [Annotated C++ Ref Manual] +@cindex Compiler differences + +@node documentation, templates, problems linking with other libraries, User Problems +@section What documentation exists for g++ 2.x? + +@cindex g++, documentation +Relatively little. +While the gcc manual that comes with the distribution has some coverage +of the C++ part of the compiler, it focuses mainly on the C compiler +(though the information on the ``back end'' pertains to C++ as well). +Still, there is useful information on the command line options and the +#pragma interface and #pragma implementation directives in the manual, +and there is a useful section on template instantiation in the 2.6 version. +There is a Unix-style manual entry, "g++.1", in the gcc-2.x +distribution; the information here is a subset of what is in the manual. + +You can buy a nicely printed and bound copy of this manual from the FSF; +see above for ordering information. + +For versions 2.6.2 and later, the gcc/g++ distribution contains the +gcc manual in PostScript. Also, +Postscript versions of GNU documentation in U.S. letter format +are available by anonymous FTP to primus.com in /pub/gnu-ps. +The same, in A4 format, are on liasun3.epfl.ch in /pub/gnu/ps-doc. + +A draft of a document describing the g++ internals appears in the gcc +distribution (called g++int.texi); it is still incomplete. + +@node templates, undefined templates, documentation, User Problems +@section Problems with the template implementation + +@cindex g++, template support +@cindex Templates + +g++ does not implement a separate pass to instantiate template functions +and classes at this point; for this reason, it will not work, for the most +part, to declare your template functions in one file and define them in +another. The compiler will need to see the entire definition of the +function, and will generate a static copy of the function in each file +in which it is used. + +(The experimental template repository code (see @xref{repository}) that +can be added to 2.7.0 does implement a separate pass, but there is still +no searching of files that the compiler never saw). + +@cindex -fno-implicit-templates +For version 2.6.0, however, a new switch @code{-fno-implicit-templates} +was added; with this switch, templates are expanded only under user +control. I recommend that all g++ users that use templates read the +section ``Template Instantiation'' in the gcc manual (version 2.6.x +and newer). g++ now supports explicit template expansion using the +syntax from the latest C++ working paper: + +@example +template class A; +template ostream& operator << (ostream&, const A&); +@end example + +@cindex template limitations +As of version 2.6.3, there are still a few limitations in the template +implementation besides the above (thanks to Jason Merrill for this info): + +@enumerate 1 +@item +Static data member templates are not supported. You can work around +this by explicitly declaring the static variable for each template +specialization: + +@example +template struct A @{ + static T t; +@}; + +template T A::t = 0; // gets bogus error +int A::t = 0; // OK (workaround) +@end example + +(still a limitation in 2.7.0) + +@item +Template member names are not available when defining member function +templates. + +@example +template struct A @{ + typedef T foo; + void f (foo); + void g (foo arg) @{ ... @}; // this works +@}; + +template void A::f (foo) @{ @} // gets bogus error +@end example + +@item +Templates are instantiated using the parser. This results in two +problems: + +a) Class templates are instantiated in some situations where such +instantiation should not occur. + +@example +template class A @{ @}; +A *aip = 0; // should not instantiate A (but does) +@end example + +b) Function templates cannot be inlined at the site of their +instantiation. + +@example +template inline T min (T a, T b) @{ return a < b ? a : b; @} + +void f () @{ + int i = min (1, 0); // not inlined +@} + +void g () @{ + int j = min (1, 0); // inlined +@} +@end example + +A workaround that works in version 2.6.1 and later is to specify + +@example +extern template int min (int, int); +@end example + +before @code{f()}; this will force it to be instantiated (though not +emitted). + +@item +Member function templates are always instantiated when their containing +class is. This is wrong. +@end enumerate + +@node undefined templates, redundant templates, templates, User Problems +@section I get undefined symbols when using templates + +(Thanks to Jason Merrill for this section). + +@cindex template instantiation +g++ does not automatically instantiate templates defined in other files. +Because of this, code written for cfront will often produce undefined +symbol errors when compiled with g++. You need to tell g++ which template +instances you want, by explicitly instantiating them in the file where they +are defined. For instance, given the files + +@file{templates.h}: +@example +template +class A @{ +public: + void f (); + T t; +@}; + +template void g (T a); +@end example + +@file{templates.cc}: +@example +#include "templates.h" + +template +void A::f () @{ @} + +template +void g (T a) @{ @} +@end example + + +main.cc: +@example +#include "templates.h" + +main () +@{ + A a; + a.f (); + g (a); +@} +@end example + +compiling everything with @code{g++ main.cc templates.cc} will result in +undefined symbol errors for @samp{A::f ()} and @samp{g (A)}. To +fix these errors, add the lines + +@example +template class A; +template void g (A); +@end example + +to the bottom of @samp{templates.cc} and recompile. + +@node redundant templates, Standard Template Library, undefined templates, User Problems +@section I get multiply defined symbols using templates + +You may be running into a bug that was introduced in version 2.6.1 +(and is still present in 2.6.3) that generated external linkage +for templates even when neither @code{-fexternal-templates} nor +@code{-fno-implicit-templates} is specified. There is a patch for +this problem at ftp.cygnus.com:pub/g++/gcc-2.6.3-template-fix. +I recommend either applying the patch or +using @code{-fno-implicit-templates} +together with explicit template instantiation as described in previous +sections. + +This bug is fixed in 2.7.0. + +@node Standard Template Library, agreement with standards, redundant templates, User Problems +@section Does g++ support the Standard Template Library? + +From Per Bothner: + +@cindex STL +@cindex Standard Template Library +The Standard Template Library (STL) uses many of the extensions that the +ANSI/ISO committee has made to templates, and g++ doesn't support +some of these yet. So if you grab HP's free implementation of STL it +isn't going to work. However, libg++-2.6.2 contains a +hacked version of STL, based on work by Carsten Bormann, which permits +gcc-2.6.3 to compile at least the containers. A full implementation is +going to need improved template support, which will take a while yet. + +As of libg++-2.7.0 and gcc-2.7.0, I've succeeded in making many short +STL example programs work, though there are still a number of bugs +and limitations. + +@node agreement with standards, compiling standard libraries, Standard Template Library, User Problems +@section What are the differences between g++ and the ARM specification of C++? + +@cindex ARM [Annotated C++ Ref Manual] +@cindex exceptions +As of version 2.7.0, g++ has exception support on most but not all +platforms +(no support on MIPS-based platforms yet), but +it doesn't work right if optimizaton is enabled, which means the +exception +implementation is still +not really ready for production use. + + +@cindex mutable +Some features that the ANSI/ISO standardization committee has voted in +that don't appear in the ARM are supported, notably the @code{mutable} +keyword, in version 2.5.x. 2.6.x adds support for the built-in boolean +type @code{bool}, with constants @code{true} and @code{false}. The +beginnings of run-time type identification are present, so there are +more reserved words: @code{typeid}, @code{static_cast}, +@code{reinterpret_cast}, @code{const_cast}, and @code{dynamic_cast}. + +@cindex g++ bugs +As with any beta-test compiler, there are bugs. You can help improve +the compiler by submitting detailed bug reports. + +One of the weakest areas of g++ other than templates is the resolution +of overloaded functions and operators in complex cases. The usual +symptom is that in a case where the ARM says that it is ambiguous which +function should be chosen, g++ chooses one (often the first one +declared). This is usually not a problem when porting C++ code from +other compilers to g++, but shows up as errors when code developed under +g++ is ported to other compilers. (I believe this is no longer a +significant problem in 2.7.0). + +[A full bug list would be very long indeed, so I won't put one here. +I may add a list of frequently-reported bugs and "non-bugs" like the +static class members issue mentioned above]. + +@node compiling standard libraries, debugging on SVR4 systems, agreement with standards, User Problems +@section Will g++ compile InterViews? The NIH class library? + +@cindex NIH class library +@cindex NIHCL with g++ +The NIH class library uses a non-portable, compiler-dependent hack +to initialize itself, which makes life difficult for g++ users. +It will not work without modification, and I don't know what modifications +are required or whether anyone has done them successfully. + +In short, it's not going to happen any time soon (previous FAQs referred +to patches that a new NIHCL release would hopefully contain, but this +hasn't happened). + +[ From Steinar Bang ] + +@cindex InterViews 3.1 +@cindex gcc, version 2.3.3 +@cindex libg++, version 2.3 +InterViews 3.1 compiles and runs with gcc-2.3.3 and libg++-2.3, except +that the "doc" application immediately dumps core when you try to run it. +There is also a small glitch with idraw. + +There is a patch for InterViews 3.1 from Johan Garpendahl + available for FTP from site ``ugle.unit.no''. +It is in the file + +@file{/pub/X11/contrib/InterViews/g++/3.1-beta3-patch}. + +This fixes two things: the Doc coredump, and the pattern menu of idraw. +Read the instructions at the start of the file. + +I think that as of version 2.5.6, the standard g++ will compile the +standard 3.1 InterViews completely successfully. I'd appreciate a +confirmation. + +@node debugging on SVR4 systems, X11 conflicts with libg++, compiling standard libraries, User Problems +@section Debugging on SVR4 systems +@cindex System VR4, debugging + +``How do I get debugging to work on my System V Release 4 system?'' + +Most systems based on System V Release 4 (except Solaris) encode symbolic +debugging information in a format known as `DWARF'. + +Although the GNU C compiler already knows how to write out symbolic debugging +information in the DWARF format, the GNU C++ compiler does not yet have this +feature, nor is it likely to in the immediate future. + +Ron Guilmette has done a great deal of work to try to get the GNU C++ compiler +to produce DWARF format symbolic debugging information (for C++ code) +but he gave up on the project because of a lack of funding and/or interest +from the g++ user community. If you have a strong desire to see this project +completed, contact Ron at . + +In the meantime, you @emph{can} get g++ debugging under SVR4 systems by +configuring gcc with the @code{--with-stabs} option. This causes gcc to +use an alternate debugging format, one more like that used under SunOS4. +You won't need to do anything special to GDB; it will always understand +the ``stabs'' format. + +@node X11 conflicts with libg++, assignment to streams, debugging on SVR4 systems, User Problems +@section X11 conflicts with libg++ in definition of String +@cindex String, conflicts in definition + +``X11 and Motif define String, and this conflicts with the String class +in libg++. How can I use both together?'' + +One possible method is the following: + +@example +#define String XString +#include +/* include other X11 and Motif headers */ +#undef String +@end example + +and remember to use the correct @code{String} or @code{XString} when +you declare things later. + +@node assignment to streams, ,X11 conflicts with libg++, User Problems +@section Why can't I assign one stream to another? + +[ Thanks to Per Bothner and Jerry Schwarz for this section. ] + +Assigning one stream to another seems like a reasonable thing to do, but +it's a bad idea. Usually, this comes up because people want to assign +to @code{cout}. This is poor style, especially for libraries, and is +contrary to good object-oriented design. (Libraries that write directly +to @code{cout} are less flexible, modular, and object-oriented). + +The iostream classes do not allow assigning to arbitrary streams, because +this can violate typing: + +@example +ifstream foo ("foo"); +istrstream str(...); +foo = str; +foo->close (); /* Oops! Not defined for istrstream! */ +@end example + +@cindex assignment to cout + +The original cfront implementation of iostreams by Jerry Schwarz allows +you to assign to @code{cin}, @code{cout}, @code{cerr}, and @code{clog}, +but this is not part of the draft standard for iostreams and generally +isn't considered a good idea, so standard-conforming code shouldn't use +this technique. + +The GNU implementation of iostream did not support assigning to +@code{cin}, @code{cout}, @code{cerr}, and @code{clog} +for quite a while, but it now does, for backward +compatibility with cfront iostream (versions 2.6.1 and later of libg++). + +The ANSI/ISO C++ Working Paper does provide ways of changing the +streambuf associated with a stream. Assignment isn't allowed; +there is an explicit named member that must be used. + +However, it is not wise to do this, and the results are confusing. For +example: @code{fstream::rdbuf} is supposed to return the @emph{original} +filebuf, not the one you assigned. (This is not yet implemented in GNU +iostream.) This must be so because @code{fstream::rdbuf} is defined to +return a @code{filebuf *}. + +@node legalities, index, User Problems, Top +@chapter What are the rules for shipping code built with g++ and libg++? +@cindex Shipping rules +@cindex GPL [GNU Public License] + +``Is it is possible to distribute programs for profit that are created +with g++ and use the g++ libraries?'' + +I am not a lawyer, and this is not legal advice. In any case, I have +little interest in telling people how to violate the spirit of the +GNU licenses without violating the letter. This section tells you +how to comply with the intention of the GNU licenses as best I understand +them. + +@cindex FSF [Free Software Foundation] +The FSF has no objection to your making money. Its only interest is that +source code to their programs, and libraries, and to modified versions of +their programs and libraries, is always available. + +The short answer is that you do not need to release the source to +your program, but you can't just ship a stripped executable either, +unless you use only the subset of libg++ that includes the iostreams +classes (see discussion below) or the new libstdc++ library (available +in libg++ 2.6.2 and later). + +Compiling your code with a GNU compiler does not affect its copyright; +it is still yours. However, in order to ship code that links in a GNU +library such as libg++ there are certain rules you must follow. The +rules are described in the file COPYING.LIB that accompanies gcc +distributions; it is also included in the libg++ distribution. +See that file for the exact rules. The agreement is called the +Library GNU Public License or LGPL. It is much "looser" than the +GNU Public License, or GPL, that covers must GNU programs. + +@cindex libg++, shipping code +Here's the deal: let's say that you use some version of libg++, +completely unchanged, in your software, and you want to ship only +a binary form of your code. You can do this, but there are several +special requirements. If you want to use libg++ but ship only object +code for your code, you have to ship source for libg++ (or ensure +somehow that your customer already has the source for the exact +version you are using), and ship your application in linkable form. +You cannot forbid your customer from reverse-engineering or extending +your program by exploiting its linkable form. + +@cindex libg++, modifying +Furthermore, if you modify libg++ itself, you must provide source +for your modifications (making a derived class does not count as +modifying the library -- that is "a work that uses the library"). + +@cindex special copying conditions for iostreams +For certain portions of libg++ that implement required parts of the C++ +language (such as iostreams and other standard classes), the FSF has +loosened the copyright requirement still more by adding the ``special +exception'' clause, which reads as follows: + +@quotation +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. +@end quotation + +If your only use of libg++ uses code with this exception, you may ship +stripped executables or license your executables under different +conditions without fear of violating an FSF copyright. It is the intent +of FSF and Cygnus that, as the other classes required by the ANSI/ISO +draft standard are developed, these will also be placed under this +``special exception'' license. +The code in the new libstdc++ library, intended to implement standard +classes as defined by ANSI/ISO, is also licensed this way. + +To avoid coming under the influence of the LGPL, you can link with +@file{-liostream} rather than @file{-lg++} (for version 2.6.x and +earlier), or @file{-lstdc++} now that it is available. In version 2.7.0 +all the standard classes are in @file{-lstdc++}; you can do the link +step with @code{c++} instead of @code{g++} to search only the +@file{-lstdc++} library and avoid the LGPL'ed code in @file{-lg++}. + +@node index, , legalities, Top +@comment node-name, next, previous, up +@appendix Concept Index + +@printindex cp + +@page +@contents +@bye diff --git a/gnu/lib/libg++/libg++/g++FAQ.txt b/gnu/lib/libg++/libg++/g++FAQ.txt new file mode 100644 index 00000000000..4d3e34ffec1 --- /dev/null +++ b/gnu/lib/libg++/libg++/g++FAQ.txt @@ -0,0 +1,1391 @@ +From: jbuck@synopsys.com (Joe Buck) +Newsgroups: gnu.g++.help,comp.lang.c++,news.answers,comp.answers +Subject: FAQ for g++ and libg++, plain text version [Revised 15 Sep 1995] +Followup-To: poster +Date: 2 Oct 1995 16:07:46 GMT +Organization: Synopsys, Inc. + +Archive-name: g++-FAQ/plain +Last-modified: 15 Sep 1995 +Frequency: bimonthly + +[ this is the plain text version, the parent is the texinfo version ] + + +Preface +******* + + This is a list of frequently asked questions (FAQ) for g++ users; +thanks to all those who sent suggestions for improvements. Thanks to +Marcus Speh for doing the index. + + Please send updates and corrections to the FAQ to +`jbuck@synopsys.com'. Please do *not* use me as a resource to get your +questions answered; that's what gnu.g++.help is for and I don't have +the time to support the net's use of g++. + + Many FAQs, including this one, are available on the archive site +rtfm.mit.edu, in the directory `pub/usenet/news.answers'. This FAQ may +be found in the subdirectory g++-FAQ. + + This FAQ is intended to supplement, not replace, Marshall Cline's +excellent FAQ for the C++ language and for the newsgroup comp.lang.c++. +Especially if g++ is the first C++ compiler you've ever used, the +question "How do I do with g++?" is probably really "How do I do + in C++?". You can find this FAQ on rtfm.mit.edu under +`pub/usenet/comp.lang.c++'. + +The latest poop - gcc-2.7.0 +*************************** + + This section is intended to describe more recent changes to g++, +libg++, and such. Some things in this section will eventually move +elsewhere. + + The big news is that version 2.7.0 has just been released. This, of +course, means new FAQs. I haven't had a lot of time to whip out this +section yet, so suggestions for improvement are welcome. + +gcc-2.7.0 breaks declarations in "for" statements! +================================================== + + gcc-2.7.0 implements the new ANSI/ISO rule on the scope of variables +declared in for loops. + + for (int i = 1; i <= 10; i++) { + // do something here + } + foo(i); + + In the above example, most existing C++ compilers would pass the +value 11 to the function `foo'. In gcc 2.7 and in the ANSI/ISO working +paper, the scope of `i' is only the for loop body, so this is an error. +So that old code can be compiled, the new gcc has a flag +`-fno-for-scope' that causes the old rule to be used. + +What's new in version 2.7.0 of gcc/g++ +====================================== + + The long-awaited version 2.7.0 of gcc/g++ (along with a matching +version of libg++) have now been released. This represents a great deal +of work on the part of the g++ maintainers to fix outstanding bugs and +move the compiler closer to the current ANSI/ISO standards committee's +working paper, including supporting many of the new features that have +been added to the language. I recommend that everyone read the NEWS +file contained in the distribution (and that system administrators make +the file available to their users). I've borrowed liberally from this +file here. + + If any features seem unfamiliar, you will probably want to look at +the recently-released public review copy of the C++ Working Paper. For +PostScript and PDF (Adobe Acrobat) versions, see the archive at +ftp://research.att.com/dist/stdc++/WP. For HTML and ASCII versions, +see ftp://ftp.cygnus.com/pub/g++. On the World Wide Web, see +http://www.cygnus.com/~mrs/wp-draft. + + * As described above, the scope of variables declared in the + initialization part of a for statement has been changed; such + variables are now visible only in the loop body. Use + `-fno-for-scope' to get the old behavior. You'll need this flag + to build groff version 1.09, Ptolemy, and many others. + + * Code that does not use #pragma interface/implementation will most + likely shrink dramatically, as g++ now only emits the vtable for a + class in the translation unit where its first non-inline, + non-abstract virtual function is defined. + + * Support for automatic template instantiation has *not* been enabled + in the official distribution, due to a disagreement over design + philosophies. But you can get a patch from Cygnus to turn it on; + retrieve the patch from + `ftp://ftp.cygnus.com/pub/g++/gcc-2.7.0-repo.gz'. + + * Support for exception handling has been improved; more targets are + now supported, and throws will use the RTTI mechanism to match + against the catch parameter type. You must give the + `-fhandle-exceptions' to turn it on. Optimization is *not + supported* with `-fhandle-exceptions'; no need to report this as a + bug. You'll probably get an internal compiler error if you try it. + + For exception handling to work your CPU must be a SPARC, + RS6000/PowerPC, 386/486/Pentium, or ARM. Other platforms are + missing the function to unwind the stack. + + * Support for Run-Time Type Identification has been added with + `-frtti'. This support is still in alpha; one major restriction + is that any file compiled with `-frtti' must include `' + (*not* `typeinfo.h' as the NEWS file says). Also, all code you + link with (including libg++) has to be built with `-frtti', so + it's still tricky to use. + + * Synthesis of compiler-generated constructors, destructors and + assignment operators is now deferred until the functions are used. + + * The parsing of expressions such as `a ? b : c = 1' has changed from + `(a ? b : c) = 1' to `a : b ? (c = 1)'. This is a new C/C++ + incompatibility brought to you by the ANSI/ISO standards committee. + + * The operator keywords and, and_eq, bitand, bitor, compl, not, + not_eq, or, or_eq, xor and xor_eq are now supported. Use `-ansi' + or `-foperator-names' to enable them. + + * The `explicit' keyword is now supported. `explicit' is used to + mark constructors and type conversion operators that should not be + used implicitly. + + * Handling of user-defined type conversion has been improved. + + * Explicit instantiation of template methods is now supported. Also, + `inline template class foo;' can be used to emit only the + vtable for a template class. + + * With -fcheck-new, g++ will check the return value of all calls to + operator new, and not attempt to modify a returned null pointer. + + * collect2 now demangles linker output, and c++filt has become part + of the gcc distribution. + + * Improvements to template instantiation: only members actually used + are instantiated. + +How do I use the new repository code? +===================================== + + Because there is some disagreement about the details of the template +repository mechanism, you'll need to obtain a patch from Cygnus Support +to enable the 2.7.0 repository code. You can obtain the patch by +anonymous FTP: `ftp://ftp.cygnus.com/pub/g++/gcc-2.7.0-repo.gz'. + + After you've applied the patch, the `-frepo' flag will enable the +repository mechanism. The flag works much like the existing +`-fno-implicit-templates' flag, except that auxiliary files, with an +`.rpo' extension, are built that specify what template expansions are +needed. At link time, the (patched) collect program detects missing +templates and recompiles some of the object files so that the required +templates are expanded. + + Note that the mechanism differs from that of cfront in that template +definitions still must be visible at the point where they are to be +expanded. No assumption is made that `foo.C' contains template +definitions corresponding to template declarations in `foo.h'. + + Jason Merrill writes: "To perform closure on a set of objects, just +try to link them together. It will fail, but as a side effect all +needed instances will be generated in the objects." + +The GNU Standard C++ Library +============================ + + The GNU Standard C++ Library (also called the "GNU ANSI C++ Library" +in places in the code) is not libg++, though it is included in the +libg++ distribution. Rather, it contains classes and functions +required by the ANSI/ISO standard. The copyright conditions are the +same as those for for the iostreams classes; the LGPL is not used. See +*Note legalities::. + + This library, libstdc++, is in the libg++ distribution in versions +2.6.2 and later. It requires at least gcc 2.6.3 to build the +libg++-2.6.2 version; use at least gcc 2.7.0 to build the libg++ 2.7.0 +version. It contains a hacked-up version of HP's implementation of the +Standard Template Library (see *Note Standard Template Library::). I've +successfully used this Standard Template Library version to build a +number of the demos you'll see on various web pages. + + As of version 2.7.0, the streams classes are now in libstdc++ +instead of libg++, and libiostream is being phased out (don't use it). +The g++ program searches this library. + +Obtaining Source Code +********************* + +What is the latest version of gcc, g++, and libg++? +=================================================== + + The latest "2.x" version of gcc/g++ is 2.7.0, released June 16, 1995. +The latest version of libg++ is 2.7.0a, released June 19, 1995 (2.7.0 +had an error in a makefile and was almost immediately replaced). . +Don't use 2.5.x, with x less than 5, for C++ code; there were some +serious bugs that didn't have easy workarounds. 2.5.8 is the most +solid 2.5.x release. 2.6.3 is the most solid 2.6.x release. + + For some non-Unix platforms, the latest port of gcc may be an earlier +version (2.5.8, say). You'll need to use a version of libg++ that has +the same first two digits as the compiler version, e.g. use libg++ +2.5.x (for the latest x you can find) with gcc version 2.5.8. + + The latest "1.x" version of gcc is 1.42, and the latest "1.x" +version of g++ is 1.42.0. While gcc 1.42 is quite usable for C +programs, I recommend against using g++ 1.x except in special +circumstances (and I can't think of any such circumstances). + +How do I get a copy of g++ for Unix? +==================================== + + First, you may already have it if you have gcc for your platform; +g++ and gcc are combined now (as of gcc version 2.0). + + You can get g++ from a friend who has a copy, by anonymous FTP or +UUCP, or by ordering a tape or CD-ROM from the Free Software Foundation. + + The Free Software Foundation is a nonprofit organization that +distributes software and manuals to raise funds for more GNU +development. Getting your copy from the FSF contributes directly to +paying staff to develop GNU software. CD-ROMs cost $400 if an +organization is buying, or $100 if an individual is buying. Tapes cost +around $200 depending on media type. I recommend asking for version 2, +not version 1, of g++. + + For more information about ordering from the FSF, contact +gnu@prep.ai.mit.edu, phone (617) 542-5942 or anonymous ftp file +`ftp://prep.ai.mit.edu/pub/gnu/GNUinfo/ORDERS' (you can also use one of +the sites listed below if you can't get into "prep"). + + Here is a list of anonymous FTP archive sites for GNU software. If +no directory is given, look in `/pub/gnu'. + + ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep, + cair.kaist.ac.kr, ftp.nectec.or.th:/pub/mirrors/gnu + + AUSTRALIA: archie.oz.au:/gnu (archie.oz or archie.oz.au for ACSnet) + + AFRICA: ftp.sun.ac.za + + MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu + + EUROPE: irisa.irisa.fr, ftp.univ-lyon1.fr:, ftp.mcc.ac.uk, + unix.hensa.ac.uk:/pub/uunet/systems/gnu, ftp.denet.dk, + src.doc.ic.ac.uk:/gnu, ftp.eunet.ch, nic.switch.ch:/mirror/gnu, + ftp.informatik.rwth-aachen.de, ftp.informatik.tu-muenchen.de, + ftp.win.tue.nl, ftp.funet.fi, ftp.stacken.kth.se, isy.liu.se, + ftp.luth.se:/pub/unix/gnu, ftp.sunet.se, archive.eu.net + + SOUTH AMERICA: ftp.unicamp.br, ftp.inf.utfsm.cl + + WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu + + USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu, + ftp.digex.net, ftp.kpc.com:/pub/mirror/gnu, + f.ms.uky.edu:/pub3/gnu, jaguar.utah.edu:/gnustuff, + ftp.hawaii.edu:/mirrors/gnu, vixen.cso.uiuc.edu:/gnu, + mrcnext.cso.uiuc.edu, ftp.cs.columbia.edu:/archives/gnu/prep, + col.hp.com:/mirrors/gnu, gatekeeper.dec.com:/pub/GNU, + ftp.uu.net:/systems/gnu + + The "official site" is prep.ai.mit.edu, but your transfer will +probably go faster if you use one of the above machines. + + Most GNU utilities are compressed with "gzip", the GNU compression +utility. All GNU archive sites should have a copy of this program, +which you will need to uncompress the distributions. + + UUNET customers can get GNU sources from UUNET via UUCP. UUCP-only +sites can get GNU sources by "anonymous UUCP" from site "osu-cis" at +Ohio State University. You pay for the long-distance call to OSU; the +price isn't too bad on weekends at 9600 bps. Send mail to +uucp@cis.ohio-state.edu or osu-cis!uucp for more information. + + OSU lines are often busy. If you're in the USA, and are willing to +spend more money, you can get sources via UUCP from UUNET using their +900 number: 1-900-GOT-SRCS (900 numbers don't work internationally). +You will be billed $0.50/minute by your phone company. + + Don't forget to retrieve libg++ as well! + +Getting gcc/g++ for the HP Precision Architecture +================================================= + + If you use the HP Precision Architecture (HP-9000/7xx and +HP-9000/8xx) and you want to use debugging, you'll need to use the GNU +assembler, GAS (version 2.3 or later). If you build from source, you +must tell the configure program that you are using GAS or you won't get +debugging support. A non-standard debug format is used, since until +recently HP considered their debug format a trade secret. Thanks to +the work of lots of good folks both inside and outside HP, the company +has seen the error of its ways and has now released the required +information. The team at the University of Utah that did the gcc port +now has code that understands the native HP format. + + Some enhancements for the HP that haven't been integrated back into +the official GCC are available from the University of Utah, site +jaguar.cs.utah.edu. You can retrieve sources and prebuilt binaries for +GCC, GDB, binutils,and libg++; see the directory `/dist'. + + The libg++ version is actually the same as the FSF 2.6. The Utah +version of GDB can now understand both the GCC and HP C compiler debug +formats, so it is no longer necessary to have two different GDB +versions. + + I recommend that HP users use the Utah versions of the tools (see +above), though at this point the standard FSF versions will work well. + + HP GNU users can also find useful stuff on the site geod.emr.ca in +the `/pub/UNIX/GNU-HP' directory. + + Jeff Law is leaving the University of Utah, so the Utah prebuilt +binaries may be discontinued. + +Getting gcc/g++ binaries for Solaris 2.x +======================================== + + "Sun took the C compiler out of Solaris 2.x. Am I stuck?" + + No; prep.ai.mit.edu and its mirror sites provide GCC binaries for +Solaris. As a rule, these binaries are not updated as often as the +sources are, so if you want the very latest version of gcc/g++, you may +need to grab and install binaries for an older version and use it to +bootstrap the latest version from source. + + The latest gcc binaries on prep.ai.mit.edu and its mirror sites are +for version 2.5.6 for Solaris on the Sparc, and version 2.4.5 for +Solaris on Intel 386/486 machines. There are also binaries for "gzip", +the GNU compression utility, which you'll need for uncompressing the +binary distribution. On any GNU archive site, look in subdirectories +`i486-sun-solaris2' or `sparc-sun-solaris2'. + + The ftp directory /pub/GNU on site ftp.quintus.com contains various +GNU and freeware programs for Solaris2.X running on the sparc. These are +packaged to enable installation using the Solaris "pkgadd" utility. +These include GNU emacs 19.27, gcc (and g++) 2.6.0, Perl 4.036, and +others. + +How do I get a copy of g++ for (some other platform)? +===================================================== + + The standard gcc/g++ distribution includes VMS support. Since the +FSF people don't use VMS, it's likely to be somewhat less solid than +the Unix version. Precompiled copies of g++ and libg++ in +VMS-installable form are available by FTP from mango.rsmas.miami.edu. +See also the site ftp.stacken.kth.se (in Sweden), directory +/pub/GNU-VMS/contrib, which has gcc-2.5.8 and libg++-2.5.3. + + There are two different versions of gcc/g++ for MS-DOS: EMX and +DJGPP. EMX also works for OS/2 and is described later. DJGPP is DJ +Delorie's port. It can be found on many FTP archive sites; its "home" +is on oak.oakland.edu, directory `~ftp/pub/msdos/djgpp'. + + The latest version of DJGPP is 1.12.maint1. This version runs under +Windows 3.x. It includes a port of gcc 2.6.0, plus support software. + + FSF sells floppies with DJGPP on them; see above for ordering +software from the FSF. + + A new Usenet group, `comp.os.msdos.djgpp', has recently been created. + + For information on Amiga ports of gcc/g++, retrieve the file +`/pub/gnu/MicrosPorts/Amiga' from prep.ai.mit.edu, or write to Markus +M. Wild , who I hope won't be too upset that +I mentioned his name here. + + A port of gcc to the Atari ST can be found on the site +"atari.archive.umich.edu", under `/atari/Gnustuff/Tos', along with many +other GNU programs. This version is usually the same as the latest FSF +release. See the "Software FAQ" for the Usenet group +"comp.sys.atari.st" for more information. + + There are two different ports of gcc to OS/2, the so-called EMX port +(which also runs on MS-DOS), and a port called "gcc/2". The latter +port is no longer supported, since the EMX port includes all of its +functionality. The EMX port's C library attempts to provide a +Unix-like environment. For more information ask around on +"comp.os.os2.programmer.misc". + + The EMX port is available by FTP from + + ftp.uni-stuttgart.de(129.69.1.12) in /pub/systems/os2/emx-0.9a + src.doc.ic.ac.uk(146.169.2.1) in /pub/packages/os2/unix/emx09a + ftp.informatik.tu-muenchen.de(131.159.0.198) in + /pub/comp/os/os2/devtools/emx+gcc + + Eberhard Mattes did the EMX port. His address is +mattes@azu.informatik.uni-stuttgart.de. + + I'm looking for more information on gcc/g++ support on the Apple +Macintosh. Until recently, this FAQ did not provide such information, +but FSF is no longer boycotting Apple as the League for Programming +Freedom boycott has been dropped. + + Mike White (cons116@twain.oit.umass.edu) says: "Versions 1.37.1 and +2.3.3 of gcc were ported by Stan Shebs and are available at +ftp.cygnus.com under /pub/shebs. They are both interfaced to MPW. +Shebs is apparently working on a cross compiler of 2.6.3 to create Mac +apps from Unix boxes." + + I don't know anything about more recent versions. + +But I can only find g++-1.42! +============================= + + "I keep hearing people talking about g++ 2.5.8 (or some other number +starting with 2), but the latest version I can find is g++ 1.42. Where +is it?" + + As of gcc 2.0, C, C++, and Objective-C as well are all combined into +a single distribution called gcc. If you get gcc you already have g++. +The standard installation procedure for any gcc version 2 compiler will +install the C++ compiler as well. + + One could argue that we shouldn't even refer to "g++-2.x.y" but it's +a convention. It means "the C++ compiler included with gcc-2.x.y." + +Installation Issues and Problems +******************************** + +I can't build g++ 1.x.y with gcc-2.x.y! +======================================= + + "I obtained gcc-2.x.y and g++ 1.x.y and I'm trying to build it, but +I'm having major problems. What's going on?" + + If you wish to build g++-1.42, you must obtain gcc-1.42 first. The +installation instructions for g++ version 1 leave a lot to be desired, +unfortunately, and I would recommend that, unless you have a special +reason for needing the 1.x compiler, that C++ users use the latest +g++-2.x version, as it is the version that is being actively maintained. + + There is no template support in g++-1.x, and it is generally much +further away from the ANSI draft standard than g++-2.x is. + +OK, I've obtained gcc; what else do I need? +=========================================== + + First off, you'll want libg++ as you can do almost nothing without it +(unless you replace it with some other class library). + + Second, depending on your platform, you may need "GAS", the GNU +assembler, or the GNU linker (see next question). + + Finally, while it is not required, you'll almost certainly want the +GNU debugger, gdb. The latest version is 4.14, released March 2, 1995. +Other debuggers (like dbx, for example) will normally not be able to +understand at least some of the debug information produced by g++. + +Should I use the GNU linker, or should I use "collect"? +======================================================= + + First off, for novices: special measures must be taken with C++ to +arrange for the calling of constructors for global or static objects +before the execution of your program, and for the calling of +destructors at the end. (Exception: System VR3 and System VR4 linkers, +Linux/ELF, and some other systems support user-defined segments; g++ on +these systems requires neither the GNU linker nor collect. So if you +have such a system, the answer is that you don't need either one). + + If you have experience with AT&T's "cfront", this function is +performed there by programs named "patch" or "munch". With GNU C++, it +is performed either by the GNU linker or by a program known as +"collect". The collect program is part of the gcc-2.x distribution; +you can obtain the GNU linker separately as part of the "binutils" +package. The latest version of binutils is 2.5.2, released November 2, +1994. + + (To be technical, it's "collect2"; there were originally several +alternative versions of collect, and this is the one that survived). + + There are advantages and disadvantages to either choice. + + Advantages of the GNU linker: + + It's faster than using collect - collect basically runs the standard +Unix linker on your program twice, inserting some extra code after the +first pass to call the constructors. This is a sizable time penalty +for large programs. The GNU linker does not require this extra pass. + + GNU ld reports undefined symbols using their true names, not the +mangled names (but as of 2.7.0 so does collect). + + If there are undefined symbols, GNU ld reports which object file(s) +refer to the undefined symbol(s). + + As of binutils version 2.2, on systems that use the so-called "a.out" +debug format (e.g. Suns running SunOS 4.x), the GNU linker compresses +the debug symbol table considerably. + + Advantages of collect: + + If your native linker supports shared libraries, you can use shared +libraries with collect. This used to be a strong reason *not* to use +the GNU linker, but recent versions of GNU ld support linking with +shared libraries on many platforms, and creating shared libraries on a +few (such as Intel x86 systems that use ELF object format). + + Note: using existing shared libraries (X and libc, for example) works +very nicely. Generating shared libraries from g++-compiled code is +another matter, generally requiring OS-dependent tricks if it is +possible at all. But progress has been made recently. + + As of 2.7.0, building C++ shared libraries should work fine on +supported platforms (HPUX 9+, IRIX 5+, DEC UNIX (formerly OSF/1), SunOS +4, and all targets using SVR4-style ELF shared libraries). + + However, as of libg++ 2.6.2, the libg++ distribution contains some +patches to build libg++ as a shared library on some OSes (those listed +above). Check the file `README.SHLIB' from that distribution. + + The GNU linker has not been ported to as many platforms as g++ has, +so you may be forced to use collect. + + If you use collect, you don't need to get something extra and figure +out how to install it; the standard gcc installation procedure will do +it for you. + + In conclusion, I don't see a clear win for either alternative at this +point. Take your pick. + +Should I use the GNU assembler, or my vendor's assembler? +========================================================= + + This depends on your platform and your decision about the GNU +linker. For most platforms, you'll need to use GAS if you use the GNU +linker. For some platforms, you have no choice; check the gcc +installation notes to see whether you must use GAS. But you can +usually use the vendor's assembler if you don't use the GNU linker. + + The GNU assembler assembles faster than many native assemblers; +however, on many platforms it cannot support the local debugging format. + + If you want to build shared libraries from gcc/g++ output and you +are on a Sun, you must *not* use GNU as, as it cannot do +position-independent code correctly yet. + + On HPUX or IRIX, you must use GAS (and configure gcc with the +`--with-gnu-as' option) to debug your programs. GAS is strongly +recommended particularly on the HP platform because of limitations in +the HP assembler. + + The GAS distribution has recently been merged with the binutils +distribution, so the GNU assembler and linker are now together in this +package (as of binutils version 2.5.1). + +Should I use the GNU C library? +=============================== + + At this point in time, no. The GNU C library is still very young, +and libg++ still conflicts with it in some places. Use your native C +library unless you know a lot about the gory details of libg++ and +gnu-libc. This will probably change in the future. + +Global constructors aren't being called +======================================= + + "I've installed gcc and it almost works, but constructors and +destructors for global objects and objects at file scope aren't being +called. What did I do wrong?" + + It appears that you are running on a platform that requires you to +install either "collect2" or the GNU linker, and you have done neither. +For more information, see the section discussing the GNU linker (*Note +use GNU linker?::). + + On Solaris 2.x, you shouldn't need a collect program and GNU ld +doesn't run. If your global constructors aren't being called, you may +need to install a patch, available from Sun, to fix your linker. The +number of the "jumbo patch" that applies is 101409-03. Thanks to +Russell Street (r.street@auckland.ac.nz) for this info. + + It appears that on IRIX, the collect2 program is not being installed +by default during the installation process, though it is required; you +can install it manually by executing + + make install-collect2 + + from the gcc source directory after installing the compiler. (I'm +not certain for which versions of gcc this problem occurs, and whether +it is still present). + +Strange assembler errors when linking C++ programs +================================================== + + "I've installed gcc and it seemed to go OK, but when I attempt to +link any C++ program, I'm getting strange errors from the assembler! +How can that be?" + + The messages in question might look something like + + as: "/usr/tmp/cca14605.s", line 8: error: statement syntax + as: "/usr/tmp/cca14605.s", line 14: error: statement syntax + + (on a Sun, different on other platforms). The important thing is +that the errors come out at the link step, *not* when a C++ file is +being compiled. + + Here's what's going on: the collect2 program uses the Unix "nm" +program to obtain a list of symbols for the global constructors and +destructors, and it builds a little assembly language module that will +permit them all to be called. If you're seeing this symptom, you have +an old version of GNU nm somewhere on your path. This old version +prints out symbol names in a format that the collect2 program does not +expect, so bad assembly code is generated. + + The solution is either to remove the old version of GNU nm from your +path (and that of everyone else who uses g++), or to install a newer +version (it is part of the GNU "binutils" package). Recent versions of +GNU nm do not have this problem. + +Other problems building libg++ +============================== + + "I am having trouble building libg++. Help!" + + On some platforms (for example, Ultrix), you may see errors +complaining about being unable to open dummy.o. On other platforms +(for example, SunOS), you may see problems having to do with the type +of size_t. The fix for these problems is to make libg++ by saying +"make CC=gcc". According to Per Bothner, it should no longer be +necessary to specify "CC=gcc" for libg++-2.3.1 or later. + + "I built and installed libg++, but g++ can't find it. Help!" + + The string given to `configure' that identifies your system must be +the same when you install libg++ as it was when you installed gcc. +Also, if you used the `--prefix' option to install gcc somewhere other +than `/usr/local', you must use the same value for `--prefix' when +installing libg++, or else g++ will not be able to find libg++. + + The toplevel Makefile in the libg++ 2.6.2 distribution is broken, +which along with a bug in g++ 2.6.3 causes problems linking programs +that use the libstdc++ complex classes. A patch for this is available +from `ftp.cygnus.com:pub/g++/libg++-2.6.2-fix.gz'. + +But I'm *still* having problems with `size_t'! +============================================== + + "I did all that, and I'm *still* having problems with disagreeing +definitions of size_t, SIZE_TYPE, and the type of functions like +`strlen'." + + The problem may be that you have an old version of `_G_config.h' +lying around. As of libg++ version 2.4, `_G_config.h', since it is +platform-specific, is inserted into a different directory; most include +files are in `$prefix/lib/g++-include', but this file now lives in +`$prefix/$arch/include'. If, after upgrading your libg++, you find that +there is an old copy of `_G_config.h' left around, remove it, otherwise +g++ will find the old one first. + +Do I need to rebuild libg++ to go with my new g++? +================================================== + + "After I upgraded g++ to the latest version, I'm seeing undefined +symbols." + + or + + "If I upgrade to a new version of g++, do I need to reinstall +libg++?" + + As a rule, the first two digits of your g++ and libg++ should be the +same. Normally when you do an upgrade in the "minor version number" +(2.5.7 to 2.5.8, say) there isn't a need to rebuild libg++, but there +have been a couple of exceptions in the past. + +User Problems +************* + +How to silence "unused parameter" warnings +========================================== + + "When I use `-Wall' (or `-Wunused'), g++ warns about unused +parameters. But the parameters have to be there, for use in derived +class functions. How do I get g++ to stop complaining?" + + The answer is to simply omit the names of the unused parameters when +defining the function. This makes clear, both to g++ and to readers of +your code, that the parameter is unused. For example: + + int Foo::bar(int arg) { return 0; } + + will give a warning for the unused parameter `arg'. To suppress the +warning write + + int Foo::bar(int) { return 0; } + +g++ objects to a declaration in a case statement +================================================ + + "The compiler objects to my declaring a variable in one of the +branches of a case statement. Earlier versions used to accept this +code. Why?" + + The draft standard does not allow a goto or a jump to a case label to +skip over an initialization of a variable or a class object. For +example: + + switch ( i ) + { + case 1: + Object obj(0); + ... + break; + case 2: + ... + break; + } + + The reason is that `obj' is also in scope in the rest of the switch +statement. + + As of version 2.7.0, the compiler will object that the jump to the +second case level crosses the initialization of `obj'. Older compiler +versions would object only if class Object has a destructor. In either +case, the solution is to add a set of curly braces around the case +branch: + + case 1: + { + Object obj(0); + ... + break; + } + +gcc 2.5.x broke my code! Changes in function overloading +========================================================= + + "I have a program that worked just fine with older g++ versions, but +as of version 2.5.x it doesn't work anymore. Help!" + + While it's always possible that a new bug has been introduced into +the compiler, it's also possible that you have been relying on bugs in +older versions of g++. For example, version 2.5.0 was the first +version of g++ to correctly implement the "hiding rule." That is, if +you have an overloaded function in a base class, and in a derived class +you redefine one of the names, the other names are effectively "hidden". +*All* the names from the baseclass need to be redefined in the derived +class. See section 13.1 of the ARM: "A function member of a derived +class is *not* in the same scope as a function member of the same name +in a base class". + + Here's an example that is handled incorrectly by g++ versions before +2.5.0 and correctly by newer versions: + + class Base { + public: + void foo(int); + }; + + class Derived : public Base { + public: + void foo(double); // *note that Base::foo(int) is hidden* + }; + + main() { + Derived d; + d.foo(2); // *Derived::foo(double), not Base::foo(int), is called* + } + +Where can I find a demangler? +============================= + + A g++-compatible demangler named `c++filt' can be found in the +`binutils' distribution. This distribution (which also contains the +GNU linker) can be found at any GNU archive site. + + As of version 2.7.0, `c++filt' is included with gcc and is installed +automatically. Even better, it is used by the `collect' linker, so you +don't see mangled symbols anymore. + +Where can I find a version of etags for C++? +============================================ + + The libg++ distribution contains a version of etags that works for +C++ code. Look in `libg++/utils'. It's not built by default when you +install libg++, but you can cd to that directory and type + + make etags + + after you've installed libg++. + +Linker reports undefined symbols for static data members +======================================================== + + "g++ reports undefined symbols for all my static data members when I +link, even though the program works correctly for compiler XYZ. What's +going on?" + + The problem is almost certainly that you don't give definitions for +your static data members. If you have + + class Foo { + ... + void method(); + static int bar; + }; + + you have only declared that there is an int named Foo::bar and a +member function named Foo::method that is defined somewhere. You still +need to defined BOTH method() and bar in some source file. According +to the draft ANSI standard, you must supply an initializer, such as + + int Foo::bar = 0; + +in one (and only one) source file. + +What does "Internal compiler error" mean? +========================================= + + It means that the compiler has detected a bug in itself. +Unfortunately, g++ still has many bugs, though it is a lot better than +it used to be. If you see this message, please send in a complete bug +report (see next section). + +I think I have found a bug in g++. +================================== + + "I think I have found a bug in g++, but I'm not sure. How do I know, +and who should I tell?" + + First, see the excellent section on bugs and bug reports in the gcc +manual (which is included in the gcc distribution). As a short summary +of that section: if the compiler gets a fatal signal, for any input, +it's a bug (newer versions of g++ will ask you to send in a bug report +when they detect an error in themselves). Same thing for producing +invalid assembly code. + + When you report a bug, make sure to describe your platform (the type +of computer, and the version of the operating system it is running) and +the version of the compiler that you are running. See the output of the +command `g++ -v' if you aren't sure. Also provide enough code so that +the g++ maintainers can duplicate your bug. Remember that the +maintainers won't have your header files; one possibility is to send +the output of the preprocessor (use `g++ -E' to get this). This is +what a "complete bug report" means. + + I will add some extra notes that are C++-specific, since the notes +from the gcc documentation are generally C-specific. + + First, mail your bug report to "bug-g++@prep.ai.mit.edu". You may +also post to gnu.g++.bug, but it's better to use mail, particularly if +you have any doubt as to whether your news software generates correct +reply addresses. Don't mail C++ bugs to bug-gcc@prep.ai.mit.edu. + + If your bug involves libg++ rather than the compiler, mail to +bug-lib-g++@prep.ai.mit.edu. If you're not sure, choose one, and if you +guessed wrong, the maintainers will forward it to the other list. + + Second, if your program does one thing, and you think it should do +something else, it is best to consult a good reference if in doubt. +The standard reference is the draft working paper from the ANSI/ISO C++ +standardization committee, which you can get on the net. For +PostScript and PDF (Adobe Acrobat) versions, see the archive at +ftp://research.att.com/dist/stdc++/WP. For HTML and ASCII versions, +see ftp://ftp.cygnus.com/pub/g++. On the World Wide Web, see +http://www.cygnus.com/~mrs/wp-draft. + + An older standard reference is "The Annotated C++ Reference Manual", +by Ellis and Stroustrup (copyright 1990, ISBN #0-201-51459-1). This is +what they're talking about on the net when they refer to "the ARM". +But you should know that changes have been made to the language since +then. + + The ANSI/ISO C++ standards committee have adopted some changes to the +C++ language since the publication of the original ARM, and newer +versions of g++ (2.5.x and later) support some of these changes, notably +the mutable keyword (added in 2.5.0), the bool type (added in 2.6.0), +and changes in the scope of variables defined in for statements (added +in 2.7.0). You can obtain an addendum to the ARM explaining these +changes by FTP from ftp.std.com in `/AW/stroustrup2e/new_iso.ps'. + + Note that the behavior of (any version of) AT&T's "cfront" compiler +is NOT the standard for the language. + +Porting programs from other compilers to g++ +============================================ + + "I have a program that runs on , and I want +to get it running under g++. Is there anything I should watch out for?" + + Note that g++ supports many of the newer keywords that have recently +been added to the language. Your other C++ compiler may not support +them, so you may need to rename variables and members that conflict +with these keywords. + + There are two other reasons why a program that worked under one +compiler might fail under another: your program may depend on the order +of evaluation of side effects in an expression, or it may depend on the +lifetime of a temporary (you may be assuming that a temporary object +"lives" longer than the standard guarantees). As an example of the +first: + + void func(int,int); + + int i = 3; + func(i++,i++); + + Novice programmers think that the increments will be evaluated in +strict left-to-right order. Neither C nor C++ guarantees this; the +second increment might happen first, for example. func might get 3,4, +or it might get 4,3. + + The second problem often happens with classes like the libg++ String +class. Let's say I have + + String func1(); + void func2(const char*); + + and I say + + func2(func1()); + + because I know that class String has an "operator const char*". So +what really happens is + + func2(func1().convert()); + + where I'm pretending I have a convert() method that is the same as +the cast. This is unsafe in g++ versions before 2.6.0, because the +temporary String object may be deleted after its last use (the call to +the conversion function), leaving the pointer pointing to garbage, so by +the time func2 is called, it gets an invalid argument. + + Both the cfront and the old g++ behaviors are legal according to the +ARM, but the powers that be have decided that compiler writers were +given too much freedom here. + + The ANSI C++ committee has now come to a resolution of the lifetime +of temporaries problem: they specify that temporaries should be deleted +at end-of-statement (and at a couple of other points). This means that +g++ versions before 2.6.0 now delete temporaries too early, and cfront +deletes temporaries too late. As of version 2.6.0, g++ does things +according to the new standard. + + For now, the safe way to write such code is to give the temporary a +name, which forces it to live until the end of the scope of the name. +For example: + + String& tmp = func1(); + func2(tmp); + + Finally, like all compilers (but especially C++ compilers, it seems), +g++ has bugs, and you may have tweaked one. If so, please file a bug +report (after checking the above issues). + +Why does g++ mangle names differently from other C++ compilers? +=============================================================== + + See the answer to the next question. + +Why can't g++ code link with code from other C++ compilers? +=========================================================== + + "Why can't I link g++-compiled programs against libraries compiled by +some other C++ compiler?" + + Some people think that, if only the FSF and Cygnus Support folks +would stop being stubborn and mangle names the same way that, say, +cfront does, then any g++-compiled program would link successfully +against any cfront-compiled library and vice versa. Name mangling is +the least of the problems. Compilers differ as to how objects are laid +out, how multiple inheritance is implemented, how virtual function +calls are handled, and so on, so if the name mangling were made the +same, your programs would link against libraries provided from other +compilers but then crash when run. For this reason, the ARM +*encourages* compiler writers to make their name mangling different +from that of other compilers for the same platform. Incompatible +libraries are then detected at link time, rather than at run time. + +What documentation exists for g++ 2.x? +====================================== + + Relatively little. While the gcc manual that comes with the +distribution has some coverage of the C++ part of the compiler, it +focuses mainly on the C compiler (though the information on the "back +end" pertains to C++ as well). Still, there is useful information on +the command line options and the #pragma interface and #pragma +implementation directives in the manual, and there is a useful section +on template instantiation in the 2.6 version. There is a Unix-style +manual entry, "g++.1", in the gcc-2.x distribution; the information +here is a subset of what is in the manual. + + You can buy a nicely printed and bound copy of this manual from the +FSF; see above for ordering information. + + For versions 2.6.2 and later, the gcc/g++ distribution contains the +gcc manual in PostScript. Also, Postscript versions of GNU +documentation in U.S. letter format are available by anonymous FTP to +primus.com in /pub/gnu-ps. The same, in A4 format, are on +liasun3.epfl.ch in /pub/gnu/ps-doc. + + A draft of a document describing the g++ internals appears in the gcc +distribution (called g++int.texi); it is still incomplete. + +Problems with the template implementation +========================================= + + g++ does not implement a separate pass to instantiate template +functions and classes at this point; for this reason, it will not work, +for the most part, to declare your template functions in one file and +define them in another. The compiler will need to see the entire +definition of the function, and will generate a static copy of the +function in each file in which it is used. + + (The experimental template repository code (see *Note repository::) +that can be added to 2.7.0 does implement a separate pass, but there is +still no searching of files that the compiler never saw). + + For version 2.6.0, however, a new switch `-fno-implicit-templates' +was added; with this switch, templates are expanded only under user +control. I recommend that all g++ users that use templates read the +section "Template Instantiation" in the gcc manual (version 2.6.x and +newer). g++ now supports explicit template expansion using the syntax +from the latest C++ working paper: + + template class A; + template ostream& operator << (ostream&, const A&); + + As of version 2.6.3, there are still a few limitations in the +template implementation besides the above (thanks to Jason Merrill for +this info): + + 1. Static data member templates are not supported. You can work + around this by explicitly declaring the static variable for each + template specialization: + + template struct A { + static T t; + }; + + template T A::t = 0; // gets bogus error + int A::t = 0; // OK (workaround) + + (still a limitation in 2.7.0) + + 2. Template member names are not available when defining member + function templates. + + template struct A { + typedef T foo; + void f (foo); + void g (foo arg) { ... }; // this works + }; + + template void A::f (foo) { } // gets bogus error + + 3. Templates are instantiated using the parser. This results in two + problems: + + a) Class templates are instantiated in some situations where such + instantiation should not occur. + + template class A { }; + A *aip = 0; // should not instantiate A (but does) + + b) Function templates cannot be inlined at the site of their + instantiation. + + template inline T min (T a, T b) { return a < b ? a : b; } + + void f () { + int i = min (1, 0); // not inlined + } + + void g () { + int j = min (1, 0); // inlined + } + + A workaround that works in version 2.6.1 and later is to specify + + extern template int min (int, int); + + before `f()'; this will force it to be instantiated (though not + emitted). + + 4. Member function templates are always instantiated when their + containing class is. This is wrong. + +I get undefined symbols when using templates +============================================ + + (Thanks to Jason Merrill for this section). + + g++ does not automatically instantiate templates defined in other +files. Because of this, code written for cfront will often produce +undefined symbol errors when compiled with g++. You need to tell g++ +which template instances you want, by explicitly instantiating them in +the file where they are defined. For instance, given the files + + `templates.h': + template + class A { + public: + void f (); + T t; + }; + + template void g (T a); + + `templates.cc': + #include "templates.h" + + template + void A::f () { } + + template + void g (T a) { } + + main.cc: + #include "templates.h" + + main () + { + A a; + a.f (); + g (a); + } + + compiling everything with `g++ main.cc templates.cc' will result in +undefined symbol errors for `A::f ()' and `g (A)'. To fix +these errors, add the lines + + template class A; + template void g (A); + + to the bottom of `templates.cc' and recompile. + +I get multiply defined symbols using templates +============================================== + + You may be running into a bug that was introduced in version 2.6.1 +(and is still present in 2.6.3) that generated external linkage for +templates even when neither `-fexternal-templates' nor +`-fno-implicit-templates' is specified. There is a patch for this +problem at ftp.cygnus.com:pub/g++/gcc-2.6.3-template-fix. I recommend +either applying the patch or using `-fno-implicit-templates' together +with explicit template instantiation as described in previous sections. + + This bug is fixed in 2.7.0. + +Does g++ support the Standard Template Library? +=============================================== + + From Per Bothner: + + The Standard Template Library (STL) uses many of the extensions that +the ANSI/ISO committee has made to templates, and g++ doesn't support +some of these yet. So if you grab HP's free implementation of STL it +isn't going to work. However, libg++-2.6.2 contains a hacked version +of STL, based on work by Carsten Bormann, which permits gcc-2.6.3 to +compile at least the containers. A full implementation is going to +need improved template support, which will take a while yet. + + As of libg++-2.7.0 and gcc-2.7.0, I've succeeded in making many short +STL example programs work, though there are still a number of bugs and +limitations. + +What are the differences between g++ and the ARM specification of C++? +====================================================================== + + As of version 2.7.0, g++ has exception support on most but not all +platforms (no support on MIPS-based platforms yet), but it doesn't work +right if optimizaton is enabled, which means the exception +implementation is still not really ready for production use. + + Some features that the ANSI/ISO standardization committee has voted +in that don't appear in the ARM are supported, notably the `mutable' +keyword, in version 2.5.x. 2.6.x adds support for the built-in boolean +type `bool', with constants `true' and `false'. The beginnings of +run-time type identification are present, so there are more reserved +words: `typeid', `static_cast', `reinterpret_cast', `const_cast', and +`dynamic_cast'. + + As with any beta-test compiler, there are bugs. You can help improve +the compiler by submitting detailed bug reports. + + One of the weakest areas of g++ other than templates is the +resolution of overloaded functions and operators in complex cases. The +usual symptom is that in a case where the ARM says that it is ambiguous +which function should be chosen, g++ chooses one (often the first one +declared). This is usually not a problem when porting C++ code from +other compilers to g++, but shows up as errors when code developed under +g++ is ported to other compilers. (I believe this is no longer a +significant problem in 2.7.0). + + [A full bug list would be very long indeed, so I won't put one here. +I may add a list of frequently-reported bugs and "non-bugs" like the +static class members issue mentioned above]. + +Will g++ compile InterViews? The NIH class library? +==================================================== + + The NIH class library uses a non-portable, compiler-dependent hack +to initialize itself, which makes life difficult for g++ users. It +will not work without modification, and I don't know what modifications +are required or whether anyone has done them successfully. + + In short, it's not going to happen any time soon (previous FAQs +referred to patches that a new NIHCL release would hopefully contain, +but this hasn't happened). + + [ From Steinar Bang ] + + InterViews 3.1 compiles and runs with gcc-2.3.3 and libg++-2.3, +except that the "doc" application immediately dumps core when you try +to run it. There is also a small glitch with idraw. + + There is a patch for InterViews 3.1 from Johan Garpendahl + available for FTP from site "ugle.unit.no". It is in +the file + + `/pub/X11/contrib/InterViews/g++/3.1-beta3-patch'. + + This fixes two things: the Doc coredump, and the pattern menu of +idraw. Read the instructions at the start of the file. + + I think that as of version 2.5.6, the standard g++ will compile the +standard 3.1 InterViews completely successfully. I'd appreciate a +confirmation. + +Debugging on SVR4 systems +========================= + + "How do I get debugging to work on my System V Release 4 system?" + + Most systems based on System V Release 4 (except Solaris) encode +symbolic debugging information in a format known as `DWARF'. + + Although the GNU C compiler already knows how to write out symbolic +debugging information in the DWARF format, the GNU C++ compiler does +not yet have this feature, nor is it likely to in the immediate future. + + Ron Guilmette has done a great deal of work to try to get the GNU +C++ compiler to produce DWARF format symbolic debugging information +(for C++ code) but he gave up on the project because of a lack of +funding and/or interest from the g++ user community. If you have a +strong desire to see this project completed, contact Ron at +. + + In the meantime, you *can* get g++ debugging under SVR4 systems by +configuring gcc with the `--with-stabs' option. This causes gcc to use +an alternate debugging format, one more like that used under SunOS4. +You won't need to do anything special to GDB; it will always understand +the "stabs" format. + +X11 conflicts with libg++ in definition of String +================================================= + + "X11 and Motif define String, and this conflicts with the String +class in libg++. How can I use both together?" + + One possible method is the following: + + #define String XString + #include + /* include other X11 and Motif headers */ + #undef String + + and remember to use the correct `String' or `XString' when you +declare things later. + +Why can't I assign one stream to another? +========================================= + + [ Thanks to Per Bothner and Jerry Schwarz for this section. ] + + Assigning one stream to another seems like a reasonable thing to do, +but it's a bad idea. Usually, this comes up because people want to +assign to `cout'. This is poor style, especially for libraries, and is +contrary to good object-oriented design. (Libraries that write directly +to `cout' are less flexible, modular, and object-oriented). + + The iostream classes do not allow assigning to arbitrary streams, +because this can violate typing: + + ifstream foo ("foo"); + istrstream str(...); + foo = str; + foo->close (); /* Oops! Not defined for istrstream! */ + + The original cfront implementation of iostreams by Jerry Schwarz +allows you to assign to `cin', `cout', `cerr', and `clog', but this is +not part of the draft standard for iostreams and generally isn't +considered a good idea, so standard-conforming code shouldn't use this +technique. + + The GNU implementation of iostream did not support assigning to +`cin', `cout', `cerr', and `clog' for quite a while, but it now does, +for backward compatibility with cfront iostream (versions 2.6.1 and +later of libg++). + + The ANSI/ISO C++ Working Paper does provide ways of changing the +streambuf associated with a stream. Assignment isn't allowed; there is +an explicit named member that must be used. + + However, it is not wise to do this, and the results are confusing. +For example: `fstream::rdbuf' is supposed to return the *original* +filebuf, not the one you assigned. (This is not yet implemented in GNU +iostream.) This must be so because `fstream::rdbuf' is defined to +return a `filebuf *'. + +What are the rules for shipping code built with g++ and libg++? +*************************************************************** + + "Is it is possible to distribute programs for profit that are created +with g++ and use the g++ libraries?" + + I am not a lawyer, and this is not legal advice. In any case, I have +little interest in telling people how to violate the spirit of the GNU +licenses without violating the letter. This section tells you how to +comply with the intention of the GNU licenses as best I understand them. + + The FSF has no objection to your making money. Its only interest is +that source code to their programs, and libraries, and to modified +versions of their programs and libraries, is always available. + + The short answer is that you do not need to release the source to +your program, but you can't just ship a stripped executable either, +unless you use only the subset of libg++ that includes the iostreams +classes (see discussion below) or the new libstdc++ library (available +in libg++ 2.6.2 and later). + + Compiling your code with a GNU compiler does not affect its +copyright; it is still yours. However, in order to ship code that +links in a GNU library such as libg++ there are certain rules you must +follow. The rules are described in the file COPYING.LIB that +accompanies gcc distributions; it is also included in the libg++ +distribution. See that file for the exact rules. The agreement is +called the Library GNU Public License or LGPL. It is much "looser" +than the GNU Public License, or GPL, that covers must GNU programs. + + Here's the deal: let's say that you use some version of libg++, +completely unchanged, in your software, and you want to ship only a +binary form of your code. You can do this, but there are several +special requirements. If you want to use libg++ but ship only object +code for your code, you have to ship source for libg++ (or ensure +somehow that your customer already has the source for the exact version +you are using), and ship your application in linkable form. You cannot +forbid your customer from reverse-engineering or extending your program +by exploiting its linkable form. + + Furthermore, if you modify libg++ itself, you must provide source +for your modifications (making a derived class does not count as +modifying the library - that is "a work that uses the library"). + + For certain portions of libg++ that implement required parts of the +C++ language (such as iostreams and other standard classes), the FSF has +loosened the copyright requirement still more by adding the "special +exception" clause, which reads as follows: + + 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. + + If your only use of libg++ uses code with this exception, you may +ship stripped executables or license your executables under different +conditions without fear of violating an FSF copyright. It is the intent +of FSF and Cygnus that, as the other classes required by the ANSI/ISO +draft standard are developed, these will also be placed under this +"special exception" license. The code in the new libstdc++ library, +intended to implement standard classes as defined by ANSI/ISO, is also +licensed this way. + + To avoid coming under the influence of the LGPL, you can link with +`-liostream' rather than `-lg++' (for version 2.6.x and earlier), or +`-lstdc++' now that it is available. In version 2.7.0 all the standard +classes are in `-lstdc++'; you can do the link step with `c++' instead +of `g++' to search only the `-lstdc++' library and avoid the LGPL'ed +code in `-lg++'. + +-- +-- Joe Buck (not speaking for Synopsys, Inc) +Anagrams for "information superhighway": Enormous hairy pig with fan + A rough whimper of insanity diff --git a/gnu/lib/libg++/libg++/genclass/ChangeLog b/gnu/lib/libg++/libg++/genclass/ChangeLog new file mode 100644 index 00000000000..0cc12419064 --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/ChangeLog @@ -0,0 +1,27 @@ +Thu Nov 4 11:18:05 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (install): Use INSTALL_PROGRAM for genclass. + +Wed Aug 12 12:52:16 1992 Per Bothner (bothner@cygnus.com) + + * genclass.sh: Don't use RCS id as version number. Instead + use libg++ version number. + * Makefile.in (genclass): Hackery to extract libg++ version + number from ../Makefile and insert it into genclass script. + +Mon Aug 10 11:38:48 1992 Ian Lance Taylor (ian@dumbest.cygnus.com) + + * Makefile.in: always create installation directories. + +Thu May 14 15:10:18 1992 Per Bothner (bothner@rtl.cygnus.com) + + * genclass.sh: Move comments inside sed script (which is + not supported by all versions of sed) outside. + * Makefile.in: Update IDIR->gxx_includedir. + +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. + diff --git a/gnu/lib/libg++/libg++/genclass/Makefile.in b/gnu/lib/libg++/libg++/genclass/Makefile.in new file mode 100644 index 00000000000..c6a04f5f481 --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/Makefile.in @@ -0,0 +1,23 @@ +# Makefile for g++ library genclass test + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +genclass: $(srcdir)/genclass.sh + echo "/^PROTODIR=/c\\" > sedscript + echo "PROTODIR=$$\{PROTODIR-$(gxx_includedir)/gen\}" >> sedscript + sed <../Makefile -n -e '/VERSION/s/LIBG++_DIST_VERSION *= *\(.*\)/s||\1|/p' >> sedscript + sed -f sedscript < $(srcdir)/genclass.sh > genclass.tmp + chmod 0755 genclass.tmp + rm -f sedscript + mv genclass.tmp genclass + +gentest: $(srcdir)/gentest.sh $(srcdir)/expected.out + $(srcdir)/gentest.sh > my.out 2>&1 + diff $(srcdir)/expected.out my.out + +.PHONY: install +install: + $(INSTALL_PROGRAM) genclass $(bindir)/genclass diff --git a/gnu/lib/libg++/libg++/genclass/configure.in b/gnu/lib/libg++/libg++/genclass/configure.in new file mode 100644 index 00000000000..6e237d716a8 --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=genclass.sh +srcname="old libg++ template expander" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + + +TOLIBGXX=../ +CLEAN='genclass *.h *.cc my.out' +ALL=genclass + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/genclass/expected.out b/gnu/lib/libg++/libg++/genclass/expected.out new file mode 100644 index 00000000000..cecc3cd3c1b --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/expected.out @@ -0,0 +1,1027 @@ +---------- genclass -usage ---------- +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +----------- +---------- genclass -version ---------- +genclass: version 2.1 +----------- +---------- genclass -requires ---------- + +----------- +---------- genclass -catalog ---------- +Catalog of genclass class templates +directories searched: + /usr/latest/lib/gcc/sun4/1.95.01/g++-include/gen + /play/hgs/libg++-1.90/gentests +selecting: all +classes available: + AVLMap AVLSet AVec BSTSet Bag CHBag CHMap CHSet DLDeque DLList + Deque FPQueue FPStack FPlex List MPlex Map OSLBag OSLSet OXPBag + OXPSet PHPQ PQ Plex Queue RAVLMap RPlex SLBag SLList SLQueue + SLSet SLStack Set SplayBag SplayMap SplayPQ SplaySet Stack VHBag + VHMap VHSet VOHSet VQueue VStack Vec XPBag XPDeque XPPQ XPQueue + XPSet XPStack XPlex defs + +----------- +---------- genclass -list ---------- +AVLMap +AVLSet +AVec +BSTSet +Bag +CHBag +CHMap +CHSet +DLDeque +DLList +Deque +FPQueue +FPStack +FPlex +List +MPlex +Map +OSLBag +OSLSet +OXPBag +OXPSet +PHPQ +PQ +Plex +Queue +RAVLMap +RPlex +SLBag +SLList +SLQueue +SLSet +SLStack +Set +SplayBag +SplayMap +SplayPQ +SplaySet +Stack +VHBag +VHMap +VHSet +VOHSet +VQueue +VStack +Vec +XPBag +XPDeque +XPPQ +XPQueue +XPSet +XPStack +XPlex +defs +----------- +---------- genclass -catalog PQ Set ---------- +Catalog of genclass class templates +directories searched: + /usr/latest/lib/gcc/sun4/1.95.01/g++-include/gen + /play/hgs/libg++-1.90/gentests +selecting: PQ Set +classes available: + AVLSet BSTSet CHSet OSLSet OXPSet PHPQ PQ SLSet Set SplayPQ + SplaySet VHSet VOHSet XPPQ XPSet + +----------- +---------- genclass -list Map Stack ---------- +AVLMap +CHMap +FPStack +Map +RAVLMap +SLStack +SplayMap +Stack +VHMap +VStack +XPStack +----------- +Generating: genclass int ref AVLMap +genclass: the AVLMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-AVLMap failed + +genclass int ref AVLMap fig +genclass: the AVLMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-AVLMap failed + +Generating: genclass int ref AVLSet +Checking for badsub +removing int.AVLSet.h int.AVLSet.cc + +genclass int ref AVLSet fig +Checking for badsub +removing figAVLSet.h figAVLSet.cc + +Generating: genclass int ref AVec +Checking for badsub +removing int.AVec.h int.AVec.cc + +genclass int ref AVec fig +Checking for badsub +removing figAVec.h figAVec.cc + +Generating: genclass int ref BSTSet +Checking for badsub +removing int.BSTSet.h int.BSTSet.cc + +genclass int ref BSTSet fig +Checking for badsub +removing figBSTSet.h figBSTSet.cc + +Generating: genclass int ref Bag +Checking for badsub +removing int.Bag.h int.Bag.cc + +genclass int ref Bag fig +Checking for badsub +removing figBag.h figBag.cc + +Generating: genclass int ref CHBag +Checking for badsub +removing int.CHBag.h int.CHBag.cc + +genclass int ref CHBag fig +Checking for badsub +removing figCHBag.h figCHBag.cc + +Generating: genclass int ref CHMap +genclass: the CHMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-CHMap failed + +genclass int ref CHMap fig +genclass: the CHMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-CHMap failed + +Generating: genclass int ref CHSet +Checking for badsub +removing int.CHSet.h int.CHSet.cc + +genclass int ref CHSet fig +Checking for badsub +removing figCHSet.h figCHSet.cc + +Generating: genclass int ref DLDeque +Checking for badsub +removing int.DLDeque.h int.DLDeque.cc + +genclass int ref DLDeque fig +Checking for badsub +removing figDLDeque.h figDLDeque.cc + +Generating: genclass int ref DLList +Checking for badsub +removing int.DLList.h int.DLList.cc + +genclass int ref DLList fig +Checking for badsub +removing figDLList.h figDLList.cc + +Generating: genclass int ref Deque +Checking for badsub +removing int.Deque.h int.Deque.cc + +genclass int ref Deque fig +Checking for badsub +removing figDeque.h figDeque.cc + +Generating: genclass int ref FPQueue +Checking for badsub +removing int.FPQueue.h int.FPQueue.cc + +genclass int ref FPQueue fig +Checking for badsub +removing figFPQueue.h figFPQueue.cc + +Generating: genclass int ref FPStack +Checking for badsub +removing int.FPStack.h int.FPStack.cc + +genclass int ref FPStack fig +Checking for badsub +removing figFPStack.h figFPStack.cc + +Generating: genclass int ref FPlex +Checking for badsub +removing int.FPlex.h int.FPlex.cc + +genclass int ref FPlex fig +Checking for badsub +removing figFPlex.h figFPlex.cc + +Generating: genclass int ref List +Checking for badsub +removing int.List.h int.List.cc + +genclass int ref List fig +Checking for badsub +removing figList.h figList.cc + +Generating: genclass int ref MPlex +Checking for badsub +removing int.MPlex.h int.MPlex.cc + +genclass int ref MPlex fig +Checking for badsub +removing figMPlex.h figMPlex.cc + +Generating: genclass int ref Map +genclass: the Map class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-Map failed + +genclass int ref Map fig +genclass: the Map class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-Map failed + +Generating: genclass int ref OSLBag +Checking for badsub +removing int.OSLBag.h int.OSLBag.cc + +genclass int ref OSLBag fig +Checking for badsub +removing figOSLBag.h figOSLBag.cc + +Generating: genclass int ref OSLSet +Checking for badsub +removing int.OSLSet.h int.OSLSet.cc + +genclass int ref OSLSet fig +Checking for badsub +removing figOSLSet.h figOSLSet.cc + +Generating: genclass int ref OXPBag +Checking for badsub +removing int.OXPBag.h int.OXPBag.cc + +genclass int ref OXPBag fig +Checking for badsub +removing figOXPBag.h figOXPBag.cc + +Generating: genclass int ref OXPSet +Checking for badsub +removing int.OXPSet.h int.OXPSet.cc + +genclass int ref OXPSet fig +Checking for badsub +removing figOXPSet.h figOXPSet.cc + +Generating: genclass int ref PHPQ +Checking for badsub +removing int.PHPQ.h int.PHPQ.cc + +genclass int ref PHPQ fig +Checking for badsub +removing figPHPQ.h figPHPQ.cc + +Generating: genclass int ref PQ +Checking for badsub +removing int.PQ.h int.PQ.cc + +genclass int ref PQ fig +Checking for badsub +removing figPQ.h figPQ.cc + +Generating: genclass int ref Plex +Checking for badsub +removing int.Plex.h int.Plex.cc + +genclass int ref Plex fig +Checking for badsub +removing figPlex.h figPlex.cc + +Generating: genclass int ref Queue +Checking for badsub +removing int.Queue.h int.Queue.cc + +genclass int ref Queue fig +Checking for badsub +removing figQueue.h figQueue.cc + +Generating: genclass int ref RAVLMap +genclass: the RAVLMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-RAVLMap failed + +genclass int ref RAVLMap fig +genclass: the RAVLMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-RAVLMap failed + +Generating: genclass int ref RPlex +Checking for badsub +removing int.RPlex.h int.RPlex.cc + +genclass int ref RPlex fig +Checking for badsub +removing figRPlex.h figRPlex.cc + +Generating: genclass int ref SLBag +Checking for badsub +removing int.SLBag.h int.SLBag.cc + +genclass int ref SLBag fig +Checking for badsub +removing figSLBag.h figSLBag.cc + +Generating: genclass int ref SLList +Checking for badsub +removing int.SLList.h int.SLList.cc + +genclass int ref SLList fig +Checking for badsub +removing figSLList.h figSLList.cc + +Generating: genclass int ref SLQueue +Checking for badsub +removing int.SLQueue.h int.SLQueue.cc + +genclass int ref SLQueue fig +Checking for badsub +removing figSLQueue.h figSLQueue.cc + +Generating: genclass int ref SLSet +Checking for badsub +removing int.SLSet.h int.SLSet.cc + +genclass int ref SLSet fig +Checking for badsub +removing figSLSet.h figSLSet.cc + +Generating: genclass int ref SLStack +Checking for badsub +removing int.SLStack.h int.SLStack.cc + +genclass int ref SLStack fig +Checking for badsub +removing figSLStack.h figSLStack.cc + +Generating: genclass int ref Set +Checking for badsub +removing int.Set.h int.Set.cc + +genclass int ref Set fig +Checking for badsub +removing figSet.h figSet.cc + +Generating: genclass int ref SplayBag +Checking for badsub +removing int.SplayBag.h int.SplayBag.cc + +genclass int ref SplayBag fig +Checking for badsub +removing figSplayBag.h figSplayBag.cc + +Generating: genclass int ref SplayMap +genclass: the SplayMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-SplayMap failed + +genclass int ref SplayMap fig +genclass: the SplayMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-SplayMap failed + +Generating: genclass int ref SplayPQ +Checking for badsub +removing int.SplayPQ.h int.SplayPQ.cc + +genclass int ref SplayPQ fig +Checking for badsub +removing figSplayPQ.h figSplayPQ.cc + +Generating: genclass int ref SplaySet +Checking for badsub +removing int.SplaySet.h int.SplaySet.cc + +genclass int ref SplaySet fig +Checking for badsub +removing figSplaySet.h figSplaySet.cc + +Generating: genclass int ref Stack +Checking for badsub +removing int.Stack.h int.Stack.cc + +genclass int ref Stack fig +Checking for badsub +removing figStack.h figStack.cc + +Generating: genclass int ref VHBag +Checking for badsub +removing int.VHBag.h int.VHBag.cc + +genclass int ref VHBag fig +Checking for badsub +removing figVHBag.h figVHBag.cc + +Generating: genclass int ref VHMap +genclass: the VHMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-VHMap failed + +genclass int ref VHMap fig +genclass: the VHMap class requires the -2 syntax for the 2nd type +usage: + genclass -list [proto ...] + genclass -catalog [proto ...] + genclass type1 {ref|val} proto [out_prefix] + genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] +Generation for int-VHMap failed + +Generating: genclass int ref VHSet +Checking for badsub +removing int.VHSet.h int.VHSet.cc + +genclass int ref VHSet fig +Checking for badsub +removing figVHSet.h figVHSet.cc + +Generating: genclass int ref VOHSet +Checking for badsub +removing int.VOHSet.h int.VOHSet.cc + +genclass int ref VOHSet fig +Checking for badsub +removing figVOHSet.h figVOHSet.cc + +Generating: genclass int ref VQueue +Checking for badsub +removing int.VQueue.h int.VQueue.cc + +genclass int ref VQueue fig +Checking for badsub +removing figVQueue.h figVQueue.cc + +Generating: genclass int ref VStack +Checking for badsub +removing int.VStack.h int.VStack.cc + +genclass int ref VStack fig +Checking for badsub +removing figVStack.h figVStack.cc + +Generating: genclass int ref Vec +Checking for badsub +removing int.Vec.h int.Vec.cc + +genclass int ref Vec fig +Checking for badsub +removing figVec.h figVec.cc + +Generating: genclass int ref XPBag +Checking for badsub +removing int.XPBag.h int.XPBag.cc + +genclass int ref XPBag fig +Checking for badsub +removing figXPBag.h figXPBag.cc + +Generating: genclass int ref XPDeque +Checking for badsub +removing int.XPDeque.h int.XPDeque.cc + +genclass int ref XPDeque fig +Checking for badsub +removing figXPDeque.h figXPDeque.cc + +Generating: genclass int ref XPPQ +Checking for badsub +removing int.XPPQ.h int.XPPQ.cc + +genclass int ref XPPQ fig +Checking for badsub +removing figXPPQ.h figXPPQ.cc + +Generating: genclass int ref XPQueue +Checking for badsub +removing int.XPQueue.h int.XPQueue.cc + +genclass int ref XPQueue fig +Checking for badsub +removing figXPQueue.h figXPQueue.cc + +Generating: genclass int ref XPSet +Checking for badsub +removing int.XPSet.h int.XPSet.cc + +genclass int ref XPSet fig +Checking for badsub +removing figXPSet.h figXPSet.cc + +Generating: genclass int ref XPStack +Checking for badsub +removing int.XPStack.h int.XPStack.cc + +genclass int ref XPStack fig +Checking for badsub +removing figXPStack.h figXPStack.cc + +Generating: genclass int ref XPlex +Checking for badsub +removing int.XPlex.h int.XPlex.cc + +genclass int ref XPlex fig +Checking for badsub +removing figXPlex.h figXPlex.cc + +Generating: genclass int ref defs +genclass: warning, class has a .h but no .cc file +Checking for badsub +egrep: int.defs.cc: No such file or directory +removing int.defs.h int.defs.cc +rm: int.defs.cc: No such file or directory + +genclass int ref defs fig +genclass: warning, class has a .h but no .cc file +Checking for badsub +egrep: figdefs.cc: No such file or directory +removing figdefs.h figdefs.cc +rm: figdefs.cc: No such file or directory + +Generating: genclass -2 int ref char val AVLMap +Checking for badsub +removing int.char.AVLMap.h int.char.AVLMap.cc + +Generating: genclass -2 int ref char val AVLMap fig +Checking for badsub +removing figAVLMap.h figAVLMap.cc + +Generating: genclass -2 int ref char val AVLSet +Checking for badsub +removing int.char.AVLSet.h int.char.AVLSet.cc + +Generating: genclass -2 int ref char val AVLSet fig +Checking for badsub +removing figAVLSet.h figAVLSet.cc + +Generating: genclass -2 int ref char val AVec +Checking for badsub +removing int.char.AVec.h int.char.AVec.cc + +Generating: genclass -2 int ref char val AVec fig +Checking for badsub +removing figAVec.h figAVec.cc + +Generating: genclass -2 int ref char val BSTSet +Checking for badsub +removing int.char.BSTSet.h int.char.BSTSet.cc + +Generating: genclass -2 int ref char val BSTSet fig +Checking for badsub +removing figBSTSet.h figBSTSet.cc + +Generating: genclass -2 int ref char val Bag +Checking for badsub +removing int.char.Bag.h int.char.Bag.cc + +Generating: genclass -2 int ref char val Bag fig +Checking for badsub +removing figBag.h figBag.cc + +Generating: genclass -2 int ref char val CHBag +Checking for badsub +removing int.char.CHBag.h int.char.CHBag.cc + +Generating: genclass -2 int ref char val CHBag fig +Checking for badsub +removing figCHBag.h figCHBag.cc + +Generating: genclass -2 int ref char val CHMap +Checking for badsub +removing int.char.CHMap.h int.char.CHMap.cc + +Generating: genclass -2 int ref char val CHMap fig +Checking for badsub +removing figCHMap.h figCHMap.cc + +Generating: genclass -2 int ref char val CHSet +Checking for badsub +removing int.char.CHSet.h int.char.CHSet.cc + +Generating: genclass -2 int ref char val CHSet fig +Checking for badsub +removing figCHSet.h figCHSet.cc + +Generating: genclass -2 int ref char val DLDeque +Checking for badsub +removing int.char.DLDeque.h int.char.DLDeque.cc + +Generating: genclass -2 int ref char val DLDeque fig +Checking for badsub +removing figDLDeque.h figDLDeque.cc + +Generating: genclass -2 int ref char val DLList +Checking for badsub +removing int.char.DLList.h int.char.DLList.cc + +Generating: genclass -2 int ref char val DLList fig +Checking for badsub +removing figDLList.h figDLList.cc + +Generating: genclass -2 int ref char val Deque +Checking for badsub +removing int.char.Deque.h int.char.Deque.cc + +Generating: genclass -2 int ref char val Deque fig +Checking for badsub +removing figDeque.h figDeque.cc + +Generating: genclass -2 int ref char val FPQueue +Checking for badsub +removing int.char.FPQueue.h int.char.FPQueue.cc + +Generating: genclass -2 int ref char val FPQueue fig +Checking for badsub +removing figFPQueue.h figFPQueue.cc + +Generating: genclass -2 int ref char val FPStack +Checking for badsub +removing int.char.FPStack.h int.char.FPStack.cc + +Generating: genclass -2 int ref char val FPStack fig +Checking for badsub +removing figFPStack.h figFPStack.cc + +Generating: genclass -2 int ref char val FPlex +Checking for badsub +removing int.char.FPlex.h int.char.FPlex.cc + +Generating: genclass -2 int ref char val FPlex fig +Checking for badsub +removing figFPlex.h figFPlex.cc + +Generating: genclass -2 int ref char val List +Checking for badsub +removing int.char.List.h int.char.List.cc + +Generating: genclass -2 int ref char val List fig +Checking for badsub +removing figList.h figList.cc + +Generating: genclass -2 int ref char val MPlex +Checking for badsub +removing int.char.MPlex.h int.char.MPlex.cc + +Generating: genclass -2 int ref char val MPlex fig +Checking for badsub +removing figMPlex.h figMPlex.cc + +Generating: genclass -2 int ref char val Map +Checking for badsub +removing int.char.Map.h int.char.Map.cc + +Generating: genclass -2 int ref char val Map fig +Checking for badsub +removing figMap.h figMap.cc + +Generating: genclass -2 int ref char val OSLBag +Checking for badsub +removing int.char.OSLBag.h int.char.OSLBag.cc + +Generating: genclass -2 int ref char val OSLBag fig +Checking for badsub +removing figOSLBag.h figOSLBag.cc + +Generating: genclass -2 int ref char val OSLSet +Checking for badsub +removing int.char.OSLSet.h int.char.OSLSet.cc + +Generating: genclass -2 int ref char val OSLSet fig +Checking for badsub +removing figOSLSet.h figOSLSet.cc + +Generating: genclass -2 int ref char val OXPBag +Checking for badsub +removing int.char.OXPBag.h int.char.OXPBag.cc + +Generating: genclass -2 int ref char val OXPBag fig +Checking for badsub +removing figOXPBag.h figOXPBag.cc + +Generating: genclass -2 int ref char val OXPSet +Checking for badsub +removing int.char.OXPSet.h int.char.OXPSet.cc + +Generating: genclass -2 int ref char val OXPSet fig +Checking for badsub +removing figOXPSet.h figOXPSet.cc + +Generating: genclass -2 int ref char val PHPQ +Checking for badsub +removing int.char.PHPQ.h int.char.PHPQ.cc + +Generating: genclass -2 int ref char val PHPQ fig +Checking for badsub +removing figPHPQ.h figPHPQ.cc + +Generating: genclass -2 int ref char val PQ +Checking for badsub +removing int.char.PQ.h int.char.PQ.cc + +Generating: genclass -2 int ref char val PQ fig +Checking for badsub +removing figPQ.h figPQ.cc + +Generating: genclass -2 int ref char val Plex +Checking for badsub +removing int.char.Plex.h int.char.Plex.cc + +Generating: genclass -2 int ref char val Plex fig +Checking for badsub +removing figPlex.h figPlex.cc + +Generating: genclass -2 int ref char val Queue +Checking for badsub +removing int.char.Queue.h int.char.Queue.cc + +Generating: genclass -2 int ref char val Queue fig +Checking for badsub +removing figQueue.h figQueue.cc + +Generating: genclass -2 int ref char val RAVLMap +Checking for badsub +removing int.char.RAVLMap.h int.char.RAVLMap.cc + +Generating: genclass -2 int ref char val RAVLMap fig +Checking for badsub +removing figRAVLMap.h figRAVLMap.cc + +Generating: genclass -2 int ref char val RPlex +Checking for badsub +removing int.char.RPlex.h int.char.RPlex.cc + +Generating: genclass -2 int ref char val RPlex fig +Checking for badsub +removing figRPlex.h figRPlex.cc + +Generating: genclass -2 int ref char val SLBag +Checking for badsub +removing int.char.SLBag.h int.char.SLBag.cc + +Generating: genclass -2 int ref char val SLBag fig +Checking for badsub +removing figSLBag.h figSLBag.cc + +Generating: genclass -2 int ref char val SLList +Checking for badsub +removing int.char.SLList.h int.char.SLList.cc + +Generating: genclass -2 int ref char val SLList fig +Checking for badsub +removing figSLList.h figSLList.cc + +Generating: genclass -2 int ref char val SLQueue +Checking for badsub +removing int.char.SLQueue.h int.char.SLQueue.cc + +Generating: genclass -2 int ref char val SLQueue fig +Checking for badsub +removing figSLQueue.h figSLQueue.cc + +Generating: genclass -2 int ref char val SLSet +Checking for badsub +removing int.char.SLSet.h int.char.SLSet.cc + +Generating: genclass -2 int ref char val SLSet fig +Checking for badsub +removing figSLSet.h figSLSet.cc + +Generating: genclass -2 int ref char val SLStack +Checking for badsub +removing int.char.SLStack.h int.char.SLStack.cc + +Generating: genclass -2 int ref char val SLStack fig +Checking for badsub +removing figSLStack.h figSLStack.cc + +Generating: genclass -2 int ref char val Set +Checking for badsub +removing int.char.Set.h int.char.Set.cc + +Generating: genclass -2 int ref char val Set fig +Checking for badsub +removing figSet.h figSet.cc + +Generating: genclass -2 int ref char val SplayBag +Checking for badsub +removing int.char.SplayBag.h int.char.SplayBag.cc + +Generating: genclass -2 int ref char val SplayBag fig +Checking for badsub +removing figSplayBag.h figSplayBag.cc + +Generating: genclass -2 int ref char val SplayMap +Checking for badsub +removing int.char.SplayMap.h int.char.SplayMap.cc + +Generating: genclass -2 int ref char val SplayMap fig +Checking for badsub +removing figSplayMap.h figSplayMap.cc + +Generating: genclass -2 int ref char val SplayPQ +Checking for badsub +removing int.char.SplayPQ.h int.char.SplayPQ.cc + +Generating: genclass -2 int ref char val SplayPQ fig +Checking for badsub +removing figSplayPQ.h figSplayPQ.cc + +Generating: genclass -2 int ref char val SplaySet +Checking for badsub +removing int.char.SplaySet.h int.char.SplaySet.cc + +Generating: genclass -2 int ref char val SplaySet fig +Checking for badsub +removing figSplaySet.h figSplaySet.cc + +Generating: genclass -2 int ref char val Stack +Checking for badsub +removing int.char.Stack.h int.char.Stack.cc + +Generating: genclass -2 int ref char val Stack fig +Checking for badsub +removing figStack.h figStack.cc + +Generating: genclass -2 int ref char val VHBag +Checking for badsub +removing int.char.VHBag.h int.char.VHBag.cc + +Generating: genclass -2 int ref char val VHBag fig +Checking for badsub +removing figVHBag.h figVHBag.cc + +Generating: genclass -2 int ref char val VHMap +Checking for badsub +removing int.char.VHMap.h int.char.VHMap.cc + +Generating: genclass -2 int ref char val VHMap fig +Checking for badsub +removing figVHMap.h figVHMap.cc + +Generating: genclass -2 int ref char val VHSet +Checking for badsub +removing int.char.VHSet.h int.char.VHSet.cc + +Generating: genclass -2 int ref char val VHSet fig +Checking for badsub +removing figVHSet.h figVHSet.cc + +Generating: genclass -2 int ref char val VOHSet +Checking for badsub +removing int.char.VOHSet.h int.char.VOHSet.cc + +Generating: genclass -2 int ref char val VOHSet fig +Checking for badsub +removing figVOHSet.h figVOHSet.cc + +Generating: genclass -2 int ref char val VQueue +Checking for badsub +removing int.char.VQueue.h int.char.VQueue.cc + +Generating: genclass -2 int ref char val VQueue fig +Checking for badsub +removing figVQueue.h figVQueue.cc + +Generating: genclass -2 int ref char val VStack +Checking for badsub +removing int.char.VStack.h int.char.VStack.cc + +Generating: genclass -2 int ref char val VStack fig +Checking for badsub +removing figVStack.h figVStack.cc + +Generating: genclass -2 int ref char val Vec +Checking for badsub +removing int.char.Vec.h int.char.Vec.cc + +Generating: genclass -2 int ref char val Vec fig +Checking for badsub +removing figVec.h figVec.cc + +Generating: genclass -2 int ref char val XPBag +Checking for badsub +removing int.char.XPBag.h int.char.XPBag.cc + +Generating: genclass -2 int ref char val XPBag fig +Checking for badsub +removing figXPBag.h figXPBag.cc + +Generating: genclass -2 int ref char val XPDeque +Checking for badsub +removing int.char.XPDeque.h int.char.XPDeque.cc + +Generating: genclass -2 int ref char val XPDeque fig +Checking for badsub +removing figXPDeque.h figXPDeque.cc + +Generating: genclass -2 int ref char val XPPQ +Checking for badsub +removing int.char.XPPQ.h int.char.XPPQ.cc + +Generating: genclass -2 int ref char val XPPQ fig +Checking for badsub +removing figXPPQ.h figXPPQ.cc + +Generating: genclass -2 int ref char val XPQueue +Checking for badsub +removing int.char.XPQueue.h int.char.XPQueue.cc + +Generating: genclass -2 int ref char val XPQueue fig +Checking for badsub +removing figXPQueue.h figXPQueue.cc + +Generating: genclass -2 int ref char val XPSet +Checking for badsub +removing int.char.XPSet.h int.char.XPSet.cc + +Generating: genclass -2 int ref char val XPSet fig +Checking for badsub +removing figXPSet.h figXPSet.cc + +Generating: genclass -2 int ref char val XPStack +Checking for badsub +removing int.char.XPStack.h int.char.XPStack.cc + +Generating: genclass -2 int ref char val XPStack fig +Checking for badsub +removing figXPStack.h figXPStack.cc + +Generating: genclass -2 int ref char val XPlex +Checking for badsub +removing int.char.XPlex.h int.char.XPlex.cc + +Generating: genclass -2 int ref char val XPlex fig +Checking for badsub +removing figXPlex.h figXPlex.cc + +Generating: genclass -2 int ref char val defs +genclass: warning, class has a .h but no .cc file +Checking for badsub +egrep: int.char.defs.cc: No such file or directory +removing int.char.defs.h int.char.defs.cc +rm: int.char.defs.cc: No such file or directory + +Generating: genclass -2 int ref char val defs fig +genclass: warning, class has a .h but no .cc file +Checking for badsub +egrep: figdefs.cc: No such file or directory +removing figdefs.h figdefs.cc +rm: figdefs.cc: No such file or directory + diff --git a/gnu/lib/libg++/libg++/genclass/genclass.sh b/gnu/lib/libg++/libg++/genclass/genclass.sh new file mode 100644 index 00000000000..08d510754ad --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/genclass.sh @@ -0,0 +1,452 @@ +#!/bin/sh + +# Copyright (C) 1989 Free Software Foundation, Inc. +# +# genclass program enhanced by Wendell C. Baker +# (original by Doug Lea (dl@rocky.oswego.edu)) + +#This file is part of GNU libg++. + +#GNU libg++ is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 1, or (at your option) +#any later version. + +#GNU libg++ is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 libg++; see the file COPYING. If not, write to +#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + + +# +# genclass -list [proto ...] +# genclass -catalog [proto ...] +# genclass type1 {ref|val} proto [out_prefix] +# genclass -2 type1 {ref|val} type2 {ref, val} proto [out_prefix] +# +# Generate classes from prototypes +# +name=genclass ; +usage=" + $name -list [proto ...] + $name -catalog [proto ...] + $name type1 {ref|val} proto [out_prefix] + $name -2 type1 {ref|val} type2 {ref|val} proto [out_prefix]" ; + +case "$1" in +-usage) + # + # -usage + # + echo "usage: $usage" 1>&2 ; + exit 0; + ;; +-version) + # + # -version + # + # is substituted by the build process. + # We currently use the libg++ version number (extracted from ../Makefile). + echo "$name: version " ; + exit 0; + ;; +-requires) + # + # -requires + # + # The following line should contain any nonstandard programs + # which must be in the users's path (i.e. not referenced by a + # fullpath);it allows one to check a script for dependencies + # without exhaustively testing its usages. + # ... in this case genclass depends on nothing else. + echo ; + exit 0; + ;; +esac ; + +# pull it in from the environment +[ "$TRACE" = "" ] || set -xv + +# Search in standard g++ prototype directory and in the current directory +# NOTE: this variable is edited by the install process +PROTODIR=/projects/gnu-cygnus/gnu-cygnus-2/mips/lib/g++-include/gen + +pwd=`pwd` + +case "$1" in +-catalog*|-list*) + # + # genclass -catalog [proto ...] + # genclass -list [proto ...] + # + option="$1" ; + shift ; + + case $# in + 0) + # + # -catalog + # -list + # + select=all ; + select_pattern=p ; + ;; + *) + # + # -catalog proto ... + # -list proto ... + # + select="$@" ; + select_pattern= ; + for i in $@ ; do + select_pattern="\ +$select_pattern +/.*$i\$/ p +" ; + done ; + + ;; + esac ; + + # + # select_pattern is now a (possibly-vacuous) newline- + # separated list of patterns of the form: + # + # /.*Proto1$/ p + # /.*Proto2$/ p + # /.*Proto3$/ p + # + # or select_pattern is simply ``p'' to select everything + + # Hmmm... not all systems have a fmt program; should we + # just go ahead and use ``nroff -Tcrt | cat -s'' here? + fmt='nroff -Tcrt | cat -s' + #fmt=fmt ; + + case "$option" in + -catalog*) + # + # -catalog [proto ...] + # + echo "\ +Catalog of ${name} class templates +directories searched: + $PROTODIR + $pwd +selecting: $select +classes available:" ; + ;; + -list*) + # + # -list [proto ...] + # + # no need to do anything (the list is coming out next) + ;; + esac ; + +# The sed script does the following: +# - If it does not end in a .ccP or .hP then +# it's not a template and we are not intereseted. +# - Get rid of pathname components [s;.*/;;] +# - Just take the template names +# - change quoting conventions and select off what we want to see +# -if it did not pass the patterns, kill it + + ls $pwd $PROTODIR | sed -e ' +/\.ccP$/ !{ + /\.hP$/ !{ + d + } +} +s;.*/;; +s/\.ccP$// +s/\.hP$// +' -e "$select_pattern +d +" | sort -u | case "$option" in + -catalog*) + # The library catalog information preceded the list + # format the list, and tab in in a bit to make it readable. + # Re-evaluate $fmt because it might contain a shell command + eval $fmt | sed -e 's/.*/ &/' ; + ;; + -list*) + # nothing special, just let the sorted list dribble out + # we must use cat to receive (and reproduce) the incoming list + cat ; + ;; + esac ; + exit 0; + ;; +-2) + # + # genclass -2 type1 {ref|val} type2 {ref|val} proto [out_prefix] + # + N=2 ; + + case $# in + 6) # genclass -2 type1 {ref|val} type2 {ref|val} proto + ;; + 7) # genclass -2 type1 {ref|val} type2 {ref|val} proto out_prefix + ;; + *) + echo "usage: $usage" 1>&2 ; + exit 1; + esac ; + shift ; + ;; +*) + # + # genclass type1 {ref|val} proto [out_prefix] + # + N=1 ; + + case $# in + 3) # genclass type1 {ref|val} proto + ;; + 4) # genclass type1 {ref|val} proto out_prefix + ;; + *) + echo "usage: $usage" 1>&2 ; + exit 1; + esac ; + ;; +esac + +# +# Args are now (the point being the leading ``-2'' is gone) +# +# type1 {ref|val} proto [out_prefix] +# type1 {ref|val} type2 {ref|val} proto [out_prefix] +# + +# +# Quote all of the $1 $2 etc references to guard against +# dynamic syntax errors due to vacuous arguments (i.e. '') +# as sometimes occurs when genclass is used from a Makefile +# + +T1="$1"; +T1NAME="$T1." ; +T1SEDNAME="$T1" ; + +case "$2" in +ref) + T1ACC="\&" ; + ;; +val) + T1ACC=" " ; + ;; +*) + echo "${name}: Must specify type1 access as ref or val" 1>&2 ; + echo "usage: $usage" 1>&2 ; + exit 1; + ;; +esac + +# N is either 1 or 2 + +case $N in +1) + # + # type1 {ref|val} proto [out_prefix] + # + class="$3" ; + + T2="" ; + T2ACC="" ; + ;; +2) + # + # type1 {ref|val} type2 {ref|val} proto [out_prefix] + # + class="$5" ; + + T2="$3"; + T2NAME="$T2." ; + T2SEDNAME="$T2" ; + + case "$4" in + ref) + T2ACC="\&" ; + ;; + val) + T2ACC=" " ; + ;; + *) + echo "${name}: Must specify type2 access: ref or val" 1>&2 ; + echo "usage: $usage" 1>&2 ; + exit 1;; + esac; + ;; +esac + +defaultprefix="$T1NAME$T2NAME" ; + +case $# in +3) # type1 {ref|val} proto + replaceprefix="N" ; + prefix="$defaultprefix" ; + ;; +5) # type1 {ref|val} type2 {ref|val} proto + replaceprefix="N" ; + prefix="$defaultprefix" ; + ;; +4) # type1 {ref|val} proto out_prefix + prefix="$4" ; + replaceprefix="Y" ; + ;; +6) # type1 {ref|val} type2 {ref|val} proto out_prefix + prefix="$6" ; + replaceprefix="Y" ; + ;; +*) + echo "${name}: too many arguments" 1>&2 ; + echo "usage: $usage" 1>&2 ; + exit 1; + ;; +esac ; + +src_h=$class.hP +src_cc=$class.ccP +out_h=$prefix$class.h; +out_cc=$prefix$class.cc ; + +# +# Note #1: The .h and .cc parts are done separately +# in case only a .h exists for the prototype +# +# Note #2: Bind the .h and .cc parts to the fullpath +# directories at the same time to ensure consistency. +# + +if [ -f $pwd/$src_h ] ; then + fullsrc_h=$pwd/$src_h ; + fullsrc_cc=$pwd/$src_cc ; +elif [ -f $PROTODIR/$src_h ] ; then + fullsrc_h=$PROTODIR/$src_h ; + fullsrc_cc=$PROTODIR/$src_cc ; +else + echo "${name}: there is no prototype for class $class - file $src_h" 1>&2 ; + $0 -list ; + exit 1; +fi + +CASES="$N$replaceprefix" ; +# CASES is one of { 2Y 2N 1Y 1N } + +# +# WATCHOUT - we have no way of checking whether or not +# the proper case type is being used with the prototype. +# +# For example, we have no way of ensuring that any of +# Map variants are specified with the -2 argument set +# Further, we have no way of ensuring that -2 is not +# used with the prototypes which require only one. +# +# The second problem is not serious because it still +# results in correctly-generated C++ code; the first +# problem is serious because it results in C++ code that +# still has ``'' and ``'' syntax inside it. Such +# code of course will not compile. +# +# SO THE BEST WE CAN DO - is check for the presence of +# and AFTER the thing has been generated. +# + +case $CASES in +2Y) # Two output substitutions, change the prefix + sed < $fullsrc_h > $out_h -e " +s//$T1/g +s//$T1$T1ACC/g +s//$T2/g +s//$T2$T2ACC/g +s/$T1SEDNAME\.$T2SEDNAME\./$prefix/g +s/$T1SEDNAME\./$prefix/g +s/$T2SEDNAME\./$prefix/g +" ; + ;; +2N) # Two output substitutions, use the default prefix + sed < $fullsrc_h > $out_h -e " +s//$T1/g +s//$T1$T1ACC/g +s//$T2/g +s//$T2$T2ACC/g +" ; + ;; +1Y) # One output substitution, change the prefix + sed < $fullsrc_h > $out_h -e " +s//$T1/g +s//$T1$T1ACC/g +s/$T1SEDNAME\./$prefix/g +" ; + ;; +1N) # One output substitution, use the default prefix + sed < $fullsrc_h > $out_h -e " +s//$T1/g +s//$T1$T1ACC/g +" ; + ;; +esac + +if egrep '' $out_h > /dev/null ; then + echo "${name}: the $class class requires the -2 syntax for the 2nd type" 1>&2 ; + echo "usage: $usage" 1>&2 ; + # the user does not get to see the mistakes (he might try to compile it) + rm $out_h ; + exit 1; +fi ; + +if [ ! -f $fullsrc_cc ] ; then + echo "${name}: warning, class has a .h but no .cc file" 1>&2 ; + exit 0; +fi + +case $CASES in +2Y) # Two output substitutions, change the prefix + sed < $fullsrc_cc > $out_cc -e " +s//$T1/g +s//$T1$T1ACC/g +s//$T2/g +s//$T2$T2ACC/g +s/$T1SEDNAME\.$T2SEDNAME\./$prefix/g +s/$T1SEDNAME\./$prefix/g +s/$T2SEDNAME\./$prefix/g +" + ;; +2N) # Two output substitutions, use the default prefix + sed < $fullsrc_cc > $out_cc -e " +s//$T1/g +s//$T1$T1ACC/g +s//$T2/g +s//$T2$T2ACC/g +" + ;; +1Y) # One output substitution, change the prefix + sed < $fullsrc_cc > $out_cc -e " +s//$T1/g +s//$T1$T1ACC/g +s/$T1SEDNAME\./$prefix/g +" + ;; +1N) # One output substitution, use the default prefix + sed < $fullsrc_cc > $out_cc -e " +s//$T1/g +s//$T1$T1ACC/g +" + ;; +esac + +if egrep '' $out_h $out_cc > /dev/null ; then + echo "${name}: the $class class requires the -2 syntax for the 2nd type" 1>&2 ; + echo "usage: $usage" 1>&2 ; + # the user does not get to see the mistakes (he might try to compile it) + rm $out_h $out_cc ; + exit 1; +fi ; + +exit 0; diff --git a/gnu/lib/libg++/libg++/genclass/gentest.sh b/gnu/lib/libg++/libg++/genclass/gentest.sh new file mode 100644 index 00000000000..1ee4f3c2712 --- /dev/null +++ b/gnu/lib/libg++/libg++/genclass/gentest.sh @@ -0,0 +1,174 @@ +#!/bin/sh + +# Copyright (C) 1989 Free Software Foundation, Inc. +# +# genclass test program by Wendell C. Baker + +#This file is part of GNU libg++. + +#GNU libg++ is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 1, or (at your option) +#any later version. + +#GNU libg++ is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 libg++; see the file COPYING. If not, write to +#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +# +# test.sh +# +name=gentest.sh +usage="$name" ; +genclass= + +case "$1" in +-usage) + # + # -usage + # + echo "usage: $usage" 1>&2 ; + exit 0; + ;; +-version) + # + # -version + # + version="`expr '$Revision: 1.1.1.1 $' : '.*Revision: \(.*\) .*'`" ; + echo "$name: version $version" ; + exit 0; + ;; +-requires) + # + # -requires + # + echo genclass ; + exit 0; + ;; +-genclass) + # + shift; genclass=$1 + ;; +esac ; + +# pull it in from the environment +[ "$TRACE" = "" ] || set -xv + +if [ "${genclass}" = "" ] +then + genclass="./genclass" +fi + +for arg in -usage -version -requires -catalog -list ; do + echo "---------- genclass $arg ----------" + ${genclass} $arg + echo "-----------" +done ; + +arg="-catalog PQ Set" +echo "---------- genclass $arg ----------" +${genclass} $arg +echo "-----------" + +arg="-list Map Stack" +echo "---------- genclass $arg ----------" +${genclass} $arg +echo "-----------" + +std1=int ; +std2=char ; + +# +# Do all of them with the single-type syntax +# The Map-based classes are expected to fail (good) +# +for proto in `${genclass} -list` ; do + file_h=$std1.$proto.h + file_cc=$std1.$proto.cc + files="$file_h $file_cc" ; + echo "Generating: genclass $std1 ref $proto" + ${genclass} $std1 ref $proto + if [ $? != 0 ] ; then + echo "Generation for $std1-$proto failed" + else + echo "Checking for badsub" + egrep '<[TC]&?>' $files + echo "removing $files" + rm $files + fi ; + echo "" + + nonstd1=fig + file_h=$nonstd1$proto.h + file_cc=$nonstd1$proto.cc + files="$file_h $file_cc" ; + echo "genclass $std1 ref $proto $nonstd1" + ${genclass} $std1 ref $proto $nonstd1 + if [ $? != 0 ] ; then + echo "Generation for $std1-$proto failed" + else + echo "Checking for badsub" + egrep '<[TC]?>' $files + echo "removing $files" + rm $files + fi ; + echo "" + +done ; + +# +# Do them all again with the -2 syntax +# None are expected to fail because there is no +# way to tell something that requires the single-type syntax +# +for proto in `${genclass} -list` ; do + file1_h=$std1.$proto.h + file1_cc=$std1.$proto.cc + files1="$file1_h $file1_cc"; + file2_h=$std1.$std2.$proto.h + file2_cc=$std1.$std2.$proto.cc + files2="$file2_h $file2_cc" ; + files="$file1_h $file1_cc $file2_h $file2_cc" ; + echo "Generating: genclass -2 $std1 ref $std2 val $proto" + ${genclass} -2 $std1 ref $std2 val $proto + if [ $? != 0 ] ; then + echo "Generation for $std1-$std2-$proto failed" + else + echo "Checking for badsub" + if [ -f $file1_h ] ; then + # then $file1_cc is expected to exist + egrep '<[TC]&?>' $files1 + echo "removing $files1" + rm $files1 + else + # then [ -f $file2_h ] + # and $file2_cc is expected to exist + egrep '<[TC]&?>' $files2 + echo "removing $files2" + rm $files2 + fi ; + fi ; + echo "" + + nonstd=fig + file_h=$nonstd$proto.h + file_cc=$nonstd$proto.cc + files="$file_h $file_cc" ; + echo "Generating: genclass -2 $std1 ref $std2 val $proto $nonstd" + ${genclass} -2 $std1 ref $std2 val $proto $nonstd + if [ $? != 0 ] ; then + echo "Generation for $std1-$std2-$proto failed" + else + echo "Checking for badsub" + egrep '<[TC]&?>' $files + echo "removing $files" + rm $files + fi ; + echo "" + +done ; diff --git a/gnu/lib/libg++/libg++/gperf/COPYING b/gnu/lib/libg++/libg++/gperf/COPYING new file mode 100644 index 00000000000..9a170375811 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/COPYING @@ -0,0 +1,249 @@ + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 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. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our 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. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, 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 a 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 tell them 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. + + 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 Agreement 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 work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 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 +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual 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 General + Public License. + + d) 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. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 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 + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying 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. + + 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. + + 7. 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 the 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 +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. 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 + + 9. 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. + + 10. 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 humanity, 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 1, 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. + +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) 19xx 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 a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/gnu/lib/libg++/libg++/gperf/ChangeLog b/gnu/lib/libg++/libg++/gperf/ChangeLog new file mode 100644 index 00000000000..50f691b633b --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/ChangeLog @@ -0,0 +1,1213 @@ +Tue Oct 10 16:37:28 1995 Mike Stump + + * src/new.cc: Since malloc/delete are not paired, we cannot call + free. + +Wed Jan 4 12:40:14 1995 Per Bothner + + * src/Makefile.in ($(TARGETPROG)): Link with $(LDFLAGS). + Patch from John Interrante . + +Sat Nov 5 19:12:48 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * src/Makefile.in (LIBS): Remove. + +Tue Oct 18 17:51:14 1994 Per Bothner + + * src/std-err.cc: Use stderror, instead of the non-standard + sys_nerr and sys_errlist. + +Sat Sep 17 22:02:13 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * src/key-list.cc (output_hash_function): + Patch from William Bader . + +Fri Jul 15 09:38:11 1994 Per Bothner (bothner@cygnus.com) + + * src/std-err.cc: #include , and only declare + extern int errno if errno is not a macro. + +Mon May 30 17:29:34 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (src_all, install): Make sure to add '/' after + `pwd` in $rootme, as expected by FLAGS_TO_PASS. + +Wed May 11 00:47:22 1994 Jason Merrill (jason@deneb.cygnus.com) + + Make libg++ build with gcc -ansi -pedantic-errors + * src/options.h: Lose commas at end of enumerator lists. + +Sun Dec 5 19:16:40 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * src/hash-table.cc (Hash_Table::~Hash_Table): Don't pass an + argument to fprintf, since it's not expecting one. + +Fri Nov 26 19:03:18 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * src/list-node.cc: #undef index, for the sake of broken NeXT, + +Thu Nov 4 11:16:03 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (install): Use INSTALL_DATA for gperf.1. + +Mon Oct 25 18:40:51 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * src/key-list.cc (Key_List::read_keys): Use POW macro + to increase hash table size to power of 2. + + * options.h (LARGE_STACK_ARRAYS): New flag. Defaults to zero. + * gen-perf.cc, key-list.cc, read-line.cc: + Only stack-allocate large arrays if LARGE_STACK_ARRAYS is set. + * main.cc (main): Only call setrlimit (RLIMIT_STACK, ...) + if LARGE_STACK_ARRAYS. + +Mon Oct 4 17:45:08 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * src/gen-perf.cc: Always use ANSI rand/srand instead of BSDisms. + +Wed Aug 18 12:19:53 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (src_all): Make less verbose output. + +Fri May 28 14:01:18 1993 Per Bothner (bothner@rtl.cygnus.com) + + * src/gen-perf.cc (Gen_Perf::change): Don't use gcc-specific + 2-operand conditional expression. + * src/key-list.cc (Key_List::output_lookup_array): + Don't use variable-size stack arrays, unless compiled by g++. + +Tue May 4 14:08:44 1993 Per Bothner (bothner@cygnus.com) + + Changes (mostly from Peter Schauer) to permit compilation + using cfront 3.0 and otherwise be ARM-conforming. + * src/key-list.h: class Key_List must use public derivation + of base class Std_Err (because Gen_Perf::operator() in gen-perf.cc + calls Std_Err::report_error). + * src/gen-perf.cc (Gen_Perf::affects_prev), src/hash-table.cc + (Hash_Table::operator()): Don't use gcc-specific 2-operand + conditional expression. + * src/iterator.cc (Iterator::operator()): Don't use gcc-specific + range construct in case label. + * key-list.cc (Key_List::output_lookup_array, Key_List::read_keys), + src/gen-perf.cc (Gen_Perf::operator(), src/read-line.cc + (Read_Line::readln_aux): If not gcc, don't allocate + variable-sized arrays on stack. + * src/new.cc (operator new): Argument type should be size_t. + * key-list.cc (Key_List::output_lookup_array, Key_List::read_keys), + new/cc (::operator new): Don't use non-standard >?= operator. + +Tue Apr 27 20:11:30 1993 Per Bothner (bothner@cygnus.com) + + * src/Makefile.in: Define TARGETPROG, and use it. + +Mon Apr 19 00:29:18 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in, configure.in: Re-vamped configure scheme. + * gperf.texinfo: Renamed to gperf.texi. + * src/bool-array.{h,cc}: ANSIfy bzero->memset. + +Sat Jan 30 20:21:28 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * tests/Makefile.in (mostlyclean): Also delete aout, cout, m3out, + pout, and preout. + +Tue Dec 29 08:58:17 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: pass $(FLAGS_TO_PASS) to all calls to make. + (FLAGS_TO_PASS): added INSTALL, INSTALL_DATA, INSTALL_PROGRAM. + +Mon Dec 21 18:46:46 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tests/expected.* renamed to *.exp to fit in 14 chars. + * tests/Makefile.in: Update accordingly. + Also rename output.* to *.out. + * src/Makefile.in (clean): Remove gperf program. + +Wed Dec 9 14:33:34 1992 Per Bothner (bothner@cygnus.com) + + * src/hash-table.cc, src/bool-array.h: ANSIfy bzero->memset. + +Thu Dec 3 19:34:12 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (distclean, realclean): Don't delete + Makefile before recursing. + +Fri Nov 6 13:41:49 1992 Per Bothner (bothner@rtl.cygnus.com) + + * key-list.{h,cc}: Remove MAX_INT (and similar) constant + fields from Key_List class, and use INT_MAX (etc) from limits.h. + * key-list.{h,cc}, options.{h,cc}, vectors.h: Removed all + uses of initialized const fields, as they are non-standard + - and their use was easy to do away with. Mostly, just + made the constants static non-fields in the .cc file. + +Mon Nov 2 13:10:11 1992 Per Bothner (bothner@cygnus.com) + + * tests/Makefile.in: When generating cinset.c, don't pass -C, + since -C assumes an ANSI compiler. Add the -C flag (with -a) + when generating test.out.3 instead. + * tests/expected.out.3: Update accordingly. + +Wed Aug 12 11:47:54 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Factor out common flags into $(FLAGS_TO_PASS). + * Makefile.in: 'install-info' depends on gperf.info. + +Mon Aug 10 11:39:52 1992 Ian Lance Taylor (ian@dumbest.cygnus.com) + + * Makefile.in, src/Makefile.in: always create installation + directories. + +Mon Jul 20 15:33:21 1992 Mike Stump (mrs@cygnus.com) + + * src/new.cc (operator new): Add cast from void * to char *, + since it is not a standard conversion. + +Wed Jun 17 16:25:30 1992 Per Bothner (bothner@rtl.cygnus.com) + + * src/gen-perf.cc: #include <_G_config.h> for _G_SYSV. + * src/key-list.cc: alloca() hair. + * src/main.cc (main): Only call getrlimit if _G_HAVE_SYS_RESOURCE. + * Makefile,in, {src,test}/Makefile.in: Fix *clean rules. + +Fri May 29 13:21:13 1992 Per Bothner (bothner@rtl.cygnus.com) + + * src/gen-perf.cc: Replace USG -> _G_SYSV. + +Thu May 14 13:58:36 1992 Per Bothner (bothner@rtl.cygnus.com) + + * src/Makefile.in: Don't pass obsolete flag -DUNLIMIT_STACK. + * tests/Makefile.in (clean): Fix. + +Sat Mar 7 00:03:56 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * gperf.texinfo: added menu item hook. + +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. + +Sun Jan 26 19:21:58 1992 Per Bothner (bothner at cygnus.com) + + * tests/Makefile.in: Use re-directed stdin instead of file + name in argv. This allows us to remove the filename + from the output, the expected output, and hence the diffs. + (Note that the input file is in $(srcdir), which we cannot + place in the expected out files.) + * tests/expected.out.[1235]: Edit out input filename, + to match new output. + +Thu Jun 28 16:17:27 1990 Doug Schmidt (schmidt at brilliant) + + * Wow, first fix on the new job! There was a dumb error + in Key_List::output_lookup_function, where I printed the + string "&wordlist[key]" instead of the correct "&wordlist[index]". + + * Added a couple of #ifdefs for USG support. + +Sun Jun 3 17:16:36 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Updated the version number to 2.5 and sent to Doug Lea for release + with the latest GNU libg++. + + * Changed the error handling when a keyword file cannot be opened + (now calls perror). + +Wed May 30 14:49:40 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Instrumented the source code with trace statements automagically + inserted using my new automated trace instrumentation tool! + +Wed May 9 11:47:41 1990 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Really fixed the previous bug. Turns out that a small amount + of logic had to be duplicated to handle static links that occur + as part of dynamic link chains. What a pain!!! + +Tue May 8 23:11:44 1990 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Fixed a stupid bug in Key_List::output_lookup_array that was + causing incorrect counts to be generated when there were both + static and dynamic links occurring for the same hash value. + Also simplified the code that performs the logic in this routine. + +Mon Apr 30 17:37:24 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Fixed stupid bug in Key_List::output_lookup_array that was + making the generated lookup[] array contain `chars' even + when the values stored in the chars are greater than 127! + + * Changed the behavior of the -G (global table) option so that it + will output the `length[]' array in the global scope along with + the `word_list[]' array. + + * Fixed a stupid bug in Key_List::output_lookup_function that + would always output the complicated `duplicate-handling' lookup + logic, even when there were no duplicates in the input! + + * Yikes, had to modify a bunch of stuff in key-list.cc to correctly + handle duplicate entries. Changed the generated code so that + the MIN_HASH_VALUE is no longer subtracted off when calculating + the hash value for a keyword. This required changing some other + code by substituting MAX_HASH_VALUE for TOTAL_KEYS in several places. + Finally, this means that the generated tables may contain leading + null entries, but I suppose it is better to trade-off space to get + faster performance... + +Mon Mar 26 13:08:43 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Updated version number to 2.4 to reflect the latest changes. + + * Changed the main program so that it always prints out gperf's + execution timings to the generated output file. + +Sun Mar 25 12:39:30 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Added the -Z option so that users can specify the name of the + generated class explicitly. Updated documentation to reflect + this change. + + * Modified the generated C++ class interface so that the functions + are declared static (to remove the overhead of passing the `this' + pointer). This means that operator()() can no longer be used, + since it only works on non-static member functions. + Also changed things so that there is no constructor (why waste + the extra call, when it doesn't do anything, eh?) + + * Modified the behavior of Key_List::output when the -L C++ option + is enabled. Previously the code generated use const data members + to record MIN_WORD_LENGTH, MIN_HASH_VALUE, etc. However, as + pointed out by James Clark this may result in suboptimal behavior + on the part of C++ compilers that can't inline these values. + Therefore, the new behavior is identical to what happens with + -L C, i.e., either #defines or function-specific enums are used. + Why sacrifice speed for some abstract notion of `code purity?' ;-) + +Tue Mar 6 18:17:42 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Added the -E option that defines constant values using an enum + local to the lookup function rather than with #defines. This + also means that different lookup functions can reside in the + same file. Thanks to James Clark (jjc@ai.mit.edu). + +Sat Mar 3 20:19:00 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Added a special case to key_list::output_switch that doesn't + generate extra comparisons when the `-S' is given an argument + of 1 (the normal case). This should speed up the generated + code output a tad... + +Fri Feb 23 14:21:28 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Renamed all instances of member function get_keysig_size + to get_max_keysig_size, since this is more precise... + + * Changed all occurrences of charset to keysig (stands for ``key + signature'') to reflect the new naming convention used in the + USENIX paper. + +Thu Feb 22 11:28:36 1990 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Changed the name of the generated associated values table from + asso_value to asso_values to reflect conventions in the USENIX + C++ paper. + +Thu Feb 15 23:29:03 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Updated the gperf.texinfo file to fix some formatting problems + that had crept in since last time. + +Wed Feb 14 23:27:24 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Fixed stupid bug in key-list.cc (get_special_input), wher + gperf replaced each '%' with the succeeding character. + + * Added support for multiple target language generation. Currently + handled languages are C and C++, with C as the default. Updated + documentation and option handler to reflect the changes. + + * Added a global destructor to new.cc and removed the #ifdef, since + the bloody thing now works with libg++. + +Mon Feb 14 13:00:00 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Found out that my gperf paper was accepted at the upcoming + USENIX C++ Conference in San Francisco. Yow! + +Tue Jan 30 09:00:29 1990 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * #ifdef'd out the new.cc memory allocator, since there are + problems with this and the libg++ stuff. + + * Changed key-list.h so that class Vectors is a public (rather + than private) base class for class Key_List. The previous + form was illegal C++, but wasn't being caught by the old + g++ compiler. Should work now... ;-) + +Sun Dec 10 14:08:23 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added several changes from rfg@ics.uci.edu. These changes + help to automate the build process. + +Wed Nov 15 15:49:33 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Removed conditional compilation for GATHER_STATISTICS. There's + really no good reason to avoid collecting this info at run-time, + since that section of code is *hardly* the bottleneck... ;-) + + * Simplified the C output routines in Key_List::set_output_types + and Key_List::output_keyword_table a bit in order to + speed-up and clean up the code generation. + + * Modified function Key_List::get_special_input so that it does + not try to `delete' a buffer that turned out to be too short. + This is important since the new memory management scheme + does not handle deletions. However, adding a small amount of + garbage won't hurt anything, since we generally don't do this + operation more than a couple times *at most*! + + * Created a new file (new.cc) which includes my own overloaded + operator new. This function should dramatically reduce the + number of calls to malloc since it grabs large chunks and + doles them out in small pieces. As a result of this change + the class-specific `operator new' was removed from class List_Node. + +Tue Nov 14 21:45:30 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Continued to refine the great hack. The latest trick is to + try and replace most uses of dynamic memory (i.e., calls to + new) with uses of gcc dynamic arrays (i.e., an alloca solution). + This makes life much easier for the overall process-size, since + it reduces the amount of overhead for memory management. As a + side-effect from this change there is no reason to have the + Bool_Array::dispose member function, so it's outta here! + + * Fixed a stupid bug that was an disaster waiting to happen... + Instead of making the boolean array large enough to index + max_hash_value it was only large enough to index max_hash_value + - 1. Once again, an off-by-one mistake in C/C++!!!! + +Mon Nov 13 19:38:27 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added the final great hack! This allows us to generate hash tables + for near-perfect hash functions that contain duplicates, *without* + having to use switch statements! Since many compilers die on large + switch statements this feature is essential. Furthermore, it appears + that the generated code is often *smaller* than that put out by + compilers, even though a large, sparse array must be created. + Here's the general idea: + + a. Generate the wordlist as a contiguous block of keywords, + just as before when using a switch statement. This + wordlist *must* be sorted by hash value. + + b. Generate the lookup array, which is an array of signed + {chars,shorts,ints}, (which ever allows full coverage of + the wordlist dimensions). If the value v, where v = + lookup[hash(str,len)], is >= 0 and < TOTAL_KEYWORDS, then we + simply use this result as a direct access into the wordlist + array to snag the keyword for comparison. + + c. Otherwise, if v is < -TOTAL_KEYWORDS or > TOTAL_KEYWORDS + this is an indication that we'll need to search through + some number of duplicates hash values. Using a hash + linking scheme we'd then index into a different part of + the hash table that provides the starting index and total + length of the duplicate entries to find via linear search! + +Sun Nov 12 13:48:10 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Simplified Key_List::output_min_max considerably by recognizing + that since the keyword list was already sorted by hash value finding + the min and max values is trivial! + + * Improved the debugging diagnostics considerably in classes Key_List, + Hash_Table, and Gen_Perf. + + * Modified the `-s' option so that a negative argument is now + interpreted to mean `allow the maximum associated value to be + about x times *smaller* than the number of input keys.' This + should help prevent massive explosion of generated hash table + size for large keysets. + +Sat Nov 11 11:31:13 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added a field in class Key_List that counts the total number + of duplicate keywords, both static and dynamic. + + * Added a new member function Bool_Array that deletes the dynamic + memory allocated to Bool_Array::storage_array. This space may + be needed for subsequent options, so it made sense to free it as + soon as possible... + + * Renamed file/class Alpha_Vectors to Vectors, to avoid problems + with 14 character length filenames on SYSV. Also changed file + adapredefined.gperf to adadefs.gperf in the ./tests directory. + + * Modified class Options by changing the member function + Options::total_positions to Options::get_charset_size and + Options::set_charset_size. These two routines now either return + the total charset size *or* the length of the largest keyword + if the user specifies the -k'*' (ALLCHARS) option. This change + cleans up client code. + + * Merged all the cperf changes into gperf. + + * Made sure to explicitly initialize perfect.fewest_collisions to + 0. + + * Cleaned up some loose ends noticed by Nels Olson. + 1. Removed `if (collisions <= perfect.fewest_collisions)' + from Gen_Perf::affects_prev since it was superfluous. + 2. Removed the fields best_char_value and best_asso_value + from Gen_Perf. There were also unnecessary. + 3. Fixed a braino in the Bool_Array::bool_array_reset + function. Since iteration numbers can never be zero + the `if (bool_array.iteration_number++ == 0)' must be + `if (++bool_array.iteration_number == 0).' + 4. Modified Std_Err::report_error so that it correctly handles + "%%". + + * It is important to note that -D no longer enables -S. + There is a good reason for this change, which will become + manifested in the next release... (suspense!). + + * Made some subtle changes to Key_List::print_switch so that if finally + seems to work correctly. Needs more stress testing, however... + + * Made a major change to the Key_List::print_switch function. + The user can now specify the number of switch statements to generate + via an argument to the -S option, i.e., -S1 means `generate 1 + switch statement with all keywords in it,' -S2 means generate + 2 switch statements with 1/2 the elements in each one, etc. + Hopefully this will fix the problem with C compilers not being + able to generate code for giant switch statements (but don't + hold your breath!) + + * Changed Key_List::length function to Key_List::keyword_list_length. + + * Added a feature to main.c that prints out the starting wall-clock + time before the program begins and prints out the ending wall-clock + time when the program is finished. + + * Added the GATHER_STATISTICS code in hash-table.c so we can + keep track of how well double hashing is doing. Eventually, + GATHER_STATISTICS will be added so that all instrumentation + code can be conditionally compiled in. + + * Fixed a stupid bug in Key_List::print_switch routine. This + was necessary to make sure the generated switch statement worked + correctly when *both* `natural,' i.e., static links and dynamic + links, i.e., unresolved duplicates, hash to the same value. + + * Modified Bool_Array::~Bool_Array destructor so that + it now frees the bool_array.storage_array when it is no longer + needed. Since this array is generally very large it makes sense + to return the memory to the freelist when it is no longer in use. + + * Changed the interface to constructor Hash_Table::Hash_Table. This + constructor now passed a pointer to a power-of-two sized buffer that + serve as storage for the hash table. Although this weakens information + hiding a little bit it greatly reduces dynamic memory fragmentation, + since we can now obtain the memory via a call to alloca, rather + than malloc. This change modified Key_List::read_keys calling + interface. + + * Since alloca is now being used more aggressively a conditional + compilation section was added in main.c. Taken from GNU GCC, + this code gets rid of any avoidable limit on stack size so that + alloca does not fail. It is only used if the -DRLIMIT_STACK + symbol is defined when gperf is compiled. + + * Added warnings in option.c so that user's would be informed + that -r superceeds -i on the command-line. + + * Rewrote Gen_Perf::affects_prev. First, the code structure + was cleaned up considerably (removing the need for a dreaded + goto!). Secondly, a major change occurred so that Gen_Perf::affects_prev + returns FALSE (success) when fewest_hits gets down to whatever + it was after inserting the previous key (instead of waiting for + it to reach 0). In other words, it stops trying if it can + resolve the new collisions added by a key, even if there are + still other old, unresolved collisions. This modification was + suggested by Nels Olson and seems to *greatly* increase the + speed of gperf for large keyfiles. Thanks Nels! + + * In a similar vein, inside the Gen_Perf::change routine + the variable `perfect.fewest_collisions is no longer initialized + with the length of the keyword list. Instead it starts out at + 0 and is incremented by 1 every time change () is called. + The rationale for this behavior is that there are times when a + collision causes the number of duplicates (collisions) to + increase by a large amount when it would presumably just have + gone up by 1 if none of the asso_values were changed. That is, + at the beginning of change(), you could initialize fewest_hits + to 1+(previous value of fewest_hits) instead of to the number of + keys. Thanks again, Nels. + + * Replaced alloca with new in the Gen_Perf::change function. + This should eliminate some overhead at the expense of a little + extra memory that is never reclaimed. + + * Renamed Gen_Perf::merge_sets to Gen_Perf::compute_disjoint_union + to reflect the change in behavior. + + * Added the -e option so users can supply a string containing + the characters used to separate keywords from their attributes. + The default behavior is ",\n". + + * Removed the char *uniq_set field from LIST_NODE and modified + uses of uniq_set in perfect.c and keylist.c. Due to changes + to Gen_Perf::compute_disjoint_sets this field was no longer + necessary, and its removal makes the program smaller and + potentially faster. + + * Added lots of changes/fixes suggested by Nels Olson + (umls.UUCP!olson@mis.ucsf.edu). In particular: + 1. Changed Bool_Array so that it would dynamically create + an array of unsigned shorts rather than ints if the + LO_CAL symbol was defined during program compilation. + This cuts the amount of dynamic memory usage in half, + which is important for large keyfile input. + 2. Added some additional debugging statements that print extra + info to stderr when the -d option is enabled. + 3. Fixed a really stupid bug in Key_List::print_switch + A right paren was placed at the wrong location, which broke + strlen (). + 4. Fixed a subtle problem with printing case values when keylinks + appear. The logic failed to account for the fact that there + can be keylinks *and* regular node info also! + 5. Changed the behavior of Key_List::read_keys so that it would + honor -D unequivocally, i.e., it doesn't try to turn off dup + handling if the user requests it, even if there are no + immediate links in the keyfile input. + 6. Modified the -j option so that -j 0 means `try random values + when searching for a way to resolve collisions.' + 7. Added a field `num_done' to the Gen_Perf struct. This is used + to report information collected when trying to resolve + hash collisions. + 8. Modified the merge_sets algorithm to perform a disjoint + union of two multisets. This ensures that subsequent + processing in Gen_Perf::affect_prev doesn't + waste time trying to change an associated value that is + shared between two conflicting keywords. + 9. Modified Gen_Perf::affects_prev so that it doesn't try + random jump values unless the -j 0 option is enabled. + 10. Fixed a silly bug in Gen_Perf::change. This problem caused + gperf to seg fault when the -k* option was given and the + keyfile file had long keywords. + +Sun Oct 29 00:18:55 1989 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Modified class-specific new operations for Read_Line and + List_Node so they don't fail if SIZE is larger than twice + the previous buffer size. Note we double buffer size + everytime the previous buffer runs out, as a heuristic + to reduce future calls to malloc. + +Sun Oct 22 13:49:43 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Updated gperf version number to 2.0. Send to Doug Lea for + incorporation into the long-awaited `official' libg++ 1.36 + release! + + * Thanks to Nels Olson a silly bug in Gen_Perf::change () + was fixed. This problem caused gperf to seg fault when + the -k* option was given and the keyfile file had long + keywords. + + * Modified Key_List::print_hash_function so that it output + max_hash_value + 1 (rather than just max_hash_value) for + any associated value entries that don't correspond to + keyword charset characters. This should speed up rejection + of non-keyword strings a little in some cases. + +Sat Oct 21 19:28:36 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Fixed Key_List::print_hash_function so that it no longer output + things like `return 0 + ...' Although this probably gets + optimized away by even the worst C compilers there isn't any + point tempting fate... ;-) + + * Fixed class List_Node's constructor so that it wouldn't a priori + refuse to consider trying to hash keys whose length is less + than the smallest user-specified key position. It turns out + this is not a problem unless the user also specifies the -n + (NOLENGTH) option, in which case such keys most likely + don't have a prayer of being hashed correctly! + + * Changed the name of the generated lookup table from `Hash_Table' + to `asso_value' to be consistent with the gperf paper. + +Tue Oct 17 14:19:48 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added a flag GATHER_STATISTICS in the Makefile. If defined + during compilation this turns on certain collection facilities + that track the performance of gperf during its execution. In + particular, I want to see how many collisions occur for the + double hashing Hash_Table. + + * Added a safety check so that we don't screw up if the total + number of `resets' of the Bool_Array exceeds MAX_INT. Since + this number is around 2^31 it is unlikely that this would ever + occur for most input, but why take the risk? + + * Changed the behavior for the -a (ANSI) option so that the + generated prototypes use int rather than size_t for the LEN + parameter. It was too ugly having to #include all + over the place... + +Mon Oct 16 11:00:35 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Continued to work on the gperf paper for the USENIX C++ + conference. At some point this will be merged back into + the gperf documentation... + +Sat Oct 14 20:29:43 1989 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Added a majorly neat hack to Bool_Array, suggested by rfg. + The basic idea was to throw away the Ullman array technique. + The Ullman array was used to remove the need to reinitialize all + the Bool_Array elements to zero everytime we needed to determine + whether there were duplicate hash values in the keyword list. + The current trick uses an `iteration number' scheme, which takes + about 1/3 the space and reduces the overall program running a + time by about 20 percent for large input! The hack works as + follows: + + 1. Dynamically allocation 1 boolean array of size k. + 2. Initialize the boolean array to zeros, and consider the first + iteration to be iteration 1. + 2. Then on all subsequent iterations we `reset' the bool array by + kicking the iteration count by 1. + 3. When it comes time to check whether a hash value is currently + in the boolean array we simply check its index location. If + the value stored there is *not* equal to the current iteration + number then the item is clearly *not* in the set. In that + case we assign the iteration number to that array's index + location for future reference. Otherwise, if the item at + the index location *is* equal to the iteration number we've + found a duplicate. No muss, no fuss! + +Mon Oct 2 12:30:54 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Changed some consts in options.h to enumerals, since g++ + doesn't seem to like them at the moment! + +Sat Sep 30 12:55:24 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed a stupid bug in Key_List::print_hash_function that manifested + itself if the `-k$' option was given (i.e., only use the key[length] + character in the hash function). + + * Added support for the -C option. This makes the contents of + all generated tables `readonly'. + + * Changed the handling of generated switches so that there is + only one call to str[n]?cmp. This *greatly* reduces the size of + the generated assembly code on all compilers I've seen. + + * Fixed a subtle bug that occurred when the -l and -S option + was given. Code produced looked something like: + + if (len != key_len || !strcmp (s1, resword->name)) return resword; + + which doesn't make any sense. Clearly, this should be: + + if (len == key_len && !strcmp (s1, resword->name)) return resword; + +Tue Sep 26 10:36:50 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Changed class Read_Line's definition so that it no longer + needs to know about the buffering scheme used to speed up + dynamic memory allocation of input keywords and their + associated attributes. This means that operator new is no longer + a friend of Read_Line. + +Mon Sep 25 23:17:10 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Decided that Obstacks had too much overhead, so they were + removed in favor of super-efficient, low-overhead buffered + storage allocation hacks in Read_Line and List_Node. + + * No longer try to inline functions that g++ complains about + (Key_List::Merge and Key_List::Merge_Sort). + +Sun Sep 24 13:11:24 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Changed classes Read_Line and List_Node to use Obstacks in order + to cache memory allocation for keyword strings and List_Nodes. + + * Continued to experiment with inheritance schemes. + + * Added a new file `alpha.h', that declares static data shared + (i.e., inherited) between classes List_Node and Key_List. + +Tue Sep 12 16:14:41 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Made numerous changes to incorporate multiple inheritance in + gperf. + +Wed Aug 16 23:04:08 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added the -DCOMPILER_FIXED flag to the ./src/Makefile. This + implies that people trying to compile gperf need to have a + working version of the new g++ compiler (1.36.0). + + * Removed some extra spaces that were being added in the generated + C code. + +Mon Jul 24 17:09:46 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed PRINT_HASH_FUNCTION and PRINT_LOOKUP_FUNCTION in keylist.c + so that the generated functions take an unsigned int length argument. + If -a is enabled the prototype is (const char *str, size_t len). + +Fri Jul 21 13:06:15 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Fixed a typo in PRINT_KEYWORD_TABLE in keylist.cc that prevented + the indentation from working correctly. + + * Fixed a horrible typo in PRINT_KEYWORD_TABLE in keylist.cc + that prevented links from being printed correctly. + +Tue Jul 18 16:04:31 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Fixed up readline.cc and readline.h so that they work OK + with g++ compilers that aren't completely up-to-date. + If symbol COMPILER_FIXED is defined then the behavior + that works on my more recent version of g++ is enabled. + +Sun Jul 9 17:53:28 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Changed the ./tests subdirectory Makefile so that it + uses $(CC) instead of gcc. + +Sun Jul 2 21:52:15 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed a number of subtle bugs that occurred when -S was + combined with various and sundry options. + + * Added the -G option, that makes the generated keyword table + a global static variable, rather than hiding it inside + the lookup function. This allows other functions to directly + access the contents in this table. + + * Added the "#" feature, that allows comments inside the keyword + list from the input file. Comment handling takes place in readline.c. + This simplifies the code and reduces the number of malloc calls. + + * Also added the -H option (user can give the name of the hash + function) and the -T option (prevents the transfer of the type decl + to the output file, which is useful if the type is already defined + elsewhere). + +Thu Jun 22 20:39:39 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Modified many classes so that they would inherit Std_Err as + a base class. This makes things more abstract... + +Fri Jun 16 14:23:00 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Modified the -f (FAST) option. This now takes an argument. + The argument corresponds to the number of iterations used + to resolve collisions. -f 0 uses the length of the + keyword list (which is what -f did before). This makes + life much easier when dealing with large keyword files. + +Tue Jun 6 17:53:27 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added the -c (comparison) option. Enabling this + will use the strncmp function for string comparisons. + The default is to use strcmp. + + * Fixed a typo in key_list.cc (PRINT_SWITCH). This caused + faulty C code to be generated when the -D, -p, and -t + options were all enabled. + +Thu May 25 14:07:21 1989 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Once again, changed class Read_Line to overload global operator + new. Hopefully, this will work...! + +Sun May 21 01:51:45 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Modified Key_List::print_hash_function () so that it properly + formats the associated values in the hash table according to + the maximum number of digits required to represent the largest + value. + + * Removed the named return value from class Hash_Table's + operator (), since this causes a seg fault when -O is enabled. + No sense tripping subtle g++ bugs if we don't have to.... ;-) + + * Removed the operator new hack from Read_Line, since this seemed + to create horrible bus error problems. + + * Changed many class member functions and data members to be `static', + if they don't manipulate this! + +Fri May 12 23:06:56 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Changed class Std_Err to use static member functions, a la + Ada or Modula 2. This eliminates the need for an explicit + error-handler class object. + + * Added the ``named return value'' feature to Hash_Table::operator () + and Bool_Array::operator [], just for the heck of it.... ;-) + + * Changed the previous hack in Read_Line so that we now use + the overloaded global `new' instead of NEW_STRING! + +Wed May 3 17:36:55 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Updated to version 1.7. This reflects the recent major changes + and the new C port. + + * Modified the GNU getopt.cc routine to have a class-based interface. + + * Fixed a typo in Perfect.cc ~Perfect that prevented the actual maximum + hash table size from being printed (maybe the stream classes + weren't so bad after all.... ;-). + + * Added support for the -f option. This generates the perfect + hash function ``fast.'' It reduces the execution time of + gperf, at the cost of minimizing the range of hash values. + +Tue May 2 16:23:29 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Added an efficiency hack to Read_Line. Instead of making + a call to operator NEW (a.k.a. malloc) for each input string + a new member function NEW_STRING stores a large buffer from + which new strings are carved out, growing the buffer if + necessary. It might be useful to add this throughout the + program.... + + * Removed all unnecessary calls to DELETE. If the program is about + to exit it is silly to waste time freeing memory. + + * Added the GNU getopt program to the distribution. This makes + GPERF portable to systems that don't include getopt in libc. + + * Added a strcspn member to class Key_List. This also increases + portability. + + * Added the get_include_src function from keylist.c as a member + function in class Key_List. Hopefully every function is + now associated with a class. This aids abstraction and + modularity. + + * Ported gperf to C. From now on both K&R C and GNU G++ versions + will be supported. There will be two ChangeLog files, one + for each version of the program. + +Mon May 1 16:41:45 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed a bug with -k'*'. This now prints out *all* the cases + up to the length of the longest word in the keyword set. + +Sun Apr 30 12:15:25 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Removed all use of the stream classes. Too ugly, slow, and + not handled by the c++-mode formatter.... + + * Modified the handling of links (i.e., keywords that have + identical hash values as other keywords). This should + speed up hash function generation for keyword sets with + many duplicate entries. The trick is to treat duplicate + values as equivalence classes, so that each set of duplicate + values is represented only once in the main list processing. + + * Fixed some capitialization typos and indentations mistakes in + Key_List::print_hash_function. + +Sat Apr 29 12:04:03 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Fixed a typo/logico in Key_List::print_switch that prevented + the last keyword in the keyword list to be print out. This + requires further examination..... + + * Fixed a stupid bug in List_Node::List_node. If the -k'*' option + was enabled the KEY_SET string wasn't getting terminated with + '\0'! + +Fri Apr 28 12:38:35 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Renamed strexp.h and strexp.cc to iterator.h and iterator.cc. + Also changed the strexp class to iterator. Continued to work + on style... + + * Updated the version number to 1.6. This reflects all the + recent changes. + +Thu Apr 27 00:14:51 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added the -D option that properly handles keyword sets that + contain duplicate hash values. + + * Continued the stylistic changes. Added the #pragma once + directive to all the *.h files. Removed all #defines and + replaced them with static consts. Also moved the key_sort + routine from options.cc into the options class as a + member function. + +Mon Apr 3 13:26:55 1989 Doug Schmidt (schmidt at zola.ics.uci.edu) + + * Made massive stylistic changes to bring source code into + conformance with GNU style guidelines. + +Thu Mar 30 23:28:45 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Fixed up the output routines so that they generate code + corresponding to the GNU style guidelines. + +Sat Mar 11 13:12:37 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed Stderr constructors so that they wouldn't try to + use the base class initializer syntax for the static + class variable Program_Name. G++ 1.34 is stricter in + enforcing the rules! + +Fri Mar 10 11:24:14 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Removed -v and ``| more'' from the Makefile to keep rfg happy... + +Thu Mar 2 12:37:30 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Sent latest GNU gperf version 1.5 to Doug Lea for inclusion + into libg++ 1.34. Note that there is a small bug with + the new %{ ... %} source inclusion facility, since it doesn't + understand comments and will barf if %{ or %} appear nested + inside the outermost delimiters. This is too trivial of + a defect to fix at the moment... + +Tue Feb 28 11:19:58 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added the -K option, which allows the user to provide a + alternative name for the keyword structure component. + The default is still ``name.'' + + * Added the LEX and YACC-like ability to include arbitrary + text at the beginning of the generated C source code output. + This required two new functions Get_Special_Input, + Key_List::Save_Include_Src; + + * Fixed memory allocation bug in Key_List::Set_Types. + Variable Return_Type needs 1 additional location + to store the "*" if the -p option is used. + + * Added code to NULL terminate both Struct_Tag and Return_Type, + *after* the strncpy (stupid mistake). + +Mon Feb 27 14:39:51 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added a new option -N. This allows the user to specify the + name to be used for the generated lookup function. The + default name is still ``in_word_set.'' This makes it + possible to completely automate the perfect hash function + generation process! + +Mon Feb 20 23:33:14 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Corrected the Hash_Table::operator () function so that + *it* is responsible for deciding when a new key has the + same signature as a previously seen key. The key length + information is now used internally to this function to + decide whether to add to the hash table those keys with + the same key sets, but different lengths. Before, this + was handled by the Key_List::Read_Keys function. However, + this failed to work for certain duplicate keys, since + they weren't being entered into the hash table properly. + +Sun Feb 19 16:02:51 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Modified class Options by moving the enum Option_Type out + of the class. This is to satisfy the new enumeration + scope rules in C++. + +Sun Jan 15 15:12:09 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Incremented the version number upto 1.4 to reflect the new + options that affect the generated code. Send the new + distribution off to Michael for use with g++ 1.33. + + * Added a fix to Key_List::Read_Keys so that it checks for links + properly when the -n option is used. Previously, it didn't + catch obvious links, which caused it to spend large amount + of time searching for a solution that could never occur! + + * Modified the Key_List data structure to record *both* the + minimum and the maximum key lengths. This information + is now computed in Key_List::Read_Keys, and thus + Key_List::Print_Min_Max doesn't need to bother. + + * Modifed the key position iterator scheme in options.cc to + eliminate the need for member function Options::Advance. + Now, the Options::Get function performs the advancement + automatically, obviating the need for an extra function call. + + * Added the new function Options::Print_Options, to print out + the user-specified command line options to generated C + output file. + + * Added a new function, Key_List::Print_Keylength_Table, + which creates a table of lengths for use in speeding + up the keyword search. This also meant that a new + option, -l (LENTABLE) is recognized. It controls + whether the length table is printed and the comparison + made in the generated function ``in_word_set.'' + + * Added a comment at the top of the generated C code + output file that tells what version of gperf was used. + Next, I'll also dump out the command line options + as a comment too. Thanks to Michael Tiemann for the + feedback on this. + + * Fixed the -n option to make it work correctly with + other parts of the program (most notably the Perfect::Hash + function and the computation of minimum and maximum lengths. + +Fri Jan 13 21:25:27 1989 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Realized the the need to add a test that will enable + optimziation of the generated C code in the ``hash'' function + by checking whether all the requested key positions are + guaranteed to exist due to the comparison in `in_word_set.'' + I'll put this in soon.... + +Thu Jan 12 20:09:21 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Added pascal, modula3, and modula2 tests inputs to the + Makefile + + * Recognised that there is a bug with the -n option. However + I'm too busy to fix it properly, right now. The problem + is that the generated #define end up being 0, since that's + my hack to make -n work. This needs complete rethinking! + +Tue Jan 10 00:08:16 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Added a new option, -n, that instructs gperf to not use the + length of an identifier when computing the hash functions. + I'm not sure how useful this is! + + * Retransmitted the distribution to rocky.oswego.edu. Hopefully, + this will work! + + * Began fixing the indentation and capitalization to conform + to the GNU coding guidelines. + +Mon Jan 9 22:23:18 1989 Doug Schmidt (schmidt at pompe.ics.uci.edu) + + * Fixed horrible bug in Read_Line::Readln_Aux. This was + a subtle and pernicous off-by-1 error, that overwrote + past the last character of the input string buffer. I + think this fault was killing the vax! + + * Yow, fixed an oversight in List_Node::List_Node, where the + pointer field Next was uninitialized. Luckily, the new routine + seems to return 0 filled objects the first time through! + +Sun Jan 8 13:43:14 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Modified the ``key linked'' diagnostic in Key_List::Read_Keys + to be more helpful and easy to read. + + * Fixed the List_Node::List_Node so that it would ignore trailing + fields if the -t option was not enabled. + + * Moved the List_Node declarations out of keylist.h and + into a file of its own, called listnode.cc and listnode.h + Made Set_Sort a member function of class List_Node. + + * Massively updated the documentation in the gperf.texinfo file. + + * Polished off the major revision to the print functions, + added a few new tests in the Makefile to check for the + validity of the program and ftp'ed the entire distribution + off to Doug Lea for libg++. ( changed it to + 1.3 to reflect the major changes with the generated + C code ). + + * Fixed Key_List::Print_Switch to deal with the -p and -t options. + This meant that the ``still-born'' function Key_List:: + Print_Type_Switch was superflous, so I removed it. + Also, removed the restriction in Option that the -p and + -t options couldn't be used simultaneously. + + * Modified List_Node::List_Node, to perform only 1 call to + ``new'' when dynamically allocating memory for the Key_Set + and the Uniq_Set. + +Sat Jan 7 14:10:51 1989 Doug Schmidt (schmidt at glacier.ics.uci.edu) + + * Fixed a big bug with the new policy of nesting the + wordlist inside of generated function ``in_word_set.'' + I'd forgotten to declare the wordlist array as static! + ( arrgh ). + + * Added a new function Key_List::Set_Types, that figures out + the return type for generated function ``in_word_set,'' + the user-defined ``struct tag,'' if one is used, and also + formates the array type for the static local array. + + * Changed the print routines to take advantage of the + new -p option. + + * Began adding the hooks to allow the return of a pointer + to a user defined struct location from the generated + ``in_word_set'' function instead of the current 0 or 1 + return value. Created function Key_List::Print_Type_Switch + and added option -p to class Option, allowing the user to + request generation of the aforementioned pointers returned + instead of booleans. + + * Put in checks in class Option to make sure that -S and -t + options are not used simultaneously. This restriction + will be removed in subsequent releases, once I decide on + a clean way to implement it. + + * Sent version 1.2 to Doug Lea for possible inclusion into + the libg++ distribution. + + * Moved the static word_list array inside the generated function + in_word_set. This supports better data hiding. + + * Added a texinfo file, gperf.texinfo + + * Revised the Makefile to cleanup the droppings from texinfo + and changed the name of gperf.cc and gperf.h to perfect.cc + and perfect.h. + +Fri Jan 6 13:04:45 1989 Doug Schmidt (schmidt at crimee.ics.uci.edu) + + * Implemented the switch statement output format. Much better + for large datasets in terms of space used. + + * Added new functions to break up the Key_List::Output function. + Functions added were Key_List::Print_Switch, Key_List::Print_Min_Max, + Key_List::Print_Keyword_Table, Key_List::Print_Hash_Function, + and Key_List::Print_Lookup_Function. This simplifies the + big mess in Key_List::Output considerably! + + * Added switch statement option to Options, which potentially + trades time for space in the generated lookup code. + +Thu Jan 5 22:46:34 1989 Doug Schmidt (schmidt at siam.ics.uci.edu) + + * Released version 1.1 + + * Fixed a bug with Gperf::Merge_Set, it was skipping letters shared + between the Set_1 and Set_2. + + * Added the optimal min/max algorithm in Key_List::Output. This + runs in O ( 3n/2 ), rather than O ( 2n ) time. + + * Changed Gperf::Sort_Set to use insertion sort, rather than + bubble sort. + + * Added a check in Key_List::Output for the special case where + the keys used are 1,$. It is possible to generate more + efficient C code in this case. diff --git a/gnu/lib/libg++/libg++/gperf/Makefile.in b/gnu/lib/libg++/libg++/gperf/Makefile.in new file mode 100644 index 00000000000..7d1d1eff9fa --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/Makefile.in @@ -0,0 +1,43 @@ +# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc. +# written by Douglas C. Schmidt (schmidt@ics.uci.edu) +# +# This file is part of GNU GPERF. +# +# GNU GPERF is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GNU GPERF is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +.PHONY: src_all +src_all: + @echo "cd src ; make ... all" + @rootme=`pwd`/ ; export rootme ; cd src ; \ + $(MAKE) $(FLAGS_TO_PASS) all + +.PHONY: install +install: + rootme=`pwd`/ ; export rootme ; cd src ; \ + $(MAKE) $(FLAGS_TO_PASS) install + $(INSTALL_DATA) $(srcdir)/gperf.1 $(man1dir)/gperf.1 + +distrib: force + cd ..; rm -f gperf.tar.Z; tar cvf gperf.tar gperf; compress gperf.tar;\ + uuencode gperf.tar.Z < gperf.tar.Z > GSHAR + +.PHONY: shar +shar: force + cd ..; makekit -ngperf ./gperf ./gperf/* ./gperf/src/* ./gperf/tests/* diff --git a/gnu/lib/libg++/libg++/gperf/README b/gnu/lib/libg++/libg++/gperf/README new file mode 100644 index 00000000000..bd9d14ea680 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/README @@ -0,0 +1,24 @@ +While teaching a data structures course at University of California, +Irvine, I developed a program called GPERF that generates perfect hash +functions for sets of key words. A perfect hash function is simply: + + A hash function and a data structure that allows + recognition of a key word in a set of words using + exactly 1 probe into the data structure. + +The gperf.texinfo file explains how the program works, the form of the +input, what options are available, and hints on choosing the best +options for particular key word sets. The texinfo file is readable +both via the GNU emacs `info' command, and is also suitable for +typesetting with TeX. + +The enclosed Makefile creates the executable program ``gperf'' and +also runs some tests. + +Output from the GPERF program is used to recognize reserved words in +the GNU C, GNU C++, and GNU Pascal compilers, as well as with the GNU +indent program. + +Happy hacking! + +Douglas C. Schmidt diff --git a/gnu/lib/libg++/libg++/gperf/configure.in b/gnu/lib/libg++/libg++/gperf/configure.in new file mode 100644 index 00000000000..ca273f57398 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/configure.in @@ -0,0 +1,27 @@ +# 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. + +configdirs="src tests" +srctrigger=gperf.1 +srcname="perfect hash function generator" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +MOSTLYCLEAN='\#* core *.o gperf.?? gperf.??s gperf.log gperf.toc gperf.*aux *inset.c *out' +CLEAN='gperf' +INFO_FILES=gperf +ALL=src_all + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/gperf/gperf.1 b/gnu/lib/libg++/libg++/gperf/gperf.1 new file mode 100644 index 00000000000..5673c80062a --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/gperf.1 @@ -0,0 +1,23 @@ +.TH GPERF 1 "December 16, 1988 +.UC 4 +.SH NAME +gperf \- generate a perfect hash function from a key set +.SH SYNOPSIS +.B gperf +[ +.B \-adghijklnoprsStv +] [ +.I keyfile +] +.SH DESCRIPTION + +\fIgperf\fP reads a set of ``keys'' from \fIkeyfile\fP (or, by +default, from the standard input) and attempts to find a non-minimal +perfect hashing function that recognizes a member of the key set in +constant, i.e., O(1), time. If such a function is found the program +generates a pair of \fIC\fP source code routines that perform the +hashing and table lookup. All generated code is directed to the +standard output. + +Please refer to the \fIgperf.texinfo\fP file for more information. +This file is distributed with \fIgperf\fP release. diff --git a/gnu/lib/libg++/libg++/gperf/gperf.info b/gnu/lib/libg++/libg++/gperf/gperf.info new file mode 100644 index 00000000000..699121ef93d --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/gperf.info @@ -0,0 +1,1127 @@ +This is Info file gperf.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/gperf/gperf.texi. + +START-INFO-DIR-ENTRY +* Gperf: (gperf). Perfect Hash Function Generator. +END-INFO-DIR-ENTRY + + This file documents the features of the GNU Perfect Hash Function +Generator + + Copyright (C) 1989 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 also +that the section entitled "GNU General Public License" is 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 the section entitled "GNU `gperf' General Public +License" an d this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: gperf.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) + +Introduction +************ + + This manual documents the GNU `gperf' perfect hash function generator +utility, focusing on its features and how to use them, and how to report +bugs. + +* Menu: + +* Copying:: GNU `gperf' General Public License says + how you can copy and share `gperf'. +* Contributors:: People who have contributed to `gperf'. +* Motivation:: Static search structures and GNU GPERF. +* Search Structures:: Static search structures and GNU `gperf' +* Description:: High-level discussion of how GPERF functions. +* Options:: A description of options to the program. +* Bugs:: Known bugs and limitations with GPERF. +* Projects:: Things still left to do. +* Implementation:: Implementation Details for GNU GPERF. +* Bibliography:: Material Referenced in this Report. + + -- The Detailed Node Listing -- + +High-Level Description of GNU `gperf' + +* Input Format:: Input Format to `gperf' +* Output Format:: Output Format for Generated C Code with `gperf' + +Input Format to `gperf' + +* Declarations:: `struct' Declarations and C Code Inclusion. +* Keywords:: Format for Keyword Entries. +* Functions:: Including Additional C Functions. + + +File: gperf.info, Node: Copying, Next: Contributors, Prev: Top, Up: Top + +GNU GENERAL PUBLIC LICENSE +************************** + + Version 1, February 1989 + + Copyright (C) 1989 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. + +Preamble +======== + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our 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. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, 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 a 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 tell them 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. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 1. This License Agreement 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 work + containing the Program or a portion of it, either verbatim or with + modifications. Each licensee is addressed as "you". + + 2. 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 General Public License + and to the absence of any warranty; and give any other recipients + of the Program a copy of this General Public License along with + the Program. You may charge a fee for the physical act of + transferring a copy. + + 3. You may modify your copy or copies of the Program or any portion of + it, and copy and distribute such modifications under the terms of + Paragraph 1 above, provided that you also do the following: + + * cause the modified files to carry prominent notices stating + that you changed the files and the date of any change; and + + * cause the whole of any work that you distribute or publish, + that in whole or in part contains the Program or any part + thereof, either with or without modifications, to be licensed + at no charge to all third parties under the terms of this + General Public License (except that you may choose to grant + warranty protection to some or all third parties, at your + option). + + * If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the simplest and most usual 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 General Public License. + + * 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. + + Mere aggregation of another independent work with the Program (or + its derivative) on a volume of a storage or distribution medium + does not bring the other work under the scope of these terms. + + 4. You may copy and distribute the Program (or a portion or + derivative of it, under Paragraph 2) in object code or executable + form under the terms of Paragraphs 1 and 2 above provided that you + also do one of the following: + + * accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + * accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal + charge for the cost of distribution) a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Paragraphs 1 and 2 above; or, + + * accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative + is allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + + Source code for a work means the preferred form of the work for + making modifications to it. For an executable file, complete + source code means all the source code for all modules it contains; + but, as a special exception, it need not include source code for + modules which are standard libraries that accompany the operating + system on which the executable file runs, or for standard header + files or definitions files that accompany that operating system. + + 5. You may not copy, modify, sublicense, distribute or transfer the + Program except as expressly provided under this General Public + License. Any attempt otherwise to copy, modify, sublicense, + distribute or transfer the Program is void, and will automatically + terminate your rights to use the Program under this License. + However, parties who have received copies, or rights to use + copies, from you under this General Public License will not have + their licenses terminated so long as such parties remain in full + compliance. + + 6. By copying, distributing or modifying 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. + + 7. 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. + + 8. 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 the 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 the license, you may choose + any version ever published by the Free Software Foundation. + + 9. 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 + + 10. 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. + + 11. 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 humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. + Copyright (C) 19YY 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 1, 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 a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + SIGNATURE OF TY COON, 1 April 1989 + Ty Coon, President of Vice + + That's all there is to it! + + +File: gperf.info, Node: Contributors, Next: Motivation, Prev: Copying, Up: Top + +Contributors to GNU `gperf' Utility +*********************************** + + * The GNU `gperf' perfect hash function generator utility was + originally written in GNU C++ by Douglas C. Schmidt. It is now + also available in a highly-portable "old-style" C version. The + general idea for the perfect hash function generator was inspired + by Keith Bostic's algorithm written in C, and distributed to + net.sources around 1984. The current program is a heavily + modified, enhanced, and extended implementation of Keith's basic + idea, created at the University of California, Irvine. Bugs, + patches, and suggestions should be reported to schmidt at + ics.uci.edu. + + * Special thanks is extended to Michael Tiemann and Doug Lea, for + providing a useful compiler, and for giving me a forum to exhibit + my creation. + + In addition, Adam de Boor and Nels Olson provided many tips and + insights that greatly helped improve the quality and functionality + of `gperf'. + + +File: gperf.info, Node: Motivation, Next: Search Structures, Prev: Contributors, Up: Top + +Introduction +************ + + `gperf' is a perfect hash function generator written in C++. It +transforms an *n* element user-specified keyword set *W* into a perfect +hash function *F*. *F* uniquely maps keywords in *W* onto the range +0..*k*, where *k* >= *n*. If *k = n* then *F* is a *minimal* perfect +hash function. `gperf' generates a 0..*k* element static lookup table +and a pair of C functions. These functions determine whether a given +character string *s* occurs in *W*, using at most one probe into the +lookup table. + + `gperf' currently generates the reserved keyword recognizer for +lexical analyzers in several production and research compilers and +language processing tools, including GNU C, GNU C++, GNU Pascal, GNU +Modula 3, and GNU indent. Complete C++ source code for `gperf' is +available via anonymous ftp from ics.uci.edu. `gperf' also is +distributed along with the GNU libg++ library. A highly portable, +functionally equivalent K&R C version of `gperf' is archived in +comp.sources.unix, volume 20. Finally, a paper describing `gperf''s +design and implementation in greater detail is available in the Second +USENIX C++ Conference proceedings. + + +File: gperf.info, Node: Search Structures, Next: Description, Prev: Motivation, Up: Top + +Static search structures and GNU `gperf' +**************************************** + + A "static search structure" is an Abstract Data Type with certain +fundamental operations, *e.g.*, *initialize*, *insert*, and *retrieve*. +Conceptually, all insertions occur before any retrievals. In +practice, `gperf' generates a `static' array containing search set +keywords and any associated attributes specified by the user. Thus, +there is essentially no execution-time cost for the insertions. It is +a useful data structure for representing *static search sets*. Static +search sets occur frequently in software system applications. Typical +static search sets include compiler reserved words, assembler +instruction opcodes, and built-in shell interpreter commands. Search +set members, called "keywords", are inserted into the structure only +once, usually during program initialization, and are not generally +modified at run-time. + + Numerous static search structure implementations exist, *e.g.*, +arrays, linked lists, binary search trees, digital search tries, and +hash tables. Different approaches offer trade-offs between space +utilization and search time efficiency. For example, an *n* element +sorted array is space efficient, though the average-case time +complexity for retrieval operations using binary search is proportional +to log *n*. Conversely, hash table implementations often locate a +table entry in constant time, but typically impose additional memory +overhead and exhibit poor worst case performance. + + *Minimal perfect hash functions* provide an optimal solution for a +particular class of static search sets. A minimal perfect hash +function is defined by two properties: + + * It allows keyword recognition in a static search set using at most + *one* probe into the hash table. This represents the "perfect" + property. + + * The actual memory allocated to store the keywords is precisely + large enough for the keyword set, and *no larger*. This is the + "minimal" property. + + For most applications it is far easier to generate *perfect* hash +functions than *minimal perfect* hash functions. Moreover, non-minimal +perfect hash functions frequently execute faster than minimal ones in +practice. This phenomena occurs since searching a sparse keyword table +increases the probability of locating a "null" entry, thereby reducing +string comparisons. `gperf''s default behavior generates +*near-minimal* perfect hash functions for keyword sets. However, +`gperf' provides many options that permit user control over the degree +of minimality and perfection. + + Static search sets often exhibit relative stability over time. For +example, Ada's 63 reserved words have remained constant for nearly a +decade. It is therefore frequently worthwhile to expend concerted +effort building an optimal search structure *once*, if it subsequently +receives heavy use multiple times. `gperf' removes the drudgery +associated with constructing time- and space-efficient search +structures by hand. It has proven a useful and practical tool for +serious programming projects. Output from `gperf' is currently used in +several production and research compilers, including GNU C, GNU C++, +GNU Pascal, and GNU Modula 3. The latter two compilers are not yet +part of the official GNU distribution. Each compiler utilizes `gperf' +to automatically generate static search structures that efficiently +identify their respective reserved keywords. + + +File: gperf.info, Node: Description, Next: Options, Prev: Search Structures, Up: Top + +High-Level Description of GNU `gperf' +************************************* + +* Menu: + +* Input Format:: Input Format to `gperf' +* Output Format:: Output Format for Generated C Code with `gperf' + + The perfect hash function generator `gperf' reads a set of +"keywords" from a "keyfile" (or from the standard input by default). +It attempts to derive a perfect hashing function that recognizes a +member of the "static keyword set" with at most a single probe into the +lookup table. If `gperf' succeeds in generating such a function it +produces a pair of C source code routines that perform hashing and +table lookup recognition. All generated C code is directed to the +standard output. Command-line options described below allow you to +modify the input and output format to `gperf'. + + By default, `gperf' attempts to produce time-efficient code, with +less emphasis on efficient space utilization. However, several options +exist that permit trading-off execution time for storage space and vice +versa. In particular, expanding the generated table size produces a +sparse search structure, generally yielding faster searches. +Conversely, you can direct `gperf' to utilize a C `switch' statement +scheme that minimizes data space storage size. Furthermore, using a C +`switch' may actually speed up the keyword retrieval time somewhat. +Actual results depend on your C compiler, of course. + + In general, `gperf' assigns values to the characters it is using for +hashing until some set of values gives each keyword a unique value. A +helpful heuristic is that the larger the hash value range, the easier +it is for `gperf' to find and generate a perfect hash function. +Experimentation is the key to getting the most from `gperf'. + + +File: gperf.info, Node: Input Format, Next: Output Format, Prev: Description, Up: Description + +Input Format to `gperf' +======================= + + You can control the input keyfile format by varying certain +command-line arguments, in particular the `-t' option. The input's +appearance is similar to GNU utilities `flex' and `bison' (or UNIX +utilities `lex' and `yacc'). Here's an outline of the general format: + + declarations + %% + keywords + %% + functions + + *Unlike* `flex' or `bison', all sections of `gperf''s input are +optional. The following sections describe the input format for each +section. + +* Menu: + +* Declarations:: `struct' Declarations and C Code Inclusion. +* Keywords:: Format for Keyword Entries. +* Functions:: Including Additional C Functions. + + +File: gperf.info, Node: Declarations, Next: Keywords, Prev: Input Format, Up: Input Format + +`struct' Declarations and C Code Inclusion +------------------------------------------ + + The keyword input file optionally contains a section for including +arbitrary C declarations and definitions, as well as provisions for +providing a user-supplied `struct'. If the `-t' option *is* enabled, +you *must* provide a C `struct' as the last component in the +declaration section from the keyfile file. The first field in this +struct must be a `char *' identifier called "name," although it is +possible to modify this field's name with the `-K' option described +below. + + Here is simple example, using months of the year and their +attributes as input: + + struct months { char *name; int number; int days; int leap_days; }; + %% + january, 1, 31, 31 + february, 2, 28, 29 + march, 3, 31, 31 + april, 4, 30, 30 + may, 5, 31, 31 + june, 6, 30, 30 + july, 7, 31, 31 + august, 8, 31, 31 + september, 9, 30, 30 + october, 10, 31, 31 + november, 11, 30, 30 + december, 12, 31, 31 + + Separating the `struct' declaration from the list of key words and +other fields are a pair of consecutive percent signs, `%%', appearing +left justified in the first column, as in the UNIX utility `lex'. + + Using a syntax similar to GNU utilities `flex' and `bison', it is +possible to directly include C source text and comments verbatim into +the generated output file. This is accomplished by enclosing the region +inside left-justified surrounding `%{', `%}' pairs. Here is an input +fragment based on the previous example that illustrates this feature: + + %{ + #include + /* This section of code is inserted directly into the output. */ + int return_month_days (struct months *months, int is_leap_year); + %} + struct months { char *name; int number; int days; int leap_days; }; + %% + january, 1, 31, 31 + february, 2, 28, 29 + march, 3, 31, 31 + ... + + It is possible to omit the declaration section entirely. In this +case the keyfile begins directly with the first keyword line, *e.g.*: + + january, 1, 31, 31 + february, 2, 28, 29 + march, 3, 31, 31 + april, 4, 30, 30 + ... + + +File: gperf.info, Node: Keywords, Next: Functions, Prev: Declarations, Up: Input Format + +Format for Keyword Entries +-------------------------- + + The second keyfile format section contains lines of keywords and any +associated attributes you might supply. A line beginning with `#' in +the first column is considered a comment. Everything following the `#' +is ignored, up to and including the following newline. + + The first field of each non-comment line is always the key itself. +It should be given as a simple name, *i.e.*, without surrounding string +quotation marks, and be left-justified flush against the first column. +In this context, a "field" is considered to extend up to, but not +include, the first blank, comma, or newline. Here is a simple example +taken from a partial list of C reserved words: + + # These are a few C reserved words, see the c.`gperf' file + # for a complete list of ANSI C reserved words. + unsigned + sizeof + switch + signed + if + default + for + while + return + + Note that unlike `flex' or `bison' the first `%%' marker may be +elided if the declaration section is empty. + + Additional fields may optionally follow the leading keyword. Fields +should be separated by commas, and terminate at the end of line. What +these fields mean is entirely up to you; they are used to initialize the +elements of the user-defined `struct' provided by you in the +declaration section. If the `-t' option is *not* enabled these fields +are simply ignored. All previous examples except the last one contain +keyword attributes. + + +File: gperf.info, Node: Functions, Prev: Keywords, Up: Input Format + +Including Additional C Functions +-------------------------------- + + The optional third section also corresponds closely with conventions +found in `flex' and `bison'. All text in this section, starting at the +final `%%' and extending to the end of the input file, is included +verbatim into the generated output file. Naturally, it is your +responsibility to ensure that the code contained in this section is +valid C. + + +File: gperf.info, Node: Output Format, Prev: Input Format, Up: Description + +Output Format for Generated C Code with `gperf' +=============================================== + + Several options control how the generated C code appears on the +standard output. Two C function are generated. They are called `hash' +and `in_word_set', although you may modify the name for `in_word_set' +with a command-line option. Both functions require two arguments, a +string, `char *' STR, and a length parameter, `int' LEN. Their default +function prototypes are as follows: + + static int hash (char *str, int len); + int in_word_set (char *str, int len); + + By default, the generated `hash' function returns an integer value +created by adding LEN to several user-specified STR key positions +indexed into an "associated values" table stored in a local static +array. The associated values table is constructed internally by +`gperf' and later output as a static local C array called HASH_TABLE; +its meaning and properties are described below. *Note +Implementation::. The relevant key positions are specified via the `-k' +option when running `gperf', as detailed in the *Options* section +below. *Note Options::. + + Two options, `-g' (assume you are compiling with GNU C and its +`inline' feature) and `-a' (assume ANSI C-style function prototypes), +alter the content of both the generated `hash' and `in_word_set' +routines. However, function `in_word_set' may be modified more +extensively, in response to your option settings. The options that +affect the `in_word_set' structure are: + + `-p' + Have function `in_word_set' return a pointer rather than a + boolean. + + `-t' + Make use of the user-defined `struct'. + + `-S TOTAL SWITCH STATEMENTS' + Generate 1 or more C `switch' statement rather than use a + large, (and potentially sparse) static array. Although the + exact time and space savings of this approach vary according + to your C compiler's degree of optimization, this method + often results in smaller and faster code. + + If the `-t', `-S', and `-p' options are omitted the default action +is to generate a `char *' array containing the keys, together with +additional null strings used for padding the array. By experimenting +with the various input and output options, and timing the resulting C +code, you can determine the best option choices for different keyword +set characteristics. + + +File: gperf.info, Node: Options, Next: Bugs, Prev: Description, Up: Top + +Options to the `gperf' Utility +****************************** + + There are *many* options to `gperf'. They were added to make the +program more convenient for use with real applications. "On-line" help +is readily available via the `-h' option. Other options include: + + `-a' + Generate ANSI Standard C code using function prototypes. The + default is to use "classic" K&R C function declaration syntax. + + `-c' + Generates C code that uses the `strncmp' function to perform + string comparisons. The default action is to use `strcmp'. + + `-C' + Makes the contents of all generated lookup tables constant, + *i.e.*, "readonly." Many compilers can generate more + efficient code for this by putting the tables in readonly + memory. + + `-d' + Enables the debugging option. This produces verbose + diagnostics to "standard error" when `gperf' is executing. + It is useful both for maintaining the program and for + determining whether a given set of options is actually + speeding up the search for a solution. Some useful + information is dumped at the end of the program when the `-d' + option is enabled. + + `-D' + Handle keywords whose key position sets hash to duplicate + values. Duplicate hash values occur for two reasons: + + * Since `gperf' does not backtrack it is possible for it + to process all your input keywords without finding a + unique mapping for each word. However, frequently only + a very small number of duplicates occur, and the + majority of keys still require one probe into the table. + + * Sometimes a set of keys may have the same names, but + possess different attributes. With the -D option + `gperf' treats all these keys as part of an equivalence + class and generates a perfect hash function with multiple + comparisons for duplicate keys. It is up to you to + completely disambiguate the keywords by modifying the + generated C code. However, `gperf' helps you out by + organizing the output. + + Option `-D' is extremely useful for certain large or highly + redundant keyword sets, *i.e.*, assembler instruction opcodes. + Using this option usually means that the generated hash + function is no longer perfect. On the other hand, it permits + `gperf' to work on keyword sets that it otherwise could not + handle. + + `-e KEYWORD DELIMITER LIST' + Allows the user to provide a string containing delimiters + used to separate keywords from their attributes. The default + is ",\n". This option is essential if you want to use + keywords that have embedded commas or newlines. One useful + trick is to use -e'TAB', where TAB is the literal tab + character. + + `-E' + Define constant values using an enum local to the lookup + function rather than with #defines. This also means that + different lookup functions can reside in the same file. + Thanks to James Clark (jjc at ai.mit.edu). + + `-f ITERATION AMOUNT' + Generate the perfect hash function "fast." This decreases + `gperf''s running time at the cost of minimizing generated + table-size. The iteration amount represents the number of + times to iterate when resolving a collision. `0' means + `iterate by the number of keywords. This option is probably + most useful when used in conjunction with options `-D' and/or + `-S' for *large* keyword sets. + + `-g' + Assume a GNU compiler, *e.g.*, `g++' or `gcc'. This makes + all generated routines use the "inline" keyword to remove the + cost of function calls. Note that `-g' does *not* imply + `-a', since other non-ANSI C compilers may have provisions + for a function `inline' feature. + + `-G' + Generate the static table of keywords as a static global + variable, rather than hiding it inside of the lookup function + (which is the default behavior). + + `-h' + Prints a short summary on the meaning of each program option. + Aborts further program execution. + + `-H HASH FUNCTION NAME' + Allows you to specify the name for the generated hash + function. Default name is `hash.' This option permits the + use of two hash tables in the same file. + + `-i INITIAL VALUE' + Provides an initial VALUE for the associate values array. + Default is 0. Increasing the initial value helps inflate the + final table size, possibly leading to more time efficient + keyword lookups. Note that this option is not particularly + useful when `-S' is used. Also, `-i' is overriden when the + `-r' option is used. + + `-j JUMP VALUE' + Affects the "jump value," *i.e.*, how far to advance the + associated character value upon collisions. JUMP VALUE is + rounded up to an odd number, the default is 5. If the JUMP + VALUE is 0 `gper f' jumps by random amounts. + + `-k KEYS' + Allows selection of the character key positions used in the + keywords' hash function. The allowable choices range between + 1-126, inclusive. The positions are separated by commas, + *e.g.*, `-k 9,4,13,14'; ranges may be used, *e.g.*, `-k 2-7'; + and positions may occur in any order. Furthermore, the + meta-character '*' causes the generated hash function to + consider *all* character positions in each key, whereas '$' + instructs the hash function to use the "final character" of a + key (this is the only way to use a character position greater + than 126, incidentally). + + For instance, the option `-k 1,2,4,6-10,'$'' generates a hash + function that considers positions 1,2,4,6,7,8,9,10, plus the + last character in each key (which may differ for each key, + obviously). Keys with length less than the indicated key + positions work properly, since selected key positions + exceeding the key length are simply not referenced in the + hash function. + + `-K KEY NAME' + By default, the program assumes the structure component + identifier for the keyword is "name." This option allows an + arbitrary choice of identifier for this component, although + it still must occur as the first field in your supplied + `struct'. + + `-l' + Compare key lengths before trying a string comparison. This + might cut down on the number of string comparisons made + during the lookup, since keys with different lengths are + never compared via `strcmp'. However, using `-l' might + greatly increase the size of the generated C code if the + lookup table range is large (which implies that the switch + option `-S' is not enabled), since the length table contains + as many elements as there are entries in the lookup table. + + `-L GENERATED LANGUAGE NAME' + Instructs `gperf' to generate code in the language specified + by the option's argument. Languages handled are currently + C++ and C. The default is C. + + `-n' + Instructs the generator not to include the length of a + keyword when computing its hash value. This may save a few + assembly instructions in the generated lookup table. + + `-N LOOKUP FUNCTION NAME' + Allows you to specify the name for the generated lookup + function. Default name is `in_word_set.' This option + permits completely automatic generation of perfect hash + functions, especially when multiple generated hash functions + are used in the same application. + + `-o' + Reorders the keywords by sorting the keywords so that + frequently occuring key position set components appear first. + A second reordering pass follows so that keys with "already + determined values" are placed towards the front of the + keylist. This may decrease the time required to generate a + perfect hash function for many keyword sets, and also produce + more minimal perfect hash functions. The reason for this is + that the reordering helps prune the search time by handling + inevitable collisions early in the search process. On the + other hand, if the number of keywords is *very* large using + `-o' may *increase* `gperf''s execution time, since + collisions will begin earlier and continue throughout the + remainder of keyword processing. See Cichelli's paper from + the January 1980 Communications of the ACM for details. + + `-p' + Changes the return value of the generated function + `in_word_set' from boolean (*i.e.*, 0 or 1), to either type + "pointer to user-defined struct," (if the `-t' option is + enabled), or simply to `char *', if `-t' is not enabled. + This option is most useful when the `-t' option (allowing + user-defined structs) is used. For example, it is possible + to automatically generate the GNU C reserved word lookup + routine with the options `-p' and `-t'. + + `-r' + Utilizes randomness to initialize the associated values + table. This frequently generates solutions faster than using + deterministic initialization (which starts all associated + values at 0). Furthermore, using the randomization option + generally increases the size of the table. If `gperf' has + difficultly with a certain keyword set try using `-r' or `-D'. + + `-s SIZE-MULTIPLE' + Affects the size of the generated hash table. The numeric + argument for this option indicates "how many times larger or + smaller" the maximum associated value range should be, in + relationship to the number of keys. If the SIZE-MULTIPLE is + negative the maximum associated value is calculated by + *dividing* it into the total number of keys. For example, a + value of 3 means "allow the maximum associated value to be + about 3 times larger than the number of input keys." + + Conversely, a value of -3 means "allow the maximum associated + value to be about 3 times smaller than the number of input + keys." Negative values are useful for limiting the overall + size of the generated hash table, though this usually + increases the number of duplicate hash values. + + If `generate switch' option `-S' is *not* enabled, the maximum + associated value influences the static array table size, and + a larger table should decrease the time required for an + unsuccessful search, at the expense of extra table space. + + The default value is 1, thus the default maximum associated + value about the same size as the number of keys (for + efficiency, the maximum associated value is always rounded up + to a power of 2). The actual table size may vary somewhat, + since this technique is essentially a heuristic. In + particular, setting this value too high slows down `gperf''s + runtime, since it must search through a much larger range of + values. Judicious use of the `-f' option helps alleviate this + overhead, however. + + `-S TOTAL SWITCH STATEMENTS' + Causes the generated C code to use a `switch' statement + scheme, rather than an array lookup table. This can lead to + a reduction in both time and space requirements for some + keyfiles. The argument to this option determines how many + `switch' statements are generated. A value of 1 generates 1 + `switch' containing all the elements, a value of 2 generates + 2 tables with 1/2 the elements in each `switch', etc. This + is useful since many C compilers cannot correctly generate + code for large `switch' statements. This option was inspired + in part by Keith Bostic's original C program. + + `-t' + Allows you to include a `struct' type declaration for + generated code. Any text before a pair of consecutive %% is + consider part of the type declaration. Key words and + additional fields may follow this, one group of fields per + line. A set of examples for generating perfect hash tables + and functions for Ada, C, and G++, Pascal, and Modula 2 and 3 + reserved words are distributed with this release. + + `-T' + Prevents the transfer of the type declaration to the output + file. Use this option if the type is already defined + elsewhere. + + `-v' + Prints out the current version number. + + `-Z CLASS NAME' + Allow user to specify name of generated C++ class. Default + name is `Perfect_Hash'. + + +File: gperf.info, Node: Bugs, Next: Projects, Prev: Options, Up: Top + +Known Bugs and Limitations with `gperf' +*************************************** + + The following are some limitations with the current release of +`gperf': + + * The `gperf' utility is tuned to execute quickly, and works quickly + for small to medium size data sets (around 1000 keywords). It is + extremely useful for maintaining perfect hash functions for + compiler keyword sets. Several recent enhancements now enable + `gperf' to work efficiently on much larger keyword sets (over + 15,000 keywords). When processing large keyword sets it helps + greatly to have over 8 megs of RAM. + + However, since `gperf' does not backtrack no guaranteed solution + occurs on every run. On the other hand, it is usually easy to + obtain a solution by varying the option parameters. In + particular, try the `-r' option, and also try changing the default + arguments to the `-s' and `-j' options. To *guarantee* a + solution, use the `-D' and `-S' options, although the final + results are not likely to be a *perfect* hash function anymore! + Finally, use the `-f' option if you want `gperf' to generate the + perfect hash function *fast*, with less emphasis on making it + minimal. + + * The size of the generate static keyword array can get *extremely* + large if the input keyword file is large or if the keywords are + quite similar. This tends to slow down the compilation of the + generated C code, and *greatly* inflates the object code size. If + this situation occurs, consider using the `-S' option to reduce + data size, potentially increasing keyword recognition time a + negligible amount. Since many C compilers cannot correctly + generated code for large switch statements it is important to + qualify the -S option with an appropriate numerical argument that + controls the number of switch statements generated. + + * The maximum number of key positions selected for a given key has an + arbitrary limit of 126. This restriction should be removed, and if + anyone considers this a problem write me and let me know so I can + remove the constraint. + + * The C++ source code only compiles correctly with GNU G++, version + 1.36 (and hopefully later versions). Porting to AT&T cfront would + be tedious, but possible (and desirable). There is also a K&R C + version available now. This should compile without change on most + BSD systems, but may require a bit of work to run on SYSV, since + `gperf' uses ALLOCA in several places. Send mail to schmidt at + ics.uci.edu for information. + + +File: gperf.info, Node: Projects, Next: Implementation, Prev: Bugs, Up: Top + +Things Still Left to Do +*********************** + + It should be "relatively" easy to replace the current perfect hash +function algorithm with a more exhaustive approach; the perfect hash +module is essential independent from other program modules. Additional +worthwhile improvements include: + + * Make the algorithm more robust. At present, the program halts + with an error diagnostic if it can't find a direct solution and + the `-D' option is not enabled. A more comprehensive, albeit + computationally expensive, approach would employ backtracking or + enable alternative options and retry. It's not clear how helpful + this would be, in general, since most search sets are rather small + in practice. + + * Another useful extension involves modifying the program to generate + "minimal" perfect hash functions (under certain circumstances, the + current version can be rather extravagant in the generated table + size). Again, this is mostly of theoretical interest, since a + sparse table often produces faster lookups, and use of the `-S' + `switch' option can minimize the data size, at the expense of + slightly longer lookups (note that the gcc compiler generally + produces good code for `switch' statements, reducing the need for + more complex schemes). + + * In addition to improving the algorithm, it would also be useful to + generate a C++ class or Ada package as the code output, in + addition to the current C routines. + + +File: gperf.info, Node: Implementation, Next: Bibliography, Prev: Projects, Up: Top + +Implementation Details of GNU `gperf' +************************************* + + A paper describing the high-level description of the data structures +and algorithms used to implement `gperf' will soon be available. This +paper is useful not only from a maintenance and enhancement perspective, +but also because they demonstrate several clever and useful programming +techniques, *e.g.*, `Iteration Number' boolean arrays, double hashing, +a "safe" and efficient method for reading arbitrarily long input from a +file, and a provably optimal algorithm for simultaneously determining +both the minimum and maximum elements in a list. + + +File: gperf.info, Node: Bibliography, Prev: Implementation, Up: Top + +Bibliography +************ + + [1] Chang, C.C.: A Scheme for Constructing Ordered Minimal Perfect +Hashing Functions Information Sciences 39(1986), 187-195. + + [2] Cichelli, Richard J. Author's Response to "On Cichelli's Minimal +Perfec t Hash Functions Method" Communications of the ACM, 23, +12(December 1980), 729. + + [3] Cichelli, Richard J. Minimal Perfect Hash Functions Made Simple +Communications of the ACM, 23, 1(January 1980), 17-19. + + [4] Cook, C. R. and Oldehoeft, R.R. A Letter Oriented Minimal +Perfect Hashing Function SIGPLAN Notices, 17, 9(September 1982), 18-27. + + [5] Cormack, G. V. and Horspool, R. N. S. and Kaiserwerth, M. +Practical Perfect Hashing Computer Journal, 28, 1(January 1985), 54-58. + + [6] Jaeschke, G. Reciprocal Hashing: A Method for Generating Minimal +Perfect Hashing Functions Communications of the ACM, 24, 12(December +1981), 829-833. + + [7] Jaeschke, G. and Osterburg, G. On Cichelli's Minimal Perfect +Hash Functions Method Communications of the ACM, 23, 12(December 1980), +728-729. + + [8] Sager, Thomas J. A Polynomial Time Generator for Minimal Perfect +Hash Functions Communications of the ACM, 28, 5(December 1985), 523-532 + + [9] Schmidt, Douglas C. GPERF: A Perfect Hash Function Generator +Second USENIX C++ Conference Proceedings, April 1990. + + [10] Sebesta, R.W. and Taylor, M.A. Minimal Perfect Hash Functions +for Reserved Word Lists SIGPLAN Notices, 20, 12(September 1985), 47-53. + + [11] Sprugnoli, R. Perfect Hashing Functions: A Single Probe +Retrieving Method for Static Sets Communications of the ACM, 20 +11(November 1977), 841-850. + + [12] Stallman, Richard M. Using and Porting GNU CC Free Software +Foundation, 1988. + + [13] Stroustrup, Bjarne The C++ Programming Language. +Addison-Wesley, 1986. + + [14] Tiemann, Michael D. User's Guide to GNU C++ Free Software +Foundation, 1989. + + + +Tag Table: +Node: Top1262 +Node: Copying2500 +Node: Contributors15803 +Node: Motivation16903 +Node: Search Structures18170 +Node: Description21723 +Node: Input Format23543 +Node: Declarations24338 +Node: Keywords26645 +Node: Functions28236 +Node: Output Format28730 +Node: Options31200 +Node: Bugs44570 +Node: Projects47257 +Node: Implementation48834 +Node: Bibliography49553 + +End Tag Table diff --git a/gnu/lib/libg++/libg++/gperf/gperf.texi b/gnu/lib/libg++/libg++/gperf/gperf.texi new file mode 100644 index 00000000000..649d05f7ec6 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/gperf.texi @@ -0,0 +1,1184 @@ +\input texinfo @c -*-texinfo-*- + +@settitle User's Guide to @code{gperf} +@setfilename gperf.info + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Gperf: (gperf). Perfect Hash Function Generator. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@ifinfo +This file documents the features of the GNU Perfect Hash Function Generator + +Copyright (C) 1989 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 +section entitled ``GNU General Public License'' is 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 the section entitled ``GNU @code{gperf} General Public License'' an +d +this permission notice may be included in translations approved by the +Free Software Foundation instead of in the original English. +@end ifinfo + +@setchapternewpage odd + +@titlepage +@center @titlefont{User's Guide} +@sp 2 +@center @titlefont{for the} +@sp 2 +@center @titlefont{GNU GPERF Utility} +@sp 4 +@center Douglas C. Schmidt +@sp 3 +@center last updated 1 November 1989 +@sp 1 +@center for version 2.0 +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1989 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 also that the +section entitled ``GNU @code{gperf} General Public License'' is included exactl +y 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 the section entitled ``GNU @code{gperf} General Public License'' ma +y be +included in a translation approved by the author instead of in the original +English. +@end titlepage + +@ifinfo +@node Top, Copying, (dir), (dir) +@ichapter Introduction + +This manual documents the GNU @code{gperf} perfect hash function generator +utility, focusing on its features and how to use them, and how to report +bugs. + +@end ifinfo +@menu +* Copying:: GNU @code{gperf} General Public License says + how you can copy and share @code{gperf}. +* Contributors:: People who have contributed to @code{gperf}. +* Motivation:: Static search structures and GNU GPERF. +* Search Structures:: Static search structures and GNU @code{gperf} +* Description:: High-level discussion of how GPERF functions. +* Options:: A description of options to the program. +* Bugs:: Known bugs and limitations with GPERF. +* Projects:: Things still left to do. +* Implementation:: Implementation Details for GNU GPERF. +* Bibliography:: Material Referenced in this Report. + + --- The Detailed Node Listing --- + +High-Level Description of GNU @code{gperf} + +* Input Format:: Input Format to @code{gperf} +* Output Format:: Output Format for Generated C Code with @code{gperf} + +Input Format to @code{gperf} + +* Declarations:: @code{struct} Declarations and C Code Inclusion. +* Keywords:: Format for Keyword Entries. +* Functions:: Including Additional C Functions. +@end menu + +@node Copying, Contributors, Top, Top +@unnumbered GNU GENERAL PUBLIC LICENSE +@center Version 1, February 1989 + +@display +Copyright @copyright{} 1989 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. +@end display + +@unnumberedsec Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our 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. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, 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 a 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 tell them 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. + + The precise terms and conditions for copying, distribution and +modification follow. + +@iftex +@unnumberedsec TERMS AND CONDITIONS +@end iftex +@ifinfo +@center TERMS AND CONDITIONS +@end ifinfo + +@enumerate +@item +This License Agreement 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 work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as ``you''. + +@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 +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + +@item +You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + +@itemize @bullet +@item +cause the modified files to carry prominent notices stating that +you changed the files and the date of any change; and + +@item +cause the whole of any work that you distribute or publish, that +in whole or in part contains the Program or any part thereof, either +with or without modifications, to be licensed at no charge to all +third parties under the terms of this General Public License (except +that you may choose to grant warranty protection to some or all +third parties, at your option). + +@item +If the modified program normally reads commands interactively when +run, you must cause it, when started running for such interactive use +in the simplest and most usual 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 General +Public License. + +@item +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. +@end itemize + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + +@item +You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + +@itemize @bullet +@item +accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of +Paragraphs 1 and 2 above; or, + +@item +accompany it with a written offer, valid for at least three +years, to give any third party free (except for a nominal charge +for the cost of distribution) a complete machine-readable copy of the +corresponding source code, to be distributed under the terms of +Paragraphs 1 and 2 above; or, + +@item +accompany it with the information you received as to where the +corresponding source code may be obtained. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form alone.) +@end itemize + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + +@item +You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + +@item +By copying, distributing or modifying 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. + +@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. + +@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 the 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 +the 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 +@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 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 humanity, 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 a brief 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 1, 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 `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 a sample; alter the names: + +@example +Yoyodyne, Inc., hereby disclaims all copyright interest in the +program `Gnomovision' (a program to direct compilers to make passes +at assemblers) written by James Hacker. + +@var{signature of Ty Coon}, 1 April 1989 +Ty Coon, President of Vice +@end example + +That's all there is to it! + +@node Contributors, Motivation, Copying, Top +@unnumbered Contributors to GNU @code{gperf} Utility + +@itemize @bullet +@item +The GNU @code{gperf} perfect hash function generator utility was +originally written in GNU C++ by Douglas C. Schmidt. It is now also +available in a highly-portable ``old-style'' C version. The general +idea for the perfect hash function generator was inspired by Keith +Bostic's algorithm written in C, and distributed to net.sources around +1984. The current program is a heavily modified, enhanced, and extended +implementation of Keith's basic idea, created at the University of +California, Irvine. Bugs, patches, and suggestions should be reported +to schmidt at ics.uci.edu. + +@item +Special thanks is extended to Michael Tiemann and Doug Lea, for +providing a useful compiler, and for giving me a forum to exhibit my +creation. + +In addition, Adam de Boor and Nels Olson provided many tips and insights +that greatly helped improve the quality and functionality of @code{gperf}. +@end itemize + +@node Motivation, Search Structures, Contributors, Top +@chapter Introduction + +@code{gperf} is a perfect hash function generator written in C++. It +transforms an @emph{n} element user-specified keyword set @emph{W} into +a perfect hash function @emph{F}. @emph{F} uniquely maps keywords in +@emph{W} onto the range 0..@emph{k}, where @emph{k} >= @emph{n}. If +@emph{k = n} then @emph{F} is a @emph{minimal} perfect hash function. +@code{gperf} generates a 0..@emph{k} element static lookup table and a +pair of C functions. These functions determine whether a given +character string @emph{s} occurs in @emph{W}, using at most one probe +into the lookup table. + +@code{gperf} currently generates the reserved keyword recognizer for +lexical analyzers in several production and research compilers and +language processing tools, including GNU C, GNU C++, GNU Pascal, GNU +Modula 3, and GNU indent. Complete C++ source code for @code{gperf} is +available via anonymous ftp from ics.uci.edu. @code{gperf} also is +distributed along with the GNU libg++ library. A highly portable, +functionally equivalent K&R C version of @code{gperf} is archived in +comp.sources.unix, volume 20. Finally, a paper describing +@code{gperf}'s design and implementation in greater detail is available +in the Second USENIX C++ Conference proceedings. + +@node Search Structures, Description, Motivation, Top +@chapter Static search structures and GNU @code{gperf} + +A @dfn{static search structure} is an Abstract Data Type with certain +fundamental operations, @emph{e.g.}, @emph{initialize}, @emph{insert}, +and @emph{retrieve}. Conceptually, all insertions occur before any +retrievals. In practice, @code{gperf} generates a @code{static} array +containing search set keywords and any associated attributes specified +by the user. Thus, there is essentially no execution-time cost for the +insertions. It is a useful data structure for representing @emph{static +search sets}. Static search sets occur frequently in software system +applications. Typical static search sets include compiler reserved +words, assembler instruction opcodes, and built-in shell interpreter +commands. Search set members, called @dfn{keywords}, are inserted into +the structure only once, usually during program initialization, and are +not generally modified at run-time. + +Numerous static search structure implementations exist, @emph{e.g.}, +arrays, linked lists, binary search trees, digital search tries, and +hash tables. Different approaches offer trade-offs between space +utilization and search time efficiency. For example, an @emph{n} element +sorted array is space efficient, though the average-case time +complexity for retrieval operations using binary search is +proportional to log @emph{n}. Conversely, hash table implementations +often locate a table entry in constant time, but typically impose +additional memory overhead and exhibit poor worst case performance. + + +@emph{Minimal perfect hash functions} provide an optimal solution for a +particular class of static search sets. A minimal perfect hash +function is defined by two properties: + +@itemize @bullet +@item +It allows keyword recognition in a static search set using at most +@emph{one} probe into the hash table. This represents the ``perfect'' +property. +@item +The actual memory allocated to store the keywords is precisely large +enough for the keyword set, and @emph{no larger}. This is the +``minimal'' property. +@end itemize + +For most applications it is far easier to generate @emph{perfect} hash +functions than @emph{minimal perfect} hash functions. Moreover, +non-minimal perfect hash functions frequently execute faster than +minimal ones in practice. This phenomena occurs since searching a +sparse keyword table increases the probability of locating a ``null'' +entry, thereby reducing string comparisons. @code{gperf}'s default +behavior generates @emph{near-minimal} perfect hash functions for +keyword sets. However, @code{gperf} provides many options that permit +user control over the degree of minimality and perfection. + +Static search sets often exhibit relative stability over time. For +example, Ada's 63 reserved words have remained constant for nearly a +decade. It is therefore frequently worthwhile to expend concerted +effort building an optimal search structure @emph{once}, if it +subsequently receives heavy use multiple times. @code{gperf} removes +the drudgery associated with constructing time- and space-efficient +search structures by hand. It has proven a useful and practical tool +for serious programming projects. Output from @code{gperf} is currently +used in several production and research compilers, including GNU C, GNU +C++, GNU Pascal, and GNU Modula 3. The latter two compilers are not yet +part of the official GNU distribution. Each compiler utilizes +@code{gperf} to automatically generate static search structures that +efficiently identify their respective reserved keywords. + +@node Description, Options, Search Structures, Top +@chapter High-Level Description of GNU @code{gperf} + +@menu +* Input Format:: Input Format to @code{gperf} +* Output Format:: Output Format for Generated C Code with @code{gperf} +@end menu + +The perfect hash function generator @code{gperf} reads a set of +``keywords'' from a @dfn{keyfile} (or from the standard input by +default). It attempts to derive a perfect hashing function that +recognizes a member of the @dfn{static keyword set} with at most a +single probe into the lookup table. If @code{gperf} succeeds in +generating such a function it produces a pair of C source code routines +that perform hashing and table lookup recognition. All generated C code +is directed to the standard output. Command-line options described +below allow you to modify the input and output format to @code{gperf}. + +By default, @code{gperf} attempts to produce time-efficient code, with +less emphasis on efficient space utilization. However, several options +exist that permit trading-off execution time for storage space and vice +versa. In particular, expanding the generated table size produces a +sparse search structure, generally yielding faster searches. +Conversely, you can direct @code{gperf} to utilize a C @code{switch} +statement scheme that minimizes data space storage size. Furthermore, +using a C @code{switch} may actually speed up the keyword retrieval time +somewhat. Actual results depend on your C compiler, of course. + +In general, @code{gperf} assigns values to the characters it is using +for hashing until some set of values gives each keyword a unique value. +A helpful heuristic is that the larger the hash value range, the easier +it is for @code{gperf} to find and generate a perfect hash function. +Experimentation is the key to getting the most from @code{gperf}. + +@node Input Format, Output Format, Description, Description +@section Input Format to @code{gperf} + +You can control the input keyfile format by varying certain command-line +arguments, in particular the @samp{-t} option. The input's appearance +is similar to GNU utilities @code{flex} and @code{bison} (or UNIX +utilities @code{lex} and @code{yacc}). Here's an outline of the general +format: + +@example +@group +declarations +%% +keywords +%% +functions +@end group +@end example + +@emph{Unlike} @code{flex} or @code{bison}, all sections of @code{gperf}'s input +are optional. The following sections describe the input format for each +section. + +@menu +* Declarations:: @code{struct} Declarations and C Code Inclusion. +* Keywords:: Format for Keyword Entries. +* Functions:: Including Additional C Functions. +@end menu + +@node Declarations, Keywords, Input Format, Input Format +@subsection @code{struct} Declarations and C Code Inclusion + +The keyword input file optionally contains a section for including +arbitrary C declarations and definitions, as well as provisions for +providing a user-supplied @code{struct}. If the @samp{-t} option +@emph{is} enabled, you @emph{must} provide a C @code{struct} as the last +component in the declaration section from the keyfile file. The first +field in this struct must be a @code{char *} identifier called ``name,'' +although it is possible to modify this field's name with the @samp{-K} +option described below. + +Here is simple example, using months of the year and their attributes as +input: + +@example +@group +struct months @{ char *name; int number; int days; int leap_days; @}; +%% +january, 1, 31, 31 +february, 2, 28, 29 +march, 3, 31, 31 +april, 4, 30, 30 +may, 5, 31, 31 +june, 6, 30, 30 +july, 7, 31, 31 +august, 8, 31, 31 +september, 9, 30, 30 +october, 10, 31, 31 +november, 11, 30, 30 +december, 12, 31, 31 +@end group +@end example + +Separating the @code{struct} declaration from the list of key words and +other fields are a pair of consecutive percent signs, @code{%%}, +appearing left justified in the first column, as in the UNIX utility +@code{lex}. + +Using a syntax similar to GNU utilities @code{flex} and @code{bison}, it +is possible to directly include C source text and comments verbatim into +the generated output file. This is accomplished by enclosing the region +inside left-justified surrounding @code{%@{}, @code{%@}} pairs. Here is +an input fragment based on the previous example that illustrates this +feature: + +@example +@group +%@{ +#include +/* This section of code is inserted directly into the output. */ +int return_month_days (struct months *months, int is_leap_year); +%@} +struct months @{ char *name; int number; int days; int leap_days; @}; +%% +january, 1, 31, 31 +february, 2, 28, 29 +march, 3, 31, 31 +... +@end group +@end example + +It is possible to omit the declaration section entirely. In this case +the keyfile begins directly with the first keyword line, @emph{e.g.}: + +@example +@group +january, 1, 31, 31 +february, 2, 28, 29 +march, 3, 31, 31 +april, 4, 30, 30 +... +@end group +@end example + +@node Keywords, Functions, Declarations, Input Format +@subsection Format for Keyword Entries + +The second keyfile format section contains lines of keywords and any +associated attributes you might supply. A line beginning with @samp{#} +in the first column is considered a comment. Everything following the +@samp{#} is ignored, up to and including the following newline. + +The first field of each non-comment line is always the key itself. It +should be given as a simple name, @emph{i.e.}, without surrounding +string quotation marks, and be left-justified flush against the first +column. In this context, a ``field'' is considered to extend up to, but +not include, the first blank, comma, or newline. Here is a simple +example taken from a partial list of C reserved words: + +@example +@group +# These are a few C reserved words, see the c.@code{gperf} file +# for a complete list of ANSI C reserved words. +unsigned +sizeof +switch +signed +if +default +for +while +return +@end group +@end example + +Note that unlike @code{flex} or @code{bison} the first @code{%%} marker +may be elided if the declaration section is empty. + +Additional fields may optionally follow the leading keyword. Fields +should be separated by commas, and terminate at the end of line. What +these fields mean is entirely up to you; they are used to initialize the +elements of the user-defined @code{struct} provided by you in the +declaration section. If the @samp{-t} option is @emph{not} enabled +these fields are simply ignored. All previous examples except the last +one contain keyword attributes. + +@node Functions, , Keywords, Input Format +@subsection Including Additional C Functions + +The optional third section also corresponds closely with conventions +found in @code{flex} and @code{bison}. All text in this section, +starting at the final @code{%%} and extending to the end of the input +file, is included verbatim into the generated output file. Naturally, +it is your responsibility to ensure that the code contained in this +section is valid C. + +@node Output Format, , Input Format, Description +@section Output Format for Generated C Code with @code{gperf} + +Several options control how the generated C code appears on the standard +output. Two C function are generated. They are called @code{hash} and +@code{in_word_set}, although you may modify the name for +@code{in_word_set} with a command-line option. Both functions require +two arguments, a string, @code{char *} @var{str}, and a length +parameter, @code{int} @var{len}. Their default function prototypes are +as follows: + +@example +@group +static int hash (char *str, int len); +int in_word_set (char *str, int len); +@end group +@end example + +By default, the generated @code{hash} function returns an integer value +created by adding @var{len} to several user-specified @var{str} key +positions indexed into an @dfn{associated values} table stored in a +local static array. The associated values table is constructed +internally by @code{gperf} and later output as a static local C array called +@var{hash_table}; its meaning and properties are described below. +@xref{Implementation}. The relevant key positions are specified via the +@samp{-k} option when running @code{gperf}, as detailed in the @emph{Options} +section below. @xref{Options}. + +Two options, @samp{-g} (assume you are compiling with GNU C and its +@code{inline} feature) and @samp{-a} (assume ANSI C-style function +prototypes), alter the content of both the generated @code{hash} and +@code{in_word_set} routines. However, function @code{in_word_set} may +be modified more extensively, in response to your option settings. The +options that affect the @code{in_word_set} structure are: + +@itemize @bullet +@table @samp +@item -p +Have function @code{in_word_set} return a pointer rather than a boolean. + +@item -t +Make use of the user-defined @code{struct}. + +@item -S @var{total switch statements} +Generate 1 or more C @code{switch} statement rather than use a large, +(and potentially sparse) static array. Although the exact time and +space savings of this approach vary according to your C compiler's +degree of optimization, this method often results in smaller and faster +code. +@end table +@end itemize + +If the @samp{-t}, @samp{-S}, and @samp{-p} options are omitted the +default action is to generate a @code{char *} array containing the keys, +together with additional null strings used for padding the array. By +experimenting with the various input and output options, and timing the +resulting C code, you can determine the best option choices for +different keyword set characteristics. + +@node Options, Bugs, Description, Top +@chapter Options to the @code{gperf} Utility + +There are @emph{many} options to @code{gperf}. They were added to make +the program more convenient for use with real applications. ``On-line'' +help is readily available via the @samp{-h} option. Other options +include: + +@itemize @bullet +@table @samp +@item -a +Generate ANSI Standard C code using function prototypes. The default is +to use ``classic'' K&R C function declaration syntax. + +@item -c +Generates C code that uses the @code{strncmp} function to perform +string comparisons. The default action is to use @code{strcmp}. + +@item -C +Makes the contents of all generated lookup tables constant, @emph{i.e.}, +``readonly.'' Many compilers can generate more efficient code for this +by putting the tables in readonly memory. + +@item -d +Enables the debugging option. This produces verbose diagnostics to +``standard error'' when @code{gperf} is executing. It is useful both for +maintaining the program and for determining whether a given set of +options is actually speeding up the search for a solution. Some useful +information is dumped at the end of the program when the @samp{-d} +option is enabled. + +@item -D +Handle keywords whose key position sets hash to duplicate values. +Duplicate hash values occur for two reasons: + +@itemize @bullet +@item +Since @code{gperf} does not backtrack it is possible for it to process +all your input keywords without finding a unique mapping for each word. +However, frequently only a very small number of duplicates occur, and +the majority of keys still require one probe into the table. +@item +Sometimes a set of keys may have the same names, but possess different +attributes. With the -D option @code{gperf} treats all these keys as part of +an equivalence class and generates a perfect hash function with multiple +comparisons for duplicate keys. It is up to you to completely +disambiguate the keywords by modifying the generated C code. However, +@code{gperf} helps you out by organizing the output. +@end itemize + +Option @samp{-D} is extremely useful for certain large or highly +redundant keyword sets, @emph{i.e.}, assembler instruction opcodes. +Using this option usually means that the generated hash function is no +longer perfect. On the other hand, it permits @code{gperf} to work on +keyword sets that it otherwise could not handle. + +@item -e @var{keyword delimiter list} +Allows the user to provide a string containing delimiters used to +separate keywords from their attributes. The default is ",\n". This +option is essential if you want to use keywords that have embedded +commas or newlines. One useful trick is to use -e'TAB', where TAB is +the literal tab character. + +@item -E +Define constant values using an enum local to the lookup function rather +than with #defines. This also means that different lookup functions can +reside in the same file. Thanks to James Clark (jjc at ai.mit.edu). + +@item -f @var{iteration amount} +Generate the perfect hash function ``fast.'' This decreases @code{gperf}'s +running time at the cost of minimizing generated table-size. The +iteration amount represents the number of times to iterate when +resolving a collision. `0' means `iterate by the number of keywords. +This option is probably most useful when used in conjunction with options +@samp{-D} and/or @samp{-S} for @emph{large} keyword sets. + +@item -g +Assume a GNU compiler, @emph{e.g.}, @code{g++} or @code{gcc}. This +makes all generated routines use the ``inline'' keyword to remove the +cost of function calls. Note that @samp{-g} does @emph{not} imply +@samp{-a}, since other non-ANSI C compilers may have provisions for a +function @code{inline} feature. + +@item -G +Generate the static table of keywords as a static global variable, +rather than hiding it inside of the lookup function (which is the +default behavior). + +@item -h +Prints a short summary on the meaning of each program option. Aborts +further program execution. + +@item -H @var{hash function name} +Allows you to specify the name for the generated hash function. Default +name is `hash.' This option permits the use of two hash tables in the +same file. + +@item -i @var{initial value} +Provides an initial @var{value} for the associate values array. Default +is 0. Increasing the initial value helps inflate the final table size, +possibly leading to more time efficient keyword lookups. Note that this +option is not particularly useful when @samp{-S} is used. Also, +@samp{-i} is overriden when the @samp{-r} option is used. + +@item -j @var{jump value} +Affects the ``jump value,'' @emph{i.e.}, how far to advance the +associated character value upon collisions. @var{Jump value} is rounded +up to an odd number, the default is 5. If the @var{jump value} is 0 @code{gper +f} +jumps by random amounts. + +@item -k @var{keys} +Allows selection of the character key positions used in the keywords' +hash function. The allowable choices range between 1-126, inclusive. +The positions are separated by commas, @emph{e.g.}, @samp{-k 9,4,13,14}; +ranges may be used, @emph{e.g.}, @samp{-k 2-7}; and positions may occur +in any order. Furthermore, the meta-character '*' causes the generated +hash function to consider @strong{all} character positions in each key, +whereas '$' instructs the hash function to use the ``final character'' +of a key (this is the only way to use a character position greater than +126, incidentally). + +For instance, the option @samp{-k 1,2,4,6-10,'$'} generates a hash +function that considers positions 1,2,4,6,7,8,9,10, plus the last +character in each key (which may differ for each key, obviously). Keys +with length less than the indicated key positions work properly, since +selected key positions exceeding the key length are simply not +referenced in the hash function. + +@item -K @var{key name} +By default, the program assumes the structure component identifier for +the keyword is ``name.'' This option allows an arbitrary choice of +identifier for this component, although it still must occur as the first +field in your supplied @code{struct}. + +@item -l +Compare key lengths before trying a string comparison. This might cut +down on the number of string comparisons made during the lookup, since +keys with different lengths are never compared via @code{strcmp}. +However, using @samp{-l} might greatly increase the size of the +generated C code if the lookup table range is large (which implies that +the switch option @samp{-S} is not enabled), since the length table +contains as many elements as there are entries in the lookup table. + +@item -L @var{generated language name} +Instructs @code{gperf} to generate code in the language specified by the +option's argument. Languages handled are currently C++ and C. The +default is C. + +@item -n +Instructs the generator not to include the length of a keyword when +computing its hash value. This may save a few assembly instructions in +the generated lookup table. + +@item -N @var{lookup function name} +Allows you to specify the name for the generated lookup function. +Default name is `in_word_set.' This option permits completely automatic +generation of perfect hash functions, especially when multiple generated +hash functions are used in the same application. + +@item -o +Reorders the keywords by sorting the keywords so that frequently +occuring key position set components appear first. A second reordering +pass follows so that keys with ``already determined values'' are placed +towards the front of the keylist. This may decrease the time required +to generate a perfect hash function for many keyword sets, and also +produce more minimal perfect hash functions. The reason for this is +that the reordering helps prune the search time by handling inevitable +collisions early in the search process. On the other hand, if the +number of keywords is @emph{very} large using @samp{-o} may +@emph{increase} @code{gperf}'s execution time, since collisions will begin +earlier and continue throughout the remainder of keyword processing. +See Cichelli's paper from the January 1980 Communications of the ACM for +details. + +@item -p +Changes the return value of the generated function @code{in_word_set} +from boolean (@emph{i.e.}, 0 or 1), to either type ``pointer to +user-defined struct,'' (if the @samp{-t} option is enabled), or simply +to @code{char *}, if @samp{-t} is not enabled. This option is most +useful when the @samp{-t} option (allowing user-defined structs) is +used. For example, it is possible to automatically generate the GNU C +reserved word lookup routine with the options @samp{-p} and @samp{-t}. + +@item -r +Utilizes randomness to initialize the associated values table. This +frequently generates solutions faster than using deterministic +initialization (which starts all associated values at 0). Furthermore, +using the randomization option generally increases the size of the +table. If @code{gperf} has difficultly with a certain keyword set try using +@samp{-r} or @samp{-D}. + +@item -s @var{size-multiple} +Affects the size of the generated hash table. The numeric argument for +this option indicates ``how many times larger or smaller'' the maximum +associated value range should be, in relationship to the number of keys. +If the @var{size-multiple} is negative the maximum associated value is +calculated by @emph{dividing} it into the total number of keys. For +example, a value of 3 means ``allow the maximum associated value to be +about 3 times larger than the number of input keys.'' + +Conversely, a value of -3 means ``allow the maximum associated value to +be about 3 times smaller than the number of input keys.'' Negative +values are useful for limiting the overall size of the generated hash +table, though this usually increases the number of duplicate hash +values. + +If `generate switch' option @samp{-S} is @emph{not} enabled, the maximum +associated value influences the static array table size, and a larger +table should decrease the time required for an unsuccessful search, at +the expense of extra table space. + +The default value is 1, thus the default maximum associated value about +the same size as the number of keys (for efficiency, the maximum +associated value is always rounded up to a power of 2). The actual +table size may vary somewhat, since this technique is essentially a +heuristic. In particular, setting this value too high slows down +@code{gperf}'s runtime, since it must search through a much larger range +of values. Judicious use of the @samp{-f} option helps alleviate this +overhead, however. + +@item -S @var{total switch statements} +Causes the generated C code to use a @code{switch} statement scheme, +rather than an array lookup table. This can lead to a reduction in both +time and space requirements for some keyfiles. The argument to this +option determines how many @code{switch} statements are generated. A +value of 1 generates 1 @code{switch} containing all the elements, a +value of 2 generates 2 tables with 1/2 the elements in each +@code{switch}, etc. This is useful since many C compilers cannot +correctly generate code for large @code{switch} statements. This option +was inspired in part by Keith Bostic's original C program. + +@item -t +Allows you to include a @code{struct} type declaration for generated +code. Any text before a pair of consecutive %% is consider part of the +type declaration. Key words and additional fields may follow this, one +group of fields per line. A set of examples for generating perfect hash +tables and functions for Ada, C, and G++, Pascal, and Modula 2 and 3 +reserved words are distributed with this release. + +@item -T +Prevents the transfer of the type declaration to the output file. Use +this option if the type is already defined elsewhere. + +@item -v +Prints out the current version number. + +@item -Z @var{class name} +Allow user to specify name of generated C++ class. Default name is +@code{Perfect_Hash}. +@end table +@end itemize + +@node Bugs, Projects, Options, Top +@chapter Known Bugs and Limitations with @code{gperf} + +The following are some limitations with the current release of +@code{gperf}: + +@itemize @bullet +@item +The @code{gperf} utility is tuned to execute quickly, and works quickly +for small to medium size data sets (around 1000 keywords). It is +extremely useful for maintaining perfect hash functions for compiler +keyword sets. Several recent enhancements now enable @code{gperf} to +work efficiently on much larger keyword sets (over 15,000 keywords). +When processing large keyword sets it helps greatly to have over 8 megs +of RAM. + +However, since @code{gperf} does not backtrack no guaranteed solution +occurs on every run. On the other hand, it is usually easy to obtain a +solution by varying the option parameters. In particular, try the +@samp{-r} option, and also try changing the default arguments to the +@samp{-s} and @samp{-j} options. To @emph{guarantee} a solution, use +the @samp{-D} and @samp{-S} options, although the final results are not +likely to be a @emph{perfect} hash function anymore! Finally, use the +@samp{-f} option if you want @code{gperf} to generate the perfect hash +function @emph{fast}, with less emphasis on making it minimal. + +@item +The size of the generate static keyword array can get @emph{extremely} +large if the input keyword file is large or if the keywords are quite +similar. This tends to slow down the compilation of the generated C +code, and @emph{greatly} inflates the object code size. If this +situation occurs, consider using the @samp{-S} option to reduce data +size, potentially increasing keyword recognition time a negligible +amount. Since many C compilers cannot correctly generated code for +large switch statements it is important to qualify the @var{-S} option +with an appropriate numerical argument that controls the number of +switch statements generated. + +@item +The maximum number of key positions selected for a given key has an +arbitrary limit of 126. This restriction should be removed, and if +anyone considers this a problem write me and let me know so I can remove +the constraint. + +@item +The C++ source code only compiles correctly with GNU G++, version 1.36 +(and hopefully later versions). Porting to AT&T cfront would be +tedious, but possible (and desirable). There is also a K&R C version +available now. This should compile without change on most BSD systems, +but may require a bit of work to run on SYSV, since @code{gperf} uses +@var{alloca} in several places. Send mail to schmidt at ics.uci.edu for +information. +@end itemize + +@node Projects, Implementation, Bugs, Top +@chapter Things Still Left to Do + +It should be ``relatively'' easy to replace the current perfect hash +function algorithm with a more exhaustive approach; the perfect hash +module is essential independent from other program modules. Additional +worthwhile improvements include: + +@itemize @bullet +@item +Make the algorithm more robust. At present, the program halts with an +error diagnostic if it can't find a direct solution and the @samp{-D} +option is not enabled. A more comprehensive, albeit computationally +expensive, approach would employ backtracking or enable alternative +options and retry. It's not clear how helpful this would be, in +general, since most search sets are rather small in practice. + +@item +Another useful extension involves modifying the program to generate +``minimal'' perfect hash functions (under certain circumstances, the +current version can be rather extravagant in the generated table size). +Again, this is mostly of theoretical interest, since a sparse table +often produces faster lookups, and use of the @samp{-S} @code{switch} +option can minimize the data size, at the expense of slightly longer +lookups (note that the gcc compiler generally produces good code for +@code{switch} statements, reducing the need for more complex schemes). + +@item +In addition to improving the algorithm, it would also be useful to +generate a C++ class or Ada package as the code output, in addition to +the current C routines. +@end itemize + +@node Implementation, Bibliography, Projects, Top +@chapter Implementation Details of GNU @code{gperf} + +A paper describing the high-level description of the data structures and +algorithms used to implement @code{gperf} will soon be available. This +paper is useful not only from a maintenance and enhancement perspective, +but also because they demonstrate several clever and useful programming +techniques, @emph{e.g.}, `Iteration Number' boolean arrays, double +hashing, a ``safe'' and efficient method for reading arbitrarily long +input from a file, and a provably optimal algorithm for simultaneously +determining both the minimum and maximum elements in a list. + +@page + +@node Bibliography, , Implementation, Top +@chapter Bibliography + +[1] Chang, C.C.: @i{A Scheme for Constructing Ordered Minimal Perfect +Hashing Functions} Information Sciences 39(1986), 187-195. + +[2] Cichelli, Richard J. @i{Author's Response to ``On Cichelli's Minimal Perfec +t Hash +Functions Method''} Communications of the ACM, 23, 12(December 1980), 729. + +[3] Cichelli, Richard J. @i{Minimal Perfect Hash Functions Made Simple} +Communications of the ACM, 23, 1(January 1980), 17-19. + +[4] Cook, C. R. and Oldehoeft, R.R. @i{A Letter Oriented Minimal +Perfect Hashing Function} SIGPLAN Notices, 17, 9(September 1982), 18-27. + +[5] Cormack, G. V. and Horspool, R. N. S. and Kaiserwerth, M. +@i{Practical Perfect Hashing} Computer Journal, 28, 1(January 1985), 54-58. + +[6] Jaeschke, G. @i{Reciprocal Hashing: A Method for Generating Minimal +Perfect Hashing Functions} Communications of the ACM, 24, 12(December +1981), 829-833. + +[7] Jaeschke, G. and Osterburg, G. @i{On Cichelli's Minimal Perfect +Hash Functions Method} Communications of the ACM, 23, 12(December 1980), +728-729. + +[8] Sager, Thomas J. @i{A Polynomial Time Generator for Minimal Perfect +Hash Functions} Communications of the ACM, 28, 5(December 1985), 523-532 + +[9] Schmidt, Douglas C. @i{GPERF: A Perfect Hash Function Generator} +Second USENIX C++ Conference Proceedings, April 1990. + +[10] Sebesta, R.W. and Taylor, M.A. @i{Minimal Perfect Hash Functions +for Reserved Word Lists} SIGPLAN Notices, 20, 12(September 1985), 47-53. + +[11] Sprugnoli, R. @i{Perfect Hashing Functions: A Single Probe +Retrieving Method for Static Sets} Communications of the ACM, 20 +11(November 1977), 841-850. + +[12] Stallman, Richard M. @i{Using and Porting GNU CC} Free Software Foundation, +1988. + +[13] Stroustrup, Bjarne @i{The C++ Programming Language.} Addison-Wesley, 1986. + +[14] Tiemann, Michael D. @i{User's Guide to GNU C++} Free Software +Foundation, 1989. + +@contents +@bye diff --git a/gnu/lib/libg++/libg++/gperf/src/Makefile.in b/gnu/lib/libg++/libg++/gperf/src/Makefile.in new file mode 100644 index 00000000000..d0cfe33d18b --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/Makefile.in @@ -0,0 +1,35 @@ +# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc. +# written by Douglas C. Schmidt (schmidt@ics.uci.edu) +# +# This file is part of GNU GPERF. +# +# GNU GPERF is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GNU GPERF is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +OBJECTS = new.o options.o iterator.o main.o gen-perf.o key-list.o list-node.o\ + hash-table.o bool-array.o read-line.o std-err.o version.o + +TARGETPROG = gperf + +$(TARGETPROG): $(OBJECTS) + $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS) + +.PHONY: install +install: $(TARGETPROG) + $(INSTALL_PROGRAM) $(TARGETPROG) $(bindir)/$(TARGETPROG) diff --git a/gnu/lib/libg++/libg++/gperf/src/bool-array.cc b/gnu/lib/libg++/libg++/gperf/src/bool-array.cc new file mode 100644 index 00000000000..b7d3601e096 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/bool-array.cc @@ -0,0 +1,99 @@ +/* Fast lookup table abstraction implemented as an Iteration Number Array + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include "options.h" +#include "bool-array.h" + +STORAGE_TYPE * Bool_Array::storage_array; +STORAGE_TYPE Bool_Array::iteration_number; +int Bool_Array::size; + +/* Prints out debugging diagnostics. */ + +Bool_Array::~Bool_Array (void) +{ + T (Trace t ("Bool_Array::~Bool_Array");) + if (option[DEBUG]) + fprintf (stderr, "\ndumping boolean array information\n" + "size = %d\niteration number = %d\nend of array dump\n", + size, iteration_number); +} + +#ifndef __OPTIMIZE__ + +Bool_Array::Bool_Array (void) +{ + T (Trace t ("Bool_Array::Bool_Array");) + storage_array = 0; + iteration_number = size = 0; +} + +void +Bool_Array::init (STORAGE_TYPE *buffer, STORAGE_TYPE s) +{ + T (Trace t ("Bool_Array::init");) + size = s; + iteration_number = 1; + storage_array = buffer; + memset (storage_array, 0, s * sizeof *storage_array); + if (option[DEBUG]) + fprintf (stderr, "\nbool array size = %d, total bytes = %d\n", + size, size * sizeof *storage_array); +} + +int +Bool_Array::find (int index) +{ + T (Trace t ("Bool_Array::find");) + if (storage_array[index] == iteration_number) + return 1; + else + { + storage_array[index] = iteration_number; + return 0; + } +} + +void +Bool_Array::reset (void) +{ + T (Trace t ("Bool_Array::reset");) + /* If we wrap around it's time to zero things out again! However, this only + occurs once about every 2^31 or 2^15 iterations, so it should probably + never happen! */ + + if (++iteration_number == 0) + { + if (option[DEBUG]) + { + fprintf (stderr, "(re-initializing bool_array)..."); + fflush (stderr); + } + iteration_number = 1; + memset (storage_array, 0, size * sizeof *storage_array); + if (option[DEBUG]) + { + fprintf (stderr, "done\n"); + fflush (stderr); + } + } +} +#endif /* not defined __OPTIMIZE__ */ diff --git a/gnu/lib/libg++/libg++/gperf/src/bool-array.h b/gnu/lib/libg++/libg++/gperf/src/bool-array.h new file mode 100644 index 00000000000..3ac36cd974a --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/bool-array.h @@ -0,0 +1,114 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Simple lookup table abstraction implemented as an Iteration Number Array. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ + +/* Define and implement a simple boolean array abstraction, + uses an Iteration Numbering implementation to save on initialization time. */ + +#ifndef bool_array_h +#define bool_array_h 1 + +#include +#include "trace.h" + +#ifdef LO_CAL +/* If we are on a memory diet then we'll only make these use a limited + amount of storage space. */ +typedef unsigned short STORAGE_TYPE; +#else +typedef int STORAGE_TYPE; +#endif + +class Bool_Array +{ +private: + static STORAGE_TYPE *storage_array; /* Initialization of the index space. */ + static STORAGE_TYPE iteration_number; /* Keep track of the current iteration. */ + static int size; /* Keep track of array size. */ + +public: + Bool_Array (void); + ~Bool_Array (void); + static void init (STORAGE_TYPE *buffer, STORAGE_TYPE s); + static int find (int hash_value); + static void reset (void); +}; + +#ifdef __OPTIMIZE__ /* efficiency hack! */ + +inline +Bool_Array::Bool_Array (void) +{ + T (Trace t ("Bool_Array::Bool_Array");) + storage_array = 0; + iteration_number = size = 0; +} + +inline void +Bool_Array::init (STORAGE_TYPE *buffer, STORAGE_TYPE s) +{ + T (Trace t ("Bool_Array::init");) + size = s; + iteration_number = 1; + storage_array = buffer; + memset (storage_array, 0, s * sizeof *storage_array); + if (option[DEBUG]) + fprintf (stderr, "\nbool array size = %d, total bytes = %d\n", + size, size * sizeof *storage_array); +} + +inline int +Bool_Array::find (int index) +{ + T (Trace t ("Bool_Array::find");) + if (storage_array[index] == iteration_number) + return 1; + else + { + storage_array[index] = iteration_number; + return 0; + } +} + +inline void +Bool_Array::reset (void) +{ + T (Trace t ("Bool_Array::reset");) + if (++iteration_number == 0) + { + if (option[DEBUG]) + { + fprintf (stderr, "(re-initializing bool_array)..."); + fflush (stderr); + } + iteration_number = 1; + memset (storage_array, 0, size * sizeof *storage_array); + if (option[DEBUG]) + { + fprintf (stderr, "done\n"); + fflush (stderr); + } + } +} +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/configure.in b/gnu/lib/libg++/libg++/gperf/src/configure.in new file mode 100644 index 00000000000..de5df58b9e7 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/configure.in @@ -0,0 +1,24 @@ +# 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. + +configdirs="" +srctrigger=gen-perf.cc +srcname="perfect hash function generator" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +TARGETPROG=gperf + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/gperf/src/depend b/gnu/lib/libg++/libg++/gperf/src/depend new file mode 100644 index 00000000000..feed30191a7 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/depend @@ -0,0 +1,76 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +bool-array.o : bool-array.cc \ + options.h \ + std-err.h \ + trace.h \ + bool-array.h +gen-perf.o : gen-perf.cc \ + options.h \ + std-err.h \ + trace.h \ + gen-perf.h \ + key-list.h \ + list-node.h \ + vectors.h \ + read-line.h \ + bool-array.h +hash-table.o : hash-table.cc \ + hash-table.h \ + list-node.h \ + std-err.h \ + vectors.h \ + options.h \ + trace.h +iterator.o : iterator.cc \ + $(srcdir)/../../$(IO_DIR)/stream.h \ + $(srcdir)/../../$(IO_DIR)/iostream.h \ + $(srcdir)/../../$(IO_DIR)/streambuf.h \ + iterator.h \ + trace.h +key-list.o : key-list.cc \ + options.h \ + std-err.h \ + trace.h \ + read-line.h \ + hash-table.h \ + list-node.h \ + vectors.h \ + key-list.h +list-node.o : list-node.cc \ + options.h \ + std-err.h \ + trace.h \ + list-node.h \ + vectors.h +main.o : main.cc \ + std-err.h \ + options.h \ + trace.h \ + gen-perf.h \ + key-list.h \ + list-node.h \ + vectors.h \ + read-line.h \ + bool-array.h +new.o : new.cc \ + std-err.h \ + trace.h +options.o : options.cc \ + options.h \ + std-err.h \ + trace.h \ + iterator.h +read-line.o : read-line.cc \ + std-err.h \ + read-line.h \ + trace.h +std-err.o : std-err.cc \ + std-err.h \ + trace.h +version.o : version.cc + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/gperf/src/gen-perf.cc b/gnu/lib/libg++/libg++/gperf/src/gen-perf.cc new file mode 100644 index 00000000000..f007922c188 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/gen-perf.cc @@ -0,0 +1,358 @@ +/* Provides high-level routines to manipulate the keywork list + structures the code generation output. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include +#include +#include +#include "options.h" +#include "gen-perf.h" +#include "trace.h" + +/* Current release version. */ +extern char *version_string; + +/* Efficiently returns the least power of two greater than or equal to X! */ +#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) + +#include <_G_config.h> + +int Vectors::occurrences[ALPHA_SIZE]; +int Vectors::asso_values[ALPHA_SIZE]; + +/* Reads input keys, possibly applies the reordering heuristic, sets the + maximum associated value size (rounded up to the nearest power of 2), + may initialize the associated values array, and determines the maximum + hash table size. Note: using the random numbers is often helpful, + though not as deterministic, of course! */ + +Gen_Perf::Gen_Perf (void) +{ + T (Trace t ("Gen_Perf::Gen_Perf");) + int asso_value_max; + int non_linked_length; + + Key_List::read_keys (); + if (option[ORDER]) + reorder (); + asso_value_max = option.get_asso_max (); + non_linked_length = Key_List::keyword_list_length (); + num_done = 1; + fewest_collisions = 0; + if (asso_value_max == 0) + asso_value_max = non_linked_length; + else if (asso_value_max > 0) + asso_value_max *= non_linked_length; + else /* if (asso_value_max < 0) */ + asso_value_max = non_linked_length / -asso_value_max; + option.set_asso_max (POW (asso_value_max)); + + if (option[RANDOM]) + { + srand (time (0)); + + for (int i = 0; i < ALPHA_SIZE; i++) + asso_values[i] = (rand () & asso_value_max - 1); + } + else + { + int asso_value = option.initial_value (); + + if (asso_value) /* Initialize array if user requests non-zero default. */ + for (int i = ALPHA_SIZE - 1; i >= 0; i--) + asso_values[i] = asso_value & option.get_asso_max () - 1; + } + max_hash_value = Key_List::max_key_length () + option.get_asso_max () * + option.get_max_keysig_size (); + + printf ("/* "); + if (option[C]) + printf ("C"); + else if (option[CPLUSPLUS]) + printf ("C++"); + printf (" code produced by gperf version %s */\n", version_string); + Options::print_options (); + + if (option[DEBUG]) + fprintf (stderr, "total non-linked keys = %d\nmaximum associated value is %d" + "\nmaximum size of generated hash table is %d\n", + non_linked_length, asso_value_max, max_hash_value); +} + +/* Merge two disjoint hash key multisets to form the ordered disjoint union of the sets. + (In a multiset, an element can occur multiple times). + Precondition: both set_1 and set_2 must be ordered. Returns the length + of the combined set. */ + +inline int +Gen_Perf::compute_disjoint_union (char *set_1, char *set_2, char *set_3) +{ + T (Trace t ("Gen_Perf::compute_disjoint_union");) + char *base = set_3; + + while (*set_1 && *set_2) + if (*set_1 == *set_2) + set_1++, set_2++; + else + { + *set_3 = *set_1 < *set_2 ? *set_1++ : *set_2++; + if (set_3 == base || *set_3 != *(set_3-1)) set_3++; + } + + while (*set_1) + { + *set_3 = *set_1++; + if (set_3 == base || *set_3 != *(set_3-1)) set_3++; + } + + while (*set_2) + { + *set_3 = *set_2++; + if (set_3 == base || *set_3 != *(set_3-1)) set_3++; + } + *set_3 = '\0'; + return set_3 - base; +} + +/* Sort the UNION_SET in increasing frequency of occurrence. + This speeds up later processing since we may assume the resulting + set (Set_3, in this case), is ordered. Uses insertion sort, since + the UNION_SET is typically short. */ + +inline void +Gen_Perf::sort_set (char *union_set, int len) +{ + T (Trace t ("Gen_Perf::sort_set");) + int i, j; + + for (i = 0, j = len - 1; i < j; i++) + { + char curr, tmp; + + for (curr = i + 1, tmp = union_set[curr]; + curr > 0 && occurrences[tmp] < occurrences[union_set[curr-1]]; + curr--) + union_set[curr] = union_set[curr - 1]; + + union_set[curr] = tmp; + } +} + +/* Generate a key set's hash value. */ + +inline int +Gen_Perf::hash (List_Node *key_node) +{ + T (Trace t ("Gen_Perf::hash");) + int sum = option[NOLENGTH] ? 0 : key_node->length; + + for (char *ptr = key_node->char_set; *ptr; ptr++) + sum += asso_values[*ptr]; + + return key_node->hash_value = sum; +} + +/* Find out how character value change affects successfully hashed items. + Returns FALSE if no other hash values are affected, else returns TRUE. + Note that because Option.Get_Asso_Max is a power of two we can guarantee + that all legal Asso_Values are visited without repetition since + Option.Get_Jump was forced to be an odd value! */ + +inline int +Gen_Perf::affects_prev (char c, List_Node *curr) +{ + T (Trace t ("Gen_Perf::affects_prev");) + int original_char = asso_values[c]; + int total_iterations = !option[FAST] + ? option.get_asso_max () : option.get_iterations () ? option.get_iterations () : keyword_list_length (); + + /* Try all legal associated values. */ + + for (int i = total_iterations - 1; i >= 0; i--) + { + int collisions = 0; + + asso_values[c] = asso_values[c] + (option.get_jump () ? option.get_jump () : rand ()) + & option.get_asso_max () - 1; + + /* Iteration Number array is a win, O(1) intialization time! */ + reset (); + + /* See how this asso_value change affects previous keywords. If + it does better than before we'll take it! */ + + for (List_Node *ptr = head; + !Bool_Array::find (hash (ptr)) || ++collisions < fewest_collisions; + ptr = ptr->next) + if (ptr == curr) + { + fewest_collisions = collisions; + if (option[DEBUG]) + fprintf (stderr, "- resolved after %d iterations", total_iterations - i); + return 0; + } + } + + /* Restore original values, no more tries. */ + asso_values[c] = original_char; + /* If we're this far it's time to try the next character.... */ + return 1; +} + +/* Change a character value, try least-used characters first. */ + +void +Gen_Perf::change (List_Node *prior, List_Node *curr) +{ + T (Trace t ("Gen_Perf::change");) + static char *union_set; + + if (!union_set) + union_set = new char [2 * option.get_max_keysig_size () + 1]; + + if (option[DEBUG]) + { + fprintf (stderr, "collision on keyword #%d, prior = \"%s\", curr = \"%s\" hash = %d\n", + num_done, prior->key, curr->key, curr->hash_value); + fflush (stderr); + } + sort_set (union_set, compute_disjoint_union (prior->char_set, curr->char_set, union_set)); + + /* Try changing some values, if change doesn't alter other values continue normal action. */ + fewest_collisions++; + + for (char *temp = union_set; *temp; temp++) + if (!affects_prev (*temp, curr)) + { + if (option[DEBUG]) + { + fprintf (stderr, " by changing asso_value['%c'] (char #%d) to %d\n", + *temp, temp - union_set + 1, asso_values[*temp]); + fflush (stderr); + } + return; /* Good, doesn't affect previous hash values, we'll take it. */ + } + + for (List_Node *ptr = head; ptr != curr; ptr = ptr->next) + hash (ptr); + + hash (curr); + + if (option[DEBUG]) + { + fprintf (stderr, "** collision not resolved after %d iterations, %d duplicates remain, continuing...\n", + !option[FAST] ? option.get_asso_max () : option.get_iterations () ? option.get_iterations () : keyword_list_length (), + fewest_collisions + total_duplicates); + fflush (stderr); + } +} + +/* Does the hard stuff.... + Initializes the Iteration Number array, and attempts to find a perfect + function that will hash all the key words without getting any + duplications. This is made much easier since we aren't attempting + to generate *minimum* functions, only perfect ones. + If we can't generate a perfect function in one pass *and* the user + hasn't enabled the DUP option, we'll inform the user to try the + randomization option, use -D, or choose alternative key positions. + The alternatives (e.g., back-tracking) are too time-consuming, i.e, + exponential in the number of keys. */ + +int +Gen_Perf::operator() (void) +{ + T (Trace t ("Gen_Perf::operator()");) +#if LARGE_STACK_ARRAYS + STORAGE_TYPE buffer[max_hash_value + 1]; +#else + // Note: we don't use new, because that invokes a custom operator new. + STORAGE_TYPE *buffer + = (STORAGE_TYPE*) malloc (sizeof(STORAGE_TYPE) * (max_hash_value + 1)); + if (buffer == NULL) + abort (); +#endif + + Bool_Array::init (buffer, max_hash_value + 1); + + List_Node *curr; + for (curr = head; curr; curr = curr->next) + { + hash (curr); + + for (List_Node *ptr = head; ptr != curr; ptr = ptr->next) + if (ptr->hash_value == curr->hash_value) + { + change (ptr, curr); + break; + } + num_done++; + } + + /* Make one final check, just to make sure nothing weird happened.... */ + + Bool_Array::reset (); + + for (curr = head; curr; curr = curr->next) + if (Bool_Array::find (hash (curr))) + if (option[DUP]) /* Keep track of this number... */ + total_duplicates++; + else /* Yow, big problems. we're outta here! */ + { + report_error ("\nInternal error, duplicate value %d:\n" + "try options -D or -r, or use new key positions.\n\n", hash (curr)); +#if !LARGE_STACK_ARRAYS + free (buffer); +#endif + return 1; + } + + /* Sorts the key word list by hash value, and then outputs the list. + The generated hash table code is only output if the early stage of + processing turned out O.K. */ + + sort (); + output (); +#if !LARGE_STACK_ARRAYS + free (buffer); +#endif + return 0; +} + +/* Prints out some diagnostics upon completion. */ + +Gen_Perf::~Gen_Perf (void) +{ + T (Trace t ("Gen_Perf::~Gen_Perf");) + if (option[DEBUG]) + { + fprintf (stderr, "\ndumping occurrence and associated values tables\n"); + + for (int i = 0; i < ALPHA_SIZE; i++) + if (occurrences[i]) + fprintf (stderr, "asso_values[%c] = %6d, occurrences[%c] = %6d\n", + i, asso_values[i], i, occurrences[i]); + + fprintf (stderr, "end table dumping\n"); + + } +} + diff --git a/gnu/lib/libg++/libg++/gperf/src/gen-perf.h b/gnu/lib/libg++/libg++/gperf/src/gen-perf.h new file mode 100644 index 00000000000..6686ba99260 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/gen-perf.h @@ -0,0 +1,50 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Provides high-level routines to manipulate the keyword list + structures the code generation output. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#ifndef gen_perf_h +#define gen_perf_h 1 + +#include "std-err.h" +#include "key-list.h" +#include "bool-array.h" + +class Gen_Perf : private Key_List, private Bool_Array +{ +private: + int max_hash_value; /* Maximum possible hash value. */ + int fewest_collisions; /* Records fewest # of collisions for asso value. */ + int num_done; /* Number of keywords processed without a collision. */ + + void change (List_Node *prior, List_Node *curr); + int affects_prev (char c, List_Node *curr); + static int hash (List_Node *key_node); + static int compute_disjoint_union (char *set_1, char *set_2, char *set_3); + static void sort_set (char *union_set, int len); + +public: + Gen_Perf (void); + ~Gen_Perf (void); + int operator () (void); +}; +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/hash-table.cc b/gnu/lib/libg++/libg++/gperf/src/hash-table.cc new file mode 100644 index 00000000000..b48bdd5ea76 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/hash-table.cc @@ -0,0 +1,86 @@ +/* Hash table for checking keyword links. Implemented using double hashing. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include +#include "hash-table.h" +#include "options.h" +#include "trace.h" + +#define NIL(TYPE) (TYPE *)0 + +/* The size of the hash table is always the smallest power of 2 >= the size + indicated by the user. This allows several optimizations, including + the use of double hashing and elimination of the mod instruction. + Note that the size had better be larger than the number of items + in the hash table, else there's trouble!!! Note that the memory + for the hash table is allocated *outside* the intialization routine. + This compromises information hiding somewhat, but greatly reduces + memory fragmentation, since we can now use alloca! */ + +Hash_Table::Hash_Table (List_Node **table_ptr, int s): + collisions (0), size (s), table (table_ptr) +{ + T (Trace t ("Hash_Table::Hash_Table");) + memset ((char *) table, 0, size * sizeof *table); +} + +Hash_Table::~Hash_Table (void) +{ + T (Trace t ("Hash_Table::~Hash_Table");) + if (option[DEBUG]) + { + int field_width = option.get_max_keysig_size (); + + fprintf (stderr, "\ndumping the hash table\ntotal available table slots = %d, total bytes = %d, total collisions = %d\n" + "location, %*s, keyword\n", size, size * sizeof *table, collisions, field_width, "keysig"); + + for (int i = size - 1; i >= 0; i--) + if (table[i]) + fprintf (stderr, "%8d, %*s, %s\n", + i, field_width, table[i]->char_set, table[i]->key); + + fprintf (stderr, "\nend dumping hash table\n\n"); + } +} + +/* If the ITEM is already in the hash table return the item found + in the table. Otherwise inserts the ITEM, and returns FALSE. + Uses double hashing. */ + +List_Node * +Hash_Table::operator() (List_Node *item, int ignore_length) +{ + T (Trace t ("Hash_Table::operator()");) + unsigned hash_val = hashpjw (item->char_set); + int probe = hash_val & size - 1; + int increment = (hash_val ^ item->length | 1) & size - 1; + + while (table[probe] + && (strcmp (table[probe]->char_set, item->char_set) + || (!ignore_length && table[probe]->length != item->length))) + { + collisions++; + probe = probe + increment & size - 1; + } + + return table[probe] ? table[probe] : (table[probe] = item, NIL (List_Node)); +} diff --git a/gnu/lib/libg++/libg++/gperf/src/hash-table.h b/gnu/lib/libg++/libg++/gperf/src/hash-table.h new file mode 100644 index 00000000000..1352fa7f4c4 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/hash-table.h @@ -0,0 +1,40 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Hash table used to check for duplicate keyword entries. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#ifndef hash_table_h +#define hash_table_h 1 +#include "list-node.h" + +class Hash_Table +{ +private: + List_Node **table; /* Vector of pointers to linked lists of List_Node's. */ + int size; /* Size of the vector. */ + int collisions; /* Find out how well our double hashing is working! */ + +public: + Hash_Table (List_Node **t, int s); + ~Hash_Table (void); + List_Node *operator () (List_Node *item, int ignore_length); +}; +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/iterator.cc b/gnu/lib/libg++/libg++/gperf/src/iterator.cc new file mode 100644 index 00000000000..05f8a0332f4 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/iterator.cc @@ -0,0 +1,88 @@ +/* Provides an Iterator for keyword characters. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include +#include "iterator.h" +#include "trace.h" + +/* Constructor for Iterator. */ + +Iterator::Iterator (char *s, int lo, int hi, int word_end, int bad_val, int key_end) +{ + T (Trace t ("Iterator::Iterator");) + end = key_end; + error_value = bad_val; + end_word = word_end; + str = s; + hi_bound = hi; + lo_bound = lo; +} + +/* Provide an Iterator, returning the ``next'' value from + the list of valid values given in the constructor. */ + +int +Iterator::operator() (void) +{ + T (Trace t ("Iterator::operator()");) +/* Variables to record the Iterator's status when handling ranges, e.g., 3-12. */ + + static int size; + static int curr_value; + static int upper_bound; + + if (size) + { + if (++curr_value >= upper_bound) + size = 0; + return curr_value; + } + else + { + while (*str) + switch (*str) + { + default: return error_value; + case ',': str++; break; + case '$': str++; return end_word; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + for (curr_value = 0; isdigit (*str); str++) + curr_value = curr_value * 10 + *str - '0'; + + if (*str == '-') + { + + for (size = 1, upper_bound = 0; + isdigit (*++str); + upper_bound = upper_bound * 10 + *str - '0'); + + if (upper_bound <= curr_value || upper_bound > hi_bound) + return error_value; + } + return curr_value >= lo_bound && curr_value <= hi_bound + ? curr_value : error_value; + } + + return end; + } +} diff --git a/gnu/lib/libg++/libg++/gperf/src/iterator.h b/gnu/lib/libg++/libg++/gperf/src/iterator.h new file mode 100644 index 00000000000..470c975eb3b --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/iterator.h @@ -0,0 +1,51 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Provides an Iterator for keyword characters. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Provides an Iterator that expands and decodes a control string containing digits + and ranges, returning an integer every time the generator function is called. + This is used to decode the user's key position requests. For example: + "-k 1,2,5-10,$" will return 1, 2, 5, 6, 7, 8, 9, 10, and 0 ( representing + the abstract ``last character of the key'' on successive calls to the + member function operator (). + No errors are handled in these routines, they are passed back to the + calling routines via a user-supplied Error_Value */ + +#ifndef iterator_h +#define iterator_h 1 + +class Iterator +{ +private: + char *str; /* A pointer to the string provided by the user. */ + int end; /* Value returned after last key is processed. */ + int end_word; /* A value marking the abstract ``end of word'' ( usually '$'). */ + int error_value; /* Error value returned when input is syntactically erroneous. */ + int hi_bound; /* Greatest possible value, inclusive. */ + int lo_bound; /* Smallest possible value, inclusive. */ + +public: + Iterator (char *s, int lo, int hi, int word_end, int bad_val, int key_end); + int operator () (void); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/key-list.cc b/gnu/lib/libg++/libg++/gperf/src/key-list.cc new file mode 100644 index 00000000000..dee8e996177 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/key-list.cc @@ -0,0 +1,1228 @@ +/* Routines for building, ordering, and printing the keyword list. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +/* AIX requires the alloca decl to be the first thing in the file. */ +#ifdef __GNUC__ +#define alloca __builtin_alloca +#elif defined(sparc) +#include +extern "C" void *__builtin_alloca(...); +#elif defined(_AIX) +#pragma alloca +#else +char *alloca (); +#endif + +#include +#include +#include +#include +#include "options.h" +#include "read-line.h" +#include "hash-table.h" +#include "key-list.h" +#include "trace.h" + +/* Make the hash table 8 times larger than the number of keyword entries. */ +static const int TABLE_MULTIPLE = 10; + +/* Default type for generated code. */ +static char *const default_array_type = "char *"; + +/* in_word_set return type, by default. */ +static char *const default_return_type = "char *"; + +/* Efficiently returns the least power of two greater than or equal to X! */ +#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) + +/* How wide the printed field width must be to contain the maximum hash value. */ +static int field_width = 0; + +int Key_List::determined[ALPHA_SIZE]; + +/* Destructor dumps diagnostics during debugging. */ + +Key_List::~Key_List (void) +{ + T (Trace t ("Key_List::~Key_List");) + if (option[DEBUG]) + { + fprintf (stderr, "\nDumping key list information:\ntotal non-static linked keywords = %d" + "\ntotal keywords = %d\ntotal duplicates = %d\nmaximum key length = %d\n", + list_len, total_keys, total_duplicates, max_key_len); + dump (); + report_error ("End dumping list.\n\n"); + } +} + +/* Gathers the input stream into a buffer until one of two things occur: + + 1. We read a '%' followed by a '%' + 2. We read a '%' followed by a '}' + + The first symbolizes the beginning of the keyword list proper, + The second symbolizes the end of the C source code to be generated + verbatim in the output file. + + I assume that the keys are separated from the optional preceding struct + declaration by a consecutive % followed by either % or } starting in + the first column. The code below uses an expandible buffer to scan off + and return a pointer to all the code (if any) appearing before the delimiter. */ + +char * +Key_List::get_special_input (char delimiter) +{ + T (Trace t ("Key_List::get_special_input");) + int size = 80; + char *buf = new char[size]; + int c, i; + + for (i = 0; (c = getchar ()) != EOF; i++) + { + if (c == '%') + { + if ((c = getchar ()) == delimiter) + { + + while ((c = getchar ()) != '\n') + ; /* discard newline */ + + if (i == 0) + return ""; + else + { + buf[delimiter == '%' && buf[i - 2] == ';' ? i - 2 : i - 1] = '\0'; + return buf; + } + } + else + buf[i++] = '%'; + } + else if (i >= size) /* Yikes, time to grow the buffer! */ + { + char *temp = new char[size *= 2]; + int j; + + for (j = 0; j < i; j++) + temp[j] = buf[j]; + + buf = temp; + } + buf[i] = c; + } + + return 0; /* Problem here. */ +} + +/* Stores any C text that must be included verbatim into the + generated code output. */ + +char * +Key_List::save_include_src (void) +{ + T (Trace t ("Key_List::save_include_src");) + int c; + + if ((c = getchar ()) != '%') + ungetc (c, stdin); + else if ((c = getchar ()) != '{') + report_error ("internal error, %c != '{' on line %d in file %s%a", c, __LINE__, __FILE__, 1); + else + return get_special_input ('}'); + return ""; +} + +/* Determines from the input file whether the user wants to build a table + from a user-defined struct, or whether the user is content to simply + use the default array of keys. */ + +char * +Key_List::get_array_type (void) +{ + T (Trace t ("Key_List::get_array_type");) + return get_special_input ('%'); +} + +/* strcspn - find length of initial segment of S consisting entirely + of characters not from REJECT (borrowed from Henry Spencer's + ANSI string package, when GNU libc comes out I'll replace this...). */ + +inline int +Key_List::strcspn (const char *s, const char *reject) +{ + T (Trace t ("Key_List::strcspn");) + const char *scan; + const char *rej_scan; + int count = 0; + + for (scan = s; *scan; scan++) + { + + for (rej_scan = reject; *rej_scan; rej_scan++) + if (*scan == *rej_scan) + return count; + + count++; + } + + return count; +} + +/* Sets up the Return_Type, the Struct_Tag type and the Array_Type + based upon various user Options. */ + +void +Key_List::set_output_types (void) +{ + T (Trace t ("Key_List::set_output_types");) + if (option[TYPE] && !(array_type = get_array_type ())) + return; /* Something's wrong, bug we'll catch it later on.... */ + else if (option[TYPE]) /* Yow, we've got a user-defined type... */ + { + int struct_tag_length = strcspn (array_type, "{\n\0"); + + if (option[POINTER]) /* And it must return a pointer... */ + { + return_type = new char[struct_tag_length + 2]; + strncpy (return_type, array_type, struct_tag_length); + return_type[struct_tag_length] = '*'; + return_type[struct_tag_length + 1] = '\0'; + } + + struct_tag = new char[struct_tag_length + 1]; + strncpy (struct_tag, array_type, struct_tag_length); + struct_tag[struct_tag_length] = '\0'; + } + else if (option[POINTER]) /* Return a char *. */ + return_type = default_array_type; +} + +/* Reads in all keys from standard input and creates a linked list pointed + to by Head. This list is then quickly checked for ``links,'' i.e., + unhashable elements possessing identical key sets and lengths. */ + +void +Key_List::read_keys (void) +{ + T (Trace t ("Key_List::read_keys");) + char *ptr; + + include_src = save_include_src (); + set_output_types (); + + /* Oops, problem with the input file. */ + if (! (ptr = Read_Line::get_line ())) + report_error ("No words in input file, did you forget to prepend %s" + " or use -t accidentally?\n%a", "%%", 1); + + /* Read in all the keywords from the input file. */ + else + { + const char *delimiter = option.get_delimiter (); + List_Node *temp, *trail = 0; + + head = new List_Node (ptr, strcspn (ptr, delimiter)); + + for (temp = head; + (ptr = Read_Line::get_line ()) && strcmp (ptr, "%%"); + temp = temp->next) + { + temp->next = new List_Node (ptr, strcspn (ptr, delimiter)); + total_keys++; + } + + /* See if any additional C code is included at end of this file. */ + if (ptr) + additional_code = 1; + + /* Hash table this number of times larger than keyword number. */ + int table_size = (list_len = total_keys) * TABLE_MULTIPLE; + +#if LARGE_STACK_ARRAYS + /* By allocating the memory here we save on dynamic allocation overhead. + Table must be a power of 2 for the hash function scheme to work. */ + List_Node *table[POW (table_size)]; +#else + // Note: we don't use new, because that invokes a custom operator new. + int malloc_size = POW (table_size) * sizeof(List_Node*); + if (malloc_size == 0) malloc_size = 1; + List_Node **table = (List_Node**)malloc(malloc_size); + if (table == NULL) + abort (); +#endif + + /* Make large hash table for efficiency. */ + Hash_Table found_link (table, table_size); + + /* Test whether there are any links and also set the maximum length of + an identifier in the keyword list. */ + + for (temp = head; temp; temp = temp->next) + { + List_Node *ptr = found_link (temp, option[NOLENGTH]); + + /* Check for links. We deal with these by building an equivalence class + of all duplicate values (i.e., links) so that only 1 keyword is + representative of the entire collection. This *greatly* simplifies + processing during later stages of the program. */ + + if (ptr) + { + total_duplicates++; + list_len--; + trail->next = temp->next; + temp->link = ptr->link; + ptr->link = temp; + + /* Complain if user hasn't enabled the duplicate option. */ + if (!option[DUP] || option[DEBUG]) + report_error ("Key link: \"%s\" = \"%s\", with key set \"%s\".\n", + temp->key, ptr->key, temp->char_set); + } + else + trail = temp; + + /* Update minimum and maximum keyword length, if needed. */ + if (max_key_len < temp->length) + max_key_len = temp->length; + if (min_key_len > temp->length) + min_key_len = temp->length; + } + +#if !LARGE_STACK_ARRAYS + free (table); +#endif + + /* Exit program if links exists and option[DUP] not set, since we can't continue */ + if (total_duplicates) + report_error (option[DUP] + ? "%d input keys have identical hash values, examine output carefully...\n" + : "%d input keys have identical hash values,\ntry different key positions or use option -D.\n%a", total_duplicates, 1); + if (option[ALLCHARS]) + option.set_keysig_size (max_key_len); + } +} + +/* Recursively merges two sorted lists together to form one sorted list. The + ordering criteria is by frequency of occurrence of elements in the key set + or by the hash value. This is a kludge, but permits nice sharing of + almost identical code without incurring the overhead of a function + call comparison. */ + +List_Node * +Key_List::merge (List_Node *list1, List_Node *list2) +{ + T (Trace t ("Key_List::merge");) + if (!list1) + return list2; + else if (!list2) + return list1; + else if (occurrence_sort && list1->occurrence < list2->occurrence + || hash_sort && list1->hash_value > list2->hash_value) + { + list2->next = merge (list2->next, list1); + return list2; + } + else + { + list1->next = merge (list1->next, list2); + return list1; + } +} + +/* Applies the merge sort algorithm to recursively sort the key list by + frequency of occurrence of elements in the key set. */ + +List_Node * +Key_List::merge_sort (List_Node *head) +{ + T (Trace t ("Key_List::merge_sort");) + if (!head || !head->next) + return head; + else + { + List_Node *middle = head; + List_Node *temp = head->next->next; + + while (temp) + { + temp = temp->next; + middle = middle->next; + if (temp) + temp = temp->next; + } + + temp = middle->next; + middle->next = 0; + return merge (merge_sort (head), merge_sort (temp)); + } +} + +/* Returns the frequency of occurrence of elements in the key set. */ + +inline int +Key_List::get_occurrence (List_Node *ptr) +{ + T (Trace t ("Key_List::get_occurrence");) + int value = 0; + + for (char *temp = ptr->char_set; *temp; temp++) + value += occurrences[*temp]; + + return value; +} + +/* Enables the index location of all key set elements that are now + determined. */ + +inline void +Key_List::set_determined (List_Node *ptr) +{ + T (Trace t ("Key_List::set_determined");) + for (char *temp = ptr->char_set; *temp; temp++) + determined[*temp] = 1; +} + +/* Returns TRUE if PTR's key set is already completely determined. */ + +inline int +Key_List::already_determined (List_Node *ptr) +{ + T (Trace t ("Key_List::already_determined");) + int is_determined = 1; + + for (char *temp = ptr->char_set; is_determined && *temp; temp++) + is_determined = determined[*temp]; + + return is_determined; +} + +/* Reorders the table by first sorting the list so that frequently occuring + keys appear first, and then the list is reorded so that keys whose values + are already determined will be placed towards the front of the list. This + helps prune the search time by handling inevitable collisions early in the + search process. See Cichelli's paper from Jan 1980 JACM for details.... */ + +void +Key_List::reorder (void) +{ + T (Trace t ("Key_List::reorder");) + List_Node *ptr; + for (ptr = head; ptr; ptr = ptr->next) + ptr->occurrence = get_occurrence (ptr); + + occurrence_sort = !(hash_sort = 0); /* Pretty gross, eh?! */ + + for (ptr = head = merge_sort (head); ptr->next; ptr = ptr->next) + { + set_determined (ptr); + + if (already_determined (ptr->next)) + continue; + else + { + List_Node *trail_ptr = ptr->next; + List_Node *run_ptr = trail_ptr->next; + + for (; run_ptr; run_ptr = trail_ptr->next) + { + + if (already_determined (run_ptr)) + { + trail_ptr->next = run_ptr->next; + run_ptr->next = ptr->next; + ptr = ptr->next = run_ptr; + } + else + trail_ptr = run_ptr; + } + } + } +} + +/* Outputs the maximum and minimum hash values. Since the + list is already sorted by hash value all we need to do is + find the final item! */ + +void +Key_List::output_min_max () +{ + T (Trace t ("Key_List::output_min_max");) + List_Node *temp; + for (temp = head; temp->next; temp = temp->next) + ; + + min_hash_value = head->hash_value; + max_hash_value = temp->hash_value; + + if (!option[ENUM]) + printf ("\n#define TOTAL_KEYWORDS %d\n#define MIN_WORD_LENGTH %d" + "\n#define MAX_WORD_LENGTH %d\n#define MIN_HASH_VALUE %d" + "\n#define MAX_HASH_VALUE %d\n", total_keys, min_key_len, + max_key_len, min_hash_value, max_hash_value); + printf ("/* maximum key range = %d, duplicates = %d */\n\n", + max_hash_value - min_hash_value + 1, total_duplicates); +} + +/* Generates the output using a C switch. This trades increased search + time for decreased table space (potentially *much* less space for + sparse tables). It the user has specified their own struct in the + keyword file *and* they enable the POINTER option we have extra work to + do. The solution here is to maintain a local static array of user + defined struct's, as with the Output_Lookup_Function. Then we use for + switch statements to perform either a strcmp or strncmp, returning 0 if + the str fails to match, and otherwise returning a pointer to appropriate index + location in the local static array. */ + +void +Key_List::output_switch (void) +{ + T (Trace t ("Key_List::output_switch");) + char *comp_buffer; + List_Node *curr = head; + int pointer_and_type_enabled = option[POINTER] && option[TYPE]; + int total_switches = option.get_total_switches (); + int switch_size = keyword_list_length () / total_switches; + + if (pointer_and_type_enabled) + { + comp_buffer = (char *) alloca (strlen ("*str == *resword->%s && !strncmp (str + 1, resword->%s + 1, len - 1)") + + 2 * strlen (option.get_key_name ()) + 1); + sprintf (comp_buffer, option[COMP] + ? "*str == *resword->%s && !strncmp (str + 1, resword->%s + 1, len - 1)" + : "*str == *resword->%s && !strcmp (str + 1, resword->%s + 1)", + option.get_key_name (), option.get_key_name ()); + } + else + comp_buffer = option[COMP] + ? "*str == *resword && !strncmp (str + 1, resword + 1, len - 1)" + : "*str == *resword && !strcmp (str + 1, resword + 1)"; + + printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n {\n" + " register int key = %s (str, len);\n\n" + " if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)\n {\n", + option.get_hash_name ()); + + /* Properly deal with user's who request multiple switch statements. */ + + while (curr) + { + List_Node *temp = curr; + int lowest_case_value = curr->hash_value; + int number_of_cases = 0; + + /* Figure out a good cut point to end this switch. */ + + for (; temp && ++number_of_cases < switch_size; temp = temp->next) + if (temp->next && temp->hash_value == temp->next->hash_value) + while (temp->next && temp->hash_value == temp->next->hash_value) + temp = temp->next; + + if (temp && total_switches != 1) + printf (" if (key <= %d)\n {\n", temp->hash_value); + else + printf (" {\n"); + + /* Output each keyword as part of a switch statement indexed by hash value. */ + + if (option[POINTER] || option[DUP]) + { + int i = 0; + + printf (" %s%s *resword; %s\n\n", + option[CONST] ? "const " : "", + pointer_and_type_enabled ? struct_tag : "char", + option[LENTABLE] && !option[DUP] ? "int key_len;" : ""); + if (total_switches == 1) + { + printf (" switch (key)\n {\n"); + lowest_case_value = 0; + } + else + printf (" switch (key - %d)\n {\n", lowest_case_value); + + for (temp = curr; temp && ++i <= number_of_cases; temp = temp->next) + { + printf (" case %*d:", field_width, temp->hash_value - lowest_case_value); + if (option[DEBUG]) + printf (" /* hash value = %4d, keyword = \"%s\" */", temp->hash_value, temp->key); + putchar ('\n'); + + /* Handle `natural links,' i.e., those that occur statically. */ + + if (temp->link) + { + List_Node *links; + + for (links = temp; links; links = links->link) + { + if (pointer_and_type_enabled) + printf (" resword = &wordlist[%d];\n", links->index); + else + printf (" resword = \"%s\";\n", links->key); + printf (" if (%s) return resword;\n", comp_buffer); + } + } + /* Handle unresolved duplicate hash values. These are guaranteed + to be adjacent since we sorted the keyword list by increasing + hash values. */ + if (temp->next && temp->hash_value == temp->next->hash_value) + { + + for ( ; temp->next && temp->hash_value == temp->next->hash_value; + temp = temp->next) + { + if (pointer_and_type_enabled) + printf (" resword = &wordlist[%d];\n", temp->index); + else + printf (" resword = \"%s\";\n", temp->key); + printf (" if (%s) return resword;\n", comp_buffer); + } + if (pointer_and_type_enabled) + printf (" resword = &wordlist[%d];\n", temp->index); + else + printf (" resword = \"%s\";\n", temp->key); + printf (" return %s ? resword : 0;\n", comp_buffer); + } + else if (temp->link) + printf (" return 0;\n"); + else + { + if (pointer_and_type_enabled) + printf (" resword = &wordlist[%d];", temp->index); + else + printf (" resword = \"%s\";", temp->key); + if (option[LENTABLE] && !option[DUP]) + printf (" key_len = %d;", temp->length); + printf (" break;\n"); + } + } + printf (" default: return 0;\n }\n"); + printf (option[LENTABLE] && !option[DUP] + ? " if (len == key_len && %s)\n return resword;\n" + : " if (%s)\n return resword;\n", comp_buffer); + printf (" return 0;\n }\n"); + curr = temp; + } + else /* Nothing special required here. */ + { + int i = 0; + printf (" char *s;\n\n switch (key - %d)\n {\n", + lowest_case_value); + + for (temp = curr; temp && ++i <= number_of_cases; temp = temp->next) + if (option[LENTABLE]) + printf (" case %*d: if (len == %d) s = \"%s\"; else return 0; break;\n", + field_width, temp->hash_value - lowest_case_value, + temp->length, temp->key); + else + printf (" case %*d: s = \"%s\"; break;\n", + field_width, temp->hash_value - lowest_case_value, temp->key); + + printf (" default: return 0;\n }\n "); + printf ("return *s == *str && !%s;\n }\n", + option[COMP] + ? "strncmp (s + 1, str + 1, len - 1)" : "strcmp (s + 1, str + 1)"); + curr = temp; + } + } + printf (" }\n }\n return 0;\n}\n"); +} + +/* Prints out a table of keyword lengths, for use with the + comparison code in generated function ``in_word_set.'' */ + +void +Key_List::output_keylength_table (void) +{ + T (Trace t ("Key_List::output_keylength_table");) + const int max_column = 15; + int index = 0; + int column = 0; + char *indent = option[GLOBAL] ? "" : " "; + List_Node *temp; + + if (!option[DUP] && !option[SWITCH]) + { + printf ("\n%sstatic %sunsigned %s lengthtable[] =\n%s%s{\n ", + indent, option[CONST] ? "const " : "", + max_key_len <= UCHAR_MAX ? "char" : (max_key_len <= USHRT_MAX ? "short" : "long"), + indent, indent); + + for (temp = head; temp; temp = temp->next, index++) + { + + if (index < temp->hash_value) + for ( ; index < temp->hash_value; index++) + printf ("%3d,%s", 0, ++column % (max_column - 1) ? "" : "\n "); + + printf ("%3d,%s", temp->length, ++column % (max_column - 1 ) ? "" : "\n "); + } + + printf ("\n%s%s};\n", indent, indent); + } +} +/* Prints out the array containing the key words for the Gen_Perf + hash function. */ + +void +Key_List::output_keyword_table (void) +{ + T (Trace t ("Key_List::output_keyword_table");) + char *l_brace = *head->rest ? "{" : ""; + char *r_brace = *head->rest ? "}," : ""; + char *indent = option[GLOBAL] ? "" : " "; + int index = 0; + List_Node *temp; + + printf ("%sstatic %s%swordlist[] =\n%s%s{\n", + indent, option[CONST] ? "const " : "", struct_tag, indent, indent); + + /* Skip over leading blank entries if there are no duplicates. */ + + printf (" "); + int column; + for (column = 1; index < head->hash_value; index++, column++) + printf ("%s\"\",%s %s", l_brace, r_brace, column % 9 ? "" : "\n "); + if (column % 10) + printf ("\n"); + + + /* Generate an array of reserved words at appropriate locations. */ + + for (temp = head ; temp; temp = temp->next, index++) + { + temp->index = index; + + if (!option[SWITCH] && (total_duplicates == 0 || !option[DUP]) && index < temp->hash_value) + { + int column; + + printf (" "); + + for (column = 1; index < temp->hash_value; index++, column++) + printf ("%s\"\",%s %s", l_brace, r_brace, column % 9 ? "" : "\n "); + + if (column % 10) + printf ("\n"); + else + { + printf ("%s\"%s\", %s%s", l_brace, temp->key, temp->rest, r_brace); + if (option[DEBUG]) + printf (" /* hash value = %d, index = %d */", temp->hash_value, temp->index); + putchar ('\n'); + continue; + } + } + + printf (" %s\"%s\", %s%s", l_brace, temp->key, temp->rest, r_brace); + if (option[DEBUG]) + printf (" /* hash value = %d, index = %d */", temp->hash_value, temp->index); + putchar ('\n'); + + /* Deal with links specially. */ + if (temp->link) + for (List_Node *links = temp->link; links; links = links->link) + { + links->index = ++index; + printf (" %s\"%s\", %s%s", l_brace, links->key, links->rest, r_brace); + if (option[DEBUG]) + printf (" /* hash value = %d, index = %d */", links->hash_value, links->index); + putchar ('\n'); + } + } + printf ("%s%s};\n\n", indent, indent); +} + +/* Generates C code for the hash function that returns the + proper encoding for each key word. */ + +void +Key_List::output_hash_function (void) +{ + T (Trace t ("Key_List::output_hash_function");) + const int max_column = 10; + int count = max_hash_value; + + /* Calculate maximum number of digits required for MAX_HASH_VALUE. */ + + for (field_width = 2; (count /= 10) > 0; field_width++) + ; + + if (option[GNU]) + printf ("#ifdef __GNUC__\ninline\n#endif\n"); + + if (option[C]) + printf ("static "); + printf ("unsigned int\n"); + if (option[CPLUSPLUS]) + printf ("%s::", option.get_class_name ()); + + printf (option[ANSI] + ? "%s (register const char *str, register int len)\n{\n static %sunsigned %s asso_values[] =\n {" + : "%s (str, len)\n register char *str;\n register int unsigned len;\n{\n static %sunsigned %s asso_values[] =\n {", + option.get_hash_name (), option[CONST] ? "const " : "", + max_hash_value <= UCHAR_MAX ? "char" : (max_hash_value <= USHRT_MAX ? "short" : "int")); + + for (count = 0; count < ALPHA_SIZE; ++count) + { + if (!(count % max_column)) + printf ("\n "); + + printf ("%*d,", field_width, occurrences[count] ? asso_values[count] : max_hash_value + 1); + } + + /* Optimize special case of ``-k 1,$'' */ + if (option[DEFAULTCHARS]) + printf ("\n };\n return %sasso_values[str[len - 1]] + asso_values[str[0]];\n}\n\n", + option[NOLENGTH] ? "" : "len + "); + else + { + int key_pos; + + option.reset (); + + /* Get first (also highest) key position. */ + key_pos = option.get (); + + /* We can perform additional optimizations here. */ + if (!option[ALLCHARS] && key_pos <= min_key_len) + { + printf ("\n };\n return %s", option[NOLENGTH] ? "" : "len + "); + + for (; key_pos != WORD_END; ) + { + printf ("asso_values[str[%d]]", key_pos - 1); + if ((key_pos = option.get ()) != EOS) + printf (" + "); + else + break; + } + + printf ("%s;\n}\n\n", key_pos == WORD_END ? "asso_values[str[len - 1]]" : ""); + } + + /* We've got to use the correct, but brute force, technique. */ + else + { + printf ("\n };\n register int hval = %s;\n\n switch (%s)\n {\n default:\n", + option[NOLENGTH] ? "0" : "len", option[NOLENGTH] ? "len" : "hval"); + + /* User wants *all* characters considered in hash. */ + if (option[ALLCHARS]) + { + int i; + + for (i = max_key_len; i > 0; i--) + printf (" case %d:\n hval += asso_values[str[%d]];\n", i, i - 1); + + printf (" }\n return hval;\n}\n\n"); + } + else /* do the hard part... */ + { + int last_case_written; + + count = key_pos + 1; + + do + { + + while (--count > key_pos) + printf (" case %d:\n", count); + + printf (" case %d:\n hval += asso_values[str[%d]];\n", + key_pos, key_pos - 1); + + last_case_written = key_pos; + } + while ((key_pos = option.get ()) != EOS && key_pos != WORD_END); + + while (--last_case_written >= min_key_len) + printf(" case %d:\n", last_case_written); + printf(" break;\n"); + + printf (" }\n return hval%s;\n}\n\n", + key_pos == WORD_END ? " + asso_values[str[len - 1]]" : ""); + } + } + } +} + +/* Generates the large, sparse table that maps hash values into + the smaller, contiguous range of the keyword table. */ + +void +Key_List::output_lookup_array (void) +{ + T (Trace t ("Key_List::output_lookup_array");) + if (total_duplicates > 0) + { + const int DEFAULT_VALUE = -1; + + struct duplicate_entry + { + int hash_value; /* Hash value for this particular duplicate set. */ + int index; /* Index into the main keyword storage array. */ + int count; /* Number of consecutive duplicates at this index. */ + }; +#if LARGE_STACK_ARRAYS + duplicate_entry duplicates[total_duplicates]; + int lookup_array[max_hash_value + 1]; +#else + // Note: we don't use new, because that invokes a custom operator new. + duplicate_entry *duplicates = (duplicate_entry*) + malloc (total_duplicates * sizeof(duplicate_entry)); + int *lookup_array = (int*)malloc(sizeof(int) * (max_hash_value + 1)); + if (duplicates == NULL || lookup_array == NULL) + abort(); +#endif + duplicate_entry *dup_ptr = duplicates; + int *lookup_ptr = lookup_array + max_hash_value + 1; + + while (lookup_ptr > lookup_array) + *--lookup_ptr = DEFAULT_VALUE; + + for (List_Node *temp = head; temp; temp = temp->next) + { + int hash_value = temp->hash_value; + lookup_array[hash_value] = temp->index; + if (option[DEBUG]) + fprintf (stderr, "keyword = %s, index = %d\n", temp->key, temp->index); + if (!temp->link && + (!temp->next || hash_value != temp->next->hash_value)) + continue; +#if LARGE_STACK_ARRAYS + *dup_ptr = (duplicate_entry) { hash_value, temp->index, 1 }; +#else + duplicate_entry _dups; + _dups.hash_value = hash_value; + _dups.index = temp->index; + _dups.count = 1; + *dup_ptr = _dups; +#endif + + for (List_Node *ptr = temp->link; ptr; ptr = ptr->link) + { + dup_ptr->count++; + if (option[DEBUG]) + fprintf (stderr, "static linked keyword = %s, index = %d\n", ptr->key, ptr->index); + } + + while (temp->next && hash_value == temp->next->hash_value) + { + temp = temp->next; + dup_ptr->count++; + if (option[DEBUG]) + fprintf (stderr, "dynamic linked keyword = %s, index = %d\n", temp->key, temp->index); + + for (List_Node *ptr = temp->link; ptr; ptr = ptr->link) + { + dup_ptr->count++; + if (option[DEBUG]) + fprintf (stderr, "static linked keyword = %s, index = %d\n", ptr->key, ptr->index); + } + } + dup_ptr++; + } + + while (--dup_ptr >= duplicates) + { + if (option[DEBUG]) + fprintf (stderr, "dup_ptr[%d]: hash_value = %d, index = %d, count = %d\n", + dup_ptr - duplicates, dup_ptr->hash_value, dup_ptr->index, dup_ptr->count); + + /* Start searching for available space towards the right part of the lookup array. */ + int i; + for (i = dup_ptr->hash_value; i < max_hash_value; i++) + if (lookup_array[i] == DEFAULT_VALUE && lookup_array[i + 1] == DEFAULT_VALUE) + { + lookup_array[i] = -dup_ptr->index; + lookup_array[i + 1] = -dup_ptr->count; + lookup_array[dup_ptr->hash_value] = max_hash_value + (i - dup_ptr->hash_value); + break; + } + + /* If we didn't find it to the right look to the left instead... */ + if (i == max_hash_value) + { + + for (i = dup_ptr->hash_value; i > 0; i--) + if (lookup_array[i] == DEFAULT_VALUE && lookup_array[i - 1] == DEFAULT_VALUE) + { + lookup_array[i - 1] = -dup_ptr->index; + lookup_array[i] = -dup_ptr->count; + lookup_array[dup_ptr->hash_value] = -(max_hash_value + (dup_ptr->hash_value - i + 1)); + break; + } + + /* We are in *big* trouble if this happens! */ + assert (i != 0); + } + } + + int max = INT_MIN; + lookup_ptr = lookup_array + max_hash_value + 1; + while (lookup_ptr > lookup_array) + { + int val = abs (*--lookup_ptr); + if (max < val) + max = val; + } + + char *indent = option[GLOBAL] ? "" : " "; + printf ("%sstatic %s%s lookup[] =\n%s%s{\n ", indent, option[CONST] ? "const " : "", + max <= SCHAR_MAX ? "char" : (max <= USHRT_MAX ? "short" : "int"), + indent, indent); + + int count = max; + + /* Calculate maximum number of digits required for MAX_HASH_VALUE. */ + + for (field_width = 2; (count /= 10) > 0; field_width++) + ; + + const int max_column = 15; + int column = 0; + + for (lookup_ptr = lookup_array; + lookup_ptr < lookup_array + max_hash_value + 1; + lookup_ptr++) + printf ("%*d,%s", field_width, *lookup_ptr, ++column % (max_column - 1) ? "" : "\n "); + + printf ("\n%s%s};\n\n", indent, indent); +#if !LARGE_STACK_ARRAYS + free (duplicates); + free (lookup_array); +#endif + } +} +/* Generates C code to perform the keyword lookup. */ + +void +Key_List::output_lookup_function (void) +{ + T (Trace t ("Key_List::output_lookup_function");) + printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n {\n" + " register int key = %s (str, len);\n\n" + " if (key <= MAX_HASH_VALUE && key >= 0)\n {\n", + option.get_hash_name ()); + + if (option[DUP] && total_duplicates > 0) + { + printf (" register int index = lookup[key];\n\n" + " if (index >= 0 && index < MAX_HASH_VALUE)\n" + " {\n" + " register %schar *s = wordlist[index]", option[CONST] ? "const " : ""); + if (array_type != default_array_type) + printf (".%s", option.get_key_name ()); + + printf (";\n\n if (%s*s == *str && !%s)\n return %s;\n }\n", + option[LENTABLE] ? "len == lengthtable[key]\n && " : "", + option[COMP] ? "strncmp (str + 1, s + 1, len - 1)" : "strcmp (str + 1, s + 1)", + option[TYPE] && option[POINTER] ? "&wordlist[index]" : "s"); + printf (" else if (index < 0 && index >= -MAX_HASH_VALUE)\n" + " return 0;\n else\n {\n" + " register int offset = key + index + (index > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);\n" + " register %s%s*base = &wordlist[-lookup[offset]];\n" + " register %s%s*ptr = base + -lookup[offset + 1];\n\n" + " while (--ptr >= base)\n ", + option[CONST] ? "const " : "", struct_tag, + option[CONST] ? "const " : "", struct_tag); + if (array_type != default_array_type) + printf ("if (*str == *ptr->%s && !strcmp (str + 1, ptr->%s + 1", + option.get_key_name (), option.get_key_name ()); + else + printf ("if (*str == **ptr && !strcmp (str + 1, *ptr + 1"); + + printf ("))\n return %sptr;" + "\n }\n }\n }\n return 0;\n}\n", array_type == default_array_type ? "*" : ""); + + } + else + { + printf (" register %schar *s = wordlist[key]", option[CONST] ? "const " : ""); + + if (array_type != default_array_type) + printf (".%s", option.get_key_name ()); + + printf (";\n\n if (%s*s == *str && !%s)\n return %s", + option[LENTABLE] ? "len == lengthtable[key]\n && " : "", + option[COMP] ? "strncmp (str + 1, s + 1, len - 1)" : "strcmp (str + 1, s + 1)", + option[TYPE] && option[POINTER] ? "&wordlist[key]" : "s"); + printf (";\n }\n }\n return 0;\n}\n"); + } +} + +/* Generates the hash function and the key word recognizer function + based upon the user's Options. */ + +void +Key_List::output (void) +{ + T (Trace t ("Key_List::output");) + printf ("%s\n", include_src); + + if (option[TYPE] && !option[NOTYPE]) /* Output type declaration now, reference it later on.... */ + printf ("%s;\n", array_type); + + output_min_max (); + + if (option[CPLUSPLUS]) + printf ("class %s\n{\nprivate:\n" + " static unsigned int hash (const char *str, int len);\npublic:\n" + " static %s%s%s (const char *str, int len);\n};\n\n", + option.get_class_name (), option[CONST] ? "const " : "", + return_type, option.get_function_name ()); + + output_hash_function (); + + if (option[GLOBAL]) + if (option[SWITCH]) + { + if (option[LENTABLE] && option[DUP]) + output_keylength_table (); + if (option[POINTER] && option[TYPE]) + output_keyword_table (); + } + else + { + if (option[LENTABLE]) + output_keylength_table (); + output_keyword_table (); + output_lookup_array (); + } + + if (option[GNU]) /* Use the inline keyword to remove function overhead. */ + printf ("#ifdef __GNUC__\ninline\n#endif\n"); + + printf ("%s%s\n", option[CONST] ? "const " : "", return_type); + if (option[CPLUSPLUS]) + printf ("%s::", option.get_class_name ()); + + printf (option[ANSI] + ? "%s (register const char *str, register int len)\n{\n" + : "%s (str, len)\n register char *str;\n register unsigned int len;\n{\n", + option.get_function_name ()); + + if (option[ENUM]) + printf (" enum\n {\n" + " TOTAL_KEYWORDS = %d,\n" + " MIN_WORD_LENGTH = %d,\n" + " MAX_WORD_LENGTH = %d,\n" + " MIN_HASH_VALUE = %d,\n" + " MAX_HASH_VALUE = %d,\n" + " };\n\n", + total_keys, min_key_len, max_key_len, min_hash_value, max_hash_value); + + /* Use the switch in place of lookup table. */ + if (option[SWITCH]) + { + if (!option[GLOBAL]) + { + if (option[LENTABLE] && option[DUP]) + output_keylength_table (); + if (option[POINTER] && option[TYPE]) + output_keyword_table (); + } + output_switch (); + } + /* Use the lookup table, in place of switch. */ + else + { + if (!option[GLOBAL]) + { + if (option[LENTABLE]) + output_keylength_table (); + output_keyword_table (); + } + if (!option[GLOBAL]) + output_lookup_array (); + output_lookup_function (); + } + + if (additional_code) + for (int c; (c = getchar ()) != EOF; putchar (c)) + ; + + fflush (stdout); +} + +/* Sorts the keys by hash value. */ + +void +Key_List::sort (void) +{ + T (Trace t ("Key_List::sort");) + hash_sort = 1; + occurrence_sort = 0; + + head = merge_sort (head); +} + +/* Dumps the key list to stderr stream. */ + +void +Key_List::dump () +{ + T (Trace t ("Key_List::dump");) + int field_width = option.get_max_keysig_size (); + + fprintf (stderr, "\nList contents are:\n(hash value, key length, index, %*s, keyword):\n", + field_width, "char_set"); + + for (List_Node *ptr = head; ptr; ptr = ptr->next) + fprintf (stderr, "%11d,%11d,%6d, %*s, %s\n", + ptr->hash_value, ptr->length, ptr->index, + field_width, ptr->char_set, ptr->key); +} + +/* Simple-minded constructor action here... */ + +Key_List::Key_List (void) +{ + T (Trace t ("Key_List::Key_List");) + total_keys = 1; + max_key_len = INT_MIN; + min_key_len = INT_MAX; + return_type = default_return_type; + array_type = struct_tag = default_array_type; + head = 0; + total_duplicates = 0; + additional_code = 0; +} + +/* Returns the length of entire key list. */ + +int +Key_List::keyword_list_length (void) +{ + T (Trace t ("Key_List::keyword_list_length");) + return list_len; +} + +/* Returns length of longest key read. */ + +int +Key_List::max_key_length (void) +{ + T (Trace t ("Key_List::max_key_length");) + return max_key_len; +} + diff --git a/gnu/lib/libg++/libg++/gperf/src/key-list.h b/gnu/lib/libg++/libg++/gperf/src/key-list.h new file mode 100644 index 00000000000..d69cdaf25b5 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/key-list.h @@ -0,0 +1,87 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Data and function member declarations for the keyword list class. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +/* The key word list is a useful abstraction that keeps track of + various pieces of information that enable that fast generation + of the Gen_Perf.hash function. A Key_List is a singly-linked + list of List_Nodes. */ + +#ifndef key_list_h +#define key_list_h 1 + +#include "list-node.h" +#include "std-err.h" +#include "vectors.h" +#include "read-line.h" + +class Key_List : public Std_Err, private Read_Line, public Vectors +{ +private: + char *array_type; /* Pointer to the type for word list. */ + char *return_type; /* Pointer to return type for lookup function. */ + char *struct_tag; /* Shorthand for user-defined struct tag type. */ + char *include_src; /* C source code to be included verbatim. */ + int max_key_len; /* Maximum length of the longest keyword. */ + int min_key_len; /* Minimum length of the shortest keyword. */ + int min_hash_value; /* Minimum hash value for all keywords. */ + int max_hash_value; /* Maximum hash value for all keywords. */ + int occurrence_sort; /* True if sorting by occurrence. */ + int hash_sort; /* True if sorting by hash value. */ + int additional_code; /* True if any additional C code is included. */ + int list_len; /* Length of head's Key_List, not counting duplicates. */ + int total_keys; /* Total number of keys, counting duplicates. */ + static int determined[ALPHA_SIZE]; /* Used in function reorder, below. */ + static int get_occurrence (List_Node *ptr); + static int strcspn (const char *s, const char *reject); + static int already_determined (List_Node *ptr); + static void set_determined (List_Node *ptr); + void output_min_max (void); + void output_switch (void); + void output_keyword_table (void); + void output_keylength_table (void); + void output_hash_function (void); + void output_lookup_function (void); + void output_lookup_array (void); + void set_output_types (void); + void dump (void); + char *get_array_type (void); + char *save_include_src (void); + char *get_special_input (char delimiter); + List_Node *merge (List_Node *list1, List_Node *list2); + List_Node *merge_sort (List_Node *head); + +protected: + List_Node *head; /* Points to the head of the linked list. */ + int total_duplicates; /* Total number of duplicate hash values. */ + +public: + Key_List (void); + ~Key_List (void); + int keyword_list_length (void); + int max_key_length (void); + void reorder (void); + void sort (void); + void read_keys (void); + void output (void); +}; +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/list-node.cc b/gnu/lib/libg++/libg++/gperf/src/list-node.cc new file mode 100644 index 00000000000..50d59bfaee6 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/list-node.cc @@ -0,0 +1,99 @@ +/* Creates and initializes a new list node. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include "options.h" +#include "list-node.h" +#include "trace.h" + +/* Defined as a macro in string.h on some systems, which causes conflicts. */ +#undef index + +/* Sorts the key set alphabetically to speed up subsequent operations. + Uses insertion sort since the set is probably quite small. */ + +inline void +List_Node::set_sort (char *base, int len) +{ + T (Trace t ("List_Node::set_sort");) + int i, j; + + for (i = 0, j = len - 1; i < j; i++) + { + char curr, tmp; + + for (curr = i + 1, tmp = base[curr]; curr > 0 && tmp < base[curr-1]; curr--) + base[curr] = base[curr - 1]; + + base[curr] = tmp; + + } +} + +/* Initializes a List_Node. This requires obtaining memory for the CHAR_SET + initializing them using the information stored in the KEY_POSITIONS array in Options, + and checking for simple errors. It's important to note that KEY and REST are + both pointers to the different offsets into the same block of dynamic memory pointed + to by parameter K. The data member REST is used to store any additional fields + of the input file (it is set to the "" string if Option[TYPE] is not enabled). + This is useful if the user wishes to incorporate a lookup structure, + rather than just an array of keys. Finally, KEY_NUMBER contains a count + of the total number of keys seen so far. This is used to initialize + the INDEX field to some useful value. */ + +List_Node::List_Node (char *k, int len): key (k), next (0), index (0), + length (len), link (0), rest (option[TYPE] ? k + len + 1 : "") +{ + T (Trace t ("List_Node::List_Node");) + char *ptr = new char[(option[ALLCHARS] ? len : option.get_max_keysig_size ()) + 1]; + char_set = ptr; + k[len] = '\0'; /* Null terminate KEY to separate it from REST. */ + + if (option[ALLCHARS]) /* Use all the character position in the KEY. */ + for (; *k; k++, ptr++) + ++occurrences[*ptr = *k]; + else /* Only use those character positions specified by the user. */ + { + int i; + + /* Iterate thru the list of key_positions, initializing occurrences table + and char_set (via char * pointer ptr). */ + + for (option.reset (); (i = option.get ()) != EOS; ) + { + if (i == WORD_END) /* Special notation for last KEY position, i.e. '$'. */ + *ptr = key[len - 1]; + else if (i <= len) /* Within range of KEY length, so we'll keep it. */ + *ptr = key[i - 1]; + else /* Out of range of KEY length, so we'll just skip it. */ + continue; + ++occurrences[*ptr++]; + } + + /* Didn't get any hits and user doesn't want to consider the + keylength, so there are essentially no usable hash positions! */ + if (ptr == char_set && option[NOLENGTH]) + report_error ("Can't hash keyword %s with chosen key positions.\n%a", key, 1); + } + *ptr = '\0'; /* Terminate this bastard.... */ + /* Sort the KEY_SET items alphabetically. */ + set_sort (char_set, ptr - char_set); +} diff --git a/gnu/lib/libg++/libg++/gperf/src/list-node.h b/gnu/lib/libg++/libg++/gperf/src/list-node.h new file mode 100644 index 00000000000..a4b20672b81 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/list-node.h @@ -0,0 +1,46 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Data and function members for defining values and operations of a list node. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#ifndef list_node_h +#define list_node_h 1 + +#include "std-err.h" +#include "vectors.h" + +struct List_Node : private Std_Err, private Vectors +{ + List_Node *link; /* TRUE if key has an identical KEY_SET as another key. */ + List_Node *next; /* Points to next element on the list. */ + char *key; /* Each keyword string stored here. */ + char *rest; /* Additional information for building hash function. */ + char *char_set; /* Set of characters to hash, specified by user. */ + int length; /* Length of the key. */ + int hash_value; /* Hash value for the key. */ + int occurrence; /* A metric for frequency of key set occurrences. */ + int index; /* Position of this node relative to other nodes. */ + + List_Node (char *key, int len); + static void set_sort (char *base, int len); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/main.cc b/gnu/lib/libg++/libg++/gperf/src/main.cc new file mode 100644 index 00000000000..466dfa62f51 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/main.cc @@ -0,0 +1,85 @@ +/* Driver program for the Gen_Perf hash function generator + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +/* Simple driver program for the Gen_Perf.hash function generator. + Most of the hard work is done in class Gen_Perf and its class methods. */ + +#include <_G_config.h> +#include +#if defined(COUNT_TIME) || _G_HAVE_SYS_RESOURCE +#include +#endif +#ifdef COUNT_TIME +#include +#endif + +#include +#include "std-err.h" +#include "options.h" +#include "gen-perf.h" +#include "trace.h" + +#if LARGE_STACK_ARRAYS && _G_HAVE_SYS_RESOURCE +#include +#endif + +int +main (int argc, char *argv[]) +{ + T (Trace t ("main");) + +#ifdef COUNT_TIME + struct tm *tm; + time_t clock; + + time (&clock); + tm = localtime (&clock); + printf ("/* starting time is %d:%02d:%02d */\n", tm->tm_hour, tm->tm_min, tm->tm_sec); +#endif + +#if defined(RLIMIT_STACK) && _G_HAVE_SYS_RESOURCE && LARGE_STACK_ARRAYS + /* Get rid of any avoidable limit on stack size. */ + { + struct rlimit rlim; + + /* Set the stack limit huge so that alloca does not fail. */ + getrlimit (RLIMIT_STACK, &rlim); + rlim.rlim_cur = rlim.rlim_max; + setrlimit (RLIMIT_STACK, &rlim); + } +#endif /* RLIMIT_STACK */ + + /* Sets the Options. */ + option (argc, argv); + + /* Initializes the key word list. */ + Gen_Perf generate_table; + + /* Generates and prints the Gen_Perf hash table. + Don't use exit here, it skips the destructors. */ + int status = generate_table (); + +#ifdef COUNT_TIME + time (&clock); + tm = localtime (&clock); + printf ("/* ending time is %d:%02d:%02d */\n", tm->tm_hour, tm->tm_min, tm->tm_sec); +#endif + return status; +} diff --git a/gnu/lib/libg++/libg++/gperf/src/new.cc b/gnu/lib/libg++/libg++/gperf/src/new.cc new file mode 100644 index 00000000000..515acabcf6d --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/new.cc @@ -0,0 +1,81 @@ +/* Defines a buffered memory allocation abstraction that reduces calls to + malloc. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include "std-err.h" +#include "trace.h" + +/* Determine default alignment. If your C++ compiler does not + like this then try something like #define DEFAULT_ALIGNMENT 8. */ +struct fooalign {char x; double d;}; +const int ALIGNMENT = ((char *)&((struct fooalign *) 0)->d - (char *)0); + +int Trace::nesting; + +/* Provide an abstraction that cuts down on the number of + calls to NEW by buffering the memory pool from which + strings are allocated. */ + +void * +operator new (size_t size) +{ + T (Trace t ("operator new");) + static char *buf_start = 0; /* Large array used to reduce calls to NEW. */ + static char *buf_end = 0; /* Indicates end of BUF_START. */ + static int buf_size = 4 * BUFSIZ; /* Size of buffer pointed to by BUF_START. */ + char *temp; + + /* Align this on correct boundaries, just to be safe... */ + size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT; + + /* If we are about to overflow our buffer we'll just grab another + chunk of memory. Since we never free the original memory it + doesn't matter that no one points to the beginning of that + chunk. Note we use a heuristic that grows the buffer either by + size of the request or by twice the previous size, whichever is + larger. */ + + if (buf_start + size >= buf_end) + { + buf_size *= 2; + if (buf_size < size) + buf_size = size; + if (buf_start = (char *)malloc (buf_size)) + buf_end = buf_start + buf_size; + else + Std_Err::report_error ("Virtual memory failed at %s, %s in function %s\n%a", __FILE__, __LINE__, "operator new", 1); + } + + temp = buf_start; + buf_start += size; + return temp; +} + +/* We need this deletion operator in order to make the linker happy. */ + +void +operator delete (void *ptr) +{ + T (Trace t ("operator delete");) + // We cannot call free here, as it doesn't match the mallocs. + // free ((char *) ptr); +} diff --git a/gnu/lib/libg++/libg++/gperf/src/options.cc b/gnu/lib/libg++/libg++/gperf/src/options.cc new file mode 100644 index 00000000000..66bde865365 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/options.cc @@ -0,0 +1,643 @@ +/* Handles parsing the Options provided to the user. + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include +#include +#include "options.h" +#include "iterator.h" + +/* Global option coordinator for the entire program. */ +Options option; + +/* Current program version. */ +extern char *version_string; + +/* Size to jump on a collision. */ +static const int DEFAULT_JUMP_VALUE = 5; + +/* Default name for generated lookup function. */ +static const char *const DEFAULT_NAME = "in_word_set"; + +/* Default name for the key component. */ +static const char *const DEFAULT_KEY = "name"; + +/* Default name for the generated class. */ +static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash"; + +/* Default name for generated hash function. */ +static const char *const DEFAULT_HASH_NAME = "hash"; + +/* Default delimiters that separate keywords from their attributes. */ +static const char *const DEFAULT_DELIMITERS = ",\n"; + +int Options::option_word; +int Options::total_switches; +int Options::total_keysig_size; +int Options::size; +int Options::key_pos; +int Options::jump; +int Options::initial_asso_value; +int Options::argument_count; +int Options::iterations; +char **Options::argument_vector; +const char *Options::function_name; +const char *Options::key_name; +const char *Options::class_name; +const char *Options::hash_name; +const char *Options::delimiters; +char Options::key_positions[MAX_KEY_POS]; + +/* Prints program usage to standard error stream. */ + +inline void +Options::usage (void) +{ + T (Trace t ("Options::usage");) + report_error ("Usage: %n [-acCdDef[num]gGhHijkKlLnNoprsStTvZ].\n" + "(type %n -h for help)\n"); +} + +/* Output command-line Options. */ + +void +Options::print_options (void) +{ + T (Trace t ("Options::print_options");) + int i; + + printf ("/* Command-line: "); + + for (i = 0; i < argument_count; i++) + printf ("%s ", argument_vector[i]); + + printf (" */"); +} + +/* Sorts the key positions *IN REVERSE ORDER!!* + This makes further routines more efficient. Especially when generating code. + Uses a simple Insertion Sort since the set is probably ordered. + Returns 1 if there are no duplicates, 0 otherwise. */ + +inline int +Options::key_sort (char *base, int len) +{ + T (Trace t ("Options::key_sort");) + int i, j; + + for (i = 0, j = len - 1; i < j; i++) + { + int curr, tmp; + + for (curr = i + 1,tmp = base[curr]; curr > 0 && tmp >= base[curr - 1]; curr--) + if ((base[curr] = base[curr - 1]) == tmp) /* oh no, a duplicate!!! */ + return 0; + + base[curr] = tmp; + } + + return 1; +} + +/* Sets the default Options. */ + +Options::Options (void) +{ + T (Trace t ("Options::Options");) + key_positions[0] = WORD_START; + key_positions[1] = WORD_END; + key_positions[2] = EOS; + total_keysig_size = 2; + delimiters = DEFAULT_DELIMITERS; + jump = DEFAULT_JUMP_VALUE; + option_word = DEFAULTCHARS | C; + function_name = DEFAULT_NAME; + key_name = DEFAULT_KEY; + hash_name = DEFAULT_HASH_NAME; + class_name = DEFAULT_CLASS_NAME; + total_switches = size = 1; + initial_asso_value = iterations = 0; +} + +/* Dumps option status when debug is set. */ + +Options::~Options (void) +{ + T (Trace t ("Options::~Options");) + if (option_word & DEBUG) + { + char *ptr; + + fprintf (stderr, "\ndumping Options:\nDEBUG is.......: %s\nORDER is.......: %s" + "\nANSI is........: %s\nTYPE is........: %s\nGNU is.........: %s" + "\nRANDOM is......: %s\nDEFAULTCHARS is: %s\nSWITCH is......: %s" + "\nPOINTER is.....: %s\nNOLENGTH is....: %s\nLENTABLE is....: %s" + "\nDUP is.........: %s\nFAST is........: %s\nCOMP is.....: %s" + "\nNOTYPE is......: %s\nGLOBAL is......: %s\nCONST is....: %s" + "\nCPLUSPLUS is...: %s\nC is...........: %s\nENUM is.....: %s" + "\niterations = %d\nlookup function name = %s\nhash function name = %s" + "\nkey name = %s\njump value = %d\nmax associcated value = %d" + "\ninitial associated value = %d\ndelimiters = %s\nnumber of switch statements = %d\n", + option_word & DEBUG ? "enabled" : "disabled", + option_word & ORDER ? "enabled" : "disabled", + option_word & ANSI ? "enabled" : "disabled", + option_word & TYPE ? "enabled" : "disabled", + option_word & GNU ? "enabled" : "disabled", + option_word & RANDOM ? "enabled" : "disabled", + option_word & DEFAULTCHARS ? "enabled" : "disabled", + option_word & SWITCH ? "enabled" : "disabled", + option_word & POINTER ? "enabled" : "disabled", + option_word & NOLENGTH ? "enabled" : "disabled", + option_word & LENTABLE ? "enabled" : "disabled", + option_word & DUP ? "enabled" : "disabled", + option_word & FAST ? "enabled" : "disabled", + option_word & COMP ? "enabled" : "disabled", + option_word & NOTYPE ? "enabled" : "disabled", + option_word & GLOBAL ? "enabled" : "disabled", + option_word & CONST ? "enabled" : "disabled", + option_word & CPLUSPLUS ? "enabled" : "disabled", + option_word & C ? "enabled" : "disabled", + option_word & ENUM ? "enabled" : "disabled", + iterations, function_name, hash_name, key_name, jump, size - 1, + initial_asso_value, delimiters, total_switches); + if (option_word & ALLCHARS) + fprintf (stderr, "all characters are used in the hash function\n"); + + fprintf (stderr, "maximum keysig size = %d\nkey positions are: \n", + total_keysig_size); + + for (ptr = key_positions; *ptr != EOS; ptr++) + if (*ptr == WORD_END) + fprintf (stderr, "$\n"); + else + fprintf (stderr, "%d\n", *ptr); + + fprintf (stderr, "finished dumping Options\n"); + } +} + + +/* Parses the command line Options and sets appropriate flags in option_word. */ + +void +Options::operator() (int argc, char *argv[]) +{ + T (Trace t ("Options::operator()");) + GetOpt getopt (argc, argv, "adcCDe:Ef:gGhH:i:j:k:K:lL:nN:oprs:S:tTvZ:"); + int option_char; + + set_program_name (argv[0]); + argument_count = argc; + argument_vector = argv; + + while ((option_char = getopt ()) != -1) + { + switch (option_char) + { + case 'a': /* Generated coded uses the ANSI prototype format. */ + { + option_word |= ANSI; + break; + } + case 'c': /* Generate strncmp rather than strcmp. */ + { + option_word |= COMP; + break; + } + case 'C': /* Make the generated tables readonly (const). */ + { + option_word |= CONST; + break; + } + case 'd': /* Enable debugging option. */ + { + option_word |= DEBUG; + report_error ("Starting program %n, version %s, with debuggin on.\n", + version_string); + break; + } + case 'D': /* Enable duplicate option. */ + { + option_word |= DUP; + break; + } + case 'e': /* Allows user to provide keyword/attribute separator */ + { + option.delimiters = getopt.optarg; + break; + } + case 'E': + { + option_word |= ENUM; + break; + } + case 'f': /* Generate the hash table ``fast.'' */ + { + option_word |= FAST; + if ((iterations = atoi (getopt.optarg)) < 0) + { + report_error ("iterations value must not be negative, assuming 0\n"); + iterations = 0; + } + break; + } + case 'g': /* Use the ``inline'' keyword for generated sub-routines. */ + { + option_word |= GNU; + break; + } + case 'G': /* Make the keyword table a global variable. */ + { + option_word |= GLOBAL; + break; + } + case 'h': /* Displays a list of helpful Options to the user. */ + { + report_error ( + "-a\tGenerate ANSI standard C output code, i.e., function prototypes.\n" + "-c\tGenerate comparison code using strncmp rather than strcmp.\n" + "-C\tMake the contents of generated lookup tables constant, i.e., readonly.\n" + "-d\tEnables the debugging option (produces verbose output to the standard error).\n" + "-D\tHandle keywords that hash to duplicate values. This is useful\n" + "\tfor certain highly redundant keyword sets. It enables the -S option.\n" + "-e\tAllow user to provide a string containing delimiters used to separate\n" + "\tkeywords from their attributes. Default is \",\\n\"\n" + "-E\tDefine constant values using an enum local to the lookup function\n" + "\trather than with defines\n" + "-f\tGenerate the gen-perf.hash function ``fast.'' This decreases GPERF's\n" + "\trunning time at the cost of minimizing generated table-size.\n" + "\tThe numeric argument represents the number of times to iterate when\n" + "\tresolving a collision. `0' means ``iterate by the number of keywords.''\n" + "-g\tAssume a GNU compiler, e.g., g++ or gcc. This makes all generated\n" + "\troutines use the ``inline'' keyword to remove cost of function calls.\n" + "-G\tGenerate the static table of keywords as a static global variable,\n" + "\trather than hiding it inside of the lookup function (which is the\n" + "\tdefault behavior).\n" + "-h\tPrints this mesage.\n" + "-H\tAllow user to specify name of generated hash function. Default\n" + "\tis `hash'.\n" + "-i\tProvide an initial value for the associate values array. Default is 0.\n" + "\tSetting this value larger helps inflate the size of the final table.\n" + "-j\tAffects the ``jump value,'' i.e., how far to advance the associated\n" + "\tcharacter value upon collisions. Must be an odd number, default is %d.\n" + "-k\tAllows selection of the key positions used in the hash function.\n" + "\tThe allowable choices range between 1-%d, inclusive. The positions\n" + "\tare separated by commas, ranges may be used, and key positions may\n" + "\toccur in any order. Also, the meta-character '*' causes the generated\n" + "\thash function to consider ALL key positions, and $ indicates the\n" + "\t``final character'' of a key, e.g., $,1,2,4,6-10.\n" + "-K\tAllow use to select name of the keyword component in the keyword structure.\n" + "-l\tCompare key lengths before trying a string comparison. This helps\n" + "\tcut down on the number of string comparisons made during the lookup.\n" + "-L\tGenerates code in the language specified by the option's argument. Languages\n" + "\thandled are currently C++ and C. The default is C.\n" + "-n\tDo not include the length of the keyword when computing the hash function\n" + "-N\tAllow user to specify name of generated lookup function. Default\n" + "\tname is `in_word_set.'\n" + "-o\tReorders input keys by frequency of occurrence of the key sets.\n" + "\tThis should decrease the search time dramatically.\n" + "-p\tChanges the return value of the generated function ``in_word_set''\n" + "\tfrom its default boolean value (i.e., 0 or 1), to type ``pointer\n" + "\tto wordlist array'' This is most useful when the -t option, allowing\n" + "\tuser-defined structs, is used.\n" + "-r\tUtilizes randomness to initialize the associated values table.\n" + "-s\tAffects the size of the generated hash table. The numeric argument\n" + "\tfor this option indicates ``how many times larger or smaller'' the associated\n" + "\tvalue range should be, in relationship to the number of keys, e.g. a value of 3\n" + "\tmeans ``allow the maximum associated value to be about 3 times larger than the\n" + "\tnumber of input keys.'' Conversely, a value of -3 means ``make the maximum\n" + "\tassociated value about 3 times smaller than the number of input keys.\n" + "\tA larger table should decrease the time required for an unsuccessful search,\n" + "\tat the expense of extra table space. Default value is 1.\n" + "-S\tCauses the generated C code to use a switch statement scheme, rather\n" + "\tthan an array lookup table. This can lead to a reduction in both\n" + "\ttime and space requirements for some keyfiles. The argument to\n" + "\tthis option determines how many switch statements are generated.\n" + "\tA value of 1 generates 1 switch containing all the elements, a value of 2\n" + "\tgenerates 2 tables with 1/2 the elements in each table, etc. This\n" + "\tis useful since many C compilers cannot correctly generate code for\n" + "\tlarge switch statements.\n" + "-t\tAllows the user to include a structured type declaration for \n" + "\tgenerated code. Any text before %%%% is consider part of the type\n" + "\tdeclaration. Key words and additional fields may follow this, one\n" + "\tgroup of fields per line.\n" + "-T\tPrevents the transfer of the type declaration to the output file.\n" + "\tUse this option if the type is already defined elsewhere.\n" + "-v\tPrints out the current version number\n" + "-Z\tAllow user to specify name of generated C++ class. Default\n" + "\tname is `Perfect_Hash.'\n%e%a", DEFAULT_JUMP_VALUE, (MAX_KEY_POS - 1), usage, 1); + } + case 'H': /* Sets the name for the hash function */ + { + hash_name = getopt.optarg; + break; + } + case 'i': /* Sets the initial value for the associated values array. */ + { + if ((initial_asso_value = atoi (getopt.optarg)) < 0) + report_error ("Initial value %d should be non-zero, ignoring and continuing.\n", initial_asso_value); + if (option[RANDOM]) + report_error ("warning, -r option superceeds -i, ignoring -i option and continuing\n"); + break; + } + case 'j': /* Sets the jump value, must be odd for later algorithms. */ + { + if ((jump = atoi (getopt.optarg)) < 0) + report_error ("Jump value %d must be a positive number.\n%e%a", jump, usage, 1); + else if (jump && even (jump)) + report_error ("Jump value %d should be odd, adding 1 and continuing...\n", jump++); + break; + } + case 'k': /* Sets key positions used for hash function. */ + { + const int BAD_VALUE = -1; + int value; + Iterator expand (getopt.optarg, 1, MAX_KEY_POS - 1, WORD_END, BAD_VALUE, EOS); + + if (*getopt.optarg == '*') /* Use all the characters for hashing!!!! */ + option_word = (option_word & ~DEFAULTCHARS) | ALLCHARS; + else + { + char *key_pos; + + for (key_pos = key_positions; (value = expand ()) != EOS; key_pos++) + if (value == BAD_VALUE) + report_error ("Illegal key value or range, use 1,2,3-%d,'$' or '*'.\n%e%a", + MAX_KEY_POS - 1, usage, 1); + else + *key_pos = value;; + + *key_pos = EOS; + + if (! (total_keysig_size = (key_pos - key_positions))) + report_error ("No keys selected.\n%e%a", usage, 1); + else if (! key_sort (key_positions, total_keysig_size)) + report_error ("Duplicate keys selected\n%e%a", usage, 1); + + if (total_keysig_size != 2 + || (key_positions[0] != 1 || key_positions[1] != WORD_END)) + option_word &= ~DEFAULTCHARS; + } + break; + } + case 'K': /* Make this the keyname for the keyword component field. */ + { + key_name = getopt.optarg; + break; + } + case 'l': /* Create length table to avoid extra string compares. */ + { + option_word |= LENTABLE; + break; + } + case 'L': /* Deal with different generated languages. */ + { + option_word &= ~C; + if (!strcmp (getopt.optarg, "C++")) + option_word |= (CPLUSPLUS | ANSI); + else if (!strcmp (getopt.optarg, "C")) + option_word |= C; + else + { + report_error ("unsupported language option %s, defaulting to C\n", getopt.optarg); + option_word |= C; + } + break; + } + case 'n': /* Don't include the length when computing hash function. */ + { + option_word |= NOLENGTH; + break; + } + case 'N': /* Make generated lookup function name be optarg */ + { + function_name = getopt.optarg; + break; + } + case 'o': /* Order input by frequency of key set occurrence. */ + { + option_word |= ORDER; + break; + } + case 'p': /* Generated lookup function now a pointer instead of int. */ + { + option_word |= POINTER; + break; + } + case 'r': /* Utilize randomness to initialize the associated values table. */ + { + option_word |= RANDOM; + if (option.initial_asso_value != 0) + report_error ("warning, -r option superceeds -i, disabling -i option and continuing\n"); + break; + } + case 's': /* Range of associated values, determines size of final table. */ + { + if (abs (size = atoi (getopt.optarg)) > 50) + report_error ("%d is excessive, did you really mean this?! (type %n -h for help)\n", size); + break; + } + case 'S': /* Generate switch statement output, rather than lookup table. */ + { + option_word |= SWITCH; + if ((option.total_switches = atoi (getopt.optarg)) <= 0) + report_error ("number of switches %s must be a positive number\n%e%a", getopt.optarg, usage, 1); + break; + } + case 't': /* Enable the TYPE mode, allowing arbitrary user structures. */ + { + option_word |= TYPE; + break; + } + case 'T': /* Don't print structure definition. */ + { + option_word |= NOTYPE; + break; + } + case 'v': /* Print out the version and quit. */ + report_error ("%n: version %s\n%e\n%a", version_string, usage, 1); + case 'Z': /* Set the class name. */ + { + class_name = getopt.optarg; + break; + } + default: + report_error ("%e%a", usage, 1); + } + + } + + if (argv[getopt.optind] && ! freopen (argv[getopt.optind], "r", stdin)) + report_error ("Cannot open keyword file %p\n%e%a", argv[getopt.optind], usage, 1); + + if (++getopt.optind < argc) + report_error ("Extra trailing arguments to %n.\n%e%a", usage, 1); +} + +#ifndef __OPTIMIZE__ + +/* TRUE if option enable, else FALSE. */ +int +Options::operator[] (Option_Type option) +{ + T (Trace t ("Options::operator[]");) + return option_word & option; +} + +/* Enables option OPT. */ +void +Options::operator= (enum Option_Type opt) +{ + T (Trace t ("Options::operator=");) + option_word |= opt; +} + +/* Disables option OPT. */ +void +Options::operator!= (enum Option_Type opt) +{ + T (Trace t ("Options::operator!=");) + option_word &= ~opt; +} + +/* Initializes the key Iterator. */ +void +Options::reset (void) +{ + T (Trace t ("Options::reset");) + key_pos = 0; +} + +/* Returns current key_position and advances index. */ +int +Options::get (void) +{ + T (Trace t ("Options::get");) + return key_positions[key_pos++]; +} + +/* Sets the size of the table size. */ +void +Options::set_asso_max (int r) +{ + T (Trace t ("Options::set_asso_max");) + size = r; +} + +/* Returns the size of the table size. */ +int +Options::get_asso_max (void) +{ + T (Trace t ("Options::get_asso_max");) + return size; +} + +/* Returns total distinct key positions. */ +int +Options::get_max_keysig_size (void) +{ + T (Trace t ("Options::get_max_keysig_size");) + return total_keysig_size; +} + +/* Sets total distinct key positions. */ +void +Options::set_keysig_size (int size) +{ + T (Trace t ("Options::set_keysig_size");) + total_keysig_size = size; +} + +/* Returns the jump value. */ +int +Options::get_jump (void) +{ + T (Trace t ("Options::get_jump");) + return jump; +} + +/* Returns the lookup function name. */ +const char * +Options::get_function_name (void) +{ + T (Trace t ("Options::get_function_name");) + return function_name; +} + +/* Returns the keyword key name. */ +const char * +Options::get_key_name (void) +{ + T (Trace t ("Options::get_key_name");) + return key_name; +} + +/* Returns the hash function name. */ +const char * +Options::get_hash_name (void) +{ + T (Trace t ("Options::get_hash_name");) + return hash_name; +} + +/* Returns the generated class name. */ +const char * +Options::get_class_name (void) +{ + T (Trace t ("Options::get_class_name");) + return class_name; +} + +/* Returns the initial associated character value. */ +int +Options::initial_value (void) +{ + T (Trace t ("Options::initial_value");) + return initial_asso_value; +} + +/* Returns the iterations value. */ +int +Options::get_iterations (void) +{ + T (Trace t ("Options::get_iterations");) + return iterations; +} + +/* Returns the string used to delimit keywords from other attributes. */ +const char * +Options::get_delimiter () +{ + T (Trace t ("Options::get_delimiter");) + return delimiters; +} + +/* Gets the total number of switch statements to generate. */ +int +Options::get_total_switches () +{ + T (Trace t ("Options::get_total_switches");) + return total_switches; +} + +#endif /* not defined __OPTIMIZE__ */ + + diff --git a/gnu/lib/libg++/libg++/gperf/src/options.h b/gnu/lib/libg++/libg++/gperf/src/options.h new file mode 100644 index 00000000000..9958a2aefa1 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/options.h @@ -0,0 +1,261 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Handles parsing the Options provided to the user. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +/* This module provides a uniform interface to the various options available + to a user of the gperf hash function generator. In addition to the + run-time options, found in the Option_Type below, there is also the + hash table Size and the Keys to be used in the hashing. + The overall design of this module was an experiment in using C++ + classes as a mechanism to enhance centralization of option and + and error handling, which tend to get out of hand in a C program. */ + +#ifndef options_h +#define options_h 1 + +#include "std-err.h" +#include "trace.h" + +/* Enumerate the potential debugging Options. */ + +enum Option_Type +{ + DEBUG = 01, /* Enable debugging (prints diagnostics to Std_Err). */ + ORDER = 02, /* Apply ordering heuristic to speed-up search time. */ + ANSI = 04, /* Generate ANSI prototypes. */ + ALLCHARS = 010, /* Use all characters in hash function. */ + GNU = 020, /* Assume GNU extensions (primarily function inline). */ + TYPE = 040, /* Handle user-defined type structured keyword input. */ + RANDOM = 0100, /* Randomly initialize the associated values table. */ + DEFAULTCHARS = 0200, /* Make default char positions be 1,$ (end of keyword). */ + SWITCH = 0400, /* Generate switch output to save space. */ + POINTER = 01000, /* Have in_word_set function return pointer, not boolean. */ + NOLENGTH = 02000, /* Don't include keyword length in hash computations. */ + LENTABLE = 04000, /* Generate a length table for string comparison. */ + DUP = 010000, /* Handle duplicate hash values for keywords. */ + FAST = 020000, /* Generate the hash function ``fast.'' */ + NOTYPE = 040000, /* Don't include user-defined type definition in output -- it's already defined elsewhere. */ + COMP = 0100000, /* Generate strncmp rather than strcmp. */ + GLOBAL = 0200000, /* Make the keyword table a global variable. */ + CONST = 0400000, /* Make the generated tables readonly (const). */ + CPLUSPLUS = 01000000, /* Generate C++ code. */ + C = 02000000, /* Generate C code. */ + ENUM = 04000000 /* Use enum for constants. */ +}; + +/* Define some useful constants (these don't really belong here, but I'm + not sure where else to put them!). These should be consts, but g++ + doesn't seem to do the right thing with them at the moment... ;-( */ + +enum +{ + MAX_KEY_POS = 128 - 1, /* Max size of each word's key set. */ + WORD_START = 1, /* Signals the start of a word. */ + WORD_END = 0, /* Signals the end of a word. */ + EOS = MAX_KEY_POS /* Signals end of the key list. */ +}; + +/* Class manager for gperf program Options. */ + +class Options : private Std_Err +{ +public: + Options (void); + ~Options (void); + int operator[] (Option_Type option); + void operator() (int argc, char *argv[]); + void operator= (enum Option_Type); + void operator!= (enum Option_Type); + static void print_options (void); + static void set_asso_max (int r); + static int get_asso_max (void); + static void reset (void); + static int get (void); + static int get_iterations (void); + static int get_max_keysig_size (void); + static void set_keysig_size (int); + static int get_jump (void); + static int initial_value (void); + static int get_total_switches (void); + static const char *get_function_name (void); + static const char *get_key_name (void); + static const char *get_class_name (void); + static const char *get_hash_name (void); + static const char *get_delimiter (void); + +private: + static int option_word; /* Holds the user-specified Options. */ + static int total_switches; /* Number of switch statements to generate. */ + static int total_keysig_size; /* Total number of distinct key_positions. */ + static int size; /* Range of the hash table. */ + static int key_pos; /* Tracks current key position for Iterator. */ + static int jump; /* Jump length when trying alternative values. */ + static int initial_asso_value; /* Initial value for asso_values table. */ + static int argument_count; /* Records count of command-line arguments. */ + static int iterations; /* Amount to iterate when a collision occurs. */ + static char **argument_vector; /* Stores a pointer to command-line vector. */ + static const char *function_name; /* Names used for generated lookup function. */ + static const char *key_name; /* Name used for keyword key. */ + static const char *class_name; /* Name used for generated C++ class. */ + static const char *hash_name; /* Name used for generated hash function. */ + static const char *delimiters; /* Separates keywords from other attributes. */ + static char key_positions[MAX_KEY_POS]; /* Contains user-specified key choices. */ + static int key_sort (char *base, int len); /* Sorts key positions in REVERSE order. */ + static void usage (void); /* Prints proper program usage. */ +}; + +/* Global option coordinator for the entire program. */ +extern Options option; + +/* Set to 1 if your want to stack-allocate some large arrays. */ +#ifndef LARGE_STACK_ARRAYS +#define LARGE_STACK_ARRAYS 0 +#endif + +#ifdef __OPTIMIZE__ + +inline int +Options::operator[] (Option_Type option) /* True if option enable, else false. */ +{ + T (Trace t ("Options::operator[]");) + return option_word & option; +} + +inline void +Options::operator = (enum Option_Type opt) /* Enables option OPT. */ +{ + option_word |= opt; +} + +inline void +Options::operator != (enum Option_Type opt) /* Disables option OPT. */ +{ + option_word &= ~opt; +} + +inline void +Options::reset (void) /* Initializes the key Iterator. */ +{ + T (Trace t ("Options::reset");) + key_pos = 0; +} + +inline int +Options::get (void) /* Returns current key_position and advanced index. */ +{ + T (Trace t ("Options::get");) + return key_positions[key_pos++]; +} + +inline void +Options::set_asso_max (int r) /* Sets the size of the table size. */ +{ + T (Trace t ("Options::set_asso_max");) + size = r; +} + +inline int +Options::get_asso_max (void) /* Returns the size of the table size. */ +{ + T (Trace t ("Options::get_asso_max");) + return size; +} + +inline int +Options::get_max_keysig_size (void) /* Returns total distinct key positions. */ +{ + T (Trace t ("Options::get_max_keysig_size");) + return total_keysig_size; +} + +inline void +Options::set_keysig_size (int size) /* Sets total distinct key positions. */ +{ + T (Trace t ("Options::set_keysig_size");) + total_keysig_size = size; +} + +inline int +Options::get_jump (void) /* Returns the jump value. */ +{ + T (Trace t ("Options::get_jump");) + return jump; +} + +inline const char * +Options::get_function_name (void) /* Returns the generated function name. */ +{ + T (Trace t ("Options::get_function_name");) + return function_name; +} + +inline const char * +Options::get_key_name (void) /* Returns the keyword key name. */ +{ + T (Trace t ("Options::get_key_name");) + return key_name; +} + +inline const char * +Options::get_hash_name (void) /* Returns the hash function name. */ +{ + T (Trace t ("Options::get_hash_name");) + return hash_name; +} + +inline const char * +Options::get_class_name (void) /* Returns the generated class name. */ +{ + T (Trace t ("Options::get_class_name");) + return class_name; +} + +inline int +Options::initial_value (void) /* Returns the initial associated character value. */ +{ + T (Trace t ("Options::initial_value");) + return initial_asso_value; +} + +inline int +Options::get_iterations (void) /* Returns the iterations value. */ +{ + T (Trace t ("Options::get_iterations");) + return iterations; +} + +inline const char * +Options::get_delimiter () /* Returns the string used to delimit keywords from other attributes. */ +{ + T (Trace t ("Options::get_delimiter");) + return delimiters; +} + +inline int +Options::get_total_switches () /* Gets the total number of switch statements to generate. */ +{ + T (Trace t ("Options::get_total_switches");) + return total_switches; +} +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/read-line.cc b/gnu/lib/libg++/libg++/gperf/src/read-line.cc new file mode 100644 index 00000000000..2e3fadf62e7 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/read-line.cc @@ -0,0 +1,98 @@ +/* Correctly reads an arbitrarily size string. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include "std-err.h" +#include "read-line.h" +#include "options.h" + +/* Recursively fills up the buffer. */ + +char * +Read_Line::readln_aux (int chunks) +{ + T (Trace t ("Read_Line::readln_aux");) +#if LARGE_STACK_ARRAYS + char buf[CHUNK_SIZE]; +#else + // Note: we don't use new, because that invokes a custom operator new. + char *buf = (char*)malloc(CHUNK_SIZE); + if (buf == NULL) + abort (); +#endif + char *bufptr = buf; + char *ptr; + int c; + + while ((c = getc (fp)) != EOF && c != '\n') /* fill the current buffer */ + { + *bufptr++ = c; + if (bufptr - buf >= CHUNK_SIZE) /* prepend remainder to ptr buffer */ + { + if (ptr = readln_aux (chunks + 1)) + + for (; bufptr != buf; *--ptr = *--bufptr); + + goto done; + } + } + if (c == EOF && bufptr == buf) + ptr = NULL; + else + { + c = chunks * CHUNK_SIZE + bufptr - buf + 1; + ptr = new char[c]; + + for (*(ptr += (c - 1)) = '\0'; bufptr != buf; *--ptr = *--bufptr) + ; + } + done: +#if !LARGE_STACK_ARRAYS + free (buf); +#endif + + return ptr; +} + +#ifndef __OPTIMIZE__ + +/* Returns the ``next'' line, ignoring comments beginning with '#'. */ + +char * +Read_Line::get_line (void) +{ + T (Trace t ("Read_Line::get_line");) + int c; + + if ((c = getc (fp)) == '#') + { + while ((c = getc (fp)) != '\n' && c != EOF) + ; + + return c != EOF ? get_line () : 0; + } + else + { + ungetc (c, stdin); + return readln_aux (0); + } +} +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/read-line.h b/gnu/lib/libg++/libg++/gperf/src/read-line.h new file mode 100644 index 00000000000..4c40917c587 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/read-line.h @@ -0,0 +1,68 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Reads arbitrarily long string from input file, returning it as a dynamic buffer. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +/* Returns a pointer to an arbitrary length string. Returns NULL on error or EOF + The storage for the string is dynamically allocated by new. */ + +#ifndef read_line_h +#define read_line_h 1 + +#include +#include "trace.h" + +class Read_Line +{ +private: + char *readln_aux (int chunks); + FILE *fp; /* FILE pointer to the input stream. */ + const int CHUNK_SIZE; /* Size of each chunk. */ + +public: + Read_Line (FILE *stream = stdin, int size = BUFSIZ): + fp (stream), CHUNK_SIZE (size) {;} + char *get_line (void); +}; + +#ifdef __OPTIMIZE__ +inline char * +Read_Line::get_line (void) +{ + T (Trace t ("Read_Line::get_line");) + int c; + + if ((c = getc (fp)) == '#') + { + while (getc (fp) != '\n') + ; + + return get_line (); + } + else + { + ungetc (c, stdin); + return readln_aux (0); + } +} +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/std-err.cc b/gnu/lib/libg++/libg++/gperf/src/std-err.cc new file mode 100644 index 00000000000..c45ae72a5ce --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/std-err.cc @@ -0,0 +1,86 @@ +/* Provides a useful variable-length argument error handling abstraction. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include +#include +#include +#include "std-err.h" +#include "trace.h" + +#include +#ifndef errno +extern int errno; +#endif + +char * Std_Err::program_name; + +/* Sets name of program. */ + +void +Std_Err::set_program_name (char *prog_name) +{ + T (Trace t ("Std_Err::set_program_name");) + program_name = prog_name; +} + +/* Valid Options (prefixed by '%', as in printf format strings) include: + 'a': exit the program at this point (var-argument is the exit status!) + 'c': print a character + 'd': print a decimal number + 'e': call the function pointed to by the corresponding argument + 'f','g': print a double + 'n': print the name of the program (NULL if not set in constructor or elsewhere) + 'p': print out the appropriate errno value from sys_errlist + 's': print out a character string + '%': print out a single percent sign, '%' */ + +void +Std_Err::report_error (char *format, ...) +{ + T (Trace t ("Std_Err::report_error");) + typedef void (*PTF)(); + va_list argp; + + va_start (argp, format); + for ( ; *format; format++) + { + if (*format != '%') + putc (*format, stderr); + else + { + switch (*++format) + { + case '%' : putc ('%', stderr); break; + case 'a' : exit (va_arg (argp, int)); + case 'c' : putc (va_arg (argp, int), stderr); break; + case 'd' : fprintf (stderr, "%d", va_arg (argp, int)); break; + case 'e' : (*va_arg (argp, PTF))(); break; + case 'f' : fprintf (stderr, "%g", va_arg (argp, double)); break; + case 'n' : fputs (program_name ? program_name : "error", stderr); break; + case 'p' : fprintf (stderr, "%s: %s", va_arg (argp, char *), + strerror (errno)); + break; + case 's' : fputs (va_arg (argp, char *), stderr); break; + } + } + } + va_end (argp); +} diff --git a/gnu/lib/libg++/libg++/gperf/src/std-err.h b/gnu/lib/libg++/libg++/gperf/src/std-err.h new file mode 100644 index 00000000000..866851598d9 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/std-err.h @@ -0,0 +1,37 @@ +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Provides a useful variable-length argument error handling abstraction. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#ifndef std_err_h +#define std_err_h 1 + +class Std_Err +{ +private: + static char *program_name; /* Records the program name. */ + +public: + static void set_program_name (char *prog_name); + static void report_error (char *format, ...); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/trace.h b/gnu/lib/libg++/libg++/gperf/src/trace.h new file mode 100644 index 00000000000..650fa5a40ad --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/trace.h @@ -0,0 +1,20 @@ +#ifndef trace_h +#define trace_h 1 + +#ifdef TRACE +#define T(X) X +#else +#define T(X) +#endif + +class Trace +{ +private: + static int nesting; + char *name; +public: + Trace (char *n) { fprintf (stderr, "%*scalling %s\n", 3 * nesting++, "", name = n); } + ~Trace (void) { fprintf (stderr, "%*sleaving %s\n", 3 * --nesting, "", name); } +}; + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/vectors.h b/gnu/lib/libg++/libg++/gperf/src/vectors.h new file mode 100644 index 00000000000..15b773dc304 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/vectors.h @@ -0,0 +1,38 @@ +#include + +/* This may look like C code, but it is really -*- C++ -*- */ + +/* Static class data members that are shared between several classes via + inheritance. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#ifndef vectors_h +#define vectors_h 1 + +static const int ALPHA_SIZE = 128; + +struct Vectors +{ + static int occurrences[ALPHA_SIZE]; /* Counts occurrences of each key set character. */ + static int asso_values[ALPHA_SIZE]; /* Value associated with each character. */ +}; + +#endif diff --git a/gnu/lib/libg++/libg++/gperf/src/version.cc b/gnu/lib/libg++/libg++/gperf/src/version.cc new file mode 100644 index 00000000000..e96c5c787e9 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/src/version.cc @@ -0,0 +1,23 @@ +#include +/* Current program version number. + + Copyright (C) 1989 Free Software Foundation, Inc. + written by Douglas C. Schmidt (schmidt@ics.uci.edu) + +This file is part of GNU GPERF. + +GNU GPERF is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU GPERF is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +char *version_string = "2.5 (GNU C++ version)"; diff --git a/gnu/lib/libg++/libg++/gperf/tests/Makefile.in b/gnu/lib/libg++/libg++/gperf/tests/Makefile.in new file mode 100644 index 00000000000..f702fc804f2 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/Makefile.in @@ -0,0 +1,72 @@ +# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc. +# written by Douglas C. Schmidt (schmidt@ics.uci.edu) +# +# This file is part of GNU GPERF. +# +# GNU GPERF is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GNU GPERF is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 GPERF; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +GPERF = ../src/gperf + +check: + @echo "performing some tests of the perfect hash generator" + $(CC) -c $(CFLAGS) $(srcdir)/test.c + $(GPERF) -p -c -l -S1 -o $(srcdir)/c.gperf > cinset.c + $(CC) $(CFLAGS) -o cout cinset.c test.o + @echo "testing ANSI C reserved words, all items should be found in the set" + ./cout -v < $(srcdir)/c.gperf > c.out + -diff -b $(srcdir)/c.exp c.out + $(GPERF) -k1,4,'$$' $(srcdir)/ada.gperf > adainset.c +# double '$$' is only there since make gets confused; programn wants only 1 '$' + $(CC) $(CFLAGS) -o aout adainset.c test.o + @echo "testing Ada reserved words, all items should be found in the set" + ./aout -v < $(srcdir)/ada.gperf > ada-res.out + -diff -b $(srcdir)/ada-res.exp ada-res.out + $(GPERF) -p -D -k1,'$$' -s 2 -o $(srcdir)/adadefs.gperf > preinset.c + $(CC) $(CFLAGS) -o preout preinset.c test.o + @echo "testing Ada predefined words, all items should be found in the set" + ./preout -v < $(srcdir)/adadefs.gperf > ada-pred.out + -diff -b $(srcdir)/ada-pred.exp ada-pred.out + $(GPERF) -k1,2,'$$' -o $(srcdir)/modula3.gperf > m3inset.c + $(CC) $(CFLAGS) -o m3out m3inset.c test.o + @echo "testing Modula3 reserved words, all items should be found in the set" + ./m3out -v < $(srcdir)/modula3.gperf > modula.out + -diff -b $(srcdir)/modula.exp modula.out + $(GPERF) -o -S2 -p < $(srcdir)/pascal.gperf > pinset.c + $(CC) $(CFLAGS) -o pout pinset.c test.o + @echo "testing Pascal reserved words, all items should be found in the set" + ./pout -v < $(srcdir)/pascal.gperf > pascal.out + -diff -b $(srcdir)/pascal.exp pascal.out +# these next 5 are demos that show off the generated code + $(GPERF) -p -j1 -g -o -t -N is_reserved_word -k1,3,'$$' < $(srcdir)/c-parse.gperf > test-1.out + -diff -b $(srcdir)/test-1.exp test-1.out + $(GPERF) -n -k1-8 -l <$(srcdir)/modula2.gperf > test-2.out + -diff -b $(srcdir)/test-2.exp test-2.out + $(GPERF) -p -j 1 -o -a -C -g -t -k1,4,$$ < $(srcdir)/gplus.gperf > test-3.out + -diff -b $(srcdir)/test-3.exp test-3.out + $(GPERF) -D -p -t < $(srcdir)/c-parse.gperf > test-4.out + -diff -b $(srcdir)/test-4.exp test-4.out + $(GPERF) -g -o -j1 -t -p -N is_reserved_word < $(srcdir)/gpc.gperf > test-5.out + -diff -b $(srcdir)/test-5.exp test-5.out +# prints out the help message + -$(GPERF) -h > test-6.out 2>&1 || [ a = a ] + -diff -b $(srcdir)/test-6.exp test-6.out + @echo "only if, do, for, case, goto, else, while, and return should be found " + ./aout -v < $(srcdir)/c.gperf > test-7.out + -diff -b $(srcdir)/test-7.exp test-7.out diff --git a/gnu/lib/libg++/libg++/gperf/tests/ada-pred.exp b/gnu/lib/libg++/libg++/gperf/tests/ada-pred.exp new file mode 100644 index 00000000000..33caaa32ea1 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/ada-pred.exp @@ -0,0 +1,54 @@ +in word set boolean +in word set character +in word set constraint_error +in word set false +in word set float +in word set integer +in word set natural +in word set numeric_error +in word set positive +in word set program_error +in word set storage_error +in word set string +in word set tasking_error +in word set true +in word set address +in word set aft +in word set base +in word set callable +in word set constrained +in word set count +in word set delta +in word set digits +in word set emax +in word set epsilon +in word set first +in word set firstbit +in word set fore +in word set image +in word set large +in word set last +in word set lastbit +in word set length +in word set machine_emax +in word set machine_emin +in word set machine_mantissa +in word set machine_overflows +in word set machine_radix +in word set machine_rounds +in word set mantissa +in word set pos +in word set position +in word set pred +in word set range +in word set safe_emax +in word set safe_large +in word set safe_small +in word set size +in word set small +in word set storage_size +in word set succ +in word set terminated +in word set val +in word set value +in word set width diff --git a/gnu/lib/libg++/libg++/gperf/tests/ada-res.exp b/gnu/lib/libg++/libg++/gperf/tests/ada-res.exp new file mode 100644 index 00000000000..8134fe861f5 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/ada-res.exp @@ -0,0 +1,63 @@ +in word set else +in word set exit +in word set terminate +in word set type +in word set raise +in word set range +in word set reverse +in word set declare +in word set end +in word set record +in word set exception +in word set not +in word set then +in word set return +in word set separate +in word set select +in word set digits +in word set renames +in word set subtype +in word set elsif +in word set function +in word set for +in word set package +in word set procedure +in word set private +in word set while +in word set when +in word set new +in word set entry +in word set delay +in word set case +in word set constant +in word set at +in word set abort +in word set accept +in word set and +in word set delta +in word set access +in word set abs +in word set pragma +in word set array +in word set use +in word set out +in word set do +in word set others +in word set of +in word set or +in word set all +in word set limited +in word set loop +in word set null +in word set task +in word set in +in word set is +in word set if +in word set rem +in word set mod +in word set begin +in word set body +in word set xor +in word set goto +in word set generic +in word set with diff --git a/gnu/lib/libg++/libg++/gperf/tests/ada.gperf b/gnu/lib/libg++/libg++/gperf/tests/ada.gperf new file mode 100644 index 00000000000..332bdc740ad --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/ada.gperf @@ -0,0 +1,63 @@ +else +exit +terminate +type +raise +range +reverse +declare +end +record +exception +not +then +return +separate +select +digits +renames +subtype +elsif +function +for +package +procedure +private +while +when +new +entry +delay +case +constant +at +abort +accept +and +delta +access +abs +pragma +array +use +out +do +others +of +or +all +limited +loop +null +task +in +is +if +rem +mod +begin +body +xor +goto +generic +with diff --git a/gnu/lib/libg++/libg++/gperf/tests/adadefs.gperf b/gnu/lib/libg++/libg++/gperf/tests/adadefs.gperf new file mode 100644 index 00000000000..875be69abc9 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/adadefs.gperf @@ -0,0 +1,54 @@ +boolean +character +constraint_error +false +float +integer +natural +numeric_error +positive +program_error +storage_error +string +tasking_error +true +address +aft +base +callable +constrained +count +delta +digits +emax +epsilon +first +firstbit +fore +image +large +last +lastbit +length +machine_emax +machine_emin +machine_mantissa +machine_overflows +machine_radix +machine_rounds +mantissa +pos +position +pred +range +safe_emax +safe_large +safe_small +size +small +storage_size +succ +terminated +val +value +width diff --git a/gnu/lib/libg++/libg++/gperf/tests/c++.gperf b/gnu/lib/libg++/libg++/gperf/tests/c++.gperf new file mode 100644 index 00000000000..650d32d0edd --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/c++.gperf @@ -0,0 +1,47 @@ +asm +auto +break +case +catch +char +class +const +continue +default +delete +do +double +else +enum +extern +float +for +friend +goto +if +inline +int +long +new +operator +overload +private +protected +public +register +return +short +signed +sizeof +static +struct +switch +template +this +typedef +union +unsigned +virtual +void +volatile +while diff --git a/gnu/lib/libg++/libg++/gperf/tests/c-parse.gperf b/gnu/lib/libg++/libg++/gperf/tests/c-parse.gperf new file mode 100644 index 00000000000..feef59babb0 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/c-parse.gperf @@ -0,0 +1,56 @@ +%{ +/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */ +%} +struct resword { char *name; short token; enum rid rid; }; +%% +__alignof, ALIGNOF, NORID +__alignof__, ALIGNOF, NORID +__asm, ASM, NORID +__asm__, ASM, NORID +__attribute, ATTRIBUTE, NORID +__attribute__, ATTRIBUTE, NORID +__const, TYPE_QUAL, RID_CONST +__const__, TYPE_QUAL, RID_CONST +__inline, SCSPEC, RID_INLINE +__inline__, SCSPEC, RID_INLINE +__signed, TYPESPEC, RID_SIGNED +__signed__, TYPESPEC, RID_SIGNED +__typeof, TYPEOF, NORID +__typeof__, TYPEOF, NORID +__volatile, TYPE_QUAL, RID_VOLATILE +__volatile__, TYPE_QUAL, RID_VOLATILE +asm, ASM, NORID +auto, SCSPEC, RID_AUTO +break, BREAK, NORID +case, CASE, NORID +char, TYPESPEC, RID_CHAR +const, TYPE_QUAL, RID_CONST +continue, CONTINUE, NORID +default, DEFAULT, NORID +do, DO, NORID +double, TYPESPEC, RID_DOUBLE +else, ELSE, NORID +enum, ENUM, NORID +extern, SCSPEC, RID_EXTERN +float, TYPESPEC, RID_FLOAT +for, FOR, NORID +goto, GOTO, NORID +if, IF, NORID +inline, SCSPEC, RID_INLINE +int, TYPESPEC, RID_INT +long, TYPESPEC, RID_LONG +register, SCSPEC, RID_REGISTER +return, RETURN, NORID +short, TYPESPEC, RID_SHORT +signed, TYPESPEC, RID_SIGNED +sizeof, SIZEOF, NORID +static, SCSPEC, RID_STATIC +struct, STRUCT, NORID +switch, SWITCH, NORID +typedef, SCSPEC, RID_TYPEDEF +typeof, TYPEOF, NORID +union, UNION, NORID +unsigned, TYPESPEC, RID_UNSIGNED +void, TYPESPEC, RID_VOID +volatile, TYPE_QUAL, RID_VOLATILE +while, WHILE, NORID diff --git a/gnu/lib/libg++/libg++/gperf/tests/c.exp b/gnu/lib/libg++/libg++/gperf/tests/c.exp new file mode 100644 index 00000000000..10c8b7f6116 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/c.exp @@ -0,0 +1,32 @@ +in word set if +in word set do +in word set int +in word set for +in word set case +in word set char +in word set auto +in word set goto +in word set else +in word set long +in word set void +in word set enum +in word set float +in word set short +in word set union +in word set break +in word set while +in word set const +in word set double +in word set static +in word set extern +in word set struct +in word set return +in word set sizeof +in word set switch +in word set signed +in word set typedef +in word set default +in word set unsigned +in word set continue +in word set register +in word set volatile diff --git a/gnu/lib/libg++/libg++/gperf/tests/c.gperf b/gnu/lib/libg++/libg++/gperf/tests/c.gperf new file mode 100644 index 00000000000..8672d6c25ed --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/c.gperf @@ -0,0 +1,32 @@ +if +do +int +for +case +char +auto +goto +else +long +void +enum +float +short +union +break +while +const +double +static +extern +struct +return +sizeof +switch +signed +typedef +default +unsigned +continue +register +volatile diff --git a/gnu/lib/libg++/libg++/gperf/tests/configure.in b/gnu/lib/libg++/libg++/gperf/tests/configure.in new file mode 100644 index 00000000000..d93c7bb1840 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/configure.in @@ -0,0 +1,26 @@ +# 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. + +configdirs="" +srctrigger=c-parse.gperf +srcname="test perfect hash function generator" + +target_makefile_frag=../../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../../ +ALL='$(NOTHING)' +CHECK=check +MOSTLYCLEAN='*.o \#* core *inset.c output.* *.out aout cout m3out pout preout' + +(. ${srcdir}/../../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/gperf/tests/gpc.gperf b/gnu/lib/libg++/libg++/gperf/tests/gpc.gperf new file mode 100644 index 00000000000..8fb469e46bc --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/gpc.gperf @@ -0,0 +1,48 @@ +%{ +/* ISO Pascal 7185 reserved words. + * + * For GNU Pascal compiler (GPC) by jtv@hut.fi + * + * run this through the Doug Schmidt's gperf program + * with command + * gperf -g -o -j1 -t -p -N is_reserved_word + * + */ +%} +struct resword { char *name; short token; short iclass;}; +%% +And, AND, PASCAL_ISO +Array, ARRAY, PASCAL_ISO +Begin, BEGIN_, PASCAL_ISO +Case, CASE, PASCAL_ISO +Const, CONST, PASCAL_ISO +Div, DIV, PASCAL_ISO +Do, DO, PASCAL_ISO +Downto, DOWNTO, PASCAL_ISO +Else, ELSE, PASCAL_ISO +End, END, PASCAL_ISO +File, FILE_, PASCAL_ISO +For, FOR, PASCAL_ISO +Function, FUNCTION, PASCAL_ISO +Goto, GOTO, PASCAL_ISO +If, IF, PASCAL_ISO +In, IN, PASCAL_ISO +Label, LABEL, PASCAL_ISO +Mod, MOD, PASCAL_ISO +Nil, NIL, PASCAL_ISO +Not, NOT, PASCAL_ISO +Of, OF, PASCAL_ISO +Or, OR, PASCAL_ISO +Packed, PACKED, PASCAL_ISO +Procedure, PROCEDURE, PASCAL_ISO +Program,PROGRAM,PASCAL_ISO +Record, RECORD, PASCAL_ISO +Repeat, REPEAT, PASCAL_ISO +Set, SET, PASCAL_ISO +Then, THEN, PASCAL_ISO +To, TO, PASCAL_ISO +Type, TYPE, PASCAL_ISO +Until, UNTIL, PASCAL_ISO +Var, VAR, PASCAL_ISO +While, WHILE, PASCAL_ISO +With, WITH, PASCAL_ISO diff --git a/gnu/lib/libg++/libg++/gperf/tests/gplus.gperf b/gnu/lib/libg++/libg++/gperf/tests/gplus.gperf new file mode 100644 index 00000000000..4a93315be52 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/gplus.gperf @@ -0,0 +1,76 @@ +%{ +/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */ +%} +struct resword { char *name; short token; enum rid rid;}; +%% +__alignof, ALIGNOF, NORID +__alignof__, ALIGNOF, NORID +__asm, ASM, NORID +__asm__, ASM, NORID +__attribute, ATTRIBUTE, NORID +__attribute__, ATTRIBUTE, NORID +__const, TYPE_QUAL, RID_CONST +__const__, TYPE_QUAL, RID_CONST +__inline, SCSPEC, RID_INLINE +__inline__, SCSPEC, RID_INLINE +__signed, TYPESPEC, RID_SIGNED +__signed__, TYPESPEC, RID_SIGNED +__typeof, TYPEOF, NORID +__typeof__, TYPEOF, NORID +__volatile, TYPE_QUAL, RID_VOLATILE +__volatile__, TYPE_QUAL, RID_VOLATILE +all, ALL, NORID /* Extension */, +except, EXCEPT, NORID /* Extension */, +exception, AGGR, RID_EXCEPTION /* Extension */, +raise, RAISE, NORID /* Extension */, +raises, RAISES, NORID /* Extension */, +reraise, RERAISE, NORID /* Extension */, +try, TRY, NORID /* Extension */, +asm, ASM, NORID, +auto, SCSPEC, RID_AUTO, +break, BREAK, NORID, +case, CASE, NORID, +catch, CATCH, NORID, +char, TYPESPEC, RID_CHAR, +class, AGGR, RID_CLASS, +const, TYPE_QUAL, RID_CONST, +continue, CONTINUE, NORID, +default, DEFAULT, NORID, +delete, DELETE, NORID, +do, DO, NORID, +double, TYPESPEC, RID_DOUBLE, +dynamic, DYNAMIC, NORID, +else, ELSE, NORID, +enum, ENUM, NORID, +extern, SCSPEC, RID_EXTERN, +float, TYPESPEC, RID_FLOAT, +for, FOR, NORID, +friend, SCSPEC, RID_FRIEND, +goto, GOTO, NORID, +if, IF, NORID, +inline, SCSPEC, RID_INLINE, +int, TYPESPEC, RID_INT, +long, TYPESPEC, RID_LONG, +new, NEW, NORID, +operator, OPERATOR, NORID, +overload, OVERLOAD, NORID, +private, PRIVATE, NORID, +protected, PROTECTED, NORID, +public, PUBLIC, NORID, +register, SCSPEC, RID_REGISTER, +return, RETURN, NORID, +short, TYPESPEC, RID_SHORT, +signed, TYPESPEC, RID_SIGNED, +sizeof, SIZEOF, NORID, +static, SCSPEC, RID_STATIC, +struct, AGGR, RID_RECORD, +switch, SWITCH, NORID, +this, THIS, NORID, +typedef, SCSPEC, RID_TYPEDEF, +typeof, TYPEOF, NORID, +union, AGGR, RID_UNION, +unsigned, TYPESPEC, RID_UNSIGNED, +virtual, SCSPEC, RID_VIRTUAL, +void, TYPESPEC, RID_VOID, +volatile, TYPE_QUAL, RID_VOLATILE, +while, WHILE, NORID, diff --git a/gnu/lib/libg++/libg++/gperf/tests/irc.gperf b/gnu/lib/libg++/libg++/gperf/tests/irc.gperf new file mode 100644 index 00000000000..afe53c59e7d --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/irc.gperf @@ -0,0 +1,63 @@ +%{ +extern int m_text(), m_private(), m_who(), m_whois(), m_user(), m_list(); +extern int m_topic(), m_invite(), m_channel(), m_version(), m_quit(); +extern int m_server(), m_kill(), m_info(), m_links(), m_summon(), m_stats(); +extern int m_users(), m_nick(), m_error(), m_help(), m_whoreply(); +extern int m_squit(), m_restart(), m_away(), m_die(), m_connect(); +extern int m_ping(), m_pong(), m_oper(), m_pass(), m_wall(), m_trace(); +extern int m_time(), m_rehash(), m_names(), m_namreply(), m_admin(); +extern int m_linreply(), m_notice(), m_lusers(), m_voice(), m_grph(); +extern int m_xtra(), m_motd(); +%} +struct Message { + char *cmd; + int (* func)(); + int count; + int parameters; +}; +%% +NICK, m_nick, 0, 1 +MSG, m_text, 0, 1 +PRIVMSG, m_private, 0, 2 +WHO, m_who, 0, 1 +WHOIS, m_whois, 0, 4 +USER, m_user, 0, 4 +SERVER, m_server, 0, 2 +LIST, m_list, 0, 1 +TOPIC, m_topic, 0, 1 +INVITE, m_invite, 0, 2 +CHANNEL, m_channel, 0, 1 +VERSION, m_version, 0, 1 +QUIT, m_quit, 0, 2 +SQUIT, m_squit, 0, 2 +KILL, m_kill, 0, 2 +INFO, m_info, 0, 1 +LINKS, m_links, 0, 1 +SUMMON, m_summon, 0, 1 +STATS, m_stats, 0, 1 +USERS, m_users, 0, 1 +RESTART, m_restart, 0, 1 +WHOREPLY,m_whoreply, 0, 7 +HELP, m_help, 0, 2 +ERROR, m_error, 0, 1 +AWAY, m_away, 0, 1 +DIE, m_die, 0, 1 +CONNECT, m_connect, 0, 3 +PING, m_ping, 0, 2 +PONG, m_pong, 0, 3 +OPER, m_oper, 0, 3 +PASS, m_pass, 0, 2 +WALL, m_wall, 0, 1 +TIME, m_time, 0, 1 +REHASH, m_rehash, 0, 1 +NAMES, m_names, 0, 1 +NAMREPLY,m_namreply, 0, 3 +ADMIN, m_admin, 0, 1 +TRACE, m_trace, 0, 1 +LINREPLY,m_linreply, 0, 2 +NOTICE, m_notice, 0, 2 +LUSERS, m_lusers, 0, 1 +VOICE, m_voice, 0, 2 +GRPH, m_grph, 0, 2 +XTRA, m_xtra, 0, 2 +MOTD, m_motd, 0, 2 diff --git a/gnu/lib/libg++/libg++/gperf/tests/makeinfo.gperf b/gnu/lib/libg++/libg++/gperf/tests/makeinfo.gperf new file mode 100644 index 00000000000..1488b8e38fb --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/makeinfo.gperf @@ -0,0 +1,116 @@ +COMMAND; +%% +!, cm_force_sentence_end, false +', insert_self, false +*, cm_asterisk, false +., cm_force_sentence_end, false +:, cm_force_abbreviated_whitespace, false +?, cm_force_sentence_end, false +@, insert_self, false +TeX, cm_TeX, true +`, insert_self, false +appendix, cm_appendix, false +appendixsec, cm_appendixsec, false +appendixsubsec, cm_appendixsubsec, false +asis, cm_asis, true +b, cm_bold, true +br, cm_br, false +bullet, cm_bullet, true +bye, cm_bye, false +c, cm_comment, false +center, cm_center, false +chapter, cm_chapter, false +cindex, cm_cindex, false +cite, cm_cite, true +code, cm_code, true +comment, cm_comment, false +contents, do_nothing, false +copyright, cm_copyright, true +ctrl, cm_ctrl, true +defcodeindex, cm_defindex, false +defindex, cm_defindex, false +dfn, cm_dfn, true +display, cm_display, false +dots, cm_dots, true +emph, cm_emph, true +end, cm_end, false +enumerate, cm_enumerate, false +equiv, cm_equiv, true +error, cm_error, true +example, cm_example, false +exdent, cm_exdent, false +expansion, cm_expansion, true +file, cm_file, true +findex, cm_findex, false +format, cm_format, false +group, cm_group, false +i, cm_italic, true +iappendix, cm_appendix, false +iappendixsec, cm_appendixsec, false +iappendixsubsec, cm_appendixsubsec, false +ichapter, cm_chapter, false +ifinfo, cm_ifinfo, false +iftex, cm_iftex, false +ignore, cm_ignore, false +include, cm_include, false +inforef, cm_inforef, true +input, cm_include, false +isection, cm_section, false +isubsection, cm_subsection, false +isubsubsection, cm_subsubsection, false +item, cm_item, false +itemize, cm_itemize, false +itemx, cm_itemx, false +iunnumbered, cm_unnumbered, false +iunnumberedsec, cm_unnumberedsec, false +iunnumberedsubsec, cm_unnumberedsubsec, false +kbd, cm_kbd, true +key, cm_key, true +kindex, cm_kindex, false +lisp, cm_lisp, false +menu, cm_menu +minus, cm_minus, true +need, cm_need, false +node, cm_node, false +noindent, cm_noindent, false +page, do_nothing, false +pindex, cm_pindex, false +point, cm_point, true +print, cm_print, true +printindex, cm_printindex, false +pxref, cm_pxref, true +quotation, cm_quotation, false +r, cm_roman, true +ref, cm_xref, true +refill, cm_refill, false +result, cm_result, true +samp, cm_samp, true +sc, cm_sc, true +section, cm_section, false +setchapternewpage, cm_setchapternewpage, false +setfilename, cm_setfilename, false +settitle, cm_settitle, false +smallexample, cm_smallexample, false +sp, cm_sp, false +strong, cm_strong, true +subsection, cm_subsection, false +subsubsection, cm_subsubsection, false +summarycontents, do_nothing, false +syncodeindex, cm_synindex, false +synindex, cm_synindex, false +t, cm_title, true +table, cm_table, false +tex, cm_tex, false +tindex, cm_tindex, false +titlepage, cm_titlepage, false +unnumbered, cm_unnumbered, false +unnumberedsec, cm_unnumberedsec, false +unnumberedsubsec, cm_unnumberedsubsec, false +var, cm_var, true +vindex, cm_vindex, false +w, cm_w, true +xref, cm_xref, true +{, insert_self, false +}, insert_self, false +infoinclude, cm_infoinclude, false +footnote, cm_footnote, false diff --git a/gnu/lib/libg++/libg++/gperf/tests/modula.exp b/gnu/lib/libg++/libg++/gperf/tests/modula.exp new file mode 100644 index 00000000000..cef7d5acad8 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/modula.exp @@ -0,0 +1,106 @@ +in word set AND +in word set ARRAY +in word set BEGIN +in word set BITS +in word set BY +in word set CASE +in word set CONST +in word set DIV +in word set DO +in word set ELSE +in word set ELSIF +in word set END +in word set EVAL +in word set EXCEPT +in word set EXCEPTION +in word set EXIT +in word set EXPORTS +in word set FINALLY +in word set FOR +in word set FROM +in word set IF +in word set IMPORT +in word set INTERFACE +in word set IN +in word set INLINE +in word set LOCK +in word set METHODS +in word set MOD +in word set MODULE +in word set NOT +in word set OBJECT +in word set OF +in word set OR +in word set PROCEDURE +in word set RAISES +in word set READONLY +in word set RECORD +in word set REF +in word set REPEAT +in word set RETURN +in word set SET +in word set THEN +in word set TO +in word set TRY +in word set TYPE +in word set TYPECASE +in word set UNSAFE +in word set UNTIL +in word set UNTRACED +in word set VALUE +in word set VAR +in word set WHILE +in word set WITH +in word set and +in word set array +in word set begin +in word set bits +in word set by +in word set case +in word set const +in word set div +in word set do +in word set else +in word set elsif +in word set end +in word set eval +in word set except +in word set exception +in word set exit +in word set exports +in word set finally +in word set for +in word set from +in word set if +in word set import +in word set interface +in word set in +in word set inline +in word set lock +in word set methods +in word set mod +in word set module +in word set not +in word set object +in word set of +in word set or +in word set procedure +in word set raises +in word set readonly +in word set record +in word set ref +in word set repeat +in word set return +in word set set +in word set then +in word set to +in word set try +in word set type +in word set typecase +in word set unsafe +in word set until +in word set untraced +in word set value +in word set var +in word set while +in word set with diff --git a/gnu/lib/libg++/libg++/gperf/tests/modula2.gperf b/gnu/lib/libg++/libg++/gperf/tests/modula2.gperf new file mode 100644 index 00000000000..5ef9c753835 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/modula2.gperf @@ -0,0 +1,40 @@ +AND +ARRAY +BEGIN +BY +CASE +CONST +DEFINITION +DIV +DO +ELSE +ELSIF +END +EXIT +EXPORT +FOR +FROM +IF +IMPLEMENTATION +IMPORT +IN +LOOP +MOD +MODULE +NOT +OF +OR +POINTER +PROCEDURE +QUALIFIED +RECORD +REPEAT +RETURN +SET +THEN +TO +TYPE +UNTIL +VAR +WHILE +WITH diff --git a/gnu/lib/libg++/libg++/gperf/tests/modula3.gperf b/gnu/lib/libg++/libg++/gperf/tests/modula3.gperf new file mode 100644 index 00000000000..d0243460d9b --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/modula3.gperf @@ -0,0 +1,106 @@ +AND +ARRAY +BEGIN +BITS +BY +CASE +CONST +DIV +DO +ELSE +ELSIF +END +EVAL +EXCEPT +EXCEPTION +EXIT +EXPORTS +FINALLY +FOR +FROM +IF +IMPORT +INTERFACE +IN +INLINE +LOCK +METHODS +MOD +MODULE +NOT +OBJECT +OF +OR +PROCEDURE +RAISES +READONLY +RECORD +REF +REPEAT +RETURN +SET +THEN +TO +TRY +TYPE +TYPECASE +UNSAFE +UNTIL +UNTRACED +VALUE +VAR +WHILE +WITH +and +array +begin +bits +by +case +const +div +do +else +elsif +end +eval +except +exception +exit +exports +finally +for +from +if +import +interface +in +inline +lock +methods +mod +module +not +object +of +or +procedure +raises +readonly +record +ref +repeat +return +set +then +to +try +type +typecase +unsafe +until +untraced +value +var +while +with diff --git a/gnu/lib/libg++/libg++/gperf/tests/pascal.exp b/gnu/lib/libg++/libg++/gperf/tests/pascal.exp new file mode 100644 index 00000000000..765e44c6a0f --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/pascal.exp @@ -0,0 +1,36 @@ +in word set with +in word set array +in word set and +in word set function +in word set case +in word set var +in word set const +in word set until +in word set then +in word set set +in word set record +in word set program +in word set procedure +in word set or +in word set packed +in word set not +in word set nil +in word set label +in word set in +in word set repeat +in word set of +in word set goto +in word set forward +in word set for +in word set while +in word set file +in word set else +in word set downto +in word set do +in word set div +in word set to +in word set type +in word set end +in word set mod +in word set begin +in word set if diff --git a/gnu/lib/libg++/libg++/gperf/tests/pascal.gperf b/gnu/lib/libg++/libg++/gperf/tests/pascal.gperf new file mode 100644 index 00000000000..fed3fbb30ea --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/pascal.gperf @@ -0,0 +1,36 @@ +with +array +and +function +case +var +const +until +then +set +record +program +procedure +or +packed +not +nil +label +in +repeat +of +goto +forward +for +while +file +else +downto +do +div +to +type +end +mod +begin +if diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-1.exp b/gnu/lib/libg++/libg++/gperf/tests/test-1.exp new file mode 100644 index 00000000000..5788cf7dfc3 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-1.exp @@ -0,0 +1,140 @@ +/* C code produced by gperf version 2.5 (GNU C++ version) */ +/* Command-line: ../src/gperf -p -j1 -g -o -t -N is_reserved_word -k1,3,$ */ +/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */ +struct resword { char *name; short token; enum rid rid; }; + +#define TOTAL_KEYWORDS 51 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 13 +#define MIN_HASH_VALUE 8 +#define MAX_HASH_VALUE 82 +/* maximum key range = 75, duplicates = 0 */ + +#ifdef __GNUC__ +inline +#endif +static unsigned int +hash (str, len) + register char *str; + register int unsigned len; +{ + static unsigned char asso_values[] = + { + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 0, 83, 1, 2, 34, + 19, 6, 11, 29, 0, 17, 83, 0, 23, 28, + 26, 30, 31, 83, 15, 1, 0, 28, 13, 4, + 83, 83, 5, 83, 83, 83, 83, 83, + }; + register int hval = len; + + switch (hval) + { + default: + case 3: + hval += asso_values[str[2]]; + case 2: + case 1: + hval += asso_values[str[0]]; + break; + } + return hval + asso_values[str[len - 1]]; +} + +#ifdef __GNUC__ +inline +#endif +struct resword * +is_reserved_word (str, len) + register char *str; + register unsigned int len; +{ + static struct resword wordlist[] = + { + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"__asm__", ASM, NORID}, + {"",}, + {"__typeof__", TYPEOF, NORID}, + {"__signed__", TYPESPEC, RID_SIGNED}, + {"__alignof__", ALIGNOF, NORID}, + {"break", BREAK, NORID}, + {"__attribute__", ATTRIBUTE, NORID}, + {"",}, {"",}, + {"else", ELSE, NORID}, + {"__attribute", ATTRIBUTE, NORID}, + {"__typeof", TYPEOF, NORID}, + {"int", TYPESPEC, RID_INT}, + {"__alignof", ALIGNOF, NORID}, + {"struct", STRUCT, NORID}, + {"sizeof", SIZEOF, NORID}, + {"switch", SWITCH, NORID}, + {"__volatile__", TYPE_QUAL, RID_VOLATILE}, + {"",}, + {"__inline__", SCSPEC, RID_INLINE}, + {"__signed", TYPESPEC, RID_SIGNED}, + {"__volatile", TYPE_QUAL, RID_VOLATILE}, + {"if", IF, NORID}, + {"__inline", SCSPEC, RID_INLINE}, + {"while", WHILE, NORID}, + {"",}, + {"__asm", ASM, NORID}, + {"auto", SCSPEC, RID_AUTO}, + {"short", TYPESPEC, RID_SHORT}, + {"default", DEFAULT, NORID}, + {"extern", SCSPEC, RID_EXTERN}, + {"",}, {"",}, + {"__const", TYPE_QUAL, RID_CONST}, + {"static", SCSPEC, RID_STATIC}, + {"__const__", TYPE_QUAL, RID_CONST}, + {"for", FOR, NORID}, + {"case", CASE, NORID}, + {"float", TYPESPEC, RID_FLOAT}, + {"return", RETURN, NORID}, + {"typeof", TYPEOF, NORID}, + {"typedef", SCSPEC, RID_TYPEDEF}, + {"volatile", TYPE_QUAL, RID_VOLATILE}, + {"do", DO, NORID}, + {"inline", SCSPEC, RID_INLINE}, + {"void", TYPESPEC, RID_VOID}, + {"char", TYPESPEC, RID_CHAR}, + {"signed", TYPESPEC, RID_SIGNED}, + {"unsigned", TYPESPEC, RID_UNSIGNED}, + {"",}, {"",}, + {"double", TYPESPEC, RID_DOUBLE}, + {"asm", ASM, NORID}, + {"",}, {"",}, + {"goto", GOTO, NORID}, + {"",}, + {"const", TYPE_QUAL, RID_CONST}, + {"enum", ENUM, NORID}, + {"register", SCSPEC, RID_REGISTER}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"continue", CONTINUE, NORID}, + {"",}, + {"union", UNION, NORID}, + {"",}, {"",}, {"",}, {"",}, {"",}, + {"long", TYPESPEC, RID_LONG}, + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register char *s = wordlist[key].name; + + if (*s == *str && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-2.exp b/gnu/lib/libg++/libg++/gperf/tests/test-2.exp new file mode 100644 index 00000000000..f74124155eb --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-2.exp @@ -0,0 +1,183 @@ +/* C code produced by gperf version 2.5 (GNU C++ version) */ +/* Command-line: ../src/gperf -n -k1-8 -l */ + +#define TOTAL_KEYWORDS 40 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 14 +#define MIN_HASH_VALUE 1 +#define MAX_HASH_VALUE 256 +/* maximum key range = 256, duplicates = 0 */ + +static unsigned int +hash (str, len) + register char *str; + register int unsigned len; +{ + static unsigned short asso_values[] = + { + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 25, 30, 35, 21, 0, + 30, 15, 30, 45, 257, 257, 0, 5, 45, 0, + 10, 0, 1, 20, 25, 15, 30, 40, 15, 5, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, + }; + register int hval = 0; + + switch (len) + { + default: + case 8: + hval += asso_values[str[7]]; + case 7: + hval += asso_values[str[6]]; + case 6: + hval += asso_values[str[5]]; + case 5: + hval += asso_values[str[4]]; + case 4: + hval += asso_values[str[3]]; + case 3: + hval += asso_values[str[2]]; + case 2: + hval += asso_values[str[1]]; + case 1: + hval += asso_values[str[0]]; + break; + } + return hval; +} + +char * +in_word_set (str, len) + register char *str; + register unsigned int len; +{ + + static unsigned char lengthtable[] = + { + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 2, 3, 0, + 0, 0, 2, 3, 0, 0, 0, 2, 4, 0, 0, 0, 4, 6, + 0, 0, 0, 3, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, + 3, 5, 6, 0, 0, 6, 0, 0, 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 4, 0, 0, 9, + 0, 4, 6, 6, 0, 0, 2, 3, 0, 0, 0, 5, 3, 0, + 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, + 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 7, 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, + }; + static char *wordlist[] = + { + "", + "OR", + "", "", "", "", "", "", "", "", + "LOOP", + "", "", "", "", "", "", "", "", "", + "ELSE", + "DO", + "", "", "", + "TO", + "MOD", + "", "", "", + "OF", + "FOR", + "", "", "", + "BY", + "FROM", + "", "", "", + "TYPE", + "MODULE", + "", "", "", + "SET", + "", "", "", "", "", + "EXPORT", + "", "", "", "", + "VAR", + "ARRAY", + "RECORD", + "", "", + "REPEAT", + "", "", "", "", + "END", + "", "", "", + "NOT", + "", "", "", "", + "IF", + "", "", "", "", + "CASE", + "", "", + "PROCEDURE", + "", + "EXIT", + "IMPORT", + "RETURN", + "", "", + "IN", + "AND", + "", "", "", + "ELSIF", + "DIV", + "", "", "", + "THEN", + "", "", "", "", "", "", "", "", "", + "IMPLEMENTATION", + "", "", "", "", + "WHILE", + "", "", "", "", "", "", "", "", "", + "CONST", + "POINTER", + "", "", "", + "UNTIL", + "", "", "", "", + "BEGIN", + "", "", "", "", + "WITH", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "QUALIFIED", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "", "", "", "", "", + "DEFINITION", + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register char *s = wordlist[key]; + + if (len == lengthtable[key] + && *s == *str && !strcmp (str + 1, s + 1)) + return s; + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-3.exp b/gnu/lib/libg++/libg++/gperf/tests/test-3.exp new file mode 100644 index 00000000000..5e889020657 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-3.exp @@ -0,0 +1,169 @@ +/* C code produced by gperf version 2.5 (GNU C++ version) */ +/* Command-line: ../src/gperf -p -j 1 -o -a -C -g -t -k1,4,$ */ +/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */ +struct resword { char *name; short token; enum rid rid;}; + +#define TOTAL_KEYWORDS 71 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 13 +#define MIN_HASH_VALUE 4 +#define MAX_HASH_VALUE 147 +/* maximum key range = 144, duplicates = 0 */ + +#ifdef __GNUC__ +inline +#endif +static unsigned int +hash (register const char *str, register int len) +{ + static const unsigned char asso_values[] = + { + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 0, 148, 19, 6, 27, + 37, 0, 12, 1, 15, 63, 148, 4, 0, 56, + 20, 15, 42, 148, 31, 5, 26, 39, 32, 10, + 148, 40, 148, 148, 148, 148, 148, 148, + }; + register int hval = len; + + switch (hval) + { + default: + case 4: + hval += asso_values[str[3]]; + case 3: + case 2: + case 1: + hval += asso_values[str[0]]; + break; + } + return hval + asso_values[str[len - 1]]; +} + +#ifdef __GNUC__ +inline +#endif +const struct resword * +in_word_set (register const char *str, register int len) +{ + static const struct resword wordlist[] = + { + {"",}, {"",}, {"",}, {"",}, + {"else", ELSE, NORID,}, + {"",}, + {"long", TYPESPEC, RID_LONG,}, + {"",}, {"",}, {"",}, {"",}, + {"__alignof__", ALIGNOF, NORID}, + {"__asm__", ASM, NORID}, + {"",}, {"",}, + {"while", WHILE, NORID,}, + {"",}, {"",}, {"",}, {"",}, {"",}, + {"__alignof", ALIGNOF, NORID}, + {"all", ALL, NORID /* Extension */,}, + {"sizeof", SIZEOF, NORID,}, + {"__const__", TYPE_QUAL, RID_CONST}, + {"__volatile", TYPE_QUAL, RID_VOLATILE}, + {"extern", SCSPEC, RID_EXTERN,}, + {"__volatile__", TYPE_QUAL, RID_VOLATILE}, + {"__inline", SCSPEC, RID_INLINE}, + {"exception", AGGR, RID_EXCEPTION /* Extension */,}, + {"__inline__", SCSPEC, RID_INLINE}, + {"case", CASE, NORID,}, + {"except", EXCEPT, NORID /* Extension */,}, + {"new", NEW, NORID,}, + {"break", BREAK, NORID,}, + {"goto", GOTO, NORID,}, + {"",}, + {"__attribute", ATTRIBUTE, NORID}, + {"",}, + {"__attribute__", ATTRIBUTE, NORID}, + {"this", THIS, NORID,}, + {"raise", RAISE, NORID /* Extension */,}, + {"class", AGGR, RID_CLASS,}, + {"delete", DELETE, NORID,}, + {"typeof", TYPEOF, NORID,}, + {"typedef", SCSPEC, RID_TYPEDEF,}, + {"for", FOR, NORID,}, + {"raises", RAISES, NORID /* Extension */,}, + {"__const", TYPE_QUAL, RID_CONST}, + {"double", TYPESPEC, RID_DOUBLE,}, + {"__typeof__", TYPEOF, NORID}, + {"",}, + {"switch", SWITCH, NORID,}, + {"auto", SCSPEC, RID_AUTO,}, + {"do", DO, NORID,}, + {"friend", SCSPEC, RID_FRIEND,}, + {"",}, + {"reraise", RERAISE, NORID /* Extension */,}, + {"",}, + {"volatile", TYPE_QUAL, RID_VOLATILE,}, + {"__typeof", TYPEOF, NORID}, + {"continue", CONTINUE, NORID,}, + {"float", TYPESPEC, RID_FLOAT,}, + {"const", TYPE_QUAL, RID_CONST,}, + {"static", SCSPEC, RID_STATIC,}, + {"virtual", SCSPEC, RID_VIRTUAL,}, + {"__asm", ASM, NORID}, + {"short", TYPESPEC, RID_SHORT,}, + {"signed", TYPESPEC, RID_SIGNED,}, + {"try", TRY, NORID /* Extension */,}, + {"",}, {"",}, {"",}, + {"__signed__", TYPESPEC, RID_SIGNED}, + {"catch", CATCH, NORID,}, + {"public", PUBLIC, NORID,}, + {"struct", AGGR, RID_RECORD,}, + {"if", IF, NORID,}, + {"asm", ASM, NORID,}, + {"union", AGGR, RID_UNION,}, + {"",}, + {"private", PRIVATE, NORID,}, + {"",}, {"",}, {"",}, + {"operator", OPERATOR, NORID,}, + {"",}, {"",}, {"",}, + {"default", DEFAULT, NORID,}, + {"dynamic", DYNAMIC, NORID,}, + {"overload", OVERLOAD, NORID,}, + {"int", TYPESPEC, RID_INT,}, + {"char", TYPESPEC, RID_CHAR,}, + {"",}, {"",}, + {"return", RETURN, NORID,}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"",}, {"",}, + {"__signed", TYPESPEC, RID_SIGNED}, + {"",}, + {"void", TYPESPEC, RID_VOID,}, + {"",}, {"",}, {"",}, + {"protected", PROTECTED, NORID,}, + {"",}, + {"enum", ENUM, NORID,}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"inline", SCSPEC, RID_INLINE,}, + {"register", SCSPEC, RID_REGISTER,}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"",}, {"",}, {"",}, {"",}, + {"unsigned", TYPESPEC, RID_UNSIGNED,}, + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register const char *s = wordlist[key].name; + + if (*s == *str && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-4.exp b/gnu/lib/libg++/libg++/gperf/tests/test-4.exp new file mode 100644 index 00000000000..5238bf94d98 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-4.exp @@ -0,0 +1,138 @@ +/* C code produced by gperf version 2.5 (GNU C++ version) */ +/* Command-line: ../src/gperf -D -p -t */ +/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */ +struct resword { char *name; short token; enum rid rid; }; + +#define TOTAL_KEYWORDS 51 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 13 +#define MIN_HASH_VALUE 4 +#define MAX_HASH_VALUE 82 +/* maximum key range = 79, duplicates = 2 */ + +static unsigned int +hash (str, len) + register char *str; + register int unsigned len; +{ + static unsigned char asso_values[] = + { + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 0, 83, 40, 20, 50, + 25, 10, 30, 0, 0, 50, 83, 0, 15, 0, + 35, 0, 83, 83, 20, 0, 10, 40, 5, 15, + 83, 83, 83, 83, 83, 83, 83, 83, + }; + return len + asso_values[str[len - 1]] + asso_values[str[0]]; +} + +struct resword * +in_word_set (str, len) + register char *str; + register unsigned int len; +{ + static struct resword wordlist[] = + { + {"",}, {"",}, {"",}, {"",}, + {"goto", GOTO, NORID}, + {"__asm", ASM, NORID}, + {"switch", SWITCH, NORID}, + {"__asm__", ASM, NORID}, + {"__const__", TYPE_QUAL, RID_CONST}, + {"__inline__", SCSPEC, RID_INLINE}, + {"__typeof__", TYPEOF, NORID}, + {"__signed__", TYPESPEC, RID_SIGNED}, + {"__alignof__", ALIGNOF, NORID}, + {"__volatile__", TYPE_QUAL, RID_VOLATILE}, + {"__attribute__", ATTRIBUTE, NORID}, + {"enum", ENUM, NORID}, + {"short", TYPESPEC, RID_SHORT}, + {"struct", STRUCT, NORID}, + {"__const", TYPE_QUAL, RID_CONST}, + {"__inline", SCSPEC, RID_INLINE}, + {"long", TYPESPEC, RID_LONG}, + {"__volatile", TYPE_QUAL, RID_VOLATILE}, + {"__attribute", ATTRIBUTE, NORID}, + {"volatile", TYPE_QUAL, RID_VOLATILE}, + {"else", ELSE, NORID}, + {"break", BREAK, NORID}, + {"do", DO, NORID}, + {"while", WHILE, NORID}, + {"signed", TYPESPEC, RID_SIGNED}, + {"__signed", TYPESPEC, RID_SIGNED}, + {"void", TYPESPEC, RID_VOID}, + {"sizeof", SIZEOF, NORID}, + {"__typeof", TYPEOF, NORID}, + {"__alignof", ALIGNOF, NORID}, + {"double", TYPESPEC, RID_DOUBLE}, + {"default", DEFAULT, NORID}, + {"asm", ASM, NORID}, + {"auto", SCSPEC, RID_AUTO}, + {"float", TYPESPEC, RID_FLOAT}, + {"typeof", TYPEOF, NORID}, + {"typedef", SCSPEC, RID_TYPEDEF}, + {"register", SCSPEC, RID_REGISTER}, + {"extern", SCSPEC, RID_EXTERN}, + {"for", FOR, NORID}, + {"static", SCSPEC, RID_STATIC}, + {"return", RETURN, NORID}, + {"int", TYPESPEC, RID_INT}, + {"case", CASE, NORID}, + {"const", TYPE_QUAL, RID_CONST}, + {"inline", SCSPEC, RID_INLINE}, + {"continue", CONTINUE, NORID}, + {"unsigned", TYPESPEC, RID_UNSIGNED}, + {"char", TYPESPEC, RID_CHAR}, + {"union", UNION, NORID}, + {"if", IF, NORID}, + }; + + static char lookup[] = + { + -1, -1, -1, -1, 4, 5, 6, 7, -1, 8, 100, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, -1, 23, 24, 25, -1, 26, + -9, -3, 27, 28, -1, 29, 30, -1, 31, -1, 32, 33, -1, 34, + 35, 36, 37, 38, 39, 40, 41, -1, -1, 42, -1, 43, -1, -1, + 44, -1, -1, -1, -1, 45, -1, 46, 47, 48, 49, -1, 50, -1, + -1, -1, -1, 51, 52, -1, -1, -1, -1, -1, 53, -1, 54, + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register int index = lookup[key]; + + if (index >= 0 && index < MAX_HASH_VALUE) + { + register char *s = wordlist[index].name; + + if (*s == *str && !strcmp (str + 1, s + 1)) + return &wordlist[index]; + } + else if (index < 0 && index >= -MAX_HASH_VALUE) + return 0; + else + { + register int offset = key + index + (index > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE); + register struct resword *base = &wordlist[-lookup[offset]]; + register struct resword *ptr = base + -lookup[offset + 1]; + + while (--ptr >= base) + if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1)) + return ptr; + } + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-5.exp b/gnu/lib/libg++/libg++/gperf/tests/test-5.exp new file mode 100644 index 00000000000..101e2798d40 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-5.exp @@ -0,0 +1,111 @@ +/* C code produced by gperf version 2.5 (GNU C++ version) */ +/* Command-line: ../src/gperf -g -o -j1 -t -p -N is_reserved_word */ +/* ISO Pascal 7185 reserved words. + * + * For GNU Pascal compiler (GPC) by jtv@hut.fi + * + * run this through the Doug Schmidt's gperf program + * with command + * gperf -g -o -j1 -t -p -N is_reserved_word + * + */ +struct resword { char *name; short token; short iclass;}; + +#define TOTAL_KEYWORDS 35 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 9 +#define MIN_HASH_VALUE 2 +#define MAX_HASH_VALUE 43 +/* maximum key range = 42, duplicates = 0 */ + +#ifdef __GNUC__ +inline +#endif +static unsigned int +hash (str, len) + register char *str; + register int unsigned len; +{ + static unsigned char asso_values[] = + { + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 18, 29, 14, 6, 7, + 10, 20, 44, 28, 44, 44, 28, 19, 22, 15, + 0, 44, 9, 23, 0, 23, 26, 2, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 0, 0, 13, 44, 30, 44, 44, 44, 0, 25, + 1, 0, 44, 44, 0, 44, 1, 44, 25, 44, + 44, 0, 44, 44, 44, 44, 44, 44, + }; + return len + asso_values[str[len - 1]] + asso_values[str[0]]; +} + +#ifdef __GNUC__ +inline +#endif +struct resword * +is_reserved_word (str, len) + register char *str; + register unsigned int len; +{ + static struct resword wordlist[] = + { + {"",}, {"",}, + {"To", TO, PASCAL_ISO}, + {"",}, + {"Type", TYPE, PASCAL_ISO}, + {"Then", THEN, PASCAL_ISO}, + {"Packed", PACKED, PASCAL_ISO}, + {"While", WHILE, PASCAL_ISO}, + {"Do", DO, PASCAL_ISO}, + {"Procedure", PROCEDURE, PASCAL_ISO}, + {"End", END, PASCAL_ISO}, + {"Else", ELSE, PASCAL_ISO}, + {"Downto", DOWNTO, PASCAL_ISO}, + {"For", FOR, PASCAL_ISO}, + {"File", FILE_, PASCAL_ISO}, + {"Record", RECORD, PASCAL_ISO}, + {"Repeat", REPEAT, PASCAL_ISO}, + {"Or", OR, PASCAL_ISO}, + {"Case", CASE, PASCAL_ISO}, + {"Function", FUNCTION, PASCAL_ISO}, + {"Const", CONST, PASCAL_ISO}, + {"And", AND, PASCAL_ISO}, + {"Mod", MOD, PASCAL_ISO}, + {"Array", ARRAY, PASCAL_ISO}, + {"Goto", GOTO, PASCAL_ISO}, + {"Nil", NIL, PASCAL_ISO}, + {"Not", NOT, PASCAL_ISO}, + {"Set", SET, PASCAL_ISO}, + {"Until", UNTIL, PASCAL_ISO}, + {"Var", VAR, PASCAL_ISO}, + {"Of", OF, PASCAL_ISO}, + {"In", IN, PASCAL_ISO}, + {"Program", PROGRAM,PASCAL_ISO}, + {"Label", LABEL, PASCAL_ISO}, + {"Div", DIV, PASCAL_ISO}, + {"Begin", BEGIN_, PASCAL_ISO}, + {"With", WITH, PASCAL_ISO}, + {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"If", IF, PASCAL_ISO}, + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register char *s = wordlist[key].name; + + if (*s == *str && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-6.exp b/gnu/lib/libg++/libg++/gperf/tests/test-6.exp new file mode 100644 index 00000000000..eba6e3cac9a --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-6.exp @@ -0,0 +1,74 @@ +-a Generate ANSI standard C output code, i.e., function prototypes. +-c Generate comparison code using strncmp rather than strcmp. +-C Make the contents of generated lookup tables constant, i.e., readonly. +-d Enables the debugging option (produces verbose output to the standard error). +-D Handle keywords that hash to duplicate values. This is useful + for certain highly redundant keyword sets. It enables the -S option. +-e Allow user to provide a string containing delimiters used to separate + keywords from their attributes. Default is ",\n" +-E Define constant values using an enum local to the lookup function + rather than with defines +-f Generate the gen-perf.hash function ``fast.'' This decreases GPERF's + running time at the cost of minimizing generated table-size. + The numeric argument represents the number of times to iterate when + resolving a collision. `0' means ``iterate by the number of keywords.'' +-g Assume a GNU compiler, e.g., g++ or gcc. This makes all generated + routines use the ``inline'' keyword to remove cost of function calls. +-G Generate the static table of keywords as a static global variable, + rather than hiding it inside of the lookup function (which is the + default behavior). +-h Prints this mesage. +-H Allow user to specify name of generated hash function. Default + is `hash'. +-i Provide an initial value for the associate values array. Default is 0. + Setting this value larger helps inflate the size of the final table. +-j Affects the ``jump value,'' i.e., how far to advance the associated + character value upon collisions. Must be an odd number, default is 5. +-k Allows selection of the key positions used in the hash function. + The allowable choices range between 1-126, inclusive. The positions + are separated by commas, ranges may be used, and key positions may + occur in any order. Also, the meta-character '*' causes the generated + hash function to consider ALL key positions, and $ indicates the + ``final character'' of a key, e.g., $,1,2,4,6-10. +-K Allow use to select name of the keyword component in the keyword structure. +-l Compare key lengths before trying a string comparison. This helps + cut down on the number of string comparisons made during the lookup. +-L Generates code in the language specified by the option's argument. Languages + handled are currently C++ and C. The default is C. +-n Do not include the length of the keyword when computing the hash function +-N Allow user to specify name of generated lookup function. Default + name is `in_word_set.' +-o Reorders input keys by frequency of occurrence of the key sets. + This should decrease the search time dramatically. +-p Changes the return value of the generated function ``in_word_set'' + from its default boolean value (i.e., 0 or 1), to type ``pointer + to wordlist array'' This is most useful when the -t option, allowing + user-defined structs, is used. +-r Utilizes randomness to initialize the associated values table. +-s Affects the size of the generated hash table. The numeric argument + for this option indicates ``how many times larger or smaller'' the associated + value range should be, in relationship to the number of keys, e.g. a value of 3 + means ``allow the maximum associated value to be about 3 times larger than the + number of input keys.'' Conversely, a value of -3 means ``make the maximum + associated value about 3 times smaller than the number of input keys. + A larger table should decrease the time required for an unsuccessful search, + at the expense of extra table space. Default value is 1. +-S Causes the generated C code to use a switch statement scheme, rather + than an array lookup table. This can lead to a reduction in both + time and space requirements for some keyfiles. The argument to + this option determines how many switch statements are generated. + A value of 1 generates 1 switch containing all the elements, a value of 2 + generates 2 tables with 1/2 the elements in each table, etc. This + is useful since many C compilers cannot correctly generate code for + large switch statements. +-t Allows the user to include a structured type declaration for + generated code. Any text before %% is consider part of the type + declaration. Key words and additional fields may follow this, one + group of fields per line. +-T Prevents the transfer of the type declaration to the output file. + Use this option if the type is already defined elsewhere. +-v Prints out the current version number +-Z Allow user to specify name of generated C++ class. Default + name is `Perfect_Hash.' +Usage: ../src/gperf [-acCdDef[num]gGhHijkKlLnNoprsStTvZ]. +(type ../src/gperf -h for help) diff --git a/gnu/lib/libg++/libg++/gperf/tests/test-7.exp b/gnu/lib/libg++/libg++/gperf/tests/test-7.exp new file mode 100644 index 00000000000..c5c942c10d1 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test-7.exp @@ -0,0 +1,32 @@ +in word set if +in word set do +NOT in word set int +in word set for +in word set case +NOT in word set char +NOT in word set auto +in word set goto +in word set else +NOT in word set long +NOT in word set void +NOT in word set enum +NOT in word set float +NOT in word set short +NOT in word set union +NOT in word set break +in word set while +NOT in word set const +NOT in word set double +NOT in word set static +NOT in word set extern +NOT in word set struct +in word set return +NOT in word set sizeof +NOT in word set switch +NOT in word set signed +NOT in word set typedef +NOT in word set default +NOT in word set unsigned +NOT in word set continue +NOT in word set register +NOT in word set volatile diff --git a/gnu/lib/libg++/libg++/gperf/tests/test.c b/gnu/lib/libg++/libg++/gperf/tests/test.c new file mode 100644 index 00000000000..b2f08cd75e6 --- /dev/null +++ b/gnu/lib/libg++/libg++/gperf/tests/test.c @@ -0,0 +1,26 @@ +/* + Tests the generated perfect has function. + The -v option prints diagnostics as to whether a word is in + the set or not. Without -v the program is useful for timing. +*/ + +#include + +#define MAX_LEN 80 + +int +main (argc, argv) + int argc; + char *argv[]; +{ + int verbose = argc > 1 ? 1 : 0; + char buf[MAX_LEN]; + + while (gets (buf)) + if (in_word_set (buf, strlen (buf)) && verbose) + printf ("in word set %s\n", buf); + else if (verbose) + printf ("NOT in word set %s\n", buf); + + return 0; +} diff --git a/gnu/lib/libg++/libg++/libg++.info b/gnu/lib/libg++/libg++/libg++.info new file mode 100644 index 00000000000..66a9b9a062c --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info @@ -0,0 +1,82 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +Indirect: +libg++.info-1: 1265 +libg++.info-2: 41086 +libg++.info-3: 90357 +libg++.info-4: 139360 +libg++.info-5: 189194 + +Tag Table: +(Indirect) +Node: Top1265 +Node: Copying3715 +Node: Contributors30614 +Node: Installation31801 +Node: Trouble32380 +Node: General32859 +Node: Conventions36600 +Node: OK39236 +Node: Proto41086 +Node: Representations55086 +Node: Expressions58688 +Node: Pix63053 +Node: Headers66086 +Node: Builtin68566 +Node: New71246 +Node: Stream74115 +Node: Obstack82360 +Node: AllocRing88656 +Node: String90357 +Node: Integer104071 +Node: Rational110330 +Node: Complex113113 +Node: Fix115190 +Node: Bit118528 +Node: Random129408 +Node: Data139360 +Node: Curses141399 +Node: List144273 +Node: LinkList151137 +Node: Vector153546 +Node: Plex158921 +Node: Stack168721 +Node: Queue170085 +Node: Deque171318 +Node: PQ172736 +Node: Set175059 +Node: Bag179326 +Node: Map182643 +Node: GetOpt185879 +Node: Projects189194 + +End Tag Table diff --git a/gnu/lib/libg++/libg++/libg++.info-1 b/gnu/lib/libg++/libg++/libg++.info-1 new file mode 100644 index 00000000000..67b0bc6d90b --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info-1 @@ -0,0 +1,822 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: libg++.info, Node: Top, Next: Copying, Up: (DIR) + + Introduction ************ + + This manual documents how to install and use the GNU C++ library. + +* Menu: + +* Copying:: GNU Library Public License says how you can copy + and share the GNU C++ library. +* Contributors:: People who have contributed to GNU C++ library. +* Installation:: How to configure, compile and install GNU C++ library +* Trouble:: If you have trouble installing GNU C++ library. +* General:: Aims, objectives, and limitations of the GNU C++ library +* Conventions:: Stylistic conventions +* OK:: Support for representation invariants +* Proto:: Introduction to container class prototypes +* Pix:: Pseudo-indexes +* Representations:: How variable-sized objects are represented +* Expressions:: Some guidance on programming expression-oriented classes +* Headers:: Header files and other support for interfacing C++ to C +* Builtin:: Utility functions for builtin types +* New:: Library dynamic allocation primitives +* IOStream:(iostream)Top. + The input/output library (istreams and ostreams). +* Stream:: obsolete I/O library +* Obstack:: Obstacks and their uses. +* AllocRing:: A place to store objects for a while +* String:: String, SubString, and Regex classes. +* Integer:: Multiple precision Integer class. +* Rational:: Multiple precision Rational class +* Complex:: Complex number class +* Fix:: Fixed point proportion classes +* Bit:: BitSet and BitString classes +* Random:: Random number generators +* Data:: SampleStatistic and related classes for data collection +* Curses:: CursesWindow class +* List:: Lisp-like List prototype +* LinkList:: Singly and doubly linked list class prototypes +* Vector:: Vector prototypes +* Plex:: Plex (adjustable array) prototypes +* Stack:: Stack prototypes +* Queue:: Queue prototypes +* Deque:: Double ended queue prototypes +* PQ:: Heap (priority queue) class prototypes +* Set:: Set class prototypes +* Bag:: Bag class prototypes +* Map:: Map (Associative array) prototypes +* GetOpt:: C++ class-based version of the GNU/UNIX getopt function +* Projects:: Things Still Left to do + + +File: libg++.info, Node: Copying, Next: Contributors, Prev: Top, Up: Top + +GNU LIBRARY GENERAL PUBLIC LICENSE +********************************** + + Version 2, June 1991 + + Copyright (C) 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.] + +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. + + 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 + +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. + + ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES. + Copyright (C) YEAR 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. + + 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. + + SIGNATURE OF TY COON, 1 April 1990 + Ty Coon, President of Vice + + That's all there is to it! + + +File: libg++.info, Node: Contributors, Next: Installation, Prev: Copying, Up: Top + +Contributors to GNU C++ library +******************************* + + Aside from Michael Tiemann, who worked out the front end for GNU +C++, and Richard Stallman, who worked out the back end, the following +people (not including those who have made their contributions to GNU +CC) should not go unmentioned. + + * Doug Lea contributed most otherwise unattributed classes. + + * Per Bothner contributed the iostream I/O classes. + + * Dirk Grunwald contributed the Random number generation classes, + and PairingHeaps. + + * Kurt Baudendistel contributed Fixed precision reals. + + * Doug Schmidt contributed ordered hash tables, a perfect hash + function generator, and several other utilities. + + * Marc Shapiro contributed the ideas and preliminary code for Plexes. + + * Eric Newton contributed the curses window classes. + + * Some of the I/O code is derived from BSD 4.4, and was developed by + the University of California, Berkeley. + + * The code for converting accurately between floating point numbers + and their string representations was written by David M. Gay of + AT&T. + + +File: libg++.info, Node: Installation, Next: Trouble, Prev: Contributors, Up: Top + +Installing GNU C++ library +************************** + + 1. Read through the README file and the Makefile. Make sure that all + paths, system-dependent compile switches, and program names are + correct. + + 2. Check that files `values.h', `stdio.h', and `math.h' declare and + define values appropriate for your system. + + 3. Type `make all' to compile the library, test, and install. + Current details about contents of the tests and utilities are in + the `README' file. + + + +File: libg++.info, Node: Trouble, Next: General, Prev: Installation, Up: Top + +Trouble in Installation +*********************** + + Here are some of the things that have caused trouble for people +installing GNU C++ library. + + 1. Make sure that your GNU C++ version number is at least as high as + your libg++ version number. For example, libg++ 1.22.0 requires + g++ 1.22.0 or later releases. + + 2. Double-check system constants in the header files mentioned above. + + + +File: libg++.info, Node: General, Next: Conventions, Prev: Trouble, Up: Top + +GNU C++ library aims, objectives, and limitations +************************************************* + + The GNU C++ library, libg++ is an attempt to provide a variety of C++ +programming tools and other support to GNU C++ programmers. + + Differences in distribution policy are only part of the difference +between libg++.a and AT&T libC.a. libg++ is not intended to be an +exact clone of libC. For one, libg++ contains bits of code that depend +on special features of GNU g++ that are either different or lacking in +the AT&T version, including slightly different inlining and overloading +strategies, dynamic local arrays, etc. All of these differences are +minor. For example, while the AT&T and GNU stream classes are +implemented in very different ways, the vast majority of C++ programs +compile and run under either version with no visible difference. +Additionally, all g++-specific constructs are conditionally compiled; +The library is designed to be compatible with any 2.0 C++ compiler. + + libg++ has also contained workarounds for some limitations in g++: +both g++ and libg++ are still undergoing rapid development and +testing--a task that is helped tremendously by the feedback of active +users. This manual is also still under development; it has some +catching up to do to include all the facilities now in the library. + + libg++ is not the only freely available source of C++ class +libraries. Some notable alternative sources are Interviews and NIHCL. +(InterViews has been available on the X-windows X11 tapes and also from +interviews.stanford.edu. NIHCL is available by anonymous ftp from GNU +archives (such as the pub directory of prep.ai.mit.edu), although it is +not supported by the FSF - and needs some work before it will work with +g++.) + + As every C++ programmer knows, the design (moreso than the +implementation) of a C++ class library is something of a challenge. +Part of the reason is that C++ supports two, partially incompatible, +styles of object-oriented programming - The "forest" approach, +involving a collection of free-standing classes that can be mixed and +matched, versus the completely hierarchical (smalltalk style) approach, +in which all classes are derived from a common ancestor. Of course, +both styles have advantages and disadvantages. So far, libg++ has +adopted the "forest" approach. Keith Gorlen's OOPS library adopts the +hierarchical approach, and may be an attractive alternative for C++ +programmers who prefer this style. + + Currently (and/or in the near future) libg++ provides support for a +few basic kinds of classes: + + The first kind of support provides an interface between C++ programs +and C libraries. This includes basic header files (like `stdio.h') as +well as things like the File and stream classes. Other classes that +interface to other aspects of C libraries (like those that maintain +environmental information) are in various stages of development; all +will undergo implementation modifications when the forthcoming GNU libc +library is released. + + The second kind of support contains general-purpose basic classes +that transparently manage variable-sized objects on the freestore. This +includes Obstacks, multiple-precision Integers and Rationals, arbitrary +length Strings, BitSets, and BitStrings. + + Third, several classes and utilities of common interest (e.g., +Complex numbers) are provided. + + Fourth, a set of pseudo-generic prototype files are available as a +mechanism for generating common container classes. These are described +in more detail in the introduction to container prototypes. Currently, +only a textual substitution mechanism is available for generic class +creation. + + +File: libg++.info, Node: Conventions, Next: OK, Prev: General, Up: Top + +GNU C++ library stylistic conventions +************************************* + + * C++ source files have file extension `.cc'. Both C-compatibility + header files and class declaration files have extension `.h'. + + * C++ class names begin with capital letters, except for `istream' + and `ostream', for AT&T C++ compatibility. Multi-word class names + capitalize each word, with no underscore separation. + + * Include files that define C++ classes begin with capital letters + (as do the names of the classes themselves). `stream.h' is + uncapitalized for AT&T C++ compatibility. + + * Include files that supply function prototypes for other C + functions (system calls and libraries) are all lower case. + + * All include files define a preprocessor variable _X_h, where X is + the name of the file, and conditionally compile only if this has + not been already defined. The `#pragma once' facility is also used + to avoid re-inclusion. + + * Structures and objects that must be publicly defined, but are not + intended for public use have names beginning with an underscore. + (for example, the `_Srep' struct, which is used only by the String + and SubString classes.) + + * The underscore is used to separate components of long function + names, + e.g., `set_File_exception_handler()'. + + * When a function could be usefully defined either as a member or a + friend, it is generally a member if it modifies and/or returns + itself, else it is a friend. There are cases where naturalness of + expression wins out over this rule. + + * Class declaration files are formatted so that it is easy to + quickly check them to determine function names, parameters, and so + on. Because of the different kinds of things that may appear in + class declarations, there is no perfect way to do this. Any + suggestions on developing a common class declaration formatting + style are welcome. + + * All classes use the same simple error (exception) handling + strategy. Almost every class has a member function named + `error(char* msg)' that invokes an associated error handler + function via a pointer to that function, so that the error + handling function may be reset by programmers. By default nearly + all call `*lib_error_handler', which prints the message and then + aborts execution. This system is subject to change. In general, + errors are assumed to be non-recoverable: Library classes do not + include code that allows graceful continuation after exceptions. + + +File: libg++.info, Node: OK, Next: Proto, Prev: Conventions, Up: Top + +Support for representation invariants +************************************* + + Most GNU C++ library classes possess a method named `OK()', that is +useful in helping to verify correct performance of class operations. + + The `OK()' operations checks the "representation invariant" of a +class object. This is a test to check whether the object is in a valid +state. In effect, it is a (sometimes partial) verification of the +library's promise that (1) class operations always leave objects in +valid states, and (2) the class protects itself so that client functions +cannot corrupt this state. + + While no simple validation technique can assure that all operations +perform correctly, calls to `OK()' can at least verify that operations +do not corrupt representations. For example for `String a, b, c; ... a += b + c;', a call to `a.OK();' will guarantee that `a' is a valid +`String', but does not guarantee that it contains the concatenation of +`b + c'. However, given that `a' is known to be valid, it is possible +to further verify its properties, for example via `a.after(b) == c && +a.before(c) == b'. In other words, `OK()' generally checks only those +internal representation properties that are otherwise inaccessible to +users of the class. Other class operations are often useful for further +validation. + + Failed calls to `OK()' call a class's `error' method if one exists, +else directly call `abort'. Failure indicates an implementation error +that should be reported. + + With only rare exceptions, the internal support functions for a class +never themselves call `OK()' (although many of the test files in the +distribution call `OK()' extensively). + + Verification of representational invariants can sometimes be very +time consuming for complicated data structures. + diff --git a/gnu/lib/libg++/libg++/libg++.info-2 b/gnu/lib/libg++/libg++/libg++.info-2 new file mode 100644 index 00000000000..ea1c4925463 --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info-2 @@ -0,0 +1,1160 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: libg++.info, Node: Proto, Next: Representations, Prev: OK, Up: Top + +Introduction to container class prototypes +****************************************** + + As a temporary mechanism enabling the support of generic classes, +the GNU C++ Library distribution contains a directory (`g++-include') +of files designed to serve as the basis for generating container +classes of specified elements. These files can be used to generate +`.h' and `.cc' files in the current directory via a supplied shell +script program that performs simple textual substitution to create +specific classes. + + While these classes are generated independently, and thus share no +code, it is possible to create versions that do share code among +subclasses. For example, using `typedef void* ent', and then generating +a `entList' class, other derived classes could be created using the +`void*' coercion method described in Stroustrup, pp204-210. + + This very simple class-generation facility is useful enough to serve +current purposes, but will be replaced with a more coherent mechanism +for handling C++ generics in a way that minimally disrupts current +usage. Without knowing exactly when or how parametric classes might be +added to the C++ language, provision of this simplest possible +mechanism, textual substitution, appears to be the safest strategy, +although it does require certain redundancies and awkward constructions. + + Specific classes may be generated via the `genclass' shell script +program. This program has arguments specifying the kinds of base +types(s) to be used. Specifying base types requires two arguments. The +first is the name of the base type, which may be any named type, like +`int' or `String'. Only named types are supported; things like `int*' +are not accepted. However, pointers like this may be used by supplying +the appropriate typedefs (e.g., editing the resulting files to include +`typedef int* intp;'). The type name must be followed by one of the +words `val' or `ref', to indicate whether the base elements should be +passed to functions by-value or by-reference. + + You can specify basic container classes using `genclass base +[val,ref] proto', where `proto' is the name of the class being +generated. Container classes like dictionaries and maps that require +two types may be specified via `genclass -2 keytype [val, ref], +basetype [val, ref] proto', where the key type is specified first and +the contents type second. The resulting classnames and filenames are +generated by prepending the specified type names to the prototype names, +and separating the filename parts with dots. For example, `genclass +int val List' generates class `intList' residing in files `int.List.h' +and `int.List.cc'. `genclass -2 String ref int val VHMap' generates +(the awkward, but unavoidable) class name `StringintVHMap'. Of course, +programmers may use `typedef' or simple editing to create more +appropriate names. The existence of dot seperators in file names +allows the use of GNU make to help automate configuration and +recompilation. An example Makefile exploiting such capabilities may be +found in the `libg++/proto-kit' directory. + + The `genclass' utility operates via simple text substitution using +`sed'. All occurrences of the pseudo-types `' and `' (if there +are two types) are replaced with the indicated type, and occurrences of +`' and `' are replaced by just the types, if `val' is +specified, or types followed by "&" if `ref' is specified. + + Programmers will frequently need to edit the `.h' file in order to +insert additional `#include' directives or other modifications. A +simple utility, `prepend-header' to prepend other `.h' files to +generated files is provided in the distribution. + + One dubious virtue of the prototyping mechanism is that, because +sources files, not archived library classes, are generated, it is +relatively simple for programmers to modify container classes in the +common case where slight variations of standard container classes are +required. + + It is often a good idea for programmers to archive (via `ar') +generated classes into `.a' files so that only those class functions +actually used in a given application will be loaded. The test +subdirectory of the distribution shows an example of this. + + Because of `#pragma interface' directives, the `.cc' files should be +compiled with `-O' or `-DUSE_LIBGXX_INLINES' enabled. + + Many container classes require specifications over and above the base +class type. For example, classes that maintain some kind of ordering of +elements require specification of a comparison function upon which to +base the ordering. This is accomplished via a prototype file `defs.hP' +that contains macros for these functions. While these macros default to +perform reasonable actions, they can and should be changed in +particular cases. Most prototypes require only one or a few of these. +No harm is done if unused macros are defined to perform nonsensical +actions. The macros are: + +`DEFAULT_INITIAL_CAPACITY' + The initial capacity for containers (e.g., hash tables) that + require an initial capacity argument for constructors. Default: + 100 + +`EQ(a, b)' + return true if a is considered equal to b for the purposes of + locating, etc., an element in a container. Default: (a == b) + +`LE(a, b)' + return true if a is less than or equal to b Default: (a <= b) + +`CMP(a, b)' + return an integer < 0 if a 0 if a>b. Default: + (a <= b)? (a==b)? 0 : -1 : 1 + +`HASH(a)' + return an unsigned integer representing the hash of a. Default: + hash(a) ; where extern unsigned int hash(). (note: several + useful hash functions are declared in builtin.h and defined in + hash.cc) + + Nearly all prototypes container classes support container traversal +via `Pix' pseudo indices, as described elsewhere. + + All object containers must perform either a `X::X(X&)' (or `X::X()' +followed by `X::operator =(X&)') to copy objects into containers. (The +latter form is used for containers built from C++ arrays, like +`VHSets'). When containers are destroyed, they invoke `X::~X()'. Any +objects used in containers must have well behaved constructors and +destructors. If you want to create containers that merely reference +(point to) objects that reside elsewhere, and are not copied or +destroyed inside the container, you must use containers of pointers, +not containers of objects. + + All prototypes are designed to generate *HOMOGENOUS* container +classes. There is no universally applicable method in C++ to support +heterogenous object collections with elements of various subclasses of +some specified base class. The only way to get heterogenous structures +is to use collections of pointers-to-objects, not collections of objects +(which also requires you to take responsibility for managing storage for +the objects pointed to yourself). + + For example, the following usage illustrates a commonly encountered +danger in trying to use container classes for heterogenous structures: + + class Base { int x; ...} + class Derived : public Base { int y; ... } + + BaseVHSet s; // class BaseVHSet generated via something like + // `genclass Base ref VHSet' + + void f() + { + Base b; + s.add(b); // OK + + Derived d; + s.add(d); // (CHOP!) + } + + At the line flagged with `(CHOP!)', a `Base::Base(Base&)' is called +inside `Set::add(Base&)'--*not* `Derived::Derived(Derived&)'. +Actually, in `VHSet', a `Base::operator =(Base&)', is used instead to +place the element in an array slot, but with the same effect. So only +the Base part is copied as a `VHSet' element (a so-called +chopped-copy). In this case, it has an `x' part, but no `y' part; and a +Base, not Derived, vtable. Objects formed via chopped copies are rarely +sensible. + + To avoid this, you must resort to pointers: + + typedef Base* BasePtr; + + BasePtrVHSet s; // class BaseVHSet generated via something like + // `genclass BasePtr val VHSet' + + void f() + { + Base* bp = new Base; + s.add(b); + + Base* dp = new Derived; + s.add(d); // works fine. + + // Don't forget to delete bp and dp sometime. + // The VHSet won't do this for you. + } + +Example +======= + + The prototypes can be difficult to use on first attempt. Here is an +example that may be helpful. The utilities in the `proto-kit' simplify +much of the actions described, but are not used here. + + Suppose you create a class `Person', and want to make an Map that +links the social security numbers associated with each person. You start +off with a file `Person.h' + + + #include + + class Person + { + String nm; + String addr; + //... + public: + const String& name() { return nm; } + const String& address() { return addr; } + void print() { ... } + //... + } + + And in file `SSN.h', + + typedef unsigned int SSN; + + Your first decision is what storage/usage strategy to use. There are +several reasonable alternatives here: You might create an "object +collection" of Persons, a "pointer collection" of pointers-to-Persons, +or even a simple String map, housing either copies of pointers to the +names of Persons, since other fields are unused for purposes of the +Map. In an object collection, instances of class Person "live" inside +the Map, while in a pointer collection, the instances live elsewhere. +Also, as above, if instances of subclasses of Person are to be used +inside the Map, you must use pointers. In a String Map, the same +difference holds, but now only for the name fields. Any of these +choices might make sense in particular applications. + + The second choice is the Map implementation strategy. Either a tree +or a hash table might make sense. Suppose you want an AVL tree Map. +There are two things to now check. First, as an object collection, the +AVLMap requires that the elsement class contain an `X(X&)' constructor. +In C++, if you don't specify such a constructor, one is constructed for +you, but it is a very good idea to always do this yourself, to avoid +surprises. In this example, you'd use something like + class Person + { ...; + Person(const Person& p) :nm(p.nm), addr(p.addr) {} + }; + + Also, an AVLMap requires a comparison function for elements in order +to maintain order. Rather than requiring you to write a particular +comparison function, a `defs' file is consulted to determine how to +compare items. You must create and edit such a file. + + Before creating `Person.defs.h', you must first make one additional +decision. Should the Map member functions like `m.contains(p)' take +arguments (`p') by reference (i.e., typed as `int Map::contains(const +Person& p)' or by value (i.e., typed as `int Map::contains(const Person +p)'. Generally, for user-defined classes, you want to pass by +reference, and for builtins and pointers, to pass by value. SO you +should pick by-reference. + + You can now create `Person.defs.h' via `genclass Person ref defs'. +This creates a simple skeleton that you must edit. First, add `#include +"Person.h"' to the top. Second, edit the `CMP(a,b)' macro to compare +on name, via + + #define CMP(a, b) ( compare(a.name(), b.name()) ) + +which invokes the `int compare(const String&, const String&)' function +from `String.h'. Of course, you could define this in any other way as +well. In fact, the default versions in the skeleton turn out to be OK +(albeit inefficient) in this particular example. + + You may also want to create file `SSN.defs.h'. Here, choosing +call-by-value makes sense, and since no other capabilities (like +comparison functions) of the SSNs are used (and the defaults are OK +anyway), you'd type + + genclass SSN val defs + +and then edit to place `#include "SSN.h"' at the top. + + Finally, you can generate the classes. First, generate the base +class for Maps via + + genclass -2 Person ref SSN val Map + +This generates only the abstract class, not the implementation, in file +`Person.SSN.Map.h' and `Person.SSN.Map.cc'. To create the AVL +implementation, type + + genclass -2 Person ref SSN val AVLMap + +This creates the class `PersonSSNAVLMap', in `Person.SSN.AVLMap.h' and +`Person.SSN.AVLMap.cc'. + + To use the AVL implementation, compile the two generated `.cc' +files, and specify `#include "Person.SSN.AVLMap.h"' in the application +program. All other files are included in the right ways automatically. + + One last consideration, peculiar to Maps, is to pick a reasonable +default contents when declaring an AVLMap. Zero might be appropriate +here, so you might declare a Map, + + PersonSSNAVLMap m((SSN)0); + + Suppose you wanted a `VHMap' instead of an `AVLMap' Besides +generating different implementations, there are two differences in how +you should prepare the `defs' file. First, because a VHMap uses a C++ +array internally, and because C++ array slots are initialized +differently than single elements, you must ensure that class Person +contains (1) a no-argument constructor, and (2) an assignment operator. +You could arrange this via + + class Person + { ...; + Person() {} + void operator = (const Person& p) { nm = p.nm; addr = p.addr; } + }; + + (The lack of action in the constructor is OK here because `Strings' +possess usable no-argument constructors.) + + You also need to edit `Person.defs.h' to indicate a usable hash +function and default capacity, via something like + + #include + #define HASH(x) (hashpjw(x.name().chars())) + #define DEFAULT_INITIAL_CAPACITY 1000 + + Since the `hashpjw' function from `builtin.h' is appropriate here. +Changing the default capacity to a value expected to exceed the actual +capacity helps to avoid "hidden" inefficiencies when a new VHMap is +created without overriding the default, which is all too easy to do. + + Otherwise, everything is the same as above, substituting `VHMap' for +`AVLMap'. + + +File: libg++.info, Node: Representations, Next: Expressions, Prev: Proto, Up: Top + +Variable-Sized Object Representation +************************************ + + One of the first goals of the GNU C++ library is to enrich the kinds +of basic classes that may be considered as (nearly) "built into" C++. A +good deal of the inspiration for these efforts is derived from +considering features of other type-rich languages, particularly Common +Lisp and Scheme. The general characteristics of most class and friend +operators and functions supported by these classes has been heavily +influenced by such languages. + + Four of these types, Strings, Integers, BitSets, and BitStrings (as +well as associated and/or derived classes) require representations +suitable for managing variable-sized objects on the free-store. The +basic technique used for all of these is the same, although various +details necessarily differ from class to class. + + The general strategy for representing such objects is to create +chunks of memory that include both header information (e.g., the size +of the object), as well as the variable-size data (an array of some +sort) at the end of the chunk. Generally the maximum size of an object +is limited to something less than all of addressable memory, as a +safeguard. The minimum size is also limited so as not to waste +allocations expanding very small chunks. Internally, chunks are +allocated in blocks well-tuned to the performance of the `new' operator. + + Class elements themselves are merely pointers to these chunks. Most +class operations are performed via inline "translation" functions that +perform the required operation on the corresponding representation. +However, constructors and assignments operate by copying entire +representations, not just pointers. + + No attempt is made to control temporary creation in expressions and +functions involving these classes. Users of previous versions of the +classes will note the disappearance of both "Tmp" classes and reference +counting. These were dropped because, while they did improve +performance in some cases, they obscure class mechanics, lead +programmers into the false belief that they need not worry about such +things, and occasionally have paradoxical behavior. + + These variable-sized object classes are integrated as well as +possible into C++. Most such classes possess converters that allow +automatic coercion both from and to builtin basic types. (e.g., char* +to and from String, long int to and from Integer, etc.). There are +pro's and con's to circular converters, since they can sometimes lead +to the conversion from a builtin type through to a class function and +back to a builtin type without any special attention on the part of the +programmer, both for better and worse. + + Most of these classes also provide special-case operators and +functions mixing basic with class types, as a way to avoid constructors +in cases where the operations do not rely on anything special about the +representations. For example, there is a special case concatenation +operator for a String concatenated with a char, since building the +result does not rely on anything about the String header. Again, there +are arguments both for and against this approach. Supporting these cases +adds a non-trivial degree of (mainly inline) function proliferation, but +results in more efficient operations. Efficiency wins out over parsimony +here, as part of the goal to produce classes that provide sufficient +functionality and efficiency so that programmers are not tempted to try +to manipulate or bypass the underlying representations. + + +File: libg++.info, Node: Expressions, Next: Pix, Prev: Representations, Up: Top + +Some guidelines for using expression-oriented classes +***************************************************** + + The fact that C++ allows operators to be overloaded for user-defined +classes can make programming with library classes like `Integer', +`String', and so on very convenient. However, it is worth becoming +familiar with some of the inherent limitations and problems associated +with such operators. + + Many operators are *constructive*, i.e., create a new object based +on some function of some arguments. Sometimes the creation of such +objects is wasteful. Most library classes supporting expressions +contain facilities that help you avoid such waste. + + For example, for `Integer a, b, c; ...; c = a + b + a;', the plus +operator is called to sum a and b, creating a new temporary object as +its result. This temporary is then added with a, creating another +temporary, which is finally copied into c, and the temporaries are then +deleted. In other words, this code might have an effect similar to +`Integer a, b, c; ...; Integer t1(a); t1 += b; Integer t2(t1); t2 += a; +c = t2;'. + + For small objects, simple operators, and/or non-time/space critical +programs, creation of temporaries is not a big problem. However, often, +when fine-tuning a program, it may be a good idea to rewrite such code +in a less pleasant, but more efficient manner. + + For builtin types like ints, and floats, C and C++ compilers already +know how to optimize such expressions to reduce the need for +temporaries. Unfortunately, this is not true for C++ user defined +types, for the simple (but very annoying, in this context) reason that +nothing at all is guaranteed about the semantics of overloaded operators +and their interrelations. For example, if the above expression just +involved ints, not Integers, a compiler might internally convert the +statement into something like ` c = a; c += b; c+= a; ', or perhaps +something even more clever. But since C++ does not know that Integer +operator += has any relation to Integer operator +, A C++ compiler +cannot do this kind of expression optimization itself. + + In many cases, you can avoid construction of temporaries simply by +using the assignment versions of operators whenever possible, since +these versions create no temporaries. However, for maximum flexibility, +most classes provide a set of "embedded assembly code" procedures that +you can use to fully control time, space, and evaluation strategies. +Most of these procedures are "three-address" procedures that take two +`const' source arguments, and a destination argument. The procedures +perform the appropriate actions, placing the results in the destination +(which is may involve overwriting old contents). These procedures are +designed to be fast and robust. In particular, aliasing is always +handled correctly, so that, for example `add(x, x, x); ' is perfectly +OK. (The names of these procedures are listed along with the classes.) + + For example, suppose you had an Integer expression ` a = (b - a) * +-(d / c); ' + + This would be compiled as if it were ` Integer t1=b-a; Integer +t2=d/c; Integer t3=-t2; Integer t4=t1*t3; a=t4;' + + But, with some manual cleverness, you might yourself some up with ` +sub(a, b, a); mul(a, d, a); div(a, c, a); ' + + A related phenomenon occurs when creating your own constructive +functions returning instances of such types. Suppose you wanted to +write function `Integer f(const Integer& a) { Integer r = a; r += a; +return r; }' + + This function, when called (as in ` a = f(a); ') demonstrates a +similar kind of wasted copy. The returned value r must be copied out of +the function before it can be used by the caller. In GNU C++, there is +an alternative via the use of named return values. Named return values +allow you to manipulate the returned object directly, rather than +requiring you to create a local inside a function and then copy it out +as the returned value. In this example, this can be done via `Integer +f(const Integer& a) return r(a) { r += a; return; }' + + A final guideline: The overloaded operators are very convenient, and +much clearer to use than procedural code. It is almost always a good +idea to make it right, *then* make it fast, by translating expression +code into procedural code after it is known to be correct. + + +File: libg++.info, Node: Pix, Next: Headers, Prev: Expressions, Up: Top + +Pseudo-indexes +************** + + Many useful classes operate as containers of elements. Techniques for +accessing these elements from a container differ from class to class. +In the GNU C++ library, access methods have been partially standardized +across different classes via the use of pseudo-indexes called `Pixes'. +A `Pix' acts in some ways like an index, and in some ways like a +pointer. (Their underlying representations are just `void*' pointers). +A `Pix' is a kind of "key" that is translated into an element access by +the class. In virtually all cases, `Pixes' are pointers to some kind +internal storage cells. The containers use these pointers to extract +items. + + `Pixes' support traversal and inspection of elements in a collection +using analogs of array indexing. However, they are pointer-like in that +`0' is treated as an invalid `Pix', and unsafe insofar as programmers +can attempt to access nonexistent elements via dangling or otherwise +invalid `Pixes' without first checking for their validity. + + In general it is a very bad idea to perform traversals in the the +midst of destructive modifications to containers. + + Typical applications might include code using the idiom + for (Pix i = a.first(); i != 0; a.next(i)) use(a(i)); + for some container `a' and function `use'. + + Classes supporting the use of `Pixes' always contain the following +methods, assuming a container `a' of element types of `Base'. + +`Pix i = a.first()' + Set i to index the first element of a or 0 if a is empty. + +`a.next(i)' + advance i to the next element of a or 0 if there is no next + element; + +`Base x = a(i); a(i) = x;' + a(i) returns a reference to the element indexed by i. + +`int present = a.owns(i)' + returns true if Pix i is a valid Pix in a. This is often a + relatively slow operation, since the collection must usually + traverse through elements to see if any correspond to the Pix. + + Some container classes also support backwards traversal via + +`Pix i = a.last()' + Set i to the last element of a or 0 if a is empty. + +`a.prev(i)' + sets i to the previous element in a, or 0 if there is none. + + Collections supporting elements with an equality operation possess + +`Pix j = a.seek(x)' + sets j to the index of the first occurrence of x, or 0 if x is not + contained in a. + + Bag classes possess + +`Pix j = a.seek(x, Pix from = 0)' + sets j to the index of the next occurrence of x following i, or 0 + if x is not contained in a. If i == 0, the first occurrence is + returned. + + Set, Bag, and PQ classes possess + +`Pix j = a.add(x) (or a.enq(x) for priority queues)' + add x to the collection, returning its Pix. The Pix of an item can + change in collections where further additions and deletions + involve the actual movement of elements (currently in OXPSet, + OXPBag, XPPQ, VOHSet), but in all other cases, an item's Pix may + be considered a permanent key to its location. + + +File: libg++.info, Node: Headers, Next: Builtin, Prev: Pix, Up: Top + +Header files for interfacing C++ to C +************************************* + + The following files are provided so that C++ programmers may invoke +common C library and system calls. The names and contents of these +files are subject to change in order to be compatible with the +forthcoming GNU C library. Other files, not listed here, are simply +C++-compatible interfaces to corresponding C library files. + +`values.h' + A collection of constants defining the numbers of bits in builtin + types, minimum and maximum values, and the like. Most names are + the same as those found in `values.h' found on Sun systems. + +`std.h' + A collection of common system calls and `libc.a' functions. Only + those functions that can be declared without introducing new type + definitions (socket structures, for example) are provided. Common + `char*' functions (like `strcmp') are among the declarations. All + functions are declared along with their library names, so that + they may be safely overloaded. + +`string.h' + This file merely includes `', where string function + prototypes are declared. This is a workaround for the fact that + system `string.h' and `strings.h' files often differ in contents. + +`osfcn.h' + This file merely includes `', where system function + prototypes are declared. + +`libc.h' + This file merely includes `', where C library function + prototypes are declared. + +`math.h' + A collection of prototypes for functions usually found in libm.a, + plus some `#define'd constants that appear to be consistent with + those provided in the AT&T version. The value of `HUGE' should be + checked before using. Declarations of all common math functions + are preceded with `overload' declarations, since these are + commonly overloaded. + +`stdio.h' + Declaration of `FILE' (`_iobuf'), common macros (like `getc'), and + function prototypes for `libc.a' functions that operate on + `FILE*''s. The value `BUFSIZ' and the declaration of `_iobuf' + should be checked before using. + +`assert.h' + C++ versions of assert macros. + +`generic.h' + String concatenation macros useful in creating generic classes. + They are similar in function to the AT&T CC versions. + +`new.h' + Declarations of the default global operator new, the two-argument + placement version, and associated error handlers. + + +File: libg++.info, Node: Builtin, Next: New, Prev: Headers, Up: Top + +Utility functions for built in types +************************************ + + Files `builtin.h' and corresponding `.cc' implementation files +contain various convenient inline and non-inline utility functions. +These include useful enumeration types, such as `TRUE', `FALSE' ,the +type definition for pointers to libg++ error handling functions, and +the following functions. + +`long abs(long x); double abs(double x);' + inline versions of abs. Note that the standard libc.a version, + `int abs(int)' is *not* declared as inline. + +`void clearbit(long& x, long b);' + clears the b'th bit of x (inline). + +`void setbit(long& x, long b);' + sets the b'th bit of x (inline) + +`int testbit(long x, long b);' + returns the b'th bit of x (inline). + +`int even(long y);' + returns true if x is even (inline). + +`int odd(long y);' + returns true is x is odd (inline). + +`int sign(long x); int sign(double x);' + returns -1, 0, or 1, indicating whether x is less than, equal to, + or greater than zero (inline). + +`long gcd(long x, long y);' + returns the greatest common divisor of x and y. + +`long lcm(long x, long y);' + returns the least common multiple of x and y. + +`long lg(long x);' + returns the floor of the base 2 log of x. + +`long pow(long x, long y); double pow(double x, long y);' + returns x to the integer power y using via the iterative O(log y) + "Russian peasant" method. + +`long sqr(long x); double sqr(double x);' + returns x squared (inline). + +`long sqrt(long y);' + returns the floor of the square root of x. + +`unsigned int hashpjw(const char* s);' + a hash function for null-terminated char* strings using the method + described in Aho, Sethi, & Ullman, p 436. + +`unsigned int multiplicativehash(int x);' + a hash function for integers that returns the lower bits of + multiplying x by the golden ratio times pow(2, 32). See Knuth, + Vol 3, p 508. + +`unsigned int foldhash(double x);' + a hash function for doubles that exclusive-or's the first and + second words of x, returning the result as an integer. + +`double start_timer()' + Starts a process timer. + +`double return_elapsed_time(double last_time)' + Returns the process time since last_time. If last_time == 0 + returns the time since the last start_timer. Returns -1 if + start_timer was not first called. + + File `Maxima.h' includes versions of `MAX, MIN' for builtin types. + + File `compare.h' includes versions of `compare(x, y)' for builtin +types. These return negative if the first argument is less than the +second, zero for equal, and positive for greater. + + +File: libg++.info, Node: New, Next: Stream, Prev: Builtin, Up: Top + +Library dynamic allocation primitives +************************************* + + Libg++ contains versions of `malloc, free, realloc' that were +designed to be well-tuned to C++ applications. The source file +`malloc.c' contains some design and implementation details. Here are +the major user-visible differences from most system malloc routines: + + 1. These routines *overwrite* storage of freed space. This means that + it is never permissible to use a `delete''d object in any way. + Doing so will either result in trapped fatal errors or random + aborts within malloc, free, or realloc. + + 2. The routines tend to perform well when a large number of objects + of the same size are allocated and freed. You may find that it is + not worth it to create your own special allocation schemes in such + cases. + + 3. The library sets top-level `operator new()' to call malloc and + `operator delete()' to call free. Of course, you may override these + definitions in C++ programs by creating your own operators that + will take precedence over the library versions. However, if you do + so, be sure to define *both* `operator new()' and `operator + delete()'. + + 4. These routines do *not* support the odd convention, maintained by + some versions of malloc, that you may call `realloc' with a pointer + that has been `free''d. + + 5. The routines automatically perform simple checks on `free''d + pointers that can often determine whether users have accidentally + written beyond the boundaries of allocated space, resulting in a + fatal error. + + 6. The function `malloc_usable_size(void* p)' returns the number of + bytes actually allocated for `p'. For a valid pointer (i.e., one + that has been `malloc''d or `realloc''d but not yet `free''d) this + will return a number greater than or equal to the requested size, + else it will normally return 0. Unfortunately, a non-zero return + can not be an absolutely perfect indication of lack of error. If a + chunk has been `free''d but then re-allocated for a different + purpose somewhere elsewhere, then `malloc_usable_size' will return + non-zero. Despite this, the function can be very valuable for + performing run-time consistency checks. + + 7. `malloc' requires 8 bytes of overhead per allocated chunk, plus a + mmaximum alignment adjustment of 8 bytes. The number of bytes of + usable space is exactly as requested, rounded to the nearest 8 + byte boundary. + + 8. The routines do *not* contain any synchronization support for + multiprocessing. If you perform global allocation on a shared + memory multiprocessor, you should disable compilation and use of + libg++ malloc in the distribution `Makefile' and use your system + version of malloc. + + + +File: libg++.info, Node: Stream, Next: Obstack, Prev: New, Up: Top + +The old I/O library +******************* + + WARNING: This chapter describes classes that are *obsolete*. These +classes are normally not available when libg++ is installed normally. +The sources are currently included in the distribution, and you can +configure libg++ to use these classes instead of the new iostream +classes. This is only a temporary measure; you should convert your +code to use iostreams as soon as possible. The iostream classes +provide some compatibility support, but it is very incomplete (there is +no longer a `File' class). + +File-based classes +================== + + The `File' class supports basic IO on Unix files. Operations are +based on common C stdio library functions. + + `File' serves as the base class for istreams, ostreams, and other +derived classes. It contains the interface between the Unix stdio file +library and these more structured classes. Most operations are +implemented as simple calls to stdio functions. `File' class operations +are also fully compatible with raw system file reads and writes (like +the system `read' and `lseek' calls) when buffering is disabled (see +below). The `FILE*' stdio file pointer is, however maintained as +protected. Classes derived from File may only use the IO operations +provided by File, which encompass essentially all stdio capabilities. + + The class contains four general kinds of functions: methods for +binding `File's to physical Unix files, basic IO methods, file and +buffer control methods, and methods for maintaining logical and +physical file status. + + Binding and related tasks are accomplished via `File' constructors +and destructors, and member functions `open, close, remove, filedesc, +name, setname'. + + If a file name is provided in a constructor or open, it is +maintained as class variable `nm' and is accessible via `name'. If no +name is provided, then `nm' remains null, except that `Files' bound to +the default files stdin, stdout, and stderr are automatically given the +names `(stdin), (stdout), (stderr)' respectively. The function +`setname' may be used to change the internal name of the `File'. This +does not change the name of the physical file bound to the File. + + The member function `close' closes a file. The `~File' destructor +closes a file if it is open, except that stdin, stdout, and stderr are +flushed but left open for the system to close on program exit since +some systems may require this, and on others it does not matter. +`remove' closes the file, and then deletes it if possible by calling the +system function to delete the file with the name provided in the `nm' +field. + +Basic IO +======== + + * `read' and `write' perform binary IO via stdio `fread' and + `fwrite'. + + * `get' and `put' for chars invoke stdio `getc' and `putc' macros. + + * `put(const char* s)' outputs a null-terminated string via stdio + `fputs'. + + * `unget' and `putback' are synonyms. Both call stdio `ungetc'. + +File Control +============ + + `flush', `seek', `tell', and `tell' call the corresponding stdio +functions. + + `flush(char)' and `fill()' call stdio `_flsbuf' and `_filbuf' +respectively. + + `setbuf' is mainly useful to turn off buffering in cases where +nonsequential binary IO is being performed. `raw' is a synonym for +`setbuf(_IONBF)'. After a `f.raw()', using the stdio functions instead +of the system `read, write', etc., calls entails very little overhead. +Moreover, these become fully compatible with intermixed system calls +(e.g., `lseek(f.filedesc(), 0, 0)'). While intermixing `File' and +system IO calls is not at all recommended, this technique does allow +the `File' class to be used in conjunction with other functions and +libraries already set up to operate on file descriptors. `setbuf' +should be called at most once after a constructor or open, but before +any IO. + +File Status +=========== + + File status is maintained in several ways. + + A `File' may be checked for accessibility via `is_open()', which +returns true if the File is bound to a usable physical file, +`readable()', which returns true if the File can be read from (opened +for reading, and not in a _fail state), or `writable()', which returns +true if the File can be written to. + + `File' operations return their status via two means: failure and +success are represented via the logical state. Also, the return values +of invoked stdio and system functions that return useful numeric values +(not just failure/success flags) are held in a class variable +accessible via `iocount'. (This is useful, for example, in determining +the number of items actually read by the `read' function.) + + Like the AT&T i/o-stream classes, but unlike the description in the +Stroustrup book, p238, `rdstate()' returns the bitwise OR of `_eof', +`_fail' and `_bad', not necessarily distinct values. The functions +`eof()', `fail()', `bad()', and `good()' can be used to test for each of +these conditions independently. + + `_fail' becomes set for any input operation that could not read in +the desired data, and for other failed operations. As with all Unix IO, +`_eof' becomes true only when an input operations fails because of an +end of file. Therefore, `_eof' is not immediately true after the last +successful read of a file, but only after one final read attempt. Thus, +for input operations, `_fail' and `_eof' almost always become true at +the same time. `bad' is set for unbound files, and may also be set by +applications in order to communicate input corruption. Conversely, +`_good' is defined as 0 and is returned by `rdstate()' if all is well. + + The state may be modified via `clear(flag)', which, despite its +name, sets the corresponding state_value flag. `clear()' with no +arguments resets the state to `_good'. `failif(int cond)' sets the +state to `_fail' only if `cond' is true. + + Errors occuring during constructors and file opens also invoke the +function `error'. `error' in turn calls a resetable error handling +function pointed to by the non-member global variable +`File_error_handler' only if a system error has been generated. Since +`error' cannot tell if the current system error is actually responsible +for a failure, it may at times print out spurious messages. Three +error handlers are provided. The default, `verbose_File_error_handler' +calls the system function `perror' to print the corresponding error +message on standard error, and then returns to the caller. +`quiet_File_error_handler' does nothing, and simply returns. +`fatal_File_error_handler' prints the error and then aborts execution. +These three handlers, or any other user-defined error handlers can be +selected via the non-member function `set_File_error_handler'. + + All read and write operations communicate either logical or physical +failure by setting the `_fail' flag. All further operations are +blocked if the state is in a `_fail' or`_bad' condition. Programmers +must explicitly use `clear()' to reset the state in order to continue +IO processing after either a logical or physical failure. C +programmers who are unfamiliar with these conventions should note that, +unlike the stdio library, `File' functions indicate IO success, status, +or failure solely through the state, not via return values of the +functions. The `void*' operator or `rdstate()' may be used to test +success. In particular, according to c++ conversion rules, the `void*' +coercion is automatically applied whenever the `File&' return value of +any `File' function is tested in an `if' or `while'. Thus, for +example, an easy way to copy all of stdin to stdout until eof (at which +point `get' fails) or some error is `char c; while(cin.get(c) && +cout.put(c));'. + + The current version of istreams and ostreams differs significantly +from previous versions in order to obtain compatibility with AT&T 1.2 +streams. Most code using previous versions should still work. However, +the following features of `File' are not incorporated in streams (they +are still present in `File'): `scan(const char* fmt...), remove(), +read(), write(), setbuf(), raw()'. Additionally, the feature of +previous streams that allowed free intermixing of stream and stdio +input and output is no longer guaranteed to always behave as desired. + + +File: libg++.info, Node: Obstack, Next: AllocRing, Prev: Stream, Up: Top + +The Obstack class +***************** + + The `Obstack' class is a simple rewrite of the C obstack macros and +functions provided in the GNU CC compiler source distribution. + + Obstacks provide a simple method of creating and maintaining a string +table, optimized for the very frequent task of building strings +character-by-character, and sometimes keeping them, and sometimes not. +They seem especially useful in any parsing application. One of the test +files demonstrates usage. + + A brief summary: +`grow' + places something on the obstack without committing to wrap it up + as a single entity yet. + +`finish' + wraps up a constructed object as a single entity, and returns the + pointer to its start address. + +`copy' + places things on the obstack, and *does* wrap them up. `copy' is + always equivalent to first grow, then finish. + +`free' + deletes something, and anything else put on the obstack since its + creation. + + The other functions are less commonly needed: +`blank' + is like grow, except it just grows the space by size units without + placing anything into this space + +`alloc' + is like `blank', but it wraps up the object and returns its + starting address. + +`chunk_size, base, next_free, alignment_mask, size, room' + returns the appropriate class variables. + +`grow_fast' + places a character on the obstack without checking if there is + enough room. + +`blank_fast' + like `blank', but without checking if there is enough room. + +`shrink(int n)' + shrink the current chunk by n bytes. + +`contains(void* addr)' + returns true if the Obstack holds the address addr. + + Here is a lightly edited version of the original C documentation: + + These functions 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 the GNU C++ `new' +operator. On occasion, they free chunks, via `delete'. + + Each independent stack is represented by a Obstack. + + One motivation for this package is the problem of growing char +strings in symbol tables. Unless you are a "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 version of grow is provided to add a single char at a time +to a growing object. + + 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' a obstack back to a + previous state. (You may remove objects much as you would with a + stack.) + + The obstack data structure is used in many places in the GNU C++ +compiler. + + Differences from the the GNU C version + 1. The obvious differences stemming from the use of classes and + inline functions instead of structs and macros. The C `init' and + `begin' macros are replaced by constructors. + + 2. Overloaded function names are used for grow (and others), rather + than the C `grow', `grow0', etc. + + 3. All dynamic allocation uses the the built-in `new' operator. This + restricts flexibility by a little, but maintains compatibility + with usual C++ conventions. + + 4. There are now two versions of finish: + + 1. finish() behaves like the C version. + + 2. finish(char terminator) adds `terminator', and then calls + `finish()'. This enables the normal invocation of + `finish(0)' to wrap up a string being grown + character-by-character. + + 5. There are special versions of grow(const char* s) and copy(const + char* s) that add the null-terminated string `s' after computing + its length. + + 6. The shrink and contains functions are provided. + + + +File: libg++.info, Node: AllocRing, Next: String, Prev: Obstack, Up: Top + +The AllocRing class +******************* + + An AllocRing is a bounded ring (circular list), each of whose +elements contains a pointer to some space allocated via `new +char[some_size]'. The entries are used cyclicly. The size, n, of the +ring is fixed at construction. After that, every nth use of the ring +will reuse (or reallocate) the same space. AllocRings are needed in +order to temporarily hold chunks of space that are needed transiently, +but across constructor-destructor scopes. They mainly useful for storing +strings containing formatted characters to print across various +functions and coercions. These strings are needed across routines, so +may not be deleted in any one of them, but should be recovered at some +point. In other words, an AllocRing is an extremely simple minded +garbage collection mechanism. The GNU C++ library used to use one +AllocRing for such formatting purposes, but it is being phased out, and +is now only used by obsolete functions. These days, AllocRings are +probably not very useful. + + Support includes: + +`AllocRing a(int n)' + constructs an Alloc ring with n entries, all null. + +`void* mem = a.alloc(sz)' + moves the ring pointer to the next entry, and reuses the space if + their is enough, also allocates space via new char[sz]. + +`int present = a.contains(void* ptr)' + returns true if ptr is held in one of the ring entries. + +`a.clear()' + deletes all space pointed to in any entry. This is called + automatically upon destruction. + +`a.free(void* ptr)' + If ptr is one of the entries, calls delete of the pointer, and + resets to entry pointer to null. + diff --git a/gnu/lib/libg++/libg++/libg++.info-3 b/gnu/lib/libg++/libg++/libg++.info-3 new file mode 100644 index 00000000000..e41195dec1f --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info-3 @@ -0,0 +1,1397 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: libg++.info, Node: String, Next: Integer, Prev: AllocRing, Up: Top + +The String class +**************** + + The `String' class is designed to extend GNU C++ to support string +processing capabilities similar to those in languages like Awk. The +class provides facilities that ought to be convenient and efficient +enough to be useful replacements for `char*' based processing via the C +string library (i.e., `strcpy, strcmp,' etc.) in many applications. +Many details about String representations are described in the +Representation section. + + A separate `SubString' class supports substring extraction and +modification operations. This is implemented in a way that user +programs never directly construct or represent substrings, which are +only used indirectly via String operations. + + Another separate class, `Regex' is also used indirectly via String +operations in support of regular expression searching, matching, and the +like. The Regex class is based entirely on the GNU Emacs regex +functions. *Note Syntax of Regular Expressions: (emacs.info)Regexps, +for a full explanation of regular expression syntax. (For +implementation details, see the internal documentation in files +`regex.h' and `regex.c'.) + +Constructors +============ + + Strings are initialized and assigned as in the following examples: + +`String x; String y = 0; String z = "";' + Set x, y, and z to the nil string. Note that either 0 or "" may + always be used to refer to the nil string. + +`String x = "Hello"; String y("Hello");' + Set x and y to a copy of the string "Hello". + +`String x = 'A'; String y('A');' + Set x and y to the string value "A" + +`String u = x; String v(x);' + Set u and v to the same string as String x + +`String u = x.at(1,4); String v(x.at(1,4));' + Set u and v to the length 4 substring of x starting at position 1 + (counting indexes from 0). + +`String x("abc", 2);' + Sets x to "ab", i.e., the first 2 characters of "abc". + +`String x = dec(20);' + Sets x to "20". As here, Strings may be initialized or assigned + the results of any `char*' function. + + There are no directly accessible forms for declaring SubString +variables. + + The declaration `Regex r("[a-zA-Z_][a-zA-Z0-9_]*");' creates a +compiled regular expression suitable for use in String operations +described below. (In this case, one that matches any C++ identifier). +The first argument may also be a String. Be careful in distinguishing +the role of backslashes in quoted GNU C++ char* constants versus those +in Regexes. For example, a Regex that matches either one or more tabs +or all strings beginning with "ba" and ending with any number of +occurrences of "na" could be declared as `Regex r = +"\\(\t+\\)\\|\\(ba\\(na\\)*\\)"' Note that only one backslash is needed +to signify the tab, but two are needed for the parenthesization and +virgule, since the GNU C++ lexical analyzer decodes and strips +backslashes before they are seen by Regex. + + There are three additional optional arguments to the Regex +constructor that are less commonly useful: + +`fast (default 0)' + `fast' may be set to true (1) if the Regex should be + "fast-compiled". This causes an additional compilation step that + is generally worthwhile if the Regex will be used many times. + +`bufsize (default max(40, length of the string))' + This is an estimate of the size of the internal compiled + expression. Set it to a larger value if you know that the + expression will require a lot of space. If you do not know, do not + worry: realloc is used if necessary. + +`transtable (default none == 0)' + The address of a byte translation table (a char[256]) that + translates each character before matching. + + As a convenience, several Regexes are predefined and usable in any +program. Here are their declarations from `String.h'. + + extern Regex RXwhite; // = "[ \n\t]+" + extern Regex RXint; // = "-?[0-9]+" + extern Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| + // \\([0-9]+\\)\\| + // \\(\\.[0-9]+\\)\\) + // \\([eE][---+]?[0-9]+\\)?" + extern Regex RXalpha; // = "[A-Za-z]+" + extern Regex RXlowercase; // = "[a-z]+" + extern Regex RXuppercase; // = "[A-Z]+" + extern Regex RXalphanum; // = "[0-9A-Za-z]+" + extern Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" + +Examples +======== + + Most `String' class capabilities are best shown via example. The +examples below use the following declarations. + + String x = "Hello"; + String y = "world"; + String n = "123"; + String z; + char* s = ","; + String lft, mid, rgt; + Regex r = "e[a-z]*o"; + Regex r2("/[a-z]*/"); + char c; + int i, pos, len; + double f; + String words[10]; + words[0] = "a"; + words[1] = "b"; + words[2] = "c"; + +Comparing, Searching and Matching +================================= + + The usual lexicographic relational operators (`==, !=, <, <=, >, >=') +are defined. A functional form `compare(String, String)' is also +provided, as is `fcompare(String, String)', which compares Strings +without regard for upper vs. lower case. + + All other matching and searching operations are based on some form +of the (non-public) `match' and `search' functions. `match' and +`search' differ in that `match' attempts to match only at the given +starting position, while `search' starts at the position, and then +proceeds left or right looking for a match. As seen in the following +examples, the second optional `startpos' argument to functions using +`match' and `search' specifies the starting position of the search: If +non-negative, it results in a left-to-right search starting at position +`startpos', and if negative, a right-to-left search starting at +position `x.length() + startpos'. In all cases, the index returned is +that of the beginning of the match, or -1 if there is no match. + + Three String functions serve as front ends to `search' and `match'. +`index' performs a search, returning the index, `matches' performs a +match, returning nonzero (actually, the length of the match) on success, +and `contains' is a boolean function performing either a search or +match, depending on whether an index argument is provided: + +`x.index("lo")' + returns the zero-based index of the leftmost occurrence of + substring "lo" (3, in this case). The argument may be a String, + SubString, char, char*, or Regex. + +`x.index("l", 2)' + returns the index of the first of the leftmost occurrence of "l" + found starting the search at position x[2], or 2 in this case. + +`x.index("l", -1)' + returns the index of the rightmost occurrence of "l", or 3 here. + +`x.index("l", -3)' + returns the index of the rightmost occurrence of "l" found by + starting the search at the 3rd to the last position of x, + returning 2 in this case. + +`pos = r.search("leo", 3, len, 0)' + returns the index of r in the `char*' string of length 3, starting + at position 0, also placing the length of the match in reference + parameter len. + +`x.contains("He")' + returns nonzero if the String x contains the substring "He". The + argument may be a String, SubString, char, char*, or Regex. + +`x.contains("el", 1)' + returns nonzero if x contains the substring "el" at position 1. + As in this example, the second argument to `contains', if present, + means to match the substring only at that position, and not to + search elsewhere in the string. + +`x.contains(RXwhite);' + returns nonzero if x contains any whitespace (space, tab, or + newline). Recall that `RXwhite' is a global whitespace Regex. + +`x.matches("lo", 3)' + returns nonzero if x starting at position 3 exactly matches "lo", + with no trailing characters (as it does in this example). + +`x.matches(r)' + returns nonzero if String x as a whole matches Regex r. + +`int f = x.freq("l")' + returns the number of distinct, nonoverlapping matches to the + argument (2 in this case). + +Substring extraction +==================== + + Substrings may be extracted via the `at', `before', `through', +`from', and `after' functions. These behave as either lvalues or +rvalues. + +`z = x.at(2, 3)' + sets String z to be equal to the length 3 substring of String x + starting at zero-based position 2, setting z to "llo" in this + case. A nil String is returned if the arguments don't make sense. + +`x.at(2, 2) = "r"' + Sets what was in positions 2 to 3 of x to "r", setting x to "Hero" + in this case. As indicated here, SubString assignments may be of + different lengths. + +`x.at("He") = "je";' + x("He") is the substring of x that matches the first occurrence of + it's argument. The substitution sets x to "jello". If "He" did not + occur, the substring would be nil, and the assignment would have + no effect. + +`x.at("l", -1) = "i";' + replaces the rightmost occurrence of "l" with "i", setting x to + "Helio". + +`z = x.at(r)' + sets String z to the first match in x of Regex r, or "ello" in this + case. A nil String is returned if there is no match. + +`z = x.before("o")' + sets z to the part of x to the left of the first occurrence of + "o", or "Hell" in this case. The argument may also be a String, + SubString, or Regex. (If there is no match, z is set to "".) + +`x.before("ll") = "Bri";' + sets the part of x to the left of "ll" to "Bri", setting x to + "Brillo". + +`z = x.before(2)' + sets z to the part of x to the left of x[2], or "He" in this case. + +`z = x.after("Hel")' + sets z to the part of x to the right of "Hel", or "lo" in this + case. + +`z = x.through("el")' + sets z to the part of x up and including "el", or "Hel" in this + case. + +`z = x.from("el")' + sets z to the part of x from "el" to the end, or "ello" in this + case. + +`x.after("Hel") = "p";' + sets x to "Help"; + +`z = x.after(3)' + sets z to the part of x to the right of x[3] or "o" in this case. + +`z = " ab c"; z = z.after(RXwhite)' + sets z to the part of its old string to the right of the first + group of whitespace, setting z to "ab c"; Use gsub(below) to strip + out multiple occurrences of whitespace or any pattern. + +`x[0] = 'J';' + sets the first element of x to 'J'. x[i] returns a reference to + the ith element of x, or triggers an error if i is out of range. + +`common_prefix(x, "Help")' + returns the String containing the common prefix of the two Strings + or "Hel" in this case. + +`common_suffix(x, "to")' + returns the String containing the common suffix of the two Strings + or "o" in this case. + +Concatenation +============= + +`z = x + s + ' ' + y.at("w") + y.after("w") + ".";' + sets z to "Hello, world." + +`x += y;' + sets x to "Helloworld" + +`cat(x, y, z)' + A faster way to say z = x + y. + +`cat(z, y, x, x)' + Double concatenation; A faster way to say x = z + y + x. + +`y.prepend(x);' + A faster way to say y = x + y. + +`z = replicate(x, 3);' + sets z to "HelloHelloHello". + +`z = join(words, 3, "/")' + sets z to the concatenation of the first 3 Strings in String array + words, each separated by "/", setting z to "a/b/c" in this case. + The last argument may be "" or 0, indicating no separation. + +Other manipulations +=================== + +`z = "this string has five words"; i = split(z, words, 10, RXwhite);' + sets up to 10 elements of String array words to the parts of z + separated by whitespace, and returns the number of parts actually + encountered (5 in this case). Here, words[0] = "this", words[1] = + "string", etc. The last argument may be any of the usual. If + there is no match, all of z ends up in words[0]. The words array + is *not* dynamically created by split. + +`int nmatches x.gsub("l","ll")' + substitutes all original occurrences of "l" with "ll", setting x + to "Hellllo". The first argument may be any of the usual, + including Regex. If the second argument is "" or 0, all + occurrences are deleted. gsub returns the number of matches that + were replaced. + +`z = x + y; z.del("loworl");' + deletes the leftmost occurrence of "loworl" in z, setting z to + "Held". + +`z = reverse(x)' + sets z to the reverse of x, or "olleH". + +`z = upcase(x)' + sets z to x, with all letters set to uppercase, setting z to + "HELLO" + +`z = downcase(x)' + sets z to x, with all letters set to lowercase, setting z to + "hello" + +`z = capitalize(x)' + sets z to x, with the first letter of each word set to uppercase, + and all others to lowercase, setting z to "Hello" + +`x.reverse(), x.upcase(), x.downcase(), x.capitalize()' + in-place, self-modifying versions of the above. + +Reading, Writing and Conversion +=============================== + +`cout << x' + writes out x. + +`cout << x.at(2, 3)' + writes out the substring "llo". + +`cin >> x' + reads a whitespace-bounded string into x. + +`x.length()' + returns the length of String x (5, in this case). + +`s = (const char*)x' + can be used to extract the `char*' char array. This coercion is + useful for sending a String as an argument to any function + expecting a `const char*' argument (like `atoi', and + `File::open'). This operator must be used with care, since the + conversion returns a pointer to `String' internals without copying + the characters: The resulting `(char*)' is only valid until the + next String operation, and you must not modify it. (The + conversion is defined to return a const value so that GNU C++ will + produce warning and/or error messages if changes are attempted.) + + +File: libg++.info, Node: Integer, Next: Rational, Prev: String, Up: Top + +The Integer class. +****************** + + The `Integer' class provides multiple precision integer arithmetic +facilities. Some representation details are discussed in the +Representation section. + + `Integers' may be up to `b * ((1 << b) - 1)' bits long, where `b' is +the number of bits per short (typically 1048560 bits when `b = 16'). +The implementation assumes that a `long' is at least twice as long as a +`short'. This assumption hides beneath almost all primitive operations, +and would be very difficult to change. It also relies on correct +behavior of *unsigned* arithmetic operations. + + Some of the arithmetic algorithms are very loosely based on those +provided in the MIT Scheme `bignum.c' release, which is Copyright (c) +1987 Massachusetts Institute of Technology. Their use here falls within +the provisions described in the Scheme release. + + Integers may be constructed in the following ways: +`Integer x;' + Declares an uninitialized Integer. + +`Integer x = 2; Integer y(2);' + Set x and y to the Integer value 2; + +`Integer u(x); Integer v = x;' + Set u and v to the same value as x. + + - Method: long Integer::as_long() const + Used to coerce an `Integer' back into longs via the `long' + coercion operator. If the Integer cannot fit into a long, this + returns MINLONG or MAXLONG (depending on the sign) where MINLONG + is the most negative, and MAXLONG is the most positive + representable long. + + - Method: int Integer::fits_in_long() const + Returns true iff the `Integer' is `< MAXLONG' and `> MINLONG'. + + - Method: double Integer::as_double() const + Coerce the `Integer' to a `double', with potential loss of + precision. `+/-HUGE' is returned if the Integer cannot fit into a + double. + + - Method: int Integer::fits_in_double() const + Returns true iff the `Integer' can fit into a double. + + All of the usual arithmetic operators are provided (`+, -, *, /, %, ++=, ++, -=, --, *=, /=, %=, ==, !=, <, <=, >, >='). All operators +support special versions for mixed arguments of Integers and regular +C++ longs in order to avoid useless coercions, as well as to allow +automatic promotion of shorts and ints to longs, so that they may be +applied without additional Integer coercion operators. The only +operators that behave differently than the corresponding int or long +operators are `++' and `--'. Because C++ does not distinguish prefix +from postfix application, these are declared as `void' operators, so +that no confusion can result from applying them as postfix. Thus, for +Integers x and y, ` ++x; y = x; ' is correct, but ` y = ++x; ' and ` y += x++; ' are not. + + Bitwise operators (`~', `&', `|', `^', `<<', `>>', `&=', `|=', `^=', +`<<=', `>>=') are also provided. However, these operate on +sign-magnitude, rather than two's complement representations. The sign +of the result is arbitrarily taken as the sign of the first argument. +For example, `Integer(-3) & Integer(5)' returns `Integer(-1)', not -3, +as it would using two's complement. Also, `~', the complement operator, +complements only those bits needed for the representation. Bit +operators are also provided in the BitSet and BitString classes. One of +these classes should be used instead of Integers when the results of +bit manipulations are not interpreted numerically. + + The following utility functions are also provided. (All arguments +are Integers unless otherwise noted). + + - Function: void divide(const Integer& X, const Integer& Y, Integer& + Q, Integer& R) + Sets Q to the quotient and R to the remainder of X and Y. (Q and + R are returned by reference). + + - Function: Integer pow(const Integer& X, const Integer& P) + Returns X raised to the power P. + + - Function: Integer Ipow(long X, long P) + Returns X raised to the power P. + + - Function: Integer gcd(const Integer& X, const Integer& P) + Returns the greatest common divisor of X and Y. + + - Function: Integer lcm(const Integer& X, const Integer& P) + Returns the least common multiple of X and Y. + + - Function: Integer abs(const Integer& X + Returns the absolute value of X. + + - Method: void Integer::negate() + Negates `this' in place. + +`Integer sqr(x)' + returns x * x; + +`Integer sqrt(x)' + returns the floor of the square root of x. + +`long lg(x);' + returns the floor of the base 2 logarithm of abs(x) + +`int sign(x)' + returns -1 if x is negative, 0 if zero, else +1. Using `if + (sign(x) == 0)' is a generally faster method of testing for zero + than using relational operators. + +`int even(x)' + returns true if x is an even number + +`int odd(x)' + returns true if x is an odd number. + +`void setbit(Integer& x, long b)' + sets the b'th bit (counting right-to-left from zero) of x to 1. + +`void clearbit(Integer& x, long b)' + sets the b'th bit of x to 0. + +`int testbit(Integer x, long b)' + returns true if the b'th bit of x is 1. + +`Integer atoI(char* asciinumber, int base = 10);' + converts the base base char* string into its Integer form. + +`void Integer::printon(ostream& s, int base = 10, int width = 0);' + prints the ascii string value of `(*this)' as a base `base' + number, in field width at least `width'. + +`ostream << x;' + prints x in base ten format. + +`istream >> x;' + reads x as a base ten number. + +`int compare(Integer x, Integer y)' + returns a negative number if xy. + +`int ucompare(Integer x, Integer y)' + like compare, but performs unsigned comparison. + +`add(x, y, z)' + A faster way to say z = x + y. + +`sub(x, y, z)' + A faster way to say z = x - y. + +`mul(x, y, z)' + A faster way to say z = x * y. + +`div(x, y, z)' + A faster way to say z = x / y. + +`mod(x, y, z)' + A faster way to say z = x % y. + +`and(x, y, z)' + A faster way to say z = x & y. + +`or(x, y, z)' + A faster way to say z = x | y. + +`xor(x, y, z)' + A faster way to say z = x ^ y. + +`lshift(x, y, z)' + A faster way to say z = x << y. + +`rshift(x, y, z)' + A faster way to say z = x >> y. + +`pow(x, y, z)' + A faster way to say z = pow(x, y). + +`complement(x, z)' + A faster way to say z = ~x. + +`negate(x, z)' + A faster way to say z = -x. + + +File: libg++.info, Node: Rational, Next: Complex, Prev: Integer, Up: Top + +The Rational Class +****************** + + Class `Rational' provides multiple precision rational number +arithmetic. All rationals are maintained in simplest form (i.e., with +the numerator and denominator relatively prime, and with the +denominator strictly positive). Rational arithmetic and relational +operators are provided (`+, -, *, /, +=, -=, *=, /=, ==, !=, <, <=, >, +>='). Operations resulting in a rational number with zero denominator +trigger an exception. + + Rationals may be constructed and used in the following ways: + +`Rational x;' + Declares an uninitialized Rational. + +`Rational x = 2; Rational y(2);' + Set x and y to the Rational value 2/1; + +`Rational x(2, 3);' + Sets x to the Rational value 2/3; + +`Rational x = 1.2;' + Sets x to a Rational value close to 1.2. Any double precision value + may be used to construct a Rational. The Rational will possess + exactly as much precision as the double. Double values that do not + have precise floating point equivalents (like 1.2) produce + similarly imprecise rational values. + +`Rational x(Integer(123), Integer(4567));' + Sets x to the Rational value 123/4567. + +`Rational u(x); Rational v = x;' + Set u and v to the same value as x. + +`double(Rational x)' + A Rational may be coerced to a double with potential loss of + precision. +/-HUGE is returned if it will not fit. + +`Rational abs(x)' + returns the absolute value of x. + +`void x.negate()' + negates x. + +`void x.invert()' + sets x to 1/x. + +`int sign(x)' + returns 0 if x is zero, 1 if positive, and -1 if negative. + +`Rational sqr(x)' + returns x * x. + +`Rational pow(x, Integer y)' + returns x to the y power. + +`Integer x.numerator()' + returns the numerator. + +`Integer x.denominator()' + returns the denominator. + +`Integer floor(x)' + returns the greatest Integer less than x. + +`Integer ceil(x)' + returns the least Integer greater than x. + +`Integer trunc(x)' + returns the Integer part of x. + +`Integer round(x)' + returns the nearest Integer to x. + +`int compare(x, y)' + returns a negative, zero, or positive number signifying whether x + is less than, equal to, or greater than y. + +`ostream << x;' + prints x in the form num/den, or just num if the denominator is + one. + +`istream >> x;' + reads x in the form num/den, or just num in which case the + denominator is set to one. + +`add(x, y, z)' + A faster way to say z = x + y. + +`sub(x, y, z)' + A faster way to say z = x - y. + +`mul(x, y, z)' + A faster way to say z = x * y. + +`div(x, y, z)' + A faster way to say z = x / y. + +`pow(x, y, z)' + A faster way to say z = pow(x, y). + +`negate(x, z)' + A faster way to say z = -x. + + +File: libg++.info, Node: Complex, Next: Fix, Prev: Rational, Up: Top + +The Complex class. +****************** + + Class `Complex' is implemented in a way similar to that described by +Stroustrup. In keeping with libg++ conventions, the class is named +`Complex', not `complex'. Complex arithmetic and relational operators +are provided (`+, -, *, /, +=, -=, *=, /=, ==, !='). Attempted +division by (0, 0) triggers an exception. + + Complex numbers may be constructed and used in the following ways: + +`Complex x;' + Declares an uninitialized Complex. + +`Complex x = 2; Complex y(2.0);' + Set x and y to the Complex value (2.0, 0.0); + +`Complex x(2, 3);' + Sets x to the Complex value (2, 3); + +`Complex u(x); Complex v = x;' + Set u and v to the same value as x. + +`double real(Complex& x);' + returns the real part of x. + +`double imag(Complex& x);' + returns the imaginary part of x. + +`double abs(Complex& x);' + returns the magnitude of x. + +`double norm(Complex& x);' + returns the square of the magnitude of x. + +`double arg(Complex& x);' + returns the argument (amplitude) of x. + +`Complex polar(double r, double t = 0.0);' + returns a Complex with abs of r and arg of t. + +`Complex conj(Complex& x);' + returns the complex conjugate of x. + +`Complex cos(Complex& x);' + returns the complex cosine of x. + +`Complex sin(Complex& x);' + returns the complex sine of x. + +`Complex cosh(Complex& x);' + returns the complex hyperbolic cosine of x. + +`Complex sinh(Complex& x);' + returns the complex hyperbolic sine of x. + +`Complex exp(Complex& x);' + returns the exponential of x. + +`Complex log(Complex& x);' + returns the natural log of x. + +`Complex pow(Complex& x, long p);' + returns x raised to the p power. + +`Complex pow(Complex& x, Complex& p);' + returns x raised to the p power. + +`Complex sqrt(Complex& x);' + returns the square root of x. + +`ostream << x;' + prints x in the form (re, im). + +`istream >> x;' + reads x in the form (re, im), or just (re) or re in which case the + imaginary part is set to zero. + + +File: libg++.info, Node: Fix, Next: Bit, Prev: Complex, Up: Top + +Fixed precision numbers +*********************** + + Classes `Fix16', `Fix24', `Fix32', and `Fix48' support operations on +16, 24, 32, or 48 bit quantities that are considered as real numbers in +the range [-1, +1). Such numbers are often encountered in digital +signal processing applications. The classes may be be used in isolation +or together. Class `Fix32' operations are entirely self-contained. +Class `Fix16' operations are self-contained except that the +multiplication operation `Fix16 * Fix16' returns a `Fix32'. `Fix24' and +`Fix48' are similarly related. + + The standard arithmetic and relational operations are supported +(`=', `+', `-', `*', `/', `<<', `>>', `+=', `-=', `*=', `/=', `<<=', +`>>=', `==', `!=', `<', `<=', `>', `>='). All operations include +provisions for special handling in cases where the result exceeds +/- +1.0. There are two cases that may be handled separately: "overflow" +where the results of addition and subtraction operations go out of +range, and all other "range errors" in which resulting values go +off-scale (as with division operations, and assignment or +initialization with off-scale values). In signal processing +applications, it is often useful to handle these two cases differently. +Handlers take one argument, a reference to the integer mantissa of the +offending value, which may then be manipulated. In cases of overflow, +this value is the result of the (integer) arithmetic computation on the +mantissa; in others it is a fully saturated (i.e., most positive or +most negative) value. Handling may be reset to any of several provided +functions or any other user-defined function via `set_overflow_handler' +and `set_range_error_handler'. The provided functions for `Fix16' are +as follows (corresponding functions are also supported for the others). + +`Fix16_overflow_saturate' + The default overflow handler. Results are "saturated": positive + results are set to the largest representable value (binary + 0.111111...), and negative values to -1.0. + +`Fix16_ignore' + Performs no action. For overflow, this will allow addition and + subtraction operations to "wrap around" in the same manner as + integer arithmetic, and for saturation, will leave values + saturated. + +`Fix16_overflow_warning_saturate' + Prints a warning message on standard error, then saturates the + results. + +`Fix16_warning' + The default range_error handler. Prints a warning message on + standard error; otherwise leaving the argument unmodified. + +`Fix16_abort' + prints an error message on standard error, then aborts execution. + + In addition to arithmetic operations, the following are provided: + +`Fix16 a = 0.5;' + Constructs fixed precision objects from double precision values. + Attempting to initialize to a value outside the range invokes the + range_error handler, except, as a convenience, initialization to + 1.0 sets the variable to the most positive representable value + (binary 0.1111111...) without invoking the handler. + +`short& mantissa(a); long& mantissa(b);' + return a * pow(2, 15) or b * pow(2, 31) as an integer. These are + returned by reference, to enable "manual" data manipulation. + +`double value(a); double value(b);' + return a or b as floating point numbers. + + +File: libg++.info, Node: Bit, Next: Random, Prev: Fix, Up: Top + +Classes for Bit manipulation +**************************** + + libg++ provides several different classes supporting the use and +manipulation of collections of bits in different ways. + + * Class `Integer' provides "integer" semantics. It supports + manipulation of bits in ways that are often useful when treating + bit arrays as numerical (integer) quantities. This class is + described elsewhere. + + * Class `BitSet' provides "set" semantics. It supports operations + useful when treating collections of bits as representing + potentially infinite sets of integers. + + * Class `BitSet32' supports fixed-length BitSets holding exactly 32 + bits. + + * Class `BitSet256' supports fixed-length BitSets holding exactly + 256 bits. + + * Class `BitString' provides "string" (or "vector") semantics. It + supports operations useful when treating collections of bits as + strings of zeros and ones. + + These classes also differ in the following ways: + + * BitSets are logically infinite. Their space is dynamically altered + to adjust to the smallest number of consecutive bits actually + required to represent the sets. Integers also have this property. + BitStrings are logically finite, but their sizes are internally + dynamically managed to maintain proper length. This means that, + for example, BitStrings are concatenatable while BitSets and + Integers are not. + + * BitSet32 and BitSet256 have precisely the same properties as + BitSets, except that they use constant fixed length bit vectors. + + * While all classes support basic unary and binary operations `~, &, + |, ^, -', the semantics differ. BitSets perform bit operations that + precisely mirror those for infinite sets. For example, + complementing an empty BitSet returns one representing an infinite + number of set bits. Operations on BitStrings and Integers operate + only on those bits actually present in the representation. For + BitStrings and Integers, the the `&' operation returns a BitString + with a length equal to the minimum length of the operands, and `|, + ^' return one with length of the maximum. + + * Only BitStrings support substring extraction and bit pattern + matching. + +BitSet +====== + + BitSets are objects that contain logically infinite sets of +nonnegative integers. Representational details are discussed in the +Representation chapter. Because they are logically infinite, all +BitSets possess a trailing, infinitely replicated 0 or 1 bit, called +the "virtual bit", and indicated via 0* or 1*. + + BitSet32 and BitSet256 have they same properties, except they are of +fixed length, and thus have no virtual bit. + + BitSets may be constructed as follows: + +`BitSet a;' + declares an empty BitSet. + +`BitSet a = atoBitSet("001000");' + sets a to the BitSet 0010*, reading left-to-right. The "0*" + indicates that the set ends with an infinite number of zero + (clear) bits. + +`BitSet a = atoBitSet("00101*");' + sets a to the BitSet 00101*, where "1*" means that the set ends + with an infinite number of one (set) bits. + +`BitSet a = longtoBitSet((long)23);' + sets a to the BitSet 111010*, the binary representation of decimal + 23. + +`BitSet a = utoBitSet((unsigned)23);' + sets a to the BitSet 111010*, the binary representation of decimal + 23. + + The following functions and operators are provided (Assume the +declaration of BitSets a = 0011010*, b = 101101*, throughout, as +examples). + +`~a' + returns the complement of a, or 1100101* in this case. + +`a.complement()' + sets a to ~a. + +`a & b; a &= b;' + returns a intersected with b, or 0011010*. + +`a | b; a |= b;' + returns a unioned with b, or 1011111*. + +`a - b; a -= b;' + returns the set difference of a and b, or 000010*. + +`a ^ b; a ^= b;' + returns the symmetric difference of a and b, or 1000101*. + +`a.empty()' + returns true if a is an empty set. + +`a == b;' + returns true if a and b contain the same set. + +`a <= b;' + returns true if a is a subset of b. + +`a < b;' + returns true if a is a proper subset of b; + +`a != b; a >= b; a > b;' + are the converses of the above. + +`a.set(7)' + sets the 7th (counting from 0) bit of a, setting a to 001111010* + +`a.clear(2)' + clears the 2nd bit bit of a, setting a to 00011110* + +`a.clear()' + clears all bits of a; + +`a.set()' + sets all bits of a; + +`a.invert(0)' + complements the 0th bit of a, setting a to 10011110* + +`a.set(0,1)' + sets the 0th through 1st bits of a, setting a to 110111110* The + two-argument versions of clear and invert are similar. + +`a.test(3)' + returns true if the 3rd bit of a is set. + +`a.test(3, 5)' + returns true if any of bits 3 through 5 are set. + +`int i = a[3]; a[3] = 0;' + The subscript operator allows bits to be inspected and changed via + standard subscript semantics, using a friend class BitSetBit. The + use of the subscript operator a[i] rather than a.test(i) requires + somewhat greater overhead. + +`a.first(1) or a.first()' + returns the index of the first set bit of a (2 in this case), or + -1 if no bits are set. + +`a.first(0)' + returns the index of the first clear bit of a (0 in this case), or + -1 if no bits are clear. + +`a.next(2, 1) or a.next(2)' + returns the index of the next bit after position 2 that is set (3 + in this case) or -1. `first' and `next' may be used as iterators, + as in `for (int i = a.first(); i >= 0; i = a.next(i))...'. + +`a.last(1)' + returns the index of the rightmost set bit, or -1 if there or no + set bits or all set bits. + +`a.prev(3, 0)' + returns the index of the previous clear bit before position 3. + +`a.count(1)' + returns the number of set bits in a, or -1 if there are an + infinite number. + +`a.virtual_bit()' + returns the trailing (infinitely replicated) bit of a. + +`a = atoBitSet("ababX", 'a', 'b', 'X');' + converts the char* string into a bitset, with 'a' denoting false, + 'b' denoting true, and 'X' denoting infinite replication. + +`a.printon(cout, '-', '.', 0)' + prints `a' to `cout' represented with `'-'' for falses, `'.'' for + trues, and no replication marker. + +`cout << a' + prints `a' to `cout' (representing lases by `'f'', trues by `'t'', + and using `'*'' as the replication marker). + +`diff(x, y, z)' + A faster way to say z = x - y. + +`and(x, y, z)' + A faster way to say z = x & y. + +`or(x, y, z)' + A faster way to say z = x | y. + +`xor(x, y, z)' + A faster way to say z = x ^ y. + +`complement(x, z)' + A faster way to say z = ~x. + +BitString +========= + + BitStrings are objects that contain arbitrary-length strings of +zeroes and ones. BitStrings possess some features that make them behave +like sets, and others that behave as strings. They are useful in +applications (such as signature-based algorithms) where both +capabilities are needed. Representational details are discussed in the +Representation chapter. Most capabilities are exact analogs of those +supported in the BitSet and String classes. A BitSubString is used +with substring operations along the same lines as the String SubString +class. A BitPattern class is used for masked bit pattern searching. + + Only a default constructor is supported. The declaration `BitString +a;' initializes a to be an empty BitString. BitStrings may often be +initialized via `atoBitString' and `longtoBitString'. + + Set operations (` ~, complement, &, &=, |, |=, -, ^, ^=') behave +just as the BitSet versions, except that there is no "virtual bit": +complementing complements only those bits in the BitString, and all +binary operations across unequal length BitStrings assume a virtual bit +of zero. The `&' operation returns a BitString with a length equal to +the minimum length of the operands, and `|, ^' return one with length +of the maximum. + + Set-based relational operations (`==, !=, <=, <, >=, >') follow the +same rules. A string-like lexicographic comparison function, +`lcompare', tests the lexicographic relation between two BitStrings. +For example, lcompare(1100, 0101) returns 1, since the first BitString +starts with 1 and the second with 0. + + Individual bit setting, testing, and iterator operations (`set, +clear, invert, test, first, next, last, prev') are also like those for +BitSets. BitStrings are automatically expanded when setting bits at +positions greater than their current length. + + The string-based capabilities are just as those for class String. +BitStrings may be concatenated (`+, +='), searched (`index, contains, +matches'), and extracted into BitSubStrings (`before, at, after') which +may be assigned and otherwise manipulated. Other string-based utility +functions (`reverse, common_prefix, common_suffix') are also provided. +These have the same capabilities and descriptions as those for Strings. + + String-oriented operations can also be performed with a mask via +class BitPattern. BitPatterns consist of two BitStrings, a pattern and +a mask. On searching and matching, bits in the pattern that correspond +to 0 bits in the mask are ignored. (The mask may be shorter than the +pattern, in which case trailing mask bits are assumed to be 0). The +pattern and mask are both public variables, and may be individually +subjected to other bit operations. + + Converting to char* and printing (`(atoBitString, atoBitPattern, +printon, ostream <<)') are also as in BitSets, except that no virtual +bit is used, and an 'X' in a BitPattern means that the pattern bit is +masked out. + + The following features are unique to BitStrings. + + Assume declarations of BitString a = atoBitString("01010110") and b = +atoBitSTring("1101"). + +`a = b + c;' + Sets a to the concatenation of b and c; + +`a = b + 0; a = b + 1;' + sets a to b, appended with a zero (one). + +`a += b;' + appends b to a; + +`a += 0; a += 1;' + appends a zero (one) to a. + +`a << 2; a <<= 2' + return a with 2 zeros prepended, setting a to 0001010110. (Note + the necessary confusion of << and >> operators. For consistency + with the integer versions, << shifts low bits to high, even though + they are printed low bits first.) + +`a >> 3; a >>= 3' + return a with the first 3 bits deleted, setting a to 10110. + +`a.left_trim(0)' + deletes all 0 bits on the left of a, setting a to 1010110. + +`a.right_trim(0)' + deletes all trailing 0 bits of a, setting a to 0101011. + +`cat(x, y, z)' + A faster way to say z = x + y. + +`diff(x, y, z)' + A faster way to say z = x - y. + +`and(x, y, z)' + A faster way to say z = x & y. + +`or(x, y, z)' + A faster way to say z = x | y. + +`xor(x, y, z)' + A faster way to say z = x ^ y. + +`lshift(x, y, z)' + A faster way to say z = x << y. + +`rshift(x, y, z)' + A faster way to say z = x >> y. + +`complement(x, z)' + A faster way to say z = ~x. + + +File: libg++.info, Node: Random, Next: Data, Prev: Bit, Up: Top + +Random Number Generators and related classes +******************************************** + + The two classes `RNG' and `Random' are used together to generate a +variety of random number distributions. A distinction must be made +between *random number generators*, implemented by class `RNG', and +*random number distributions*. A random number generator produces a +series of randomly ordered bits. These bits can be used directly, or +cast to other representations, such as a floating point value. A +random number generator should produce a *uniform* distribution. A +random number distribution, on the other hand, uses the randomly +generated bits of a generator to produce numbers from a distribution +with specific properties. Each instance of `Random' uses an instance +of class `RNG' to provide the raw, uniform distribution used to produce +the specific distribution. Several instances of `Random' classes can +share the same instance of `RNG', or each instance can use its own copy. + +RNG +=== + + Random distributions are constructed from members of class `RNG', +the actual random number generators. The `RNG' class contains no data; +it only serves to define the interface to random number generators. +The `RNG::asLong' member returns an unsigned long (typically 32 bits) +of random bits. Applications that require a number of random bits can +use this directly. More often, these random bits are transformed to a +uniform random number: + + // + // Return random bits converted to either a float or a double + // + float asFloat(); + double asDouble(); + }; + +using either `asFloat' or `asDouble'. It is intended that `asFloat' +and `asDouble' return differing precisions; typically, `asDouble' will +draw two random longwords and transform them into a legal `double', +while `asFloat' will draw a single longword and transform it into a +legal `float'. These members are used by subclasses of the `Random' +class to implement a variety of random number distributions. + +ACG +=== + + Class `ACG' is a variant of a Linear Congruential Generator +(Algorithm M) described in Knuth, *Art of Computer Programming, Vol +III*. This result is permuted with a Fibonacci Additive Congruential +Generator to get good independence between samples. This is a very high +quality random number generator, although it requires a fair amount of +memory for each instance of the generator. + + The `ACG::ACG' constructor takes two parameters: the seed and the +size. The seed is any number to be used as an initial seed. The +performance of the generator depends on having a distribution of bits +through the seed. If you choose a number in the range of 0 to 31, a +seed with more bits is chosen. Other values are deterministically +modified to give a better distribution of bits. This provides a good +random number generator while still allowing a sequence to be repeated +given the same initial seed. + + The `size' parameter determines the size of two tables used in the +generator. The first table is used in the Additive Generator; see the +algorithm in Knuth for more information. In general, this table is +`size' longwords long. The default value, used in the algorithm in +Knuth, gives a table of 220 bytes. The table size affects the period of +the generators; smaller values give shorter periods and larger tables +give longer periods. The smallest table size is 7 longwords, and the +longest is 98 longwords. The `size' parameter also determines the size +of the table used for the Linear Congruential Generator. This value is +chosen implicitly based on the size of the Additive Congruential +Generator table. It is two powers of two larger than the power of two +that is larger than `size'. For example, if `size' is 7, the ACG table +is 7 longwords and the LCG table is 128 longwords. Thus, the default +size (55) requires 55 + 256 longwords, or 1244 bytes. The largest table +requires 2440 bytes and the smallest table requires 100 bytes. +Applications that require a large number of generators or applications +that aren't so fussy about the quality of the generator may elect to +use the `MLCG' generator. + +MLCG +==== + + The `MLCG' class implements a *Multiplicative Linear Congruential +Generator*. In particular, it is an implementation of the double MLCG +described in *"Efficient and Portable Combined Random Number +Generators"* by Pierre L'Ecuyer, appearing in *Communications of the +ACM, Vol. 31. No. 6*. This generator has a fairly long period, and has +been statistically analyzed to show that it gives good inter-sample +independence. + + The `MLCG::MLCG' constructor has two parameters, both of which are +seeds for the generator. As in the `MLCG' generator, both seeds are +modified to give a "better" distribution of seed digits. Thus, you can +safely use values such as `0' or `1' for the seeds. The `MLCG' +generator used much less state than the `ACG' generator; only two +longwords (8 bytes) are needed for each generator. + +Random +====== + + A random number generator may be declared by first declaring a `RNG' +and then a `Random'. For example, `ACG gen(10, 20); NegativeExpntl rnd +(1.0, &gen);' declares an additive congruential generator with seed 10 +and table size 20, that is used to generate exponentially distributed +values with mean of 1.0. + + The virtual member `Random::operator()' is the common way of +extracting a random number from a particular distribution. The base +class, `Random' does not implement `operator()'. This is performed by +each of the subclasses. Thus, given the above declaration of `rnd', new +random values may be obtained via, for example, `double next_exp_rand = +rnd();' Currently, the following subclasses are provided. + +Binomial +======== + + The binomial distribution models successfully drawing items from a +pool. The first parameter to the constructor, `n', is the number of +items in the pool, and the second parameter, `u', is the probability of +each item being successfully drawn. The member `asDouble' returns the +number of samples drawn from the pool. Although it is not checked, it +is assumed that `n>0' and `0 <= u <= 1'. The remaining members allow +you to read and set the parameters. + +Erlang +====== + + The `Erlang' class implements an Erlang distribution with mean +`mean' and variance `variance'. + +Geometric +========= + + The `Geometric' class implements a discrete geometric distribution. +The first parameter to the constructor, `mean', is the mean of the +distribution. Although it is not checked, it is assumed that `0 <= +mean <= 1'. `Geometric()' returns the number of uniform random samples +that were drawn before the sample was larger than `mean'. This +quantity is always greater than zero. + +HyperGeometric +============== + + The `HyperGeometric' class implements the hypergeometric +distribution. The first parameter to the constructor, `mean', is the +mean and the second, `variance', is the variance. The remaining +members allow you to inspect and change the mean and variance. + +NegativeExpntl +============== + + The `NegativeExpntl' class implements the negative exponential +distribution. The first parameter to the constructor is the mean. The +remaining members allow you to inspect and change the mean. + +Normal +====== + + The `Normal'class implements the normal distribution. The first +parameter to the constructor, `mean', is the mean and the second, +`variance', is the variance. The remaining members allow you to +inspect and change the mean and variance. The `LogNormal' class is a +subclass of `Normal'. + +LogNormal +========= + + The `LogNormal'class implements the logarithmic normal distribution. +The first parameter to the constructor, `mean', is the mean and the +second, `variance', is the variance. The remaining members allow you +to inspect and change the mean and variance. The `LogNormal' class is +a subclass of `Normal'. + +Poisson +======= + + The `Poisson' class implements the poisson distribution. The first +parameter to the constructor is the mean. The remaining members allow +you to inspect and change the mean. + +DiscreteUniform +=============== + + The `DiscreteUniform' class implements a uniform random variable over +the closed interval ranging from `[low..high]'. The first parameter to +the constructor is `low', and the second is `high', although the order +of these may be reversed. The remaining members allow you to inspect +and change `low' and `high'. + +Uniform +======= + + The `Uniform' class implements a uniform random variable over the +open interval ranging from `[low..high)'. The first parameter to the +constructor is `low', and the second is `high', although the order of +these may be reversed. The remaining members allow you to inspect and +change `low' and `high'. + +Weibull +======= + + The `Weibull' class implements a weibull distribution with +parameters `alpha' and `beta'. The first parameter to the class +constructor is `alpha', and the second parameter is `beta'. The +remaining members allow you to inspect and change `alpha' and `beta'. + +RandomInteger +============= + + The `RandomInteger' class is *not* a subclass of Random, but a +stand-alone integer-oriented class that is dependent on the RNG +classes. RandomInteger returns random integers uniformly from the +closed interval `[low..high]'. The first parameter to the constructor +is `low', and the second is `high', although both are optional. The +last argument is always a generator. Additional members allow you to +inspect and change `low' and `high'. Random integers are generated +using `asInt()' or `asLong()'. Operator syntax (`()') is also +available as a shorthand for `asLong()'. Because `RandomInteger' is +often used in simulations for which uniform random integers are desired +over a variety of ranges, `asLong()' and `asInt' have `high' as an +optional argument. Using this optional argument produces a single +value from the new range, but does not change the default range. + diff --git a/gnu/lib/libg++/libg++/libg++.info-4 b/gnu/lib/libg++/libg++/libg++.info-4 new file mode 100644 index 00000000000..26058ab4086 --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info-4 @@ -0,0 +1,1578 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: libg++.info, Node: Data, Next: Curses, Prev: Random, Up: Top + +Data Collection +*************** + + Libg++ currently provides two classes for *data collection* and +analysis of the collected data. + +SampleStatistic +=============== + + Class `SampleStatistic' provides a means of accumulating samples of +`double' values and providing common sample statistics. + + Assume declaration of `double x'. + +`SampleStatistic a;' + declares and initializes a. + +`a.reset();' + re-initializes a. + +`a += x;' + adds sample x. + +`int n = a.samples();' + returns the number of samples. + +`x = a.mean;' + returns the means of the samples. + +`x = a.var()' + returns the sample variance of the samples. + +`x = a.stdDev()' + returns the sample standard deviation of the samples. + +`x = a.min()' + returns the minimum encountered sample. + +`x = a.max()' + returns the maximum encountered sample. + +`x = a.confidence(int p)' + returns the p-percent (0 <= p < 100) confidence interval. + +`x = a.confidence(double p)' + returns the p-probability (0 <= p < 1) confidence interval. + +SampleHistogram +=============== + + Class `SampleHistogram' is a derived class of `SampleStatistic' that +supports collection and display of samples in bucketed intervals. It +supports the following in addition to `SampleStatisic' operations. + +`SampleHistogram h(double lo, double hi, double width);' + declares and initializes h to have buckets of size width from lo + to hi. If the optional argument width is not specified, 10 + buckets are created. The first bucket and also holds samples less + than lo, and the last one holds samples greater than hi. + +`int n = h.similarSamples(x)' + returns the number of samples in the same bucket as x. + +`int n = h.inBucket(int i)' + returns the number of samples in bucket i. + +`int b = h.buckets()' + returns the number of buckets. + +`h.printBuckets(ostream s)' + prints bucket counts on ostream s. + +`double bound = h.bucketThreshold(int i)' + returns the upper bound of bucket i. + + +File: libg++.info, Node: Curses, Next: List, Prev: Data, Up: Top + +Curses-based classes +******************** + + The `CursesWindow' class is a repackaging of standard curses library +features into a class. It relies on `curses.h'. + + The supplied `curses.h' is a fairly conservative declaration of +curses library features, and does not include features like "screen" or +X-window support. It is, for the most part, an adaptation, rather than +an improvement of C-based `curses.h' files. The only substantive +changes are the declarations of many functions as inline functions +rather than macros, which was done solely to allow overloading. + + The `CursesWindow' class encapsulates curses window functions within +a class. Only those functions that control windows are included: +Terminal control functions and macros like `cbreak' are not part of the +class. All `CursesWindows' member functions have names identical to +the corresponding curses library functions, except that the "w" prefix +is generally dropped. Descriptions of these functions may be found in +your local curses library documentation. + + A `CursesWindow' may be declared via + +`CursesWindow w(WINDOW* win)' + attaches w to the existing WINDOW* win. This is constructor is + normally used only in the following special case. + +`CursesWindow w(stdscr)' + attaches w to the default curses library standard screen window. + +`CursesWindow w(int lines, int cols, int begin_y, int begin_x)' + attaches to an allocated curses window with the indicated size and + screen position. + +`CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a')' + attaches to a subwindow of w created via the curses `subwin' + command. If ar is sent as `r', the origin (by, bx) is relative to + the parent window, else it is absolute. + + The class maintains a static counter that is used in order to +automatically call the curses library `initscr' and `endscr' functions +at the proper times. These need not, and should not be called +"manually". + + `CursesWindow's maintain a tree of their subwindows. Upon +destruction of a `CursesWindow', all of their subwindows are also +invalidated if they had not previously been destroyed. + + It is possible to traverse trees of subwindows via the following +member functions + +`CursesWindow* w.parent()' + returns a pointer to the parent of the subwindow, or 0 if there is + none. + +`CursesWindow* w.child()' + returns the first child subwindow of the window, or 0 if there is + none. + +`CursesWindow* w.sibling()' + returns the next sibling of the subwindow, or 0 if there is none. + + For example, to call some function `visit' for all subwindows of a +window, you could write + + + void traverse(CursesWindow& w) + { + visit(w); + if (w.child() != 0) traverse(*w.child); + if (w.sibling() != 0) traverse(*w.sibling); + } + + +File: libg++.info, Node: List, Next: LinkList, Prev: Curses, Up: Top + +List classes +************ + + The files `g++-include/List.hP' and `g++-include/List.ccP' provide +pseudo-generic Lisp-type List classes. These lists are homogeneous +lists, more similar to lists in statically typed functional languages +like ML than Lisp, but support operations very similar to those found +in Lisp. Any particular kind of list class may be generated via the +`genclass' shell command. However, the implementation assumes that the +base class supports an equality operator `=='. All equality tests use +the `==' operator, and are thus equivalent to the use of `equal', not +`eq' in Lisp. + + All list nodes are created dynamically, and managed via reference +counts. `List' variables are actually pointers to these list nodes. +Lists may also be traversed via Pixes, as described in the section +describing Pixes. *Note Pix:: + + Supported operations are mirrored closely after those in Lisp. +Generally, operations with functional forms are constructive, +functional operations, while member forms (often with the same name) +are sometimes procedural, possibly destructive operations. + + As with Lisp, destructive operations are supported. Programmers are +allowed to change head and tail fields in any fashion, creating +circular structures and the like. However, again as with Lisp, some +operations implicitly assume that they are operating on pure lists, and +may enter infinite loops when presented with improper lists. Also, the +reference-counting storage management facility may fail to reclaim +unused circularly-linked nodes. + + Several Lisp-like higher order functions are supported (e.g., `map'). +Typedef declarations for the required functional forms are provided int +the `.h' file. + + For purposes of illustration, assume the specification of class +`intList'. Common Lisp versions of supported operations are shown in +brackets for comparison purposes. + +Constructors and assignment +=========================== + +`intList a; [ (setq a nil) ]' + Declares a to be a nil intList. + +`intList b(2); [ (setq b (cons 2 nil)) ]' + Declares b to be an intList with a head value of 2, and a nil tail. + +`intList c(3, b); [ (setq c (cons 3 b)) ]' + Declares c to be an intList with a head value of 3, and b as its + tail. + +`b = a; [ (setq b a) ]' + Sets b to be the same list as a. + + Assume the declarations of intLists a, b, and c in the following. +*Note Pix::. + +List status +=========== + +`a.null(); OR !a; [ (null a) ]' + returns true if a is null. + +`a.valid(); [ (listp a) ]' + returns true if a is non-null. Inside a conditional test, the + `void*' coercion may also be used as in `if (a) ...'. + +`intList(); [ nil ]' + intList() may be used to null terminate a list, as in `intList + f(int x) {if (x == 0) return intList(); ... } '. + +`a.length(); [ (length a) ]' + returns the length of a. + +`a.list_length(); [ (list-length a) ]' + returns the length of a, or -1 if a is circular. + +heads and tails +=============== + +`a.get(); OR a.head() [ (car a) ]' + returns a reference to the head field. + +`a[2]; [ (elt a 2) ]' + returns a reference to the second (counting from zero) head field. + +`a.tail(); [ (cdr a) ]' + returns the intList that is the tail of a. + +`a.last(); [ (last a) ]' + returns the intList that is the last node of a. + +`a.nth(2); [ (nth a 2) ]' + returns the intList that is the nth node of a. + +`a.set_tail(b); [ (rplacd a b) ]' + sets a's tail to b. + +`a.push(2); [ (push 2 a) ]' + equivalent to a = intList(2, a); + +`int x = a.pop() [ (setq x (car a)) (pop a) ]' + returns the head of a, also setting a to its tail. + +Constructive operations +======================= + +`b = copy(a); [ (setq b (copy-seq a)) ]' + sets b to a copy of a. + +`b = reverse(a); [ (setq b (reverse a)) ]' + Sets b to a reversed copy of a. + +`c = concat(a, b); [ (setq c (concat a b)) ]' + Sets c to a concatenated copy of a and b. + +`c = append(a, b); [ (setq c (append a b)) ]' + Sets c to a concatenated copy of a and b. All nodes of a are + copied, with the last node pointing to b. + +`b = map(f, a); [ (setq b (mapcar f a)) ]' + Sets b to a new list created by applying function f to each node + of a. + +`c = combine(f, a, b);' + Sets c to a new list created by applying function f to successive + pairs of a and b. The resulting list has length the shorter of a + and b. + +`b = remove(x, a); [ (setq b (remove x a)) ]' + Sets b to a copy of a, omitting all occurrences of x. + +`b = remove(f, a); [ (setq b (remove-if f a)) ]' + Sets b to a copy of a, omitting values causing function f to + return true. + +`b = select(f, a); [ (setq b (remove-if-not f a)) ]' + Sets b to a copy of a, omitting values causing function f to + return false. + +`c = merge(a, b, f); [ (setq c (merge a b f)) ]' + Sets c to a list containing the ordered elements (using the + comparison function f) of the sorted lists a and b. + +Destructive operations +====================== + +`a.append(b); [ (rplacd (last a) b) ]' + appends b to the end of a. No new nodes are constructed. + +`a.prepend(b); [ (setq a (append b a)) ]' + prepends b to the beginning of a. + +`a.del(x); [ (delete x a) ]' + deletes all nodes with value x from a. + +`a.del(f); [ (delete-if f a) ]' + deletes all nodes causing function f to return true. + +`a.select(f); [ (delete-if-not f a) ]' + deletes all nodes causing function f to return false. + +`a.reverse(); [ (nreverse a) ]' + reverses a in-place. + +`a.sort(f); [ (sort a f) ]' + sorts a in-place using ordering (comparison) function f. + +`a.apply(f); [ (mapc f a) ]' + Applies void function f (int x) to each element of a. + +`a.subst(int old, int repl); [ (nsubst repl old a) ]' + substitutes repl for each occurrence of old in a. Note the + different argument order than the Lisp version. + +Other operations +================ + +`a.find(int x); [ (find x a) ]' + returns the intList at the first occurrence of x. + +`a.find(b); [ (find b a) ]' + returns the intList at the first occurrence of sublist b. + +`a.contains(int x); [ (member x a) ]' + returns true if a contains x. + +`a.contains(b); [ (member b a) ]' + returns true if a contains sublist b. + +`a.position(int x); [ (position x a) ]' + returns the zero-based index of x in a, or -1 if x does not occur. + +`int x = a.reduce(f, int base); [ (reduce f a :initial-value base) ]' + Accumulates the result of applying int function f(int, int) to + successive elements of a, starting with base. + + +File: libg++.info, Node: LinkList, Next: Vector, Prev: List, Up: Top + +Linked Lists +************ + + SLLists provide pseudo-generic singly linked lists. DLLists provide +doubly linked lists. The lists are designed for the simple maintenance +of elements in a linked structure, and do not provide the more extensive +operations (or node-sharing) of class `List'. They behave similarly to +the `slist' and similar classes described by Stroustrup. + + All list nodes are created dynamically. Assignment is performed via +copying. + + Class `DLList' supports all `SLList' operations, plus additional +operations described below. + + For purposes of illustration, assume the specification of class +`intSLList'. In addition to the operations listed here, SLLists support +traversal via Pixes. *Note Pix:: + +`intSLList a;' + Declares a to be an empty list. + +`intSLList b = a;' + Sets b to an element-by-element copy of a. + +`a.empty()' + returns true if a contains no elements + +`a.length();' + returns the number of elements in a. + +`a.prepend(x);' + places x at the front of the list. + +`a.append(x);' + places x at the end of the list. + +`a.join(b)' + places all nodes from b to the end of a, simultaneously destroying + b. + +`x = a.front()' + returns a reference to the item stored at the head of the list, or + triggers an error if the list is empty. + +`a.rear()' + returns a reference to the rear of the list, or triggers an error + if the list is empty. + +`x = a.remove_front()' + deletes and returns the item stored at the head of the list. + +`a.del_front()' + deletes the first element, without returning it. + +`a.clear()' + deletes all items from the list. + +`a.ins_after(Pix i, item);' + inserts item after position i. If i is null, insertion is at the + front. + +`a.del_after(Pix i);' + deletes the element following i. If i is 0, the first item is + deleted. + +Doubly linked lists +=================== + + Class `DLList' supports the following additional operations, as well +as backward traversal via Pixes. + +`x = a.remove_rear();' + deletes and returns the item stored at the rear of the list. + +`a.del_rear();' + deletes the last element, without returning it. + +`a.ins_before(Pix i, x)' + inserts x before the i. + +`a.del(Pix& iint dir = 1)' + deletes the item at the current position, then advances forward if + dir is positive, else backward. + + +File: libg++.info, Node: Vector, Next: Plex, Prev: LinkList, Up: Top + +Vector classes +************** + + The files `g++-include/Vec.ccP' and `g++-include/AVec.ccP' provide +pseudo-generic standard array-based vector operations. The +corresponding header files are `g++-include/Vec.hP' and +`g++-include/AVec.hP'. Class `Vec' provides operations suitable for +any base class that includes an equality operator. Subclass `AVec' +provides additional arithmetic operations suitable for base classes +that include the full complement of arithmetic operators. + + `Vecs' are constructed and assigned by copying. Thus, they should +normally be passed by reference in applications programs. + + Several mapping functions are provided that allow programmers to +specify operations on vectors as a whole. + + For illustrative purposes assume that classes `intVec' and `intAVec' +have been generated via `genclass'. + +Constructors and assignment +=========================== + +`intVec a;' + declares a to be an empty vector. Its size may be changed via + resize. + +`intVec a(10);' + declares a to be an uninitialized vector of ten elements (numbered + 0-9). + +`intVec b(6, 0);' + declares b to be a vector of six elements, all initialized to + zero. Any value can be used as the initial fill argument. + +`a = b;' + Copies b to a. a is resized to be the same as b. + +`a = b.at(2, 4)' + constructs a from the 4 elements of b starting at b[2]. + + Assume declarations of `intVec a, b, c' and `int i, x' in the +following. + +Status and access +================= + +`a.capacity();' + returns the number of elements that can be held in a. + +`a.resize(20);' + sets a's length to 20. All elements are unchanged, except that if + the new size is smaller than the original, than trailing elements + are deleted, and if greater, trailing elements are uninitialized. + +`a[i];' + returns a reference to the i'th element of a, or produces an error + if i is out of range. + +`a.elem(i)' + returns a reference to the i'th element of a. Unlike the `[]' + operator, i is not checked to ensure that it is within range. + +`a == b;' + returns true if a and b contain the same elements in the same + order. + +`a != b;' + is the converse of a == b. + +Constructive operations +======================= + +`c = concat(a, b);' + sets c to the new vector constructed from all of the elements of a + followed by all of b. + +`c = map(f, a);' + sets c to the new vector constructed by applying int function + f(int) to each element of a. + +`c = merge(a, b, f);' + sets c to the new vector constructed by merging the elements of + ordered vectors a and b using ordering (comparison) function f. + +`c = combine(f, a, b);' + sets c to the new vector constructed by applying int function + f(int, int) to successive pairs of a and b. The result has length + the shorter of a and b. + +`c = reverse(a)' + sets c to a, with elements in reverse order. + +Destructive operations +====================== + +`a.reverse();' + reverses a in-place. + +`a.sort(f)' + sorts a in-place using comparison function f. The sorting method + is a variation of the quicksort functions supplied with GNU emacs. + +`a.fill(0, 4, 2)' + fills the 2 elements starting at a[4] with zero. + +Other operations +================ + +`a.apply(f)' + applies function f to each element in a. + +`x = a.reduce(f, base)' + accumulates the results of applying function f to successive + elements of a starting with base. + +`a.index(int targ);' + returns the index of the leftmost occurrence of the target, or -1, + if it does not occur. + +`a.error(char* msg)' + invokes the error handler. The default version prints the error + message, then aborts. + +AVec operations. +================ + + AVecs provide additional arithmetic operations. All vector-by-vector +operators generate an error if the vectors are not the same length. The +following operations are provided, for `AVecs a, b' and base element +(scalar) `s'. + +`a = b;' + Copies b to a. a and b must be the same size. + +`a = s;' + fills all elements of a with the value s. a is not resized. + +`a + s; a - s; a * s; a / s' + adds, subtracts, multiplies, or divides each element of a with the + scalar. + +`a += s; a -= s; a *= s; a /= s;' + adds, subtracts, multiplies, or divides the scalar into a. + +`a + b; a - b; product(a, b), quotient(a, b)' + adds, subtracts, multiplies, or divides corresponding elements of + a and b. + +`a += b; a -= b; a.product(b); a.quotient(b);' + adds, subtracts, multiplies, or divides corresponding elements of + b into a. + +`s = a * b;' + returns the inner (dot) product of a and b. + +`x = a.sum();' + returns the sum of elements of a. + +`x = a.sumsq();' + returns the sum of squared elements of a. + +`x = a.min();' + returns the minimum element of a. + +`x = a.max();' + returns the maximum element of a. + +`i = a.min_index();' + returns the index of the minimum element of a. + +`i = a.max_index();' + returns the index of the maximum element of a. + + Note that it is possible to apply vector versions other arithmetic + operators via the mapping functions. For example, to set vector b + to the cosines of doubleVec a, use `b = map(cos, a);'. This is + often more efficient than performing the operations in an + element-by-element fashion. + + +File: libg++.info, Node: Plex, Next: Stack, Prev: Vector, Up: Top + +Plex classes +************ + + A "Plex" is a kind of array with the following properties: + + * Plexes may have arbitrary upper and lower index bounds. For example + a Plex may be declared to run from indices -10 .. 10. + + * Plexes may be dynamically expanded at both the lower and upper + bounds of the array in steps of one element. + + * Only elements that have been specifically initialized or added may + be accessed. + + * Elements may be accessed via indices. Indices are always checked + for validity at run time. Plexes may be traversed via simple + variations of standard array indexing loops. + + * Plex elements may be accessed and traversed via Pixes. + + * Plex-to-Plex assignment and related operations on entire Plexes + are supported. + + * Plex classes contain methods to help programmers check the validity + of indexing and pointer operations. + + * Plexes form "natural" base classes for many restricted-access data + structures relying on logically contiguous indices, such as + array-based stacks and queues. + + * Plexes are implemented as pseudo-generic classes, and must be + generated via the `genclass' utility. + + Four subclasses of Plexes are supported: A `FPlex' is a Plex that +may only grow or shrink within declared bounds; an `XPlex' may +dynamically grow or shrink without bounds; an `RPlex' is the same as an +`XPlex' but better supports indexing with poor locality of reference; a +`MPlex' may grow or shrink, and additionally allows the logical +deletion and restoration of elements. Because these classes are virtual +subclasses of the "abstract" class `Plex', it is possible to write user +code such as `void f(Plex& a) ...' that operates on any kind of Plex. +However, as with nearly any virtual class, specifying the particular +Plex class being used results in more efficient code. + + Plexes are implemented as a linked list of `IChunks'. Each chunk +contains a part of the array. Chunk sizes may be specified within Plex +constructors. Default versions also exist, that use a `#define'd' +default. Plexes grow by filling unused space in existing chunks, if +possible, else, except for FPlexes, by adding another chunk. Whenever +Plexes grow by a new chunk, the default element constructors (i.e., +those which take no arguments) for all chunk elements are called at +once. When Plexes shrink, destructors for the elements are not called +until an entire chunk is freed. For this reason, Plexes (like C++ +arrays) should only be used for elements with default constructors and +destructors that have no side effects. + + Plexes may be indexed and used like arrays, although traversal +syntax is slightly different. Even though Plexes maintain elements in +lists of chunks, they are implemented so that iteration and other +constructs that maintain locality of reference require very little +overhead over that for simple array traversal Pix-based traversal is +also supported. For example, for a plex, p, of ints, the following +traversal methods could be used. + + for (int i = p.low(); i < p.fence(); p.next(i)) use(p[i]); + for (int i = p.high(); i > p.ecnef(); p.prev(i)) use(p[i]); + for (Pix t = p.first(); t != 0; p.next(t)) use(p(i)); + for (Pix t = p.last(); t != 0; p.prev(t)) use(p(i)); + + Except for MPlexes, simply using `++i' and `--i' works just as well +as `p.next(i)' and `p.prev(i)' when traversing by index. Index-based +traversal is generally a bit faster than Pix-based traversal. + + `XPlexes' and `MPlexes' are less than optimal for applications in +which widely scattered elements are indexed, as might occur when using +Plexes as hash tables or "manually" allocated linked lists. In such +applications, `RPlexes' are often preferable. `RPlexes' use a secondary +chunk index table that requires slightly greater, but entirely uniform +overhead per index operation. + + Even though they may grow in either direction, Plexes are normally +constructed so that their "natural" growth direction is upwards, in +that default chunk construction leaves free space, if present, at the +end of the plex. However, if the chunksize arguments to constructors +are negative, they leave space at the beginning. + + All versions of Plexes support the following basic capabilities. +(letting `Plex' stand for the type name constructed via the genclass +utility (e.g., `intPlex', `doublePlex')). Assume declarations of `Plex +p, q', `int i, j', base element `x', and Pix `pix'. + +`Plex p;' + Declares p to be an initially zero-sized Plex with low index of + zero, and the default chunk size. For FPlexes, chunk sizes + represent maximum sizes. + +`Plex p(int size);' + Declares p to be an initially zero-sized Plex with low index of + zero, and the indicated chunk size. If size is negative, then the + Plex is created with free space at the beginning of the Plex, + allowing more efficient add_low() operations. Otherwise, it leaves + space at the end. + +`Plex p(int low, int size);' + Declares p to be an initially zero-sized Plex with low index of + low, and the indicated chunk size. + +`Plex p(int low, int high, Base initval, int size = 0);' + Declares p to be a Plex with indices from low to high, initially + filled with initval, and the indicated chunk size if specified, + else the default or (high - low + 1), whichever is greater. + +`Plex q(p);' + Declares q to be a copy of p. + +`p = q;' + Copies Plex q into p, deleting its previous contents. + +`p.length()' + Returns the number of elements in the Plex. + +`p.empty()' + Returns true if Plex p contains no elements. + +`p.full()' + Returns true if Plex p cannot be expanded. This always returns + false for XPlexes and MPlexes. + +`p[i]' + Returns a reference to the i'th element of p. An exception (error) + occurs if i is not a valid index. + +`p.valid(i)' + Returns true if i is a valid index into Plex p. + +`p.low(); p.high();' + Return the minimum (maximum) valid index of the Plex, or the high + (low) fence if the plex is empty. + +`p.ecnef(); p.fence();' + Return the index one position past the minimum (maximum) valid + index. + +`p.next(i); i = p.prev(i);' + Set i to the next (previous) index. This index may not be within + bounds. + +`p(pix)' + returns a reference to the item at Pix pix. + +`pix = p.first(); pix = p.last();' + Return the minimum (maximum) valid Pix of the Plex, or 0 if the + plex is empty. + +`p.next(pix); p.prev(pix);' + set pix to the next (previous) Pix, or 0 if there is none. + +`p.owns(pix)' + Returns true if the Plex contains the element associated with pix. + +`p.Pix_to_index(pix)' + If pix is a valid Pix to an element of the Plex, returns its + corresponding index, else raises an exception. + +`ptr = p.index_to_Pix(i)' + if i is a valid index, returns a the corresponding Pix. + +`p.low_element(); p.high_element();' + Return a reference to the element at the minimum (maximum) valid + index. An exception occurs if the Plex is empty. + +`p.can_add_low(); p.can_add_high();' + Returns true if the plex can be extended one element downward + (upward). These always return true for XPlex and MPlex. + +`j = p.add_low(x); j = p.add_high(x);' + Extend the Plex by one element downward (upward). The new minimum + (maximum) index is returned. + +`j = p.del_low(); j = p.del_high()' + Shrink the Plex by one element on the low (high) end. The new + minimum (maximum) element is returned. An exception occurs if the + Plex is empty. + +`p.append(q);' + Append all of Plex q to the high side of p. + +`p.prepend(q);' + Prepend all of q to the low side of p. + +`p.clear()' + Delete all elements, resetting p to a zero-sized Plex. + +`p.reset_low(i);' + Resets p to be indexed starting at low() = i. For example. if p + were initially declared via `Plex p(0, 10, 0)', and then + re-indexed via `p.reset_low(5)', it could then be indexed from + indices 5 .. 14. + +`p.fill(x)' + sets all p[i] to x. + +`p.fill(x, lo, hi)' + sets all of p[i] from lo to hi, inclusive, to x. + +`p.reverse()' + reverses p in-place. + +`p.chunk_size()' + returns the chunk size used for the plex. + +`p.error(const char * msg)' + calls the resettable error handler. + + MPlexes are plexes with bitmaps that allow items to be logically +deleted and restored. They behave like other plexes, but also support +the following additional and modified capabilities: + +`p.del_index(i); p.del_Pix(pix)' + logically deletes p[i] (p(pix)). After deletion, attempts to + access p[i] generate a error. Indexing via low(), high(), prev(), + and next() skip the element. Deleting an element never changes the + logical bounds of the plex. + +`p.undel_index(i); p.undel_Pix(pix)' + logically undeletes p[i] (p(pix)). + +`p.del_low(); p.del_high()' + Delete the lowest (highest) undeleted element, resetting the + logical bounds of the plex to the next lowest (highest) undeleted + index. Thus, MPlex del_low() and del_high() may shrink the bounds + of the plex by more than one index. + +`p.adjust_bounds()' + Resets the low and high bounds of the Plex to the indexes of the + lowest and highest actual undeleted elements. + +`int i = p.add(x)' + Adds x in an unused index, if possible, else performs add_high. + +`p.count()' + returns the number of valid (undeleted) elements. + +`p.available()' + returns the number of available (deleted) indices. + +`int i = p.unused_index()' + returns the index of some deleted element, if one exists, else + triggers an error. An unused element may be reused via undel. + +`pix = p.unused_Pix()' + returns the pix of some deleted element, if one exists, else 0. + An unused element may be reused via undel. + + +File: libg++.info, Node: Stack, Next: Queue, Prev: Plex, Up: Top + +Stacks +****** + + Stacks are declared as an "abstract" class. They are currently +implemented in any of three ways. + +`VStack' + implement fixed sized stacks via arrays. + +`XPStack' + implement dynamically-sized stacks via XPlexes. + +`SLStack' + implement dynamically-size stacks via linked lists. + + All possess the same capabilities. They differ only in constructors. +VStack constructors require a fixed maximum capacity argument. XPStack +constructors optionally take a chunk size argument. SLStack +constructors take no argument. + + Assume the declaration of a base element `x'. + +`Stack s; or Stack s(int capacity)' + declares a Stack. + +`s.empty()' + returns true if stack s is empty. + +`s.full()' + returns true if stack s is full. XPStacks and SLStacks never + become full. + +`s.length()' + returns the current number of elements in the stack. + +`s.push(x)' + pushes x on stack s. + +`x = s.pop()' + pops and returns the top of stack + +`s.top()' + returns a reference to the top of stack. + +`s.del_top()' + pops, but does not return the top of stack. When large items are + held on the stack it is often a good idea to use `top()' to + inspect and use the top of stack, followed by a `del_top()' + +`s.clear()' + removes all elements from the stack. + + +File: libg++.info, Node: Queue, Next: Deque, Prev: Stack, Up: Top + +Queues +****** + + Queues are declared as an "abstract" class. They are currently +implemented in any of three ways. + +`VQueue' + implement fixed sized Queues via arrays. + +`XPQueue' + implement dynamically-sized Queues via XPlexes. + +`SLQueue' + implement dynamically-size Queues via linked lists. + + All possess the same capabilities; they differ only in constructors. +`VQueue' constructors require a fixed maximum capacity argument. +`XPQueue' constructors optionally take a chunk size argument. +`SLQueue' constructors take no argument. + + Assume the declaration of a base element `x'. + +`Queue q; or Queue q(int capacity);' + declares a queue. + +`q.empty()' + returns true if queue q is empty. + +`q.full()' + returns true if queue q is full. XPQueues and SLQueues are never + full. + +`q.length()' + returns the current number of elements in the queue. + +`q.enq(x)' + enqueues x on queue q. + +`x = q.deq()' + dequeues and returns the front of queue + +`q.front()' + returns a reference to the front of queue. + +`q.del_front()' + dequeues, but does not return the front of queue + +`q.clear()' + removes all elements from the queue. + + +File: libg++.info, Node: Deque, Next: PQ, Prev: Queue, Up: Top + +Double ended Queues +******************* + + Deques are declared as an "abstract" class. They are currently +implemented in two ways. + +`XPDeque' + implement dynamically-sized Deques via XPlexes. + +`DLDeque' + implement dynamically-size Deques via linked lists. + + All possess the same capabilities. They differ only in constructors. +XPDeque constructors optionally take a chunk size argument. DLDeque +constructors take no argument. + + Double-ended queues support both stack-like and queue-like +capabilities: + + Assume the declaration of a base element `x'. + +`Deque d; or Deque d(int initial_capacity)' + declares a deque. + +`d.empty()' + returns true if deque d is empty. + +`d.full()' + returns true if deque d is full. Always returns false in current + implementations. + +`d.length()' + returns the current number of elements in the deque. + +`d.enq(x)' + inserts x at the rear of deque d. + +`d.push(x)' + inserts x at the front of deque d. + +`x = d.deq()' + dequeues and returns the front of deque + +`d.front()' + returns a reference to the front of deque. + +`d.rear()' + returns a reference to the rear of the deque. + +`d.del_front()' + deletes, but does not return the front of deque + +`d.del_rear()' + deletes, but does not return the rear of the deque. + +`d.clear()' + removes all elements from the deque. + + +File: libg++.info, Node: PQ, Next: Set, Prev: Deque, Up: Top + +Priority Queue class prototypes. +******************************** + + Priority queues maintain collections of objects arranged for fast +access to the least element. + + Several prototype implementations of priority queues are supported. + +`XPPQs' + implement 2-ary heaps via XPlexes. + +`SplayPQs' + implement PQs via Sleator and Tarjan's (JACM 1985) splay trees. + The algorithms use a version of "simple top-down splaying" + (described on page 669 of the article). The simple-splay + mechanism for priority queue functions is loosely based on the one + used by D. Jones in the C splay tree functions available from + volume 14 of the uunet.uu.net archives. + +`PHPQs' + implement pairing heaps (as described by Fredman and Sedgewick in + `Algorithmica', Vol 1, p111-129). Storage for heap elements is + managed via an internal freelist technique. The constructor allows + an initial capacity estimate for freelist space. The storage is + automatically expanded if necessary to hold new items. The + deletion technique is a fast "lazy deletion" strategy that marks + items as deleted, without reclaiming space until the items come to + the top of the heap. + + All PQ classes support the following operations, for some PQ class +`Heap', instance `h', `Pix ind', and base class variable `x'. + +`h.empty()' + returns true if there are no elements in the PQ. + +`h.length()' + returns the number of elements in h. + +`ind = h.enq(x)' + Places x in the PQ, and returns its index. + +`x = h.deq()' + Dequeues the minimum element of the PQ into x, or generates an + error if the PQ is empty. + +`h.front()' + returns a reference to the minimum element. + +`h.del_front()' + deletes the minimum element. + +`h.clear();' + deletes all elements from h; + +`h.contains(x)' + returns true if x is in h. + +`h(ind)' + returns a reference to the item indexed by ind. + +`ind = h.first()' + returns the Pix of first item in the PQ or 0 if empty. This need + not be the Pix of the least element. + +`h.next(ind)' + advances ind to the Pix of next element, or 0 if there are no more. + +`ind = h.seek(x)' + Sets ind to the Pix of x, or 0 if x is not in h. + +`h.del(ind)' + deletes the item with Pix ind. + + +File: libg++.info, Node: Set, Next: Bag, Prev: PQ, Up: Top + +Set class prototypes +******************** + + Set classes maintain unbounded collections of items containing no +duplicate elements. + + These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] adding, [f] finding (via seek, +contains), [d] deleting, elements, and [c] comparing (via ==, <=) and +[m] merging (via |=, -=, &=) sets). + +`XPSets' + implement unordered sets via XPlexes. ([a O(n)], [f O(n)], [d + O(n)], [c O(n^2)] [m O(n^2)]). + +`OXPSets' + implement ordered sets via XPlexes. ([a O(n)], [f O(log n)], [d + O(n)], [c O(n)] [m O(n)]). + +`SLSets' + implement unordered sets via linked lists ([a O(n)], [f O(n)], [d + O(n)], [c O(n^2)] [m O(n^2)]). + +`OSLSets' + implement ordered sets via linked lists ([a O(n)], [f O(n)], [d + O(n)], [c O(n)] [m O(n)]). + +`AVLSets' + implement ordered sets via threaded AVL trees ([a O(log n)], [f + O(log n)], [d O(log n)], [c O(n)] [m O(n)]). + +`BSTSets' + implement ordered sets via binary search trees. The trees may be + manually rebalanced via the O(n) `balance()' member function. ([a + O(log n)/O(n)], [f O(log n)/O(n)], [d O(log n)/O(n)], [c O(n)] [m + O(n)]). + +`SplaySets' + implement ordered sets via Sleator and Tarjan's (JACM 1985) splay + trees. The algorithms use a version of "simple top-down splaying" + (described on page 669 of the article). (Amortized: [a O(log n)], + [f O(log n)], [d O(log n)], [c O(n)] [m O(n log n)]). + +`VHSets' + implement unordered sets via hash tables. The tables are + automatically resized when their capacity is exhausted. ([a + O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m + O(n)/O(n^2)]). + +`VOHSets' + implement unordered sets via ordered hash tables The tables are + automatically resized when their capacity is exhausted. ([a + O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m + O(n)/O(n^2)]). + +`CHSets' + implement unordered sets via chained hash tables. ([a O(1)/O(n)], + [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m O(n)/O(n^2)]). + + The different implementations differ in whether their constructors +require an argument specifying their initial capacity. Initial +capacities are required for plex and hash table based Sets. If none is +given `DEFAULT_INITIAL_CAPACITY' (from `defs.h') is used. + + Sets support the following operations, for some class `Set', +instances `a' and `b', `Pix ind', and base element `x'. Since all +implementations are virtual derived classes of the `Set' class, it +is possible to mix and match operations across different +implementations, although, as usual, operations are generally faster +when the particular classes are specified in functions operating on +Sets. + + Pix-based operations are more fully described in the section on +Pixes. *Note Pix:: + +`Set a; or Set a(int initial_size);' + Declares a to be an empty Set. The second version is allowed in + set classes that require initial capacity or sizing specifications. + +`a.empty()' + returns true if a is empty. + +`a.length()' + returns the number of elements in a. + +`Pix ind = a.add(x)' + inserts x into a, returning its index. + +`a.del(x)' + deletes x from a. + +`a.clear()' + deletes all elements from a; + +`a.contains(x)' + returns true if x is in a. + +`a(ind)' + returns a reference to the item indexed by ind. + +`ind = a.first()' + returns the Pix of first item in the set or 0 if the Set is empty. + For ordered Sets, this is the Pix of the least element. + +`a.next(ind)' + advances ind to the Pix of next element, or 0 if there are no more. + +`ind = a.seek(x)' + Sets ind to the Pix of x, or 0 if x is not in a. + +`a == b' + returns true if a and b contain all the same elements. + +`a != b' + returns true if a and b do not contain all the same elements. + +`a <= b' + returns true if a is a subset of b. + +`a |= b' + Adds all elements of b to a. + +`a -= b' + Deletes all elements of b from a. + +`a &= b' + Deletes all elements of a not occurring in b. + + +File: libg++.info, Node: Bag, Next: Map, Prev: Set, Up: Top + +Bag class prototypes +******************** + + Bag classes maintain unbounded collections of items potentially +containing duplicate elements. + + These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] adding, [f] finding (via seek, +contains), [d] deleting elements). + +`XPBags' + implement unordered Bags via XPlexes. ([a O(1)], [f O(n)], [d + O(n)]). + +`OXPBags' + implement ordered Bags via XPlexes. ([a O(n)], [f O(log n)], [d + O(n)]). + +`SLBags' + implement unordered Bags via linked lists ([a O(1)], [f O(n)], [d + O(n)]). + +`OSLBags' + implement ordered Bags via linked lists ([a O(n)], [f O(n)], [d + O(n)]). + +`SplayBags' + implement ordered Bags via Sleator and Tarjan's (JACM 1985) splay + trees. The algorithms use a version of "simple top-down splaying" + (described on page 669 of the article). (Amortized: [a O(log n)], + [f O(log n)], [d O(log n)]). + +`VHBags' + implement unordered Bags via hash tables. The tables are + automatically resized when their capacity is exhausted. ([a + O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)]). + +`CHBags' + implement unordered Bags via chained hash tables. ([a O(1)/O(n)], + [f O(1)/O(n)], [d O(1)/O(n)]). + + The implementations differ in whether their constructors require an +argument to specify their initial capacity. Initial capacities are +required for plex and hash table based Bags. If none is given +`DEFAULT_INITIAL_CAPACITY' (from `defs.h') is used. + + Bags support the following operations, for some class `Bag', +instances `a' and `b', `Pix ind', and base element `x'. Since all +implementations are virtual derived classes of the `Bag' class, it +is possible to mix and match operations across different +implementations, although, as usual, operations are generally faster +when the particular classes are specified in functions operating on +Bags. + + Pix-based operations are more fully described in the section on +Pixes. *Note Pix:: + +`Bag a; or Bag a(int initial_size)' + Declares a to be an empty Bag. The second version is allowed in + Bag classes that require initial capacity or sizing specifications. + +`a.empty()' + returns true if a is empty. + +`a.length()' + returns the number of elements in a. + +`ind = a.add(x)' + inserts x into a, returning its index. + +`a.del(x)' + deletes one occurrence of x from a. + +`a.remove(x)' + deletes all occurrences of x from a. + +`a.clear()' + deletes all elements from a; + +`a.contains(x)' + returns true if x is in a. + +`a.nof(x)' + returns the number of occurrences of x in a. + +`a(ind)' + returns a reference to the item indexed by ind. + +`int = a.first()' + returns the Pix of first item in the Bag or 0 if the Bag is empty. + For ordered Bags, this is the Pix of the least element. + +`a.next(ind)' + advances ind to the Pix of next element, or 0 if there are no more. + +`ind = a.seek(x, Pix from = 0)' + Sets ind to the Pix of the next occurrence x, or 0 if there are + none. If from is 0, the first occurrence is returned, else the + following from. + + +File: libg++.info, Node: Map, Next: GetOpt, Prev: Bag, Up: Top + +Map Class Prototypes +******************** + + Maps support associative array operations (insertion, deletion, and +membership of records based on an associated key). They require the +specification of two types, the key type and the contents type. + + These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] accessing (via op [], +contains), [d] deleting elements). + +`AVLMaps' + implement ordered Maps via threaded AVL trees ([a O(log n)], [d + O(log n)]). + +`RAVLMaps' + Similar, but also maintain ranking information, used via + `ranktoPix(int r)', that returns the `Pix' of the item at rank r, + and `rank(key)' that returns the rank of the corresponding item. + ([a O(log n)], [d O(log n)]). + +`SplayMaps' + implement ordered Maps via Sleator and Tarjan's (JACM 1985) splay + trees. The algorithms use a version of "simple top-down splaying" + (described on page 669 of the article). (Amortized: [a O(log n)], + [d O(log n)]). + +`VHMaps' + implement unordered Maps via hash tables. The tables are + automatically resized when their capacity is exhausted. ([a + O(1)/O(n)], [d O(1)/O(n)]). + +`CHMaps' + implement unordered Maps via chained hash tables. ([a O(1)/O(n)], + [d O(1)/O(n)]). + + The different implementations differ in whether their constructors +require an argument specifying their initial capacity. Initial +capacities are required for hash table based Maps. If none is given +`DEFAULT_INITIAL_CAPACITY' (from `defs.h') is used. + + All Map classes share the following operations (for some Map class, +`Map' instance `d', `Pix ind' and key variable `k', and contents +variable `x'). + + Pix-based operations are more fully described in the section on +Pixes. *Note Pix:: + +`Map d(x); Map d(x, int initial_capacity)' + Declare d to be an empty Map. The required argument, x, specifies + the default contents, i.e., the contents of an otherwise + uninitialized location. The second version, specifying initial + capacity is allowed for Maps with an initial capacity argument. + +`d.empty()' + returns true if d contains no items. + +`d.length()' + returns the number of items in d. + +`d[k]' + returns a reference to the contents of item with key k. If no such + item exists, it is installed with the default contents. Thus d[k] + = x installs x, and x = d[k] retrieves it. + +`d.contains(k)' + returns true if an item with key field k exists in d. + +`d.del(k)' + deletes the item with key k. + +`d.clear()' + deletes all items from the table. + +`x = d.dflt()' + returns the default contents. + +`k = d.key(ind)' + returns a reference to the key at Pix ind. + +`x = d.contents(ind)' + returns a reference to the contents at Pix ind. + +`ind = d.first()' + returns the Pix of the first element in d, or 0 if d is empty. + +`d.next(ind)' + advances ind to the next element, or 0 if there are no more. + +`ind = d.seek(k)' + returns the Pix of element with key k, or 0 if k is not in d. + + +File: libg++.info, Node: GetOpt, Next: Projects, Prev: Map, Up: Top + +C++ version of the GNU getopt function +************************************** + + The GetOpt class provides an efficient and structured mechanism for +processing command-line options from an application program. The sample +program fragment below illustrates a typical use of the GetOpt class +for some hypothetical application program: + + #include + #include + //... + int debug_flag, compile_flag, size_in_bytes; + + int + main (int argc, char **argv) + { + // Invokes ctor `GetOpt (int argc, char **argv, + // char *optstring);' + GetOpt getopt (argc, argv, "dcs:"); + int option_char; + + // Invokes member function `int operator ()(void);' + while ((option_char = getopt ()) != EOF) + switch (option_char) + { + case 'd': debug_flag = 1; break; + case 'c': compile_flag = 1; break; + case 's': size_in_bytes = atoi (getopt.optarg); break; + case '?': fprintf (stderr, + "usage: %s [dcs]\n", argv[0]); + } + } + + Unlike the C library version, the libg++ GetOpt class uses its +constructor to initialize class data members containing the argument +count, argument vector, and the option string. This simplifies the +interface for each subsequent call to member function `int operator +()(void)'. + + The C version, on the other hand, uses hidden static variables to +retain the option string and argument list values between calls to +`getopt'. This complicates the `getopt' interface since the argument +count, argument vector, and option string must be passed as parameters +for each invocation. For the C version, the loop in the previous +example becomes: + + while ((option_char = getopt (argc, argv, "dcs:")) != EOF) + // ... + + which requires extra overhead to pass the parameters for every call. + + Along with the GetOpt constructor and `int operator ()(void)', the +other relevant elements of class GetOpt are: + +`char *optarg' + Used for communication from `operator ()(void)' to the caller. + When `operator ()(void)' finds an option that takes an argument, + the argument value is stored here. + +`int optind' + 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 `operator ()(void)'. + + When `operator ()(void)' 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. + + The libg++ version of GetOpt acts like standard UNIX `getopt' for +the calling routine, 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 _POSIX_OPTION_ORDER disables +permutation. Then the behavior is completely standard. + diff --git a/gnu/lib/libg++/libg++/libg++.info-5 b/gnu/lib/libg++/libg++/libg++.info-5 new file mode 100644 index 00000000000..8ab2851fbea --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.info-5 @@ -0,0 +1,102 @@ +This is Info file libg++.info, produced by Makeinfo-1.55 from the input +file /kalessin/giga/bothner/dist/devo/libg++/libg++.texi. + +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY + + This file documents the features and implementation of The GNU C++ +library + + Copyright (C) 1988, 1991, 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. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the section entitled "GNU Library General Public License" is +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 the section entitled "GNU Library General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. + + +File: libg++.info, Node: Projects, Prev: GetOpt, Up: Top + +Projects and other things left to do +************************************ + +Coming Attractions +================== + + Some things that will probably be available in libg++ in the near +future: + + * Revamped C-compatibility header files that will be compatible with + the forthcoming (ANSI-based) GNU libc.a + + * A revision of the File-based classes that will use the GNU stdio + library, and also be 100% compatible (even at the streambuf level) + with the AT&T 2.0 stream classes. + + * Additional container class prototypes. + + * generic Matrix class prototypes. + + * A task package probably based on Dirk Grunwald's threads package. + +Wish List +========= + + Some things that people have mentioned that they would like to see +in libg++, but for which there have not been any offers: + + * A method to automatically convert or incorporate libg++ classes so + they can be used directly in Gorlen's OOPS environment. + + * A class browser. + + * A better general exception-handling strategy. + + * Better documentation. + +How to contribute +================= + + Programmers who have written C++ classes that they believe to be of +general interest are encourage to write to dl at rocky.oswego.edu. +Contributing code is not difficult. Here are some general guidelines: + + * FSF must maintain the right to accept or reject potential + contributions. Generally, the only reasons for rejecting + contributions are cases where they duplicate existing or + nearly-released code, contain unremovable specific machine + dependencies, or are somehow incompatible with the rest of the + library. + + * Acceptance of contributions means that the code is accepted for + adaptation into libg++. FSF must reserve the right to make + various editorial changes in code. Very often, this merely entails + formatting, maintenance of various conventions, etc. Contributors + are always given authorship credit and shown the final version for + approval. + + * Contributors must assign their copyright to FSF via a form sent out + upon acceptance. Assigning copyright to FSF ensures that the code + may be freely distributed. + + * Assistance in providing documentation, test files, and debugging + support is strongly encouraged. + + Extensions, comments, and suggested modifications of existing libg++ +features are also very welcome. + + diff --git a/gnu/lib/libg++/libg++/libg++.texi b/gnu/lib/libg++/libg++/libg++.texi new file mode 100644 index 00000000000..ee3755d7a96 --- /dev/null +++ b/gnu/lib/libg++/libg++/libg++.texi @@ -0,0 +1,4818 @@ +\input texinfo @c -*-texinfo-*- + +@settitle User's Guide to the GNU C++ Class Library +@setfilename libg++.info + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Libg++: (libg++). The g++ class library. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@ifinfo +This file documents the features and implementation of The GNU C++ library + +Copyright (C) 1988, 1991, 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 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 +section entitled ``GNU Library General Public License'' is 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 the section entitled ``GNU Library General Public License'' and +this permission notice may be included in translations approved by the +Free Software Foundation instead of in the original English. +@end ifinfo + +@iftex +@finalout +@c @smallbook +@c @cropmarks +@end iftex + +@setchapternewpage odd + +@titlepage +@title User's Guide +@title to the GNU C++ Library +@sp 3 +@subtitle last updated April 29, 1992 +@subtitle for version 2.0 +@author Doug Lea (dl@@g.oswego.edu) +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1988, 1991, 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. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +section entitled ``GNU Library General Public License'' is 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 the section entitled ``GNU Library General Public License'' may be +included in a translation approved by the author instead of in the original +English. + +@strong{Note: The GNU C++ library is still in test release. You will +be performing a valuable service if you report any bugs you encounter.} + +@end titlepage + +@ifinfo +@node Top, Copying, , (DIR) + +Introduction +************ + +This manual documents how to install and use the GNU C++ library. + +@end ifinfo +@menu +* Copying:: GNU Library Public License says how you can copy + and share the GNU C++ library. +* Contributors:: People who have contributed to GNU C++ library. +* Installation:: How to configure, compile and install GNU C++ library +* Trouble:: If you have trouble installing GNU C++ library. +* General:: Aims, objectives, and limitations of the GNU C++ library +* Conventions:: Stylistic conventions +* OK:: Support for representation invariants +* Proto:: Introduction to container class prototypes +* Pix:: Pseudo-indexes +* Representations:: How variable-sized objects are represented +* Expressions:: Some guidance on programming expression-oriented classes +* Headers:: Header files and other support for interfacing C++ to C +* Builtin:: Utility functions for builtin types +* New:: Library dynamic allocation primitives +* IOStream:(iostream)Top. + The input/output library (istreams and ostreams). +* Stream:: obsolete I/O library +* Obstack:: Obstacks and their uses. +* AllocRing:: A place to store objects for a while +* String:: String, SubString, and Regex classes. +* Integer:: Multiple precision Integer class. +* Rational:: Multiple precision Rational class +* Complex:: Complex number class +* Fix:: Fixed point proportion classes +* Bit:: BitSet and BitString classes +* Random:: Random number generators +* Data:: SampleStatistic and related classes for data collection +* Curses:: CursesWindow class +* List:: Lisp-like List prototype +* LinkList:: Singly and doubly linked list class prototypes +* Vector:: Vector prototypes +* Plex:: Plex (adjustable array) prototypes +* Stack:: Stack prototypes +* Queue:: Queue prototypes +* Deque:: Double ended queue prototypes +* PQ:: Heap (priority queue) class prototypes +* Set:: Set class prototypes +* Bag:: Bag class prototypes +* Map:: Map (Associative array) prototypes +* GetOpt:: C++ class-based version of the GNU/UNIX getopt function +* Projects:: Things Still Left to do +@end menu + +@node Copying, Contributors, Top, Top +@include lgpl.texinfo + +@node Contributors, Installation, Copying, Top +@unnumbered Contributors to GNU C++ library + +Aside from Michael Tiemann, who worked out the front end for GNU C++, and +Richard Stallman, who worked out the back end, the following people (not +including those who have made their contributions to GNU CC) should not go +unmentioned. + +@itemize @bullet +@item +Doug Lea contributed most otherwise unattributed classes. + +@item +Per Bothner contributed the iostream I/O classes. + +@item +Dirk Grunwald contributed the Random number generation classes, +and PairingHeaps. + +@item +Kurt Baudendistel contributed Fixed precision reals. + +@item +Doug Schmidt contributed ordered hash tables, a perfect +hash function generator, and several other utilities. + +@item +Marc Shapiro contributed the ideas and preliminary code for Plexes. + +@item +Eric Newton contributed the curses window classes. + +@item +Some of the I/O code is derived from BSD 4.4, +and was developed by the University of California, Berkeley. + +@item +The code for converting accurately between floating point numbers +and their string representations was written by David M. Gay of AT&T. +@end itemize + +@node Installation, Trouble, Contributors, Top +@chapter Installing GNU C++ library + + +@enumerate +@item +Read through the README file and the Makefile. Make sure that all +paths, system-dependent compile switches, and program names are correct. + +@item +Check that files @file{values.h}, @file{stdio.h}, +and @file{math.h} declare and define values appropriate for your +system. + +@item +Type @samp{make all} to compile the library, test, and install. +Current details about contents of the tests and utilities are in the +@file{README} file. + +@end enumerate + +@node Trouble, General, Installation, Top +@chapter Trouble in Installation + +Here are some of the things that have caused trouble for people installing +GNU C++ library. + +@enumerate +@item +Make sure that your GNU C++ version number is at least as high as your +libg++ version number. For example, libg++ 1.22.0 requires g++ 1.22.0 or +later releases. + +@item +Double-check system constants in the header files mentioned above. + +@end enumerate + +@node General, Conventions, Trouble, Top +@chapter GNU C++ library aims, objectives, and limitations + +The GNU C++ library, libg++ is an attempt to provide a variety of C++ +programming tools and other support to GNU C++ programmers. + +Differences in distribution policy are only part of the difference +between libg++.a and AT&T libC.a. libg++ is not intended to be an +exact clone of libC. For one, libg++ contains bits of code that depend +on special features of GNU g++ that are either different or lacking in +the AT&T version, including slightly different inlining and overloading +strategies, dynamic local arrays, etc. All of these +differences are minor. For example, while the AT&T and GNU stream +classes are implemented in very different ways, the vast majority of +C++ programs compile and run under either version with no visible +difference. Additionally, all g++-specific constructs are conditionally +compiled; The library is designed to be compatible with any 2.0 C++ +compiler. + +libg++ has also contained workarounds for some limitations in g++: both +g++ and libg++ are still undergoing rapid development and testing---a +task that is helped tremendously by the feedback of active users. This +manual is also still under development; it has some catching up to do +to include all the facilities now in the library. + +libg++ is not the only freely available source of C++ class libraries. +Some notable alternative sources are Interviews and NIHCL. +(InterViews has been available on the X-windows X11 tapes and also +from interviews.stanford.edu. NIHCL is available by anonymous +ftp from GNU archives (such as the pub directory of prep.ai.mit.edu), +although it is not supported by the FSF - and needs some work +before it will work with g++.) + +As every C++ programmer knows, the design (moreso than the +implementation) of a C++ class library is something of a challenge. +Part of the reason is that C++ supports two, partially incompatible, +styles of object-oriented programming -- The "forest" approach, +involving a collection of free-standing classes that can be mixed and +matched, versus the completely hierarchical (smalltalk style) +approach, in which all classes are derived from a common ancestor. Of +course, both styles have advantages and disadvantages. So far, libg++ +has adopted the "forest" approach. Keith Gorlen's OOPS library adopts +the hierarchical approach, and may be an attractive alternative for C++ +programmers who prefer this style. + +Currently (and/or in the near future) libg++ provides support for a +few basic kinds of classes: + +The first kind of support provides an interface between C++ programs and +C libraries. This includes basic header files (like @file{stdio.h}) as +well as things like the File and stream classes. Other classes that +interface to other aspects of C libraries (like those that maintain +environmental information) are in various stages of development; all +will undergo implementation modifications when the forthcoming GNU libc +library is released. + +The second kind of support contains general-purpose basic classes that +transparently manage variable-sized objects on the freestore. This +includes Obstacks, multiple-precision Integers and Rationals, +arbitrary length Strings, BitSets, and BitStrings. + +Third, several classes and utilities of common interest (e.g., +Complex numbers) are provided. + +Fourth, a set of pseudo-generic prototype files are available +as a mechanism for generating common container classes. These +are described in more detail in the introduction to container +prototypes. Currently, only a textual substitution +mechanism is available for generic class creation. + +@node Conventions, OK, General, Top +@chapter GNU C++ library stylistic conventions + +@itemize @bullet + +@item +C++ source files have file extension @file{.cc}. Both C-compatibility +header files and class declaration files have extension @file{.h}. + +@item +C++ class names begin with capital letters, except for @code{istream} +and @code{ostream}, for AT&T C++ compatibility. Multi-word class +names capitalize each word, with no underscore separation. + +@item +Include files that define C++ classes begin with capital letters +(as do the names of the classes themselves). @file{stream.h} is +uncapitalized for AT&T C++ compatibility. + +@item +Include files that supply function prototypes for other C +functions (system calls and libraries) are all lower case. + +@item +All include files define a preprocessor variable _X_h, where X +is the name of the file, and conditionally compile only if this +has not been already defined. The @code{#pragma once} facility +is also used to avoid re-inclusion. + +@item +Structures and objects that must be publicly defined, +but are not intended for public use have names beginning +with an underscore. (for example, the @code{_Srep} struct, which +is used only by the String and SubString classes.) + +@item +The underscore is used to separate components of long function +names, @*e.g., @code{set_File_exception_handler()}. + +@item +When a function could be usefully defined either as a +member or a friend, it is generally a member if it modifies +and/or returns itself, else it is a friend. There are cases +where naturalness of expression wins out over this rule. + +@item +Class declaration files are formatted so that it is easy +to quickly check them to determine function names, parameters, +and so on. Because of the different kinds of things that may +appear in class declarations, there is no perfect way to do +this. Any suggestions on developing a common class +declaration formatting style are welcome. + +@item +All classes use the same simple error (exception) handling strategy. +Almost every class has a member function named @code{error(char* msg)} +that invokes an associated error handler function via a pointer to that +function, so that the error handling function may be reset by +programmers. By default nearly all call @code{*lib_error_handler}, which +prints the message and then aborts execution. This system is subject +to change. In general, errors are assumed to be non-recoverable: +Library classes do not include code that allows graceful continuation +after exceptions. + +@end itemize + +@node OK, Proto, Conventions, Top +@chapter Support for representation invariants + +Most GNU C++ library classes possess a method named @code{OK()}, +that is useful in helping to verify correct performance of class +operations. + +The @code{OK()} operations checks the ``representation invariant'' of a +class object. This is a test to check whether the object is in a valid +state. In effect, it is a (sometimes partial) verification of the +library's promise that (1) class operations always leave objects in +valid states, and (2) the class protects itself so that client functions +cannot corrupt this state. + +While no simple validation technique can assure that all operations +perform correctly, calls to @code{OK()} can at least verify that +operations do not corrupt representations. For example for @code{String +a, b, c; ... a = b + c;}, a call to @code{a.OK();} will guarantee that +@code{a} is a valid @code{String}, but does not guarantee that it +contains the concatenation of @code{b + c}. However, given that @code{a} +is known to be valid, it is possible to further verify its properties, +for example via @code{a.after(b) == c && a.before(c) == b}. In other +words, @code{OK()} generally checks only those internal representation +properties that are otherwise inaccessible to users of the class. Other +class operations are often useful for further validation. + +Failed calls to @code{OK()} call a class's @code{error} method if +one exists, else directly call @code{abort}. Failure indicates +an implementation error that should be reported. + +With only rare exceptions, the internal support functions for a class +never themselves call @code{OK()} (although many of the test files +in the distribution call @code{OK()} extensively). + +Verification of representational invariants can sometimes be +very time consuming for complicated data structures. + + +@node Proto, Representations, OK, Top +@chapter Introduction to container class prototypes + +As a temporary mechanism enabling the support of generic classes, the GNU +C++ Library distribution contains a directory (@file{g++-include}) of files +designed to serve as the basis for generating container classes of +specified elements. These files can be used to generate @file{.h} and +@file{.cc} files in the current directory via a supplied shell script +program that performs simple textual substitution to create specific +classes. + +While these classes are generated independently, and thus share no code, +it is possible to create versions that do share code among subclasses. For +example, using @code{typedef void* ent}, and then generating a +@code{entList} class, other derived classes could be created using the +@code{void*} coercion method described in Stroustrup, pp204-210. + +This very simple class-generation facility is useful enough to serve +current purposes, but will be replaced with a more coherent mechanism for +handling C++ generics in a way that minimally disrupts current usage. +Without knowing exactly when or how parametric classes might be +added to the C++ language, provision of this simplest possible +mechanism, textual substitution, appears to be the safest strategy, +although it does require certain redundancies and awkward constructions. + +Specific classes may be generated via the @file{genclass} shell script +program. This program has arguments specifying the kinds of base types(s) +to be used. Specifying base types requires two arguments. The first is the +name of the base type, which may be any named type, like @code{int} or +@code{String}. Only named types are supported; things like @code{int*} are +not accepted. However, pointers like this may be used by supplying the +appropriate typedefs (e.g., editing the resulting files to include +@code{typedef int* intp;}). The type name must be followed by one of the +words @code{val} or @code{ref}, to indicate whether the base elements +should be passed to functions by-value or by-reference. + +You can specify basic container classes using @code{genclass base +[val,ref] proto}, where @code{proto} is the name of the class being +generated. Container classes like dictionaries and maps that require +two types may be specified via @code{genclass -2 keytype [val, ref], +basetype [val, ref] proto}, where the key type is specified first and +the contents type second. The resulting classnames and filenames are +generated by prepending the specified type names to the prototype names, +and separating the filename parts with dots. For example, +@code{genclass int val List} generates class @code{intList} residing in +files @file{int.List.h} and @file{int.List.cc}. @code{genclass -2 String +ref int val VHMap} generates (the awkward, but unavoidable) class name +@code{StringintVHMap}. Of course, programmers may use @code{typedef} or +simple editing to create more appropriate names. The existence of dot +seperators in file names allows the use of GNU make to help automate +configuration and recompilation. An example Makefile exploiting such +capabilities may be found in the @file{libg++/proto-kit} directory. + +The @code{genclass} utility operates via simple text substitution using +@code{sed}. All occurrences of the pseudo-types @code{} and @code{} +(if there are two types) are replaced with the indicated type, and +occurrences of @code{} and @code{} are replaced by just the types, +if @code{val} is specified, or types followed by ``&'' if @code{ref} is +specified. + +Programmers will frequently need to edit the @file{.h} file in order to +insert additional @code{#include} directives or other modifications. A +simple utility, @file{prepend-header} to prepend other @file{.h} files +to generated files is provided in the distribution. + +One dubious virtue of the prototyping mechanism is that, because sources files, +not archived library classes, are generated, it is relatively simple for +programmers to modify container classes in the common case where slight +variations of standard container classes are required. + +It is often a good idea for programmers to archive (via @code{ar}) +generated classes into @file{.a} files so that only those class +functions actually used in a given application will be loaded. +The test subdirectory of the distribution shows an example of this. + +Because of @code{#pragma interface} directives, the @file{.cc} files +should be compiled with @code{-O} or @code{-DUSE_LIBGXX_INLINES} +enabled. + +Many container classes require specifications over and above the base +class type. For example, classes that maintain some kind of ordering of +elements require specification of a comparison function upon which to +base the ordering. This is accomplished via a prototype file +@file{defs.hP} that contains macros for these functions. While these +macros default to perform reasonable actions, they can and should be +changed in particular cases. Most prototypes require only one or a few +of these. No harm is done if unused macros are defined to perform +nonsensical actions. The macros are: + +@table @code + +@item DEFAULT_INITIAL_CAPACITY +The initial capacity for containers (e.g., hash tables) that require +an initial capacity argument for constructors. +Default: 100 + +@item EQ(a, b) +return true if a is considered equal to b for the purposes of +locating, etc., an element in a container. +Default: (a == b) + +@item LE(a, b) +return true if a is less than or equal to b +Default: (a <= b) + +@item CMP(a, b) +return an integer < 0 if a 0 if a>b. +Default: (a <= b)? (a==b)? 0 : -1 : 1 + +@item HASH(a) +return an unsigned integer representing the hash of a. +Default: hash(a) ; where extern unsigned int hash(). +(note: several useful hash functions are declared in builtin.h +and defined in hash.cc) + +@end table + +Nearly all prototypes container classes support container +traversal via @code{Pix} pseudo indices, as described elsewhere. + +All object containers must perform either a @code{X::X(X&)} (or +@code{X::X()} followed by @code{X::operator =(X&)}) to copy objects into +containers. (The latter form is used for containers built from C++ +arrays, like @code{VHSets}). When containers are destroyed, they invoke +@code{X::~X()}. Any objects used in containers must have well behaved +constructors and destructors. If you want to create containers that +merely reference (point to) objects that reside elsewhere, and are not +copied or destroyed inside the container, you must use containers +of pointers, not containers of objects. + +All prototypes are designed to generate @emph{HOMOGENOUS} container +classes. There is no universally applicable method in C++ to support +heterogenous object collections with elements of various subclasses of +some specified base class. The only way to get heterogenous structures +is to use collections of pointers-to-objects, not collections of objects +(which also requires you to take responsibility for managing storage for +the objects pointed to yourself). + +For example, the following usage illustrates a commonly encountered +danger in trying to use container classes for heterogenous structures: + +@smallexample +class Base @{ int x; ...@} +class Derived : public Base @{ int y; ... @} + +BaseVHSet s; // class BaseVHSet generated via something like + // `genclass Base ref VHSet' + +void f() +@{ + Base b; + s.add(b); // OK + + Derived d; + s.add(d); // (CHOP!) +@} +@end smallexample + +At the line flagged with @samp{(CHOP!)}, a @code{Base::Base(Base&)} is +called inside @code{Set::add(Base&)}---@emph{not} +@code{Derived::Derived(Derived&)}. Actually, in @code{VHSet}, a +@code{Base::operator =(Base&)}, is used instead to place the element in +an array slot, but with the same effect. So only the Base part is +copied as a @code{VHSet} element (a so-called chopped-copy). In this +case, it has an @code{x} part, but no @code{y} part; and a Base, not +Derived, vtable. Objects formed via chopped copies are rarely +sensible.@refill + +To avoid this, you must resort to pointers: + +@smallexample +typedef Base* BasePtr; + +BasePtrVHSet s; // class BaseVHSet generated via something like + // `genclass BasePtr val VHSet' + +void f() +@{ + Base* bp = new Base; + s.add(b); + + Base* dp = new Derived; + s.add(d); // works fine. + + // Don't forget to delete bp and dp sometime. + // The VHSet won't do this for you. +@} +@end smallexample + +@section Example + +The prototypes can be difficult to use on first attempt. Here is an +example that may be helpful. The utilities in the @file{proto-kit} +simplify much of the actions described, but are not used here. + +Suppose you create a class @code{Person}, and want to make an Map that +links the social security numbers associated with each person. You start +off with a file @file{Person.h} + +@example + +#include + +class Person +@{ + String nm; + String addr; + //... +public: + const String& name() @{ return nm; @} + const String& address() @{ return addr; @} + void print() @{ ... @} + //... +@} + +@end example + +And in file @file{SSN.h}, + +@example +typedef unsigned int SSN; +@end example + +Your first decision is what storage/usage strategy to use. There are +several reasonable alternatives here: You might create an ``object +collection'' of Persons, a ``pointer collection'' of +pointers-to-Persons, or even a simple String map, housing either copies +of pointers to the names of Persons, since other fields are unused for +purposes of the Map. In an object collection, instances of class Person +``live'' inside the Map, while in a pointer collection, the instances +live elsewhere. Also, as above, if instances of subclasses of Person are +to be used inside the Map, you must use pointers. In a String Map, the +same difference holds, but now only for the name fields. Any of these +choices might make sense in particular applications. + +The second choice is the Map implementation strategy. Either a tree +or a hash table might make sense. Suppose you want an AVL tree Map. +There are two things to now check. First, as an object collection, +the AVLMap requires that the elsement class contain an @code{X(X&)} +constructor. In C++, if you don't specify such a constructor, one +is constructed for you, but it is a very good idea to always do this +yourself, to avoid surprises. In this example, you'd use something like +@example +class Person +@{ ...; + Person(const Person& p) :nm(p.nm), addr(p.addr) @{@} +@}; +@end example + +Also, an AVLMap requires a comparison function for elements in order +to maintain order. Rather than requiring you to write a particular +comparison function, a @file{defs} file is consulted to determine how to +compare items. You must create and edit such a file. + +Before creating @file{Person.defs.h}, you must first make one additional +decision. Should the Map member functions like @code{m.contains(p)} +take arguments (@code{p}) by reference (i.e., typed as +@code{int Map::contains(const Person& p)} or by value (i.e., typed as +@code{int Map::contains(const Person p)}. Generally, for user-defined +classes, you want to pass by reference, and for builtins and pointers, +to pass by value. SO you should pick by-reference. + +You can now create @file{Person.defs.h} via @code{genclass Person ref defs}. +This creates a simple skeleton that you must edit. First, add +@code{#include "Person.h"} to the top. Second, edit the @code{CMP(a,b)} +macro to compare on name, via + +@example +#define CMP(a, b) ( compare(a.name(), b.name()) ) +@end example + +@noindent +which invokes the @code{int compare(const String&, const String&)} +function from @file{String.h}. Of course, you could define this in any +other way as well. In fact, the default versions in the skeleton turn +out to be OK (albeit inefficient) in this particular example. + +You may also want to create file @file{SSN.defs.h}. Here, choosing +call-by-value makes sense, and since no other capabilities (like +comparison functions) of the SSNs are used (and the defaults are OK +anyway), you'd type + +@example +genclass SSN val defs +@end example + +@noindent +and then edit to place @code{#include "SSN.h"} at the top. + +Finally, you can generate the classes. First, generate the base +class for Maps via + +@example +genclass -2 Person ref SSN val Map +@end example + +@noindent +This generates only the abstract class, not the implementation, in file +@file{Person.SSN.Map.h} and @file{Person.SSN.Map.cc}. To create the +AVL implementation, type + +@example +genclass -2 Person ref SSN val AVLMap +@end example + +@noindent +This creates the class @code{PersonSSNAVLMap}, in +@file{Person.SSN.AVLMap.h} and @file{Person.SSN.AVLMap.cc}. + +To use the AVL implementation, compile the two generated @file{.cc} files, and +specify @samp{#include "Person.SSN.AVLMap.h"} in the application program. +All other files are included in the right ways automatically. + +One last consideration, peculiar to Maps, is to pick a reasonable +default contents when declaring an AVLMap. Zero might be appropriate +here, so you might declare a Map, + +@example +PersonSSNAVLMap m((SSN)0); +@end example + +Suppose you wanted a @code{VHMap} instead of an @code{AVLMap} Besides +generating different implementations, there are two differences in +how you should prepare the @file{defs} file. First, because a VHMap +uses a C++ array internally, and because C++ array slots are initialized +differently than single elements, you must ensure that class Person +contains (1) a no-argument constructor, and (2) an assignment operator. +You could arrange this via + +@smallexample +class Person +@{ ...; + Person() @{@} + void operator = (const Person& p) @{ nm = p.nm; addr = p.addr; @} +@}; +@end smallexample + +(The lack of action in the constructor is OK here because @code{Strings} +possess usable no-argument constructors.) + +You also need to edit @file{Person.defs.h} to indicate a usable hash +function and default capacity, via something like + +@example +#include +#define HASH(x) (hashpjw(x.name().chars())) +#define DEFAULT_INITIAL_CAPACITY 1000 +@end example + +Since the @code{hashpjw} function from @file{builtin.h} is +appropriate here. Changing the default capacity to a value +expected to exceed the actual capacity helps to avoid +``hidden'' inefficiencies when a new VHMap is created without +overriding the default, which is all too easy to do. + +Otherwise, everything is the same as above, substituting +@code{VHMap} for @code{AVLMap}. + +@node Representations, Expressions, Proto, Top +@chapter Variable-Sized Object Representation + +One of the first goals of the GNU C++ library is to enrich the kinds of +basic classes that may be considered as (nearly) ``built into'' C++. A good +deal of the inspiration for these efforts is derived from considering +features of other type-rich languages, particularly Common Lisp and Scheme. +The general characteristics of most class and friend operators and +functions supported by these classes has been heavily influenced +by such languages. + +Four of these types, Strings, Integers, BitSets, and BitStrings (as well as +associated and/or derived classes) require representations suitable for +managing variable-sized objects on the free-store. The basic technique used +for all of these is the same, although various details necessarily differ +from class to class. + +The general strategy for representing such objects is to create chunks of +memory that include both header information (e.g., the size of the object), +as well as the variable-size data (an array of some sort) at the end +of the chunk. Generally the maximum size of an object is limited to +something less than all of addressable memory, as a safeguard. The minimum +size is also limited so as not to waste allocations expanding very small +chunks. Internally, chunks are allocated in blocks well-tuned to the +performance of the @code{new} operator. + +Class elements themselves are merely pointers to these chunks. +Most class operations are performed via inline ``translation'' +functions that perform the required operation on the corresponding +representation. However, constructors and assignments operate by +copying entire representations, not just pointers. + + +No attempt is made to control temporary creation in expressions +and functions involving these classes. Users of previous versions +of the classes will note the disappearance of both ``Tmp'' classes +and reference counting. These were dropped because, while they +did improve performance in some cases, they obscure class +mechanics, lead programmers into the false belief that they need not +worry about such things, and occasionally have paradoxical behavior. + + +These variable-sized object classes are integrated as well as possible +into C++. Most such classes possess converters that allow automatic +coercion both from and to builtin basic types. (e.g., char* to and from +String, long int to and from Integer, etc.). There are pro's and con's +to circular converters, since they can sometimes lead to the conversion +from a builtin type through to a class function and back to a builtin +type without any special attention on the part of the programmer, both +for better and worse. + +Most of these classes also provide special-case operators and functions +mixing basic with class types, as a way to avoid constructors in cases +where the operations do not rely on anything special about the +representations. For example, there is a special case concatenation +operator for a String concatenated with a char, since building the +result does not rely on anything about the String header. Again, there +are arguments both for and against this approach. Supporting these cases +adds a non-trivial degree of (mainly inline) function proliferation, but +results in more efficient operations. Efficiency wins out over parsimony +here, as part of the goal to produce classes that provide sufficient +functionality and efficiency so that programmers are not tempted to try +to manipulate or bypass the underlying representations. + +@node Expressions, Pix, Representations, Top +@chapter Some guidelines for using expression-oriented classes + + +The fact that C++ allows operators to be overloaded for user-defined +classes can make programming with library classes like @code{Integer}, +@code{String}, and so on very convenient. However, it is worth +becoming familiar with some of the inherent limitations and problems +associated with such operators. + +Many operators are @emph{constructive}, i.e., create a new object +based on some function of some arguments. Sometimes the creation +of such objects is wasteful. Most library classes supporting +expressions contain facilities that help you avoid such waste. + +For example, for @code{Integer a, b, c; ...; c = a + b + a;}, the +plus operator is called to sum a and b, creating a new temporary object +as its result. This temporary is then added with a, creating another +temporary, which is finally copied into c, and the temporaries are then +deleted. In other words, this code might have an effect similar to +@code{Integer a, b, c; ...; Integer t1(a); t1 += b; Integer t2(t1); +t2 += a; c = t2;}. + +For small objects, simple operators, and/or non-time/space critical +programs, creation of temporaries is not a big problem. However, often, +when fine-tuning a program, it may be a good idea to rewrite such +code in a less pleasant, but more efficient manner. + +For builtin types like ints, and floats, C and C++ compilers already +know how to optimize such expressions to reduce the need for +temporaries. Unfortunately, this is not true for C++ user defined +types, for the simple (but very annoying, in this context) reason that +nothing at all is guaranteed about the semantics of overloaded operators +and their interrelations. For example, if the above expression just +involved ints, not Integers, a compiler might internally convert the +statement into something like @code{ c = a; c += b; c+= a; }, or +perhaps something even more clever. But since C++ does not know that +Integer operator += has any relation to Integer operator +, A C++ +compiler cannot do this kind of expression optimization itself. + +In many cases, you can avoid construction of temporaries simply by +using the assignment versions of operators whenever possible, since +these versions create no temporaries. However, for maximum flexibility, +most classes provide a set of ``embedded assembly code'' procedures +that you can use to fully control time, space, and evaluation strategies. +Most of these procedures are ``three-address'' procedures that take +two @code{const} source arguments, and a destination argument. The +procedures perform the appropriate actions, placing the results in +the destination (which is may involve overwriting old contents). These +procedures are designed to be fast and robust. In particular, aliasing +is always handled correctly, so that, for example +@code{add(x, x, x); } is perfectly OK. (The names of these procedures +are listed along with the classes.) + +For example, suppose you had an Integer expression +@code{ a = (b - a) * -(d / c); } + +This would be compiled as if it were +@code{ Integer t1=b-a; Integer t2=d/c; Integer t3=-t2; Integer t4=t1*t3; a=t4;} + +But, with some manual cleverness, you might yourself some up with +@code{ sub(a, b, a); mul(a, d, a); div(a, c, a); } + + +A related phenomenon occurs when creating your own constructive +functions returning instances of such types. Suppose you wanted +to write function +@code{Integer f(const Integer& a) @{ Integer r = a; r += a; return r; @}} + +This function, when called (as in @code{ a = f(a); }) demonstrates a +similar kind of wasted copy. The returned value r must be copied +out of the function before it can be used by the caller. In GNU +C++, there is an alternative via the use of named return values. +Named return values allow you to manipulate the returned object +directly, rather than requiring you to create a local inside +a function and then copy it out as the returned value. In this +example, this can be done via +@code{Integer f(const Integer& a) return r(a) @{ r += a; return; @}} + + +A final guideline: The overloaded operators are very convenient, and +much clearer to use than procedural code. It is almost always a good +idea to make it right, @emph{then} make it fast, by translating +expression code into procedural code after it is known to be correct. + + + +@node Pix, Headers, Expressions, Top +@chapter Pseudo-indexes + +Many useful classes operate as containers of elements. Techniques for +accessing these elements from a container differ from class to class. +In the GNU C++ library, access methods have been partially standardized +across different classes via the use of pseudo-indexes called +@code{Pixes}. A @code{Pix} acts in some ways like an index, and in some +ways like a pointer. (Their underlying representations are just +@code{void*} pointers). A @code{Pix} is a kind of ``key'' that is +translated into an element access by the class. In virtually all cases, +@code{Pixes} are pointers to some kind internal storage cells. The +containers use these pointers to extract items. + +@code{Pixes} support traversal and inspection of elements in a +collection using analogs of array indexing. However, they are +pointer-like in that @code{0} is treated as an invalid @code{Pix}, and +unsafe insofar as programmers can attempt to access nonexistent elements +via dangling or otherwise invalid @code{Pixes} without first checking +for their validity. + +In general it is a very bad idea to perform traversals in the the midst +of destructive modifications to containers. + +Typical applications might include code using the idiom +@example +for (Pix i = a.first(); i != 0; a.next(i)) use(a(i)); +@end example +for some container @code{a} and function @code{use}. + +Classes supporting the use of @code{Pixes} always contain the following +methods, assuming a container @code{a} of element types of @code{Base}. + +@table @code + +@item Pix i = a.first() +Set i to index the first element of a or 0 if a is empty. + +@item a.next(i) +advance i to the next element of a or 0 if there is no next element; + +@item Base x = a(i); a(i) = x; +a(i) returns a reference to the element indexed by i. + +@item int present = a.owns(i) +returns true if Pix i is a valid Pix in a. This is often a +relatively slow operation, since the collection must usually +traverse through elements to see if any correspond to the Pix. + +@end table + +Some container classes also support backwards traversal via + +@table @code +@item Pix i = a.last() +Set i to the last element of a or 0 if a is empty. + +@item a.prev(i) +sets i to the previous element in a, or 0 if there is none. +@end table + +Collections supporting elements with an equality operation possess + +@table @code +@item Pix j = a.seek(x) +sets j to the index of the first occurrence of x, or 0 if x is +not contained in a. +@end table + +Bag classes possess + +@table @code +@item Pix j = a.seek(x, Pix from = 0) +sets j to the index of the next occurrence of x following i, +or 0 if x is not contained in a. If i == 0, the first occurrence +is returned. +@end table + +Set, Bag, and PQ classes possess + +@table @code +@item Pix j = a.add(x) (or a.enq(x) for priority queues) +add x to the collection, returning its Pix. The Pix of an item +can change in collections where further additions and deletions +involve the actual movement of elements (currently in OXPSet, +OXPBag, XPPQ, VOHSet), but in all other cases, an item's Pix may +be considered a permanent key to its location. +@end table + +@node Headers, Builtin, Pix, Top +@chapter Header files for interfacing C++ to C + +The following files are provided so that C++ programmers may +invoke common C library and system calls. The names and contents +of these files are subject to change in order to be compatible +with the forthcoming GNU C library. Other files, not listed +here, are simply C++-compatible interfaces to corresponding C +library files. + +@table @file +@item values.h +A collection of constants defining the numbers of bits in builtin +types, minimum and maximum values, and the like. Most names are +the same as those found in @file{values.h} found on Sun systems. + +@item std.h +A collection of common system calls and @file{libc.a} functions. +Only those functions that can be declared without introducing +new type definitions (socket structures, for example) are +provided. Common @code{char*} functions (like @code{strcmp}) are among +the declarations. All functions are declared along with their +library names, so that they may be safely overloaded. + +@item string.h +This file merely includes @file{}, where string function +prototypes are declared. This is a workaround for the fact that +system @file{string.h} and @file{strings.h} files often differ +in contents. + +@item osfcn.h +This file merely includes @file{}, where system function +prototypes are declared. + +@item libc.h +This file merely includes @file{}, where C library function +prototypes are declared. + +@item math.h +A collection of prototypes for functions usually found in +libm.a, plus some @code{#define}d constants that appear to be +consistent with those provided in the AT&T version. The value +of @code{HUGE} should be checked before using. Declarations of +all common math functions are preceded with @code{overload} +declarations, since these are commonly overloaded. + +@item stdio.h +Declaration of @code{FILE} (@code{_iobuf}), common macros (like +@code{getc}), and function prototypes for @file{libc.a} +functions that operate on @code{FILE*}'s. The value +@code{BUFSIZ} and the declaration of @code{_iobuf} should be +checked before using. + +@item assert.h +C++ versions of assert macros. + +@item generic.h +String concatenation macros useful in creating generic classes. +They are similar in function to the AT&T CC versions. + +@item new.h +Declarations of the default global operator new, the two-argument +placement version, and associated error handlers. +@end table + +@node Builtin, New, Headers, Top +@chapter Utility functions for built in types + +Files @file{builtin.h} and corresponding @file{.cc} implementation +files contain various convenient +inline and non-inline utility functions. These include useful +enumeration types, such as @code{TRUE}, @code{FALSE} ,the type +definition for pointers to libg++ error handling functions, and +the following functions. + +@table @code +@item long abs(long x); double abs(double x); +inline versions of abs. Note that the standard libc.a version, +@code{int abs(int)} is @emph{not} declared as inline. + +@item void clearbit(long& x, long b); +clears the b'th bit of x (inline). + +@item void setbit(long& x, long b); +sets the b'th bit of x (inline) + +@item int testbit(long x, long b); +returns the b'th bit of x (inline). + +@item int even(long y); +returns true if x is even (inline). + +@item int odd(long y); +returns true is x is odd (inline). + +@item int sign(long x); int sign(double x); +returns -1, 0, or 1, indicating whether x is less than, equal to, or +greater than zero (inline). + +@item long gcd(long x, long y); +returns the greatest common divisor of x and y. + +@item long lcm(long x, long y); +returns the least common multiple of x and y. + +@item long lg(long x); +returns the floor of the base 2 log of x. + +@item long pow(long x, long y); double pow(double x, long y); +returns x to the integer power y using via the iterative O(log y) +``Russian peasant'' method. + +@item long sqr(long x); double sqr(double x); +returns x squared (inline). + +@item long sqrt(long y); +returns the floor of the square root of x. + +@item unsigned int hashpjw(const char* s); +a hash function for null-terminated char* strings using the +method described in Aho, Sethi, & Ullman, p 436. + +@item unsigned int multiplicativehash(int x); +a hash function for integers that returns the lower bits of +multiplying x by the golden ratio times pow(2, 32). +See Knuth, Vol 3, p 508. + +@item unsigned int foldhash(double x); +a hash function for doubles that exclusive-or's the first and +second words of x, returning the result as an integer. + +@item double start_timer() +Starts a process timer. + +@item double return_elapsed_time(double last_time) +Returns the process time since last_time. +If last_time == 0 returns the time since the last start_timer. +Returns -1 if start_timer was not first called. + +@end table + +File @file{Maxima.h} includes versions of @code{MAX, MIN} +for builtin types. + +File @file{compare.h} includes versions of @code{compare(x, y)} +for builtin types. These return negative if the first argument +is less than the second, zero for equal, and positive for greater. + +@node New, Stream, Builtin, Top +@chapter Library dynamic allocation primitives + +Libg++ contains versions of @code{malloc, free, realloc} that were +designed to be well-tuned to C++ applications. The source file +@file{malloc.c} contains some design and implementation details. +Here are the major user-visible differences from most system +malloc routines: + +@enumerate + +@item +These routines @emph{overwrite} storage of freed space. This +means that it is never permissible to use a @code{delete}'d +object in any way. Doing so will either result in trapped +fatal errors or random aborts within malloc, free, or realloc. + +@item +The routines tend to perform well when a large number +of objects of the same size are allocated and freed. You +may find that it is not worth it to create your +own special allocation schemes in such cases. + +@item +The library sets top-level @code{operator new()} to call malloc and +@code{operator delete()} to call free. Of course, you may override these +definitions in C++ programs by creating your own operators that will +take precedence over the library versions. However, if you do so, be +sure to define @emph{both} @code{operator new()} and @code{operator +delete()}. + +@item +These routines do @emph{not} support the odd convention, maintained by +some versions of malloc, that you may call @code{realloc} with a pointer +that has been @code{free}'d. + +@item +The routines automatically perform simple checks on @code{free}'d +pointers that can often determine whether users have accidentally +written beyond the boundaries of allocated space, resulting in a fatal +error. + +@item +The function @code{malloc_usable_size(void* p)} returns the number of +bytes actually allocated for @code{p}. For a valid pointer (i.e., one +that has been @code{malloc}'d or @code{realloc}'d but not yet +@code{free}'d) this will return a number greater than or equal to the +requested size, else it will normally return 0. Unfortunately, a +non-zero return can not be an absolutely perfect indication of lack of +error. If a chunk has been @code{free}'d but then re-allocated for a +different purpose somewhere elsewhere, then @code{malloc_usable_size} +will return non-zero. Despite this, the function can be very valuable +for performing run-time consistency checks. + +@item +@code{malloc} requires 8 bytes of overhead per allocated chunk, plus a +mmaximum alignment adjustment of 8 bytes. The number of bytes of usable +space is exactly as requested, rounded to the nearest 8 byte boundary. + +@item +The routines do @emph{not} contain any synchronization support for +multiprocessing. If you perform global allocation on a shared +memory multiprocessor, you should disable compilation and use +of libg++ malloc in the distribution @file{Makefile} and use your +system version of malloc. + +@end enumerate + +@iftex +@node IOStream +@chapter The new input/output classes + +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). +These classes are available in @code{libg++} for convenience and for +compatibility with older releases; however, since the iostream classes +are licensed under less stringent terms than @code{libg++}, they are now +also available in a separate library called @code{libio}---and +documented in a separate manual, corresponding to that library. + +@xref{Introduction,,Introduction, iostream.info, The GNU C++ Iostream +Library}. +@end iftex + +@node Stream, Obstack, New, Top +@chapter The old I/O library + +WARNING: This chapter describes classes that are @emph{obsolete}. +These classes are normally not available when libg++ +is installed normally. The sources are currently included +in the distribution, and you can configure libg++ to use +these classes instead of the new iostream classes. +This is only a temporary measure; you should convert your +code to use iostreams as soon as possible. The iostream +classes provide some compatibility support, but it is +very incomplete (there is no longer a @code{File} class). + +@section File-based classes + +The @code{File} class supports basic IO on Unix files. Operations are +based on common C stdio library functions. + +@code{File} serves as the base class for istreams, ostreams, and other +derived classes. It contains the interface between the Unix stdio file +library and these more structured classes. Most operations are implemented +as simple calls to stdio functions. @code{File} class operations are also fully +compatible with raw system file reads and writes (like the system +@code{read} and @code{lseek} calls) when buffering is disabled (see below). +The @code{FILE*} stdio file pointer is, however maintained as protected. +Classes derived from File may only use the IO operations provided by File, +which encompass essentially all stdio capabilities. + +The class contains four general kinds of functions: methods for binding +@code{File}s to physical Unix files, basic IO methods, file and buffer +control methods, and methods for maintaining logical and physical file +status. + + +Binding and related tasks are accomplished via @code{File} constructors and +destructors, and member functions @code{open, close, remove, filedesc, +name, setname}. + +If a file name is provided in a constructor or open, it is +maintained as class variable @code{nm} and is accessible +via @code{name}. If no name is provided, then @code{nm} remains +null, except that @code{Files} bound to the default files stdin, +stdout, and stderr are automatically given the names +@code{(stdin), (stdout), (stderr)} respectively. +The function @code{setname} may be used to change the +internal name of the @code{File}. This does not change the name +of the physical file bound to the File. + +The member function @code{close} closes a file. The +@code{~File} destructor closes a file if it is open, except +that stdin, stdout, and stderr are flushed but left open for +the system to close on program exit since some systems may +require this, and on others it does not matter. @code{remove} +closes the file, and then deletes it if possible by calling the +system function to delete the file with the name provided in +the @code{nm} field. + +@section Basic IO + +@itemize @bullet + +@item +@code{read} and @code{write} perform binary IO via stdio +@code{fread} and @code{fwrite}. + +@item +@code{get} and @code{put} for chars invoke stdio @code{getc} +and @code{putc} macros. + +@item +@code{put(const char* s)} outputs a null-terminated string via +stdio @code{fputs}. + +@item +@code{unget} and @code{putback} are synonyms. Both call stdio +@code{ungetc}. + +@end itemize + +@section File Control + +@code{flush}, @code{seek}, @code{tell}, and @code{tell} call the +corresponding stdio functions. + +@code{flush(char)} and @code{fill()} call stdio @code{_flsbuf} +and @code{_filbuf} respectively. + +@code{setbuf} is mainly useful to turn off buffering in cases +where nonsequential binary IO is being performed. @code{raw} is a +synonym for @code{setbuf(_IONBF)}. After a @code{f.raw()}, using +the stdio functions instead of the system @code{read, write}, +etc., calls entails very little overhead. Moreover, these become +fully compatible with intermixed system calls (e.g., +@code{lseek(f.filedesc(), 0, 0)}). While intermixing @code{File} +and system IO calls is not at all recommended, this technique +does allow the @code{File} class to be used in conjunction with +other functions and libraries already set up to operate on file +descriptors. @code{setbuf} should be called at most once after a +constructor or open, but before any IO. + +@section File Status + +File status is maintained in several ways. + +A @code{File} may be checked for accessibility via +@code{is_open()}, which returns true if the File is bound to a +usable physical file, @code{readable()}, which returns true if +the File can be read from (opened for reading, and not in a +_fail state), or @code{writable()}, which returns true if the +File can be written to. + +@code{File} operations return their status via two means: failure and +success are represented via the logical state. Also, the +return values of invoked stdio and system functions that +return useful numeric values (not just failure/success flags) +are held in a class variable accessible via @code{iocount}. +(This is useful, for example, in determining the number of +items actually read by the @code{read} function.) + +Like the AT&T i/o-stream classes, but unlike the description in +the Stroustrup book, p238, @code{rdstate()} returns the bitwise +OR of @code{_eof}, @code{_fail} and @code{_bad}, not necessarily +distinct values. The functions @code{eof()}, @code{fail()}, +@code{bad()}, and @code{good()} can be used to test for each of +these conditions independently. + +@code{_fail} becomes set for any input operation that could not +read in the desired data, and for other failed operations. As +with all Unix IO, @code{_eof} becomes true only when an input +operations fails because of an end of file. Therefore, +@code{_eof} is not immediately true after the last successful +read of a file, but only after one final read attempt. Thus, for +input operations, @code{_fail} and @code{_eof} almost always +become true at the same time. @code{bad} is set for unbound +files, and may also be set by applications in order to communicate +input corruption. Conversely, @code{_good} is defined as 0 and +is returned by @code{rdstate()} if all is well. + +The state may be modified via @code{clear(flag)}, which, +despite its name, sets the corresponding state_value flag. +@code{clear()} with no arguments resets the state to @code{_good}. +@code{failif(int cond)} sets the state to @code{_fail} only if +@code{cond} is true. + +Errors occuring during constructors and file opens also invoke the +function @code{error}. @code{error} in turn calls a resetable error +handling function pointed to by the non-member global variable +@code{File_error_handler} only if a system error has been generated. +Since @code{error} cannot tell if the current system error is actually +responsible for a failure, it may at times print out spurious messages. +Three error handlers are provided. The default, +@code{verbose_File_error_handler} calls the system function +@code{perror} to print the corresponding error message on standard +error, and then returns to the caller. @code{quiet_File_error_handler} +does nothing, and simply returns. @code{fatal_File_error_handler} +prints the error and then aborts execution. These three handlers, or any +other user-defined error handlers can be selected via the non-member +function @code{set_File_error_handler}. + +All read and write operations communicate either logical or +physical failure by setting the @code{_fail} flag. All further +operations are blocked if the state is in a @code{_fail} or@code{_bad} +condition. Programmers must explicitly use @code{clear()} to +reset the state in order to continue IO processing after +either a logical or physical failure. C programmers who are +unfamiliar with these conventions should note that, unlike +the stdio library, @code{File} functions indicate IO success, +status, or failure solely through the state, not via return values of +the functions. The @code{void*} operator or @code{rdstate()} +may be used to test success. In particular, according to c++ +conversion rules, the @code{void*} coercion is automatically +applied whenever the @code{File&} return value of any @code{File} +function is tested in an @code{if} or @code{while}. Thus, +for example, an easy way to copy all of stdin to stdout until +eof (at which point @code{get} fails) or some error is +@code{char c; while(cin.get(c) && cout.put(c));}. + +@ignore +@section The istream and ostream classes + +Some of these are supported by incorporating additional, +mainly virtual, functions into streambufs: + +@table @code + +@item streambuf::open([various args]) +attaches the streambuf to a file, if applicable + +@item streambuf::close() +detaches the streambuf from a file, if applicable. + +@item streambuf::sputs(const char* s) +outputs null-terminated string s in a generally faster way +than repeated @code{sputcs}. + +@item streambuf::sputsn(const char* s, int n) +outputs the first n characters of s in a generally faster way +than repeated @code{sputcs}. + +@end table +@end ignore + +The current version of istreams and ostreams differs significantly +from previous versions in order to obtain compatibility with +AT&T 1.2 streams. Most code using previous versions should still +work. However, the following features of @code{File} are not +incorporated in streams (they are still present in @code{File}): +@code{scan(const char* fmt...), remove(), read(), write(), +setbuf(), raw()}. Additionally, the feature of previous streams +that allowed free intermixing of stream and stdio input and output +is no longer guaranteed to always behave as desired. + +@node Obstack, AllocRing, Stream, Top +@chapter The Obstack class + + +The @code{Obstack} class is a simple rewrite of the C obstack macros and +functions provided in the GNU CC compiler source distribution. + +Obstacks provide a simple method of creating and maintaining a string +table, optimized for the very frequent task of building strings +character-by-character, and sometimes keeping them, and sometimes +not. They seem especially useful in any parsing application. One of the +test files demonstrates usage. + +A brief summary: +@table @code + +@item grow +places something on the obstack without committing to wrap +it up as a single entity yet. + +@item finish +wraps up a constructed object as a single entity, +and returns the pointer to its start address. + +@item copy +places things on the obstack, and @emph{does} wrap them up. +@code{copy} is always equivalent to first grow, then finish. + +@item free +deletes something, and anything else put on the obstack since its creation. +@end table + +The other functions are less commonly needed: +@table @code +@item blank +is like grow, except it just grows the space by size units +without placing anything into this space +@item alloc +is like @code{blank}, but it wraps up the object and returns its starting +address. +@item chunk_size, base, next_free, alignment_mask, size, room +returns the appropriate class variables. +@item grow_fast +places a character on the obstack without checking if there is enough room. +@item blank_fast +like @code{blank}, but without checking if there is enough room. +@item shrink(int n) +shrink the current chunk by n bytes. +@item contains(void* addr) +returns true if the Obstack holds the address addr. +@end table + +Here is a lightly edited version of the original C documentation: + +These functions 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 the GNU C++ @code{new} +operator. On occasion, they free chunks, via @code{delete}. + +Each independent stack is represented by a Obstack. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are a ``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, @code{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, @emph{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 version of grow is provided to add a single char at a time +to a growing object. + +Summary: + +@itemize @bullet +@item +We allocate large chunks. +@item +We carve out one object at a time from the current chunk. +@item +Once carved, an object never moves. +@item +We are free to append data of any size to the currently growing object. +@item +Exactly one object is growing in an obstack at any one time. +@item +You can run one obstack per control block. +@item +You may have as many control blocks as you dare. +@item +Because of the way we do it, you can `unwind' a obstack back to a +previous state. (You may remove objects much as you would with a stack.) +@end itemize + +The obstack data structure is used in many places in the GNU C++ compiler. + +Differences from the the GNU C version +@enumerate +@item +The obvious differences stemming from the use of classes and +inline functions instead of structs and macros. The C +@code{init} and @code{begin} macros are replaced by constructors. + +@item +Overloaded function names are used for grow (and others), +rather than the C @code{grow}, @code{grow0}, etc. + +@item +All dynamic allocation uses the the built-in @code{new} operator. +This restricts flexibility by a little, but maintains compatibility +with usual C++ conventions. + +@item +There are now two versions of finish: + +@enumerate +@item +finish() behaves like the C version. + +@item +finish(char terminator) adds @code{terminator}, and then calls +@code{finish()}. This enables the normal invocation of @code{finish(0)} to +wrap up a string being grown character-by-character. +@end enumerate + +@item +There are special versions of grow(const char* s) and +copy(const char* s) that add the null-terminated string @code{s} +after computing its length. + +@item +The shrink and contains functions are provided. + +@end enumerate + +@node AllocRing, String, Obstack, Top +@chapter The AllocRing class + +An AllocRing is a bounded ring (circular list), each of whose elements +contains a pointer to some space allocated via @code{new +char[some_size]}. The entries are used cyclicly. The size, n, of the +ring is fixed at construction. After that, every nth use of the ring +will reuse (or reallocate) the same space. AllocRings are needed in +order to temporarily hold chunks of space that are needed transiently, +but across constructor-destructor scopes. They mainly useful for storing +strings containing formatted characters to print across various +functions and coercions. These strings are needed across routines, so +may not be deleted in any one of them, but should be recovered at some +point. In other words, an AllocRing is an extremely simple minded +garbage collection mechanism. The GNU C++ library used to use one +AllocRing for such formatting purposes, but it is being phased out, +and is now only used by obsolete functions. +These days, AllocRings are probably not very useful. + +Support includes: + +@table @code + +@item AllocRing a(int n) +constructs an Alloc ring with n entries, all null. + +@item void* mem = a.alloc(sz) +moves the ring pointer to the next entry, and reuses the space +if their is enough, also allocates space via new char[sz]. + +@item int present = a.contains(void* ptr) +returns true if ptr is held in one of the ring entries. + +@item a.clear() +deletes all space pointed to in any entry. This is called +automatically upon destruction. + +@item a.free(void* ptr) +If ptr is one of the entries, calls delete of the pointer, +and resets to entry pointer to null. + +@end table + +@node String, Integer, AllocRing, Top +@chapter The String class + +The @code{String} class is designed to extend GNU C++ to support +string processing capabilities similar to those in languages like +Awk. The class provides facilities that ought to be convenient +and efficient enough to be useful replacements for @code{char*} +based processing via the C string library (i.e., @code{strcpy, +strcmp,} etc.) in many applications. Many details about String +representations are described in the Representation section. + +A separate @code{SubString} class supports substring extraction +and modification operations. This is implemented in a way that +user programs never directly construct or represent substrings, +which are only used indirectly via String operations. + +Another separate class, @code{Regex} is also used indirectly via String +operations in support of regular expression searching, matching, and the +like. The Regex class is based entirely on the GNU Emacs regex +functions. @xref{Regexps, Syntax of Regular Expressions, Syntax of +Regular Expressions, emacs.info, GNU Emacs Manual}, for a full +explanation of regular expression syntax. (For implementation details, +see the internal documentation in files @file{regex.h} and +@file{regex.c}.) + +@section Constructors + +Strings are initialized and assigned as in the following examples: + +@table @code + +@item String x; String y = 0; String z = ""; +Set x, y, and z to the nil string. Note that either 0 or "" may +always be used to refer to the nil string. + +@item String x = "Hello"; String y("Hello"); +Set x and y to a copy of the string "Hello". + +@item String x = 'A'; String y('A'); +Set x and y to the string value "A" + +@item String u = x; String v(x); +Set u and v to the same string as String x + +@item String u = x.at(1,4); String v(x.at(1,4)); +Set u and v to the length 4 substring of x starting at position 1 +(counting indexes from 0). + +@item String x("abc", 2); +Sets x to "ab", i.e., the first 2 characters of "abc". + +@item String x = dec(20); +Sets x to "20". As here, Strings may be initialized or assigned +the results of any @code{char*} function. + +@end table + +There are no directly accessible forms for declaring SubString +variables. + +The declaration @code{Regex r("[a-zA-Z_][a-zA-Z0-9_]*");} creates +a compiled regular expression suitable for use in String +operations described below. (In this case, one that matches any +C++ identifier). The first argument may also be a String. +Be careful in distinguishing the role of backslashes in quoted +GNU C++ char* constants versus those in Regexes. For example, a Regex +that matches either one or more tabs or all strings beginning +with "ba" and ending with any number of occurrences of "na" +could be declared as @code{Regex r = "\\(\t+\\)\\|\\(ba\\(na\\)*\\)"} +Note that only one backslash is needed to signify the tab, but +two are needed for the parenthesization and virgule, since the +GNU C++ lexical analyzer decodes and strips backslashes before +they are seen by Regex. + +There are three additional optional arguments to the Regex constructor +that are less commonly useful: + +@table @code +@item fast (default 0) +@code{fast} may be set to true (1) if the Regex should be +"fast-compiled". This causes an additional compilation step that +is generally worthwhile if the Regex will be used many times. + +@item bufsize (default max(40, length of the string)) +This is an estimate of the size of the internal compiled +expression. Set it to a larger value if you know that the +expression will require a lot of space. If you do not know, +do not worry: realloc is used if necessary. + +@item transtable (default none == 0) +The address of a byte translation table (a char[256]) that +translates each character before matching. + +@end table + +As a convenience, several Regexes are predefined and usable in +any program. Here are their declarations from @file{String.h}. + +@smallexample +extern Regex RXwhite; // = "[ \n\t]+" +extern Regex RXint; // = "-?[0-9]+" +extern Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| + // \\([0-9]+\\)\\| + // \\(\\.[0-9]+\\)\\) + // \\([eE][---+]?[0-9]+\\)?" +extern Regex RXalpha; // = "[A-Za-z]+" +extern Regex RXlowercase; // = "[a-z]+" +extern Regex RXuppercase; // = "[A-Z]+" +extern Regex RXalphanum; // = "[0-9A-Za-z]+" +extern Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" + +@end smallexample + +@section Examples + +Most @code{String} class capabilities are best shown via example. +The examples below use the following declarations. + +@example + String x = "Hello"; + String y = "world"; + String n = "123"; + String z; + char* s = ","; + String lft, mid, rgt; + Regex r = "e[a-z]*o"; + Regex r2("/[a-z]*/"); + char c; + int i, pos, len; + double f; + String words[10]; + words[0] = "a"; + words[1] = "b"; + words[2] = "c"; + +@end example + +@section Comparing, Searching and Matching + +The usual lexicographic relational operators (@code{==, !=, <, <=, >, >=}) +are defined. A functional form @code{compare(String, String)} is also +provided, as is @code{fcompare(String, String)}, which compares +Strings without regard for upper vs. lower case. + +All other matching and searching operations are based on some form of the +(non-public) @code{match} and @code{search} functions. @code{match} and +@code{search} differ in that @code{match} attempts to match only at the +given starting position, while @code{search} starts at the position, and +then proceeds left or right looking for a match. As seen in the following +examples, the second optional @code{startpos} argument to functions using +@code{match} and @code{search} specifies the starting position of the +search: If non-negative, it results in a left-to-right search starting at +position @code{startpos}, and if negative, a right-to-left search starting +at position @code{x.length() + startpos}. In all cases, the index returned +is that of the beginning of the match, or -1 if there is no match. + +Three String functions serve as front ends to @code{search} and @code{match}. +@code{index} performs a search, returning the index, @code{matches} performs +a match, returning nonzero (actually, the length of the match) on success, +and @code{contains} is a boolean function performing either a search or +match, depending on whether an index argument is provided: + +@table @code + +@item x.index("lo") +returns the zero-based index of the leftmost occurrence of +substring "lo" (3, in this case). The argument may be a +String, SubString, char, char*, or Regex. + +@item x.index("l", 2) +returns the index of the first of the leftmost occurrence of "l" +found starting the search at position x[2], or 2 in this case. + +@item x.index("l", -1) +returns the index of the rightmost occurrence of "l", or 3 here. + +@item x.index("l", -3) +returns the index of the rightmost occurrence of "l" found by +starting the search at the 3rd to the last position of x, +returning 2 in this case. + +@item pos = r.search("leo", 3, len, 0) +returns the index of r in the @code{char*} string of length 3, +starting at position 0, also placing the length of the match +in reference parameter len. + +@item x.contains("He") +returns nonzero if the String x contains the substring "He". The +argument may be a String, SubString, char, char*, or Regex. + +@item x.contains("el", 1) +returns nonzero if x contains the substring "el" at position 1. +As in this example, the second argument to @code{contains}, +if present, means to match the substring only at that position, +and not to search elsewhere in the string. + +@item x.contains(RXwhite); +returns nonzero if x contains any whitespace (space, tab, or +newline). Recall that @code{RXwhite} is a global whitespace Regex. + +@item x.matches("lo", 3) +returns nonzero if x starting at position 3 exactly matches "lo", with +no trailing characters (as it does in this example). + +@item x.matches(r) +returns nonzero if String x as a whole matches Regex r. + +@item int f = x.freq("l") +returns the number of distinct, nonoverlapping matches to the argument +(2 in this case). + +@end table + +@section Substring extraction + +Substrings may be extracted via the @code{at}, @code{before}, +@code{through}, @code{from}, and @code{after} functions. +These behave as either lvalues or rvalues. + +@table @code + +@item z = x.at(2, 3) +sets String z to be equal to the length 3 substring of String x +starting at zero-based position 2, setting z to "llo" in this +case. A nil String is returned if the arguments don't make sense. + +@item x.at(2, 2) = "r" +Sets what was in positions 2 to 3 of x to "r", setting x to +"Hero" in this case. As indicated here, SubString assignments may +be of different lengths. + +@item x.at("He") = "je"; +x("He") is the substring of x that matches the first occurrence of +it's argument. The substitution sets x to "jello". If "He" did +not occur, the substring would be nil, and the assignment would +have no effect. + +@item x.at("l", -1) = "i"; +replaces the rightmost occurrence of "l" with "i", setting x to +"Helio". + +@item z = x.at(r) +sets String z to the first match in x of Regex r, or "ello" in this +case. A nil String is returned if there is no match. + +@item z = x.before("o") +sets z to the part of x to the left of the first occurrence of +"o", or "Hell" in this case. The argument may also be a String, +SubString, or Regex. (If there is no match, z is set to "".) + +@item x.before("ll") = "Bri"; +sets the part of x to the left of "ll" to "Bri", setting x to +"Brillo". + +@item z = x.before(2) +sets z to the part of x to the left of x[2], or "He" in this +case. + +@item z = x.after("Hel") +sets z to the part of x to the right of "Hel", or "lo" in this +case. + +@item z = x.through("el") +sets z to the part of x up and including "el", or "Hel" in this case. + +@item z = x.from("el") +sets z to the part of x from "el" to the end, or "ello" in this case. + +@item x.after("Hel") = "p"; +sets x to "Help"; + +@item z = x.after(3) +sets z to the part of x to the right of x[3] or "o" in this case. + +@item z = " ab c"; z = z.after(RXwhite) +sets z to the part of its old string to the right of the first +group of whitespace, setting z to "ab c"; Use gsub(below) to +strip out multiple occurrences of whitespace or any pattern. + +@item x[0] = 'J'; +sets the first element of x to 'J'. x[i] returns a reference to +the ith element of x, or triggers an error if i is out of range. + +@item common_prefix(x, "Help") +returns the String containing the common prefix of the two Strings +or "Hel" in this case. + +@item common_suffix(x, "to") +returns the String containing the common suffix of the two Strings +or "o" in this case. + +@end table + +@section Concatenation + +@table @code + +@item z = x + s + ' ' + y.at("w") + y.after("w") + "."; +sets z to "Hello, world." + +@item x += y; +sets x to "Helloworld" + +@item cat(x, y, z) +A faster way to say z = x + y. + +@item cat(z, y, x, x) +Double concatenation; A faster way to say x = z + y + x. + +@item y.prepend(x); +A faster way to say y = x + y. + +@item z = replicate(x, 3); +sets z to "HelloHelloHello". + +@item z = join(words, 3, "/") +sets z to the concatenation of the first 3 Strings in String +array words, each separated by "/", setting z to "a/b/c" in this +case. The last argument may be "" or 0, indicating no separation. + +@end table + +@section Other manipulations + +@table @code + +@item z = "this string has five words"; i = split(z, words, 10, RXwhite); +sets up to 10 elements of String array words to the parts of z +separated by whitespace, and returns the number of parts actually +encountered (5 in this case). Here, words[0] = "this", words[1] = +"string", etc. The last argument may be any of the usual. +If there is no match, all of z ends up in words[0]. The words array +is @emph{not} dynamically created by split. + +@item int nmatches x.gsub("l","ll") +substitutes all original occurrences of "l" with "ll", setting x +to "Hellllo". The first argument may be any of the usual, +including Regex. If the second argument is "" or 0, all +occurrences are deleted. gsub returns the number of matches +that were replaced. + +@item z = x + y; z.del("loworl"); +deletes the leftmost occurrence of "loworl" in z, setting z to +"Held". + +@item z = reverse(x) +sets z to the reverse of x, or "olleH". + +@item z = upcase(x) +sets z to x, with all letters set to uppercase, setting z to "HELLO" + +@item z = downcase(x) +sets z to x, with all letters set to lowercase, setting z to "hello" + +@item z = capitalize(x) +sets z to x, with the first letter of each word set to uppercase, +and all others to lowercase, setting z to "Hello" + +@item x.reverse(), x.upcase(), x.downcase(), x.capitalize() +in-place, self-modifying versions of the above. + +@end table + +@section Reading, Writing and Conversion + +@table @code + +@item cout << x +writes out x. + +@item cout << x.at(2, 3) +writes out the substring "llo". + +@item cin >> x +reads a whitespace-bounded string into x. + +@item x.length() +returns the length of String x (5, in this case). + +@item s = (const char*)x +can be used to extract the @code{char*} char array. This +coercion is useful for sending a String as an argument to any +function expecting a @code{const char*} argument (like +@code{atoi}, and @code{File::open}). This operator must be +used with care, since the conversion returns a pointer +to @code{String} internals without copying the characters: +The resulting @code{(char*)} is only valid until +the next String operation, and you must not modify it. +(The conversion is defined to return a const +value so that GNU C++ will produce warning and/or error +messages if changes are attempted.) + +@end table + +@node Integer, Rational, String, Top +@chapter The Integer class. + +The @code{Integer} class provides multiple precision integer arithmetic +facilities. Some representation details are discussed in the +Representation section. + +@code{Integers} may be up to @code{b * ((1 << b) - 1)} bits long, where +@code{b} is the number of bits per short (typically 1048560 bits when +@code{b = 16}). The implementation assumes that a @code{long} is at least +twice as long as a @code{short}. This assumption hides beneath almost all +primitive operations, and would be very difficult to change. It also relies +on correct behavior of @emph{unsigned} arithmetic operations. + +Some of the arithmetic algorithms are very loosely based on those +provided in the MIT Scheme @file{bignum.c} release, which is +Copyright (c) 1987 Massachusetts Institute of Technology. Their use +here falls within the provisions described in the Scheme release. + +Integers may be constructed in the following ways: +@table @code + +@item Integer x; +Declares an uninitialized Integer. + +@item Integer x = 2; Integer y(2); +Set x and y to the Integer value 2; + +@item Integer u(x); Integer v = x; +Set u and v to the same value as x. + +@end table + +@deftypefn Method long Integer::as_long() const +Used to coerce an @code{Integer} back into longs via the @code{long} +coercion operator. If the Integer cannot fit into a long, this returns +MINLONG or MAXLONG (depending on the sign) where MINLONG is the most +negative, and MAXLONG is the most positive representable long. +@end deftypefn + +@deftypefn Method int Integer::fits_in_long() const +Returns true iff the @code{Integer} is @code{< MAXLONG} and @code{> MINLONG}. +@end deftypefn + +@deftypefn Method double Integer::as_double() const +Coerce the @code{Integer} to a @code{double}, with potential +loss of precision. +@code{+/-HUGE} is returned if the Integer cannot fit into a double. +@end deftypefn + +@deftypefn Method int Integer::fits_in_double() const +Returns true iff the @code{Integer} can fit into a double. +@end deftypefn + +All of the usual arithmetic operators are provided (@code{+, -, *, /, +%, +=, ++, -=, --, *=, /=, %=, ==, !=, <, <=, >, >=}). All operators +support special versions for mixed arguments of Integers and regular +C++ longs in order to avoid useless coercions, as well as to allow +automatic promotion of shorts and ints to longs, so that they may be +applied without additional Integer coercion operators. The only +operators that behave differently than the corresponding int or long +operators are @code{++} and @code{--}. Because C++ does not +distinguish prefix from postfix application, these are declared as +@code{void} operators, so that no confusion can result from applying +them as postfix. Thus, for Integers x and y, @code{ ++x; y = x; } is +correct, but @code{ y = ++x; } and @code{ y = x++; } are not. + +Bitwise operators (@code{~}, @code{&}, @code{|}, @code{^}, @code{<<}, +@code{>>}, @code{&=}, @code{|=}, @code{^=}, @code{<<=}, @code{>>=}) are +also provided. However, these operate on sign-magnitude, rather than +two's complement representations. The sign of the result is arbitrarily +taken as the sign of the first argument. For example, @code{Integer(-3) +& Integer(5)} returns @code{Integer(-1)}, not -3, as it would using +two's complement. Also, @code{~}, the complement operator, complements +only those bits needed for the representation. Bit operators are also +provided in the BitSet and BitString classes. One of these classes +should be used instead of Integers when the results of bit manipulations +are not interpreted numerically. + +The following utility functions are also provided. (All arguments +are Integers unless otherwise noted). + +@deftypefun void divide(const Integer& @var{x}, const Integer& @var{y}, Integer& @var{q}, Integer& @var{r}) +Sets @var{q} to the quotient and @var{r} to the remainder of @var{x} and @var{y}. +(@var{q} and @var{r} are returned by reference). +@end deftypefun + +@deftypefun Integer pow(const Integer& @var{x}, const Integer& @var{p}) +Returns @var{x} raised to the power @var{p}. +@end deftypefun + +@deftypefun Integer Ipow(long @var{x}, long @var{p}) +Returns @var{x} raised to the power @var{p}. +@end deftypefun + +@deftypefun Integer gcd(const Integer& @var{x}, const Integer& @var{p}) +Returns the greatest common divisor of @var{x} and @var{y}. +@end deftypefun + +@deftypefun Integer lcm(const Integer& @var{x}, const Integer& @var{p}) +Returns the least common multiple of @var{x} and @var{y}. +@end deftypefun + +@deftypefun Integer abs(const Integer& @var{x} +Returns the absolute value of @var{x}. +@end deftypefun + +@deftypefn Method void Integer::negate() +Negates @code{this} in place. +@end deftypefn + +@table @code + +@item Integer sqr(x) +returns x * x; + +@item Integer sqrt(x) +returns the floor of the square root of x. + +@item long lg(x); +returns the floor of the base 2 logarithm of abs(x) + +@item int sign(x) +returns -1 if x is negative, 0 if zero, else +1. +Using @code{if (sign(x) == 0)} is a generally faster method +of testing for zero than using relational operators. + +@item int even(x) +returns true if x is an even number + +@item int odd(x) +returns true if x is an odd number. + +@item void setbit(Integer& x, long b) +sets the b'th bit (counting right-to-left from zero) of x to 1. + +@item void clearbit(Integer& x, long b) +sets the b'th bit of x to 0. + +@item int testbit(Integer x, long b) +returns true if the b'th bit of x is 1. + +@item Integer atoI(char* asciinumber, int base = 10); +converts the base base char* string into its Integer form. + +@item void Integer::printon(ostream& s, int base = 10, int width = 0); +prints the ascii string value of @code{(*this)} as a base @code{base} +number, in field width at least @code{width}. + +@item ostream << x; +prints x in base ten format. + +@item istream >> x; +reads x as a base ten number. + +@item int compare(Integer x, Integer y) +returns a negative number if xy. + +@item int ucompare(Integer x, Integer y) +like compare, but performs unsigned comparison. + +@item add(x, y, z) +A faster way to say z = x + y. + +@item sub(x, y, z) +A faster way to say z = x - y. + +@item mul(x, y, z) +A faster way to say z = x * y. + +@item div(x, y, z) +A faster way to say z = x / y. + +@item mod(x, y, z) +A faster way to say z = x % y. + +@item and(x, y, z) +A faster way to say z = x & y. + +@item or(x, y, z) +A faster way to say z = x | y. + +@item xor(x, y, z) +A faster way to say z = x ^ y. + +@item lshift(x, y, z) +A faster way to say z = x << y. + +@item rshift(x, y, z) +A faster way to say z = x >> y. + +@item pow(x, y, z) +A faster way to say z = pow(x, y). + +@item complement(x, z) +A faster way to say z = ~x. + +@item negate(x, z) +A faster way to say z = -x. + +@end table + +@node Rational, Complex, Integer, Top +@chapter The Rational Class + +Class @code{Rational} provides multiple precision rational +number arithmetic. All rationals are maintained in simplest +form (i.e., with the numerator and denominator relatively +prime, and with the denominator strictly positive). +Rational arithmetic and relational operators are provided +(@code{+, -, *, /, +=, -=, *=, /=, ==, !=, <, <=, >, >=}). +Operations resulting in a rational number with zero denominator +trigger an exception. + +Rationals may be constructed and used in the following ways: + +@table @code + +@item Rational x; +Declares an uninitialized Rational. + +@item Rational x = 2; Rational y(2); +Set x and y to the Rational value 2/1; + +@item Rational x(2, 3); +Sets x to the Rational value 2/3; + +@item Rational x = 1.2; +Sets x to a Rational value close to 1.2. Any double precision value +may be used to construct a Rational. The Rational will possess +exactly as much precision as the double. Double values that do +not have precise floating point equivalents (like 1.2) produce +similarly imprecise rational values. + +@item Rational x(Integer(123), Integer(4567)); +Sets x to the Rational value 123/4567. + +@item Rational u(x); Rational v = x; +Set u and v to the same value as x. + +@item double(Rational x) +A Rational may be coerced to a double with potential +loss of precision. +/-HUGE is returned if it will not fit. + +@item Rational abs(x) +returns the absolute value of x. + +@item void x.negate() +negates x. + +@item void x.invert() +sets x to 1/x. + +@item int sign(x) +returns 0 if x is zero, 1 if positive, and -1 if negative. + +@item Rational sqr(x) +returns x * x. + +@item Rational pow(x, Integer y) +returns x to the y power. + +@item Integer x.numerator() +returns the numerator. + +@item Integer x.denominator() +returns the denominator. + +@item Integer floor(x) +returns the greatest Integer less than x. + +@item Integer ceil(x) +returns the least Integer greater than x. + +@item Integer trunc(x) +returns the Integer part of x. + +@item Integer round(x) +returns the nearest Integer to x. + +@item int compare(x, y) +returns a negative, zero, or positive number signifying whether x is +less than, equal to, or greater than y. + +@item ostream << x; +prints x in the form num/den, or just num if the denominator is one. + +@item istream >> x; +reads x in the form num/den, or just num in which case the +denominator is set to one. + +@item add(x, y, z) +A faster way to say z = x + y. + +@item sub(x, y, z) +A faster way to say z = x - y. + +@item mul(x, y, z) +A faster way to say z = x * y. + +@item div(x, y, z) +A faster way to say z = x / y. + +@item pow(x, y, z) +A faster way to say z = pow(x, y). + +@item negate(x, z) +A faster way to say z = -x. + +@end table + +@node Complex, Fix, Rational, Top +@chapter The Complex class. + +Class @code{Complex} is implemented in a way similar to that +described by Stroustrup. In keeping with libg++ conventions, +the class is named @code{Complex}, not @code{complex}. +Complex arithmetic and relational operators are provided +(@code{+, -, *, /, +=, -=, *=, /=, ==, !=}). +Attempted division by (0, 0) triggers an exception. + +Complex numbers may be constructed and used in the following ways: + +@table @code + +@item Complex x; +Declares an uninitialized Complex. + +@item Complex x = 2; Complex y(2.0); +Set x and y to the Complex value (2.0, 0.0); + +@item Complex x(2, 3); +Sets x to the Complex value (2, 3); + +@item Complex u(x); Complex v = x; +Set u and v to the same value as x. + +@item double real(Complex& x); +returns the real part of x. + +@item double imag(Complex& x); +returns the imaginary part of x. + +@item double abs(Complex& x); +returns the magnitude of x. + +@item double norm(Complex& x); +returns the square of the magnitude of x. + +@item double arg(Complex& x); +returns the argument (amplitude) of x. + +@item Complex polar(double r, double t = 0.0); +returns a Complex with abs of r and arg of t. + +@item Complex conj(Complex& x); +returns the complex conjugate of x. + +@item Complex cos(Complex& x); +returns the complex cosine of x. + +@item Complex sin(Complex& x); +returns the complex sine of x. + +@item Complex cosh(Complex& x); +returns the complex hyperbolic cosine of x. + +@item Complex sinh(Complex& x); +returns the complex hyperbolic sine of x. + +@item Complex exp(Complex& x); +returns the exponential of x. + +@item Complex log(Complex& x); +returns the natural log of x. + +@item Complex pow(Complex& x, long p); +returns x raised to the p power. + +@item Complex pow(Complex& x, Complex& p); +returns x raised to the p power. + +@item Complex sqrt(Complex& x); +returns the square root of x. + +@item ostream << x; +prints x in the form (re, im). + +@item istream >> x; +reads x in the form (re, im), or just (re) or re in which case the +imaginary part is set to zero. + +@end table + +@node Fix, Bit, Complex, Top +@chapter Fixed precision numbers + +Classes @code{Fix16}, @code{Fix24}, @code{Fix32}, and @code{Fix48} +support operations on 16, 24, 32, or 48 bit quantities that are +considered as real numbers in the range [-1, +1). Such numbers are +often encountered in digital signal processing applications. The classes +may be be used in isolation or together. Class @code{Fix32} +operations are entirely self-contained. Class @code{Fix16} operations +are self-contained except that the multiplication operation @code{Fix16 +* Fix16} returns a @code{Fix32}. @code{Fix24} and @code{Fix48} are +similarly related. + +The standard arithmetic and relational operations are supported +(@code{=}, @code{+}, @code{-}, @code{*}, @code{/}, @code{<<}, @code{>>}, +@code{+=}, @code{-=}, @code{*=}, @code{/=}, @code{<<=}, @code{>>=}, +@code{==}, @code{!=}, @code{<}, @code{<=}, @code{>}, @code{>=}). +All operations include provisions for special handling in cases where +the result exceeds +/- 1.0. There are two cases that may be handled +separately: ``overflow'' where the results of addition and subtraction +operations go out of range, and all other ``range errors'' in which +resulting values go off-scale (as with division operations, and +assignment or initialization with off-scale values). In signal +processing applications, it is often useful to handle these two cases +differently. Handlers take one argument, a reference to the integer +mantissa of the offending value, which may then be manipulated. In +cases of overflow, this value is the result of the (integer) arithmetic +computation on the mantissa; in others it is a fully saturated (i.e., +most positive or most negative) value. Handling may be reset to any of +several provided functions or any other user-defined function via +@code{set_overflow_handler} and @code{set_range_error_handler}. The +provided functions for @code{Fix16} are as follows (corresponding +functions are also supported for the others). + +@table @code + +@item Fix16_overflow_saturate +The default overflow handler. Results are ``saturated'': positive results +are set to the largest representable value (binary 0.111111...), and +negative values to -1.0. + +@item Fix16_ignore +Performs no action. For overflow, this will allow addition and +subtraction operations to ``wrap around'' in the same manner +as integer arithmetic, and for saturation, will leave values saturated. + +@item Fix16_overflow_warning_saturate +Prints a warning message on standard error, then saturates the results. + +@item Fix16_warning +The default range_error handler. Prints a warning message +on standard error; otherwise leaving the argument unmodified. + +@item Fix16_abort +prints an error message on standard error, then aborts execution. + + +@end table + +In addition to arithmetic operations, the following are provided: + +@table @code + +@item Fix16 a = 0.5; +Constructs fixed precision objects from double precision values. +Attempting to initialize to a value outside the range invokes +the range_error handler, except, as a convenience, +initialization to 1.0 sets the variable to the most positive +representable value (binary 0.1111111...) without invoking the handler. + +@item short& mantissa(a); long& mantissa(b); +return a * pow(2, 15) or b * pow(2, 31) as an integer. These +are returned by reference, to enable ``manual'' data manipulation. + +@item double value(a); double value(b); +return a or b as floating point numbers. + +@end table + +@node Bit, Random, Fix, Top +@chapter Classes for Bit manipulation + +libg++ provides several different classes supporting the use +and manipulation of collections of bits in different ways. + +@itemize @bullet + +@item +Class @code{Integer} provides ``integer'' semantics. It supports +manipulation of bits in ways that are often useful when treating bit arrays +as numerical (integer) quantities. This class is described elsewhere. + +@item +Class @code{BitSet} provides ``set'' semantics. It supports operations +useful when treating collections of bits as representing potentially +infinite sets of integers. + +@item +Class @code{BitSet32} supports fixed-length BitSets holding exactly +32 bits. + +@item +Class @code{BitSet256} supports fixed-length BitSets holding exactly +256 bits. + +@item +Class @code{BitString} provides ``string'' (or ``vector'') semantics. +It supports operations useful when treating collections of bits as +strings of zeros and ones. + +@end itemize + +These classes also differ in the following ways: + +@itemize @bullet + + +@item +BitSets are logically infinite. Their space is dynamically altered to +adjust to the smallest number of consecutive bits actually required to +represent the sets. Integers also have this property. BitStrings are +logically finite, but their sizes are internally dynamically managed to +maintain proper length. This means that, for example, BitStrings are +concatenatable while BitSets and Integers are not. + +@item +BitSet32 and BitSet256 have precisely the same properties as BitSets, +except that they use constant fixed length bit vectors. + +@item +While all classes support basic unary and binary operations @code{~, &, +|, ^, -}, the semantics differ. BitSets perform bit operations that +precisely mirror those for infinite sets. For example, complementing an +empty BitSet returns one representing an infinite number of set bits. +Operations on BitStrings and Integers operate only on those bits +actually present in the representation. For BitStrings and Integers, +the the @code{&} operation returns a BitString with a length equal to +the minimum length of the operands, and @code{|, ^} return one with +length of the maximum. + +@item +Only BitStrings support substring extraction and bit pattern matching. + +@end itemize + +@section BitSet + +BitSets are objects that contain logically infinite sets of nonnegative +integers. Representational details are discussed in the Representation +chapter. Because they are logically infinite, all BitSets possess a +trailing, infinitely replicated 0 or 1 bit, called the ``virtual bit'', and +indicated via 0* or 1*. + +BitSet32 and BitSet256 have they same properties, except they are +of fixed length, and thus have no virtual bit. + +BitSets may be constructed as follows: + +@table @code + +@item BitSet a; +declares an empty BitSet. + +@item BitSet a = atoBitSet("001000"); +sets a to the BitSet 0010*, reading left-to-right. The ``0*'' +indicates that the set ends with an infinite number of zero +(clear) bits. + +@item BitSet a = atoBitSet("00101*"); +sets a to the BitSet 00101*, where ``1*'' means that the set ends +with an infinite number of one (set) bits. + +@item BitSet a = longtoBitSet((long)23); +sets a to the BitSet 111010*, the binary representation of decimal 23. + +@item BitSet a = utoBitSet((unsigned)23); +sets a to the BitSet 111010*, the binary representation of decimal 23. + +@end table + +The following functions and operators are provided (Assume the +declaration of BitSets a = 0011010*, b = 101101*, throughout, as +examples). + +@table @code + +@item ~a +returns the complement of a, or 1100101* in this case. + +@item a.complement() +sets a to ~a. + +@item a & b; a &= b; +returns a intersected with b, or 0011010*. + +@item a | b; a |= b; +returns a unioned with b, or 1011111*. + +@item a - b; a -= b; +returns the set difference of a and b, or 000010*. + +@item a ^ b; a ^= b; +returns the symmetric difference of a and b, or 1000101*. + +@item a.empty() +returns true if a is an empty set. + +@item a == b; +returns true if a and b contain the same set. + +@item a <= b; +returns true if a is a subset of b. + +@item a < b; +returns true if a is a proper subset of b; + +@item a != b; a >= b; a > b; +are the converses of the above. + +@item a.set(7) +sets the 7th (counting from 0) bit of a, setting a to 001111010* + +@item a.clear(2) +clears the 2nd bit bit of a, setting a to 00011110* + +@item a.clear() +clears all bits of a; + +@item a.set() +sets all bits of a; + +@item a.invert(0) +complements the 0th bit of a, setting a to 10011110* + +@item a.set(0,1) +sets the 0th through 1st bits of a, setting a to 110111110* +The two-argument versions of clear and invert are similar. + +@item a.test(3) +returns true if the 3rd bit of a is set. + +@item a.test(3, 5) +returns true if any of bits 3 through 5 are set. + +@item int i = a[3]; a[3] = 0; +The subscript operator allows bits to be inspected and changed +via standard subscript semantics, using a friend class BitSetBit. +The use of the subscript operator a[i] rather than a.test(i) +requires somewhat greater overhead. + +@item a.first(1) or a.first() +returns the index of the first set bit of a (2 in this case), +or -1 if no bits are set. + +@item a.first(0) +returns the index of the first clear bit of a (0 in this case), +or -1 if no bits are clear. + +@item a.next(2, 1) or a.next(2) +returns the index of the next bit after position 2 that is set (3 +in this case) or -1. @code{first} and @code{next} may be used as +iterators, as in +@code{for (int i = a.first(); i >= 0; i = a.next(i))...}. + +@item a.last(1) +returns the index of the rightmost set bit, or -1 if there or no set +bits or all set bits. + +@item a.prev(3, 0) +returns the index of the previous clear bit before position 3. + +@item a.count(1) +returns the number of set bits in a, or -1 if there are +an infinite number. + +@item a.virtual_bit() +returns the trailing (infinitely replicated) bit of a. + +@item a = atoBitSet("ababX", 'a', 'b', 'X'); +converts the char* string into a bitset, with 'a' denoting false, +'b' denoting true, and 'X' denoting infinite replication. + +@item a.printon(cout, '-', '.', 0) +prints @code{a} to @code{cout} represented with +@code{'-'} for falses, @code{'.'} for trues, and no replication marker. + +@item cout << a +prints @code{a} to @code{cout} (representing lases by @code{'f'}, +trues by @code{'t'}, and using @code{'*'} as the replication marker). + +@item diff(x, y, z) +A faster way to say z = x - y. + +@item and(x, y, z) +A faster way to say z = x & y. + +@item or(x, y, z) +A faster way to say z = x | y. + +@item xor(x, y, z) +A faster way to say z = x ^ y. + +@item complement(x, z) +A faster way to say z = ~x. + +@end table + +@section BitString + +BitStrings are objects that contain arbitrary-length strings of +zeroes and ones. BitStrings possess some features that make them +behave like sets, and others that behave as strings. They are +useful in applications (such as signature-based algorithms) where +both capabilities are needed. Representational details are +discussed in the Representation chapter. Most capabilities are +exact analogs of those supported in the BitSet and String +classes. A BitSubString is used with substring operations along +the same lines as the String SubString class. A BitPattern class +is used for masked bit pattern searching. + +Only a default constructor is supported. The declaration +@code{BitString a;} initializes a to be an empty BitString. +BitStrings may often be initialized via @code{atoBitString} +and @code{longtoBitString}. + +Set operations (@code{ ~, complement, &, &=, |, |=, -, ^, ^=}) +behave just as the BitSet versions, except that there is no +``virtual bit'': complementing complements only those bits in the +BitString, and all binary operations across unequal length +BitStrings assume a virtual bit of zero. The @code{&} operation +returns a BitString with a length equal to the minimum length of +the operands, and @code{|, ^} return one with length of the +maximum. + +Set-based relational operations (@code{==, !=, <=, <, >=, >}) +follow the same rules. A string-like lexicographic comparison +function, @code{lcompare}, tests the lexicographic relation between +two BitStrings. For example, lcompare(1100, 0101) returns 1, +since the first BitString starts with 1 and the second with 0. + +Individual bit setting, testing, and iterator operations +(@code{set, clear, invert, test, first, next, last, prev}) +are also like those for BitSets. BitStrings are automatically +expanded when setting bits at positions greater than their +current length. + +The string-based capabilities are just as those for class String. +BitStrings may be concatenated (@code{+, +=}), searched +(@code{index, contains, matches}), and extracted into +BitSubStrings (@code{before, at, after}) which may be assigned and +otherwise manipulated. Other string-based utility functions +(@code{reverse, common_prefix, common_suffix}) are also provided. +These have the same capabilities and descriptions as those +for Strings. + +String-oriented operations can also be performed with a mask via +class BitPattern. BitPatterns consist of two BitStrings, a +pattern and a mask. On searching and matching, bits in the pattern +that correspond to 0 bits in the mask are ignored. (The mask may +be shorter than the pattern, in which case trailing mask bits are +assumed to be 0). The pattern and mask are both public variables, +and may be individually subjected to other bit operations. + +Converting to char* and printing (@code{(atoBitString, +atoBitPattern, printon, ostream <<)}) are also as in BitSets, +except that no virtual bit is used, and an 'X' in a BitPattern means +that the pattern bit is masked out. + +The following features are unique to BitStrings. + +Assume declarations of BitString a = atoBitString("01010110") and b = +atoBitSTring("1101"). + +@table @code + +@item a = b + c; +Sets a to the concatenation of b and c; + +@item a = b + 0; a = b + 1; +sets a to b, appended with a zero (one). + +@item a += b; +appends b to a; + +@item a += 0; a += 1; +appends a zero (one) to a. + +@item a << 2; a <<= 2 +return a with 2 zeros prepended, setting a to 0001010110. (Note +the necessary confusion of << and >> operators. For consistency +with the integer versions, << shifts low bits to high, even though +they are printed low bits first.) + +@item a >> 3; a >>= 3 +return a with the first 3 bits deleted, setting a to 10110. + +@item a.left_trim(0) +deletes all 0 bits on the left of a, setting a to 1010110. + +@item a.right_trim(0) +deletes all trailing 0 bits of a, setting a to 0101011. + +@item cat(x, y, z) +A faster way to say z = x + y. + +@item diff(x, y, z) +A faster way to say z = x - y. + +@item and(x, y, z) +A faster way to say z = x & y. + +@item or(x, y, z) +A faster way to say z = x | y. + +@item xor(x, y, z) +A faster way to say z = x ^ y. + +@item lshift(x, y, z) +A faster way to say z = x << y. + +@item rshift(x, y, z) +A faster way to say z = x >> y. + +@item complement(x, z) +A faster way to say z = ~x. + +@end table + + +@node Random, Data, Bit, Top +@chapter Random Number Generators and related classes + +The two classes @code{RNG} and @code{Random} are used together to +generate a variety of random number distributions. A distinction must +be made between @emph{random number generators}, implemented by class +@code{RNG}, and @emph{random number distributions}. A random number +generator produces a series of randomly ordered bits. These bits can be +used directly, or cast to other representations, such as a floating +point value. A random number generator should produce a @emph{uniform} +distribution. A random number distribution, on the other hand, uses the +randomly generated bits of a generator to produce numbers from a +distribution with specific properties. Each instance of @code{Random} +uses an instance of class @code{RNG} to provide the raw, uniform +distribution used to produce the specific distribution. Several +instances of @code{Random} classes can share the same instance of +@code{RNG}, or each instance can use its own copy. + +@section RNG + +Random distributions are constructed from members of class @code{RNG}, +the actual random number generators. The @code{RNG} class contains no +data; it only serves to define the interface to random number +generators. The @code{RNG::asLong} member returns an unsigned long +(typically 32 bits) of random bits. Applications that require a number +of random bits can use this directly. More often, these random bits are +transformed to a uniform random number: + +@smallexample + // + // Return random bits converted to either a float or a double + // + float asFloat(); + double asDouble(); +@}; +@end smallexample + +@noindent +using either @code{asFloat} or @code{asDouble}. It is intended that +@code{asFloat} and @code{asDouble} return differing precisions; +typically, @code{asDouble} will draw two random longwords and transform +them into a legal @code{double}, while @code{asFloat} will draw a single +longword and transform it into a legal @code{float}. These members are +used by subclasses of the @code{Random} class to implement a variety of +random number distributions. + +@section ACG + +Class @code{ACG} is a variant of a Linear Congruential Generator +(Algorithm M) described in Knuth, @emph{Art of Computer Programming, Vol +III}. This result is permuted with a Fibonacci Additive Congruential +Generator to get good independence between samples. This is a very high +quality random number generator, although it requires a fair amount of +memory for each instance of the generator. + +The @code{ACG::ACG} constructor takes two parameters: the seed and the +size. The seed is any number to be used as an initial seed. The +performance of the generator depends on having a distribution of bits +through the seed. If you choose a number in the range of 0 to 31, a +seed with more bits is chosen. Other values are deterministically +modified to give a better distribution of bits. This provides a good +random number generator while still allowing a sequence to be repeated +given the same initial seed. + +The @code{size} parameter determines the size of two tables used in the +generator. The first table is used in the Additive Generator; see the +algorithm in Knuth for more information. In general, this table is +@code{size} longwords long. The default value, used in the algorithm in +Knuth, gives a table of 220 bytes. The table size affects the period of +the generators; smaller values give shorter periods and larger tables +give longer periods. The smallest table size is 7 longwords, and the +longest is 98 longwords. The @code{size} parameter also determines the +size of the table used for the Linear Congruential Generator. This value +is chosen implicitly based on the size of the Additive Congruential +Generator table. It is two powers of two larger than the power of two +that is larger than @code{size}. For example, if @code{size} is 7, the +ACG table is 7 longwords and the LCG table is 128 longwords. Thus, the +default size (55) requires 55 + 256 longwords, or 1244 bytes. The +largest table requires 2440 bytes and the smallest table requires 100 +bytes. Applications that require a large number of generators or +applications that aren't so fussy about the quality of the generator may +elect to use the @code{MLCG} generator. + +@section MLCG + +The @code{MLCG} class implements a @emph{Multiplicative Linear +Congruential Generator}. In particular, it is an implementation of the +double MLCG described in @emph{``Efficient and Portable Combined Random +Number Generators''} by Pierre L'Ecuyer, appearing in +@emph{Communications of the ACM, Vol. 31. No. 6}. This generator has a +fairly long period, and has been statistically analyzed to show that it +gives good inter-sample independence. + +The @code{MLCG::MLCG} constructor has two parameters, both of which are +seeds for the generator. As in the @code{MLCG} generator, both seeds are +modified to give a ``better'' distribution of seed digits. Thus, you can +safely use values such as `0' or `1' for the seeds. The @code{MLCG} +generator used much less state than the @code{ACG} generator; only two +longwords (8 bytes) are needed for each generator. + +@section Random + +A random number generator may be declared by first declaring a +@code{RNG} and then a @code{Random}. For example, @code{ACG gen(10, 20); +NegativeExpntl rnd (1.0, &gen);} declares an additive congruential +generator with seed 10 and table size 20, that is used to generate +exponentially distributed values with mean of 1.0. + +The virtual member @code{Random::operator()} is the common way of +extracting a random number from a particular distribution. The base +class, @code{Random} does not implement @code{operator()}. This is +performed by each of the subclasses. Thus, given the above declaration +of @code{rnd}, new random values may be obtained via, for example, +@code{double next_exp_rand = rnd();} Currently, the following subclasses +are provided. + +@section Binomial + +The binomial distribution models successfully drawing items from +a pool. The first parameter to the constructor, @code{n}, is the +number of items in the pool, and the second parameter, @code{u}, +is the probability of each item being successfully drawn. The +member @code{asDouble} returns the number of samples drawn from +the pool. Although it is not checked, it is assumed that +@code{n>0} and @code{0 <= u <= 1}. The remaining members allow +you to read and set the parameters. + +@section Erlang + +The @code{Erlang} class implements an Erlang distribution with +mean @code{mean} and variance @code{variance}. + +@section Geometric + +The @code{Geometric} class implements a discrete geometric +distribution. The first parameter to the constructor, +@code{mean}, is the mean of the distribution. Although it is not +checked, it is assumed that @code{0 <= mean <= 1}. +@code{Geometric()} returns the number of uniform random samples +that were drawn before the sample was larger than @code{mean}. +This quantity is always greater than zero. + +@section HyperGeometric + +The @code{HyperGeometric} class implements the hypergeometric +distribution. The first parameter to the constructor, +@code{mean}, is the mean and the second, @code{variance}, is the +variance. The remaining members allow you to inspect and change +the mean and variance. + +@section NegativeExpntl + +The @code{NegativeExpntl} class implements the negative +exponential distribution. The first parameter to the constructor +is the mean. The remaining members allow you to inspect and +change the mean. + +@section Normal + +The @code{Normal}class implements the normal distribution. The +first parameter to the constructor, @code{mean}, is the mean and +the second, @code{variance}, is the variance. The remaining +members allow you to inspect and change the mean and variance. +The @code{LogNormal} class is a subclass of @code{Normal}. + +@section LogNormal + +The @code{LogNormal}class implements the logarithmic normal +distribution. The first parameter to the constructor, +@code{mean}, is the mean and the second, @code{variance}, is the +variance. The remaining members allow you to inspect and change +the mean and variance. The @code{LogNormal} class is a subclass +of @code{Normal}. + +@section Poisson + +The @code{Poisson} class implements the poisson distribution. +The first parameter to the constructor is the mean. The +remaining members allow you to inspect and change the mean. + +@section DiscreteUniform + +The @code{DiscreteUniform} class implements a uniform random variable over +the closed interval ranging from @code{[low..high]}. The first parameter +to the constructor is @code{low}, and the second is @code{high}, although +the order of these may be reversed. The remaining members allow you to +inspect and change @code{low} and @code{high}. + +@section Uniform + +The @code{Uniform} class implements a uniform random variable over the +open interval ranging from @code{[low..high)}. The first parameter to +the constructor is @code{low}, and the second is @code{high}, although +the order of these may be reversed. The remaining members allow you to +inspect and change @code{low} and @code{high}.@refill + +@section Weibull + +The @code{Weibull} class implements a weibull distribution with +parameters @code{alpha} and @code{beta}. The first parameter to +the class constructor is @code{alpha}, and the second parameter +is @code{beta}. The remaining members allow you to inspect and +change @code{alpha} and @code{beta}. + +@section RandomInteger + +The @code{RandomInteger} class is @emph{not} a subclass of Random, +but a stand-alone integer-oriented class that is dependent on the +RNG classes. RandomInteger returns random integers uniformly from +the closed interval @code{[low..high]}. The first parameter to the +constructor is @code{low}, and the second is @code{high}, although +both are optional. The last argument is always a generator. +Additional members allow you to inspect and change @code{low} and +@code{high}. Random integers are generated using @code{asInt()} or +@code{asLong()}. Operator syntax (@code{()}) is also available as a +shorthand for @code{asLong()}. Because @code{RandomInteger} is often +used in simulations for which uniform random integers are desired over +a variety of ranges, @code{asLong()} and @code{asInt} have @code{high} +as an optional argument. Using this optional argument produces a +single value from the new range, but does not change the default +range. + + +@node Data, Curses, Random, Top +@chapter Data Collection +Libg++ currently provides two classes for @emph{data collection} +and analysis of the collected data. + +@section SampleStatistic + +Class @code{SampleStatistic} provides a means of accumulating +samples of @code{double} values and providing common sample statistics. + +Assume declaration of @code{double x}. + +@table @code + +@item SampleStatistic a; +declares and initializes a. + +@item a.reset(); +re-initializes a. + +@item a += x; +adds sample x. + +@item int n = a.samples(); +returns the number of samples. + +@item x = a.mean; +returns the means of the samples. + +@item x = a.var() +returns the sample variance of the samples. + +@item x = a.stdDev() +returns the sample standard deviation of the samples. + +@item x = a.min() +returns the minimum encountered sample. + +@item x = a.max() +returns the maximum encountered sample. + +@item x = a.confidence(int p) +returns the p-percent (0 <= p < 100) confidence interval. + +@item x = a.confidence(double p) +returns the p-probability (0 <= p < 1) confidence interval. + + +@end table + +@section SampleHistogram + +Class @code{SampleHistogram} is a derived class of +@code{SampleStatistic} that supports collection and display of samples +in bucketed intervals. It supports the following in addition to +@code{SampleStatisic} operations. + +@table @code + +@item SampleHistogram h(double lo, double hi, double width); +declares and initializes h to have buckets of size width from lo to hi. +If the optional argument width is not specified, 10 buckets are +created. The first bucket and also holds samples less than lo, +and the last one holds samples greater than hi. + +@item int n = h.similarSamples(x) +returns the number of samples in the same bucket as x. + +@item int n = h.inBucket(int i) +returns the number of samples in bucket i. + +@item int b = h.buckets() +returns the number of buckets. + +@item h.printBuckets(ostream s) +prints bucket counts on ostream s. + +@item double bound = h.bucketThreshold(int i) +returns the upper bound of bucket i. + + +@end table + +@node Curses, List, Data, Top +@chapter Curses-based classes + +The @code{CursesWindow} class is a repackaging of standard +curses library features into a class. It relies on @file{curses.h}. + +The supplied @file{curses.h} is a fairly conservative declaration +of curses library features, and does not include features like +``screen'' or X-window support. It is, for the most part, an +adaptation, rather than an improvement of C-based @file{curses.h} +files. The only substantive changes are the declarations of +many functions as inline functions rather than macros, which +was done solely to allow overloading. + +The @code{CursesWindow} class encapsulates curses window functions +within a class. Only those functions that control windows are included: +Terminal control functions and macros like @code{cbreak} are not part +of the class. All @code{CursesWindows} member functions have names +identical to the corresponding curses library functions, except that the +``w'' prefix is generally dropped. Descriptions of these functions may +be found in your local curses library documentation. + +A @code{CursesWindow} may be declared via + +@table @code + +@item CursesWindow w(WINDOW* win) +attaches w to the existing WINDOW* win. This is constructor is normally +used only in the following special case. + +@item CursesWindow w(stdscr) +attaches w to the default curses library standard screen window. + +@item CursesWindow w(int lines, int cols, int begin_y, int begin_x) +attaches to an allocated curses window with the indicated size and +screen position. + +@item CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a') +attaches to a subwindow of w created via the curses `subwin' command. +If ar is sent as `r', the origin (by, bx) is relative to the parent +window, else it is absolute. + +@end table + +The class maintains a static counter that is used in order to +automatically call the curses library @code{initscr} and @code{endscr} +functions at the proper times. These need not, and should not be +called ``manually''. + +@code{CursesWindow}s maintain a tree of their subwindows. Upon +destruction of a @code{CursesWindow}, all of their subwindows are +also invalidated if they had not previously been destroyed. + +It is possible to traverse trees of subwindows via the following +member functions + +@table @code + +@item CursesWindow* w.parent() +returns a pointer to the parent of the subwindow, or 0 if there is none. + +@item CursesWindow* w.child() +returns the first child subwindow of the window, or 0 if there is none. + +@item CursesWindow* w.sibling() +returns the next sibling of the subwindow, or 0 if there is none. + +@end table + +For example, to call some function @code{visit} for all subwindows +of a window, you could write + +@example + +void traverse(CursesWindow& w) +@{ + visit(w); + if (w.child() != 0) traverse(*w.child); + if (w.sibling() != 0) traverse(*w.sibling); +@} + +@end example + +@node List, LinkList, Curses, Top +@chapter List classes + +The files @file{g++-include/List.hP} and @file{g++-include/List.ccP} +provide pseudo-generic Lisp-type List classes. These lists are homogeneous +lists, more similar to lists in statically typed functional languages like +ML than Lisp, but support operations very similar to those found in Lisp. +Any particular kind of list class may be generated via the @code{genclass} +shell command. However, the implementation assumes that the base class +supports an equality operator @code{==}. All equality tests use the +@code{==} operator, and are thus equivalent to the use of @code{equal}, not +@code{eq} in Lisp.@refill + +All list nodes are created dynamically, and managed via reference counts. +@code{List} variables are actually pointers to these list nodes. +Lists may also be traversed via Pixes, as described in the section +describing Pixes. @xref{Pix} + +Supported operations are mirrored closely after those in Lisp. Generally, +operations with functional forms are constructive, functional operations, +while member forms (often with the same name) are sometimes +procedural, possibly destructive operations. + +As with Lisp, destructive operations are supported. Programmers +are allowed to change head and tail fields in any fashion, creating +circular structures and the like. However, again as with Lisp, some +operations implicitly assume that they are operating on pure lists, and +may enter infinite loops when presented with improper lists. Also, the +reference-counting storage management facility may fail to reclaim +unused circularly-linked nodes. + +Several Lisp-like higher order functions are supported (e.g., @code{map}). +Typedef declarations for the required functional forms are provided +int the @file{.h} file. + +For purposes of illustration, assume the specification of class +@code{intList}. Common Lisp versions of supported operations are shown +in brackets for comparison purposes. + +@section Constructors and assignment + +@table @code + +@item intList a; [ (setq a nil) ] +Declares a to be a nil intList. + +@item intList b(2); [ (setq b (cons 2 nil)) ] +Declares b to be an intList with a head value of 2, and a nil tail. + +@item intList c(3, b); [ (setq c (cons 3 b)) ] +Declares c to be an intList with a head value of 3, and b as its tail. + +@item b = a; [ (setq b a) ] +Sets b to be the same list as a. + +@end table + +Assume the declarations of intLists a, b, and c in the following. +@xref{Pix}. + +@section List status + +@table @code + +@item a.null(); OR !a; [ (null a) ] +returns true if a is null. + +@item a.valid(); [ (listp a) ] +returns true if a is non-null. Inside a conditional test, the +@code{void*} coercion may also be used as in @code{if (a) ...}. + +@item intList(); [ nil ] +intList() may be used to null terminate a list, as in +@code{intList f(int x) @{if (x == 0) return intList(); ... @} }. + +@item a.length(); [ (length a) ] +returns the length of a. + +@item a.list_length(); [ (list-length a) ] +returns the length of a, or -1 if a is circular. +@end table + +@section heads and tails + +@table @code + +@item a.get(); OR a.head() [ (car a) ] +returns a reference to the head field. + +@item a[2]; [ (elt a 2) ] +returns a reference to the second (counting from zero) head field. + +@item a.tail(); [ (cdr a) ] +returns the intList that is the tail of a. + +@item a.last(); [ (last a) ] +returns the intList that is the last node of a. + +@item a.nth(2); [ (nth a 2) ] +returns the intList that is the nth node of a. + +@item a.set_tail(b); [ (rplacd a b) ] +sets a's tail to b. + +@item a.push(2); [ (push 2 a) ] +equivalent to a = intList(2, a); + +@item int x = a.pop() [ (setq x (car a)) (pop a) ] +returns the head of a, also setting a to its tail. + +@end table + +@section Constructive operations + +@table @code + +@item b = copy(a); [ (setq b (copy-seq a)) ] +sets b to a copy of a. + +@item b = reverse(a); [ (setq b (reverse a)) ] +Sets b to a reversed copy of a. + +@item c = concat(a, b); [ (setq c (concat a b)) ] +Sets c to a concatenated copy of a and b. + +@item c = append(a, b); [ (setq c (append a b)) ] +Sets c to a concatenated copy of a and b. All nodes of a are +copied, with the last node pointing to b. + +@item b = map(f, a); [ (setq b (mapcar f a)) ] +Sets b to a new list created by applying function f to each node +of a. + +@item c = combine(f, a, b); +Sets c to a new list created by applying function f to successive +pairs of a and b. The resulting list has length the shorter of a +and b. + +@item b = remove(x, a); [ (setq b (remove x a)) ] +Sets b to a copy of a, omitting all occurrences of x. + +@item b = remove(f, a); [ (setq b (remove-if f a)) ] +Sets b to a copy of a, omitting values causing function f to +return true. + +@item b = select(f, a); [ (setq b (remove-if-not f a)) ] +Sets b to a copy of a, omitting values causing function f to +return false. + +@item c = merge(a, b, f); [ (setq c (merge a b f)) ] +Sets c to a list containing the ordered elements (using the +comparison function f) of the sorted lists a and b. + +@end table + +@section Destructive operations + +@table @code + +@item a.append(b); [ (rplacd (last a) b) ] +appends b to the end of a. No new nodes are constructed. + +@item a.prepend(b); [ (setq a (append b a)) ] +prepends b to the beginning of a. + +@item a.del(x); [ (delete x a) ] +deletes all nodes with value x from a. + +@item a.del(f); [ (delete-if f a) ] +deletes all nodes causing function f to return true. + +@item a.select(f); [ (delete-if-not f a) ] +deletes all nodes causing function f to return false. + +@item a.reverse(); [ (nreverse a) ] +reverses a in-place. + +@item a.sort(f); [ (sort a f) ] +sorts a in-place using ordering (comparison) function f. + +@item a.apply(f); [ (mapc f a) ] +Applies void function f (int x) to each element of a. + +@item a.subst(int old, int repl); [ (nsubst repl old a) ] +substitutes repl for each occurrence of old in a. Note the +different argument order than the Lisp version. + +@end table + +@section Other operations + +@table @code + +@item a.find(int x); [ (find x a) ] +returns the intList at the first occurrence of x. + +@item a.find(b); [ (find b a) ] +returns the intList at the first occurrence of sublist b. + +@item a.contains(int x); [ (member x a) ] +returns true if a contains x. + +@item a.contains(b); [ (member b a) ] +returns true if a contains sublist b. + +@item a.position(int x); [ (position x a) ] +returns the zero-based index of x in a, or -1 if x does not occur. + +@item int x = a.reduce(f, int base); [ (reduce f a :initial-value base) ] +Accumulates the result of applying int function f(int, int) to +successive elements of a, starting with base. + +@end table + + +@node LinkList, Vector, List, Top +@chapter Linked Lists + +SLLists provide pseudo-generic singly linked lists. DLLists provide +doubly linked lists. The lists are designed for the simple maintenance +of elements in a linked structure, and do not provide the more extensive +operations (or node-sharing) of class @code{List}. They behave similarly +to the @code{slist} and similar classes described by Stroustrup.@refill + +All list nodes are created dynamically. Assignment is performed via +copying. + +Class @code{DLList} supports all @code{SLList} operations, plus +additional operations described below. + +For purposes of illustration, assume the specification of class +@code{intSLList}. In addition to the operations listed here, +SLLists support traversal via Pixes. @xref{Pix} + +@table @code + +@item intSLList a; +Declares a to be an empty list. + +@item intSLList b = a; +Sets b to an element-by-element copy of a. + +@item a.empty() +returns true if a contains no elements + +@item a.length(); +returns the number of elements in a. + +@item a.prepend(x); +places x at the front of the list. + +@item a.append(x); +places x at the end of the list. + +@item a.join(b) +places all nodes from b to the end of a, simultaneously destroying b. + +@item x = a.front() +returns a reference to the item stored at the head of the list, +or triggers an error if the list is empty. + +@item a.rear() +returns a reference to the rear of the list, or triggers an error if the +list is empty. + +@item x = a.remove_front() +deletes and returns the item stored at the head of the list. + +@item a.del_front() +deletes the first element, without returning it. + +@item a.clear() +deletes all items from the list. + +@item a.ins_after(Pix i, item); +inserts item after position i. If i is null, insertion is at the front. + +@item a.del_after(Pix i); +deletes the element following i. If i is 0, the first item is deleted. + +@end table + +@section Doubly linked lists + +Class @code{DLList} supports the following additional operations, +as well as backward traversal via Pixes. + +@table @code + +@item x = a.remove_rear(); +deletes and returns the item stored at the rear of the list. + +@item a.del_rear(); +deletes the last element, without returning it. + +@item a.ins_before(Pix i, x) +inserts x before the i. + +@item a.del(Pix& iint dir = 1) +deletes the item at the current position, then advances forward +if dir is positive, else backward. + +@end table + +@node Vector, Plex, LinkList, Top +@chapter Vector classes + +The files @file{g++-include/Vec.ccP} and @file{g++-include/AVec.ccP} +provide pseudo-generic standard array-based vector operations. The +corresponding header files are @file{g++-include/Vec.hP} and +@file{g++-include/AVec.hP}. Class @code{Vec} provides operations +suitable for any base class that includes an equality operator. Subclass +@code{AVec} provides additional arithmetic operations suitable for base +classes that include the full complement of arithmetic operators. + +@code{Vecs} are constructed and assigned by copying. Thus, they should +normally be passed by reference in applications programs. + +Several mapping functions are provided that allow programmers to +specify operations on vectors as a whole. + +For illustrative purposes assume that classes @code{intVec} and +@code{intAVec} have been generated via @code{genclass}. + +@section Constructors and assignment + +@table @code +@item intVec a; +declares a to be an empty vector. Its size may be changed via resize. + +@item intVec a(10); +declares a to be an uninitialized vector of ten elements (numbered 0-9). + +@item intVec b(6, 0); +declares b to be a vector of six elements, all initialized to zero. Any +value can be used as the initial fill argument. + +@item a = b; +Copies b to a. a is resized to be the same as b. + +@item a = b.at(2, 4) +constructs a from the 4 elements of b starting at b[2]. +@end table + +Assume declarations of @code{intVec a, b, c} and @code{int i, x} in +the following. + +@section Status and access + +@table @code +@item a.capacity(); +returns the number of elements that can be held in a. + +@item a.resize(20); +sets a's length to 20. All elements are unchanged, except that if +the new size is smaller than the original, than trailing elements +are deleted, and if greater, trailing elements are uninitialized. + +@item a[i]; +returns a reference to the i'th element of a, or produces an error +if i is out of range. + +@item a.elem(i) +returns a reference to the i'th element of a. Unlike the @code{[]} operator, +i is not checked to ensure that it is within range. + +@item a == b; +returns true if a and b contain the same elements in the same order. + +@item a != b; +is the converse of a == b. +@end table + +@section Constructive operations + +@table @code +@item c = concat(a, b); +sets c to the new vector constructed from all of the elements of +a followed by all of b. + +@item c = map(f, a); +sets c to the new vector constructed by applying int function f(int) +to each element of a. + +@item c = merge(a, b, f); +sets c to the new vector constructed by merging the elements of +ordered vectors a and b using ordering (comparison) function f. + +@item c = combine(f, a, b); +sets c to the new vector constructed by applying int function f(int, int) +to successive pairs of a and b. The result has length the shorter of +a and b. + +@item c = reverse(a) +sets c to a, with elements in reverse order. +@end table + +@section Destructive operations + +@table @code +@item a.reverse(); +reverses a in-place. + +@item a.sort(f) +sorts a in-place using comparison function f. The sorting method is a +variation of the quicksort functions supplied with GNU emacs. + +@item a.fill(0, 4, 2) +fills the 2 elements starting at a[4] with zero. + +@end table + +@section Other operations + +@table @code + +@item a.apply(f) +applies function f to each element in a. + +@item x = a.reduce(f, base) +accumulates the results of applying function f to successive elements +of a starting with base. + +@item a.index(int targ); +returns the index of the leftmost occurrence of the target, or -1, +if it does not occur. + +@item a.error(char* msg) +invokes the error handler. The default version prints the error message, +then aborts. +@end table + +@section AVec operations. + +AVecs provide additional arithmetic operations. All vector-by-vector +operators generate an error if the vectors are not the same length. The +following operations are provided, for @code{AVecs a, b} and +base element (scalar) @code{s}. + +@table @code +@item a = b; +Copies b to a. a and b must be the same size. + +@item a = s; +fills all elements of a with the value s. a is not resized. + +@item a + s; a - s; a * s; a / s +adds, subtracts, multiplies, or divides each element of a with the scalar. + +@item a += s; a -= s; a *= s; a /= s; +adds, subtracts, multiplies, or divides the scalar into a. + +@item a + b; a - b; product(a, b), quotient(a, b) +adds, subtracts, multiplies, or divides corresponding elements of a and b. + +@item a += b; a -= b; a.product(b); a.quotient(b); +adds, subtracts, multiplies, or divides corresponding elements of b into a. + +@item s = a * b; +returns the inner (dot) product of a and b. + +@item x = a.sum(); +returns the sum of elements of a. + +@item x = a.sumsq(); +returns the sum of squared elements of a. + +@item x = a.min(); +returns the minimum element of a. + +@item x = a.max(); +returns the maximum element of a. + +@item i = a.min_index(); +returns the index of the minimum element of a. + +@item i = a.max_index(); +returns the index of the maximum element of a. + +Note that it is possible to apply vector versions other arithmetic +operators via the mapping functions. For example, to set vector b +to the cosines of doubleVec a, use @code{b = map(cos, a);}. +This is often more efficient than performing the operations +in an element-by-element fashion. +@end table + +@node Plex, Stack, Vector, Top +@chapter Plex classes + +A ``Plex'' is a kind of array with the following properties: + +@itemize @bullet +@item +Plexes may have arbitrary upper and lower index bounds. For example +a Plex may be declared to run from indices -10 .. 10. + +@item +Plexes may be dynamically expanded at both the lower and upper bounds +of the array in steps of one element. + +@item +Only elements that have been specifically initialized or added may +be accessed. + +@item +Elements may be accessed via indices. Indices are always checked for +validity at run time. Plexes may be traversed via simple variations of +standard array indexing loops. + +@item +Plex elements may be accessed and traversed via Pixes. + +@item +Plex-to-Plex assignment and related operations on entire Plexes +are supported. + +@item +Plex classes contain methods to help programmers check the validity +of indexing and pointer operations. + +@item +Plexes form ``natural'' base classes for many restricted-access data +structures relying on logically contiguous indices, such as array-based +stacks and queues. + +@item +Plexes are implemented as pseudo-generic classes, and must be generated +via the @code{genclass} utility. +@end itemize + +Four subclasses of Plexes are supported: A @code{FPlex} is a Plex that +may only grow or shrink within declared bounds; an @code{XPlex} may +dynamically grow or shrink without bounds; an @code{RPlex} is the +same as an @code{XPlex} but better supports indexing with poor +locality of reference; a @code{MPlex} may grow +or shrink, and additionally allows the logical deletion and restoration +of elements. Because these classes are virtual subclasses of the +``abstract'' class @code{Plex}, it is possible to write user code +such as @code{void f(Plex& a) ...} that operates on any kind of +Plex. However, as with nearly any virtual class, specifying the +particular Plex class being used results in more efficient code. + +Plexes are implemented as a linked list of @code{IChunks}. Each chunk +contains a part of the array. Chunk sizes may be specified within Plex +constructors. Default versions also exist, that use a @code{#define'd} +default. Plexes grow by filling unused space in existing chunks, if +possible, else, except for FPlexes, by adding another chunk. Whenever +Plexes grow by a new chunk, the default element constructors (i.e., +those which take no arguments) for all chunk elements are called at +once. When Plexes shrink, destructors for the elements are not called +until an entire chunk is freed. For this reason, Plexes (like C++ +arrays) should only be used for elements with default constructors and +destructors that have no side effects. + +Plexes may be indexed and used like arrays, although traversal +syntax is slightly different. Even though Plexes maintain elements +in lists of chunks, they are implemented so that iteration and +other constructs that maintain locality of reference require very +little overhead over that for simple array traversal +Pix-based traversal is also supported. For example, for a plex, p, +of ints, the following traversal methods could be used. + +@smallexample +for (int i = p.low(); i < p.fence(); p.next(i)) use(p[i]); +for (int i = p.high(); i > p.ecnef(); p.prev(i)) use(p[i]); +for (Pix t = p.first(); t != 0; p.next(t)) use(p(i)); +for (Pix t = p.last(); t != 0; p.prev(t)) use(p(i)); +@end smallexample + +Except for MPlexes, simply using @code{++i} and @code{--i} works just as +well as @code{p.next(i)} and @code{p.prev(i)} when traversing by index. +Index-based traversal is generally a bit faster than Pix-based +traversal. + +@code{XPlexes} and @code{MPlexes} are less than optimal for applications +in which widely scattered elements are indexed, as might occur when +using Plexes as hash tables or ``manually'' allocated linked lists. +In such applications, @code{RPlexes} are often preferable. @code{RPlexes} +use a secondary chunk index table that requires slightly greater, +but entirely uniform overhead per index operation. + +Even though they may grow in either direction, Plexes are normally +constructed so that their ``natural'' growth direction is upwards, +in that default chunk construction leaves free space, if present, +at the end of the plex. However, if the chunksize arguments to +constructors are negative, they leave space at the beginning. + +All versions of Plexes support the following basic capabilities. +(letting @code{Plex} stand for the type name constructed via the +genclass utility (e.g., @code{intPlex}, @code{doublePlex})). Assume +declarations of @code{Plex p, q}, @code{int i, j}, base element +@code{x}, and Pix @code{pix}. + +@table @code + +@item Plex p; +Declares p to be an initially zero-sized Plex with low index of zero, +and the default chunk size. For FPlexes, chunk sizes represent maximum +sizes. + +@item Plex p(int size); +Declares p to be an initially zero-sized Plex with low index of zero, +and the indicated chunk size. If size is negative, then the Plex +is created with free space at the beginning of the Plex, +allowing more efficient add_low() operations. Otherwise, it +leaves space at the end. + +@item Plex p(int low, int size); +Declares p to be an initially zero-sized Plex with low index of low, +and the indicated chunk size. + +@item Plex p(int low, int high, Base initval, int size = 0); +Declares p to be a Plex with indices from low to high, initially +filled with initval, and the indicated chunk size if specified, +else the default or (high - low + 1), whichever is greater. + +@item Plex q(p); +Declares q to be a copy of p. + +@item p = q; +Copies Plex q into p, deleting its previous contents. + +@item p.length() +Returns the number of elements in the Plex. + +@item p.empty() +Returns true if Plex p contains no elements. + +@item p.full() +Returns true if Plex p cannot be expanded. This always returns +false for XPlexes and MPlexes. + +@item p[i] +Returns a reference to the i'th element of p. An exception (error) occurs +if i is not a valid index. + +@item p.valid(i) +Returns true if i is a valid index into Plex p. + +@item p.low(); p.high(); +Return the minimum (maximum) valid index of the Plex, or the high (low) +fence if the plex is empty. + +@item p.ecnef(); p.fence(); +Return the index one position past the minimum (maximum) valid index. + +@item p.next(i); i = p.prev(i); +Set i to the next (previous) index. This index may not be within bounds. + +@item p(pix) +returns a reference to the item at Pix pix. + +@item pix = p.first(); pix = p.last(); +Return the minimum (maximum) valid Pix of the Plex, or 0 +if the plex is empty. + +@item p.next(pix); p.prev(pix); +set pix to the next (previous) Pix, or 0 if there is none. + +@item p.owns(pix) +Returns true if the Plex contains the element associated with pix. + +@item p.Pix_to_index(pix) +If pix is a valid Pix to an element of the Plex, +returns its corresponding index, else raises an exception. + +@item ptr = p.index_to_Pix(i) +if i is a valid index, returns a the corresponding Pix. + +@item p.low_element(); p.high_element(); +Return a reference to the element at the minimum (maximum) valid index. +An exception occurs if the Plex is empty. + +@item p.can_add_low(); p.can_add_high(); +Returns true if the plex can be extended one element downward (upward). +These always return true for XPlex and MPlex. + +@item j = p.add_low(x); j = p.add_high(x); +Extend the Plex by one element downward (upward). The new minimum +(maximum) index is returned. + +@item j = p.del_low(); j = p.del_high() +Shrink the Plex by one element on the low (high) end. The new +minimum (maximum) element is returned. An exception occurs if the +Plex is empty. + +@item p.append(q); +Append all of Plex q to the high side of p. + +@item p.prepend(q); +Prepend all of q to the low side of p. + +@item p.clear() +Delete all elements, resetting p to a zero-sized Plex. + +@item p.reset_low(i); +Resets p to be indexed starting at low() = i. For example. +if p were initially declared via @code{Plex p(0, 10, 0)}, +and then re-indexed via @code{p.reset_low(5)}, +it could then be indexed from indices 5 .. 14. + +@item p.fill(x) +sets all p[i] to x. + +@item p.fill(x, lo, hi) +sets all of p[i] from lo to hi, inclusive, to x. + +@item p.reverse() +reverses p in-place. + +@item p.chunk_size() +returns the chunk size used for the plex. + +@item p.error(const char * msg) +calls the resettable error handler. + +@end table + +MPlexes are plexes with bitmaps that allow items to be logically +deleted and restored. They behave like other plexes, but +also support the following additional and modified capabilities: + +@table @code + +@item p.del_index(i); p.del_Pix(pix) +logically deletes p[i] (p(pix)). After deletion, attempts to access p[i] +generate a error. Indexing via low(), high(), prev(), +and next() skip the element. Deleting an element never changes the +logical bounds of the plex. + +@item p.undel_index(i); p.undel_Pix(pix) +logically undeletes p[i] (p(pix)). + +@item p.del_low(); p.del_high() +Delete the lowest (highest) undeleted element, resetting the +logical bounds of the plex to the next lowest (highest) undeleted +index. Thus, MPlex del_low() and del_high() may shrink the bounds +of the plex by more than one index. + +@item p.adjust_bounds() +Resets the low and high bounds of the Plex to the indexes of +the lowest and highest actual undeleted elements. + +@item int i = p.add(x) +Adds x in an unused index, if possible, else performs add_high. + +@item p.count() +returns the number of valid (undeleted) elements. + +@item p.available() +returns the number of available (deleted) indices. + +@item int i = p.unused_index() +returns the index of some deleted element, if one exists, +else triggers an error. An unused element may be reused via undel. + +@item pix = p.unused_Pix() +returns the pix of some deleted element, if one exists, else 0. +An unused element may be reused via undel. + +@end table + +@node Stack, Queue, Plex, Top +@chapter Stacks + +Stacks are declared as an ``abstract'' class. They are currently +implemented in any of three ways. + +@table @code + +@item VStack +implement fixed sized stacks via arrays. + +@item XPStack +implement dynamically-sized stacks via XPlexes. + +@item SLStack +implement dynamically-size stacks via linked lists. + +@end table + +All possess the same capabilities. They differ only in constructors. +VStack constructors require a fixed maximum capacity argument. +XPStack constructors optionally take a chunk size argument. +SLStack constructors take no argument. + +Assume the declaration of a base element @code{x}. + +@table @code + +@item Stack s; or Stack s(int capacity) +declares a Stack. + +@item s.empty() +returns true if stack s is empty. + +@item s.full() +returns true if stack s is full. XPStacks and SLStacks never become full. + +@item s.length() +returns the current number of elements in the stack. + +@item s.push(x) +pushes x on stack s. + +@item x = s.pop() +pops and returns the top of stack + +@item s.top() +returns a reference to the top of stack. + +@item s.del_top() +pops, but does not return the top of stack. When large items are held +on the stack it is often a good idea to use @code{top()} to inspect and use +the top of stack, followed by a @code{del_top()} + +@item s.clear() +removes all elements from the stack. + +@end table + +@node Queue, Deque, Stack, Top +@chapter Queues + +Queues are declared as an ``abstract'' class. They are currently +implemented in any of three ways. + +@table @code +@item VQueue +implement fixed sized Queues via arrays. + +@item XPQueue +implement dynamically-sized Queues via XPlexes. + +@item SLQueue +implement dynamically-size Queues via linked lists. +@end table + +All possess the same capabilities; they differ only in constructors. +@code{VQueue} constructors require a fixed maximum capacity argument. +@code{XPQueue} constructors optionally take a chunk size argument. +@code{SLQueue} constructors take no argument. + +Assume the declaration of a base element @code{x}. + +@table @code +@item Queue q; or Queue q(int capacity); +declares a queue. + +@item q.empty() +returns true if queue q is empty. + +@item q.full() +returns true if queue q is full. XPQueues and SLQueues are never full. + +@item q.length() +returns the current number of elements in the queue. + +@item q.enq(x) +enqueues x on queue q. + +@item x = q.deq() +dequeues and returns the front of queue + +@item q.front() +returns a reference to the front of queue. + +@item q.del_front() +dequeues, but does not return the front of queue + +@item q.clear() +removes all elements from the queue. +@end table + +@node Deque, PQ, Queue, Top +@chapter Double ended Queues + +Deques are declared as an ``abstract'' class. They are currently +implemented in two ways. + +@table @code + +@item XPDeque +implement dynamically-sized Deques via XPlexes. + +@item DLDeque +implement dynamically-size Deques via linked lists. + +@end table + +All possess the same capabilities. They differ only in constructors. +XPDeque constructors optionally take a chunk size argument. +DLDeque constructors take no argument. + +Double-ended queues support both stack-like and queue-like capabilities: + +Assume the declaration of a base element @code{x}. + +@table @code + +@item Deque d; or Deque d(int initial_capacity) +declares a deque. + +@item d.empty() +returns true if deque d is empty. + +@item d.full() +returns true if deque d is full. +Always returns false in current implementations. + +@item d.length() +returns the current number of elements in the deque. + +@item d.enq(x) +inserts x at the rear of deque d. + +@item d.push(x) +inserts x at the front of deque d. + +@item x = d.deq() +dequeues and returns the front of deque + +@item d.front() +returns a reference to the front of deque. + +@item d.rear() +returns a reference to the rear of the deque. + +@item d.del_front() +deletes, but does not return the front of deque + +@item d.del_rear() +deletes, but does not return the rear of the deque. + +@item d.clear() +removes all elements from the deque. + +@end table + +@node PQ, Set, Deque, Top +@chapter Priority Queue class prototypes. + +Priority queues maintain collections of objects arranged for fast +access to the least element. + +Several prototype implementations of priority queues are supported. + +@table @code + +@item XPPQs +implement 2-ary heaps via XPlexes. + +@item SplayPQs +implement PQs via Sleator and Tarjan's (JACM 1985) +splay trees. The algorithms use a version of ``simple top-down +splaying'' (described on page 669 of the article). The simple-splay +mechanism for priority queue functions is loosely based on the one used +by D. Jones in the C splay tree functions available from volume 14 of +the uunet.uu.net archives. + +@item PHPQs +implement pairing heaps (as described by Fredman and +Sedgewick in @cite{Algorithmica}, Vol 1, p111-129). Storage for heap elements +is managed via an internal freelist technique. The constructor allows an +initial capacity estimate for freelist space. The storage is automatically +expanded if necessary to hold new items. The deletion technique is a fast +``lazy deletion'' strategy that marks items as deleted, without reclaiming +space until the items come to the top of the heap. + +@end table + +All PQ classes support the following operations, for some PQ class +@code{Heap}, instance @code{h}, @code{Pix ind}, and base class +variable @code{x}. + +@table @code + +@item h.empty() +returns true if there are no elements in the PQ. + +@item h.length() +returns the number of elements in h. + +@item ind = h.enq(x) +Places x in the PQ, and returns its index. + +@item x = h.deq() +Dequeues the minimum element of the PQ into x, or generates an error +if the PQ is empty. + +@item h.front() +returns a reference to the minimum element. + +@item h.del_front() +deletes the minimum element. + +@item h.clear(); +deletes all elements from h; + +@item h.contains(x) +returns true if x is in h. + +@item h(ind) +returns a reference to the item indexed by ind. + +@item ind = h.first() +returns the Pix of first item in the PQ or 0 if empty. +This need not be the Pix of the least element. + +@item h.next(ind) +advances ind to the Pix of next element, or 0 if there are no more. + +@item ind = h.seek(x) +Sets ind to the Pix of x, or 0 if x is not in h. + +@item h.del(ind) +deletes the item with Pix ind. + +@end table + +@node Set, Bag, PQ, Top +@chapter Set class prototypes + +Set classes maintain unbounded collections of items containing +no duplicate elements. + +These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] adding, [f] finding (via seek, +contains), [d] deleting, elements, and [c] comparing (via ==, <=) and +[m] merging (via |=, -=, &=) sets). + +@table @code +@item XPSets +implement unordered sets via XPlexes. +([a O(n)], [f O(n)], [d O(n)], [c O(n^2)] [m O(n^2)]). + +@item OXPSets +implement ordered sets via XPlexes. +([a O(n)], [f O(log n)], [d O(n)], [c O(n)] [m O(n)]). + +@item SLSets +implement unordered sets via linked lists +([a O(n)], [f O(n)], [d O(n)], [c O(n^2)] [m O(n^2)]). + +@item OSLSets +implement ordered sets via linked lists +([a O(n)], [f O(n)], [d O(n)], [c O(n)] [m O(n)]). + +@item AVLSets +implement ordered sets via threaded AVL trees +([a O(log n)], [f O(log n)], [d O(log n)], [c O(n)] [m O(n)]). + +@item BSTSets +implement ordered sets via binary search trees. The trees may +be manually rebalanced via the O(n) @code{balance()} member function. +([a O(log n)/O(n)], [f O(log n)/O(n)], [d O(log n)/O(n)], [c O(n)] [m O(n)]). + +@item SplaySets +implement ordered sets via Sleator and Tarjan's (JACM 1985) +splay trees. The algorithms use a version of ``simple top-down +splaying'' (described on page 669 of the article). +(Amortized: [a O(log n)], [f O(log n)], [d O(log n)], [c O(n)] [m O(n log n)]). + +@item VHSets +implement unordered sets via hash tables. +The tables are automatically resized when their capacity is exhausted. +([a O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m O(n)/O(n^2)]). + +@item VOHSets +implement unordered sets via ordered hash tables +The tables are automatically resized when their capacity is exhausted. +([a O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m O(n)/O(n^2)]). + +@item CHSets +implement unordered sets via chained hash tables. +([a O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m O(n)/O(n^2)]). +@end table + +The different implementations differ in whether their constructors +require an argument specifying their initial capacity. Initial +capacities are required for plex and hash table based Sets. If none is +given @code{DEFAULT_INITIAL_CAPACITY} (from @file{defs.h}) is +used.@refill + +Sets support the following operations, for some class @code{Set}, +instances @code{a} and @code{b}, @code{Pix ind}, and base +element @code{x}. Since all implementations are virtual derived classes +of the @code{Set} class, it is possible to mix and match operations +across different implementations, although, as usual, operations +are generally faster when the particular classes are specified +in functions operating on Sets. + +Pix-based operations are more fully described in the section +on Pixes. @xref{Pix} + +@table @code + +@item Set a; or Set a(int initial_size); +Declares a to be an empty Set. The second version is allowed in +set classes that require initial capacity or sizing specifications. + +@item a.empty() +returns true if a is empty. + +@item a.length() +returns the number of elements in a. + +@item Pix ind = a.add(x) +inserts x into a, returning its index. + +@item a.del(x) +deletes x from a. + +@item a.clear() +deletes all elements from a; + +@item a.contains(x) +returns true if x is in a. + +@item a(ind) +returns a reference to the item indexed by ind. + +@item ind = a.first() +returns the Pix of first item in the set or 0 if the Set is empty. +For ordered Sets, this is the Pix of the least element. + +@item a.next(ind) +advances ind to the Pix of next element, or 0 if there are no more. + +@item ind = a.seek(x) +Sets ind to the Pix of x, or 0 if x is not in a. + +@item a == b +returns true if a and b contain all the same elements. + +@item a != b +returns true if a and b do not contain all the same elements. + +@item a <= b +returns true if a is a subset of b. + +@item a |= b +Adds all elements of b to a. + +@item a -= b +Deletes all elements of b from a. + +@item a &= b +Deletes all elements of a not occurring in b. + +@end table + + +@node Bag, Map, Set, Top +@chapter Bag class prototypes + +Bag classes maintain unbounded collections of items potentially +containing duplicate elements. + +These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] adding, [f] finding (via seek, +contains), [d] deleting elements). + + +@table @code + +@item XPBags +implement unordered Bags via XPlexes. +([a O(1)], [f O(n)], [d O(n)]). + +@item OXPBags +implement ordered Bags via XPlexes. +([a O(n)], [f O(log n)], [d O(n)]). + +@item SLBags +implement unordered Bags via linked lists +([a O(1)], [f O(n)], [d O(n)]). + +@item OSLBags +implement ordered Bags via linked lists +([a O(n)], [f O(n)], [d O(n)]). + +@item SplayBags +implement ordered Bags via Sleator and Tarjan's (JACM 1985) +splay trees. The algorithms use a version of ``simple top-down +splaying'' (described on page 669 of the article). +(Amortized: [a O(log n)], [f O(log n)], [d O(log n)]). + +@item VHBags +implement unordered Bags via hash tables. +The tables are automatically resized when their capacity is exhausted. +([a O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)]). + +@item CHBags +implement unordered Bags via chained hash tables. +([a O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)]). + +@end table + +The implementations differ in whether their constructors +require an argument to specify their initial capacity. Initial +capacities are required for plex and hash table based Bags. If none is +given @code{DEFAULT_INITIAL_CAPACITY} (from @file{defs.h}) is used.@refill + +Bags support the following operations, for some class @code{Bag}, +instances @code{a} and @code{b}, @code{Pix ind}, and base +element @code{x}. Since all implementations are virtual derived classes +of the @code{Bag} class, it is possible to mix and match operations +across different implementations, although, as usual, operations +are generally faster when the particular classes are specified +in functions operating on Bags. + +Pix-based operations are more fully described in the section +on Pixes. @xref{Pix} + +@table @code + +@item Bag a; or Bag a(int initial_size) +Declares a to be an empty Bag. The second version is allowed in +Bag classes that require initial capacity or sizing specifications. + +@item a.empty() +returns true if a is empty. + +@item a.length() +returns the number of elements in a. + +@item ind = a.add(x) +inserts x into a, returning its index. + +@item a.del(x) +deletes one occurrence of x from a. + +@item a.remove(x) +deletes all occurrences of x from a. + +@item a.clear() +deletes all elements from a; + +@item a.contains(x) +returns true if x is in a. + +@item a.nof(x) +returns the number of occurrences of x in a. + +@item a(ind) +returns a reference to the item indexed by ind. + +@item int = a.first() +returns the Pix of first item in the Bag or 0 if the Bag is empty. +For ordered Bags, this is the Pix of the least element. + +@item a.next(ind) +advances ind to the Pix of next element, or 0 if there are no more. + +@item ind = a.seek(x, Pix from = 0) +Sets ind to the Pix of the next occurrence x, or 0 if there are none. +If from is 0, the first occurrence is returned, else the following from. + +@end table + +@node Map, GetOpt, Bag, Top +@chapter Map Class Prototypes + +Maps support associative array operations (insertion, deletion, and +membership of records based on an associated key). They require +the specification of two types, the key type and the contents type. + +These are currently implemented in several ways, differing in +representation strategy, algorithmic efficiency, and appropriateness for +various tasks. (Listed next to each are average (followed by worst-case, +if different) time complexities for [a] accessing (via op [], +contains), [d] deleting elements). + + +@table @code + +@item AVLMaps +implement ordered Maps via threaded AVL trees +([a O(log n)], [d O(log n)]). + +@item RAVLMaps +Similar, but also maintain ranking information, used via +@code{ranktoPix(int r)}, that returns the @code{Pix} of the +item at rank r, and @code{rank(key)} that returns the +rank of the corresponding item. +([a O(log n)], [d O(log n)]). + +@item SplayMaps +implement ordered Maps via Sleator and Tarjan's (JACM 1985) +splay trees. The algorithms use a version of ``simple top-down +splaying'' (described on page 669 of the article). +(Amortized: [a O(log n)], [d O(log n)]). + +@item VHMaps +implement unordered Maps via hash tables. +The tables are automatically resized when their capacity is exhausted. +([a O(1)/O(n)], [d O(1)/O(n)]). + +@item CHMaps +implement unordered Maps via chained hash tables. +([a O(1)/O(n)], [d O(1)/O(n)]). + +@end table + +The different implementations differ in whether their constructors +require an argument specifying their initial capacity. Initial +capacities are required for hash table based Maps. If none is +given @code{DEFAULT_INITIAL_CAPACITY} (from @file{defs.h}) is +used.@refill + +All Map classes share the following operations (for some Map class, +@code{Map} instance @code{d}, @code{Pix ind} and key variable @code{k}, +and contents variable @code{x}). + +Pix-based operations are more fully described in the section +on Pixes. @xref{Pix} + +@table @code + +@item Map d(x); Map d(x, int initial_capacity) +Declare d to be an empty Map. The required argument, x, specifies +the default contents, i.e., the contents of an otherwise +uninitialized location. The second version, specifying +initial capacity is allowed for Maps with an initial capacity +argument. + +@item d.empty() +returns true if d contains no items. + +@item d.length() +returns the number of items in d. + +@item d[k] +returns a reference to the contents of item with key k. If no +such item exists, it is installed with the default contents. +Thus d[k] = x installs x, and x = d[k] retrieves it. + +@item d.contains(k) +returns true if an item with key field k exists in d. + +@item d.del(k) +deletes the item with key k. + +@item d.clear() +deletes all items from the table. + +@item x = d.dflt() +returns the default contents. + +@item k = d.key(ind) +returns a reference to the key at Pix ind. + +@item x = d.contents(ind) +returns a reference to the contents at Pix ind. + +@item ind = d.first() +returns the Pix of the first element in d, or 0 if d is empty. + +@item d.next(ind) +advances ind to the next element, or 0 if there are no more. + +@item ind = d.seek(k) +returns the Pix of element with key k, or 0 if k is not in d. + +@end table + +@node GetOpt, Projects, Map, Top +@chapter C++ version of the GNU getopt function + +The GetOpt class provides an efficient and structured mechanism for +processing command-line options from an application program. The sample +program fragment below illustrates a typical use of the GetOpt class +for some hypothetical application program: + +@smallexample +#include +#include +//... +int debug_flag, compile_flag, size_in_bytes; + +int +main (int argc, char **argv) +@{ + // Invokes ctor `GetOpt (int argc, char **argv, + // char *optstring);' + GetOpt getopt (argc, argv, "dcs:"); + int option_char; + + // Invokes member function `int operator ()(void);' + while ((option_char = getopt ()) != EOF) + switch (option_char) + @{ + case 'd': debug_flag = 1; break; + case 'c': compile_flag = 1; break; + case 's': size_in_bytes = atoi (getopt.optarg); break; + case '?': fprintf (stderr, + "usage: %s [dcs]\n", argv[0]); + @} +@} +@end smallexample + +Unlike the C library version, the libg++ GetOpt class uses its +constructor to initialize class data members containing the argument +count, argument vector, and the option string. This simplifies the +interface for each subsequent call to member function @code{int operator +()(void)}. + +The C version, on the other hand, uses hidden static variables to retain +the option string and argument list values between calls to +@code{getopt}. This complicates the @code{getopt} interface since the +argument count, argument vector, and option string must be passed as +parameters for each invocation. For the C version, the loop in the +previous example becomes: + +@smallexample + while ((option_char = getopt (argc, argv, "dcs:")) != EOF) + // ... +@end smallexample + +which requires extra overhead to pass the parameters for every call. + +Along with the GetOpt constructor and @code{int operator ()(void)}, +the other relevant elements of class GetOpt are: + +@table @code +@item char *optarg +Used for communication from @code{operator ()(void)} to the caller. +When @code{operator ()(void)} finds an option that takes an argument, the +argument value is stored here. +@item int optind +Index in @code{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 @code{operator ()(void)}. + +When @code{operator ()(void)} returns EOF, this is the index of the +first of the non-option elements that the caller should itself scan. + +Otherwise, @code{optind} communicates from one call to the next how much +of @code{argv} has been scanned so far. +@end table + +The libg++ version of GetOpt acts like standard UNIX @code{getopt} for +the calling routine, 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 @code{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 _POSIX_OPTION_ORDER disables +permutation. Then the behavior is completely standard. + +@ignore +((Left out because it is not part of libg++ proper, and does not +use the library copyright.)) + +@node Gperf, Projects, GetOpt, Top +@chapter A Perfect Hash Function Generator + +GNU GPERF is a utility program that automatically generates perfect hash +functions from a list of keywords. The GNU C, GNU C++, GNU Pascal, GNU +Modula 3 compilers and the GNU indent code formatting program all +utilize reserved word recognizer routines generated by GPERF. Complete +documentation and source code is available in the ./gperf subdirectory +in the libg++ distribution. A paper describing GPERF in detail is +available in the proceedings of the USENIX Second C++ Conference. +@end ignore + +@node Projects, , GetOpt, Top +@chapter Projects and other things left to do + +@section Coming Attractions + +Some things that will probably be available in libg++ in the near future: + +@itemize @bullet + +@item +Revamped C-compatibility header files that will be compatible with +the forthcoming (ANSI-based) GNU libc.a + +@item +A revision of the File-based classes that will use the GNU stdio library, +and also be 100% compatible (even at the streambuf level) with the AT&T +2.0 stream classes. + +@item +Additional container class prototypes. + +@item +generic Matrix class prototypes. + +@item +A task package probably based on Dirk Grunwald's threads package. + +@end itemize + +@section Wish List + +Some things that people have mentioned that they would like to +see in libg++, but for which there have not been any offers: + +@itemize @bullet + +@item +A method to automatically convert or incorporate libg++ classes +so they can be used directly in Gorlen's OOPS environment. + +@item +A class browser. + +@item +A better general exception-handling strategy. + +@item +Better documentation. + +@end itemize + +@section How to contribute + +Programmers who have written C++ classes that they believe to +be of general interest are encourage to write to dl at rocky.oswego.edu. +Contributing code is not difficult. Here are some general guidelines: + +@itemize @bullet + +@item +FSF must maintain the right to accept or reject potential contributions. +Generally, the only reasons for rejecting contributions are cases where +they duplicate existing or nearly-released code, contain unremovable +specific machine dependencies, or are somehow incompatible with the +rest of the library. + +@item +Acceptance of contributions means that the code is accepted for adaptation +into libg++. FSF must reserve the right to make various editorial changes +in code. Very often, this merely entails formatting, maintenance of various +conventions, etc. Contributors are always given authorship credit and shown +the final version for approval. + +@item +Contributors must assign their copyright to FSF via a form sent out +upon acceptance. Assigning copyright to FSF ensures that the code +may be freely distributed. + +@item +Assistance in providing documentation, test files, and debugging +support is strongly encouraged. + +@end itemize + +Extensions, comments, and suggested modifications of existing libg++ +features are also very welcome. +@contents +@bye diff --git a/gnu/lib/libg++/libg++/no-stream/.cvsignore b/gnu/lib/libg++/libg++/no-stream/.cvsignore new file mode 100644 index 00000000000..7abff1dbead --- /dev/null +++ b/gnu/lib/libg++/libg++/no-stream/.cvsignore @@ -0,0 +1,2 @@ +Makefile +config.status diff --git a/gnu/lib/libg++/libg++/no-stream/Makefile.in b/gnu/lib/libg++/libg++/no-stream/Makefile.in new file mode 100644 index 00000000000..a4f35c57530 --- /dev/null +++ b/gnu/lib/libg++/libg++/no-stream/Makefile.in @@ -0,0 +1,24 @@ +# This is a dummy io directory, with nothing to build. +# This is used by setting IO_DIR=no=stream when building libg++. +# The effect is that iostream does not get built, installed, or used. +# This is useful when: +# a) You're using some other C++ compiler that comes with its own iostreams. +# b) You're using iostream/stdio in your C-library. In that case, +# you will install iostream as part of your C-library, not as part of libg++. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +stamp: + @touch stamp + +.PHONY: add-to-targetlib +# Invoked from other directories, overriding $(TARGETLIB). +add-to-targetlib: + @echo "(Nothing to add)" + +iostream.list: + @echo >iostream.list + diff --git a/gnu/lib/libg++/libg++/no-stream/configure.in b/gnu/lib/libg++/libg++/no-stream/configure.in new file mode 100644 index 00000000000..284b321e19e --- /dev/null +++ b/gnu/lib/libg++/libg++/no-stream/configure.in @@ -0,0 +1,25 @@ +# 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. + +configdirs="" +srctrigger=Makefile.in +srcname="dummy directory (no iostreams)" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +CLEAN='genclass *.h *.cc my.out' +ALL='$(NOTHING)' + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/old-stream/.cvsignore b/gnu/lib/libg++/libg++/old-stream/.cvsignore new file mode 100644 index 00000000000..7abff1dbead --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/.cvsignore @@ -0,0 +1,2 @@ +Makefile +config.status diff --git a/gnu/lib/libg++/libg++/old-stream/ChangeLog b/gnu/lib/libg++/libg++/old-stream/ChangeLog new file mode 100644 index 00000000000..be725db9e7b --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/ChangeLog @@ -0,0 +1,18 @@ +Wed Aug 12 00:41:12 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (distclean): rm Makefile and config.status. + * File.cc: Don't use possibly-undefined _IOAPPEND. + +Fri Jan 17 13:54:02 1992 Per Bothner (bothner at cygnus.com) + + Merge in Doug Lea's latest version; other fixes. + * Most files: Replaced copyright notice (the old + ones claimed to be part of GNU CC). + * Most files: Remove #pragma once (useless for gcc-2). + * File.h, istream.cc, ostream.h: Minor fixes. + + * istream.h, istream.cc: Add ws in addistion to WS, + to allow src files to use the newer (iostream) name. + * itoa.cc: Moved definitions of hex() etc to here + from builtin.h. + * Makefile.in: Remove subdir-related junk. diff --git a/gnu/lib/libg++/libg++/old-stream/File.cc b/gnu/lib/libg++/libg++/old-stream/File.cc new file mode 100644 index 00000000000..96c700634d9 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/File.cc @@ -0,0 +1,580 @@ +/* +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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include // needed to determine values of O_RDONLY... + + +#ifdef VMS +#include // needed to get the psect magic loaded +#define FP (*fp) +#else +#define FP fp +#endif + +// error handlers + +void verbose_File_error_handler(const char* msg) +{ + perror(msg); + errno = 0; +} + +void quiet_File_error_handler(const char*) +{ + errno = 0; +} + +void fatal_File_error_handler(const char* msg) +{ + perror(msg); + exit(1); +} + +one_arg_error_handler_t File_error_handler = verbose_File_error_handler; + + +one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = File_error_handler; + File_error_handler = f; + return old; +} + + +/* + + Opening files. + + open(filename, io_mode, access_mode) is done via system open + command since fopen doesn't handle all of the cases possible + with sys open. After a successful open, fdopen is called to + attach an _iobuf to the file descriptor. + + All this requires a few decoding routines that can translate among our + enumerated types, system flags, and fopen modes. + +*/ + + +enum sys_open_cmd_io_mode // These should be correct for most systems +{ + sio_read = O_RDONLY, + sio_write = O_WRONLY, + sio_readwrite = O_RDWR, + sio_append = O_APPEND +}; + +enum sys_open_cmd_access_mode +{ + sa_create = O_CREAT, + sa_truncate = O_TRUNC, + sa_createonly = O_EXCL | O_CREAT +}; + + +static int open_cmd_arg(io_mode i, access_mode a) // decode modes +{ + int arg; + switch(i) + { + case io_readonly: arg = sio_read; break; + case io_writeonly: arg = sio_write; break; + case io_readwrite: arg = sio_readwrite; break; + case io_appendonly: arg = sio_append | sio_write; break; + case io_append: arg = sio_append | sio_readwrite; break; + default: return -1; + }; + switch(a) + { + case a_createonly: return arg | sa_createonly; + case a_create: return arg | sa_create | sa_truncate; + case a_useonly: return arg; + case a_use: return arg | sa_create; + default: return -1; + } +} + +static char* fopen_cmd_arg(io_mode i) +{ + switch(i) + { + case io_readonly: return "r"; + case io_writeonly: return "w"; + case io_readwrite: return "r+"; + case io_appendonly:return "a"; + case io_append: return "a+"; + default: return 0; + } +} + + +void File::initialize() +{ + fp = 0; nm = 0; stat = 0; state = _bad; rw = 0; +} + +// reset class vars after open +// fp->_flag inspection is isolated here + +void File::reinitialize(const char* filename) +{ + if (filename != 0) setname(filename); + else if (fp == stdin) setname("(stdin)"); + else if (fp == stdout) setname("(stdout)"); + else if (fp == stderr) setname("(stderr)"); + else if (rw & 4) setname("(string)"); + else setname(0); + + if (fp != 0) + { + state = _good; + if (FP->_flag & (_IOREAD|_IORW)) + rw |= 01; + if (FP->_flag & (_IOWRT|_IORW)) + rw |= 02; + check_state(); + } + else + { + set(_fail); set(_bad); + error(); + } +} + + +File& File::open(const char* filename, io_mode m, access_mode a) +{ + close(); + int open_arg = open_cmd_arg(m, a); + if (open_arg != -1) + { + int fd = ::open(filename, open_arg, 0666); + if (fd >= 0) + fp = fdopen(fd, fopen_cmd_arg(m)); + } + reinitialize(filename); + return *this; +} + +File& File::open(const char* filename, const char* m) +{ + close(); + fp = fopen(filename, m); + reinitialize(filename); + return *this; +} + +File& File::open(FILE* fileptr) +{ + close(); + fp = fileptr; + reinitialize(0); + return *this; +} + +File& File::open(int filedesc, io_mode m) +{ + close(); + fp = fdopen(filedesc, fopen_cmd_arg(m)); + reinitialize(0); + return *this; +} + +File& File::close() +{ + if (fp != 0) + { +#ifdef VMS + if (rw & 4) // we own the iobuf, kill it + delete(*fp); // kill the _iobuf +#endif + if (rw & 4) // we own the iobuf, kill it + delete fp; + else if (fp == stdin || fp == stdout || fp == stderr) + flush(); + else + fclose(fp); + } + fp = 0; + rw = 0; + set(_bad); + return *this; +} + +File& File::remove() +{ + close(); + return failif (nm == 0 || unlink(nm) != 0); +} + + +File::File() +{ + initialize(); +} + +File::File(const char* filename, io_mode m, access_mode a) +{ + initialize(); + open(filename, m, a); +} + +File::File(const char* filename, const char* m) +{ + initialize(); + open(filename, m); +} + +File::File(int filedesc, io_mode m) +{ + initialize(); + open(filedesc, m); +} + +File::File(FILE* fileptr) +{ + initialize(); + open(fileptr); +} + +File::File(int sz, char* buf, io_mode m) +{ + if (m != io_readonly && m != io_writeonly) + (*File_error_handler) ("invalid io_mode for string IO"); + initialize(); + rw = 4; +#ifdef VMS + _iobuf *iob; + FILE *f; + + iob = new _iobuf; + f = new(FILE); + *f = iob; + fp = f; +#else + fp = new _iobuf; +#endif +#ifndef _NFILE + FP->_file = 255; // any illegal value +#else + FP->_file = _NFILE-1; // The last filedescriptor... +#ifdef BUFEND_ENTRY_TYPE + _bufendtab[FP->_file] = (BUFEND_ENTRY_TYPE)buf+sz-1; +#endif +#endif + FP->_ptr = FP->_base = buf; +#ifdef HAVE_BUFSIZ + FP->_bufsiz = sz; +#endif + if (m == io_readonly) + { + int len = 0; + while (len < sz && buf[len] != 0) ++len; + if (len == sz) + buf[sz - 1] = 0; // force null-termination! + FP->_cnt = len; + FP->_flag = _IOREAD | _IOSTRG | _IOMYBUF; + } + else + { + bzero(buf, sz); // so any result will be null-terminated + FP->_cnt = sz - 1; // leave at least one null at end + FP->_flag = _IOWRT | _IOSTRG | _IOMYBUF; + } + reinitialize(0); +} + +File::~File() +{ + delete(nm); + close(); +} + +void File::setname(const char* newname) +{ + if (nm == newname) return; + + if (nm != 0) + delete(nm); + if (newname != 0) + { + nm = new char[strlen(newname) + 1]; + strcpy(nm, newname); + } + else + nm = 0; +} + + +File& File::setbuf(int buffer_kind) +{ + if (!is_open()) + { + set(_fail); + return *this; + } + switch(buffer_kind) + { + case _IOFBF: +#ifdef HAVE_SETVBUF + setvbuf(fp, 0, _IOFBF, 0); +#endif + break; + case _IONBF: + ::setbuf(fp, 0); + break; + case _IOLBF: +#ifdef HAVE_SETLINEBUF + setlinebuf(fp); +#else +#ifdef HAVE_SETVBUF + setvbuf(fp, 0, _IOLBF, 0); +#endif +#endif + break; + default: + break; + } + return *this; +} + +File& File::setbuf(int size, char* buf) +{ + if (!is_open()) + { + set(_fail); + return *this; + } +#ifdef HAVE_SETVBUF + setvbuf(fp, buf, _IOFBF, size); +#else + setbuffer(fp, buf, size); +#endif + return *this; +} + +void File::error() +{ + check_state(); + set(_fail); + if (errno != 0) + { + char error_string[400]; + strcpy(error_string, "\nerror in File "); + if (nm != 0) + strcat(error_string, nm); + (*File_error_handler)(error_string); + } +} + + +//------------------------------------------------------------------ + +void File::check_state() // ensure fp & state agree about eof +{ + if (fp != 0) + { + if (feof(fp)) + set(_eof); + else + unset(_eof); + if (ferror(fp)) + set(_bad); + } +} + +File& File::put(const char* s) +{ + return failif(!writable() || fputs(s, fp) == EOF); +} + +File& File::get(char* s, int n, char terminator) +{ + if (!readable()) + { + set(_fail); + return *this; + } + + char ch; + stat = --n; + + if (n > 0 && (get(ch))) + { + if (ch == terminator) { + unget(ch); + stat= 0; // This is not an error condition ! + } + else + { + *s++ = ch; --n; + while (n > 0 && (get(ch))) + { + if (ch == terminator) + { + unget(ch); + break; + } + else + { + *s++ = ch; --n; + } + } + } + } + + *s = 0; + return failif((stat != 0) && ((stat -= n) == 0)); +} + +File& File::getline(char* s, int n, char terminator) +{ + if (!readable()) + { + set(_fail); + return *this; + } + + char ch; + stat = --n; + + while (n > 0 && (get(ch))) + { + --n; + if ((*s++ = ch) == terminator) + break; + } + + *s = 0; + return failif((stat != 0) && ((stat -= n) == 0)); +} + +// from Doug Schmidt + +// This should probably be a page size.... +#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 *File::readline (int chunk_number, char terminator) +{ + char buf[CHUNK_SIZE]; + register char *bufptr = buf; + register char *ptr; + char ch; + int continu; + + while ((continu = !!get(ch)) && ch != terminator) /* fill the current buffer */ + { + *bufptr++ = ch; + if (bufptr - buf >= CHUNK_SIZE) /* prepend remainder to ptr buffer */ + { + if (ptr = readline (chunk_number + 1, terminator)) + + for (; bufptr != buf; *--ptr = *--bufptr); + + return ptr; + } + } + if (!continu && bufptr == buf) + return NULL; + + int size = (chunk_number * CHUNK_SIZE + bufptr - buf) + 1; + + if (ptr = new char[stat = size]) + { + + for (*(ptr += (size - 1)) = '\0'; bufptr != buf; *--ptr = *--bufptr) + ; + + return ptr; + } + else + return NULL; +} + +/* 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 *). */ + +File& File::gets(char **s, char terminator) +{ + if (!readable()) + { + set(_fail); + return *this; + } + + return failif(!(*s = readline (0, terminator))); +} + +#ifndef VMS +File& File::scan(const char* fmt ...) +{ + if (readable()) + { + va_list args; + va_start(args, fmt); +#ifndef HAVE_VSCANF + stat = _doscan(fp, fmt, args); +#else + stat = vfscanf(fp, fmt, args); +#endif + va_end(args); + failif(stat <= 0); + } + return *this; +} +#endif + +File& File::form(const char* fmt ...) +{ + va_list args; + va_start(args, fmt); +#ifndef HAVE_VPRINTF + stat = _doprnt(fmt, args, fp); +#ifdef HAVE_VOID_DOPRNT + stat = ferror(fp) ? -1 : 0; +#endif +#else + stat = vfprintf(fp, fmt, args); +#endif + va_end(args); + failif(stat < 0); + return *this; +} + +#ifdef VMS +extern "C" { + unlink(const char *s) + { + int remove(const char *); + + return remove(s); + } +} +#endif + diff --git a/gnu/lib/libg++/libg++/old-stream/File.h b/gnu/lib/libg++/libg++/old-stream/File.h new file mode 100644 index 00000000000..dfd6029dc7a --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/File.h @@ -0,0 +1,316 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _File_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _File_h 1 + +#include +#include +#include + +#include + +class Filebuf; + +class File +{ + friend class Filebuf; +protected: + FILE* fp; // _iobuf file pointer + char* nm; // file name (dynamically allocated) + char rw; // 1 = read; 2 = write; 3 = readwrite + // bit 2 (4) means read/write into string + state_value state; // _good/_eof/_fail/_bad + long stat; // last read/write/... return value + + void initialize(); + void reinitialize(const char*); + char *readline (int chunk_number, char terminator); + +public: + File(); + File(const char* filename, io_mode m, access_mode a); + File(const char* filename, const char* m); + File(int filedesc, io_mode m); + File(FILE* fileptr); + File(int sz, char* buf, io_mode m); + + ~File(); + +// binding, rebinding, unbinding to physical files + + File& open(const char* filename, io_mode m, access_mode a); + File& open(const char* filename, const char* m); + File& open(int filedesc, io_mode m); + File& open(FILE* fileptr); + + File& close(); + File& remove(); + +// class variable access + + int filedesc(); + const char* name(); + void setname(const char* newname); + int iocount(); + + int rdstate(); + int eof(); + int fail(); + int bad(); + int good(); + +// other status queries + + int readable(); + int writable(); + int is_open(); + + operator void*(); + +// error handling + + void error(); + void clear(state_value f = _good); // poorly named + void set(state_value f); // set corresponding but + void unset(state_value f); // clear corresponding bit + File& failif(int cond); + void check_state(); + +// character IO + + File& get(char& c); + File& put(char c); + File& unget(char c); + File& putback(char c); // a synonym for unget + +// char* IO + + File& put(const char* s); + File& get (char* s, int n, char terminator = '\n'); + File& getline(char* s, int n, char terminator = '\n'); + File& gets (char **s, char terminator = '\n'); + +// binary IO + + File& read(void* x, int sz, int n); + File& write(const void* x, int sz, int n); + +// formatted IO + + File& form(const char* ...); + File& scan(const char* ...); + +// buffer IO + + File& flush(); + File& flush(char ch); // call stdio _flsbuf + int fill(); // call stdio _filbuf + +// position control + + File& seek(long pos, int seek_mode=0); // default seek mode=absolute + long tell(); + +// buffer control + + File& setbuf(int buffer_kind); // legal vals: _IONBF, _IOFBF, _IOLBF + File& setbuf(int size, char* buf); + File& raw(); +}; + + +// error handlers + +extern void verbose_File_error_handler(const char*); +extern void quiet_File_error_handler(const char*); +extern void fatal_File_error_handler(const char*); +extern one_arg_error_handler_t File_error_handler; +extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t); + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + + + +inline int File::filedesc() +{ + return fileno(fp); +} + +inline const char* File::name() +{ + return nm; +} + +inline int File::iocount() +{ + return stat; +} + +inline void File::clear(state_value flag) +{ + state = flag; +} + +inline void File::set(state_value flag) +{ + state = state_value(int(state) | int(flag)); +} + +inline void File::unset(state_value flag) +{ + state = state_value(int(state) & ~int(flag)); +} + +inline int File::readable() +{ + if (fp != 0) { if (feof(fp)) set(_eof); if (ferror(fp)) set(_bad);} + return (state == _good && (rw & 01)); +} + +inline int File::writable() +{ + if (fp != 0 && ferror(fp)) set(_bad); + return ((int(state) & (int(_fail)|int(_bad))) == 0 && (rw & 02)); +} + +inline int File::is_open() +{ + return (fp != 0); +} + + +inline File& File::raw() +{ + return this->File::setbuf(_IONBF); +} + + +inline File& File::failif(int cond) +{ + if (cond) set(_fail); return *this; +} + +inline File& File::get(char& c) +{ + if (readable()) + { + int ch = getc(fp); + c = ch; + failif (ch == EOF); + } + return *this; +} + +inline File& File::put(char c) +{ + return failif (!writable() || putc(c, fp) == EOF); +} + +inline File& File::unget(char c) +{ + return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); +} + +inline File& File::putback(char c) +{ + return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); +} + +inline File& File::read(void* x, int sz, int n) +{ + return failif (!readable() || (stat = fread(x, sz, n, fp)) != n); +} + +inline File& File::write(void* x, int sz, int n) +{ + return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n); +} + +inline File& File::flush() +{ + return failif(!is_open() || fflush(fp) == EOF); +} + +inline File& File::flush(char ch) +{ +#ifdef VMS + return failif(!is_open() || c$$flsbuf(ch, fp) == EOF); +#else + return failif(!is_open() || _flsbuf(ch, fp) == EOF); +#endif +} + +inline int File::fill() +{ +#ifdef VMS + failif(!is_open() || (stat = c$$filbuf(fp)) == EOF); +#else + failif(!is_open() || (stat = _filbuf(fp)) == EOF); +#endif + return stat; +} + +inline File& File::seek(long pos, int seek_mode) +{ + return failif (!is_open() || fseek(fp, pos, seek_mode) < 0); +} + +inline long File::tell() +{ + failif (!is_open() || ((stat = ftell(fp)) < 0)); + return stat; +} + +inline int File::rdstate() +{ + check_state(); return state; // check_state is necessary in rare but +} // possible circumstances + +inline File::operator void*() +{ + check_state(); return (int(state) & (int(_bad)|int(_fail)))? 0 : this ; +} + +inline int File::eof() +{ + check_state(); return state & _eof; +} + +inline int File::fail() +{ + check_state(); return state & _fail; +} + +inline int File::bad() +{ + check_state(); return state & _bad; +} + +inline int File::good() +{ + check_state(); return rdstate() == _good; +} + + +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/Filebuf.cc b/gnu/lib/libg++/libg++/old-stream/Filebuf.cc new file mode 100644 index 00000000000..568453a01ba --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/Filebuf.cc @@ -0,0 +1,326 @@ +/* +Copyright (C) 1990 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include +#include // needed to determine values of O_RDONLY... + +#ifndef _bufsiz +#ifdef masscomp +#ifdef _UCB +#define _bufsiz(p) 4096 +#endif +#else +#define _bufsiz(p) ((p)->_bufsiz) +#endif +#endif + +#ifdef VMS +#include +#define FPOINT (*(Fp->fp)) +#undef _bufsiz +#define _bufsiz(p) BUFSIZ // we do not have this available +#else +#define FPOINT Fp->fp +#endif + +void Filebuf::init_streambuf_ptrs() +{ + if (Fp->fp == 0 || FPOINT->_cnt == 0) + { + base = gptr = pptr = eptr = 0; // let first over/under flow deal with it + } + else + { +#ifdef VMS + base = new char[BUFSIZ]; + alloc = 1; +#else + base = FPOINT->_base; +#endif + eptr = base - 1 + _bufsiz(Fp->fp); + pptr = gptr = base; + } +} + + +int Filebuf::is_open() +{ + return (Fp != 0 && Fp->is_open()); +} + + +streambuf* Filebuf::open(const char* name, io_mode m, access_mode a) +{ + if (Fp == 0) + Fp = new File(name, m, a); + else + Fp->open(name, m, a); +#ifndef VMS + if (base != 0) Fp->setbuf(eptr-base+1, base); +#endif + init_streambuf_ptrs(); + return this; +} + +streambuf* Filebuf::open(const char* name, const char* m) +{ + if (Fp == 0) + Fp = new File(name, m); + else + Fp->open(name, m); +#ifndef VMS + if (base != 0) Fp->setbuf(eptr-base+1, base); +#endif + init_streambuf_ptrs(); + return this; +} + +streambuf* Filebuf::open(const char* name, open_mode m) +{ + switch(m) + { + case input: return open(name, "r"); + case output: return open(name, "w"); + case append: return open(name, "a"); + } +} + +streambuf* Filebuf::open(int filedesc, io_mode m) +{ + if (Fp == 0) + Fp = new File(filedesc, m); + else + Fp->open(filedesc, m); +#ifndef VMS + if (base != 0) Fp->setbuf(eptr-base+1, base); +#endif + init_streambuf_ptrs(); + return this; +} + +streambuf* Filebuf::open(FILE* fileptr) +{ + if (Fp == 0) + Fp = new File(fileptr); + else + Fp->open(fileptr); +#ifndef VMS + if (base != 0) Fp->setbuf(eptr-base+1, base); +#endif + init_streambuf_ptrs(); + return this; +} + +Filebuf::Filebuf() : streambuf(), Fp(0) {} + +Filebuf::Filebuf(const char* filename, io_mode m, access_mode a) + : streambuf() +{ + Fp = new File(filename, m, a); + init_streambuf_ptrs(); +} + +Filebuf::Filebuf(const char* filename, const char* m) + : streambuf() +{ + Fp = new File(filename, m); + init_streambuf_ptrs(); +} + +Filebuf::Filebuf(int filedesc, io_mode m) + : streambuf() +{ + Fp = new File(filedesc, m); + init_streambuf_ptrs(); +} + +Filebuf::Filebuf(FILE* fileptr) + : streambuf() +{ + Fp = new File(fileptr); + init_streambuf_ptrs(); +} + +int Filebuf::close() +{ + int was = Fp->is_open(); + if (was) { overflow(); Fp->close(); } +#ifdef VMS + if (was) { + if(alloc && (base != 0)) {delete base; base=0; alloc = 0;}; + gptr=0;}; +#endif + return was; +} + + +Filebuf::~Filebuf() +{ + if (Fp != 0) + { + close(); + delete Fp; + } +} + +#ifdef VMS +/* + VMS implementation notes: + The underflow routine works fine as long as there is no mixing of input and + output for the same stream. If this were to happen, then great confusion + would occur, since we maintain a seperate buffer for the case of output. + the stream classes do not allow this as they are currently written, so for + now we are OK. VMS does not handle buffered output in quite the same way + that UNIX does, so a seperate buffer is allocated, and used by the program. + when it comes time to flush it we call write(...) to empty it. The flush + function under VMS does not flush the buffer unless it is full, and whatsmore + the _iobuf is not 14 bytes long as one might suspect from the structure def, + but at *least* 66 bytes long. Some of these hidden structure elements need + to be set for the output to work properly, and it seemed to be poor + programming practice to fool with them +*/ +#endif +/* + The underflow and overflow methods sync the streambuf with the _iobuf + ptrs on the way in and out of the read. I believe that this is + done in a portable way. +*/ +int Filebuf::underflow() +{ + int ch; + if (Fp == 0) return EOF; + if (gptr == 0) // stdio _iobuf ptrs not initialized until after 1st read + { +#ifdef VMS + assert(alloc==0); +#endif + ch = Fp->fill(); + base = FPOINT->_base; + eptr = base - 1 + _bufsiz(Fp->fp); + } + else + { + FPOINT->_ptr = gptr; + FPOINT->_cnt = eptr - gptr + 1; + ch = Fp->fill(); + } + gptr = base; + *gptr = ch; + if (ch == EOF) + pptr = base; + else + pptr = base + FPOINT->_cnt + 1; + if (Fp->good()) + return ch; + else + { + Fp->clear(); + return EOF; + } +} + +int Filebuf::overflow(int ch) +{ + if (Fp == 0) return EOF; + if (FPOINT->_flag & _IONBF) // handle unbuffered IO specially + { + if (pptr == 0) // 1st write + { + if (ch == EOF) + return 0; + else + { + Fp->flush(ch); + } + } + else + { + if (ch == EOF) + Fp->flush(); // Probably not necessary + else + Fp->flush(ch); + } + } + else + { + if (pptr == 0) // 1st write + { + if (ch == EOF) + return 0; + else + { + Fp->flush(ch); +#ifdef VMS + base = new char[BUFSIZ]; + alloc = 1; +#else + base = FPOINT->_base; +#endif + eptr = base - 1 + _bufsiz(Fp->fp); + gptr = base; + } + } + else + { + if (ch != EOF) *pptr++ = ch; +#ifdef VMS + if(gptr==base) write(FPOINT->_file,base,pptr-base); +#else + FPOINT->_ptr = pptr; + FPOINT->_cnt = eptr - pptr + 1; +#endif + Fp->flush(); + } +#ifdef VMS + pptr = base; +#else + pptr = FPOINT->_ptr; +#endif + } + if (Fp->fail() || Fp->bad()) + { + Fp->clear(); // this allows recovery from ostream level + return EOF; + } + else + return 0; +} + +const char* Filebuf::name() +{ + return Fp->name(); +} + +streambuf* Filebuf::setbuf(char* buf, int buflen, int preload) +{ + if (preload != 0) return 0; // cannot preload, sorry + if (Fp != 0) Fp = new File; + Fp->setbuf(buflen, buf); + init_streambuf_ptrs(); + return (Fp->good())? this : 0; +} + +void Filebuf::error() +{ + Fp->error(); +} diff --git a/gnu/lib/libg++/libg++/old-stream/Filebuf.h b/gnu/lib/libg++/libg++/old-stream/Filebuf.h new file mode 100644 index 00000000000..cd0302f0a9a --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/Filebuf.h @@ -0,0 +1,62 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _Filebuf_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Filebuf_h 1 + +#include +#include + +class Filebuf: public streambuf // libg++ File version +{ +public: + File* Fp; + + void init_streambuf_ptrs(); + + int overflow(int c = EOF); + int underflow(); + + Filebuf(); + Filebuf(const char* filename, io_mode m, access_mode a); + Filebuf(const char* filename, const char* m); + Filebuf(int filedesc, io_mode m); + Filebuf(FILE* fileptr); + + ~Filebuf(); + + const char* name(); + streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0); + + streambuf* open(const char* name, open_mode m); + streambuf* open(const char* filename, io_mode m, access_mode a); + streambuf* open(const char* filename, const char* m); + streambuf* open(int filedesc, io_mode m); + streambuf* open(FILE* fileptr); + + int is_open(); + int close(); + + void error(); +}; + + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/Fmodes.h b/gnu/lib/libg++/libg++/old-stream/Fmodes.h new file mode 100644 index 00000000000..f80bbc98be8 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/Fmodes.h @@ -0,0 +1,33 @@ + +#ifndef _Fmodes_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Fmodes_h 1 + +enum io_mode // known unix file IO modes +{ + io_readonly = 0, + io_writeonly = 1, + io_readwrite = 2, + io_appendonly = 3, + io_append = 4, // append, plus allow reads +}; + +enum access_mode // ways to open a file +{ + a_createonly = 0, // create, fail if file exists + a_create = 1, // create if doesn't exist, else truncate + a_useonly = 2, // use (no truncate) fail if doesn't exist + a_use = 3, // use (no truncate), create if doesn't exist +}; + +enum state_value // File states +{ + _good = 0, // all is well + _eof = 1, // at eof + _fail = 2, // logical or physical IO error + _bad = 4 // unopened/corrupted +}; + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/Makefile.in b/gnu/lib/libg++/libg++/old-stream/Makefile.in new file mode 100644 index 00000000000..0e1772db13a --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/Makefile.in @@ -0,0 +1,33 @@ +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +OBJS = File.o PlotFile.o Filebuf.o SFile.o \ + filebuf.o form.o istream.o itoa.o ostream.o streambuf.o + +# The following include files are publicly visible, and +# should be installed where user programs can find them. + +USER_INCLUDES = File.h Filebuf.h Fmodes.h PlotFile.h SFile.h \ + filebuf.h istream.h ostream.h stream.h streambuf.h + +# The following include files are private to the implementation. + +INTERNAL_INCLUDES = + +DEPEND_SOURCES = $(srcdir)/*.c $(srcdir)/*.cc + +$(TARGETLIB): $(OBJS) + $(AR) $(AR_FLAGS) $(TARGETLIB) $(OBJS) + $(RANLIB) $(TARGETLIB) + +install-include-files: + if [ ! -d $(IDIR) ] ; then mkdir $(IDIR) ; fi + cd $(srcdir); \ + for FILE in $(USER_INCLUDES) ; do \ + rm -f $(IDIR)/$$FILE; \ + $(INSTALL_DATA) $$FILE $(IDIR)/$$FILE ; \ + chmod 0444 $(IDIR)/$$FILE; \ + echo $(IDIR)/$$FILE installed; \ + done diff --git a/gnu/lib/libg++/libg++/old-stream/PlotFile.cc b/gnu/lib/libg++/libg++/old-stream/PlotFile.cc new file mode 100644 index 00000000000..feb82a27ab4 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/PlotFile.cc @@ -0,0 +1,181 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +/* + PlotFile implementation module +*/ + + +PlotFile:: PlotFile() {} +PlotFile::~PlotFile() {} + + +PlotFile::PlotFile(const char* filename, io_mode m, access_mode a) +:(filename, m, a) {} + +PlotFile::PlotFile(const char* filename) +:(filename, io_writeonly, a_create) {} + +PlotFile::PlotFile(const char* filename, const char* m) +:(filename, m) {} + +PlotFile::PlotFile(int filedesc, const io_mode m) +:(filedesc, m) {} + +PlotFile::PlotFile(FILE* fileptr) +:(fileptr) {} + +PlotFile::operator void*() +{ + return (state & (_bad|_fail))? 0 : this ; +} + + +PlotFile& PlotFile::open(const char* filename, + io_mode m, access_mode a) +{ + File::open(filename, m, a); return *this; +} + +PlotFile& PlotFile::open(const char* filename, const char* m) +{ + File::open(filename, m); return *this; +} + +PlotFile& PlotFile::open(int filedesc, io_mode m) +{ + File::open(filedesc, m); return *this; +} + +PlotFile& PlotFile::open(FILE* fileptr) +{ + File::open(fileptr); return *this; +} + +PlotFile& PlotFile::setbuf(const int buffer_kind) +{ + File::setbuf(buffer_kind); return *this; +} + +PlotFile& PlotFile::setbuf(const int size, char* buf) +{ + File::setbuf(size, buf); return *this; +} + + +PlotFile& PlotFile:: cmd(char c) +{ + File::put(c); + return *this; +} + +PlotFile& PlotFile:: operator<<(const int x) +{ +#if defined(convex) + File::put((char)(x>>8)); + File::put((char)(x&0377)); +#else + File::put((char)(x&0377)); + File::put((char)(x>>8)); +#endif + return *this; +} + +PlotFile& PlotFile:: operator<<(const char *s) +{ + File::put(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/gnu/lib/libg++/libg++/old-stream/PlotFile.h b/gnu/lib/libg++/libg++/old-stream/PlotFile.h new file mode 100644 index 00000000000..ffe2b31ad3e --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/PlotFile.h @@ -0,0 +1,149 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + a very simple implementation of a class to output unix "plot" + format plotter files. See corresponding unix man pages for + more details. +*/ + +#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. +*/ + + +class PlotFile : private File +{ +protected: + PlotFile& cmd(char c); + PlotFile& operator << (const int x); + PlotFile& operator << (const char *s); + +public: + + PlotFile(); + PlotFile(const char* filename); + PlotFile(const char* filename, io_mode m, access_mode a); + PlotFile(const char* filename, const char* m); + PlotFile(int filedesc, const io_mode m = io_writeonly); + PlotFile(FILE* fileptr); + + ~PlotFile(); + + operator void*(); + + PlotFile& close() { File::close(); return *this; } + PlotFile& remove() { File::remove(); return *this; } + + int filedesc() { return File::filedesc(); } + const char* name() { return File::name(); } + void setname(const char* newname) { File::setname(newname); } + int iocount() { return File::iocount(); } + + int rdstate() { return File::rdstate(); } + int eof() { return File::eof(); } + int fail() { return File::fail(); } + int bad() { return File::bad(); } + int good() { return File::good(); } + + // other status queries + + int readable() { return File::readable(); } + int writable() { return File::writable(); } + int is_open() { return File::is_open(); } + + void error() { File::error(); } + void clear(state_value f = _good) { File::clear(f); } + void set(state_value f) { File::set(f); } + void unset(state_value f) { File::unset(f); } + PlotFile& failif(int cond) { File::failif(cond); return *this; } + void check_state() { File::check_state(); } + + PlotFile& raw() { File::raw(); return *this; } + + PlotFile& open(const char* filename, io_mode m, access_mode a); + PlotFile& open(const char* filename, const char* m); + PlotFile& open(int filedesc, io_mode m); + PlotFile& open(FILE* fileptr); + PlotFile& setbuf(const int buffer_kind); // vals: _IONBF, _IOFBF, _IOLBF + PlotFile& setbuf(const int size, char* buf); + + 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); +}; + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gnu/lib/libg++/libg++/old-stream/SFile.cc b/gnu/lib/libg++/libg++/old-stream/SFile.cc new file mode 100644 index 00000000000..a9e4bcaf51e --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/SFile.cc @@ -0,0 +1,48 @@ +/* +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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +SFile::SFile() {} +SFile::~SFile() {} + +SFile::SFile(const char* filename, int size, io_mode m, access_mode a) +: (filename, m, a) +{ + sz = size; +} + +SFile::SFile(const char* filename, int size, const char* m) +: (filename, m) +{ + sz = size; +} + +SFile::SFile(int filedesc, int size, io_mode m) +: (filedesc, m) +{ + sz = size; +} + +SFile::SFile(FILE* fileptr, int size) +: (fileptr) +{ + sz = size; +} diff --git a/gnu/lib/libg++/libg++/old-stream/SFile.h b/gnu/lib/libg++/libg++/old-stream/SFile.h new file mode 100644 index 00000000000..077cdff7682 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/SFile.h @@ -0,0 +1,82 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _SFile_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SFile_h 1 + +#include + +class SFile: public File +{ +protected: + int sz; // unit size for structured binary IO + +public: + SFile(); + SFile(const char* filename, int size, io_mode m, access_mode a); + SFile(const char* filename, int size, const char* m); + SFile(int filedesc, int size, io_mode m); + SFile(FILE* fileptr, int size); + + ~SFile(); + + int size(); + int setsize(int s); + + SFile& get(void* x); + SFile& put(void* x); + SFile& operator[](long i); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + + +inline int SFile::size() +{ + return sz; +} + +inline int SFile::setsize(int s) +{ + int old = sz; + sz = s; + return old; +} + +inline SFile& SFile::get(void* x) +{ + read(x, sz, 1); return *this; +} + +inline SFile& SFile::put(void* x) +{ + write(x, sz, 1); return *this; +} + +inline SFile& SFile::operator[](long i) +{ + seek(i * sz, 0); return *this; +} + + +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/configure.in b/gnu/lib/libg++/libg++/old-stream/configure.in new file mode 100644 index 00000000000..63fc79826a7 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/configure.in @@ -0,0 +1,25 @@ +# 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. + +configdirs="" +srctrigger=Filebuf.cc +srcname="old streams" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +ALL='$(NOTHING)' +TARGETLIB=libstream.a + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/old-stream/depend b/gnu/lib/libg++/libg++/old-stream/depend new file mode 100644 index 00000000000..0a6cc40afab --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/depend @@ -0,0 +1,50 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +File.o : File.cc \ + File.h \ + Fmodes.h +Filebuf.o : Filebuf.cc \ + Filebuf.h \ + File.h \ + Fmodes.h \ + streambuf.h +PlotFile.o : PlotFile.cc \ + PlotFile.h \ + File.h \ + Fmodes.h +SFile.o : SFile.cc \ + SFile.h \ + File.h \ + Fmodes.h +filebuf.o : filebuf.cc \ + filebuf.h \ + streambuf.h \ + Fmodes.h +form.o : form.cc +istream.o : istream.cc \ + stream.h \ + ostream.h \ + File.h \ + Fmodes.h \ + streambuf.h \ + filebuf.h \ + Filebuf.h \ + istream.h +itoa.o : itoa.cc +ostream.o : ostream.cc \ + stream.h \ + ostream.h \ + File.h \ + Fmodes.h \ + streambuf.h \ + filebuf.h \ + Filebuf.h \ + istream.h +streambuf.o : streambuf.cc \ + streambuf.h \ + Fmodes.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/old-stream/filebuf.cc b/gnu/lib/libg++/libg++/old-stream/filebuf.cc new file mode 100644 index 00000000000..c85a57607f1 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/filebuf.cc @@ -0,0 +1,137 @@ +/* +Copyright (C) 1990 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#if 1 +#ifdef __GNUG__ +#pragma implementation +#endif +#endif + +#include +#include // needed to determine values of O_RDONLY... +#include + +filebuf::filebuf() + :streambuf(), fd(-1), opened(0) {} + +filebuf::filebuf(int newfd) + : streambuf(), fd(newfd), opened(1) {} + +filebuf::filebuf(int newfd, char* buf, int buflen) + : streambuf(buf, buflen), fd(newfd), opened(1) {} + +int filebuf::is_open() +{ + return opened; +} + +int filebuf::close() +{ + int was = opened; + if (was) ::close(fd); + opened = 0; + return was; +} + +streambuf* filebuf::open(const char* name, open_mode m) +{ + if (opened) return 0; + int mode = -1; // any illegal value + switch (m) + { + case input: mode = O_RDONLY; + break; + case output: mode = O_WRONLY | O_CREAT | O_TRUNC; + break; + case append: mode = O_APPEND | O_CREAT | O_WRONLY; + break; + } + fd = ::open(name, mode, 0666); + if (opened = (fd >= 0)) + { + allocate(); + return this; + } + else + return 0; +} + + +streambuf* filebuf::open(const char* filename, io_mode m, access_mode a) +{ + return 0; +} + +streambuf* filebuf::open(const char* filename, const char* m) +{ + return 0; +} + +streambuf* filebuf::open(int filedesc, io_mode m) +{ + return 0; +} + +streambuf* filebuf::open(FILE* fileptr) +{ + return 0; +} + +int filebuf::underflow() +{ + if (!opened) return EOF; + if (base == 0) allocate(); + int nwanted = eptr - base + 1; + int nread = ::read(fd, base, nwanted); + if (nread >= 0) + { + gptr = base; + pptr = base + nread; + } + return (nread <= 0)? EOF : int(*gptr); +} + +int filebuf::overflow(int ch) +{ + if (!opened) return EOF; + if (base == 0) allocate(); + if (ch != EOF) // overflow *must* be called before really full + *pptr++ = (char)(ch); + + // loop, in case write can't handle full request + // From: Rene' Seindal + + int w, n, t; + for (w = t = 0, n = pptr - base; n > 0; n -= w, t += w) + { + if ((w = ::write(fd, base + t, n)) < 0) + break; + } + + pptr = base; + return (n == 0 && w >= 0)? 0 : EOF; +} + +filebuf::~filebuf() +{ + close(); +} diff --git a/gnu/lib/libg++/libg++/old-stream/filebuf.h b/gnu/lib/libg++/libg++/old-stream/filebuf.h new file mode 100644 index 00000000000..7b7646758f3 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/filebuf.h @@ -0,0 +1,61 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _filebuf_h +#ifdef __GNUG__ +#if (__GNUG__ == 1) +#pragma once +#endif +#pragma interface +#endif +#define _filebuf_h 1 + +#include +#include + +class filebuf: public streambuf +{ +public: + int fd; + char opened; + + int overflow(int c = EOF); + int underflow(); + + filebuf(); + filebuf(int newfd); + filebuf(int newfd, char* buf, int buflen); + + ~filebuf(); + + streambuf* open(const char* name, open_mode m); + streambuf* open(const char* filename, io_mode m, access_mode a); + streambuf* open(const char* filename, const char* m); + streambuf* open(int filedesc, io_mode m); + streambuf* open(FILE* fileptr); + int is_open(); + int close(); +}; + + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/form.cc b/gnu/lib/libg++/libg++/old-stream/form.cc new file mode 100644 index 00000000000..ae373ed13d4 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/form.cc @@ -0,0 +1,56 @@ +/* +Copyright (C) 1990 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include + +extern AllocRing _libgxx_fmtq; + +char* form(const char* fmt ...) +{ + va_list args; + va_start(args, fmt); + char* fmtbase = (char *) _libgxx_fmtq.alloc(BUFSIZ); +#ifndef HAVE_VPRINTF + FILE b; +#ifdef VMS + b->_flag = _IOWRT|_IOSTRG; + b->_ptr = fmtbase; + b->_cnt = BUFSIZ-1; +#else + b._flag = _IOWRT|_IOSTRG; + b._ptr = fmtbase; + b._cnt = BUFSIZ-1; +#endif + _doprnt(fmt, args, &b); + putc('\0', &b); +#else + vsprintf(fmtbase, fmt, args); +#endif + va_end(args); + return fmtbase; +} diff --git a/gnu/lib/libg++/libg++/old-stream/istream.cc b/gnu/lib/libg++/libg++/old-stream/istream.cc new file mode 100644 index 00000000000..b158f954f9e --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/istream.cc @@ -0,0 +1,503 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include + + +istream::istream(streambuf* s, int sk, ostream* t) + : bp(s), state(_good), skipws(sk), tied_to(t), ownbuf(0) {} + +istream::istream(int sz, char* buf, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new streambuf; + if (buf == 0) + { + bp->alloc = 1; + buf = new char[sz]; + } + else + bp->alloc = 0; + + bp->setbuf(buf, sz, sz); +} + +istream::~istream() +{ + if (ownbuf) delete bp; +} + +istream::istream(const char* filename, io_mode m, access_mode a, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new Filebuf(filename, m, a); +} + +istream::istream(const char* filename, const char* m, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new Filebuf(filename, m); +} + +istream::istream(int filedesc, io_mode m, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new Filebuf(filedesc, m); +} + +istream::istream(FILE* fileptr, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new Filebuf(fileptr); + +} + +istream::istream(int filedesc, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new filebuf(filedesc); +} + +istream::istream(int filedesc, char* buf, int buflen, int sk, ostream* t) + : state(_good), skipws(sk), tied_to(t), ownbuf(1) +{ + bp = new filebuf(filedesc, buf, buflen); +} + +istream& istream::open(const char* filename, io_mode m, access_mode a) +{ + return failif(bp->open(filename, m, a) == 0); +} + +istream& istream::open(const char* filename, const char* m) +{ + return failif(bp->open(filename, m) == 0); +} + +istream& istream::open(int filedesc, io_mode m) +{ + return failif(bp->open(filedesc, m) == 0); +} + +istream& istream::open(FILE* fileptr) +{ + return failif(bp->open(fileptr) == 0); +} + +istream& istream::open(const char* filenam, open_mode m) +{ + return failif(bp->open(filenam, m) == 0); +} + +istream& istream::get(char& c) +{ + if (good()) + { + if(tied_to != 0) tied_to->flush(); + int ch = bp->sgetc(); + if (ch == EOF) + set(_eof); + else + { + c = ch; + bp->stossc(); + } + } + return *this; +} + + +istream& istream::operator >> (whitespace&) +{ + if (good()) + { + int ch; + if(tied_to != 0) tied_to->flush(); + while (((ch = bp->sgetc()) != EOF) && isspace(ch)) bp->stossc(); + if (ch == EOF) set(_eof); + } + return *this; +} + + +istream& istream::operator >> (char& c) +{ + if (skipws) (*this >> WS); + return get(c); +} + +istream& istream::get(char* s, int n, char terminator) +{ + if (!readable()) + { + set(_fail); + return *this; + } + + char ch = 0; + char* start = s; + if (--n > 0 && get(ch)) + { + if (ch == terminator) + unget(ch); + else + { + *s++ = ch; --n; + while (n-- > 0 && get(ch)) + { + if (ch == terminator) + { + unget(ch); + break; + } + else + *s++ = ch; + } + } + } + + *s = 0; + if (s != start) clear(); + return *this; +} + + +istream& istream::operator >> (char* s) +{ + if (!readable() || s == 0) + { + set(_fail); + return *this; + } + + if (skipws && !(*this >> WS)) return *this; + + char ch; + char* start = s; + if (get(ch)) + { + *s++ = ch; + while (get(ch)) + { + if (isspace(ch)) + { + unget(ch); + break; + } + else + *s++ = ch; + } + } + + *s = 0; + if (s != start) clear(); + return *this; +} + + +istream& istream::getline(char* s, int n, char terminator) +{ + if (!readable()) + { + set(_fail); + return *this; + } + char* start = s; + char ch; + while (--n > 0 && get(ch) && ((*s++ = ch) != terminator)); + + *s = 0; + if (s != start) clear(); + return *this; +} + +// from Doug Schmidt + +// This should probably be a page size.... +#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 *istream::readline (int chunk_number, char terminator) +{ + char buf[CHUNK_SIZE]; + register char *bufptr = buf; + register char *ptr; + char ch; + int continu; + + while ((continu = !!get(ch)) && ch != terminator) /* fill the current buffer */ + { + *bufptr++ = ch; + if (bufptr - buf >= CHUNK_SIZE) /* prepend remainder to ptr buffer */ + { + if (ptr = readline (chunk_number + 1, terminator)) + + for (; bufptr != buf; *--ptr = *--bufptr); + + return ptr; + } + } + if (!continu && bufptr == buf) + return NULL; + + int size = (chunk_number * CHUNK_SIZE + bufptr - buf) + 1; + + if (ptr = new char[size]) + { + + for (*(ptr += (size - 1)) = '\0'; bufptr != buf; *--ptr = *--bufptr) + ; + + return ptr; + } + else + return NULL; +} + +/* 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 terminator) +{ + return failif(!readable() || !(*s = readline (0, terminator))); +} + +istream& istream::operator >> (long& y) +{ + if (!readable()) + { + set(_bad); + return *this; + } + + int got_one = 0; + char sgn = 0; + char ch; + y = 0; + if (skipws) *this >> WS; + if (!good()) + { + set(_bad); + return *this; + } + while (get(ch)) + { + if (ch == '-') + { + if (sgn == 0 && got_one == 0) + sgn = '-'; + else + break; + } + else if (ch >= '0' && ch <= '9') + y = y * 10 + ((got_one = ch) - '0'); + else + break; + } + if (good()) + unget(ch); + if (!got_one) + set(_bad); + else + clear(); + + if (sgn == '-') + y = -y; + + return *this; +} + +istream& istream::operator >> (unsigned long& y) +{ + if (!readable()) + { + set(_bad); + return *this; + } + + int got_one = 0; + char ch; + y = 0; + if (skipws) *this >> WS; + if (!good()) + while (get(ch)) + { + if (ch >= '0' && ch <= '9') + y = y * 10 + ((got_one = ch) - '0'); + else + break; + } + if (good()) + unget(ch); + if (!got_one) + set(_bad); + else + clear(); + return *this; +} + + +/* for input to a double, we must trust atof (cannot even use +the better strtod since it is not universally supported). So +guaranteed legal chars are gathered up into an obstack. The +only possible, undiagnosable error is that the input number +might give a floating overflow or underflow inside atof. +I know of no way to avoid this */ + +extern Obstack _libgxx_io_ob; + +istream& istream::operator >> (double & y) +{ + if (!readable()) + { + set(_bad); + return *this; + } + + + char seenint = 0; + char seendec = 0; + char seenexp = 0; + char seensgn = 0; + char seene = 0; + char seenexpsgn = 0; + char seendot = 0; + char ch; + + if (skipws) *this >> WS; + if (!good()) + { + set(_bad); + return *this; + } + while (get(ch)) + { + if (ch == '-' || ch == '+') + { + if (seene && !seenexpsgn) + _libgxx_io_ob.grow(seenexpsgn = ch); + else if (!seensgn && !seenint) + _libgxx_io_ob.grow(seensgn = ch); + else + break; + } + else if (ch == '.' && !seendot) + { + _libgxx_io_ob.grow(seendot = ch); + } + else if ((ch == 'e' || ch == 'E') && !seene) + { + _libgxx_io_ob.grow(seene = ch); + } + else if (ch >= '0' && ch <= '9') + { + _libgxx_io_ob.grow(ch); + if (seene) seenexp = ch; + else if (seendot) seendec = ch; + else seenint = ch; + } + else + break; + } + char* str = (char *) _libgxx_io_ob.finish(0); + if (good()) + unget(ch); + if ((seenint || seendec) && (!seene || seenexp)) + y = atof(str); + else + set(_bad); + _libgxx_io_ob.free(str); + return *this; +} + +istream& istream::operator >> (int& y) +{ + long l; (*this >> l); y = int(l); return *this; +} + +istream& istream:: operator >> (unsigned int& y) +{ + long l; (*this >> l); y = (unsigned int)(l); return *this; +} + +istream& istream:: operator >> (short& y) +{ + long l; (*this >> l); y = short(l); return *this; +} + +istream& istream:: operator >> (unsigned short& y) +{ + long l; (*this >> l); y = (unsigned short)(l); return *this; +} + +istream& istream:: operator >> (float& y) +{ + double d; (*this >> d); y = float(d); return *this; +} + +const char* istream::name() +{ + return bp->name(); +} + +void istream::error() +{ + bp->error(); +} + +ostream* istream::tie(ostream* s) +{ + ostream* was = tied_to; tied_to = s; return was; +} + +void istream::_flush() +{ + if(tied_to != 0) tied_to->flush(); +} + + +//-------------------------------------------------------------- + +extern ostream cout; + +#ifndef DEFAULT_filebuf + +istream cin(stdin, 1, &cout); + +#else + +static char cinbuf[BUFSIZE]; +istream cin (0, cinbuf, BUFSIZE, 1, &cout); + +#endif + +whitespace WS; +whitespace ws; diff --git a/gnu/lib/libg++/libg++/old-stream/istream.h b/gnu/lib/libg++/libg++/old-stream/istream.h new file mode 100644 index 00000000000..42d6e1e2bf8 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/istream.h @@ -0,0 +1,254 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ + +/* istream.h now separately includable */ + +#ifndef _istream_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _istream_h 1 + + +#include +#include +#include +#include + +class whitespace // a class used only to input and +{ // discard white space characters + char filler; +}; + +class ostream; + +class istream +{ + friend void eatwhite(istream& s); +protected: + streambuf* bp; + state_value state; // _good/_eof/_fail/_bad + ostream* tied_to; + char skipws; + char ownbuf; + void _flush(); + char* readline (int chunk_number, char terminator); + +public: + istream(const char* filename, io_mode m, access_mode a, + int sk=1, ostream* t = 0); + istream(const char* filename, const char* m, + int sk=1, ostream* t = 0); + istream(int filedesc, io_mode m, int sk=1, ostream* t = 0); + istream(FILE* fileptr, int sk=1, ostream* t = 0); + istream(int sz, char* buf, int sk=1, ostream* t = 0); + istream(int filedesc, int sk=1, ostream* t = 0); + istream(int filedesc, char* buf, int buflen, + int sk, ostream* t = 0); + istream(streambuf* s, int sk=1, ostream* t = 0); + + ~istream(); + + istream& open(const char* filename, io_mode m, access_mode a); + istream& open(const char* filename, const char* m); + istream& open(int filedesc, io_mode m); + istream& open(FILE* fileptr); + istream& open(const char* filenam, open_mode m); + + istream& close(); + + ostream* tie(ostream* s); + int skip(int); + +// stream status + + int rdstate(); + int eof(); + int fail(); + int bad(); + int good(); + +// other status queries + + int readable(); + int writable(); + int is_open(); + + operator void*(); + int operator !(); + + const char* name(); + + char* bufptr(); + +// error handling + + void error(); + void clear(state_value f = _good); // poorly named + void set(state_value f); // set corresponding bit + void unset(state_value f); // clear corresponding bit + istream& failif(int cond); + +// unformatted IO + + istream& get(char& c); + istream& unget(char c); + istream& putback(char c); // a synonym for unget + + istream& get (char* s, int n, char terminator = '\n'); + istream& getline(char* s, int n, char terminator = '\n'); + istream& gets (char **s, char terminator = '\n'); + + + istream& operator >> (char& c); + istream& operator >> (short& n); + istream& operator >> (unsigned short& n); + istream& operator >> (int& n); + istream& operator >> (unsigned int& n); + istream& operator >> (long& n); + istream& operator >> (unsigned long& n); +#ifdef __GNUG__ + istream& operator >> (long long& n); + istream& operator >> (unsigned long long& n); +#endif + istream& operator >> (float& n); + istream& operator >> (double& n); + istream& operator >> (char* s); + istream& operator >> (whitespace& w); +}; + +// pre-declared streams + +extern istream cin; // stdin + +extern whitespace WS; // for convenience (Old name) +extern whitespace ws; // for convenience (iostream-style name) + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + + +inline void istream::clear(state_value flag) +{ + state = flag; +} + +inline void istream::set(state_value flag) +{ + state = state_value(int(state) | int(flag)); +} + +inline void istream::unset(state_value flag) +{ + state = state_value(int(state) & ~int(flag)); +} + +inline int istream::rdstate() +{ + return int(state); +} + +inline int istream::good() +{ + return state == _good; +} + +inline int istream::eof() +{ + return int(state) & int(_eof); +} + +inline int istream::fail() +{ + return int(state) & int(_fail); +} + +inline int istream::bad() +{ + return int(state) & int(_bad); +} + +inline istream::operator void*() +{ + return (state == _good)? this : 0; +} + +inline int istream::operator !() +{ + return (state != _good); +} + +inline istream& istream::failif(int cond) +{ + if (cond) set(_fail); return *this; +} + +inline int istream::is_open() +{ + return bp->is_open(); +} + +inline int istream::readable() +{ + return (bp != 0) && (bp->is_open()) && (state == _good); +} + +inline int istream::writable() +{ + return 0; +} + + +inline char* istream::bufptr() +{ + return bp->base; +} + + +inline istream& istream::close() +{ + bp->close(); return *this; +} + + +inline int istream::skip(int sk) +{ + int was = skipws; skipws = sk; return was; +} + + +inline istream& istream::unget(char c) +{ + if (bp->sputbackc(c) == EOF) set(_fail); return *this; +} + +inline istream& istream::putback(char c) +{ + if (bp->sputbackc(c) == EOF) set(_fail); return *this; +} + +inline void eatwhite(istream& s) +{ + s >> WS; +} + +#endif + + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/itoa.cc b/gnu/lib/libg++/libg++/old-stream/itoa.cc new file mode 100644 index 00000000000..162dbb923dc --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/itoa.cc @@ -0,0 +1,251 @@ +/* +Copyright (C) 1990 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include + +extern AllocRing _libgxx_fmtq; + +char* itoa(long x, int base, int width) +{ + int wrksiz; + if (base == 10) + wrksiz = width + 13; + else + wrksiz = (BITS(long) + 1) / lg(base) + 1 + width + 1; + + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* e = fmtbase + wrksiz - 1; + char* s = e; + *--s = 0; + char sgn = 0; + + if (x == 0) + *--s = '0'; + else + { + unsigned int z; + if (x < 0) + { + sgn = '-'; + z = -x; + } + else + z = x; + while (z != 0) + { + char ch = char(z % base); + z = z / base; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + } + + if (sgn) *--s = sgn; + int w = e - s - 1; + while (w++ < width) + *--s = ' '; + return s; +} + +char* itoa(unsigned long x, int base, int width) +{ + int wrksiz; + if (base == 10) + wrksiz = width + 13; + else + wrksiz = (BITS(long) + 1) / lg(base) + 1 + width + 1; + + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* e = fmtbase + wrksiz - 1; + char* s = e; + *--s = 0; + + if (x == 0) + *--s = '0'; + else + { + unsigned int b = base; + while (x != 0) + { + char ch = char(x % b); + x = x / b; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + } + + int w = e - s - 1; + while (w++ < width) + *--s = ' '; + return s; +} + +#ifdef __GNUG__ +#ifndef VMS +char* itoa(long long x, int base, int width) +{ + int wrksiz; + if (base == 10) + wrksiz = width + 23; + else + wrksiz = (BITS(long long) + 1) / lg(base) + 1 + width + 1; + + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* e = fmtbase + wrksiz - 1; + char* s = e; + *--s = 0; + char sgn = 0; + + if (x == 0) + *--s = '0'; + else + { + long long z; + if (x < 0) + { + sgn = '-'; + z = -x; + } + else + z = x; + while (z != 0) + { + char ch = char(z % base); + z = z / base; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + } + + if (sgn) *--s = sgn; + int w = e - s - 1; + while (w++ < width) + *--s = ' '; + return s; +} + +char* itoa(unsigned long long x, int base, int width) +{ + int wrksiz; + if (base == 10) + wrksiz = width + 23; + else + wrksiz = (BITS(long long) + 1) / lg(base) + 1 + width + 1; + + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* e = fmtbase + wrksiz - 1; + char* s = e; + *--s = 0; + + if (x == 0) + *--s = '0'; + else + { + unsigned int b = base; + while (x != 0) + { + char ch = char(x % b); + x = x / b; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + } + + int w = e - s - 1; + while (w++ < width) + *--s = ' '; + return s; +} +#endif +#endif + +char* hex(long i, int width) +{ + return itoa(i, 16, width); +} + +char* oct(long i, int width) +{ + return itoa(i, 8, width); +} + +char* dec(long i, int width) +{ + return itoa(i, 10, width); +} + +char* hex(unsigned long i, int width) +{ + return itoa(i, 16, width); +} + +char* oct(unsigned long i, int width) +{ + return itoa(i, 8, width); +} + +char* dec(unsigned long i, int width) +{ + return itoa(i, 10, width); +} + +// The following functions used to be inline in builtin.h, but +// the definitions there clashed with those in iostream/stream.C. +// Since people aren't supposed to be using these functions in +// any case, there is no reason to make them inline. + +char* hex(int x, int width = 0) { return hex(long(x), width); } +char* hex(short x, int width = 0) { return hex(long(x), width); } +char* hex(unsigned int x, int width = 0) +{ return hex((unsigned long)(x), width); } +char* hex(unsigned short x, int width = 0) +{ return hex((unsigned long)(x), width); } + +char* oct(int x, int width = 0) { return oct(long(x), width); } +char* oct(short x, int width = 0) { return oct(long(x), width); } +char* oct(unsigned int x, int width = 0) +{ return oct((unsigned long)(x), width); } +char* oct(unsigned short x, int width = 0) +{ return oct((unsigned long)(x), width); } + +char* dec(int x, int width = 0) { return dec(long(x), width); } +char* dec(short x, int width = 0) { return dec(long(x), width); } +char* dec(unsigned int x, int width = 0) +{ return dec((unsigned long)(x), width); } +char* dec(unsigned short x, int width = 0) +{ return dec((unsigned long)(x), width); } diff --git a/gnu/lib/libg++/libg++/old-stream/ostream.cc b/gnu/lib/libg++/libg++/old-stream/ostream.cc new file mode 100644 index 00000000000..b90b620a328 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/ostream.cc @@ -0,0 +1,219 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include + +ostream::ostream(streambuf* s) + : bp(s), state(_good), ownbuf(0) {} + +ostream::ostream(int sz, char* buf) + : state(_good), ownbuf(1) +{ + if (buf == 0) + { + buf = new char[sz]; + bp = new streambuf(buf, sz); + bp->setbuf(buf, sz); + bp->alloc = 1; + } + else + { + bp = new streambuf(buf, sz); + bp->alloc = 0; + } +} + + +ostream::ostream(const char* filename, io_mode m, access_mode a) + : state(_good), ownbuf(1) +{ + bp = new Filebuf(filename, m, a); +} + +ostream::ostream(const char* filename, const char* m) + : state(_good), ownbuf(1) +{ + bp = new Filebuf(filename, m); +} + +ostream::ostream(int filedesc, io_mode m) + : state(_good), ownbuf(1) +{ + bp = new Filebuf(filedesc, m); +} + +ostream::ostream(FILE* fileptr) + : state(_good), ownbuf(1) +{ + bp = new Filebuf(fileptr); +} + +ostream::ostream(int filedesc) + : state(_good), ownbuf(1) +{ + bp = new filebuf(filedesc); +} + +ostream::ostream(int filedesc, char* buf, int buflen) + : state(_good), ownbuf(1) +{ + bp = new filebuf(filedesc, buf, buflen); +} + +ostream::~ostream() +{ + if (ownbuf) delete bp; +} + +ostream& ostream::open(const char* filename, io_mode m, access_mode a) +{ + return failif(bp->open(filename, m, a) == 0); +} + +ostream& ostream::open(const char* filename, const char* m) +{ + return failif(bp->open(filename, m) == 0); +} + +ostream& ostream::open(int filedesc, io_mode m) +{ + return failif(bp->open(filedesc, m) == 0); +} + +ostream& ostream::open(FILE* fileptr) +{ + return failif(bp->open(fileptr) == 0); +} + +ostream& ostream::open(const char* filenam, open_mode m) +{ + return failif(bp->open(filenam, m) == 0); +} + +ostream& ostream::form(const char* fmt...) +{ + va_list args; + va_start(args, fmt); + char buf[BUFSIZ]; +#ifndef HAVE_VPRINTF + FILE b; + b._flag = _IOWRT|_IOSTRG; + b._ptr = buf; + b._cnt = BUFSIZ; + _doprnt(fmt, args, &b); + putc('\0', &b); +#else + vsprintf(buf, fmt, args); +#endif + va_end(args); + return put(buf); +} + +ostream& ostream::operator<<(short n) +{ + return put(itoa(long(n))); +} + +ostream& ostream::operator<<(unsigned short n) +{ + return put(itoa((unsigned long)(n))); +} + +ostream& ostream::operator<<(int n) +{ + return put(itoa(long(n))); +} + +ostream& ostream::operator<<(unsigned int n) +{ + return put(itoa((unsigned long)(n))); +} + +ostream& ostream::operator<<(long n) +{ + return put(itoa(n)); +} + +ostream& ostream::operator<<(unsigned long n) +{ + return put(itoa(n)); +} + +#ifdef __GNUG__ +#ifndef VMS +ostream& ostream::operator<<(long long n) +{ + return put(itoa(n)); +} + +ostream& ostream::operator<<(unsigned long long n) +{ + return put(itoa(n)); +} +#endif +#endif +ostream& ostream::operator<<(float n) +{ + return put(dtoa(double(n))); +} + +ostream& ostream::operator<<(double n) +{ + return put(dtoa(n)); +} + +ostream& ostream::operator<<(const void* p) +{ + put("0x"); + return put(itoa((unsigned long)(p), 16)); +} + + +const char* ostream::name() +{ + return bp->name(); +} + +void ostream::error() +{ + bp->error(); +} + +#ifndef DEFAULT_filebuf + +ostream cerr(stderr); +ostream cout(stdout); + +#else + +static char cerrbuf[1]; +static char coutbuf[BUFSIZE]; + +ostream cerr(2, cerrbuf, 1); +ostream cout(1, coutbuf, BUFSIZE); + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/ostream.h b/gnu/lib/libg++/libg++/old-stream/ostream.h new file mode 100644 index 00000000000..52fb2f1e442 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/ostream.h @@ -0,0 +1,250 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ + +/* ostream.h now separately includable */ + +#ifndef _ostream_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _ostream_h 1 + +/* uncomment the next line to disable ostream << char */ +//#define NO_OUTPUT_CHAR + + +#include +#include +#include +#include + +class istream; + +class ostream +{ + friend class istream; +protected: + streambuf* bp; + state_value state; // _good/_eof/_fail/_bad + char ownbuf; // true if we own *bp + +public: + ostream(const char* filename, io_mode m, access_mode a); + ostream(const char* filename, const char* m); + ostream(int filedesc, io_mode m); + ostream(FILE* fileptr); + ostream(int sz, char* buf); + ostream(int filedesc, char* buf, int buflen); + ostream(int filedesc); + ostream(streambuf* s); + + ~ostream(); + + ostream& open(const char* filename, io_mode m, access_mode a); + ostream& open(const char* filename, const char* m); + ostream& open(int filedesc, io_mode m); + ostream& open(FILE* fileptr); + ostream& open(const char* filenam, open_mode m); + + ostream& close(); + ostream& flush(); + +// stream status + + int rdstate(); + int eof(); + int fail(); + int bad(); + int good(); + +// other status queries + + int readable(); + int writable(); + int is_open(); + + operator void*(); + int operator !(); + + const char* name(); + + char* bufptr(); + +// error handling + + void error(); + void clear(state_value f = _good); // poorly named + void set(state_value f); // set corresponding bit + void unset(state_value); // clear corresponding bit + ostream& failif(int cond); + +// unformatted IO + + ostream& put(char c); + ostream& put(const char* s); + ostream& put(const char* s, int slen); + +// formatted IO + + ostream& form(const char* fmt, ...); + + ostream& operator << (short n); + ostream& operator << (unsigned short n); + ostream& operator << (int n); + ostream& operator << (unsigned int n); + ostream& operator << (long n); + ostream& operator << (unsigned long n); +#ifdef __GNUG__ + ostream& operator << (long long n); + ostream& operator << (unsigned long long n); +#endif /* __GNUG__ */ + ostream& operator << (float n); + ostream& operator << (double n); + ostream& operator << (const char* s); + ostream& operator << (const void* ptr); + +#ifndef NO_OUTPUT_CHAR + ostream& operator << (char c); +#endif + +}; + +extern ostream cout; // stdout +extern ostream cerr; // stderr + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + + +inline void ostream::clear(state_value flag) +{ + state = flag; +} + +inline void ostream::set(state_value flag) +{ + state = state_value(int(state) | int(flag)); +} + +inline void ostream::unset(state_value flag) +{ + state = state_value(int(state) & ~int(flag)); +} + +inline int ostream::rdstate() +{ + return int(state); +} + +inline int ostream::good() +{ + return state == _good; +} + +inline int ostream::eof() +{ + return int(state) & int(_eof); +} + +inline int ostream::fail() +{ + return int(state) & int(_fail); +} + +inline int ostream::bad() +{ + return int(state) & int(_bad); +} + +inline ostream::operator void*() +{ + return (state == _good)? this : 0; +} + +inline int ostream::operator !() +{ + return (state != _good); +} + +inline ostream& ostream::failif(int cond) +{ + if (cond) set(_fail); return *this; +} + +inline int ostream::is_open() +{ + return bp->is_open(); +} + +inline int ostream::readable() +{ + return 0; +} + +inline int ostream::writable() +{ + return (bp != 0) && (state == _good); +} + + +inline char* ostream::bufptr() +{ + return bp->base; +} + +inline ostream& ostream::flush() +{ + bp->overflow(); return *this; +} + +inline ostream& ostream::close() +{ + bp->overflow(); bp->close(); return *this; +} + +inline ostream& ostream::put(char ch) +{ + return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF); +} + +#ifndef NO_OUTPUT_CHAR +inline ostream& ostream::operator << (char ch) +{ + return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF); +} +#endif + +inline ostream& ostream::put(const char* s) +{ + return failif((state != _good) || bp->sputs(s) == EOF); +} + +inline ostream& ostream::put(const char* s, int len) +{ + return failif((state != _good) || bp->sputsn(s, len) == EOF); +} + +inline ostream& ostream::operator << (const char* s) +{ + return failif((state != _good) || bp->sputs(s) == EOF); +} + +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/stream.h b/gnu/lib/libg++/libg++/old-stream/stream.h new file mode 100644 index 00000000000..fa15b0b07a1 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/stream.h @@ -0,0 +1,12 @@ +/* ostream.h and istream.h now separately includable */ + +#ifndef _stream_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _stream_h 1 + +#include +#include + +#endif diff --git a/gnu/lib/libg++/libg++/old-stream/streambuf.cc b/gnu/lib/libg++/libg++/old-stream/streambuf.cc new file mode 100644 index 00000000000..05649c9683d --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/streambuf.cc @@ -0,0 +1,133 @@ +/* +Copyright (C) 1990 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + + +streambuf::streambuf() + :base(0), gptr(0), pptr(0), eptr(0), alloc(0) +{} + +streambuf::streambuf(char* buf, int buflen) + : base(buf), gptr(buf), pptr(buf), eptr(buf+buflen-1), alloc(0) +{} + +streambuf::~streambuf() +{ + if (alloc && (base != 0)) delete base; +} + +int streambuf::doallocate() +{ + if (alloc && base != 0) delete base; + base = new char[BUFSIZ]; + gptr = pptr = base; + eptr = base + BUFSIZ - 1; + alloc = 1; + return BUFSIZ; +} + +streambuf* streambuf::setbuf(char* buf, int buflen, int preloaded_count) +{ + if (alloc && (base != 0)) delete base; + alloc = 0; + base = gptr = buf; + pptr = base + preloaded_count; + eptr = base + buflen - 1; + return this; +} + +const char* streambuf::name() +{ + return 0; +} + +int streambuf::overflow(int c) +{ + if (base == 0) allocate(); + return (c == EOF)? c : ((pptr <= eptr)? (*pptr++ = (char)(c)) : EOF); +} + +int streambuf::underflow() +{ + return EOF; +} + +int streambuf::sputs(const char* s) +{ + if (s != 0) + { + for(; *s != 0; ++s) + { + if (must_overflow(*s)) { if (overflow(*s) == EOF) return EOF; } + else *pptr++ = *s; + } + } + return 0; +} + +int streambuf::sputsn(const char* s, int len) +{ + for(; --len >= 0; ++s) + { + if (must_overflow(*s)) { if (overflow(*s) == EOF) return EOF; } + else *pptr++ = *s; + } + return 0; +} + + +int streambuf::is_open() +{ + return 1; +} + +int streambuf::close() +{ + return 1; +} + +void streambuf::error() +{ + abort(); +} + +streambuf* streambuf::open(const char*, open_mode) +{ + return 0; +} + +streambuf* streambuf::open(const char*, io_mode, access_mode) +{ + return 0; +} +streambuf* streambuf::open(const char*, const char*) +{ + return 0; +} +streambuf* streambuf::open(int, io_mode) +{ + return 0; +} +streambuf* streambuf::open(FILE*) +{ + return 0; +} diff --git a/gnu/lib/libg++/libg++/old-stream/streambuf.h b/gnu/lib/libg++/libg++/old-stream/streambuf.h new file mode 100644 index 00000000000..9ae9538a4b3 --- /dev/null +++ b/gnu/lib/libg++/libg++/old-stream/streambuf.h @@ -0,0 +1,162 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _streambuf_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _streambuf_h 1 + +/* streambufs. + basic streambufs and filebufs are as in Stroustrup, ch 8, + but the base class contains virtual extensions that allow + most capabilities of libg++ Files to be used as streambufs + via `Filebufs'. +*/ + +#include +#include +#include + +// Flag used to distinguish old streams from new iostreams. +#define _OLD_STREAMS + +// see below for NO_LINE_BUFFER_STREAMBUFS + +#ifndef BUFSIZE +#ifdef BUFSIZ +#define BUFSIZE BUFSIZ +#else +#define BUFSIZE 1024 +#endif +#endif + +enum open_mode // filebuf open modes +{ + input=0, + output=1, + append=2 +}; + +class streambuf +{ +public: + char* base; // start of buffer + char* pptr; // put-pointer (and gptr fence) + char* gptr; // get-pointer + char* eptr; // last valid addr in buffer + + char alloc; // true if we own freestore alloced buffer + + streambuf(); + streambuf(char* buf, int buflen); + + virtual ~streambuf(); + + int doallocate(); + int allocate(); + + + int must_overflow(int ch); // true if should call overflow + + virtual int overflow(int c = EOF); // flush -- return EOF if fail + virtual int underflow(); // fill -- return EOF if fail + + int sgetc(); // get one char (as int) or EOF + int snextc(); // get and advance + void stossc(); // advance only + + int sputbackc(char); // unget + + int sputc(int c = EOF); // write one char + + virtual streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0); + // (not virtual in AT&T) + +// the following aren't in AT&T version: + + int sputs(const char* s); // write null-terminated str + int sputsn(const char* s, int len); // write len bytes + + virtual const char* name(); + + + virtual streambuf* open(const char* name, open_mode m); + virtual streambuf* open(const char* filename, io_mode m, access_mode a); + virtual streambuf* open(const char* filename, const char* m); + virtual streambuf* open(int filedesc, io_mode m); + virtual streambuf* open(FILE* fileptr); + + virtual int is_open(); + virtual int close(); + + virtual void error(); +}; + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + + +inline int streambuf::must_overflow(int ch) +{ +#ifndef NO_LINE_BUFFER_STREAMBUF + return pptr >= eptr || ch == '\n'; +#else + return pptr >= eptr; +#endif +} + + +inline int streambuf::allocate() +{ + return (base == 0)? doallocate() : 0; +} + +inline int streambuf::sgetc() +{ + return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr)); +} + + +inline int streambuf::snextc() +{ + ++gptr; + return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr)); +} + + +inline void streambuf::stossc() +{ + if (gptr >= pptr) underflow(); else gptr++; +} + + +inline int streambuf::sputbackc(char ch) +{ + return (gptr > base)? int((unsigned char)(*--gptr = ch)) : EOF; +} + +inline int streambuf::sputc(int ch) +{ + return must_overflow(ch)? overflow(ch) : + int((unsigned char)(*pptr++ = char(ch))); +} + +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/proto-kit/Makefile b/gnu/lib/libg++/libg++/proto-kit/Makefile new file mode 100644 index 00000000000..2b71e200926 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/Makefile @@ -0,0 +1,379 @@ +#****************************************************************************** +# This GNUmakefile is useful for large and complex projects which involve +# both G++ library prototypes, and prototypes added by the user(s). It +# is assumed that certain conventions are followed. +# +# 1) each object has its own source and header files. For example class W +# would have W.h and W.cc +# +# 2) each prototype object has its own source and header files (W.hP and W.ccP) +# +# 3) object header files are contained in directory $(IDIR) (for Include +# DIRectory) +# +# 4) object source files are contained in the current directory +# +# 5) prototype instantiations are contained in $(PC) (for Prototype C++ +# directory) +# +# 6) user prototype files (both header and source) are contained in $(IPP) +# +# 7) non-class code is contained in .h and .cc files, which live in $(IDIR) +# and the current directory respectively +# +# *) as an extra, I have added the convention that whenever a W.cc file +# is being compiled, the macro _W_cc is defined. This is useful +# particularly for conditional parts of header files (for example, +# W.h could have ifdef _W_cc ... +# +# The makefile works in the following manner: the source dependencies are +# contained in .Makefile.S_DEP, while the (machine generated) object +# dependencies are contained in .Makefile.O_DEP. The types needed by +# the program are defined by several variables, and the makefile generates +# the necessary dependencies (both source and object) from those variables. +# The prototype lists are contained in .Makefile.TYPES. +# +# NOTE: in order to create the machine generated files .Makefile.TYPES, +# .Makefile.S_DEP, and .Makefile.O_DEP, empty versions of these +# file must exist. They can be easily created using "touch ". +# +# -- Carl Staelin +# staelin@princeton.edu +#****************************************************************************** + +#****************************************************************************** +# standard Makefile definitions + +comma := , +space := $(empty) $(empty) +tab := $(empty) $(empty) + +#****************************************************************************** +# definitions from environment variables + +# the CPATH include directories +cpath-include-directories := $(addprefix -I, $(subst :,$(space),$(CPATH))) + +# the LPATH load directories +lpath-load-directories := $(addprefix -L, $(subst :,$(space),$(LPATH))) + +#****************************************************************************** +# Basic definitions + +HOST := $(shell hostname) + +BASE := + +# CMU Directories +USR := $(BASE)/usr +MACH := $(BASE)/usr/mach +CS := $(BASE)/usr/cs + +# GNU directories +GNULIBDIR := $(BASE)/usr/local/lib +GNUIDIR := $(GNULIBDIR)/g++-include + +# the g++ library prototypes... +LPP := $(GNUIDIR) +PC := ../libg++ + +# the user's library prototypes... +IPP := ../proto + +# the include directory +IDIR := ../include + +# the include directories needed... +IDIRS := -I$(IDIR) -I$(PC) -I$(GNUIDIR) $(cpath-include-directories) + +# the directories where the libraries live... +LDIRS := $(lpath-load-directories) + +#****************************************************************************** +# standard function (and associated variables) definitions + +C++ = g++ +C++FLAGS = -pipe -O $(IDIRS) + -Dc_plusplus \ + -DDEBUG \ + -D$(strip $(subst .,_, _$(basename $(@F))_cc)) + + +GENCLASS = ../bin/genclass.extnsn +PREPEND = ../bin/prepend +HIERARCHY = ../bin/hierarchy +MAKE_TYPES = ../bin/make-types +PROTOTYPE = ../bin/prototype + +#****************************************************************************** +# implicit rules + +%.o : %.cc + $(C++) $(C++FLAGS) \ + -c -o $@ $(@D)$(basename $(@F)).cc + +#****************************************************************************** +# User types + +BASIC_TYPES = \ + int \ + u_int \ + l_int \ + l_u_int + +# generated by this make file (initially create an empty .Makefile.TYPES +# so that "make dependencies" can create the real file) +include .Makefile.TYPES + +#****************************************************************************** +# User types (with sample values filled in) +# +# NOTE: do NOT add .h to the end of these, MAKE does it for you! + +HEADER_FILES = \ + disk_set \ + file_types \ + include \ + inode \ + inode_t \ + lib \ + main \ + nfs_functions \ + nfs_mount \ + nfs_params \ + nfs_prot \ + system + +SOURCE_FILES = \ + disk_set \ + lib \ + nfs_auxil \ + nfs_dirent \ + nfs_fh \ + nfs_ipcress \ + nfs_links \ + nfs_main \ + nfs_mnt_serv \ + nfs_mount_xdr \ + nfs_prot_xdr \ + nfs_serv1 \ + nfs_serv2 \ + nfs_serv3 \ + nfs_serv4 \ + +#****************************************************************************** +# some sample machine generated user-file stuff +# +../include/file_types.h : ../include/file_types.type.h ../include/file_types.operation.h +../include/Substrate_file.h : ../include/file_types.includes.h + +../include/file_types.type.h : ../include/file_types.hierarchy + $(HIERARCHY) -voutput_type=type ../include/file_types.hierarchy > $@ + +../include/file_types.includes.h : ../include/file_types.hierarchy + $(HIERARCHY) -voutput_type=general -vpreamble='#include "' \ + -vpostamble='.h"' -vprint_first=1 ../include/file_types.hierarchy > $@ + +../include/file_types.operation.h : ../include/file_types.hierarchy + (echo '#define FILE_TYPES_OPERATION(OPERATION) \' ; \ + $(HIERARCHY) -voutput_type=general -vpreamble='OPERATION(' \ + -vpostamble=') \' -vprint_first=1 ../include/file_types.hierarchy ; \ + echo ; ) | sed 's/\.//g' > $@ ; + +#****************************************************************************** +# source files... + +HEADERS := $(wildcard $(addprefix $(IDIR)/, $(addsuffix .h, $(USER_TYPES) $(HEADER_FILES)))) + +SOURCES := $(wildcard $(addsuffix .cc, $(USER_TYPES) $(SOURCE_FILES))) + +OBJECTS := $(patsubst %.cc,%.o,$(SOURCES)) + +#****************************************************************************** +# User prototype instantiations + +USER_PROTO_HEADERS := $(addprefix $(PC)/, $(addsuffix .h, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(IPP)/, $(addsuffix .hP, $(USER_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(USER_PROTO_TYPES))))) + +USER_PROTO_SOURCES := $(addprefix $(PC)/, $(addsuffix .cc, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(IPP)/, $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(USER_PROTO_TYPES))))) + +USER_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(USER_PROTO_SOURCES)) + +USER_PROTO_TYPE_SOURCES := $(wildcard $(addprefix $(IPP)/, $(addsuffix .hP, $(USER_BASE_PROTO_TYPES)) $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES)))) + +#****************************************************************************** +# libg++ prototype instantiations + +LIB_PROTO_HEADERS := $(addprefix $(PC)/, $(addsuffix .h, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(LPP)/, $(addsuffix .hP, $(LIB_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(LIB_PROTO_TYPES))))) + +LIB_PROTO_SOURCES := $(addprefix $(PC)/, $(addsuffix .cc, $(foreach type, $(basename $(notdir $(wildcard $(addprefix $(LPP)/, $(addsuffix .ccP, $(LIB_BASE_PROTO_TYPES)))))), $(filter %.$(type), $(LIB_PROTO_TYPES))))) + +LIB_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(LIB_PROTO_SOURCES)) + +.PHONY : test +test : + @echo LIB_PROTO_TYPES = "${LIB_PROTO_TYPES}"; + @echo LIB_BASE_PROTO_TYPES = "${LIB_BASE_PROTO_TYPES}" ; + @echo LIB_PROTO_OBJECTS = "${LIB_PROTO_OBJECTS}" ; + @echo LIB_PROTO_HEADERS = "${LIB_PROTO_HEADERS}" ; + +#***************************************************************************** +# main procedures.. + +# example: +foo : foo.o $(OBJECTS) + $(C++) $(C++FLAGS) -o $@ foo.o $(OBJECTS) $(LDIRS) + +sources : $(SOURCES) + +#****************************************************************************** +# various cleanup stuff... + +.PHONY : rmback clean realclean + +rmback : + cd .. ; rm -f proto/*~ include/*~ src/*~ + +clean : rmback + rm -f $(OBJECTS) $(PROTOLIB) $(LIB_PROTO_OBJECTS) $(USER_PROTO_OBJECTS) + +realclean : clean + rm -f $(LIB_PROTO_SOURCES) $(USER_PROTO_SOURCES) $(LIB_PROTO_HEADERS) $(USER_PROTO_HEADERS) + + +#***************************************************************************** +# debugging actions + +%.E : %.cc + $(C++) $(C++FLAGS) -E $(@D)$(basename $(@F)).cc > $@ + +%.s : %.cc + $(C++) -S $(C++FLAGS) $< -o $@ + +#****************************************************************************** +# "functions" for creating library source code from prototypes + +parameters = $(subst .,$(space),$(notdir $(basename $(basename $@)))) +ifdef_filename = $(subst .,_,$(notdir $(basename $@))) + +generic-type = $(subst .,,$(suffix $(basename $(notdir $@)))) + +# +# return the type if it should be a "val" type (pointer or basic type) +# +parameter-val-q = $(filter %_p, $(parameter)) $(filter-out %_p, $(filter $(parameter), $(BASIC_TYPES))) + +# +# return the list of pairs of types and their prototype type (val or ref) +# +proto-type-arg = $(parameter) \ + $(patsubst %, val, $(filter 1, $(words $(parameter-val-q)))) \ + $(patsubst %, ref, $(filter-out 1, $(words $(parameter-val-q)))) + +define make-proto-file +$(GENCLASS) \ + $(dir $<) \ + $(dir $@) \ + $(suffix $@) \ + $(foreach parameter, $(parameters), $(proto-type-arg)) \ + $(generic-type) ; +endef + + +define prepend-proto-includes +$(PREPEND) \ + $(addsuffix .h, $(basename $@)) \ + '#include "include.h"' \ + $(patsubst %, '#include "%.h"', $(foreach type, $(USER_TYPES) $(USER_PROTO_TYPES) $(LIB_PROTO_TYPES), $(patsubst %, $(type), $(filter $(subst .,, $(type)), $(patsubst %_p, %, $(parameters)))))) ; +endef + +#****************************************************************************** +# libg++ prototype dependencies + + +# +# Used to automatically generate a %_p.defs file, which is required by classes +# which do comparisons, for pointer types to objects which have the real +# comparison code. +# +# this will cat the appropriate strings +# +$(addprefix $(PC)/, $(addsuffix .h, $(filter-out char_p.defs, $(filter %_p.defs, $(LIB_PROTO_TYPES))))) : + @ echo creating $@ ; \ + ( ifdef_filename=$(strip $(ifdef_filename)) \ + p=$(strip $(patsubst %_p, %, $(parameters))) \ + ../bin/make-defs-file ) > $@ ; + +lib_proto_intermediate_sources = \ +$(filter-out %_p.defs.h, $(LIB_PROTO_HEADERS) $(LIB_PROTO_SOURCES)) \ +$(addprefix $(PC)/, $(addsuffix .h, char_p.defs)) + +lib_type_and_suffix_list = $(sort $(join $(suffix $(basename $(lib_proto_intermediate_sources))), $(addprefix ., $(suffix $(lib_proto_intermediate_sources))))) + +#****************************************************************************** +# prototype dependencies + +proto_intermediate_sources = \ + $(USER_PROTO_HEADERS) \ + $(USER_PROTO_SOURCES) + +type_and_suffix_list = $(sort $(join $(suffix $(basename $(proto_intermediate_sources))), $(addprefix ., $(suffix $(proto_intermediate_sources))))) + +#****************************************************************************** +# generate machine generated dependencies + +H_FILES = $(HEADERS) $(LIB_PROTO_HEADERS) $(USER_PROTO_HEADERS) +CC_FILES = $(SOURCES) $(LIB_PROTO_SOURCES) $(USER_PROTO_SOURCES) + +DEPENDENCIES = $(addsuffix .d, $(basename $(CC_FILES))) + +$(addsuffix .d, $(basename $(CC_FILES))) : %.d : %.cc + ( echo -n $(@D) ; $(C++) -M $(C++FLAGS) $*.cc) > $@; + +#****************************************************************************** +# machine generated type stuff +# + +$(DEPENDENCIES) : $(H_FILES) + +.PHONY : dependencies source-dependencies object-dependencies + +dependencies : type-definitions source-dependencies + @ $(MAKE) object-dependencies + +object-dependencies : $(DEPENDENCIES) + @echo making object dependencies... ; \ + rm .Makefile.O_DEP ; \ + ls . | grep '\.d$$' > /tmp/dependencies ; \ + ls $(PC) | gawk '{printf "$(PC)/%s\n", $$0 ; }' | grep '\.d$$' >> \ + /tmp/dependencies ; \ + for file in `cat /tmp/dependencies` ; do \ + cat $$file ; \ + done > .Makefile.O_DEP.tmp ; \ + mv .Makefile.O_DEP.tmp .Makefile.O_DEP ; \ + for file in `cat /tmp/dependencies` ; do \ + rm $$file ; \ + done ; \ + rm /tmp/dependencies ; + + +source-dependencies : + @ echo making source dependencies... ; \ + ($(PROTOTYPE) -voutput_type=libg++-prototypes \ + ../include/prototype.dependencies | \ + gawk '($$1 !~ "_p.defs$$") || ($$1 == "char_p.defs") { print ; }' | \ + PROTO_SOURCE=$(LPP) PP=LPP ../bin/make-source-dependencies ; \ + ($(PROTOTYPE) -voutput_type=user-prototypes \ + ../include/prototype.dependencies ; \ + $(HIERARCHY) -voutput_type=general ../include/file_types.hierarchy) | \ + PROTO_SOURCE=$(IPP) PP=IPP ../bin/make-source-dependencies ; \ + ) > .Makefile.S_DEP ; + +type-definitions : + @ echo make type definitions... ; \ + $(MAKE_TYPES) > .Makefile.TYPES ; + +#****************************************************************************** +# include machine generated dependencies + +include .Makefile.S_DEP +include .Makefile.O_DEP diff --git a/gnu/lib/libg++/libg++/proto-kit/Makefile.new b/gnu/lib/libg++/libg++/proto-kit/Makefile.new new file mode 100644 index 00000000000..978ff04c844 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/Makefile.new @@ -0,0 +1,438 @@ +#****************************************************************************** +# This GNUmakefile is useful for large and complex projects which involve +# both G++ library prototypes, and prototypes added by the user(s). It +# is assumed that certain conventions are followed. +# +# 1) each object has its own source and header files. For example class W +# would have W.h and W.cc +# +# 2) each prototype object has its own source and header files (W.hP and W.ccP) +# +# 3) object header files are contained in directory $(IDIR) (for Include +# DIRectory) +# +# 4) object source files are contained in the current directory +# +# 5) prototype instantiations are contained in $(PC) (for Prototype C++ +# directory) +# +# 6) user prototype files (both header and source) are contained in $(IPP) +# +# 7) non-class code is contained in .h and .cc files, which live in $(IDIR) +# and the current directory respectively +# +# *) as an extra, I have added the convention that whenever a W.cc file +# is being compiled, the macro _W_cc is defined. This is useful +# particularly for conditional parts of header files (for example, +# W.h could have ifdef _W_cc ... +# +# The makefile works in the following manner: the source dependencies are +# contained in .Makefile.S_DEP, while the (machine generated) object +# dependencies are contained in .Makefile.O_DEP. The types needed by +# the program are defined by several variables, and the makefile generates +# the necessary dependencies (both source and object) from those variables. +# The prototype lists are contained in .Makefile.TYPES. +# +# NOTE: in order to create the machine generated files .Makefile.TYPES, +# .Makefile.S_DEP, and .Makefile.O_DEP, empty versions of these +# file must exist. They can be easily created using "touch ". +# +# -- Carl Staelin +# staelin@princeton.edu +#****************************************************************************** + +#****************************************************************************** +# standard Makefile definitions + +comma := , +space := $(empty) $(empty) +tab := $(empty) $(empty) + +#****************************************************************************** +# definitions from environment variables + +# the CPATH include directories +cpath-include-directories := $(addprefix -I, $(subst :,$(space),$(CPATH))) + +# the LPATH load directories +lpath-load-directories := $(addprefix -L, $(subst :,$(space),$(LPATH))) + +#****************************************************************************** +# Basic definitions + +HOST := $(shell hostname) + +BASE := + +# CMU Directories +USR := $(BASE)/usr +MACH := $(BASE)/usr/mach +CS := $(BASE)/usr/cs + +# GNU directories +GNULIBDIR := $(BASE)/usr/local/lib +GNUIDIR := $(GNULIBDIR)/g++-include + +# the g++ library prototypes... +LPP := $(GNUIDIR) +PC := ../libg++ + +# the user's library prototypes... +IPP := ../proto + +# the include directory +IDIR := ../include + +# the include directories needed... +IDIRS := -I$(IDIR) -I$(PC) -I$(GNUIDIR) $(cpath-include-directories) + +# the directories where the libraries live... +LDIRS := $(lpath-load-directories) + +#****************************************************************************** +# standard function (and associated variables) definitions + +C++ = g++ +C++FLAGS = -pipe -O $(IDIRS) + -Dc_plusplus \ + -DDEBUG \ + -D$(strip $(subst .,_, _$(basename $(@F))_cc)) + + +GENCLASS = ../bin/genclass.extnsn +PREPEND = ../bin/prepend +HIERARCHY = ../bin/hierarchy +MAKE_TYPES = ../bin/make-types +PROTOTYPE = ../bin/prototype + +#****************************************************************************** +# implicit rules + +%.o : %.cc + $(C++) $(C++FLAGS) \ + -c -o $@ $(@D)$(basename $(@F)).cc + +#****************************************************************************** +# User types + +BASIC_TYPES = \ + int \ + u_int \ + l_int \ + l_u_int + +# generated by this make file (initially create an empty .Makefile.TYPES +# so that "make dependencies" can create the real file) +include .Makefile.TYPES + +#****************************************************************************** +# User types (with sample values filled in) +# +# NOTE: do NOT add .h to the end of these, MAKE does it for you! + +HEADER_FILES = \ + disk_set \ + file_types \ + include \ + inode \ + inode_t \ + lib \ + main \ + nfs_functions \ + nfs_mount \ + nfs_params \ + nfs_prot \ + system + +SOURCE_FILES = \ + disk_set \ + lib \ + nfs_auxil \ + nfs_dirent \ + nfs_fh \ + nfs_ipcress \ + nfs_links \ + nfs_main \ + nfs_mnt_serv \ + nfs_mount_xdr \ + nfs_prot_xdr \ + nfs_serv1 \ + nfs_serv2 \ + nfs_serv3 \ + nfs_serv4 \ + +#****************************************************************************** +# some sample machine generated user-file stuff +# +../include/file_types.h : ../include/file_types.type.h \ + ../include/file_types.operation.h +../include/Substrate_file.h : ../include/file_types.includes.h + +../include/file_types.type.h : ../include/file_types.hierarchy + $(HIERARCHY) -voutput_type=type ../include/file_types.hierarchy > $@ + +../include/file_types.includes.h : ../include/file_types.hierarchy + $(HIERARCHY) -voutput_type=general -vpreamble='#include "' \ + -vpostamble='.h"' -vprint_first=1 ../include/file_types.hierarchy > $@ + +../include/file_types.operation.h : ../include/file_types.hierarchy + (echo '#define FILE_TYPES_OPERATION(OPERATION) \' ; \ + $(HIERARCHY) -voutput_type=general -vpreamble='OPERATION(' \ + -vpostamble=') \' -vprint_first=1 ../include/file_types.hierarchy ; \ + echo ; ) | sed 's/\.//g' > $@ ; + +#****************************************************************************** +# source files... + +HEADERS := $(wildcard $(addprefix $(IDIR)/, $(addsuffix .h, \ + $(USER_TYPES) $(HEADER_FILES)))) + +SOURCES := $(wildcard $(addsuffix .cc, $(USER_TYPES) $(SOURCE_FILES))) + +OBJECTS := $(patsubst %.cc,%.o,$(SOURCES)) + +#****************************************************************************** +# User prototype instantiations + +USER_PROTO_HEADERS := \ + $(addprefix $(PC)/, \ + $(addsuffix .h, \ + $(foreach type, \ + $(basename \ + $(notdir \ + $(wildcard \ + $(addprefix $(IPP)/, \ + $(addsuffix .hP, \ + $(USER_BASE_PROTO_TYPES)))))), \ + $(filter %.$(type), $(USER_PROTO_TYPES))))) + +USER_PROTO_SOURCES := \ + $(addprefix $(PC)/, \ + $(addsuffix .cc, \ + $(foreach type, \ + $(basename \ + $(notdir \ + $(wildcard \ + $(addprefix $(IPP)/,\ + $(addsuffix .ccP, \ + $(USER_BASE_PROTO_TYPES)))))),\ + $(filter %.$(type), $(USER_PROTO_TYPES))))) + +USER_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(USER_PROTO_SOURCES)) + +USER_PROTO_TYPE_SOURCES := \ + $(wildcard \ + $(addprefix $(IPP)/, \ + $(addsuffix .hP, $(USER_BASE_PROTO_TYPES)) \ + $(addsuffix .ccP, $(USER_BASE_PROTO_TYPES)))) + +#****************************************************************************** +# libg++ prototype instantiations + +LIB_PROTO_HEADERS := \ + $(addprefix $(PC)/, \ + $(addsuffix .h, \ + $(foreach type, \ + $(basename \ + $(notdir \ + $(wildcard \ + $(addprefix $(LPP)/, \ + $(addsuffix .hP, $(LIB_BASE_PROTO_TYPES)))))), \ + $(filter %.$(type), $(LIB_PROTO_TYPES))))) + +LIB_PROTO_SOURCES := \ + $(addprefix $(PC)/, \ + $(addsuffix .cc, \ + $(foreach type, \ + $(basename \ + $(notdir \ + $(wildcard \ + $(addprefix $(LPP)/, \ + $(addsuffix .ccP, $(LIB_BASE_PROTO_TYPES)))))), + $(filter %.$(type), $(LIB_PROTO_TYPES))))) + +LIB_PROTO_OBJECTS := $(patsubst %.cc, %.o, $(LIB_PROTO_SOURCES)) + +.PHONY : test +test : + @echo LIB_PROTO_TYPES = "${LIB_PROTO_TYPES}"; + @echo LIB_BASE_PROTO_TYPES = "${LIB_BASE_PROTO_TYPES}" ; + @echo LIB_PROTO_OBJECTS = "${LIB_PROTO_OBJECTS}" ; + @echo LIB_PROTO_HEADERS = "${LIB_PROTO_HEADERS}" ; + +#***************************************************************************** +# main procedures.. + +# example: +foo : foo.o $(OBJECTS) + $(C++) $(C++FLAGS) -o $@ foo.o $(OBJECTS) $(LDIRS) + +sources : $(SOURCES) + +#****************************************************************************** +# various cleanup stuff... + +.PHONY : rmback clean realclean + +rmback : + cd .. ; rm -f proto/*~ include/*~ src/*~ + +clean : rmback + rm -f $(OBJECTS) $(PROTOLIB) $(LIB_PROTO_OBJECTS) $(USER_PROTO_OBJECTS) + +realclean : clean + rm -f $(LIB_PROTO_SOURCES) $(USER_PROTO_SOURCES) $(LIB_PROTO_HEADERS) \ + $(USER_PROTO_HEADERS) + + +#***************************************************************************** +# debugging actions + +%.E : %.cc + $(C++) $(C++FLAGS) -E $(@D)$(basename $(@F)).cc > $@ + +%.s : %.cc + $(C++) -S $(C++FLAGS) $< -o $@ + +#****************************************************************************** +# "functions" for creating library source code from prototypes + +parameters = $(subst .,$(space),$(notdir $(basename $(basename $@)))) +ifdef_filename = $(subst .,_,$(notdir $(basename $@))) + +generic-type = $(subst .,,$(suffix $(basename $(notdir $@)))) + +# +# return the type if it should be a "val" type (pointer or basic type) +# +parameter-val-q = $(filter %_p, $(parameter)) $(filter-out %_p, $(filter $(parameter), $(BASIC_TYPES))) + +# +# return the list of pairs of types and their prototype type (val or ref) +# +proto-type-arg = $(parameter) \ + $(patsubst %, val, $(filter 1, $(words $(parameter-val-q)))) \ + $(patsubst %, ref, $(filter-out 1, $(words $(parameter-val-q)))) + +define make-proto-file +$(GENCLASS) \ + $(dir $<) \ + $(dir $@) \ + $(suffix $@) \ + $(foreach parameter, $(parameters), $(proto-type-arg)) \ + $(generic-type) ; +endef + + +define prepend-proto-includes +$(PREPEND) \ + $(addsuffix .h, $(basename $@)) \ + '#include "include.h"' \ + $(patsubst %, '#include "%.h"', \ + $(foreach type, $(USER_TYPES) \ + $(USER_PROTO_TYPES) \ + $(LIB_PROTO_TYPES), \ + $(patsubst %, $(type), \ + $(filter $(subst .,, $(type)),\ + $(patsubst %_p, %, $(parameters)))))) ; +endef + +#****************************************************************************** +# libg++ prototype dependencies + + +# +# Used to automatically generate a %_p.defs file, which is required by classes +# which do comparisons, for pointer types to objects which have the real +# comparison code. +# +# this will cat the appropriate strings +# +$(addprefix $(PC)/, \ + $(addsuffix .h, \ + $(filter-out char_p.defs, $(filter %_p.defs, $(LIB_PROTO_TYPES))))) : + @ echo creating $@ ; \ + ( ifdef_filename=$(strip $(ifdef_filename)) \ + p=$(strip $(patsubst %_p, %, $(parameters))) \ + ../bin/make-defs-file ) > $@ ; + +lib_proto_intermediate_sources = \ + $(filter-out %_p.defs.h, $(LIB_PROTO_HEADERS) $(LIB_PROTO_SOURCES)) \ + $(addprefix $(PC)/, $(addsuffix .h, char_p.defs)) + +lib_type_and_suffix_list = \ + $(sort \ + $(join $(suffix $(basename $(lib_proto_intermediate_sources))),\ + $(addprefix ., $(suffix $(lib_proto_intermediate_sources))))) + +#****************************************************************************** +# prototype dependencies + +proto_intermediate_sources = \ + $(USER_PROTO_HEADERS) \ + $(USER_PROTO_SOURCES) + +type_and_suffix_list = \ + $(sort \ + $(join $(suffix $(basename $(proto_intermediate_sources))), \ + $(addprefix ., $(suffix $(proto_intermediate_sources))))) + +#****************************************************************************** +# generate machine generated dependencies + +H_FILES = $(HEADERS) $(LIB_PROTO_HEADERS) $(USER_PROTO_HEADERS) +CC_FILES = $(SOURCES) $(LIB_PROTO_SOURCES) $(USER_PROTO_SOURCES) + +DEPENDENCIES = $(addsuffix .d, $(basename $(CC_FILES))) + +$(addsuffix .d, $(basename $(CC_FILES))) : %.d : %.cc + ( echo -n $(@D) ; $(C++) -M $(C++FLAGS) $*.cc) > $@; + +#****************************************************************************** +# machine generated type stuff +# + +$(DEPENDENCIES) : $(H_FILES) + +.PHONY : dependencies source-dependencies object-dependencies + +dependencies : type-definitions source-dependencies + @ $(MAKE) object-dependencies + +object-dependencies : $(DEPENDENCIES) + @echo making object dependencies... ; \ + rm .Makefile.O_DEP ; \ + ls . | grep '\.d$$' > /tmp/dependencies ; \ + ls $(PC) | gawk '{printf "$(PC)/%s\n", $$0 ; }' | grep '\.d$$' >> \ + /tmp/dependencies ; \ + for file in `cat /tmp/dependencies` ; do \ + cat $$file ; \ + done > .Makefile.O_DEP.tmp ; \ + mv .Makefile.O_DEP.tmp .Makefile.O_DEP ; \ + for file in `cat /tmp/dependencies` ; do \ + rm $$file ; \ + done ; \ + rm /tmp/dependencies ; + + +source-dependencies : + @ echo making source dependencies... ; \ + ($(PROTOTYPE) -voutput_type=libg++-prototypes \ + ../include/prototype.dependencies | \ + gawk '($$1 !~ "_p.defs$$") || ($$1 == "char_p.defs") { print ; }' | \ + PROTO_SOURCE=$(LPP) PP=LPP ../bin/make-source-dependencies ; \ + ($(PROTOTYPE) -voutput_type=user-prototypes \ + ../include/prototype.dependencies ; \ + $(HIERARCHY) -voutput_type=general ../include/file_types.hierarchy)|\ + PROTO_SOURCE=$(IPP) PP=IPP ../bin/make-source-dependencies ; \ + ) > .Makefile.S_DEP ; + +type-definitions : + @ echo make type definitions... ; \ + $(MAKE_TYPES) > .Makefile.TYPES ; + +#****************************************************************************** +# include machine generated dependencies + +include .Makefile.S_DEP +include .Makefile.O_DEP diff --git a/gnu/lib/libg++/libg++/proto-kit/file_types.hierarchy b/gnu/lib/libg++/libg++/proto-kit/file_types.hierarchy new file mode 100644 index 00000000000..0104fcc602a --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/file_types.hierarchy @@ -0,0 +1,7 @@ +root Substrate +set Whole Partial +set Simple +children Substrate Unix Immediate +children Unix Directory Immediate +children Directory Immediate +children diff --git a/gnu/lib/libg++/libg++/proto-kit/file_types.includes.h b/gnu/lib/libg++/libg++/proto-kit/file_types.includes.h new file mode 100644 index 00000000000..7f763678265 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/file_types.includes.h @@ -0,0 +1,15 @@ +#include "Substrate.h" +#include "Substrate.Unix.h" +#include "Substrate.Immediate.h" +#include "Substrate.Simple.h" +#include "SubstrateUnix.Directory.h" +#include "SubstrateUnix.Immediate.h" +#include "SubstrateUnix.Simple.h" +#include "SubstrateSimple.Whole.h" +#include "SubstrateSimple.Partial.h" +#include "SubstrateUnixDirectory.Immediate.h" +#include "SubstrateUnixDirectory.Simple.h" +#include "SubstrateUnixSimple.Whole.h" +#include "SubstrateUnixSimple.Partial.h" +#include "SubstrateUnixDirectorySimple.Whole.h" +#include "SubstrateUnixDirectorySimple.Partial.h" diff --git a/gnu/lib/libg++/libg++/proto-kit/file_types.operation.h b/gnu/lib/libg++/libg++/proto-kit/file_types.operation.h new file mode 100644 index 00000000000..d108c161f84 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/file_types.operation.h @@ -0,0 +1,17 @@ +#define FILE_TYPES_OPERATION(OPERATION) \ +OPERATION(Substrate) \ +OPERATION(SubstrateUnix) \ +OPERATION(SubstrateImmediate) \ +OPERATION(SubstrateSimple) \ +OPERATION(SubstrateUnixDirectory) \ +OPERATION(SubstrateUnixImmediate) \ +OPERATION(SubstrateUnixSimple) \ +OPERATION(SubstrateSimpleWhole) \ +OPERATION(SubstrateSimplePartial) \ +OPERATION(SubstrateUnixDirectoryImmediate) \ +OPERATION(SubstrateUnixDirectorySimple) \ +OPERATION(SubstrateUnixSimpleWhole) \ +OPERATION(SubstrateUnixSimplePartial) \ +OPERATION(SubstrateUnixDirectorySimpleWhole) \ +OPERATION(SubstrateUnixDirectorySimplePartial) \ + diff --git a/gnu/lib/libg++/libg++/proto-kit/file_types.type.h b/gnu/lib/libg++/libg++/proto-kit/file_types.type.h new file mode 100644 index 00000000000..380b80ca704 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/file_types.type.h @@ -0,0 +1,30 @@ +Substrate_type = + isa_Substrate, +SubstrateUnix_type = + isa_Substrate | isa_Unix, +SubstrateImmediate_type = + isa_Substrate | isa_Immediate, +SubstrateSimple_type = + isa_Substrate | isa_Simple, +SubstrateUnixDirectory_type = + isa_Substrate | isa_Unix | isa_Directory, +SubstrateUnixImmediate_type = + isa_Substrate | isa_Unix | isa_Immediate, +SubstrateUnixSimple_type = + isa_Substrate | isa_Unix | isa_Simple, +SubstrateSimpleWhole_type = + isa_Substrate | isa_Simple | isa_Whole, +SubstrateSimplePartial_type = + isa_Substrate | isa_Simple | isa_Partial, +SubstrateUnixDirectoryImmediate_type = + isa_Substrate | isa_Unix | isa_Directory | isa_Immediate, +SubstrateUnixDirectorySimple_type = + isa_Substrate | isa_Unix | isa_Directory | isa_Simple, +SubstrateUnixSimpleWhole_type = + isa_Substrate | isa_Unix | isa_Simple | isa_Whole, +SubstrateUnixSimplePartial_type = + isa_Substrate | isa_Unix | isa_Simple | isa_Partial, +SubstrateUnixDirectorySimpleWhole_type = + isa_Substrate | isa_Unix | isa_Directory | isa_Simple | isa_Whole, +SubstrateUnixDirectorySimplePartial_type = + isa_Substrate | isa_Unix | isa_Directory | isa_Simple | isa_Partial, diff --git a/gnu/lib/libg++/libg++/proto-kit/genclass.extnsn b/gnu/lib/libg++/libg++/proto-kit/genclass.extnsn new file mode 100644 index 00000000000..e9097120878 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/genclass.extnsn @@ -0,0 +1,112 @@ +#!/bin/csh + +# shell script for generating classes from prototypes +# +# usage: genclass protodir cdir extension type {ref | val} [type {ref | val}] ... proto +# + +set PROGRAM_NAME=$0 +set USAGE="Usage: ${PROGRAM_NAME} ' {ref | val} [ {ref | val}] ... '"; + +# there are at least 6 parameters, plus the program name (total of seven) +if (($#argv < 6) || ($#argv % 2) > 0) then + echo "${PROGRAM_NAME}: invalid parameter count"; + echo "${USAGE}"; + exit 1; +endif + +set PWD=`pwd`/ + +# get the prototype directory, the C directory and the C file extension (.h or .cc) +# from the argument list +set PROTODIR = $1; shift; +set OUTDIR = $1; shift; +set EXTNSN = $1; shift; + +if ($PROTODIR !~ */) then + set PROTODIR = $PROTODIR/ +endif +if ($OUTDIR !~ */) then + set OUTDIR = $OUTDIR/ +endif + +set FILE_NAME=; +set CLASS_NAME=; +set TYPES=; +set VALS=; + +# loop through the parameters, pulling pairs off the +# argument list. + +while ( $#argv > 2 ) + set TYPES = (${TYPES} $1) + set VALS = (${VALS} $2) + set FILE_NAME = "${FILE_NAME}$1." + set CLASS_NAME = "${CLASS_NAME}$1" + + if (($2 != "ref") && ($2 != "val")) then + echo "${PROGRAM_NAME}: invalid reference type" ; + echo ${USAGE} ; + exit 1; + endif + + shift; + shift; +end + +set CLASS = $1 + +set FILE_NAME = "${FILE_NAME}${CLASS}.${EXTNSN}" +set CLASS_NAME = "${CLASS_NAME}${CLASS}" +set HSRC = "$CLASS.hP" +set SRC = "$CLASS.${EXTNSN}P" +set OUT = "$OUTDIR$FILE_NAME" + +if ( (-f $PWD$SRC) && (-r $PWD$SRC) && (-f $PWD$HSRC) ) then + set PSRC = $PWD$SRC + set HSRC = $PWD$HSRC +else if ( (-f $PROTODIR$SRC) && (-r $PROTODIR$SRC) && (-f $PROTODIR$HSRC) ) then + set PSRC = $PROTODIR$SRC + set HSRC = $PROTODIR$HSRC +else + echo "${PROGRAM_NAME}: $SRC: no such file"; + exit 1; +endif + +set SEARCH_STRING = (generic class $CLASS\\\[.\*\\\]) + +set SED_SCRIPT = /tmp/genclass.$$ + +# this is so we can handle unreformed files from the distribution +if (1) then + set TYPE_LIST = T + if ( $#TYPES == 2 ) set TYPE_LIST = (${TYPE_LIST} C) +else + # get TYPE_LIST somehow... ??? + set TEMP = "`grep $SEARCH_STRING $HSRC`" + set TYPE_LIST=(`expr $TEMP : \[^\\\[\]\*\\\[\(.*\)\\\].\* | tr ',' ' '`); + unset TEMP + echo "s/$SEARCH_STRING/class $CLASS_NAME/g" >> SED_SCRIPT +endif + +set DUMMY=0 +while ( $DUMMY < $#TYPES ) + @ DUMMY++ + set PREAMBLE = 's/<'; + set MIDDLE = '>/'; + set POSTAMBLE = '/g'; + echo ${PREAMBLE}${TYPE_LIST[$DUMMY]}${MIDDLE}${TYPES[$DUMMY]}${POSTAMBLE} >>$SED_SCRIPT + + set MIDDLE = "&$MIDDLE" + if ($VALS[$DUMMY] == "ref") set POSTAMBLE = "\&$POSTAMBLE"; + + echo ${PREAMBLE}${TYPE_LIST[$DUMMY]}${MIDDLE}${TYPES[$DUMMY]}${POSTAMBLE} >>$SED_SCRIPT +end + +sed -f $SED_SCRIPT < $PSRC > $OUT + +rm -f $SED_SCRIPT + + + + diff --git a/gnu/lib/libg++/libg++/proto-kit/hierarchy b/gnu/lib/libg++/libg++/proto-kit/hierarchy new file mode 100644 index 00000000000..86a844431d8 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/hierarchy @@ -0,0 +1,139 @@ +#!/usr/local/bin/gawk -f +#************************************************************************************** +# +# hierarchy: +# This program takes an input file which defines a DAG +# and expands it into a tree. It is useful when you have a tree of +# generic types. See the sample input file "file_types.hierarchy" +# for a sample dataset, and sample outputs "file_types.includes.h", +# "file_types.operation.h" and "file_types.type.h". The input has +# three distinct types of input lines: +# +# root TYPE +# set TYPE1 TYPE2 ... +# children TYPE| TYPE| TYPE| ... +# +# each word is tab-separated. "root" defines the root type of the +# tree. "set" defines an alias for a list of types. "children" +# defines the child types (or sets of types) for a given type or +# set of types. +# +#************************************************************************************** +# command line switches: +# -voutput_type=type -- print the specialized type definition (iPcress only) +# -voutput_type=general -- general output type. has sub-options +# -vpreamble=??? -- print this ??? string before the type +# -vpostamble=??? -- print this ??? string after after the type +# -vprint_first=1 -- if you want to include the root type +# +# +#************************************************************************************** + +function print_type_node (queue, node, out, i) { + for (i = 1 ; i <= queue[node] ; i ++) + printf "%s", queue[node,i] ; + printf "_type = \n\t" ; + for (i = 1 ; i <= queue[node] ; i ++) + { + printf "isa_%s", queue[node,i] ; + if (i < queue[node]) + printf " | " ; + } + printf ",\n" ; + return +} + +function print_general_node (queue, node, i) { + if ((queue[node] > 1) || (print_first == 1)) + { + printf "%s", preamble; + for (i = 1 ; i <= queue[node] ; i ++) + { + if ((i == queue[node]) && (i > 1)) + printf "."; + printf "%s", queue[node,i] ; + } + printf "%s\n", postamble; + } + return +} + +BEGIN { head = 2; + tail = 1; + } + +$1 == "set" { + set_names[$2] = NF - 2; + for (dummy = 3 ; dummy <= NF ; dummy ++) + { + set_names[$2,dummy - 2] = $dummy; + } + } + +$1 == "root" { root_set = $2 ; } + +($1 == "children") && ($2 ~ /<.+>/) { + for (s_el = 1 ; s_el <= set_names[$2] ; s_el ++) + { + t=0 ; + for (dummy = 3 ; dummy <= NF ; dummy ++) + if ($dummy ~ /<.+>/) + { + for (i = 1 ; i <= set_names[$dummy] ; i ++) + { + t++ + children[set_names[$2,s_el],t] = set_names[$dummy,i] + } + } + else + { + t ++ + children[set_names[$2,s_el],t] = $dummy; + } + children[set_names[$2,s_el]] = t; + } + } + +($1 == "children") && ($2 !~ /<.+>/) { + t = 0; + for (dummy = 3 ; dummy <= NF ; dummy ++) + if ($dummy ~ /<.+>/) + { + for (i = 1 ; i <= set_names[$dummy] ; i ++) + { + t++ + children[$2,t] = set_names[$dummy,i] + } + } + else + { + t ++ + children[$2,t] = $dummy; + } + children[$2] = t; + } + +END { + queue[1] = 1; + queue[1,1] = root_set; + while (head > tail) + { + if (output_type == "type") + print_type_node(queue,tail); + if (output_type == "general") + print_general_node(queue,tail); + + for (i = 1 ; i <= children[queue[tail,queue[tail]]] ; i ++) + { + # add new node to queue + for (j = 1 ; j <= queue[tail] ; j ++) + queue[head,j] = queue[tail,j]; + queue[head] = queue[tail] + 1; + queue[head,queue[head]] = children[queue[tail,queue[tail]],i] + head ++ + } + tail ++ + } + } + + diff --git a/gnu/lib/libg++/libg++/proto-kit/make-defs-file b/gnu/lib/libg++/libg++/proto-kit/make-defs-file new file mode 100644 index 00000000000..03f304cc1b6 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/make-defs-file @@ -0,0 +1,16 @@ +#!/bin/sh +# +# create a "defs" file, as needed by some libg++ types (see defs.hP +# for the model "defs" file) +# + +echo "#ifndef _${ifdef_filename}_h"; +echo "#define _${ifdef_filename}_h"; + +echo "#include \"${p}.defs.h\""; +echo "#define ${p}_pEQ(a,b) ${p}EQ(*(a),*(b))" ; +echo "#define ${p}_pLE(a,b) ${p}LE(*(a),*(b))" ; +echo "#define ${p}_pCMP(a,b) ${p}CMP(*(a),*(b))" ; +echo "#define ${p}_pHASH(a,b) ${p}HASH(*(a),*(b))" ; + +echo "#endif _${ifdef_filename}_h"; diff --git a/gnu/lib/libg++/libg++/proto-kit/make-source-dependencies b/gnu/lib/libg++/libg++/proto-kit/make-source-dependencies new file mode 100644 index 00000000000..fb22d77ec78 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/make-source-dependencies @@ -0,0 +1,45 @@ +#!/bin/sh +# +# make-source-dependencies: +# this shell script prints GNU Make compatible +# input from a list of prototype instantiations read +# (one per line) from the input. +# +# instantiations instances: /tmp/make-source-dependencies.$$.0 +# (cleaned up) instantiation instances: /tmp/make-source-dependencies.$$.1 +# sorted list of generic prototypes (culled from above): /tmp/make-source-dependencies.$$.2 + +while read instance ; do +echo "${instance}" +done >> /tmp/make-source-dependencies.$$.0 + +# instances +cat /tmp/make-source-dependencies.$$.0 | \ + gawk '{ for (i = 1 ; i <= NF ; i ++) print $i ; }' > /tmp/make-source-dependencies.$$.1 + +# prototypes +cat /tmp/make-source-dependencies.$$.0 | \ + gawk -F. '{ print $NF; }' | sort | uniq > /tmp/make-source-dependencies.$$.2 + +for t in `cat /tmp/make-source-dependencies.$$.2` ; do + + if [ -f ${PROTO_SOURCE}/${t}.hP ] ; then + cat /tmp/make-source-dependencies.$$.1 | \ + gawk -F. '$NF == "'${t}'" { printf "$(PC)/%s.h ", $0 ; }' ; + echo ": \$(${PP})/${t}.hP" ; + echo ' $(make-proto-file) $(prepend-proto-includes)' ; + echo ; + fi; + + if [ -f ${PROTO_SOURCE}/${t}.ccP ] ; then + cat /tmp/make-source-dependencies.$$.1 | \ + gawk -F. '$NF == "'${t}'" { printf "$(PC)/%s.cc ", $0 ; }' ; + echo ": \$(${PP})/${t}.ccP" ; + echo ' $(make-proto-file)' ; + echo ; + fi; +done; + +rm -f /tmp/make-source-dependencies.$$.0 +rm -f /tmp/make-source-dependencies.$$.1 +rm -f /tmp/make-source-dependencies.$$.2 diff --git a/gnu/lib/libg++/libg++/proto-kit/make-types b/gnu/lib/libg++/libg++/proto-kit/make-types new file mode 100644 index 00000000000..f8d96b7dd4e --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/make-types @@ -0,0 +1,50 @@ +#!/bin/sh +# +# using information included in the prototype dependencies and +# the hierarchy datasets, print off a GNU Make compatible form +# of the type variable lists +# + +( ../bin/prototype -voutput_type=user-types ../include/prototype.dependencies ; \ + ) | gawk '{ for (i = 1 ; i <= NF ; i ++) printf "%s\n", $i ; }' | sort > \ + /tmp/make-types.$$.user_types ; + +( ../bin/prototype -voutput_type=user-prototypes ../include/prototype.dependencies ; \ + ../bin/hierarchy -voutput_type=general ../include/file_types.hierarchy \ + ) | gawk '{ for (i = 1 ; i <= NF ; i ++) printf "%s\n", $i ; }' | sort > \ + /tmp/make-types.$$.user_proto_types ; + +( ../bin/prototype -voutput_type=libg++-prototypes ../include/prototype.dependencies ; \ + ) | gawk '{ for (i = 1 ; i <= NF ; i ++) printf "%s\n", $i ; }' | sort > \ + /tmp/make-types.$$.lib_proto_types ; + +# within each variable, all types are on a line by themselves. + +echo 'USER_TYPES := \' ; +cat /tmp/make-types.$$.user_types | gawk '{ printf "\t%s \\\n", $0 ; }' ; +echo ; + +echo 'LIB_TYPES := \' ; +echo ; + +echo 'USER_PROTO_TYPES := \' ; +cat /tmp/make-types.$$.user_proto_types | gawk '{ printf "\t%s \\\n", $0 ; }' ; +echo ; + +echo 'USER_BASE_PROTO_TYPES := \' ; +cat /tmp/make-types.$$.user_proto_types | gawk -F. '{ printf "\t%s \\\n", $NF; }' | \ + sort | uniq ; +echo ; + +echo 'LIB_PROTO_TYPES := \' ; +cat /tmp/make-types.$$.lib_proto_types | gawk '{ printf "\t%s \\\n", $0 ; }' ; +echo ; + +echo 'LIB_BASE_PROTO_TYPES := \' ; +cat /tmp/make-types.$$.lib_proto_types | gawk -F. '{ printf "\t%s \\\n", $NF; }' | \ + sort | uniq ; +echo ; + +rm -f /tmp/make-types.$$.user_types ; +rm -f /tmp/make-types.$$.user_proto_types ; +rm -f /tmp/make-types.$$.lib_proto_types ; diff --git a/gnu/lib/libg++/libg++/proto-kit/prepend b/gnu/lib/libg++/libg++/proto-kit/prepend new file mode 100644 index 00000000000..52b96fbde82 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/prepend @@ -0,0 +1,29 @@ +#!/bin/csh + +# usage: prepend file string1 ... stringn +# + +if ($#argv < 2) then +echo incorrect usage ; exit 1; +endif + +set FILE = $1; shift; +set TMP = /tmp/prepend.$$ + +if (!(-r $FILE)) then +echo file $FILE not found ; exit 1; +endif + +set DUMMY = 0 + +while ($DUMMY < $#argv) +@ DUMMY++ +echo $argv[$DUMMY] >>& $TMP +end + +cat $FILE >> $TMP + +cp $TMP $FILE + +rm -f $TMP + diff --git a/gnu/lib/libg++/libg++/proto-kit/prepend-header b/gnu/lib/libg++/libg++/proto-kit/prepend-header new file mode 100644 index 00000000000..ab373a01a95 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/prepend-header @@ -0,0 +1,29 @@ +#!/bin/csh -f + +# usage: prepend file string1 ... stringn +# + +if ($#argv < 2) then +echo incorrect usage ; exit 1; +endif + +set FILE = $1; shift; +set TMP = /tmp/prepend.$$ + +if (!(-r $FILE)) then +echo file $FILE not found ; exit 1; +endif + +set DUMMY = 0 + +while ($DUMMY < $#argv) +@ DUMMY++ +echo "$argv[$DUMMY]" >>& $TMP +end + +cat $FILE >> $TMP + +cp $TMP $FILE + +rm -f $TMP + diff --git a/gnu/lib/libg++/libg++/proto-kit/prototype b/gnu/lib/libg++/libg++/proto-kit/prototype new file mode 100644 index 00000000000..4a21baaaa12 --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/prototype @@ -0,0 +1,176 @@ +#!/usr/local/bin/gawk -f +# +# types: types[x] = 1 for each type 'x' we have completed. 'x' has separators +# +# prototypes: +# prototypes[x] = the number of dependent types +# (x is base type string -- without variables. eg. AVLMap) +# prototypes[x,"variables"] = the type string with period separated variables +# prototypes[x,y] = a dependent type (y integer) +# +# lib_prototype[x] = 1 +# user_prototype[x] = 1 +# "x" is base type string (eg. AVLMap) +# +# queue: queue of types to be done (with period separators) +# head: head of queue (where types added) +# tail: tail of queue (where types are processed) +# + + +# +# get_template +# +function get_template (template_string, instance, res, t_count, t_elements, i_count, i_elements, i) { + t_count = split (template_string, t_elements, "."); + i_count = split (instance, i_elements, "."); + + for (i = 1 ; i < i_count ; i ++) + { + if (i > 1) res = (res ","); + res = (res t_elements[i] "." i_elements[i]); + } + return res; + } + +# +# transform: takes an array of the form vars[variable] = value, and returns +# the instantiation of those variables according to template. +# "variable" is of the form +# +function transform (vars, template, res, pairs, map, count, i, var, preamble, postamble) { + res = template; + count = split(vars, pairs, ","); + + for (i = 1 ; i <= count ; i++) + { + split(pairs[i],map,"."); + if (match(map[1],"<.+>") > 0) + { + var = substr(map[1],RSTART,RLENGTH); + if (RSTART > 1) + preamble = substr(map[1],1,RSTART); + if (RSTART + RLENGTH < length(map[1])) + postamble = substr(map[1],RSTART+RLENGTH); + + if (match(map[2],("^" preamble ".*" postamble "$")) > 0) + { + match(map[2],("^" preamble)); + if (RLENGTH > 0) + map[2] = substr(map[2],RSTART+RLENGTH); + match(map[2],(postamble "$")); + if (RLENGTH > 0) + map[2] = substr(map[2],1,RSTART-1); + + gsub(var, map[2], res); + } + } + } + return res; + } + +function is_basic (t) { + if (basic_types[t] == 1) + return 1; + return 0; + } + +function add_type (t, c, e) { + c = split(t,e,"."); + + if ((is_basic(t) != 0) || (t ~ /_p$/) || (c <= 1)) + return 0; + if (match(t,"<.*>") > 0) + return 0; + + types[t] = 1; + return 1; + } + +function get_prototype (type, count, names) { + count = split(type, names, "."); + return names[count]; + } + +BEGIN { + head = 1; + tail = 1; + } + +($1 == "basic-type") || ($1 == "libg++-type") || ($1 == "user-type") { + if ($1 == "basic-type") + basic_types[$2] = 1 ; + if ($1 == "libg++-type") + lib_types[$2] = 1; + if ($1 == "user-type") + { + add_type($2); + user_types[$2] = 1 ; + for (i = 3 ; i <= NF ; i++) + if (add_type($i) > 0) + { + queue[head] = $i; + head ++; + } + } + + } + +($1 == "libg++-prototype") || ($1 == "user-prototype") { + proto = get_prototype($2); + prototypes[proto] = NF - 2; + prototypes[proto,"variables"] = $2; + + if ($1 == "libg++-prototype") + lib_prototypes[proto] = 1; + if ($1 == "user-prototype") + user_prototypes[proto] = 1; + + for (i = 3 ; i <= NF ; i ++) + prototypes[proto,i - 2] = $i; + } + +$1 == "instantiate" { + if (add_type($2) > 0) + { + queue[head] = $2; + head ++; + } + } + +END { + while (head > tail) + { + count = split(queue[tail], elements, "."); + template = get_template(prototypes[elements[count],"variables"], queue[tail]); + + for (i = 1 ; i <= prototypes[elements[count]] ; i ++) + { + t = transform(template, prototypes[elements[count],i]); + if (add_type(t)) + { + queue[head] = t; + head++; + } + } + tail ++; + } + + for (t in types) + if (types[t] == 1) + { + proto = get_prototype(t); + if ((output_type == "libg++-prototypes") && (lib_prototypes[proto] == 1)) + print t; + if ((output_type == "user-prototypes") && (user_prototypes[proto] == 1)) + print t; + } + + if (output_type == "libg++-types") + for (t in lib_types) + print t; + + if (output_type == "user-types") + for (t in user_types) + print t; + } diff --git a/gnu/lib/libg++/libg++/proto-kit/prototype.dependencies b/gnu/lib/libg++/libg++/proto-kit/prototype.dependencies new file mode 100644 index 00000000000..d8dae23fcab --- /dev/null +++ b/gnu/lib/libg++/libg++/proto-kit/prototype.dependencies @@ -0,0 +1,107 @@ +basic-type int +basic-type u_int +basic-type l_int +basic-type l_u_int +basic-type char + +user-type B_cache B_cache_node.LRUCache B_cache_node_p.SLStack +user-type B_cache_node +user-type Buffer +user-type CMPList +user-type CMPListNode +user-type D_block l_u_int.Block +user-type D_manager D_block.Alloc +user-type Disk +user-type Disk_manager D_block.Disk_free +user-type Disk_manager_creation D_block_p.AVLSet +user-type F_addr l_u_int.DLList +user-type F_cache F_addr.Substrate_file.LRUMapCache Substrate_file_p.SLStack +user-type File_handle Segment.File_handle_p.CHMap F_addr.File_handle_p.AVLMap +user-type File_system_manager +user-type M_block char_p.Block +user-type M_manager M_block.Coalesce +user-type Segment +user-type Substrate +user-type Substrate_file +user-type inode_t + +instantiate l_u_int.D_blockDisk_free_p.AVLMap +instantiate D_block.Disk_free +instantiate int.Disk_p.AVLMap +instantiate inode_t.Disk_free +instantiate l_u_int.Buffer_p.AVLMap +instantiate l_u_int.SLStack + +user-prototype .Alloc .Free +user-prototype .Block +user-prototype .CMPList .CMPListNode +user-prototype .CMPListNode +user-prototype .Coalesce .Realloc _p.SLStack _p.AVLSet +user-prototype .Directory +user-prototype .Disk_free l_u_int..AVLMap +user-prototype .Free .CMPList CMPListNode_p.AVLSet l_u_int.CMPList.AVLMap .CMPList +user-prototype .Indirect +user-prototype .LRUCache LRUCacheNode.CMPList LRUCacheNodeCMPListNode_p.AVLSet .LRUCacheNode +user-prototype .LRUCacheNode +user-prototype ..LRUMapCache LRUMapCacheNode.LRUCache ..LRUMapCacheNode +user-prototype ..LRUMapCacheNode +user-prototype .Multiple +user-prototype .Partial l_u_int.Buffer_p.AVLMap l_u_int.SLStack +user-prototype .Realloc .Alloc +user-prototype .Simple +user-prototype .Unix +user-prototype .Whole + +libg++-prototype _p.defs .defs +libg++-prototype .Bag .defs +libg++-prototype .CHBag .Bag +libg++-prototype .OSLBag .Bag .SLList +libg++-prototype .OXPBag .Bag .XPlex +libg++-prototype .SLBag .Bag .SLList +libg++-prototype .SlayBag .Bag +libg++-prototype .VHBag .Bag +libg++-prototype .XPBag .Bag .XPlex +libg++-prototype .Deque .defs +libg++-prototype .DLDeque .Deque .DLList +libg++-prototype .XPDeque .Deque .XPlex +libg++-prototype ..Map .defs +libg++-prototype ..AVLMap ..Map +libg++-prototype ..CHMap ..Map +libg++-prototype ..SplayMap ..Map +libg++-prototype ..VHMap ..Map +libg++-prototype .List +libg++-prototype .DLList +libg++-prototype .SLList +libg++-prototype .Plex .defs +libg++-prototype .FPlex .Plex +libg++-prototype .MPlex .Plex +libg++-prototype .RPlex .Plex +libg++-prototype .XPlex .Plex +libg++-prototype .PQ .defs +libg++-prototype .PHPQ .PQ +libg++-prototype .SplayPQ .PQ +libg++-prototype .XPPQ .PQ +libg++-prototype .Queue .defs +libg++-prototype .FPQueue .Queue .FPlex +libg++-prototype .SLQueue .Queue .SLList +libg++-prototype .VQueue .Queue +libg++-prototype .XPQueue .Queue .XPlex +libg++-prototype .Set .defs +libg++-prototype .AVLSet .Set +libg++-prototype .BSTSet .Set +libg++-prototype .CHSet .Set +libg++-prototype .OSLSet .Set .SLList +libg++-prototype .OXPSet .Set .XPlex +libg++-prototype .SLSet .Set .SLList +libg++-prototype .SplaySet .Set +libg++-prototype .VHSet .Set +libg++-prototype .VOHSet .Set +libg++-prototype .XPSet .Set .XPlex +libg++-prototype .Stack .defs +libg++-prototype .SLStack .Stack .SLList +libg++-prototype .FPStack .Stack .FPlex +libg++-prototype .VStack .Stack +libg++-prototype .XPStack .Stack .XPlex +libg++-prototype .Vec +libg++-prototype .AVec .Vec + diff --git a/gnu/lib/libg++/libg++/src/.cvsignore b/gnu/lib/libg++/libg++/src/.cvsignore new file mode 100644 index 00000000000..c4aa8aecb77 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/.cvsignore @@ -0,0 +1,3 @@ +Makefile +stamp +config.status diff --git a/gnu/lib/libg++/libg++/src/ACG.cc b/gnu/lib/libg++/libg++/src/ACG.cc new file mode 100644 index 00000000000..b8a3c89e582 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/ACG.cc @@ -0,0 +1,292 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 Free Software Foundation + +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 +#include + +// +// This is an extension of the older implementation of Algorithm M +// which I previously supplied. The main difference between this +// version and the old code are: +// +// + Andres searched high & low for good constants for +// the LCG. +// +// + theres more bit chopping going on. +// +// The following contains his comments. +// +// agn@UNH.CS.CMU.EDU sez.. +// +// The generator below is based on 2 well known +// methods: Linear Congruential (LCGs) and Additive +// Congruential generators (ACGs). +// +// The LCG produces the longest possible sequence +// of 32 bit random numbers, each being unique in +// that sequence (it has only 32 bits of state). +// It suffers from 2 problems: a) Independence +// isnt great, that is the (n+1)th number is +// somewhat related to the preceding one, unlike +// flipping a coin where knowing the past outcomes +// dont help to predict the next result. b) +// Taking parts of a LCG generated number can be +// quite non-random: for example, looking at only +// the least significant byte gives a permuted +// 8-bit counter (that has a period length of only +// 256). The advantage of an LCA is that it is +// perfectly uniform when run for the entire period +// length (and very uniform for smaller sequences +// too, if the parameters are chosen carefully). +// +// ACGs have extremly long period lengths and +// provide good independence. Unfortunately, +// uniformity isnt not too great. Furthermore, I +// didnt find any theoretically analysis of ACGs +// that addresses uniformity. +// +// The RNG given below will return numbers +// generated by an LCA that are permuted under +// control of a ACG. 2 permutations take place: the +// 4 bytes of one LCG generated number are +// subjected to one of 16 permutations selected by +// 4 bits of the ACG. The permutation a such that +// byte of the result may come from each byte of +// the LCG number. This effectively destroys the +// structure within a word. Finally, the sequence +// of such numbers is permuted within a range of +// 256 numbers. This greatly improves independence. +// +// +// Algorithm M as describes in Knuths "Art of Computer Programming", +// Vol 2. 1969 +// is used with a linear congruential generator (to get a good uniform +// distribution) that is permuted with a Fibonacci additive congruential +// generator to get good independence. +// +// Bit, byte, and word distributions were extensively tested and pass +// Chi-squared test near perfect scores (>7E8 numbers tested, Uniformity +// assumption holds with probability > 0.999) +// +// Run-up tests for on 7E8 numbers confirm independence with +// probability > 0.97. +// +// Plotting random points in 2d reveals no apparent structure. +// +// Autocorrelation on sequences of 5E5 numbers (A(i) = SUM X(n)*X(n-i), +// i=1..512) +// results in no obvious structure (A(i) ~ const). +// +// Except for speed and memory requirements, this generator outperforms +// random() for all tests. (random() scored rather low on uniformity tests, +// while independence test differences were less dramatic). +// +// AGN would like to.. +// thanks to M.Mauldin, H.Walker, J.Saxe and M.Molloy for inspiration & help. +// +// And I would (DGC) would like to thank Donald Kunth for AGN for letting me +// use his extensions in this implementation. +// + +// +// Part of the table on page 28 of Knuth, vol II. This allows us +// to adjust the size of the table at the expense of shorter sequences. +// + +static randomStateTable[][3] = { +{3,7,16}, {4,9, 32}, {3,10, 32}, {1,11, 32}, {1,15,64}, {3,17,128}, +{7,18,128}, {3,20,128}, {2,21, 128}, {1,22, 128}, {5,23, 128}, {3,25, 128}, +{2,29, 128}, {3,31, 128}, {13,33, 256}, {2,35, 256}, {11,36, 256}, +{14,39,256}, {3,41,256}, {9,49,256}, {3,52,256}, {24,55,256}, {7,57, 256}, +{19,58,256}, {38,89,512}, {17,95,512}, {6,97,512}, {11,98,512}, {-1,-1,-1} }; + +// +// spatial permutation table +// RANDOM_PERM_SIZE must be a power of two +// + +#define RANDOM_PERM_SIZE 64 +_G_uint32_t randomPermutations[RANDOM_PERM_SIZE] = { +0xffffffff, 0x00000000, 0x00000000, 0x00000000, // 3210 +0x0000ffff, 0x00ff0000, 0x00000000, 0xff000000, // 2310 +0xff0000ff, 0x0000ff00, 0x00000000, 0x00ff0000, // 3120 +0x00ff00ff, 0x00000000, 0xff00ff00, 0x00000000, // 1230 + +0xffff0000, 0x000000ff, 0x00000000, 0x0000ff00, // 3201 +0x00000000, 0x00ff00ff, 0x00000000, 0xff00ff00, // 2301 +0xff000000, 0x00000000, 0x000000ff, 0x00ffff00, // 3102 +0x00000000, 0x00000000, 0x00000000, 0xffffffff, // 2103 + +0xff00ff00, 0x00000000, 0x00ff00ff, 0x00000000, // 3012 +0x0000ff00, 0x00000000, 0x00ff0000, 0xff0000ff, // 2013 +0x00000000, 0x00000000, 0xffffffff, 0x00000000, // 1032 +0x00000000, 0x0000ff00, 0xffff0000, 0x000000ff, // 1023 + +0x00000000, 0xffffffff, 0x00000000, 0x00000000, // 0321 +0x00ffff00, 0xff000000, 0x00000000, 0x000000ff, // 0213 +0x00000000, 0xff000000, 0x0000ffff, 0x00ff0000, // 0132 +0x00000000, 0xff00ff00, 0x00000000, 0x00ff00ff // 0123 +}; + +// +// SEED_TABLE_SIZE must be a power of 2 +// +#define SEED_TABLE_SIZE 32 +static _G_uint32_t seedTable[SEED_TABLE_SIZE] = { +0xbdcc47e5, 0x54aea45d, 0xec0df859, 0xda84637b, +0xc8c6cb4f, 0x35574b01, 0x28260b7d, 0x0d07fdbf, +0x9faaeeb0, 0x613dd169, 0x5ce2d818, 0x85b9e706, +0xab2469db, 0xda02b0dc, 0x45c60d6e, 0xffe49d10, +0x7224fea3, 0xf9684fc9, 0xfc7ee074, 0x326ce92a, +0x366d13b5, 0x17aaa731, 0xeb83a675, 0x7781cb32, +0x4ec7c92d, 0x7f187521, 0x2cf346b4, 0xad13310f, +0xb89cff2b, 0x12164de1, 0xa865168d, 0x32b56cdf +}; + +// +// The LCG used to scramble the ACG +// +// +// LC-parameter selection follows recommendations in +// "Handbook of Mathematical Functions" by Abramowitz & Stegun 10th, edi. +// +// LC_A = 251^2, ~= sqrt(2^32) = 66049 +// LC_C = result of a long trial & error series = 3907864577 +// + +static const _G_uint32_t LC_A = 66049; +static const _G_uint32_t LC_C = 3907864577; +static inline _G_uint32_t LCG(_G_uint32_t x) +{ + return( x * LC_A + LC_C ); +} + + +ACG::ACG(_G_uint32_t seed, int size) +{ + register int l; + initialSeed = seed; + + // + // Determine the size of the state table + // + + for (l = 0; + randomStateTable[l][0] != -1 && randomStateTable[l][1] < size; + l++); + + if (randomStateTable[l][1] == -1) { + l--; + } + + initialTableEntry = l; + + stateSize = randomStateTable[ initialTableEntry ][ 1 ]; + auxSize = randomStateTable[ initialTableEntry ][ 2 ]; + + // + // Allocate the state table & the auxillary table in a single malloc + // + + state = new _G_uint32_t[stateSize + auxSize]; + auxState = &state[stateSize]; + + reset(); +} + +// +// Initialize the state +// +void +ACG::reset() +{ + register _G_uint32_t u; + + if (initialSeed < SEED_TABLE_SIZE) { + u = seedTable[ initialSeed ]; + } else { + u = initialSeed ^ seedTable[ initialSeed & (SEED_TABLE_SIZE-1) ]; + } + + + j = randomStateTable[ initialTableEntry ][ 0 ] - 1; + k = randomStateTable[ initialTableEntry ][ 1 ] - 1; + + register int i; + for(i = 0; i < stateSize; i++) { + state[i] = u = LCG(u); + } + + for (i = 0; i < auxSize; i++) { + auxState[i] = u = LCG(u); + } + + k = u % stateSize; + int tailBehind = (stateSize - randomStateTable[ initialTableEntry ][ 0 ]); + j = k - tailBehind; + if (j < 0) { + j += stateSize; + } + + lcgRecurr = u; + + assert(sizeof(double) == 2 * sizeof(_G_int32_t)); +} + +ACG::~ACG() +{ + if (state) delete state; + state = 0; + // don't delete auxState, it's really an alias for state. +} + +// +// Returns 32 bits of random information. +// + +_G_uint32_t +ACG::asLong() +{ + _G_uint32_t result = state[k] + state[j]; + state[k] = result; + j = (j <= 0) ? (stateSize-1) : (j-1); + k = (k <= 0) ? (stateSize-1) : (k-1); + + short int auxIndex = (result >> 24) & (auxSize - 1); + register _G_uint32_t auxACG = auxState[auxIndex]; + auxState[auxIndex] = lcgRecurr = LCG(lcgRecurr); + + // + // 3c is a magic number. We are doing four masks here, so we + // do not want to run off the end of the permutation table. + // This insures that we have always got four entries left. + // + register _G_uint32_t *perm = & randomPermutations[result & 0x3c]; + + result = *(perm++) & auxACG; + result |= *(perm++) & ((auxACG << 24) + | ((auxACG >> 8)& 0xffffff)); + result |= *(perm++) & ((auxACG << 16) + | ((auxACG >> 16) & 0xffff)); + result |= *(perm++) & ((auxACG << 8) + | ((auxACG >> 24) & 0xff)); + + return(result); +} diff --git a/gnu/lib/libg++/libg++/src/ACG.h b/gnu/lib/libg++/libg++/src/ACG.h new file mode 100644 index 00000000000..aa1d25914a8 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/ACG.h @@ -0,0 +1,68 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _ACG_h +#define _ACG_h 1 + +#include +#include +#ifdef __GNUG__ +#pragma interface +#endif + +// +// Additive number generator. This method is presented in Volume II +// of The Art of Computer Programming by Knuth. I've coded the algorithm +// and have added the extensions by Andres Nowatzyk of CMU to randomize +// the result of algorithm M a bit by using an LCG & a spatial +// permutation table. +// +// The version presented uses the same constants for the LCG that Andres +// uses (chosen by trial & error). The spatial permutation table is +// the same size (it's based on word size). This is for 32-bit words. +// +// The ``auxillary table'' used by the LCG table varies in size, and +// is chosen to be the the smallest power of two which is larger than +// twice the size of the state table. +// + +class ACG : public RNG { + + _G_uint32_t initialSeed; // used to reset generator + int initialTableEntry; + + _G_uint32_t *state; + _G_uint32_t *auxState; + short stateSize; + short auxSize; + _G_uint32_t lcgRecurr; + short j; + short k; + +protected: + +public: + ACG(_G_uint32_t seed = 0, int size = 55); + virtual ~ACG(); + // + // Return a long-words word of random bits + // + virtual _G_uint32_t asLong(); + virtual void reset(); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/AllocRing.cc b/gnu/lib/libg++/libg++/src/AllocRing.cc new file mode 100644 index 00000000000..519f36486d1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/AllocRing.cc @@ -0,0 +1,110 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 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 +#include +#include + +AllocRing::AllocRing(int max) + :n(max), current(0), nodes(new AllocQNode[max]) +{ + for (int i = 0; i < n; ++i) + { + nodes[i].ptr = 0; + nodes[i].sz = 0; + } +} + +int AllocRing::find(void* p) +{ + if (p == 0) return -1; + + for (int i = 0; i < n; ++i) + if (nodes[i].ptr == p) + return i; + + return -1; +} + + +void AllocRing::clear() +{ + for (int i = 0; i < n; ++i) + { + if (nodes[i].ptr != 0) + { + delete(nodes[i].ptr); + nodes[i].ptr = 0; + } + nodes[i].sz = 0; + } + current = 0; +} + + +void AllocRing::free(void* p) +{ + int idx = find(p); + if (idx >= 0) + { + delete nodes[idx].ptr; + nodes[idx].ptr = 0; + } +} + +AllocRing::~AllocRing() +{ + clear(); +} + +int AllocRing::contains(void* p) +{ + return find(p) >= 0; +} + +static inline unsigned int good_size(unsigned int s) +{ + unsigned int req = s + 4; + unsigned int good = 8; + while (good < req) good <<= 1; + return good - 4; +} + +void* AllocRing::alloc(int s) +{ + unsigned int size = good_size(s); + + void* p; + if (nodes[current].ptr != 0 && + nodes[current].sz >= int(size) && + nodes[current].sz < int(4 * size)) + p = nodes[current].ptr; + else + { + if (nodes[current].ptr != 0) operator delete (nodes[current].ptr); + p = operator new (size); + nodes[current].ptr = p; + nodes[current].sz = size; + } + ++current; + if (current >= n) current = 0; + return p; +} diff --git a/gnu/lib/libg++/libg++/src/AllocRing.h b/gnu/lib/libg++/libg++/src/AllocRing.h new file mode 100644 index 00000000000..fc8b30c44d5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/AllocRing.h @@ -0,0 +1,62 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 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. +*/ + + +#ifndef _AllocRing_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _AllocRing_h 1 + + +/* + An AllocRing holds the last n malloc'ed strings, reallocating/reusing + one only when the queue wraps around. It thus guarantees that the + last n allocations are intact. It is useful for things like I/O + formatting where reasonable restrictions may be made about the + number of allowable live allocations before auto-deletion. +*/ + +class AllocRing +{ + + struct AllocQNode + { + void* ptr; + int sz; + }; + + AllocQNode* nodes; + int n; + int current; + + int find(void* p); + +public: + + AllocRing(int max); + ~AllocRing(); + + void* alloc(int size); + int contains(void* ptr); + void clear(); + void free(void* p); +}; + + +#endif diff --git a/gnu/lib/libg++/libg++/src/Binomial.cc b/gnu/lib/libg++/libg++/src/Binomial.cc new file mode 100644 index 00000000000..8e2b56d71ab --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Binomial.cc @@ -0,0 +1,34 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double Binomial::operator()() +{ + int s = 0; + for (int i = 0; i < pN; i++) { + if (pGenerator -> asDouble() < pU) { + s++; + } + } + return(double(s)); +} + diff --git a/gnu/lib/libg++/libg++/src/Binomial.h b/gnu/lib/libg++/libg++/src/Binomial.h new file mode 100644 index 00000000000..8ce241d6f4e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Binomial.h @@ -0,0 +1,55 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Binomial_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Binomial_h 1 + +#include + +class Binomial: public Random { +protected: + int pN; + double pU; +public: + Binomial(int n, double u, RNG *gen); + + int n(); + int n(int xn); + + double u(); + double u(int xu); + + virtual double operator()(); + +}; + + +inline Binomial::Binomial(int n, double u, RNG *gen) +: Random(gen){ + pN = n; pU = u; +} + +inline int Binomial::n() { return pN; } +inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; } + +inline double Binomial::u() { return pU; } +inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; } + +#endif diff --git a/gnu/lib/libg++/libg++/src/BitSet.cc b/gnu/lib/libg++/libg++/src/BitSet.cc new file mode 100644 index 00000000000..dd1f6503990 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/BitSet.cc @@ -0,0 +1,1101 @@ +/* +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. +*/ + +/* + BitSet class implementation + */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef OK + +void BitSet::error(const char* msg) const +{ + (*lib_error_handler)("BitSet", msg); +} + +// globals & constants + +BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here + +#define ONES ((_BS_word)(~0L)) +#define MAXBitSetRep_SIZE ((1U << (sizeof(unsigned short)*CHAR_BIT - 1)) - 1) +#define MINBitSetRep_SIZE (sizeof(_BS_word)*CHAR_BIT) + +#ifndef MALLOC_MIN_OVERHEAD +#define MALLOC_MIN_OVERHEAD 4 +#endif + +// break things up into .s indices and positions + + +// mask out bits from left + +static inline _BS_word lmask(int p) +{ + return ONES << p; +} + +// mask out high bits + +static inline _BS_word rmask(int p) +{ + return ONES >> (BITSETBITS - 1 - p); +} + + +inline static BitSetRep* BSnew(int newlen) +{ + unsigned int siz = sizeof(BitSetRep) + newlen * sizeof(_BS_word) + + MALLOC_MIN_OVERHEAD; + unsigned int allocsiz = MINBitSetRep_SIZE;; + while (allocsiz < siz) allocsiz <<= 1; + allocsiz -= MALLOC_MIN_OVERHEAD; + if (allocsiz >= MAXBitSetRep_SIZE * sizeof(_BS_word)) + (*lib_error_handler)("BitSet", "Requested length out of range"); + + BitSetRep* rep = new (operator new (allocsiz)) BitSetRep; + memset(rep, 0, allocsiz); + rep->sz = (allocsiz - sizeof(BitSetRep) + sizeof(_BS_word)) / sizeof(_BS_word); + return rep; +} + +BitSetRep* BitSetalloc(BitSetRep* old, const _BS_word* src, int srclen, + int newvirt, int newlen) +{ + if (old == &_nilBitSetRep) old = 0; + BitSetRep* rep; + if (old == 0 || newlen >= old->sz) + rep = BSnew(newlen); + else + rep = old; + + rep->len = newlen; + rep->virt = newvirt; + + if (srclen != 0 && src != rep->s) + memcpy(rep->s, src, srclen * sizeof(_BS_word)); + // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus + if (rep->virt) + memset(&rep->s[srclen], ONES, (newlen - srclen) * sizeof(_BS_word)); + if (old != rep && old != 0) delete old; + return rep; +} + +BitSetRep* BitSetresize(BitSetRep* old, int newlen) +{ + BitSetRep* rep; + if (old == 0 || old == &_nilBitSetRep) + { + rep = BSnew(newlen); + rep->virt = 0; + } + else if (newlen >= old->sz) + { + rep = BSnew(newlen); + memcpy(rep->s, old->s, old->len * sizeof(_BS_word)); + rep->virt = old->virt; + // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus + if (rep->virt) + memset(&rep->s[old->len], ONES, (newlen - old->len) * sizeof(_BS_word)); + delete old; + } + else + { + rep = old; + if (rep->len < newlen) + memset(&rep->s[rep->len], + rep->virt ? ONES : 0, + (newlen - rep->len) * sizeof(_BS_word)); + } + + rep->len = newlen; + + return rep; +} + +// same, for straight copy + +BitSetRep* BitSetcopy(BitSetRep* old, const BitSetRep* src) +{ + BitSetRep* rep; + if (old == &_nilBitSetRep) old = 0; + if (src == 0 || src == &_nilBitSetRep) + { + if (old == 0) + rep = BSnew(0); + else + rep = old; + rep->len = 0; + rep->virt = 0; + } + else if (old == src) + return old; + else + { + int newlen = src->len; + if (old == 0 || newlen > old->sz) + { + rep = BSnew(newlen); + if (old != 0) delete old; + } + else + rep = old; + + memcpy(rep->s, src->s, newlen * sizeof(_BS_word)); + rep->len = newlen; + rep->virt = src->virt; + } + return rep; +} + + +// remove unneeded top bits + +inline static void trim(BitSetRep* rep) +{ + int l = rep->len; + _BS_word* s = &(rep->s[l - 1]); + + if (rep->virt == 0) + while (l > 0 && *s-- == 0) --l; + else + while (l > 0 && *s-- == ONES) --l; + rep->len = l; +} + +int operator == (const BitSet& x, const BitSet& y) +{ + if (x.rep->virt != y.rep->virt) + return 0; + int xl = x.rep->len; + int yl = y.rep->len; + + const _BS_word* xs = x.rep->s; + const _BS_word* ys = y.rep->s; + if (xl < yl) { + if (memcmp((void*)xs, (void*)ys, xl * sizeof(_BS_word))) + return 0; + ys+=xl; + const _BS_word* topy = &(ys[yl]); + while (ysvirt?((*ys++)!=ONES):((*ys++)!=0)) + return 0; + } + else { + if (memcmp((void*)xs, (void*)ys, yl * sizeof(_BS_word))) + return 0; + if (xl > yl) { + xs+=yl; + const _BS_word* topx = &(xs[xl]); + while (xsvirt?((*xs++)!=ONES):((*xs++)!=0)) + return 0; + } + } + return 1; +} + +int operator <= (const BitSet& x, const BitSet& y) +{ + if (x.rep->virt > y.rep->virt) + return 0; + + int xl = x.rep->len; + int yl = y.rep->len; + + const _BS_word* xs = x.rep->s; + const _BS_word* ys = y.rep->s; + const _BS_word* topx = &(xs[xl]); + const _BS_word* topy = &(ys[yl]); + + while (xs < topx && ys < topy) + { + _BS_word a = *xs++; + _BS_word b = *ys++; + if ((a | b) != b) + return 0; + } + if (xl < yl) { + if (x.rep->virt) { + while (ys yl) { + if (!y.rep->virt) { + while (xsvirt > y.rep->virt) + return 0; + + int xl = x.rep->len; + int yl = y.rep->len; + + _BS_word* xs = x.rep->s; + _BS_word* ys = y.rep->s; + _BS_word* topx = &(xs[xl]); + _BS_word* topy = &(ys[yl]); + int one_diff = 0; + while (xs < topx && ys < topy) + { + _BS_word a = *xs++; + _BS_word b = *ys++; + _BS_word c = a | b; + if (c != b) + return 0; + else if (c != a) + one_diff = 1; + } + if (xl < yl) { + if (x.rep->virt) { + if (!one_diff) + return 0; + while (ysvirt) + return 1; + while (ys yl) { + if (y.rep->virt) { + if (one_diff || !x.rep->virt) + return 1; + while (xsvirt < y.rep->virt; +} + +int lcompare(const BitSet& x, const BitSet& y) +{ + int xl = x.rep->len; + int yl = y.rep->len; + + const _BS_word* xs = x.rep->s; + const _BS_word* ys = y.rep->s; + const _BS_word* topx = &(xs[xl]); + const _BS_word* topy = &(ys[yl]); + + while (xs < topx && ys < topy) + { + _BS_word a = *xs++; + _BS_word b = *ys++; + if (a!=b) { +#if 0 + // Faster but opinable + return (ab) + return 1; + } + if (xl < yl) { + if (x.rep->virt) { + while (ys yl) { + if (y.rep->virt) { + while (xsvirt == 1) + return 0; + + _BS_word* bots = rep->s; + _BS_word* s = &(bots[rep->len - 1]); + while (s >= bots) if (*s-- != 0) return 0; + return 1; +} + + +int BitSet::count(int b) const +{ + if (b == rep->virt) + return -1; + int l = 0; + _BS_word* s = rep->s; + _BS_word* tops = &(s[rep->len]); + if (b == 1) + { + while (s < tops) + { + _BS_word a = *s++; + for (int i = 0; i < BITSETBITS && a != 0; ++i) + { + if (a & 1) + ++l; + a >>= 1; + } + } + } + else + { + _BS_word maxbit = 1U << (BITSETBITS - 1); + while (s < tops) + { + _BS_word a = *s++; + for (int i = 0; i < BITSETBITS; ++i) + { + if ((a & maxbit) == 0) + ++l; + a <<= 1; + } + } + } + return l; +} + +BitSetRep* BitSetcmpl(const BitSetRep* src, BitSetRep* r) +{ + r = BitSetcopy(r, src); + r->virt = !src->virt; + _BS_word* rs = r->s; + _BS_word* topr = &(rs[r->len]); + if (r->len == 0) + *rs = ONES; + else + { + while (rs < topr) + { + _BS_word cmp = ~(*rs); + *rs++ = cmp; + } + } + trim(r); + return r; +} + + +BitSetRep* BitSetop(const BitSetRep* x, const BitSetRep* y, + BitSetRep* r, char op) +{ + int xrsame = x == r; + int yrsame = y == r; + int xv = x->virt; + int yv = y->virt; + int xl = x->len; + int yl = y->len; + int rl = (xl >= yl)? xl : yl; + + r = BitSetresize(r, rl); + _BS_word* rs = r->s; + _BS_word* topr = &(rs[rl]); + + int av, bv; + const _BS_word* as; + const _BS_word* topa; + const _BS_word* bs; + const _BS_word* topb; + + if (xl <= yl) + { + as = (xrsame)? r->s : x->s; + av = xv; + topa = &(as[xl]); + bs = (yrsame)? r->s : y->s; + bv = yv; + topb = &(bs[yl]); + } + else + { + as = (yrsame)? r->s : y->s; + av = yv; + topa = &(as[yl]); + bs = (xrsame)? r->s : x->s; + bv = xv; + topb = &(bs[xl]); + if (op == '-') // reverse sense of difference + op = 'D'; + } + + switch (op) + { + case '&': + r->virt = av & bv; + while (as < topa) *rs++ = *as++ & *bs++; + if (av) + while (rs < topr) *rs++ = *bs++; + else + while (rs < topr) *rs++ = 0; + break; + case '|': + r->virt = av | bv; + while (as < topa) *rs++ = *as++ | *bs++; + if (av) + while (rs < topr) *rs++ = ONES; + else + while (rs < topr) *rs++ = *bs++; + break; + case '^': + r->virt = av ^ bv; + while (as < topa) *rs++ = *as++ ^ *bs++; + if (av) + while (rs < topr) *rs++ = ~(*bs++); + else + while (rs < topr) *rs++ = *bs++; + break; + case '-': + r->virt = av & ~(bv); + while (as < topa) *rs++ = *as++ & ~(*bs++); + if (av) + while (rs < topr) *rs++ = ~(*bs++); + else + while (rs < topr) *rs++ = 0; + break; + case 'D': + r->virt = ~(av) & (bv); + while (as < topa) *rs++ = ~(*as++) & (*bs++); + if (av) + while (rs < topr) *rs++ = 0; + else + while (rs < topr) *rs++ = *bs++; + break; + } + trim(r); + return r; +} + + +void BitSet::set(int p) +{ + if (p < 0) error("Illegal bit index"); + + int index = BitSet_index(p); + int pos = BitSet_pos(p); + + if (index >= rep->len) + { + if (rep->virt) + return; + else + rep = BitSetresize(rep, index+1); + } + + rep->s[index] |= (1U << pos); +} + +void BitSet::clear() +{ + if (rep->len > 0) memset(rep->s, 0, rep->sz * sizeof(_BS_word)); + rep->len = rep->virt = 0; +} + +void BitSet::clear(int p) +{ + if (p < 0) error("Illegal bit index"); + int index = BitSet_index(p); + if (index >= rep->len) + { + if (rep->virt == 0) + return; + else + rep = BitSetresize(rep, index+1); + } + rep->s[index] &= ~(1U << BitSet_pos(p)); +} + +void BitSet::invert(int p) +{ + if (p < 0) error("Illegal bit index"); + int index = BitSet_index(p); + if (index >= rep->len) rep = BitSetresize(rep, index+1); + rep->s[index] ^= (1U << BitSet_pos(p)); +} + +void BitSet::set(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + + int index1 = BitSet_index(from); + int pos1 = BitSet_pos(from); + + if (rep->virt && index1 >= rep->len) + return; + + int index2 = BitSet_index(to); + int pos2 = BitSet_pos(to); + + if (index2 >= rep->len) + rep = BitSetresize(rep, index2+1); + + _BS_word* s = &(rep->s[index1]); + _BS_word m1 = lmask(pos1); + _BS_word m2 = rmask(pos2); + if (index2 == index1) + *s |= m1 & m2; + else + { + *s++ |= m1; + _BS_word* top = &(rep->s[index2]); + *top |= m2; + while (s < top) + *s++ = ONES; + } +} + +void BitSet::clear(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + + int index1 = BitSet_index(from); + int pos1 = BitSet_pos(from); + + if (!rep->virt && index1 >= rep->len) + return; + + int index2 = BitSet_index(to); + int pos2 = BitSet_pos(to); + + if (index2 >= rep->len) + rep = BitSetresize(rep, index2+1); + + _BS_word* s = &(rep->s[index1]); + _BS_word m1 = lmask(pos1); + _BS_word m2 = rmask(pos2); + if (index2 == index1) + *s &= ~(m1 & m2); + else + { + *s++ &= ~m1; + _BS_word* top = &(rep->s[index2]); + *top &= ~m2; + while (s < top) + *s++ = 0; + } +} + +void BitSet::invert(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + + int index1 = BitSet_index(from); + int pos1 = BitSet_pos(from); + int index2 = BitSet_index(to); + int pos2 = BitSet_pos(to); + + if (index2 >= rep->len) + rep = BitSetresize(rep, index2+1); + + _BS_word* s = &(rep->s[index1]); + _BS_word m1 = lmask(pos1); + _BS_word m2 = rmask(pos2); + if (index2 == index1) + *s ^= m1 & m2; + else + { + *s++ ^= m1; + _BS_word* top = &(rep->s[index2]); + *top ^= m2; + while (s < top) + { + _BS_word cmp = ~(*s); + *s++ = cmp; + } + } +} + + +int BitSet::test(int from, int to) const +{ + if (from < 0 || from > to) return 0; + + int index1 = BitSet_index(from); + int pos1 = BitSet_pos(from); + + if (index1 >= rep->len) + return rep->virt; + + int index2 = BitSet_index(to); + int pos2 = BitSet_pos(to); + + if (index2 >= rep->len) + { + if (rep->virt) + return 1; + else + { + index2 = rep->len - 1; + pos2 = BITSETBITS - 1; + } + } + + _BS_word* s = &(rep->s[index1]); + _BS_word m1 = lmask(pos1); + _BS_word m2 = rmask(pos2); + + if (index2 == index1) + return (*s & m1 & m2) != 0; + else + { + if (*s++ & m1) + return 1; + _BS_word* top = &(rep->s[index2]); + if (*top & m2) + return 1; + while (s < top) + if (*s++ != 0) + return 1; + return 0; + } +} + +int BitSet::next(int p, int b) const +{ + ++p; + int index = BitSet_index(p); + int pos = BitSet_pos(p); + + int l = rep->len; + + if (index >= l) + { + if (rep->virt == b) + return p; + else + return -1; + } + int j = index; + _BS_word* s = rep->s; + _BS_word a = s[j] >> pos; + int i = pos; + + if (b == 1) + { + for (; i < BITSETBITS && a != 0; ++i) + { + if (a & 1) + return j * BITSETBITS + i; + a >>= 1; + } + for (++j; j < l; ++j) + { + a = s[j]; + for (i = 0; i < BITSETBITS && a != 0; ++i) + { + if (a & 1) + return j * BITSETBITS + i; + a >>= 1; + } + } + if (rep->virt) + return j * BITSETBITS; + else + return -1; + } + else + { + for (; i < BITSETBITS; ++i) + { + if ((a & 1) == 0) + return j * BITSETBITS + i; + a >>= 1; + } + for (++j; j < l; ++j) + { + a = s[j]; + if (a != ONES) + { + for (i = 0; i < BITSETBITS; ++i) + { + if ((a & 1) == 0) + return j * BITSETBITS + i; + a >>= 1; + } + } + } + if (!rep->virt) + return j * BITSETBITS; + else + return -1; + } +} + +int BitSet::prev(int p, int b) const +{ + if (--p < 0) + return -1; + + int index = BitSet_index(p); + int pos = BitSet_pos(p); + + _BS_word* s = rep->s; + int l = rep->len; + + if (index >= l) + { + if (rep->virt == b) + return p; + else + { + index = l - 1; + pos = BITSETBITS - 1; + } + } + + int j = index; + _BS_word a = s[j]; + + int i = pos; + _BS_word maxbit = 1U << pos; + + if (b == 1) + { + for (; i >= 0 && a != 0; --i) + { + if (a & maxbit) + return j * BITSETBITS + i; + a <<= 1; + } + maxbit = 1U << (BITSETBITS - 1); + for (--j; j >= 0; --j) + { + a = s[j]; + for (i = BITSETBITS - 1; i >= 0 && a != 0; --i) + { + if (a & maxbit) + return j * BITSETBITS + i; + a <<= 1; + } + } + return -1; + } + else + { + if (a != ONES) + { + for (; i >= 0; --i) + { + if ((a & maxbit) == 0) + return j * BITSETBITS + i; + a <<= 1; + } + } + maxbit = 1U << (BITSETBITS - 1); + for (--j; j >= 0; --j) + { + a = s[j]; + if (a != ONES) + { + for (i = BITSETBITS - 1; i >= 0; --i) + { + if ((a & maxbit) == 0) + return j * BITSETBITS + i; + a <<= 1; + } + } + } + return -1; + } +} + +int BitSet::last(int b) const +{ + if (b == rep->virt) + return -1; + else + return prev((rep->len) * BITSETBITS, b); +} + + +extern AllocRing _libgxx_fmtq; + +const char* BitSettoa(const BitSet& x, char f, char t, char star) +{ + trim(x.rep); + int wrksiz = (x.rep->len + 1) * BITSETBITS + 2; + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + ostrstream stream(fmtbase, wrksiz); + + x.printon(stream, f, t, star); + stream << ends; + return fmtbase; +} + +BitSet shorttoBitSet(unsigned short i) +{ + BitSet r; + _BS_word w = i; + r.rep = BitSetalloc(0, &w, 1, 0, 2); trim(r.rep); + return r; +} + +BitSet longtoBitSet(unsigned long i) +{ + BitSet r; +#if 1 + _BS_word w = i; + r.rep = BitSetalloc(0, &w, 1, 0, 2); +#else + _BS_word u[2]; + u[0] = i & ((_BS_word)(~(0))); + u[1] = sizeof(long) <= sizeof(_BS_word) ? 0 : i >> BITSETBITS; + r.rep = BitSetalloc(0, &u[0], 2, 0, 3); +#endif + trim(r.rep); + return r; +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +BitSet atoBitSet(const char* s, char f, char t, char star) return r +{ + int sl = strlen(s); + if (sl != 0) + { + r.rep = BitSetresize(r.rep, sl / BITSETBITS + 1); + _BS_word* rs = r.rep->s; + _BS_word a = 0; + _BS_word m = 1; + char lastch = 0; + unsigned int i = 0; + unsigned int l = 1; + for(;;) + { + char ch = s[i]; + if (ch == t) + a |= m; + else if (ch == star) + { + if ((r.rep->virt = (lastch == t))) + *rs = a | ~(m - 1); + else + *rs = a; + break; + } + else if (ch != f) + { + *rs = a; + break; + } + lastch = ch; + if (++i == sl) + { + *rs = a; + break; + } + else if (i % BITSETBITS == 0) + { + *rs++ = a; + a = 0; + m = 1; + ++l; + } + else + m <<= 1; + } + r.rep->len = l; + trim(r.rep); + } + return; +} + +#else + +BitSet atoBitSet(const char* s, char f, char t, char star) +{ + BitSet r; + int sl = strlen(s); + if (sl != 0) + { + r.rep = BitSetresize(r.rep, sl / BITSETBITS + 1); + _BS_word* rs = r.rep->s; + _BS_word a = 0; + _BS_word m = 1; + char lastch = 0; + unsigned int i = 0; + unsigned int l = 1; + for(;;) + { + char ch = s[i]; + if (ch == t) + a |= m; + else if (ch == star) + { + if (r.rep->virt = lastch == t) + *rs = a | ~(m - 1); + else + *rs = a; + break; + } + else if (ch != f) + { + *rs = a; + break; + } + lastch = ch; + if (++i == sl) + { + *rs = a; + break; + } + else if (i % BITSETBITS == 0) + { + *rs++ = a; + a = 0; + m = 1; + ++l; + } + else + m <<= 1; + } + r.rep->len = l; + trim(r.rep); + } + return r; +} + +#endif + +ostream& operator << (ostream& s, const BitSet& x) +{ + if (s.opfx()) + x.printon(s); + return s; +} + +void BitSet::printon(ostream& os, char f, char t, char star) const +// FIXME: Does not respect s.width()! +{ + trim(rep); + register streambuf* sb = os.rdbuf(); + const _BS_word* s = rep->s; + const _BS_word* top = &(s[rep->len - 1]); + + while (s < top) + { + _BS_word a = *s++; + for (int j = 0; j < BITSETBITS; ++j) + { + sb->sputc((a & 1)? t : f); + a >>= 1; + } + } + + if (!rep->virt) + { + _BS_word a = *s; + if (rep->len != 0) + { + for (int j = 0; j < BITSETBITS && a != 0; ++j) + { + sb->sputc((a & 1)? t : f); + a >>= 1; + } + } + sb->sputc(f); + } + else + { + _BS_word a = *s; + _BS_word mask = ONES; + _BS_word himask = (1U << (BITSETBITS - 1)) - 1; + if (rep->len != 0) + { + for (int j = 0; j < BITSETBITS && a != mask; ++j) + { + sb->sputc((a & 1)? t : f); + a = (a >> 1) & himask; + mask = (mask >> 1) & himask; + } + } + sb->sputc(t); + } + + sb->sputc(star); +} + +int BitSet::OK() const +{ + int v = rep != 0; // have a rep + v &= rep->len <= rep->sz; // within bounds + v &= rep->virt == 0 || rep->virt == 1; // valid virtual bit + if (!v) error("invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/BitSet.h b/gnu/lib/libg++/libg++/src/BitSet.h new file mode 100644 index 00000000000..491102d50e8 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/BitSet.h @@ -0,0 +1,370 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + +#ifndef _BitSet_h +#ifdef __GNUG__ +#pragma interface +#endif + +#define _BitSet_h 1 + +#include +#include +#include + +#undef OK + +#define BITSETBITS (sizeof(_BS_word) * CHAR_BIT) + +struct BitSetRep +{ + unsigned short len; // number of _BS_word in s + unsigned short sz; // allocated slots + unsigned short virt; // virtual 0 or 1 + _BS_word s[1]; // bits start here +}; + +extern BitSetRep* BitSetalloc(BitSetRep*, const _BS_word*, + int, int, int); +extern BitSetRep* BitSetcopy(BitSetRep*, const BitSetRep*); +extern BitSetRep* BitSetresize(BitSetRep*, int); +extern BitSetRep* BitSetop(const BitSetRep*, const BitSetRep*, + BitSetRep*, char); +extern BitSetRep* BitSetcmpl(const BitSetRep*, BitSetRep*); + + +extern BitSetRep _nilBitSetRep; + +class BitSet; + +class BitSetBit +{ +protected: + BitSet* src; + unsigned long pos; + + public: + BitSetBit(BitSet* v, int p); + BitSetBit(const BitSetBit& b); + ~BitSetBit(); + operator int() const; + int operator = (int b); + int operator = (const BitSetBit& b); +}; + +class BitSet +{ +protected: + BitSetRep* rep; + + +public: + +// constructors + BitSet(); + BitSet(const BitSet&); + + ~BitSet(); + + BitSet& operator = (const BitSet& y); + +// equality & subset tests + + friend int operator == (const BitSet& x, const BitSet& y); + friend int operator != (const BitSet& x, const BitSet& y); + friend int operator < (const BitSet& x, const BitSet& y); + friend int operator <= (const BitSet& x, const BitSet& y); + friend int operator > (const BitSet& x, const BitSet& y); + friend int operator >= (const BitSet& x, const BitSet& y); + friend int lcompare(const BitSet& x, const BitSet& y); + + +// operations on self + + BitSet& operator |= (const BitSet& y); + BitSet& operator &= (const BitSet& y); + BitSet& operator -= (const BitSet& y); + BitSet& operator ^= (const BitSet& y); + + void complement(); + +// individual bit manipulation + + void set(int pos); + void set(int from, int to); + void set(); // set all + + void clear(int pos); + void clear(int from, int to); + void clear(); // clear all + + void invert(int pos); + void invert(int from, int to); + + int test(int pos) const; + int test(int from, int to) const; + + BitSetBit operator [] (int i); + +// iterators + + int first(int b = 1) const; + int last(int b = 1) const; + + int next(int pos, int b = 1) const; + int prev(int pos, int b = 1) const; + int previous(int pos, int b = 1) const /* Obsolete synonym */ + { return prev(pos, b); } + +// status + + int empty() const; + int virtual_bit() const; + int count(int b = 1) const; + +// convertors & IO + + friend BitSet atoBitSet(const char* s, + char f='0', char t='1', char star='*'); + // BitSettoa is deprecated; do not use in new programs. + friend const char* BitSettoa(const BitSet& x, + char f='0', char t='1', char star='*'); + + friend BitSet shorttoBitSet(unsigned short w); + friend BitSet longtoBitSet(unsigned long w); + + friend ostream& operator << (ostream& s, const BitSet& x); + void printon(ostream& s, + char f='0', char t='1', char star='*') const; + +// procedural versions of operators + + friend void and(const BitSet& x, const BitSet& y, BitSet& r); + friend void or(const BitSet& x, const BitSet& y, BitSet& r); + friend void xor(const BitSet& x, const BitSet& y, BitSet& r); + friend void diff(const BitSet& x, const BitSet& y, BitSet& r); + friend void complement(const BitSet& x, BitSet& r); + +// misc + + void error(const char* msg) const; + int OK() const; +}; + + +typedef BitSet BitSetTmp; + +// These are inlined regardless of optimization + +inline int BitSet_index(int l) +{ + return (unsigned)(l) / BITSETBITS; +} + +inline int BitSet_pos(int l) +{ + return l & (BITSETBITS - 1); +} + + +inline BitSet::BitSet() : rep(&_nilBitSetRep) {} + +inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {} + +inline BitSet::~BitSet() { if (rep != &_nilBitSetRep) delete rep; } + +inline BitSet& BitSet::operator = (const BitSet& y) +{ + rep = BitSetcopy(rep, y.rep); + return *this; +} + +inline int operator != (const BitSet& x, const BitSet& y) { return !(x == y); } + +inline int operator > (const BitSet& x, const BitSet& y) { return y < x; } + +inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; } + +inline void and(const BitSet& x, const BitSet& y, BitSet& r) +{ + r.rep = BitSetop(x.rep, y.rep, r.rep, '&'); +} + +inline void or(const BitSet& x, const BitSet& y, BitSet& r) +{ + r.rep = BitSetop(x.rep, y.rep, r.rep, '|'); +} + +inline void xor(const BitSet& x, const BitSet& y, BitSet& r) +{ + r.rep = BitSetop(x.rep, y.rep, r.rep, '^'); +} + +inline void diff(const BitSet& x, const BitSet& y, BitSet& r) +{ + r.rep = BitSetop(x.rep, y.rep, r.rep, '-'); +} + +inline void complement(const BitSet& x, BitSet& r) +{ + r.rep = BitSetcmpl(x.rep, r.rep); +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +inline BitSet operator & (const BitSet& x, const BitSet& y) return r +{ + and(x, y, r); +} + +inline BitSet operator | (const BitSet& x, const BitSet& y) return r +{ + or(x, y, r); +} + +inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r +{ + xor(x, y, r); +} + +inline BitSet operator - (const BitSet& x, const BitSet& y) return r +{ + diff(x, y, r); +} + +inline BitSet operator ~ (const BitSet& x) return r +{ + ::complement(x, r); +} + +#else /* NO_NRV */ + +inline BitSet operator & (const BitSet& x, const BitSet& y) +{ + BitSet r; and(x, y, r); return r; +} + +inline BitSet operator | (const BitSet& x, const BitSet& y) +{ + BitSet r; or(x, y, r); return r; +} + +inline BitSet operator ^ (const BitSet& x, const BitSet& y) +{ + BitSet r; xor(x, y, r); return r; +} + +inline BitSet operator - (const BitSet& x, const BitSet& y) +{ + BitSet r; diff(x, y, r); return r; +} + +inline BitSet operator ~ (const BitSet& x) +{ + BitSet r; ::complement(x, r); return r; +} + +#endif + +inline BitSet& BitSet::operator &= (const BitSet& y) +{ + and(*this, y, *this); + return *this; +} + +inline BitSet& BitSet::operator |= (const BitSet& y) +{ + or(*this, y, *this); + return *this; +} + +inline BitSet& BitSet::operator ^= (const BitSet& y) +{ + xor(*this, y, *this); + return *this; +} + +inline BitSet& BitSet::operator -= (const BitSet& y) +{ + diff(*this, y, *this); + return *this; +} + + +inline void BitSet::complement() +{ + ::complement(*this, *this); +} + +inline int BitSet::virtual_bit() const +{ + return rep->virt; +} + +inline int BitSet::first(int b) const +{ + return next(-1, b); +} + +inline int BitSet::test(int p) const +{ + if (p < 0) error("Illegal bit index"); + int index = BitSet_index(p); + return (index >= rep->len)? rep->virt : + ((rep->s[index] & (1 << BitSet_pos(p))) != 0); +} + + +inline void BitSet::set() +{ + rep = BitSetalloc(rep, 0, 0, 1, 0); +} + +inline BitSetBit::BitSetBit(const BitSetBit& b) :src(b.src), pos(b.pos) {} + +inline BitSetBit::BitSetBit(BitSet* v, int p) +{ + src = v; pos = p; +} + +inline BitSetBit::~BitSetBit() {} + +inline BitSetBit::operator int() const +{ + return src->test(pos); +} + +inline int BitSetBit::operator = (int b) +{ + if (b) src->set(pos); else src->clear(pos); return b; +} + +inline int BitSetBit::operator = (const BitSetBit& b) +{ + int i = (int)b; + *this = i; + return i; +} + +inline BitSetBit BitSet::operator [] (int i) +{ + if (i < 0) error("illegal bit index"); + return BitSetBit(this, i); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/BitString.cc b/gnu/lib/libg++/libg++/src/BitString.cc new file mode 100644 index 00000000000..32568fa7ef2 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/BitString.cc @@ -0,0 +1,1608 @@ +/* +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. +*/ + +/* + BitString class implementation + */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#undef OK + +void BitString::error(const char* msg) const +{ + (*lib_error_handler)("BitString", msg); +} + +// globals + +BitStrRep _nilBitStrRep = { 0, 1, {0} }; + +BitString _nil_BitString; + +#define MINBitStrRep_SIZE 8 +#define MAXBitStrRep_SIZE ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1) + +#ifndef MALLOC_MIN_OVERHEAD +#define MALLOC_MIN_OVERHEAD 4 +#endif + +#define ONES ((_BS_word)(~0L)) +#define MAXBIT (((_BS_word)1) << (BITSTRBITS - 1)) + +/* + * bit manipulation utilities +*/ + +// break things up into .s indices and positions + +inline static int BitStr_len(int l) +{ + return (unsigned)(l) / BITSTRBITS + 1; +} + + +// mask out low bits + +static inline _BS_word lmask(int p) +{ + return ONES _BS_RIGHT p; +} + +// mask out high bits + +static inline _BS_word rmask(int p) +{ + int s = BITSTRBITS - 1 - p; + if (s <= 0) + return ONES; + else + return ONES _BS_LEFT s; +} + + +// mask out unused bits in last word of rep + +inline static void check_last(BitStrRep* r) +{ + int bit_len_mod = r->len & (BITSTRBITS - 1); + if (bit_len_mod) + r->s[r->len / BITSTRBITS] &= ONES _BS_LEFT (BITSTRBITS - bit_len_mod); +} + +// merge bits from next word + +static inline _BS_word borrow_hi(const _BS_word a[], int ind, + int maxind, int p) +{ + if (p == 0) + return a[ind]; + else if (ind < maxind) + return (a[ind] _BS_LEFT p) | (a[ind+1] _BS_RIGHT (BITSTRBITS - p)); + else + return (a[ind] _BS_LEFT p); +} + +// merge bits from prev word + +static inline _BS_word borrow_lo(const _BS_word a[], int ind, + int minind, int p) +{ + _BS_word word = a[ind] _BS_RIGHT (BITSTRBITS - 1 - p); + if (ind > minind) + word |= (a[ind-1] _BS_LEFT (p + 1)); + return word; +} + +// same with bounds check (for masks shorter than patterns) + +static inline _BS_word safe_borrow_hi(const _BS_word a[], int ind, + int maxind, int p) +{ + if (ind > maxind) + return 0; + else if (p == 0) + return a[ind]; + else if (ind == maxind) + return a[ind] _BS_LEFT p; + else + return (a[ind] _BS_LEFT p) | (a[ind+1] _BS_RIGHT (BITSTRBITS - p)); +} + + +// allocate a new rep; pad to near a power of two + +inline static BitStrRep* BSnew(int newlen) +{ + unsigned int siz = sizeof(BitStrRep) + BitStr_len(newlen) * sizeof(_BS_word) + + MALLOC_MIN_OVERHEAD; + unsigned int allocsiz = MINBitStrRep_SIZE;; + while (allocsiz < siz) allocsiz <<= 1; + allocsiz -= MALLOC_MIN_OVERHEAD; + if (allocsiz >= MAXBitStrRep_SIZE * sizeof(_BS_word)) + (*lib_error_handler)("BitString", "Requested length out of range"); + + BitStrRep* rep = new (operator new (allocsiz)) BitStrRep; + memset(rep, 0, allocsiz); + rep->sz = + (allocsiz - sizeof(BitStrRep) + sizeof(_BS_word)) / sizeof(_BS_word); + return rep; +} + +inline void +copy_bits (_BS_word* pdst, _BS_size_t dstbit, + const _BS_word* psrc, _BS_size_t srcbit, + _BS_size_t length) +{ + _BS_NORMALIZE (pdst, dstbit); + _BS_NORMALIZE (psrc, srcbit); + _BS_copy (pdst, dstbit, psrc, srcbit, length); +} + +BitStrRep* BStr_alloc(BitStrRep* old, const _BS_word* src, + int startpos, int endp, int newlen) +{ + if (old == &_nilBitStrRep) old = 0; + if (newlen < 0) newlen = 0; + int news = BitStr_len(newlen); + BitStrRep* rep; + if (old == 0 || news > old->sz) + rep = BSnew(newlen); + else + rep = old; + rep->len = newlen; + + if (src != 0 && endp > 0 && (src != rep->s || startpos > 0)) + copy_bits (rep->s, 0, src, startpos, endp - startpos); + + check_last(rep); + + if (old != rep && old != 0) delete old; + + return rep; +} + +BitStrRep* BStr_resize(BitStrRep* old, int newlen) +{ + BitStrRep* rep; + if (newlen < 0) newlen = 0; + int news = BitStr_len(newlen); + if (old == 0 || old == &_nilBitStrRep) + { + rep = BSnew(newlen); + } + else if (news > old->sz) + { + rep = BSnew(newlen); + memcpy(rep->s, old->s, BitStr_len(old->len) * sizeof(_BS_word)); + delete old; + } + else + rep = old; + + rep->len = newlen; + check_last(rep); + return rep; +} + +BitStrRep* BStr_copy(BitStrRep* old, const BitStrRep* src) +{ + BitStrRep* rep; + if (old == src && old != &_nilBitStrRep) return old; + if (old == &_nilBitStrRep) old = 0; + if (src == &_nilBitStrRep) src = 0; + if (src == 0) + { + if (old == 0) + rep = BSnew(0); + else + rep = old; + rep->len = 0; + } + else + { + int newlen = src->len; + int news = BitStr_len(newlen); + if (old == 0 || news > old->sz) + { + rep = BSnew(newlen); + if (old != 0) delete old; + } + else + rep = old; + + memcpy(rep->s, src->s, news * sizeof(_BS_word)); + rep->len = newlen; + } + check_last(rep); + return rep; +} + + +int operator == (const BitString& x, const BitString& y) +{ + return x.rep->len == y.rep->len && + memcmp((void*)x.rep->s, (void*)y.rep->s, + BitStr_len(x.rep->len) * sizeof(_BS_word)) == 0; +} + +int operator <= (const BitString& x, const BitString& y) +{ + unsigned int xl = x.rep->len; + unsigned int yl = y.rep->len; + if (xl > yl) + return 0; + + const _BS_word* xs = x.rep->s; + const _BS_word* topx = &(xs[BitStr_len(xl)]); + const _BS_word* ys = y.rep->s; + + while (xs < topx) + { + _BS_word a = *xs++; + _BS_word b = *ys++; + if ((a | b) != b) + return 0; + } + return 1; +} + +int operator < (const BitString& x, const BitString& y) +{ + unsigned short xl = x.rep->len; + unsigned short yl = y.rep->len; + if (xl > yl) + return 0; + + const _BS_word* xs = x.rep->s; + const _BS_word* ys = y.rep->s; + const _BS_word* topx = &(xs[BitStr_len(xl)]); + const _BS_word* topy = &(ys[BitStr_len(yl)]); + int one_diff = 0; + while (xs < topx) + { + _BS_word a = *xs++; + _BS_word b = *ys++; + _BS_word c = a | b; + if (c != b) + return 0; + else if (c != a) + one_diff = 1; + } + if (one_diff) + return 1; + else + { + while (ys < topy) + if (*ys++ != 0) + return 1; + return 0; + } +} + +int lcompare(const BitString& x, const BitString& y) +{ + return _BS_lcompare_0 (x.rep->s, x.rep->len, y.rep->s, y.rep->len); +} + +int BitString::count(unsigned int b) const +{ + int count = _BS_count (rep->s, 0, rep->len); + if (!b) + count = rep->len - count; + return count; +} + + +BitStrRep* cmpl(const BitStrRep* src, BitStrRep* r) +{ + r = BStr_copy(r, src); + _BS_word* rs = r->s; + _BS_word* topr = &(rs[BitStr_len(r->len)]); + while (rs < topr) + { + _BS_word cmp = ~(*rs); + *rs++ = cmp; + } + check_last(r); + return r; +} + + +BitStrRep* and(const BitStrRep* x, const BitStrRep* y, BitStrRep* r) +{ + int xrsame = x == r; + int yrsame = y == r; + + unsigned int xl = x->len; + unsigned int yl = y->len; + unsigned int rl = (xl <= yl)? xl : yl; + + r = BStr_resize(r, rl); + + _BS_word* rs = r->s; + _BS_word* topr = &(rs[BitStr_len(rl)]); + const _BS_word* xs = (xrsame)? rs : x->s; + const _BS_word* ys = (yrsame)? rs : y->s; + + while (rs < topr) *rs++ = *xs++ & *ys++; + check_last(r); + return r; +} + +BitStrRep* or(const BitStrRep* x, const BitStrRep* y, BitStrRep* r) +{ + unsigned int xl = x->len; + unsigned int yl = y->len; + unsigned int rl = (xl >= yl)? xl : yl; + int xrsame = x == r; + int yrsame = y == r; + + r = BStr_resize(r, rl); + + _BS_word* rs = r->s; + const _BS_word* xs = (xrsame)? rs : x->s; + const _BS_word* topx = &(xs[BitStr_len(xl)]); + const _BS_word* ys = (yrsame)? rs : y->s; + const _BS_word* topy = &(ys[BitStr_len(yl)]); + + if (xl <= yl) + { + while (xs < topx) *rs++ = *xs++ | *ys++; + if (rs != ys) while (ys < topy) *rs++ = *ys++; + } + else + { + while (ys < topy) *rs++ = *xs++ | *ys++; + if (rs != xs) while (xs < topx) *rs++ = *xs++; + } + check_last(r); + return r; +} + + +BitStrRep* xor(const BitStrRep* x, const BitStrRep* y, BitStrRep* r) +{ + unsigned int xl = x->len; + unsigned int yl = y->len; + unsigned int rl = (xl >= yl)? xl : yl; + int xrsame = x == r; + int yrsame = y == r; + + r = BStr_resize(r, rl); + + _BS_word* rs = r->s; + const _BS_word* xs = (xrsame)? rs : x->s; + const _BS_word* topx = &(xs[BitStr_len(xl)]); + const _BS_word* ys = (yrsame)? rs : y->s; + const _BS_word* topy = &(ys[BitStr_len(yl)]); + + if (xl <= yl) + { + while (xs < topx) *rs++ = *xs++ ^ *ys++; + if (rs != ys) while (ys < topy) *rs++ = *ys++; + } + else + { + while (ys < topy) *rs++ = *xs++ ^ *ys++; + if (rs != xs) while (xs < topx) *rs++ = *xs++; + } + check_last(r); + return r; +} + + +BitStrRep* diff(const BitStrRep* x, const BitStrRep* y, BitStrRep* r) +{ + unsigned int xl = x->len; + unsigned int yl = y->len; + int xrsame = x == y; + int yrsame = y == r; + + r = BStr_resize(r, xl); + + _BS_word* rs = r->s; + const _BS_word* xs = (xrsame)? rs : x->s; + const _BS_word* topx = &(xs[BitStr_len(xl)]); + const _BS_word* ys = (yrsame)? rs : y->s; + const _BS_word* topy = &(ys[BitStr_len(yl)]); + + if (xl <= yl) + { + while (xs < topx) *rs++ = *xs++ & ~(*ys++); + } + else + { + while (ys < topy) *rs++ = *xs++ & ~(*ys++); + if (rs != xs) while (xs < topx) *rs++ = *xs++; + } + check_last(r); + return r; +} + + +BitStrRep* cat(const BitStrRep* x, const BitStrRep* y, BitStrRep* r) +{ + unsigned int xl = x->len; + unsigned int yl = y->len; + unsigned int rl = xl + yl; + int xrsame = x == r; + int yrsame = y == r; + + if (yrsame) + { + if (xrsame) + { + r = BStr_resize(r, rl); + copy_bits (r->s, xl, r->s, 0, yl); + } + else + { + BitStrRep* tmp = BStr_copy(0, y); + r = BStr_resize(r, rl); + _BS_copy_0(r->s, x->s, xl); + copy_bits (r->s, xl, tmp->s, 0, yl); + delete tmp; + } + } + else + { + r = BStr_resize(r, rl); + if (!xrsame) _BS_copy_0(r->s, x->s, xl); + copy_bits (r->s, xl, y->s, 0, yl); + } + check_last(r); + return r; +} + +BitStrRep* cat(const BitStrRep* x, unsigned int bit, BitStrRep* r) +{ + unsigned int xl = x->len; + int xrsame = x == r; + r = BStr_resize(r, xl+1); + if (!xrsame) + _BS_copy_0(r->s, x->s, xl); + if (bit) + r->s[BitStr_index(xl)] |= _BS_BITMASK(BitStr_pos(xl)); + else + r->s[BitStr_index(xl)] &= ~(_BS_BITMASK(BitStr_pos(xl))); + check_last(r); + return r; +} + +BitStrRep* lshift(const BitStrRep* x, int s, BitStrRep* r) +{ + int xrsame = x == r; + int xl = x->len; + int rl = xl + s; + if (s == 0) + r = BStr_copy(r, x); + else if (rl <= 0) + { + r = BStr_resize(r, 0); + r->len = 0; + r->s[0] = 0; + } + else if (s > 0) + { + r = BStr_resize(r, rl); + const _BS_word* xs = (xrsame)? r->s : x->s; + copy_bits (r->s, s, xs, 0, xl); + _BS_clear (r->s, 0, s); + } + else if (xrsame) + { + r = BStr_resize(r, xl); + r->len = rl; + copy_bits (r->s, 0, r->s, -s, xl + s); + } + else + { + r = BStr_resize(r, rl); + copy_bits (r->s, 0, x->s, -s, xl + s); + } + check_last(r); + return r; +} + + +void BitString::set(int p) +{ + if (p < 0) error("Illegal bit index"); + if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1); + rep->s[BitStr_index(p)] |= _BS_BITMASK(BitStr_pos(p)); +} + +void BitString::assign(int p, unsigned int bit) +{ + if (p < 0) error("Illegal bit index"); + if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1); + if (bit) + rep->s[BitStr_index(p)] |= _BS_BITMASK(BitStr_pos(p)); + else + rep->s[BitStr_index(p)] &= ~(_BS_BITMASK(BitStr_pos(p))); +} + +void BitString::clear(int p) +{ + if (p < 0) error("Illegal bit index"); + if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1); + rep->s[BitStr_index(p)] &= ~(_BS_BITMASK(BitStr_pos(p))); +} + +void BitString::clear() +{ + if (rep == &_nilBitStrRep) return; + _BS_clear (rep->s, 0, rep->len); +} + +void BitString::set() +{ + if (rep == &_nilBitStrRep) return; + _BS_word* s = rep->s; + _BS_word* tops = &(s[BitStr_len(rep->len)]); + while (s < tops) *s++ = ONES; + check_last(rep); +} + +void BitString::invert(int p) +{ + if (p < 0) error("Illegal bit index"); + if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1); + rep->s[BitStr_index(p)] ^= _BS_BITMASK(BitStr_pos(p)); +} + +void BitString::set(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1); + + _BS_size_t len = to - from + 1; + _BS_word* xs = rep->s; + _BS_NORMALIZE (xs, from); + _BS_invert (xs, from, len); +} + +void BitString::clear(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1); + + _BS_size_t len = to - from + 1; + _BS_word* xs = rep->s; + _BS_NORMALIZE (xs, from); + _BS_clear (xs, from, len); +} + +void BitString::invert(int from, int to) +{ + if (from < 0 || from > to) error("Illegal bit index"); + if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1); + _BS_size_t len = to - from + 1; + _BS_word* xs = rep->s; + _BS_NORMALIZE (xs, from); + _BS_invert (xs, from, len); +} + + +int BitString::test(int from, int to) const +{ + if (from < 0 || from > to || (unsigned)(from) >= rep->len) return 0; + + _BS_size_t len = to - from + 1; + _BS_word* xs = rep->s; + _BS_NORMALIZE (xs, from); + return _BS_any (xs, from, len); +} + +int BitString::next(int p, unsigned int b) const +{ + if ((unsigned)(++p) >= rep->len) + return -1; + + int ind = BitStr_index(p); + int pos = BitStr_pos(p); + int l = BitStr_len(rep->len); + + int j = ind; + const _BS_word* s = rep->s; + _BS_word a = s[j] >> pos; + int i = pos; + + if (b != 0) + { + for (; i < BITSTRBITS && a != 0; ++i) + { + if (a & 1) + return j * BITSTRBITS + i; + a >>= 1; + } + for (++j; j < l; ++j) + { + a = s[j]; + for (i = 0; i < BITSTRBITS && a != 0; ++i) + { + if (a & 1) + return j * BITSTRBITS + i; + a >>= 1; + } + } + return -1; + } + else + { + int last = BitStr_pos(rep->len); + if (j == l - 1) + { + for (; i < last; ++i) + { + if ((a & 1) == 0) + return j * BITSTRBITS + i; + a >>= 1; + } + return -1; + } + + for (; i < BITSTRBITS; ++i) + { + if ((a & 1) == 0) + return j * BITSTRBITS + i; + a >>= 1; + } + for (++j; j < l - 1; ++j) + { + a = s[j]; + if (a != ONES) + { + for (i = 0; i < BITSTRBITS; ++i) + { + if ((a & 1) == 0) + return j * BITSTRBITS + i; + a >>= 1; + } + } + } + a = s[j]; + for (i = 0; i < last; ++i) + { + if ((a & 1) == 0) + return j * BITSTRBITS + i; + a >>= 1; + } + return -1; + } +} + +int BitString::prev(int p, unsigned int b) const +{ + if (--p < 0) + return -1; + + int ind = BitStr_index(p); + int pos = BitStr_pos(p); + + const _BS_word* s = rep->s; + + if ((unsigned)(p) >= rep->len) + { + ind = BitStr_index(rep->len - 1); + pos = BitStr_pos(rep->len - 1); + } + + int j = ind; + _BS_word a = s[j]; + + int i = pos; + _BS_word maxbit = ((_BS_word)1) << pos; + + if (b != 0) + { + for (; i >= 0 && a != 0; --i) + { + if (a & maxbit) + return j * BITSTRBITS + i; + a <<= 1; + } + maxbit = ((_BS_word)1) << (BITSTRBITS - 1); + for (--j; j >= 0; --j) + { + a = s[j]; + for (i = BITSTRBITS - 1; i >= 0 && a != 0; --i) + { + if (a & maxbit) + return j * BITSTRBITS + i; + a <<= 1; + } + } + return -1; + } + else + { + if (a != ONES) + { + for (; i >= 0; --i) + { + if ((a & maxbit) == 0) + return j * BITSTRBITS + i; + a <<= 1; + } + } + maxbit = ((_BS_word)1) << (BITSTRBITS - 1); + for (--j; j >= 0; --j) + { + a = s[j]; + if (a != ONES) + { + for (i = BITSTRBITS - 1; i >= 0; --i) + { + if ((a & maxbit) == 0) + return j * BITSTRBITS + i; + a <<= 1; + } + } + } + return -1; + } +} + + +int BitString::search(int startx, int lengthx, + const _BS_word* ys, int starty, int lengthy) const +{ + const _BS_word* xs = rep->s; + int ylen = lengthy - starty; + int righty = lengthy - 1; + int rev = startx < 0; + if (rev) + { + int leftx = 0; + int rightx = lengthx + startx; + startx = rightx - ylen + 1; + if (ylen == 0) return startx; + if (starty < 0 || righty < 0 || startx < 0 || startx >= lengthx) return -1; + + int xind = BitStr_index(startx); + int xpos = BitStr_pos(startx); + int yind = BitStr_index(starty); + int ypos = BitStr_pos(starty); + + int rightxind = BitStr_index(rightx); + + _BS_word x = borrow_hi(xs, xind, rightxind, xpos); + + int rightyind = BitStr_index(righty); + int rightypos = BitStr_pos(righty); + _BS_word y = borrow_hi(ys, yind, rightyind, ypos); + _BS_word ymask; + if (yind == rightyind) + ymask = rmask(rightypos); + else if (yind+1 == rightyind) + ymask = rmask(BITSTRBITS - ypos + rightypos + 1); + else + ymask = ONES; + + int p = startx; + for (;;) + { + if ((x & ymask) == y) + { + int xi = xind; + int yi = yind; + for (;;) + { + if (++yi > rightyind || ++xi > rightxind) + return p; + _BS_word tx = borrow_hi(xs, xi, rightxind, xpos); + _BS_word ty = borrow_hi(ys, yi, rightyind, ypos); + if (yi == rightyind) + tx &= rmask(rightypos); + else if (yi+1 == rightyind) + tx &= rmask(BITSTRBITS - ypos + rightypos + 1); + if (tx != ty) + break; + } + } + if (--p < leftx) + return -1; + if (--xpos < 0) + { + xpos = BITSTRBITS - 1; + --xind; + } + x = borrow_hi(xs, xind, rightxind, xpos); + } + } + else + { + + int rightx = lengthx - 1; + if (ylen == 0) return startx; + if (starty < 0 || righty < 0 || startx < 0 || startx >= lengthx) return -1; + + int xind = BitStr_index(startx); + int xpos = BitStr_pos(startx); + int yind = BitStr_index(starty); + int ypos = BitStr_pos(starty); + + int rightxind = BitStr_index(rightx); + + _BS_word x = borrow_hi(xs, xind, rightxind, xpos); + _BS_word nextx = (xind >= rightxind) ? 0 : (xs[xind+1] >> xpos); + + int rightyind = BitStr_index(righty); + int rightypos = BitStr_pos(righty); + _BS_word y = borrow_hi(ys, yind, rightyind, ypos); + _BS_word ymask; + if (yind == rightyind) + ymask = rmask(rightypos); + else if (yind+1 == rightyind) + ymask = rmask(BITSTRBITS - ypos + rightypos + 1); + else + ymask = ONES; + + int p = startx; + for (;;) + { + if ((x & ymask) == y) + { + int xi = xind; + int yi = yind; + for (;;) + { + if (++yi > rightyind || ++xi > rightxind) + return p; + _BS_word tx = borrow_hi(xs, xi, rightxind, xpos); + _BS_word ty = borrow_hi(ys, yi, rightyind, ypos); + if (yi == rightyind) + tx &= rmask(rightypos); + else if (yi+1 == rightyind) + tx &= rmask(BITSTRBITS - ypos + rightypos + 1); + if (tx != ty) + break; + } + } + if (++p > rightx) + return -1; + if (++xpos == BITSTRBITS) + { + xpos = 0; + x = xs[++xind]; + nextx = (xind >= rightxind) ? 0 : xs[xind+1]; + } + else + { + x >>= 1; + if (nextx & 1) + x |= MAXBIT; + nextx >>= 1; + } + } + } +} + + +int BitPattern::search(const _BS_word* xs, int startx, int lengthx) const +{ + const _BS_word* ys = pattern.rep->s; + const _BS_word* ms = mask.rep->s; + int righty = pattern.rep->len - 1; + int rightm = mask.rep->len - 1; + + int rev = startx < 0; + if (rev) + { + int leftx = 0; + int rightx = lengthx + startx; + startx = rightx - righty; + + if (righty < 0) return startx; + if (startx < 0 || startx >= lengthx) return -1; + + int xind = BitStr_index(startx); + int xpos = BitStr_pos(startx); + + int rightxind = BitStr_index(rightx); + + int rightmind = BitStr_index(rightm); + int rightyind = BitStr_index(righty); + + _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos); + _BS_word m = safe_borrow_hi(ms, 0, rightmind, 0); + _BS_word y = safe_borrow_hi(ys, 0, rightyind, 0) & m; + + int p = startx; + for (;;) + { + if ((x & m) == y) + { + int xi = xind; + int yi = 0; + for (;;) + { + if (++yi > rightyind || ++xi > rightxind) + return p; + _BS_word tm = safe_borrow_hi(ms, yi, rightmind, 0); + _BS_word ty = safe_borrow_hi(ys, yi, rightyind, 0); + _BS_word tx = safe_borrow_hi(xs, xi, rightxind, xpos); + if ((tx & tm) != (ty & tm)) + break; + } + } + if (--p < leftx) + return -1; + if (--xpos < 0) + { + xpos = BITSTRBITS - 1; + --xind; + } + x = safe_borrow_hi(xs, xind, rightxind, xpos); + } + } + else + { + + int rightx = lengthx - 1; + + if (righty < 0) return startx; + if (startx < 0 || startx >= lengthx) return -1; + + int xind = BitStr_index(startx); + int xpos = BitStr_pos(startx); + + int rightxind = BitStr_index(rightx); + + int rightmind = BitStr_index(rightm); + int rightyind = BitStr_index(righty); + + _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos); + _BS_word m = safe_borrow_hi(ms, 0, rightmind, 0); + _BS_word y = safe_borrow_hi(ys, 0, rightyind, 0) & m; + + _BS_word nextx = (xind >= rightxind) ? 0 : (xs[xind+1] >> xpos); + + int p = startx; + for (;;) + { + if ((x & m) == y) + { + int xi = xind; + int yi = 0; + for (;;) + { + if (++yi > rightyind || ++xi > rightxind) + return p; + _BS_word tm = safe_borrow_hi(ms, yi, rightmind, 0); + _BS_word ty = safe_borrow_hi(ys, yi, rightyind, 0); + _BS_word tx = safe_borrow_hi(xs, xi, rightxind, xpos); + if ((tx & tm) != (ty & tm)) + break; + } + } + if (++p > rightx) + return -1; + if (++xpos == BITSTRBITS) + { + xpos = 0; + x = xs[++xind]; + nextx = (xind >= rightxind) ? 0 : xs[xind+1]; + } + else + { + x >>= 1; + if (nextx & 1) + x |= MAXBIT; + nextx >>= 1; + } + } + } +} + +int BitString::match(int startx, int lengthx, int exact, + const _BS_word* ys, int starty, int yl) const +{ + const _BS_word* xs = rep->s; + int ylen = yl - starty; + int righty = yl - 1; + + int rightx; + int rev = startx < 0; + if (rev) + { + rightx = lengthx + startx; + startx = rightx - ylen + 1; + if (exact && startx != 0) + return 0; + } + else + { + rightx = lengthx - 1; + if (exact && rightx - startx != righty) + return 0; + } + + if (ylen == 0) return 1; + if (righty < 0 || startx < 0 || startx >= lengthx) return 0; + + int xi = BitStr_index(startx); + int xpos = BitStr_pos(startx); + int yi = BitStr_index(starty); + int ypos = BitStr_pos(starty); + + int rightxind = BitStr_index(rightx); + int rightyind = BitStr_index(righty); + int rightypos = BitStr_pos(righty); + + for (;;) + { + _BS_word x = borrow_hi(xs, xi, rightxind, xpos); + _BS_word y = borrow_hi(ys, yi, rightyind, ypos); + if (yi == rightyind) + x &= rmask(rightypos); + else if (yi+1 == rightyind) + x &= rmask(BITSTRBITS - ypos + rightypos + 1); + if (x != y) + return 0; + else if (++yi > rightyind || ++xi > rightxind) + return 1; + } +} + +int BitPattern::match(const _BS_word* xs, int startx, + int lengthx, int exact) const +{ + const _BS_word* ys = pattern.rep->s; + int righty = pattern.rep->len - 1; + _BS_word* ms = mask.rep->s; + int rightm = mask.rep->len - 1; + + int rightx; + int rev = startx < 0; + if (rev) + { + rightx = lengthx + startx; + startx = rightx - righty; + if (exact && startx != 0) + return 0; + } + else + { + rightx = lengthx - 1; + if (exact && rightx - startx != righty) + return 0; + } + + if (righty < 0) return 1; + if (startx < 0 || startx >= lengthx) return 0; + + int xind = BitStr_index(startx); + int xpos = BitStr_pos(startx); + int yind = 0; + + int rightxind = BitStr_index(rightx); + int rightyind = BitStr_index(righty); + int rightmind = BitStr_index(rightm); + + for(;;) + { + _BS_word m = safe_borrow_hi(ms, yind, rightmind, 0); + _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos) & m; + _BS_word y = safe_borrow_hi(ys, yind, rightyind, 0) & m; + if (x != y) + return 0; + else if (++yind > rightyind || ++xind > rightxind) + return 1; + } +} + +BitSubString& BitSubString::operator = (const BitString& y) +{ + if (&S == &_nil_BitString) + return *this; + BitStrRep* targ = S.rep; + + unsigned int ylen = y.rep->len; + int sl = targ->len - len + ylen; + + if (y.rep == targ || ylen > len) + { + BitStrRep* oldtarg = targ; + targ = BStr_alloc(0, 0, 0, 0, sl); + _BS_copy (targ->s, 0, oldtarg->s, 0, pos); + copy_bits (targ->s, pos, y.rep->s, 0, ylen); + copy_bits (targ->s, pos + ylen, oldtarg->s, pos+len, oldtarg->len-pos-len); + delete oldtarg; + } + else if (len == ylen) + copy_bits (targ->s, pos, y.rep->s, 0, len); + else if (ylen < len) + { + copy_bits (targ->s, pos, y.rep->s, 0, ylen); + copy_bits (targ->s, pos + ylen, targ->s, pos + len, targ->len - pos - len); + targ->len = sl; + } + check_last(targ); + S.rep = targ; + return *this; +} + +BitSubString& BitSubString::operator = (const BitSubString& y) +{ + if (&S == &_nil_BitString) + return *this; + BitStrRep* targ = S.rep; + + if (len == 0 || pos >= targ->len) + return *this; + + int sl = targ->len - len + y.len; + + if (y.S.rep == targ || y.len > len) + { + BitStrRep* oldtarg = targ; + targ = BStr_alloc(0, 0, 0, 0, sl); + _BS_copy_0(targ->s, oldtarg->s, pos); + copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len); + copy_bits (targ->s, pos + y.len, oldtarg->s, pos+len, + oldtarg->len-pos-len); + delete oldtarg; + } + else if (len == y.len) + copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len); + else if (y.len < len) + { + copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len); + copy_bits (targ->s, pos + y.len, targ->s, pos + len, + targ->len - pos - len); + targ->len = sl; + } + check_last(targ); + S.rep = targ; + return *this; +} + +BitSubString BitString::at(int first, int len) +{ + return _substr(first, len); +} + +BitSubString BitString::before(int pos) +{ + return _substr(0, pos); +} + +BitSubString BitString::after(int pos) +{ + return _substr(pos + 1, rep->len - (pos + 1)); +} + +BitSubString BitString::at(const BitString& y, int startpos) +{ + int first = search(startpos, rep->len, y.rep->s, 0, y.rep->len); + return _substr(first, y.rep->len); +} + +BitSubString BitString::before(const BitString& y, int startpos) +{ + int last = search(startpos, rep->len, y.rep->s, 0, y.rep->len); + return _substr(0, last); +} + +BitSubString BitString::after(const BitString& y, int startpos) +{ + int first = search(startpos, rep->len, y.rep->s, 0, y.rep->len); + if (first >= 0) first += y.rep->len; + return _substr(first, rep->len - first); +} + + +BitSubString BitString::at(const BitSubString& y, int startpos) +{ + int first = search(startpos, rep->len, y.S.rep->s, y.pos, y.len); + return _substr(first, y.len); +} + +BitSubString BitString::before(const BitSubString& y, int startpos) +{ + int last = search(startpos, rep->len, y.S.rep->s, y.pos, y.len); + return _substr(0, last); +} + +BitSubString BitString::after(const BitSubString& y, int startpos) +{ + int first = search(startpos, rep->len, y.S.rep->s, y.pos, y.len); + if (first >= 0) first += y.len; + return _substr(first, rep->len - first); +} + +BitSubString BitString::at(const BitPattern& r, int startpos) +{ + int first = r.search(rep->s, startpos, rep->len); + return _substr(first, r.pattern.rep->len); +} + + +BitSubString BitString::before(const BitPattern& r, int startpos) +{ + int first = r.search(rep->s, startpos, rep->len); + return _substr(0, first); +} + +BitSubString BitString::after(const BitPattern& r, int startpos) +{ + int first = r.search(rep->s, startpos, rep->len); + if (first >= 0) first += r.pattern.rep->len; + return _substr(first, rep->len - first); +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) +#define RETURN(r) return +#define RETURNS(r) return r; +#define RETURN_OBJECT(TYPE, NAME) /* nothing */ +#define USE_UNSIGNED 1 /* probably correct */ +#else /* _G_NO_NRV */ +#define RETURN(r) return r +#define RETURNS(r) /* nothing */ +#define RETURN_OBJECT(TYPE, NAME) TYPE NAME; +#define USE_UNSIGNED 0 /* probably old bug */ +#endif + +BitString +common_prefix (const BitString& x, const BitString& y, int startpos) + RETURNS(r) +{ + RETURN_OBJECT(BitString, r); + unsigned int xl = x.rep->len; + unsigned int yl = y.rep->len; + + unsigned int startx, starty; + if (startpos < 0) + { + startx = xl + startpos; + starty = yl + startpos; + } + else + startx = starty = startpos; + + if (startx >= xl || starty >= yl) + RETURN(r); + + const _BS_word* xs = &(x.rep->s[BitStr_index(startx)]); + _BS_word a = *xs++; + unsigned int xp = startx; + + const _BS_word* ys = &(y.rep->s[BitStr_index(starty)]); + _BS_word b = *ys++; + unsigned int yp = starty; + + for(; xp < xl && yp < yl; ++xp, ++yp) + { + _BS_word xbit = ((_BS_word)1) << (BitStr_pos(xp)); + _BS_word ybit = ((_BS_word)1) << (BitStr_pos(yp)); + if (((a & xbit) == 0) != ((b & ybit) == 0)) + break; + if (xbit == MAXBIT) + a = *xs++; + if (ybit == MAXBIT) + b = *ys++; + } + r.rep = BStr_alloc(0, x.rep->s, startx, xp, xp - startx); + RETURN(r); +} + + +BitString +common_suffix (const BitString& x, const BitString& y, int startpos) + RETURNS(r) +{ + RETURN_OBJECT(BitString, r); + unsigned int xl = x.rep->len; + unsigned int yl = y.rep->len; + + unsigned int startx, starty; + if (startpos < 0) + { + startx = xl + startpos; + starty = yl + startpos; + } + else + startx = starty = startpos; + + if (startx >= xl || starty >= yl) + RETURN(r); + + const _BS_word* xs = &(x.rep->s[BitStr_index(startx)]); + _BS_word a = *xs--; + int xp = startx; + + const _BS_word* ys = &(y.rep->s[BitStr_index(starty)]); + _BS_word b = *ys--; + int yp = starty; + + for(; xp >= 0 && yp >= 0; --xp, --yp) + { + _BS_word xbit = ((_BS_word)1) << (BitStr_pos(xp)); + _BS_word ybit = ((_BS_word)1) << (BitStr_pos(yp)); + if (((a & xbit) == 0) != ((b & ybit) == 0)) + break; + if (xbit == 1) + a = *xs--; + if (ybit == 1) + b = *ys--; + } + r.rep = BStr_alloc(0, x.rep->s, xp+1, startx+1, startx - xp); + RETURN(r); +} + +BitString reverse (const BitString& x) + RETURNS(r) +{ + RETURN_OBJECT(BitString, r); + unsigned int yl = x.rep->len; + BitStrRep* y = BStr_resize(0, yl); + if (yl > 0) + { + const _BS_word* ls = x.rep->s; + _BS_word lm = 1; + _BS_word* rs = &(y->s[BitStr_index(yl - 1)]); + _BS_word rm = ((_BS_word)1) << (BitStr_pos(yl - 1)); + for (unsigned int l = 0; l < yl; ++l) + { + if (*ls & lm) + *rs |= rm; + if (lm == MAXBIT) + { + ++ls; + lm = 1; + } + else + lm <<= 1; + if (rm == 1) + { + --rs; + rm = MAXBIT; + } + else + rm >>= 1; + } + } + r.rep = y; + RETURN(r); +} + +BitString +atoBitString (const char* s, char f, char t) + RETURNS(res) +{ + RETURN_OBJECT(BitString, res); + int sl = strlen(s); + BitStrRep* r = BStr_resize(0, sl); + if (sl != 0) + { + unsigned int rl = 0; + _BS_word* rs = r->s; + _BS_word a = 0; + _BS_word m = 1; + unsigned int i = 0; + for(;;) + { + char ch = s[i]; + if (ch != t && ch != f) + { + *rs = a; + break; + } + ++rl; + if (ch == t) + a |= m; + if (++i == sl) + { + *rs = a; + break; + } + else if (i % BITSTRBITS == 0) + { + *rs++ = a; + a = 0; + m = 1; + } + else + m <<= 1; + } + r = BStr_resize(r, rl); + } + res.rep = r; + RETURN(res); +} + +BitPattern +atoBitPattern (const char* s, char f,char t,char x) + RETURNS(r) +{ + RETURN_OBJECT(BitPattern, r); + int sl = strlen(s); + if (sl != 0) + { + unsigned int rl = 0; + r.pattern.rep = BStr_resize(r.pattern.rep, sl); + r.mask.rep = BStr_resize(r.mask.rep, sl); + _BS_word* rs = r.pattern.rep->s; + _BS_word* ms = r.mask.rep->s; + _BS_word a = 0; + _BS_word b = 0; + _BS_word m = 1; + unsigned int i = 0; + for(;;) + { + char ch = s[i]; + if (ch != t && ch != f && ch != x) + { + *rs = a; + *ms = b; + break; + } + ++rl; + if (ch == t) + { + a |= m; + b |= m; + } + else if (ch == f) + { + b |= m; + } + if (++i == sl) + { + *rs = a; + *ms = b; + break; + } + else if (i % BITSTRBITS == 0) + { + *rs++ = a; + *ms++ = b; + a = 0; + b = 0; + m = 1; + } + else + m <<= 1; + } + r.pattern.rep = BStr_resize(r.pattern.rep, rl); + r.mask.rep = BStr_resize(r.mask.rep, rl); + } + RETURN(r); +} + +extern AllocRing _libgxx_fmtq; + +void BitString::printon (ostream& os, char f, char t) const +{ + unsigned int xl = rep->len; + const _BS_word* ptr = rep->s; + register streambuf *sb = os.rdbuf(); + _BS_word a = 0; + + for (unsigned int i = 0; i < xl; ++i) + { + if (i % BITSTRBITS == 0) + a = *ptr++; + sb->sputc((a & 1)? t : f); + a >>= 1; + } +} +const char* BitStringtoa(const BitString& x, char f, char t) +{ + int wrksiz = x.length() + 2; + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + ostrstream stream(fmtbase, wrksiz); + + x.printon(stream, f, t); + stream << ends; + return fmtbase; +} + +ostream& operator << (ostream& s, const BitString& x) +{ + if (s.opfx()) + x.printon(s); + return s; +} + +const char* BitPatterntoa(const BitPattern& p, char f,char t,char x) +{ + unsigned int pl = p.pattern.rep->len; + unsigned int ml = p.mask.rep->len; + unsigned int l = (pl <= ml)? pl : ml; + + int wrksiz = l + 2; + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + ostrstream stream(fmtbase, wrksiz); + + p.printon(stream, f, t, x); + stream << ends; + return fmtbase; +} + +void BitPattern::printon(ostream& s, char f,char t,char x) const +{ + unsigned int pl = pattern.rep->len; + unsigned int ml = mask.rep->len; + unsigned int l = (pl <= ml)? pl : ml; + register streambuf *sb = s.rdbuf(); + + const _BS_word* ps = pattern.rep->s; + const _BS_word* ms = mask.rep->s; + _BS_word a = 0; + _BS_word m = 0; + + for (unsigned int i = 0; i < l; ++i) + { + if (i % BITSTRBITS == 0) + { + a = *ps++; + m = *ms++; + } + if (m & 1) + sb->sputc((a & 1)? t : f); + else + sb->sputc(x); + a >>= 1; + m >>= 1; + } +} + +ostream& operator << (ostream& s, const BitPattern& x) +{ + if (s.opfx()) + x.printon(s); + return s; +} + + +int BitString::OK() const +{ + int v = rep != 0; // have a rep; + v &= BitStr_len(rep->len) <= rep->sz; // within allocated size + if (!v) error("invariant failure"); + return v; +} + +int BitSubString::OK() const +{ + int v = S.OK(); // valid BitString + v &= pos + len <= S.rep->len; // within bounds of targ + if (!v) S.error("BitSubString invariant failure"); + return v; +} + +int BitPattern::OK() const +{ + int v = pattern.OK() && mask.OK(); + if (!v) pattern.error("BitPattern invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/BitString.h b/gnu/lib/libg++/libg++/src/BitString.h new file mode 100644 index 00000000000..f3f2d8c3111 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/BitString.h @@ -0,0 +1,763 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + +#ifndef _BitString_h +#ifdef __GNUG__ +#pragma interface +#endif + +#define _BitString_h 1 + +#include +#include + +#undef OK + +#include +#define BITSTRBITS _BS_BITS_PER_WORD + +struct BitStrRep +{ + unsigned int len; // length in bits + unsigned short sz; // allocated slots + _BS_word s[1]; // bits start here +}; + +extern BitStrRep* BStr_alloc(BitStrRep*, const _BS_word*, int, int,int); +extern BitStrRep* BStr_resize(BitStrRep*, int); +extern BitStrRep* BStr_copy(BitStrRep*, const BitStrRep*); +extern BitStrRep* cmpl(const BitStrRep*, BitStrRep*); +extern BitStrRep* and(const BitStrRep*, const BitStrRep*, BitStrRep*); +extern BitStrRep* or(const BitStrRep*, const BitStrRep*, BitStrRep*); +extern BitStrRep* xor(const BitStrRep*, const BitStrRep*, BitStrRep*); +extern BitStrRep* diff(const BitStrRep*, const BitStrRep*, BitStrRep*); +extern BitStrRep* cat(const BitStrRep*, const BitStrRep*, BitStrRep*); +extern BitStrRep* cat(const BitStrRep*, unsigned int, BitStrRep*); +extern BitStrRep* lshift(const BitStrRep*, int, BitStrRep*); + + +class BitString; +class BitPattern; + +class BitStrBit +{ +protected: + BitString& src; + unsigned int pos; + + public: + BitStrBit(BitString& v, int p); + BitStrBit(const BitStrBit& b); + ~BitStrBit(); + operator unsigned int() const; + int operator = (unsigned int b); +}; + +class BitSubString +{ + friend class BitString; + friend class BitPattern; + +protected: + + BitString& S; + unsigned int pos; + unsigned int len; + + BitSubString(BitString& x, int p, int l); + BitSubString(const BitSubString& x); +public: + ~BitSubString(); + + BitSubString& operator = (const BitString&); + BitSubString& operator = (const BitSubString&); + + int length() const; + int empty() const; + + int OK() const; +}; + +class BitString +{ + friend class BitSubString; + friend class BitPattern; +protected: + BitStrRep* rep; + + int search(int, int, const _BS_word*, int, int) const; + int match(int, int, int, const _BS_word*,int,int) const; + BitSubString _substr(int first, int l); + +public: + +// constructors + BitString(); + BitString(const BitString&); + BitString(const BitSubString& y); + + ~BitString(); + + BitString& operator = (unsigned int bit); + BitString& operator = (const BitString& y); + BitString& operator = (const BitSubString& y); + +// equality & subset tests + + friend int operator == (const BitString&, const BitString&); + friend int operator != (const BitString&, const BitString&); + friend int operator < (const BitString&, const BitString&); + friend int operator <= (const BitString&, const BitString&); + friend int operator > (const BitString&, const BitString&); + friend int operator >= (const BitString&, const BitString&); + +// procedural versions of operators + + + friend void and(const BitString&, const BitString&, BitString&); + friend void or(const BitString&, const BitString&, BitString&); + friend void xor(const BitString&, const BitString&, BitString&); + friend void diff(const BitString&, const BitString&, BitString&); + friend void cat(const BitString&, const BitString&, BitString&); + friend void cat(const BitString&, unsigned int, BitString&); + friend void lshift(const BitString&, int, BitString&); + friend void rshift(const BitString&, int, BitString&); + + friend void complement(const BitString&, BitString&); + + friend int lcompare(const BitString&, const BitString&); + +// assignment-based operators +// (constuctive versions decalred inline below + + BitString& operator |= (const BitString&); + BitString& operator &= (const BitString&); + BitString& operator -= (const BitString&); + BitString& operator ^= (const BitString&); + BitString& operator += (const BitString&); + BitString& operator += (unsigned int b); + BitString& operator <<=(int s); + BitString& operator >>=(int s); + + void complement(); + +// individual bit manipulation + + void set(int pos); + void set(int from, int to); + void set(); + + void clear(int pos); + void clear(int from, int to); + void clear(); + + void invert(int pos); + void invert(int from, int to); + + int test(int pos) const; + int test(int from, int to) const; + + void assign(int p, unsigned int bit); + +// indexing + + BitStrBit operator [] (int pos); + +// iterators + + int first(unsigned int bit = 1) const; + int last(unsigned int b = 1) const; + + int next(int pos, unsigned int b = 1) const; + int prev(int pos, unsigned int b = 1) const; + int previous(int pos, unsigned int b = 1) const + { return prev(pos, b); } /* Obsolete synonym */ + +// searching & matching + + int index(unsigned int bit, int startpos = 0) const ; + int index(const BitString&, int startpos = 0) const; + int index(const BitSubString&, int startpos = 0) const; + int index(const BitPattern&, int startpos = 0) const; + + int contains(const BitString&) const; + int contains(const BitSubString&) const; + int contains(const BitPattern&) const; + + int contains(const BitString&, int pos) const; + int contains(const BitSubString&, int pos) const; + int contains(const BitPattern&, int pos) const; + + int matches(const BitString&, int pos = 0) const; + int matches(const BitSubString&, int pos = 0) const; + int matches(const BitPattern&, int pos = 0) const; + +// BitSubString extraction + + BitSubString at(int pos, int len); + BitSubString at(const BitString&, int startpos = 0); + BitSubString at(const BitSubString&, int startpos = 0); + BitSubString at(const BitPattern&, int startpos = 0); + + BitSubString before(int pos); + BitSubString before(const BitString&, int startpos = 0); + BitSubString before(const BitSubString&, int startpos = 0); + BitSubString before(const BitPattern&, int startpos = 0); + + BitSubString after(int pos); + BitSubString after(const BitString&, int startpos = 0); + BitSubString after(const BitSubString&, int startpos = 0); + BitSubString after(const BitPattern&, int startpos = 0); + +// other friends & utilities + + friend BitString common_prefix(const BitString&, const BitString&, + int pos = 0); + friend BitString common_suffix(const BitString&, const BitString&, + int pos = -1); + friend BitString reverse(const BitString&); + + void right_trim(unsigned int bit); + void left_trim(unsigned int bit); + +// status + + int empty() const ; + int count(unsigned int bit = 1) const; + int length() const; + +// convertors & IO + + friend BitString atoBitString(const char* s, char f='0', char t='1'); + // BitStringtoa is deprecated; do not use in new programs! + friend const char* BitStringtoa(const BitString&, char f='0', char t='1'); + void printon(ostream&, char f='0', char t='1') const; + + friend BitString shorttoBitString(unsigned short); + friend BitString longtoBitString(unsigned long); + + friend ostream& operator << (ostream& s, const BitString&); + +// misc + + void error(const char* msg) const; + +// indirect friends + + friend BitPattern atoBitPattern(const char* s, + char f='0',char t='1',char x='X'); + friend const char* BitPatterntoa(const BitPattern& p, + char f='0',char t='1',char x='X'); + int OK() const; +}; + + +class BitPattern +{ +public: + BitString pattern; + BitString mask; + + BitPattern(); + BitPattern(const BitPattern&); + BitPattern(const BitString& p, const BitString& m); + + ~BitPattern(); + + friend const char* BitPatterntoa(const BitPattern& p, + char f/*='0'*/,char t/*='1'*/,char x/*='X'*/); + void printon(ostream&, char f='0',char t='1',char x='X') const; + friend BitPattern atoBitPattern(const char* s, char f,char t, char x); + friend ostream& operator << (ostream& s, const BitPattern&); + + int search(const _BS_word*, int, int) const; + int match(const _BS_word* xs, int, int, int) const; + + int OK() const; +}; + +BitString operator & (const BitString& x, const BitString& y); +BitString operator | (const BitString& x, const BitString& y); +BitString operator ^ (const BitString& x, const BitString& y); +BitString operator << (const BitString& x, int y); +BitString operator >> (const BitString& x, int y); +BitString operator - (const BitString& x, const BitString& y); +BitString operator + (const BitString& x, const BitString& y); +BitString operator + (const BitString& x, unsigned int y); +BitString operator ~ (const BitString& x); +int operator != (const BitString& x, const BitString& y); +int operator>(const BitString& x, const BitString& y); +int operator>=(const BitString& x, const BitString& y); + +extern BitStrRep _nilBitStrRep; +extern BitString _nil_BitString; + +// primitive bit extraction + +// These must be inlined regardless of optimization. + +inline int BitStr_index(int l) { return (unsigned)(l) / BITSTRBITS; } + +inline int BitStr_pos(int l) { return l & (BITSTRBITS - 1); } + + +// constructors & assignment + +inline BitString::BitString() :rep(&_nilBitStrRep) {} + +inline BitString::BitString(const BitString& x) :rep(BStr_copy(0, x.rep)) {} + +inline BitString::BitString(const BitSubString& y) + :rep (BStr_alloc(0, y.S.rep->s, y.pos, y.pos+y.len, y.len)) {} + +inline BitString::~BitString() +{ + if (rep != &_nilBitStrRep) delete rep; +} + +inline BitString shorttoBitString(unsigned short w) +{ + BitString r; + _BS_word ww = w; +#if _BS_BIGENDIAN + abort(); +#endif + r.rep = BStr_alloc(0, &ww, 0, 8 * sizeof(short), 8 * sizeof(short)); + return r; +} + +inline BitString longtoBitString(unsigned long w) +{ + BitString r; +#if 1 + _BS_word u = w; + r.rep = BStr_alloc(0, &u, 0, BITSTRBITS, BITSTRBITS); +#else + unsigned short u[2]; + u[0] = w & ((unsigned short)(~(0))); + u[1] = w >> BITSTRBITS; + r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS); +#endif + return r; +} + +inline BitString& BitString::operator = (const BitString& y) +{ + rep = BStr_copy(rep, y.rep); + return *this; +} + +inline BitString& BitString::operator = (unsigned int b) +{ + _BS_word bit = b; + rep = BStr_alloc(rep, &bit, 0, 1, 1); + return *this; +} + +inline BitString& BitString::operator=(const BitSubString& y) +{ + rep = BStr_alloc(rep, y.S.rep->s, y.pos, y.pos+y.len, y.len); + return *this; +} + +inline BitSubString::BitSubString(const BitSubString& x) + :S(x.S), pos(x.pos), len(x.len) {} + +inline BitSubString::BitSubString(BitString& x, int p, int l) + : S(x), pos(p), len(l) {} + +inline BitSubString::~BitSubString() {} + +inline BitPattern::BitPattern(const BitString& p, const BitString& m) + :pattern(p), mask(m) {} + +inline BitPattern::BitPattern(const BitPattern& b) + :pattern(b.pattern), mask(b.mask) {} + +inline BitPattern::BitPattern() {} +inline BitPattern::~BitPattern() {} + + +// procedural versions of operators + +inline void and(const BitString& x, const BitString& y, BitString& r) +{ + r.rep = and(x.rep, y.rep, r.rep); +} + +inline void or(const BitString& x, const BitString& y, BitString& r) +{ + r.rep = or(x.rep, y.rep, r.rep); +} + +inline void xor(const BitString& x, const BitString& y, BitString& r) +{ + r.rep = xor(x.rep, y.rep, r.rep); +} + +inline void diff(const BitString& x, const BitString& y, BitString& r) +{ + r.rep = diff(x.rep, y.rep, r.rep); +} + +inline void cat(const BitString& x, const BitString& y, BitString& r) +{ + r.rep = cat(x.rep, y.rep, r.rep); +} + +inline void cat(const BitString& x, unsigned int y, BitString& r) +{ + r.rep = cat(x.rep, y, r.rep); +} + +inline void rshift(const BitString& x, int y, BitString& r) +{ + r.rep = lshift(x.rep, -y, r.rep); +} + +inline void lshift(const BitString& x, int y, BitString& r) +{ + r.rep = lshift(x.rep, y, r.rep); +} + +inline void complement(const BitString& x, BitString& r) +{ + r.rep = cmpl(x.rep, r.rep); +} + +// operators + + +inline BitString& BitString::operator &= (const BitString& y) +{ + and(*this, y, *this); + return *this; +} + + +inline BitString& BitString::operator |= (const BitString& y) +{ + or(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator ^= (const BitString& y) +{ + xor(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator <<= (int y) +{ + lshift(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator >>= (int y) +{ + rshift(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator -= (const BitString& y) +{ + diff(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator += (const BitString& y) +{ + cat(*this, y, *this); + return *this; +} + +inline BitString& BitString::operator += (unsigned int y) +{ + cat(*this, y, *this); + return *this; +} + +inline void BitString::complement() +{ + ::complement(*this, *this); +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +inline BitString operator & (const BitString& x, const BitString& y) return r +{ + and(x, y, r); +} + +inline BitString operator | (const BitString& x, const BitString& y) return r +{ + or(x, y, r); +} + +inline BitString operator ^ (const BitString& x, const BitString& y) return r +{ + xor(x, y, r); +} + +inline BitString operator << (const BitString& x, int y) return r +{ + lshift(x, y, r); +} + +inline BitString operator >> (const BitString& x, int y) return r +{ + rshift(x, y, r); +} + +inline BitString operator - (const BitString& x, const BitString& y) return r +{ + diff(x, y, r); +} + +inline BitString operator + (const BitString& x, const BitString& y) return r +{ + cat(x, y, r); +} + +inline BitString operator + (const BitString& x, unsigned int y) return r +{ + cat(x, y, r); +} + +inline BitString operator ~ (const BitString& x) return r +{ + complement(x, r); +} + +#else /* NO_NRV */ + +inline BitString operator & (const BitString& x, const BitString& y) +{ + BitString r; and(x, y, r); return r; +} + +inline BitString operator | (const BitString& x, const BitString& y) +{ + BitString r; or(x, y, r); return r; +} + +inline BitString operator ^ (const BitString& x, const BitString& y) +{ + BitString r; xor(x, y, r); return r; +} + +inline BitString operator << (const BitString& x, int y) +{ + BitString r; lshift(x, y, r); return r; +} + +inline BitString operator >> (const BitString& x, int y) +{ + BitString r; rshift(x, y, r); return r; +} + +inline BitString operator - (const BitString& x, const BitString& y) +{ + BitString r; diff(x, y, r); return r; +} + +inline BitString operator + (const BitString& x, const BitString& y) +{ + BitString r; cat(x, y, r); return r; +} + +inline BitString operator + (const BitString& x, unsigned int y) +{ + BitString r; cat(x, y, r); return r; +} + +inline BitString operator ~ (const BitString& x) +{ + BitString r; complement(x, r); return r; +} + +#endif + +// status, matching + +inline int BitString::length() const +{ + return rep->len; +} + +inline int BitString::empty() const +{ + return rep->len == 0; +} + +inline int BitString::index(const BitString& y, int startpos) const +{ + return search(startpos, rep->len, y.rep->s, 0, y.rep->len); +} + +inline int BitString::index(const BitSubString& y, int startpos) const +{ + return search(startpos, rep->len, y.S.rep->s, y.pos, y.pos+y.len); +} + +inline int BitString::contains(const BitString& y) const +{ + return search(0, rep->len, y.rep->s, 0, y.rep->len) >= 0; +} + +inline int BitString::contains(const BitSubString& y) const +{ + return search(0, rep->len, y.S.rep->s, y.pos, y.pos+y.len) >= 0; +} + +inline int BitString::contains(const BitString& y, int p) const +{ + return match(p, rep->len, 0, y.rep->s, 0, y.rep->len); +} + +inline int BitString::matches(const BitString& y, int p) const +{ + return match(p, rep->len, 1, y.rep->s, 0, y.rep->len); +} + +inline int BitString::contains(const BitSubString& y, int p) const +{ + return match(p, rep->len, 0, y.S.rep->s, y.pos, y.pos+y.len); +} + +inline int BitString::matches(const BitSubString& y, int p) const +{ + return match(p, rep->len, 1, y.S.rep->s, y.pos, y.pos+y.len); +} + +inline int BitString::contains(const BitPattern& r) const +{ + return r.search(rep->s, 0, rep->len) >= 0; +} + +inline int BitString::contains(const BitPattern& r, int p) const +{ + return r.match(rep->s, p, rep->len, 0); +} + +inline int BitString::matches(const BitPattern& r, int p) const +{ + return r.match(rep->s, p, rep->len, 1); +} + +inline int BitString::index(const BitPattern& r, int startpos) const +{ + return r.search(rep->s, startpos, rep->len); +} + +inline int BitSubString::length() const +{ + return len; +} + +inline int BitSubString::empty() const +{ + return len == 0; +} + +inline int operator != (const BitString& x, const BitString& y) +{ + return !(x == y); +} + +inline int operator>(const BitString& x, const BitString& y) +{ + return y < x; +} + +inline int operator>=(const BitString& x, const BitString& y) +{ + return y <= x; +} + +inline int BitString::first(unsigned int b) const +{ + return next(-1, b); +} + +inline int BitString::last(unsigned int b) const +{ + return prev(rep->len, b); +} + +inline int BitString::index(unsigned int bit, int startpos) const +{ + if (startpos >= 0) + return next(startpos - 1, bit); + else + return prev(rep->len + startpos + 1, bit); +} + +inline void BitString::right_trim(unsigned int b) +{ + int nb = (b == 0)? 1 : 0; + rep = BStr_resize(rep, prev(rep->len, nb) + 1); +} + +inline void BitString::left_trim(unsigned int b) +{ + int nb = (b == 0)? 1 : 0; + int p = next(-1, nb); + rep = BStr_alloc(rep, rep->s, p, rep->len, rep->len - p); +} + +inline int BitString::test(int i) const +{ + return ((unsigned)(i) >= rep->len)? 0 : + ((rep->s[BitStr_index(i)] & (1 << (BitStr_pos(i)))) != 0); +} + + +// subscripting + +inline BitStrBit::BitStrBit(const BitStrBit& b) :src(b.src), pos(b.pos) {} + +inline BitStrBit::BitStrBit(BitString& v, int p) :src(v), pos(p) {} + +inline BitStrBit::~BitStrBit() {} + +inline BitStrBit::operator unsigned int() const +{ + return src.test(pos); +} + +inline int BitStrBit::operator = (unsigned int b) +{ + src.assign(pos, b); return b; +} + +inline BitStrBit BitString::operator [] (int i) +{ + if ((unsigned)(i) >= rep->len) error("illegal bit index"); + return BitStrBit(*this, i); +} + +inline BitSubString BitString::_substr(int first, int l) +{ + if (first < 0 || l <= 0 || (unsigned)(first + l) > rep->len) + return BitSubString(_nil_BitString, 0, 0) ; + else + return BitSubString(*this, first, l); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/ChangeLog b/gnu/lib/libg++/libg++/src/ChangeLog new file mode 100644 index 00000000000..9b165997883 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/ChangeLog @@ -0,0 +1,1127 @@ +Sun Nov 12 16:41:56 1995 Per Bothner + + * configure.in (EXTRA_DISTCLEAN): Add rx.h. + +Thu Nov 9 17:43:04 1995 Jason Merrill + + * String.cc (common_prefix, common_suffix): Fix for scoping for + non-NRV case. + * configure.in (MOSTLYCLEAN): Add pic and stamp-picdir. + From alan@spri.levels.unisa.edu.au (Alan Modra). + +Thu Nov 2 21:54:45 1995 Per Bothner + + * BitSet.cc (shorttoBitsSet, longtoBitSet): Re-implement for + new word-length. + +Wed Sep 27 10:18:03 1995 Roberto Bagnara + + * BitSet.cc: several bug fixes, mainly concerning the treatment + (especially in comparison operators) of non-normalized reps + (e.g. with trailing zeros). + * bitlcomp.c (_BS_lcompare_0): was completely wrong, fixed. + * BitSet.h: added lexical comparison function on BitSets + int lcompare(const BitSet& x, const BitSet& y). + * BitSet.h: now makes use of the _BS_* macros of bitprims.h. + +Tue Sep 5 23:08:05 1995 Brendan Kehoe + + * depend: Updated now that libstdc++ doesn't have a string.h. + +Fri Sep 1 13:22:47 1995 Per Bothner + + * bitprims.h (_BS_BITMASK): Cast 1 to _BS_word. + Fix from Curtis A. Snyder . + +Tue Aug 29 21:53:34 1995 Jason Merrill + + * builtin.h: Remove 'noreturn' attribute from error handler typedefs. + +Tue Aug 22 15:11:46 1995 Jason Merrill + + * error.cc (default_one_arg_error_handler): Lose uses of + _VOLATILE_VOID and NoReturnFunc. + * builtin.h: Replace use of _VOLATILE_VOID with __attribute__ + ((noreturn)). + +Mon Aug 21 12:41:20 1995 Jason Merrill + + * builtin.h: Lose definitions of abs(float), abs(double) and + abs(long). + + * std.h: Use C++ names of standard headers. + + * Complex.h: Use complex from libstdc++. + * Complex.cc: Remove. + * Makefile.in: Forget about Complex.o. + +Wed Aug 2 17:19:12 1995 Per Bothner + + * gen/AVLSet.hP. gen/BSTSet.hP, gen/CHMap.hP, gen/CHNode.hP, + gen/DLList.hP, gen/RAVLMap.hP, gen/SLList.hP, gen/SplayMap.hP, + gen/SplayNode.hP: Re-order constructor args to avoid -Wall warnings. + * gen/BSTSet.ccP (T>BSTSet::add): Re-arrange to avoid warning. + * gen/MPlex.ccP: Make constant unsigned to avoid warning. + * gen/PHPQ.ccP: Add parentheses to avoid warning from -Wall. + +Sun Jun 25 13:58:25 1995 Per Bothner + + * gen/CHMap.hP, gen/AVLSet.hP: Re-order constructor args, + to avoid warnings. Reported by Per Cederqvist . + * RndInt.h: Likewise. Reported by Ralf Stephan . + +Tue Jun 20 20:27:23 1995 Paul Eggert + + * CursesW.h (_begx, _begy, _maxx, _maxy): + Define to be their _-less equivalents + if __bsdi__, __NetBSD__, or __FreeBSD__ is defined, + to work around an incompatibility with 4.4 BSD curses. + +Tue Jun 20 16:49:36 1995 Jason Merrill + + * SmplStat.h, gen/*.hP: Declare inline virtuals accordingly in class. + +Wed Jun 14 21:45:44 1995 Jason Merrill + + * CursesW.cc (OK): Define if not already defined. + +Mon Jun 5 18:42:04 1995 Jason Merrill + + * Makefile.in (libgxx.list): Depend on stamp-picdir. + +Mon May 22 23:46:34 1995 Per Bothner + + * bitprims.h: Rewrite __GNUC__ test to work with gcc-1.xx. + +Fri May 5 17:25:17 1995 Per Bothner + + * timer.c: #include also if we have . + +Fri May 5 13:04:17 1995 Mike Stump + + * Move `for' decl out of `for' statement. + +Thu Apr 27 01:03:42 1995 Jason Merrill + + * Fix24.h: Move definition of ~Fix48 up. + * Fix16.h: Move definition of ~Fix32 up. + +Wed Apr 26 13:01:30 1995 Jason Merrill + + * configure.in (XCINCLUDES): Rename to work with config.shared change. + +Mon Apr 17 16:59:17 1995 Per Bothner + + * BitSet.h: Remove duplicate (forward) decls of inline functions. + +Sun Apr 16 12:47:53 1995 Per Bothner + + * CursesW.h: Make return type explicit instead of implicit int. + Reported by Ulrich Drepper . + + * SLList.h (BaseSLNode): Force double alignment of derived fields. + +Thu Mar 30 18:09:58 1995 Jason Merrill + + * AllocRing.cc (alloc): Call operator new/delete directly. + * String.cc (Snew): Use placement new to create the new rep. + * BitSet.cc (BSnew): Ditto. + * BitString.cc (BSnew): Ditto. + * Fix.cc (_new_Fix): Ditto. + * Obstack.cc (newchunk): Ditto. + * Integer.cc (Inew): Ditto. + (printon): Use array delete to match array new. + +Fri Feb 17 16:33:39 1995 Ian Lance Taylor + + * timer.c: If _G_HAVE_SYS_TIMES is 0, define USE_CLOCK. Add + USE_CLOCK cases where needed which call the ANSI function clock. + + * BitSet.h: Add #undef OK after including system header files, to + avoid problems on VxWorks. + * BitString.h, DLList.h, Integer.h, Obstack.h: Likewise. + * Rational.h, Regex.h, SLList.h, String.h: Likewise. + * BitSet.cc, BitString.cc, Integer.cc, Rational.cc: Likewise. + * String.cc: Likewise. + + * SmplStat.h: Add #undef min and #undef max after including system + header files. + + * timer.c (return_elapsed_time): Fix syntax of #if 0 case. + +Mon Feb 6 20:10:35 1995 Jason Merrill + + * Makefile.in (OBJS): Don't include EH support anymore. + * except.c: Move code to libstdc++/exception.cc. + +Thu Jan 26 13:16:09 1995 Jason Merrill + + * Fix.h: Add Fix(_G_uint16_t) for targets where _G_uint16_t does + not promote to int. + +Fri Jan 20 01:36:37 1995 Jason Merrill + + * Makefile.in (OBJS): Remove new.o and math.o. + + * std.h: Include std/stddef.h instead of defines.h. + * complex.h: Remove (replaced by libstdc++ version). + * defines.h: Remove (replaced by libstdc++ std/stddef.h). + * new.{cc,h}: Remove (replaced by libstdc++ new.cc and std/new.h). + * drt0.c, dynamic_lib.c, init.c, init_main.c: Remove (obsolete). + * math.cc, xyzzy.cc: Remove (obsolete). + * depend: Update. + +Wed Dec 14 18:41:11 1994 Per Bothner + + * gen/VQueue.ccP (VQueue::resize): Fix thinko. Reported by + Jocelyn Serot . + +Tue Dec 13 17:05:02 1994 Per Bothner + + * gen/AVLMap.hP: Re-order base initializer to avoid warning. + Patch from Gustavo Chaves . + +Tue Nov 29 12:58:44 1994 Per Bothner + + * gen/Map.hP (Map::empty, Map::length): Make const. + Patch from Gustavo Chaves . + +Sat Nov 5 19:13:17 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * configure.in (LIBDIR): Set. + +Sat Nov 5 16:23:02 1994 Per Bothner + + * Makefile.in (REGEX_OBJ): Remove ../../librx/rx.o. + This is now the responsibility of ../Makefile.in. + +Fri Nov 4 21:46:30 1994 Paul Eggert + + * bitprims.h (__P): Change argument name spelling from + `paramlist' to `protos' for compatibility with BSDI 1.1. + +Mon Oct 24 16:06:44 1994 Per Bothner + + * CursesW.h (box): Slightly more complicated "wrapper" to turn + box macro into inline function, needed for Solaris2 + (which defines box with no arguments as box32). + +Fri Oct 14 16:36:56 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * CursesW.h: Wrap #include by extern "C" { ... }, + because even systems with "C++-ready" header files often miss curses.h. + + * DLList.cc (BaseDLList::del): Fix memory leak. + Patch from Mark Stankus . + +Thu Oct 13 16:57:08 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen/List.hP, gen/List.ccP (copy): Take const argument. + (List::seekK): Make const. + (const & operator () (Pix p) const): Added. + * gen/List.hP (operator!=): Add missing inline. + * gen/List.hP (new): Take const argument. + * gen/List.ccP (List::del): Defer deleting. + Patches from Klamer Schutte . + +Wed Oct 12 13:49:27 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.cc (Sresize): Make static. + * String.h, String.cc (String::alloc): Don't change length, only size. + Bug reported by Mark Stankus . + * String.cc (join): Use Sresize, not (changed) String::alloc. + Also, merge NO_NRV and named return value versions. + +Thu Sep 29 03:23:24 1994 Philippe De Muyter (phdm@info.ucl.ac.be) + + * timer.c: include before + +Tue Sep 27 13:27:17 1994 Mike Stump (mrs@cygnus.com) + + * Makefile.in, depend, except.c: New support routines for EH. + +Sun Sep 4 14:22:25 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.cc: Remove unneeded #include . + +Thu Sep 1 16:34:33 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * error.cc (#define ABORT): Add missing parentheses. + + * regex.cc, regex.h: Removed. + +Wed Aug 31 10:32:57 1994 Jason Merrill (jason@deneb.cygnus.com) + + * SLList.h: Make BaseSLList::{error,owns,OK} const, create const + SLList::{first,next}. + * DLList.h: Similarly. + +Fri Aug 26 18:44:43 1994 Jason Merrill (jason@deneb.cygnus.com) + + * SLList.h: Make SLList::first and SLList::next const, create + const SLList::operator(). + * DLList.h: Similarly. + +Tue Aug 16 11:41:43 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Regex.cc (Regex::Regex): Add missing 'const'. + + * configure.in (rx.h): Add link to ../../librx/rx.h. + +Mon Aug 15 16:41:30 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Regex.cc, Makefile.in: Change to use Tom Lord'd rx library, + instead of (a very old version of) the regex library. + +Fri Aug 12 12:05:39 1994 Brendan Kehoe (brendan@lisa.cygnus.com) + + Improve Alpha support a bit more. + + * Fix.cc (Fix::shift): Cast Y to _G_int32_t, not long. + (Fix::printon): Use _G_int32_t, not long. + * Fix16.h: Declare all methods to take/return _G_{u,}int32_t, not long + or unsigned long. + (Fix32_fs, Fix32_msb, Fix32_m_max, Fix32_m_min): Cast to _G_{,u}int32_t + not long/unsigned long. + (class Fix32): Make member M _G_int32_t. Declare methods round, + assign, both mantissa, overflow, and range_error to use _G_int32_t. + * Fix16.cc: Likewise. + (operator*, operator/): Declare stuff to be _G_uint32_t, not unsigned + long. + * Fix24.h (twolongs): Make them _G_{,u}int32_t, not long/unsigned long. + (class Fix24): Same as above for Fix32. + * Fix24.cc: As in Fix16.cc. + + * RNG.h (RNG::asLong): Make its return value _G_uint32_t. + * MLCG.h (MLCG::asLong): Likewise. + * MLCG.cc (MLCG::asLong): Likewise. + + * ACG.h (ACG): Make members initialSeed, state, auxState, and + lcgRecurr to be _G_uint32_t. + (ACG::ACG): Declare SEED to be _G_uint32_t. + (ACG::asLong): Declare return value to be _G_uint32_t. + * ACG.cc (ACG::reset): Check _G_int32_t, not long, against double. + Define local variable U to be _G_uint32_t, not unsigned long. + (randomPermutations): Define as _G_uint32_t, not unsigned long. + (seedTable): Likewise. + (LC_A, LC_C, LCG): Likewise. + (ACG::ACG): Define SEED argument to be _G_uint32_t, not unsigned + long. Create a _G_uint32_t for STATE, not an unsigned long. + (ACG::asLong): Declare return to be _G_uint32_t. Make local + variables RESULT, AUXACG, and PERM also be _G_uint32_t. + +Tue Aug 2 00:53:01 1994 Jason Merrill (jason@deneb.cygnus.com) + + * defines.h (enum capacity): Define. + +Fri Jul 22 17:31:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.h (String::operator[](int) const): New method, + added to allow indexing of const Strings. Patch + from Klamer Schutte . + +Thu Jul 21 23:41:36 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * builtin.h: Remove unneeded forward declarations. (Compiling + with -Wall complains because they are missing "inline".) + Reported by Michael Haggerty . + +Wed Jul 20 14:54:50 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.h: Add "inline" to friend declarations, and remove + some unneeded forward references, to avoid complaints from -Wall. + Patch from Klamer Schutte . + +Tue Jul 19 12:35:13 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Complex.h: Remove unneeded forward declarations. (Compiling + with -Wall complains because they are missing "inline".) + Reported by John Eaton . + +Mon Jul 18 18:15:17 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.h, String.cc: Add const to some parameter types, + to fix to const violations. + +Fri Jul 1 11:20:34 1994 Brendan Kehoe (brendan@phydeaux.cygnus.com) + + * MLCG.cc (seedTable): Declare to be a _G_int32_t, not a long. + (MLCG::MLCG): Make its arguments likewise. + (MLCG::reset): Also make SEED1 and SEED2 _G_int32_t. + (MLCG::asLong): Likewise for local variables K and Z. + * MLCG.h (class MLCG): Declare members to be _G_int32_t, not long. + Make constructor and other mothod args and return type match the + way we've adjusted them. + + * RNG.cc (RNG::RNG): Check against _G_uint32_t, not unsigned long. + * RNG.h: Include _G_config.h. + (PrivateRNGSingleType, PrivateRNGDoubleType): Adjust U member the + same way...use _G_uint32_t, not unsigned long. + +Tue Jun 28 03:04:13 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen/List.*: Add some 'const's. + * gen/Vec.*: Ditto. + + * gen/AVec.* (Vec): Add additional vec() method for const AVecs, + which returns a const pointer. The operand of operator = is a + const reference. + +Mon Jun 27 17:49:25 1994 Jason Merrill (jason@deneb.cygnus.com) + + * Fix.*: Add lots of 'const's. Lose _Fix typedef for _Frep*, as + it caused confusion like thinking that 'const _Fix' was meaningful + and declaring references to _Fix. Move _Frep inside of Fix and + rename it to Rep. Move lots of associated functions and variables + inside Fix. Use _G_int16_t instead of uint16. Put function names + flush left. + + * gen/List.* (operator =): Make parameter a const reference. + + * Fix.h (operator =): Make parameter a const reference. + +Wed Jun 15 10:50:35 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * String.cc (Scapitalize): Don't consider '\'' a word break. + +Tue May 31 09:18:10 1994 Mike Stump (mrs@cygnus.com) + + * BitString.cc: Make more portable to machines where sizeof(int) + != sizeof(long). Cures warnings on Alpha. + +Mon May 30 17:31:18 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * bitcount.c: #define inline as empty if compiled + by a non-GNU C compiler. + * Makefile.in (install): Install include files. + (This used to be done by ../Makefile.in.) + +Sun May 29 19:07:29 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * bitdo2.h: Fix typo/thinko: srcbit -> dstbit. + +Wed May 25 15:45:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * SLList.h (SLList::empty): Move up the hierarchy (to become + BaseSLList::empty), and make const. + * DLList.h, DLList.cc (BaseDLList::empty, BaseDLList::length): + Make const. + +Sun May 22 17:13:24 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * bitand.c, bitany.c, bitblt.c, bitclear.c, bitcopy.c, bitcount.c, + bitdo1.h, bitdo2.h, bitinvert.c, bitlcomp.c, bitprims.h, bitset1.c, + bitxor.c: Preliminary version of language-independent (sub-)library + for general low-level manipulation of bistrings. + * BitString.h, BitString.cc, Makefile.in: Partially re-written + BitString class using the new library. + + * sysent.h: New file, provided for compatibility with other C++ + compilers, and so Fresco can compile. + +Thu May 19 23:00:26 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen/PHPQ.ccP (PHPQ::OK): Set int variable to INT_MAX, not + LONG_MAX. + +Fri May 13 14:14:47 1994 Mike Stump (mrs@cygnus.com) + + * bool.h: Use builtin bool, true, and false, if compiler supports + them. + +Wed May 11 00:31:12 1994 Jason Merrill (jason@deneb.cygnus.com) + + Make libg++ build with gcc -ansi -pedantic-errors + * ?LList.*: Add 'const' as necessary to make conformant. + * {BitSet,BitString,Integer,Rational,String}.*: Change NO_NRV to + _G_NO_NRV. + * {Fix,Integer,Rational}.*: Protect uses of ? with #ifndef + __STRICT_ANSI__. + * generic.h: Put /* */ around #endif comment. + * regex.cc: Remove comma at end of enumerator list. + +Fri May 6 14:25:15 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * SLList.h, SLList.cc (BaseSLList::length): Make const. + +Thu May 5 14:28:30 1994 Jason Merrill (jason@deneb.cygnus.com) + + * defines.h: Avoid multiple definition of wint_t. + +Sat Apr 30 14:49:02 1994 Jason Merrill (jason@deneb.cygnus.com) + + * defines.h: New file as per 17.3.1 of the WP. + * new.h: include defines.h instead of std.h. + (new[]): Add default placement version of opeator new[]. + * std.h: include defines.h instead of stddef.h. + +Mon Apr 25 14:05:57 1994 Jason Merrill (jason@deneb.cygnus.com) + + * Fix24.h (operator>>): Cast mask to long explicitly, since it + doesn't fit in a long. + +Sun Mar 27 18:45:20 1994 Jason Merrill (jason@deneb.cygnus.com) + + * BitSet.h (BitSetBit): operator int() is const. + +Mon Mar 14 10:46:26 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * BitSet.h, BitString.{h,cc}, Integer.h, Rational.h, String.h: + Make operator= and similar operators return a reference to lhs. + Patches from Martin Pottendorfer . + + * Obstack.cc: Re-do int -> char* convertsion (using pointer + subtraction as in the C version of obstack.h) to avoid problems + on 64-bits machines like the Alpha. + * Integer.cc (operator>>): Return stream, not 0. + * CursesW.h (box, scroll, touchwin): If these are macros (as + they can be in the SYSV-based nurses.h), convert to inlines. + * Fix.h (Fix::Fix(int, const _Fix)): Use named constants instead + of integer literals. Patch from Andreas Schwab + . + +Thu Feb 10 16:36:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * BitSet.cc (BitSetresize): When newlen is greater than the + old->len (but < old->sz), clear out new words. + +Fri Feb 4 12:07:23 1994 Jason Merrill (jason@deneb.cygnus.com) + + * new.h: Wrap g++-specific things in #ifdef __GNUG__. + (NEW): Use parens now. + (new): Remove definition of realloc-ish new, as it doesn't belong + in a standard header. + +Wed Dec 29 22:52:43 1993 Mike Stump (mrs@cygnus.com) + + * BitSet.h (BitSetBit): Add int operator = (const BitSetBit& b), + because the default op= would have the wrong semantics. + +Mon Dec 6 14:14:52 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * math-68881.h: Removed. + +Sun Dec 5 19:15:01 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Integer.cc (cvtItoa): Delete unused var `gap'. + * Fix.cc (Fix::printon): Delete unused var `format'. + +Thu Nov 18 16:51:49 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * gen/*: Replace all occurences of with . + Replace MAXLONG with LONG_MAX. + +Thu Nov 4 17:00:20 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * gen/List.hP: Re-arrange #includes. Patch submitted + by chris@lslsun7.epfl.ch (Christian Iseli). + + * osfcn.h: #include before . + +Wed Nov 3 12:56:28 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Integer.cc: Move functions that convert between Integer and + double from here to ... + * Intdouble.cc (new file): Here. Improves modularity, and lessens + need for linking with libm.a on some systems (e.g. SunOS4). + * Integer.hP: New file. Integer internals. + * Integer.h, Makefile.in: Associated changes. + +Mon Oct 25 19:16:19 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * timer.c (return_elapsed_time): Make K&R-(not C++-)compatible. + + * configure.in: Define CINCLUDES (to get _G_config.h). + * timer.cc -> timer.c: Convert to reduce some portability + problems with getrusage. + * builtin.h (start_timer, return_elapsed_time): Now extern "C". + +Sat Oct 23 22:29:16 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * gen/SplaySet.hP (SplaySet::operator =): Added. + (Many other classes also need operator=. FIXME.) + +Sun Oct 10 15:02:22 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * gen/VOHSet.ccP: Patch from Doug Lea , fixing + a bug reported by David Einstein . + +Thu Aug 26 18:02:51 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Integer.cc (operator>>(istream&, Integer&): Fixed some logic + problems (single "0" dropped when base is unknown) by copying + algorithm from istream::operator>>(int &). + +Wed Aug 18 12:03:52 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Add libgxx.list, for use by libg++/Makefile. + * configure.in: No longer need TOUCH_ON_COMPILE magic. + * configure.in (MOSTLYCLEAN): Add libgxx.list. + + * CursesW.h: Remove re-definition of wattrset from macro to inline. + Doesn't work under Solaris (wattrset is parameterless), and isn't + needed (there are no conflicting definitions of wattrset in CursesW.*). + +Sat Aug 14 14:01:04 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * malloc.c: New version from Doug Lea. + +Thu Jul 29 13:25:31 1993 Per Bothner (bothner@kalessin) + + * error.cc (abort prototype): Removed (can conflict with stdlib.h). + * error.cc (ABORT): New macro, to call abort(), but with a cast + to avoid g++ warning about volatile function returning. + * error.cc (default_one_arg_error_handler, + default_two_arg_error_handler): Use ABORT macro. + +Wed Jul 28 15:40:29 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * CursesW.cc, RNG.cc, Rational.cc, Regex.cc: + Remove unneeded #include . + * DLList.cc, Obstack.cc, SLList.cc: Replace non-standard #include + by ANSI , and macro MAXLONG by LONG_MAX. + * Makefile.in (OBJS): Remove dtoa.o: It is obsolete and non-portable. + * std.h: Remove #include of non-standard . + +Sat Jul 24 17:57:51 1993 Per Bothner (bothner@kalessin) + + * LogNorm.cc (LogNormal::operator()): Call exp (foo) instead + of pow (M_E, foo), thus avoiding use of non-ANSI M_E macro + (and probably being more efficient). + * timer.cc: Don't #include . + Do #include before #include . + +Mon Jun 28 18:34:41 1993 Per Bothner (bothner@rtl.cygnus.com) + + * regex.cc (STORE_NUMBER): Add cast to avoid g++ warning. + * Fix16.h (Fix32_m_max): Add cast to avoid g++ warning. + +Tue Jun 22 14:08:23 1993 Per Bothner (bothner@deneb.cygnus.com) + + * Integer.h: Remove Integer::operator long and + Integer::operator double. They cuase ambiguities, and this + seems the cleanest fix, though it does break compatibility. + * regex.h, regex.cc: Remove defs of re_comp and re_exec. + +Fri Jun 4 18:06:54 1993 Per Bothner (bothner@cygnus.com) + + * Integer.cc (setbit): Do Iresize also when x.rep initially NULL. + Fixes bug reported by Marco Franzen . + * Integer.cc (clearbit): No need to resize to clear bits! + +Tue Jun 1 16:06:23 1993 Per Bothner (bothner@rtl.cygnus.com) + + * BitSet.h, Complex.h, SmplHist.h: #include , + not obsolete . + * Fix.h (Fix::Fix(double&), Fix::operator=): Take double, not double&. + * Fix.h, Fix.cc, Fix16.h, Fix16.cc, Fix24.h, Fix24.cc: + Make operands be const, where appropriate. (Incoplete.) + * Fix.cc (mantissa, multiply), String.cc (SubString::OK): + Minor changes to avoid ambiguity complaints from cfront. + * Fix.cc, Complex.cc, Rational.cc, String.cc, Integer.cc: + Avoid non-standard iostream operations (ios::set, _fail). + * Rational.cc (pow): Use Integer::as_long(). + * Rational.cc (ceil, floor, round): Use prefix ++ and -- + instead of (the missing) postfix versions. + * Rational.h (Rational::Rational): Add some more overloaded + versions, to avoid cfront ambiguity complaints. + * Integer.h (Integer::opertor long, Integer::operator double): + Disable these, unless using g++. These cause lots of + ambiguities, which g++ tolerates, but shouldn't. + * Integer.h (Integer::as_long, Integer::as_double): + Substitues for above conversions. + + * gen/MPlex.ccP, gen/RPlex.ccP: ANSIfy bzero->memset, bcopy->memcpy. + + * GetOpt.cc, regex.cc: #ifdef sparc, add declaration + __builtin_alloca; needed when compiling on Solaris2 with cfront. + * regex.cc (re_match_2): Add extra cast, to make cfront happy. + * Makefile.in (add-to-targetlib): New rule. + +Fri May 28 14:25:47 1993 Per Bothner (bothner@rtl.cygnus.com) + + * BitSet.h (BitSetBit::operator==, BitSetBit::operator!=), + BitString.h (BitStrBit::operator==, BitStrBit::operator!=): + Remove redundant operators. + * builtin.h (chr, str): Moved to ../iostream/stream.h. + * CursesW.cc (CursesWindow::printw, CursesWindow::mvprintw): + Assume existence of vsprintf. (Will be provided by + libiberty, at worst.) + * CursesW.cc (CursesWindow::scanw, CursesWindow::mvscanw): + Re-do logic for missing vsscanf: Provide an implementation, + unless we're using GNU iostreams. + +Wed May 26 15:09:49 1993 Per Bothner (bothner@cygnus.com) + + * CursesW.h: Also "convert" wstandend, wstandout, and wattrset + from macros to inlines. Needed for Coherent 4.0. + Patch from Jim West . + +Thu May 6 15:52:40 1993 Per Bothner (bothner@cygnus.com) + + * Rational.cc (Rational::fits_in_float, Rational::fits_in_double): + Add explicit double->Rational conversion; else cfront complains. + * SLList.h (SLNode::SLNode), DLList.h (DLNode::DLNode): + Don't use mem-initializers for members of a base class. + * DLList.h (DLList::remove_front, DLList::remove_rear), SLList.h + (SLList::remove_front): Use base class qualifiers to avoid ambiguity. + * gen/AVLMap.ccP, gen/AVLSet.ccP, gen/RAVLMap.ccP: Cfront + complains about jumps past initializer (in switch statement). + Fix by adding block around such statements. + +Fri Apr 30 15:03:12 1993 Per Bothner (bothner@cygnus.com) + + * BitSet.cc (BitSet::printon): Fix name clash (rename s -> os). + * dtoa.cc (dtoa): #ifdef out unless __GNUC__, since cfront + can't compile it (variable-sized array), and it's obsolete anyway. + * configure.in: Set TOUCH_ON_COMPILE to cause stamp file to + be touched on every compile. + +Mon Apr 19 00:48:10 1993 Per Bothner (bothner@cygnus.com) + + * gen/Plex.ccP (Plex::del_chunk): Delete unused local variable. + + * Makefile.in, configure.in: Re-vamped configure scheme. + * CursesW.h: #undef lines to avoid clash on SCO. + +Fri Apr 16 15:25:39 1993 Per Bothner (bothner@cygnus.com) + + * BitSet.{h,cc}, BitString.{h,cc}: Rename BitSet::previous() + and BitString::pvreious() to prev() for the sake of consistency + with other libg++ classes. Keep previous() as a synonym + for compatibility. + +Fri Mar 5 17:25:59 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Integer.cc (Icopy_zero): Make sure we don't trash + a STATIC_IntRep object. + * Integer.cc: #include after and + to avoid some conflict I don't remember. + +Tue Jan 5 20:52:29 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Rational.cc (floor, ceil, round): Use prefix ++ and --, not + postfix, since the Integer class only has prefix defined. + +Tue Dec 29 13:15:59 1992 Ian Lance Taylor (ian@cygnus.com) + + * builtin.h: Check _G_MATH_H_INLINES rather than __hpux. + * CursesW.h: Undef "lines" to avoid problems on SCO 3.2v4. + +Mon Dec 21 18:57:41 1992 Per Bothner (bothner@rtl.cygnus.com) + + * SLList.h: Fix typo. + * osfcn.h: Don't include non-Posix . + * Integer.h, String.h: #include , not old . + * Integer.cc, String.cc: Update _fail->ios::failbit, + _eof->ios::eofbit. + * CursesW.h: #include <_G_config.h> before testing _H_HAVE_CURSES. + * gen/{XPBag,OXPBag}.h: Add #undef remove, to avoid conflicts + with systems where stdio.h defines remove as a macro. + +Wed Dec 9 14:36:37 1992 Per Bothner (bothner@cygnus.com) + + * gen/Bag.hP, gen/List.hP: #undef remove, in case some + version of stdio.h defines remove as a macro. + * gen/MPlex.ccP, gen/RPlex.ccP: Use ANSI memset/memcpy + instead of bzero/bcopy. + +Thu Dec 3 15:37:17 1992 Per Bothner (bothner@cygnus.com) + + * BitSet.cc (operator ==): Fixed version from + karplus@cse.ucsc.edu (Kevin Karplus). + + * Integer.cc (compare, operator>>): Two small patches from + Doug Lea. + * regex.cc, BitString.cc, Fix.cc, Obstack.cc, GetOpt.cc: + Replace bcopy/bzero/cmp by ANSI functions memcpy/memset/memcmp. + * gen/List.ccP: Use EQ macro instead of ==, as appropriate. + * SLList.h, DLList.h: Fix destructors so that clear() is + called directly in the SLList/DLList destructor, not + in the BaseSLList/BaseDLList destructor, since the vtable + pointer gets reset by the time the latter is called. + +Thu Nov 19 17:54:43 1992 Per Bothner (bothner@cygnus.com) + + * BitString.cc, BitSet.cc: Use ANSI byte-string functions + instead of BSD ones: bcmp->memcmp, bzero->memset, bcopy->memcpy. + +Tue Nov 17 21:50:09 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Complex.cc: Use standard fabs() in preference to inline + overloaded function abs() defined in builtin.h. + * DLList.h, SLList.h: Make destructors virtual, to shut up + a warning. + +Thu Oct 29 16:06:38 1992 Per Bothner (bothner@rtl.cygnus.com) + + * GetOpt.h (GetOpt): Make GetOpt::ordering be a regular field, + not a static member. (No reason it should be static.) + * GetOpt.cc: Remove no-longer-needed dedinition of + GetOpt::ordering (- which had visibility problems). + +Tue Oct 27 14:50:52 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Integer.cc, Sample.cc, SmplStat.cc, SmplHist.cc: Replace + non-ANSI HUGE by standard HUGE_VAL or DBL_MAX as appropriate. + +Wed Oct 21 15:22:32 1992 Per Bothner (bothner@cygnus.com) + + * BitSet.cc (BitSetalloc, BitSetresize): Merged in a bug fix + from Kevin Karplus . + * BitSet.ccANSI-fy: bcopy -> memcpy, bzero -> memset. + * Integer.h: Un-optimize non-working operator %=. + +Fri Oct 16 15:35:51 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Obstack.h: ANSI-fy: bcopy -> memcpy. + * builtin.h: Supposedly, HPUX defines __hpux, not hpux. + +Fri Sep 25 11:13:53 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Obstack.cc (Obstack::_free): Use delete [], not plain delete. + + * {SLList,DLList}.{h,cc}: New template-based versions derived + from gen/{SLList,DLList}.{h,cc}P. + * Makefile.in: Make {SLList,DLList}.o. + +Thu Sep 10 22:48:49 1992 Ian Lance Taylor (ian@cygnus.com) + + * CursesW.h, CursesW.cc: don't do anything if the new + configuration flag _G_HAVE_CURSES is zero. + +Mon Aug 31 22:52:17 1992 Brendan Kehoe (brendan@rtl.cygnus.com) + + * BitString.h (BitPattern::BitPatterntoa): Fix comments around + default parameters. + +Mon Aug 31 15:44:07 1992 Per Bothner (bothner@rtl.cygnus.com) + + * gen/Vec.ccP (Vec::index): Use EQ instead of ==. + * BitString.h (BitPatterntoa friend of BitPattern): + Comment out default parameters to avoid duplication (that + cfront -and ANSI- frown on). + * String.h (SubString::contains) Fix parameter list + passed to String::search. + * generic.h: Comment out genericerror() declaration, since + we don't support it. + +Mon Aug 10 15:05:42 1992 Per Bothner (bothner@cygnus.com) + + * gen/defs.hP: New macro HASHTABLE_TOO_CROWDED to decide + when to rehash a hash table (specifically, when 7/8 full). + * gen/{VHSet.ccP,VHBag.ccP,vHMap.ccP}: Use HASHTABLE_TOO_CROWDED + to control when hash table needs to grow. + + * GetOpt.cc (GetOpt::operator()): Replace index() -> strchr(). + * Integer.{h,cc}: Add Integer::Integer(unsigned long) + constructor in addition to Integer::Integer(long). + * Rational.h: Add Rational constructors taking (unsigned long). + * Makefile.in (XTRAFLAGS): Fix. + +Mon Jul 13 06:52:57 1992 Michael Tiemann (tiemann@rtl.cygnus.com) + + * Regex.cc (Regex::Regex): Cast malloc calls, since G++ no longer + freely converts void* to char* (in accordance with dpANSI spec). + +Fri Jun 26 11:23:32 1992 Per Bothner (bothner@rtl.cygnus.com) + + * BitString.cc: Replace bcopy->memmove; + add const to cast; remove two unused variables. + * CursesW.h, builtin.h: Kludges for hpux. + * Integer.cc: Replace MAXLONG/MINLONG by ANSI standard + LONG_MAX/LONG_MIN. + * Integer.h, Integer.cc, builtin.h: Protect setbit function + name from macro-expansion (on systems that define setbit as + a macro is sys/param.h) by putting parentheses around it. + * Obstack.h, regex.cc: Use proper const-ness in casts, + * std.h: #include <_G_config.h>, since it may not be + included otherwise if we're not using ../g++-include. + +Sat Jun 13 20:05:24 1992 Per Bothner (bothner@rtl.cygnus.com) + + * gen/List.ccP: Remove redundant 'inline'. + * gen/{SLList,DLList}.{hP,ccP}: Make 'copy-ee' arg of copy + constructors and 2nd arg of operator= be const. + * CursesW.h: Make more robust wrt const vs. non-const + formal parameters to support SVR4. + * EH.cc, EH2.c: Removed (since currently not used). + * GetOpt.cc: alloca() kludges. + * {BitSet,BitString}.{cc,h}, Integer.cc, String.cc: Remove + dependence on non-standard in favor of standard + CHAR_BIT from + * Makefile.in: Fix *clean stuff. + * math-68881.h: Updated versions form gcc2. + * timer.cc: #include before . + Use !_G_HAVE_SYS_RESOURCE, not !defined(_G_HAVE_SYS_RESOURCE). + +Mon Jun 15 19:57:45 1992 Mike Stump (mrs at cygnus.com) + + * regex.cc (re_compile_pattern): Add const to p, p1, pend and p1. + +Wed Jun 3 16:49:51 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Fix.cc (Fix::printon): Fix fmtflags -> ios::fmtflags. + * Makefile.in: Hook (for Linux) for not putting regex.o into lib. + * Regex.cc (Regex::Regex): Replace cast. + * regex.h (RE_DUP_MAX): Gross hack for AIX. + * regex.h, regex.cc, Regex.c: Change 2nd arg of + re_compile_pattern from (char*) to (const char*). + * timer.cc: Use explicit USE_TIMES to control use of + times() instead of getrusage(). Supposedly, some systems + have , but not getrusage(). + +Fri May 29 11:51:44 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Fix.cc (Fix::printon):: Re-write to use operator<< instead + of the non-standard ostream::form. + * builtin.h: Removed redundant declarations of min() and max() + (available in minmax.h). + * malloc.c, regex.cc: Replace #ifdef USG by #ifdef _G_SYSV. + * math-68881.h: Update from gcc (should be removed!), + * minmax.h: Removed redundant 'signed' qualifiers. + Add (char) versiosn of min and max, and made the (signed + char) version conditional #ifndef _G_BROKEN_SIGNED_CHAR. + * regex.cc: Better definitions of SIGN_EXTEND_CHAR. + * new.cc: Change //-comment to /*comment*/ for old cpp-s. + * Binomial.h, DiscUnif.h, Erlang.h, Geom.h, HypGeom.h, LogNorm.h, + NegExp.h, Normal.h, Poisson.h, Uniform.h, Weibull.h, + gen/{AVLMap.hP,AVec.hP,RAVLMap.hP,SplayMap.hP}: Replace + anachronistic base constructor syntax :(args) with :Base(args). + * gen/stdlib.h (_do_treeify): #include (for abort()). + * gen/{CHNode,SplayNode,Vec}.hP: Include .defs.h. + * gen/{FPlex,RPlex,XPlex}.{h,cc}P: Remove redundant (and + conflicting - according to cfront) append and prepend methods. + * gen/SkipBag.ccP (SKipBag::seek): Add cast (for cfront's sake). + * gen/SkipMap.hP: Fixed visibilty bug. + * gen/Vec.ccP (operator==): Use EQ macro, instead of !=. + +Thu May 14 00:07:29 1992 Per Bothner (bothner@rtl.cygnus.com) + + * String.cc (operator>> and readline): Clean up setting + of ios::flags(). + + * osfcn.h: Only #include sys/socket.h and sys/resource.h + if these are available (according to _G_config.h). + * timer.cc: If HZ is undefined, define it as CLK_TCK (Posix, sort of). + * gen/Lisp.hP: #include ".defs.h", as done elsewhere. + +Sat May 9 12:34:09 1992 Per Bothner (bothner@rtl.cygnus.com) + + * std.h: Add strcasecmp(). + +Wed May 6 01:33:05 1992 Per Bothner (bothner@rtl.cygnus.com) + + * gen/SLList.{hP,ccP}: Make argument of copy constructor + be const. + + * CursesW.h: Add more kludges to convert macros into inline + functions. This is so we can use /usr/include/curses.h. + * CursesW.h: Replace uses of old cbool typedef by int. + * bool.h: Add a comment deprecating its use. + +Tue May 5 15:19:24 1992 Per Bothner (bothner@rtl.cygnus.com) + + * CursesW.h: Fix typo. + * curses.cc: Removed: No longer needed. + * Makefile.in: Don't build curses.o. + +Sat May 2 16:42:28 1992 Per Bothner (bothner@rtl.cygnus.com) + + VMS changes from Eric Youngdale. + * AllocRing.cc, Obstack.cc: Remove some a VMS hack that + is no longer needed. + * CursesW.cc, regex.h: More VMS stuff. + +Thu Apr 30 13:52:30 1992 Per Bothner (bothner@rtl.cygnus.com) + + * timer.cc: Use the more specific _G_HAVE_SYS_RESOURCE + instead of the vague _G_SYSV. + * delete.cc: Redundant with gcc/libgcc.2.c. + * malloc.c: Remove junk that is now in gcc/libgcc2.c. + +Thu Apr 30 09:11:21 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: make CFLAGS work from command line to make. + +Mon Apr 20 14:42:34 1992 Per Bothner (bothner@cygnus.com) + + * String.cc (String::OK): Re-arrange to avoid + not-reached warning. + * Makefile.in: Make 'touch stamp' not print out. + +Fri Apr 17 12:01:33 1992 Per Bothner (bothner at PersSony) + + * Integer.h, ...: Moved from ../g++-include. The plan + is that ../g++-include only contains wrappers around + standard C headers. It would not be needed on systems + where the C header already support C++ (e.g. SVR4, Linux). + * gen: Directory moved from ../g++-include. + * CursesW.h, CursesW.cc: Handle using /usr/include/curses.h. + * {Integer,Rational}.{h,cc}: Add a convention that an IntRep + whose sz==0 is staticly allocated and should not be deleted + when an Integer is destroyed. Define static INtReps for -1, 0, + and 1, and use those where appropriate (including default + constructors for Integer and Rational). + * Integer.cc, Rational.cc, String.cc: Make Integer::OK(), + Rational::OK() and String::OK() more robust. + * RNG.cc: Don't give RNG::{single,double}Mantissa initial + values, since that may be too late if there is a static + RNG. Instead, initialize them in RNG::RNG. + * bcopy.cc: Removed (use libiberty version). + * timer.cc: Include <_G_config.h> to get __G_SYSV definition. + +Tue Mar 24 16:15:40 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Rational.cc: Added Rational::fits_in_float() and + fits_in_double() methods. Suggested/requested by + Wendell Craig Baker / + +Mon Mar 23 16:34:16 1992 Per Bothner (bothner@rtl.cygnus.com) + + * BitSet.cc, BitString.cc, Fix.cc: Add printon() methods, + and changed operator<< functions to use printon(). + Deprecate use of *toa-style functions that use AllocRing; + the new printon() methods do not. + * Integer.cc: Added Integer::printon; fixed up operator<< + to use opfx() as it's supposed to. + +Fri Mar 6 15:25:55 1992 Per Bothner (bothner@cygnus.com) + + * gnulib3.c: Removed obsolete file. + +Thu Mar 5 16:40:09 1992 Per Bothner (bothner@cygnus.com) + + * *.cc: Experiemnted with for each Foo.cc, adding + '#define _COMPILING_Foo' to control compilation of inlines in + Foo.h, then undid that change (see discussion in + ../g_++-include/ChangeLog). Net difference is thus some + minor tweaking. + + * regex.cc: Tweaks to remove warnings. + +Tue Mar 3 17:23:57 1992 Per Bothner (bothner@cygnus.com) + + * BitSet.cc: Move BitSet::clear() here from BitSet.h, + and make non-inlined. + +Sun Mar 1 16:26:07 1992 Per Bothner (bothner@cygnus.com) + + * BitSet.cc, BitString.cc, Integer.cc, Rational.cc, String.cc: + Make error() methods return void, not volatile void, since + sometimes these error handlers *do* return. + * Fix.cc: Fix parenthesization error. + +Sat Feb 29 14:07:32 1992 Michael Tiemann (tiemann@cygnus.com) + + * regex.cc (re_compile_pattern): Back out source code change that + was used to workaround a bug in g++. + +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. + +Wed Feb 26 12:37:43 1992 Per Bothner (bothner at cygnus.com) + + * BitSet.cc, BitString.cc, Integer.cc, Rational.cc, + String.cc, error.cc: Use new _VOLATILE_VOID macro (from + builtin.h) (to allow compilation by other C++ compilers). + * BitSet.cc,regex.cc: #include . + +Thu Feb 20 21:46:17 1992 Per Bothner (bothner at cygnus.com) + + * Regex.cc, regex.cc: Add some needed casts. + +Wed Feb 19 23:32:38 1992 Per Bothner (bothner at cygnus.com) + + * timer.cc: Include sys/types.h, since it is no + longer automatically included by time.h. + * regex.cc: Added a comment about being based on regex.c. + +Tue Feb 11 11:24:18 1992 Per Bothner (bothner at cygnus.com) + + * String.cc: Only skip ws if appropriate. + * Complex.cc, Fix.cc, Integer.cc, Rational.cc: + Apply fix below to other cases of operator>>. + (And if the format is bad, set failbit, not badbit.) + + * String.cc (String::operator>>, readline): + Use ipfx(0) instead of good() (unless _OLD_STREAMS). + Thus make sure to set the failbit (to prevent + infinite loops if eofbit is set without failbit). + +Mon Feb 10 11:20:13 1992 Per Bothner (bothner at rtl.cygnus.com) + + * String.C (String::operator const char*): Don't + use the str() function to copy into an AllocRing + (since we're phasing out use of AllocRings). + +Wed Jan 29 12:51:05 1992 Per Bothner (bothner at cygnus.com) + + * Sample.cc: Rename #included files to current names. + +Fri Jan 24 15:51:50 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in, configure.in: Some common rules moved to Make.defs. + + * new.cc, delete.cc: Include stdlib.h instead of obsolete malloc.h. + +Fri Jan 17 15:03:28 1992 Per Bothner (bothner at cygnus.com) + + Merge in Doug Lea's latest version; other fixes. + * Most files: Replaced copyright notice (the old + ones claimed to be part of GNU CC). + * Makefile.in (depend): Tweak it. + * ACG.cc, AllocRing.cc, BitSet.cc, BitString.cc, GetOpt.cc, + RNG.cc, dtoa.cc: Minor improvements. + * BitString.cc, Fix16.cc, Fix24.cc, String.cc: Change (int) + to (unsigned int) various places, inspired by gcc-2 warnings. + * Complex.cc, CursesW.cc, Fix.cc, Integer.cc, Rational.cc, + String.cc: Various changes to allow use with either the + old stream facility or the new iostream facility. + * regex.cc: Use 'new char[]' instead of 'malloc()'. + * bcopy.cc: Minor changes. Rename bcopy -> libgxx_bcopy. + * malloc.c: Use size_t consistently. + * regex.cc: New version from FSF (C++ -ified). + * minmax.cc: New file. + * MIN.cc, MAX.cc, std.cc: Removed. + +Sat Jan 11 14:44:17 1992 Michael Tiemann (tiemann at cygnus.com) + + * CursesW.cc, GetOpt.cc: Don't declare any static class members + `static' at top-level. + +Sun Jan 5 00:12:05 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in, configure.in: Automated 'make depend' support. + * String.cc: For now, use _bad instead of ios::badbit. + * File.cc, Filebuf.cc, PlotFile.cc, SFile.cc, filebuf.cc, + form.cc, istream.cc, itoa.cc, ostream.cc, streambuf.cc: + Moved to ../old-stream. + * Makefile.in: Move rules for Making the stream stuff to + ../old-stream/Makefile.in. + +Fri Jan 3 17:00:40 1992 Per Bothner (bothner at cygnus.com) + + * Integer.cc, BitSet.cc, BitString.cc, Rational.cc: + Add #include as needed. It was included by the + old stream.h, but not by the new iostream.h. + * Integer.cc: Merged in Doug Lea's changes to avoid + signed/unsigned warnings. + * Fix.cc, String.cc: Fix some portabilty problems that + depended on the old stream code. + +Tue Dec 31 18:19:15 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Move common definitions to ../Make.defs. + * configure.in: Define host_makefile_frag to pull in Make.defs. + +Sat Dec 28 16:47:38 1991 Michael Tiemann (tiemann at cygnus.com) + + * regex.cc (re_compile_pattern,re_comp,main): Use `malloc' instead + of `new char[]' since we need to call realloc, and that doesn't + work with arrays allocated by new. + * Regex.cc (Regex::Regex): Ditto. + diff --git a/gnu/lib/libg++/libg++/src/Complex.h b/gnu/lib/libg++/libg++/src/Complex.h new file mode 100644 index 00000000000..242f06e1664 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Complex.h @@ -0,0 +1,10 @@ +// This may look like C code, but it is really -*- C++ -*- + +#ifndef _Complex_h +#define _Complex_h + +// Use the ANSI complex number template. +#include +typedef complex Complex; + +#endif diff --git a/gnu/lib/libg++/libg++/src/CursesW.cc b/gnu/lib/libg++/libg++/src/CursesW.cc new file mode 100644 index 00000000000..c80f33d47da --- /dev/null +++ b/gnu/lib/libg++/libg++/src/CursesW.cc @@ -0,0 +1,257 @@ +/* +Copyright (C) 1989, 1992 Free Software Foundation + written by Eric Newton (newton@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 +#include +#include +#ifndef _OLD_STREAMS +#include +#endif +// Include CurseW.h and/or curses.h *after* iostream includes, +// because curses.h defines a clear macro that conflicts with iostream. Sigh. +#include + +#if _G_HAVE_CURSES + +#ifndef OK +#define OK (1) +#endif + +int CursesWindow::count = 0; + +/* + * C++ interface to curses library. + * + */ + +#if !defined(_IO_MAGIC) && !defined(HAVE_VSCANF) &&!defined vsscanf +extern "C" int _doscan(FILE *, const char*, va_list args); + +static int vsscanf(char *buf, const char * fmt, va_list args) +{ + FILE b; +#ifdef _IOSTRG + b._flag = _IOREAD|_IOSTRG; +#else + b._flag = _IOREAD; +#endif + b._base = (unsigned char*)buf; + b._ptr = (unsigned char*)buf; + b._cnt = BUFSIZ; + return _doscan(&b, fmt, args); +} +#endif + +/* + * varargs functions are handled conservatively: + * They interface directly into the underlying + * _doscan, _doprnt and/or vfprintf routines rather than + * assume that such things are handled compatibly in the curses library + */ + +int CursesWindow::scanw(const char * fmt, ...) +{ + va_list args; + va_start(args, fmt); +#ifdef VMS + int result = wscanw(w , fmt , args); +#else /* NOT VMS */ + char buf[BUFSIZ]; + int result = wgetstr(w, buf); + if (result == OK) { + +#ifdef _IO_MAGIC /* GNU iostreams */ + strstreambuf ss(buf, BUFSIZ); + result = ss.vscan(fmt, args); +#else + result = vsscanf(buf, fmt, args); +#endif + } +#endif /* !VMS */ + va_end(args); + return result; +} + +int CursesWindow::mvscanw(int y, int x, const char * fmt, ...) +{ + va_list args; + va_start(args, fmt); + char buf[BUFSIZ]; + int result = wmove(w, y, x); + if (result == OK) +#ifdef VMS + result=wscanw(w , fmt , args); +#else /* !VMS */ + { + result = wgetstr(w, buf); + if (result == OK) { +#ifdef _IO_MAGIC /* GNU iostreams */ + strstreambuf ss(buf, BUFSIZ); + result = ss.vscan(fmt, args); +#else + result = vsscanf(buf, fmt, args); +#endif + } + } +#endif /* !VMS */ + va_end(args); + return result; +} + +int CursesWindow::printw(const char * fmt, ...) +{ + va_list args; + va_start(args, fmt); + char buf[BUFSIZ]; + vsprintf(buf, fmt, args); + va_end(args); + return waddstr(w, buf); +} + + +int CursesWindow::mvprintw(int y, int x, const char * fmt, ...) +{ + va_list args; + va_start(args, fmt); + int result = wmove(w, y, x); + if (result == OK) + { + char buf[BUFSIZ]; + vsprintf(buf, fmt, args); + result = waddstr(w, buf); + } + va_end(args); + return result; +} + +CursesWindow::CursesWindow(int lines, int cols, int begin_y, int begin_x) +{ + if (count==0) + initscr(); + + w = newwin(lines, cols, begin_y, begin_x); + if (w == 0) + { + (*lib_error_handler)("CursesWindow", "Cannot construct window"); + } + + alloced = 1; + subwins = par = sib = 0; + count++; +} + +CursesWindow::CursesWindow(WINDOW* &window) +{ + if (count==0) + initscr(); + + w = window; + alloced = 0; + subwins = par = sib = 0; + count++; +} + +CursesWindow::CursesWindow(CursesWindow& win, int l, int c, + int by, int bx, char absrel) +{ + + if (absrel == 'r') // relative origin + { + by += win.begy(); + bx += win.begx(); + } + + // Even though we treat subwindows as a tree, the standard curses + // library needs the `subwin' call to link to the root in + // order to correctly perform refreshes, etc. + + CursesWindow* root = &win; + while (root->par != 0) root = root->par; + + w = subwin(root->w, l, c, by, bx); + if (w == 0) + { + (*lib_error_handler)("CursesWindow", "Cannot construct subwindow"); + } + + par = &win; + sib = win.subwins; + win.subwins = this; + subwins = 0; + alloced = 1; + count++; +} + + +void CursesWindow::kill_subwindows() +{ + for (CursesWindow* p = subwins; p != 0; p = p->sib) + { + p->kill_subwindows(); + if (p->alloced) + { + if (p->w != 0) + ::delwin(p->w); + p->alloced = 0; + } + p->w = 0; // cause a run-time error if anyone attempts to use... + } +} + +CursesWindow::~CursesWindow() +{ + kill_subwindows(); + + if (par != 0) // Snip us from the parent's list of subwindows. + { + CursesWindow * win = par->subwins; + CursesWindow * trail = 0; + for (;;) + { + if (win == 0) + break; + else if (win == this) + { + if (trail != 0) + trail->sib = win->sib; + else + par->subwins = win->sib; + break; + } + else + { + trail = win; + win = win->sib; + } + } + } + + if (alloced && w != 0) + delwin(w); + + --count; + if (count == 0) + endwin(); + else if (count < 0) // cannot happen! + { + (*lib_error_handler)("CursesWindow", "Too many windows destroyed"); + } +} + +#endif /* _G_HAVE_CURSES */ diff --git a/gnu/lib/libg++/libg++/src/CursesW.h b/gnu/lib/libg++/libg++/src/CursesW.h new file mode 100644 index 00000000000..5bff08df258 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/CursesW.h @@ -0,0 +1,603 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +Copyright (C) 1989 Free Software Foundation + written by Eric Newton (newton@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. +*/ + +#ifndef _CursesWindow_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _CursesWindow_h + +#include <_G_config.h> + +#if defined(__bsdi__) || defined(__NetBSD__) || defined(__FreeBSD__) +#define _begx begx +#define _begy begy +#define _maxx maxx +#define _maxy maxy +#endif + +#if _G_HAVE_CURSES +// Even many system which mostly have C++-ready header files, +// do not have C++-ready curses.h. +extern "C" { +#include +} + +/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. + Undefine it here, because CursesWindow uses lines as a method. */ +#undef lines + +// "Convert" macros to inlines, if needed. +#ifdef addch +inline int (addch)(char ch) { return addch(ch); } +#undef addch +#endif +#ifdef addstr +/* The (char*) cast is to hack around missing const's */ +inline int (addstr)(const char * str) { return addstr((char*)str); } +#undef addstr +#endif +#ifdef clear +inline int (clear)() { return clear(); } +#undef clear +#endif +#ifdef clearok +inline int (clearok)(WINDOW* win, int bf) { return clearok(win, bf); } +#undef clearok +#else +extern "C" int clearok(WINDOW*, int); +#endif +#ifdef clrtobot +inline int (clrtobot)() { return clrtobot(); } +#undef clrtobot +#endif +#ifdef clrtoeol +inline int (clrtoeol)() { return clrtoeol(); } +#undef clrtoeol +#endif +#ifdef delch +inline int (delch)() { return delch(); } +#undef delch +#endif +#ifdef deleteln +inline int (deleteln)() { return deleteln(); } +#undef deleteln +#endif +#ifdef erase +inline int (erase)() { return erase(); } +#undef erase +#endif +#ifdef flushok +inline int (flushok)(WINDOW* _win, int _bf) { return flushok(_win, _bf); } +#undef flushok +#else +#define _no_flushok +#endif +#ifdef getch +inline int (getch)() { return getch(); } +#undef getch +#endif +#ifdef getstr +inline int (getstr)(char *_str) { return getstr(_str); } +#undef getstr +#endif +#ifdef getyx +inline void (getyx)(WINDOW* win, int& y, int& x) { getyx(win, y, x); } +#undef getyx +#endif +#ifdef inch +inline int (inch)() { return inch(); } +#undef inch +#endif +#ifdef insch +inline int (insch)(char c) { return insch(c); } +#undef insch +#endif +#ifdef insertln +inline int (insertln)() { return insertln(); } +#undef insertln +#endif +#ifdef leaveok +inline int (leaveok)(WINDOW* win, int bf) { return leaveok(win, bf); } +#undef leaveok +#else +extern "C" int leaveok(WINDOW* win, int bf); +#endif +#ifdef move +inline int (move)(int x, int y) { return move(x, y); } +#undef move +#endif +#ifdef refresh +inline int (rfresh)() { return refresh(); } +#undef refresh +#endif +#ifdef scrollok +inline int (scrollok)(WINDOW* win, int bf) { return scrollok(win, bf); } +#undef scrollok +#else +#ifndef hpux +extern "C" int scrollok(WINDOW*, int); +#else +extern "C" int scrollok(WINDOW*, char); +#endif +#endif +#ifdef standend +inline int (standend)() { return standend(); } +#undef standend +#endif +#ifdef standout +inline int (standout)() { return standout(); } +#undef standout +#endif +#ifdef wstandend +inline int (wstandend)(WINDOW *win) { return wstandend(win); } +#undef wstandend +#endif +#ifdef wstandout +inline int (wstandout)(WINDOW *win) { return wstandout(win); } +#undef wstandout +#endif +#ifdef winch +inline int (winch)(WINDOW* win) { return winch(win); } +#undef winch +#endif + +/* deal with conflicting macros in ncurses.h which is SYSV based*/ +#ifdef box +inline int _G_box(WINDOW* win, chtype v, chtype h) {return box(win, v, h); } +#undef box +inline int box(WINDOW* win, chtype v, chtype h) {return _G_box(win, v, h); } +#endif +#ifdef scroll +inline int (scroll)(WINDOW* win) { return scroll(win); } +#undef scroll +#endif +#ifdef touchwin +inline int (touchwin)(WINDOW* win) { return touchwin(win); } +#undef touchwin +#endif + +#ifdef mvwaddch +inline int (mvwaddch)(WINDOW *win, int y, int x, char ch) +{ return mvwaddch(win, y, x, ch); } +#undef mvwaddch +#endif +#ifdef mvwaddstr +inline int (mvwaddstr)(WINDOW *win, int y, int x, const char * str) +{ return mvwaddstr(win, y, x, (char*)str); } +#undef mvwaddstr +#endif +#ifdef mvwdelch +inline int (mvwdelch)(WINDOW *win, int y, int x) { return mvwdelch(win, y, x);} +#undef mvwdelch +#endif +#ifdef mvwgetch +inline int (mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} +#undef mvwgetch +#endif +#ifdef mvwgetstr +inline int (mvwgetstr)(WINDOW *win, int y, int x, char *str) +{return mvwgetstr(win,y,x, str);} +#undef mvwgetstr +#endif +#ifdef mvwinch +inline int (mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);} +#undef mvwinch +#endif +#ifdef mvwinsch +inline int (mvwinsch)(WINDOW *win, int y, int x, char c) +{ return mvwinsch(win, y, x, c); } +#undef mvwinsch +#endif + +#ifdef mvaddch +inline int (mvaddch)(int y, int x, char ch) +{ return mvaddch(y, x, ch); } +#undef mvaddch +#endif +#ifdef mvaddstr +inline int (mvaddstr)(int y, int x, const char * str) +{ return mvaddstr(y, x, (char*)str); } +#undef mvaddstr +#endif +#ifdef mvdelch +inline int (mvdelch)(int y, int x) { return mvdelch(y, x);} +#undef mvdelch +#endif +#ifdef mvgetch +inline int (mvgetch)(int y, int x) { return mvgetch(y, x);} +#undef mvgetch +#endif +#ifdef mvgetstr +inline int (mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} +#undef mvgetstr +#endif +#ifdef mvinch +inline int (mvinch)(int y, int x) { return mvinch(y, x);} +#undef mvinch +#endif +#ifdef mvinsch +inline int (mvinsch)(int y, int x, char c) +{ return mvinsch(y, x, c); } +#undef mvinsch +#endif + +/* + * + * C++ class for windows. + * + * + */ + +class CursesWindow +{ +protected: + static int count; // count of all active windows: + // We rely on the c++ promise that + // all otherwise uninitialized + // static class vars are set to 0 + + WINDOW * w; // the curses WINDOW + + int alloced; // true if we own the WINDOW + + CursesWindow* par; // parent, if subwindow + CursesWindow* subwins; // head of subwindows list + CursesWindow* sib; // next subwindow of parent + + void kill_subwindows(); // disable all subwindows + +public: + CursesWindow(WINDOW* &window); // useful only for stdscr + + CursesWindow(int lines, // number of lines + int cols, // number of columns + int begin_y, // line origin + int begin_x); // col origin + + CursesWindow(CursesWindow& par, // parent window + int lines, // number of lines + int cols, // number of columns + int by, // absolute or relative + int bx, // origins: + char absrel = 'a'); // if `a', by & bx are + // absolute screen pos, + // else if `r', they are + // relative to par origin + ~CursesWindow(); + +// terminal status + int lines(); // number of lines on terminal, *not* window + int cols(); // number of cols on terminal, *not* window + +// window status + int height(); // number of lines in this window + int width(); // number of cols in this window + int begx(); // smallest x coord in window + int begy(); // smallest y coord in window + int maxx(); // largest x coord in window + int maxy(); // largest x coord in window + +// window positioning + int move(int y, int x); + +// coordinate positioning + void getyx(int& y, int& x); + int mvcur(int sy, int ey, int sx, int ex); + +// input + int getch(); + int getstr(char * str); + int scanw(const char *, ...); + +// input + positioning + int mvgetch(int y, int x); + int mvgetstr(int y, int x, char * str); + int mvscanw(int, int, const char*, ...); + +// output + int addch(const char ch); + int addstr(const char * str); + int printw(const char * fmt, ...); + int inch(); + int insch(char c); + int insertln(); + +// output + positioning + int mvaddch(int y, int x, char ch); + int mvaddstr(int y, int x, const char * str); + int mvprintw(int y, int x, const char * fmt, ...); + int mvinch(int y, int x); + int mvinsch(int y, int x, char ch); + +// borders + int box(char vert, char hor); + +// erasure + int erase(); + int clear(); + int clearok(int bf); + int clrtobot(); + int clrtoeol(); + int delch(); + int mvdelch(int y, int x); + int deleteln(); + +// screen control + int scroll(); + int scrollok(int bf); + int touchwin(); + int refresh(); + int leaveok(int bf); +#ifndef _no_flushok + int flushok(int bf); +#endif + int standout(); + int standend(); + +// multiple window control + int overlay(CursesWindow &win); + int overwrite(CursesWindow &win); + + +// traversal support + CursesWindow* child(); + CursesWindow* sibling(); + CursesWindow* parent(); +}; + + +inline int CursesWindow::begx() +{ + return w->_begx; +} + +inline int CursesWindow::begy() +{ + return w->_begy; +} + +inline int CursesWindow::maxx() +{ + return w->_maxx; +} + +inline int CursesWindow::maxy() +{ + return w->_maxy; +} + +inline int CursesWindow::height() +{ + return maxy() - begy() + 1; +} + +inline int CursesWindow::width() +{ + return maxx() - begx() + 1; +} + +inline int CursesWindow::box(char vert, char hor) +{ + return ::box(w, vert, hor); +} + +inline int CursesWindow::overlay(CursesWindow &win) +{ + return ::overlay(w, win.w); +} + +inline int CursesWindow::overwrite(CursesWindow &win) +{ + return ::overwrite(w, win.w); +} + +inline int CursesWindow::scroll() +{ + return ::scroll(w); +} + + +inline int CursesWindow::touchwin() +{ + return ::touchwin(w); +} + +inline int CursesWindow::addch(const char ch) +{ + return ::waddch(w, ch); +} + +inline int CursesWindow::addstr(const char * str) +{ + // The (char*) cast is to hack around prototypes in curses.h that + // have const missing in the parameter lists. [E.g. SVR4] + return ::waddstr(w, (char*)str); +} + +inline int CursesWindow::clear() +{ + return ::wclear(w); +} + +inline int CursesWindow::clrtobot() +{ + return ::wclrtobot(w); +} + +inline int CursesWindow::clrtoeol() +{ + return ::wclrtoeol(w); +} + +inline int CursesWindow::delch() +{ + return ::wdelch(w); +} + +inline int CursesWindow::deleteln() +{ + return ::wdeleteln(w); +} + +inline int CursesWindow::erase() +{ + return ::werase(w); +} + +inline int CursesWindow::getch() +{ + return ::wgetch(w); +} + +inline int CursesWindow::getstr(char * str) +{ + return ::wgetstr(w, str); +} + +inline int CursesWindow::inch() +{ + return winch(w); +} + +inline int CursesWindow::insch(char c) +{ + return ::winsch(w, c); +} + +inline int CursesWindow::insertln() +{ + return ::winsertln(w); +} + +inline int CursesWindow::move(int y, int x) +{ + return ::wmove(w, y, x); +} + + +inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex) +{ + return ::mvcur(sy, ey, sx,ex); +} + +inline int CursesWindow::mvaddch(int y, int x, char ch) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::waddch(w, ch); +} + +inline int CursesWindow::mvgetch(int y, int x) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::wgetch(w); +} + +inline int CursesWindow::mvaddstr(int y, int x, const char * str) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::waddstr(w, (char*)str); +} + +inline int CursesWindow::mvgetstr(int y, int x, char * str) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::wgetstr(w, str); +} + +inline int CursesWindow::mvinch(int y, int x) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::winch(w); +} + +inline int CursesWindow::mvdelch(int y, int x) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::wdelch(w); +} + +inline int CursesWindow::mvinsch(int y, int x, char ch) +{ + return (::wmove(w, y, x)==ERR) ? ERR : ::winsch(w, ch); +} + +inline int CursesWindow::refresh() +{ + return ::wrefresh(w); +} + +inline int CursesWindow::clearok(int bf) +{ + return ::clearok(w,bf); +} + +inline int CursesWindow::leaveok(int bf) +{ + return ::leaveok(w,bf); +} + +inline int CursesWindow::scrollok(int bf) +{ + return ::scrollok(w,bf); +} + +#ifndef _no_flushok +inline int CursesWindow::flushok(int bf) +{ + return ::flushok(w, bf); +} +#endif + +inline void CursesWindow::getyx(int& y, int& x) +{ + ::getyx(w, y, x); +} + +inline int CursesWindow::standout() +{ + return ::wstandout(w); +} + +inline int CursesWindow::standend() +{ + return ::wstandend(w); +} + +inline int CursesWindow::lines() +{ + return LINES; +} + +inline int CursesWindow::cols() +{ + return COLS; +} + +inline CursesWindow* CursesWindow::child() +{ + return subwins; +} + +inline CursesWindow* CursesWindow::parent() +{ + return par; +} + +inline CursesWindow* CursesWindow::sibling() +{ + return sib; +} + +#endif /* _G_HAVE_CURSES */ +#endif diff --git a/gnu/lib/libg++/libg++/src/DLList.cc b/gnu/lib/libg++/libg++/src/DLList.cc new file mode 100644 index 00000000000..6e15408d35b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/DLList.cc @@ -0,0 +1,327 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + +#ifndef _G_NO_TEMPLATES +#ifdef __GNUG__ +//#pragma implementation +#endif +#include +#include +#include +#include "DLList.h" + +void BaseDLList::error(const char* msg) const +{ + (*lib_error_handler)("DLList", msg); +} + +int BaseDLList::length() const +{ + int l = 0; + BaseDLNode* t = h; + if (t != 0) do { ++l; t = t->fd; } while (t != h); + return l; +} + +// Note: This is an internal method. It does *not* free old contents! + +void BaseDLList::copy(const BaseDLList& a) +{ + if (a.h == 0) + h = 0; + else + { + BaseDLNode* p = a.h; + BaseDLNode* t = copy_node(p->item()); + h = t; + p = p->fd; + while (p != a.h) + { + BaseDLNode* n = copy_node(p->item()); + t->fd = n; + n->bk = t; + t = n; + p = p->fd; + } + t->fd = h; + h->bk = t; + return; + } +} + +void BaseDLList::clear() +{ + if (h == 0) + return; + + BaseDLNode* p = h->fd; + h->fd = 0; + h = 0; + + while (p != 0) + { + BaseDLNode* nxt = p->fd; + delete_node(p); + p = nxt; + } +} + +BaseDLList& BaseDLList::operator = (const BaseDLList& a) +{ + if (h != a.h) + { + clear(); + copy(a); + } + return *this; +} + + +Pix BaseDLList::prepend(const void *datum) +{ + BaseDLNode* t = copy_node(datum); + if (h == 0) + t->fd = t->bk = h = t; + else + { + t->fd = h; + t->bk = h->bk; + h->bk->fd = t; + h->bk = t; + h = t; + } + return Pix(t); +} + +Pix BaseDLList::append(const void *datum) +{ + BaseDLNode* t = copy_node(datum); + if (h == 0) + t->fd = t->bk = h = t; + else + { + t->bk = h->bk; + t->bk->fd = t; + t->fd = h; + h->bk = t; + } + return Pix(t); +} + +Pix BaseDLList::ins_after(Pix p, const void *datum) +{ + if (p == 0) return prepend(datum); + BaseDLNode* u = (BaseDLNode*) p; + BaseDLNode* t = copy_node(datum); + t->bk = u; + t->fd = u->fd; + u->fd->bk = t; + u->fd = t; + return Pix(t); +} + +Pix BaseDLList::ins_before(Pix p, const void *datum) +{ + if (p == 0) error("null Pix"); + BaseDLNode* u = (BaseDLNode*) p; + BaseDLNode* t = copy_node(datum); + t->bk = u->bk; + t->fd = u; + u->bk->fd = t; + u->bk = t; + if (u == h) h = t; + return Pix(t); +} + +void BaseDLList::join(BaseDLList& b) +{ + BaseDLNode* t = b.h; + b.h = 0; + if (h == 0) + h = t; + else if (t != 0) + { + BaseDLNode* l = t->bk; + h->bk->fd = t; + t->bk = h->bk; + h->bk = l; + l->fd = h; + } +} + +int BaseDLList::owns(Pix p) const +{ + BaseDLNode* t = h; + if (t != 0 && p != 0) + { + do + { + if (Pix(t) == p) return 1; + t = t->fd; + } while (t != h); + } + return 0; +} + +void BaseDLList::del(Pix& p, int dir) +{ + if (p == 0) error("null Pix"); + BaseDLNode* t = (BaseDLNode*) p; + if (t->fd == t) + { + h = 0; + p = 0; + } + else + { + if (dir < 0) + { + if (t == h) + p = 0; + else + p = Pix(t->bk); + } + else + { + if (t == h->bk) + p = 0; + else + p = Pix(t->fd); + } + t->bk->fd = t->fd; + t->fd->bk = t->bk; + if (t == h) h = t->fd; + } + delete_node(t); +} + +void BaseDLList::del_after(Pix& p) +{ + if (p == 0) + { + del_front(); + return; + } + + BaseDLNode* b = (BaseDLNode*) p; + BaseDLNode* t = b->fd; + + if (b == t) + { + h = 0; + p = 0; + } + else + { + t->bk->fd = t->fd; + t->fd->bk = t->bk; + if (t == h) h = t->fd; + } + delete_node(t); +} + +void BaseDLList::remove_front(void *dst) +{ + if (h == 0) + error("remove_front of empty list"); + else { + BaseDLNode* t = h; + copy_item(dst, t->item()); + if (h->fd == h) + h = 0; + else + { + h->fd->bk = h->bk; + h->bk->fd = h->fd; + h = h->fd; + } + delete_node(t); + } +} + +void BaseDLList::del_front() +{ + if (h == 0) + error("del_front of empty list"); + BaseDLNode* t = h; + if (h->fd == h) + h = 0; + else + { + h->fd->bk = h->bk; + h->bk->fd = h->fd; + h = h->fd; + } + delete_node(t); +} + +void BaseDLList::remove_rear(void *dst) +{ + if (h == 0) + error("remove_rear of empty list"); + else + { + BaseDLNode* t = h->bk; + copy_item(dst, t->item()); + if (h->fd == h) + h = 0; + else + { + t->fd->bk = t->bk; + t->bk->fd = t->fd; + } + delete_node(t); + } +} + +void BaseDLList::del_rear() +{ + if (h == 0) + error("del_rear of empty list"); + BaseDLNode* t = h->bk; + if (h->fd == h) + h = 0; + else + { + t->fd->bk = t->bk; + t->bk->fd = t->fd; + } + delete_node(t); +} + + +int BaseDLList::OK() const +{ + int v = 1; + if (h != 0) + { + BaseDLNode* t = h; + long count = LONG_MAX; // Lots of chances to find h! + do + { + count--; + v &= t->bk->fd == t; + v &= t->fd->bk == t; + t = t->fd; + } while (v && count > 0 && t != h); + v &= count > 0; + } + if (!v) error("invariant failure"); + return v; +} +#endif diff --git a/gnu/lib/libg++/libg++/src/DLList.h b/gnu/lib/libg++/libg++/src/DLList.h new file mode 100644 index 00000000000..3723c5c6506 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/DLList.h @@ -0,0 +1,139 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _DLList_h +#ifdef __GNUG__ +//#pragma interface +#endif +#define _DLList_h 1 + +#undef OK + +#include + +struct BaseDLNode { + BaseDLNode *bk; + BaseDLNode *fd; + void *item() {return (void*)(this+1);} //Return ((DLNode*)this)->hd +}; + +template +class DLNode : public BaseDLNode +{ + public: + T hd; + DLNode() { } + DLNode(const T& h, DLNode* p = 0, DLNode* n = 0) + : hd(h) { bk = p; fd = n; } + ~DLNode() { } +}; + +class BaseDLList { + protected: + BaseDLNode *h; + + BaseDLList() { h = 0; } + void copy(const BaseDLList&); + BaseDLList& operator= (const BaseDLList& a); + virtual void delete_node(BaseDLNode*node) = 0; + virtual BaseDLNode* copy_node(const void* datum) = 0; + virtual void copy_item(void *dst, void *src) = 0; + virtual ~BaseDLList() { } + + Pix prepend(const void*); + Pix append(const void*); + Pix ins_after(Pix p, const void *datum); + Pix ins_before(Pix p, const void *datum); + void remove_front(void *dst); + void remove_rear(void *dst); + void join(BaseDLList&); + + public: + int empty() const { return h == 0; } + int length() const; + void clear(); + void error(const char* msg) const; + int owns(Pix p) const; + int OK() const; + void del(Pix& p, int dir = 1); + void del_after(Pix& p); + void del_front(); + void del_rear(); +}; + +template +class DLList : public BaseDLList { + //friend class DLListTrav; + + virtual void delete_node(BaseDLNode *node) { delete (DLNode*)node; } + virtual BaseDLNode* copy_node(const void *datum) + { return new DLNode(*(const T*)datum); } + virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } + + public: + DLList() : BaseDLList() { } + DLList(const DLList& a) : BaseDLList() { copy(a); } + + DLList& operator = (const DLList& a) + { BaseDLList::operator=((const BaseDLList&) a); return *this; } + virtual ~DLList() { clear(); } + + Pix prepend(const T& item) {return BaseDLList::prepend(&item);} + Pix append(const T& item) {return BaseDLList::append(&item);} + + void join(DLList& a) { BaseDLList::join(a); } + + T& front() { + if (h == 0) error("front: empty list"); + return ((DLNode*)h)->hd; } + T& rear() { + if (h == 0) error("rear: empty list"); + return ((DLNode*)h->bk)->hd; + } + const T& front() const { + if (h == 0) error("front: empty list"); + return ((DLNode*)h)->hd; } + const T& rear() const { + if (h == 0) error("rear: empty list"); + return ((DLNode*)h->bk)->hd; + } + T remove_front() { T dst; BaseDLList::remove_front(&dst); return dst; } + T remove_rear() { T dst; BaseDLList::remove_rear(&dst); return dst; } + + T& operator () (Pix p) { + if (p == 0) error("null Pix"); + return ((DLNode*)p)->hd; + } + const T& operator () (Pix p) const { + if (p == 0) error("null Pix"); + return ((DLNode*)p)->hd; + } + Pix first() const { return Pix(h); } + Pix last() const { return (h == 0) ? 0 : Pix(h->bk); } + void next(Pix& p) const + { p = (p == 0 || p == h->bk)? 0 : Pix(((DLNode*)p)->fd); } + void prev(Pix& p) const + { p = (p == 0 || p == h)? 0 : Pix(((DLNode*)p)->bk); } + Pix ins_after(Pix p, const T& item) + {return BaseDLList::ins_after(p, &item); } + Pix ins_before(Pix p, const T& item) + {return BaseDLList::ins_before(p, &item);} +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/DiscUnif.cc b/gnu/lib/libg++/libg++/src/DiscUnif.cc new file mode 100644 index 00000000000..950d9f9409e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/DiscUnif.cc @@ -0,0 +1,29 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double DiscreteUniform::operator()() +{ + long tmp = long(floor(delta * pGenerator -> asDouble())); + return( double(pLow + tmp) ); +} + diff --git a/gnu/lib/libg++/libg++/src/DiscUnif.h b/gnu/lib/libg++/libg++/src/DiscUnif.h new file mode 100644 index 00000000000..8633db2c804 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/DiscUnif.h @@ -0,0 +1,72 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _DiscreteUniform_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _DiscreteUniform_h 1 + +#include + +// +// The interval [lo..hi) +// + +class DiscreteUniform: public Random { + long pLow; + long pHigh; + double delta; +public: + DiscreteUniform(long low, long high, RNG *gen); + + long low(); + long low(long x); + long high(); + long high(long x); + + virtual double operator()(); +}; + + +inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) +: Random(gen) +{ + pLow = (low < high) ? low : high; + pHigh = (low < high) ? high : low; + delta = (pHigh - pLow) + 1; +} + +inline long DiscreteUniform::low() { return pLow; } + +inline long DiscreteUniform::low(long x) { + long tmp = pLow; + pLow = x; + delta = (pHigh - pLow) + 1; + return tmp; +} + +inline long DiscreteUniform::high() { return pHigh; } + +inline long DiscreteUniform::high(long x) { + long tmp = pHigh; + pHigh = x; + delta = (pHigh - pLow) + 1; + return tmp; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Erlang.cc b/gnu/lib/libg++/libg++/src/Erlang.cc new file mode 100644 index 00000000000..5a73021f10f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Erlang.cc @@ -0,0 +1,32 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double Erlang::operator()() +{ + double prod = 1.0; + + for (int i = 0; i < k; i++) { + prod *= pGenerator -> asDouble(); + } + return(-log(prod)/a); +} diff --git a/gnu/lib/libg++/libg++/src/Erlang.h b/gnu/lib/libg++/libg++/src/Erlang.h new file mode 100644 index 00000000000..3f2b3ede71f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Erlang.h @@ -0,0 +1,68 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Erlang_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Erlang_h 1 + +#include + +class Erlang: public Random { +protected: + double pMean; + double pVariance; + int k; + double a; + void setState(); +public: + Erlang(double mean, double variance, RNG *gen); + + double mean(); + double mean(double x); + double variance(); + double variance(double x); + + virtual double operator()(); + +}; + + +inline void Erlang::setState() { + k = int( (pMean * pMean ) / pVariance + 0.5 ); + k = (k > 0) ? k : 1; + a = k / pMean; +} + +inline Erlang::Erlang(double mean, double variance, RNG *gen) : Random(gen) +{ + pMean = mean; pVariance = variance; + setState(); +} + +inline double Erlang::mean() { return pMean; } +inline double Erlang::mean(double x) { + double tmp = pMean; pMean = x; setState(); return tmp; +}; + +inline double Erlang::variance() { return pVariance; } +inline double Erlang::variance(double x) { + double tmp = pVariance; pVariance = x; setState(); return tmp; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Fix.cc b/gnu/lib/libg++/libg++/src/Fix.cc new file mode 100644 index 00000000000..9f68f826c6c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix.cc @@ -0,0 +1,670 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 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. +*/ +// +// Fix.cc : variable length fixed point data type class functions +// + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include +#include + +// member constants + +const _G_uint16_t Fix::min_length; +const _G_uint16_t Fix::max_length; +const double Fix::min_value; +const double Fix::max_value; + +// default parameters + +_G_uint16_t Fix::default_length = 16; +int Fix::default_print_width = 8; + +Fix::PEH Fix::overflow_handler = Fix::overflow_saturate; + +Fix::Rep Fix::Rep_0 = { 16, 1, 1, { 0 } }; +Fix::Rep Fix::Rep_m1 = { 16, 1, 1, { 0x8000 } }; +Fix::Rep Fix::Rep_quotient_bump = { 16, 1, 1, { 0x4000 } }; + +// error handling + +void +Fix::default_error_handler(const char* msg) +{ + cerr << "Fix: " << msg << "\n"; + abort(); +} + +void +Fix::default_range_error_handler(const char* msg) +{ + cerr << "Fix: range error in " << msg << "\n"; + //abort(); +} + +one_arg_error_handler_t + Fix::error_handler = Fix::default_error_handler, + Fix::range_error_handler = Fix::default_range_error_handler; + +one_arg_error_handler_t +Fix::set_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = error_handler; + error_handler = f; + return old; +} + +one_arg_error_handler_t +Fix::set_range_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = range_error_handler; + range_error_handler = f; + return old; +} + +void +Fix::error(const char* msg) +{ + error_handler(msg); +} + +void +Fix::range_error(const char* msg) +{ + range_error_handler(msg); +} + +// Fix::Rep allocation and initialization functions + +static inline Fix::Rep* +_new_Fix(_G_uint16_t len) +{ + int siz = (((_G_uint32_t) len + 15) >> 4); + if (siz <= 0) siz = 1; + unsigned int allocsiz = (sizeof(Fix::Rep) + (siz - 1) * sizeof(_G_uint16_t)); + Fix::Rep* z = new (operator new (allocsiz)) Fix::Rep; + memset(z, 0, allocsiz); + z->len = len; + z->siz = siz; + z->ref = 1; + return z; +} + +Fix::Rep* +Fix::new_Fix(_G_uint16_t len) +{ + return _new_Fix(len); +} + +Fix::Rep* +Fix::new_Fix(_G_uint16_t len, const Rep* x) +{ + Rep* z = _new_Fix(len); + return copy(x,z); +} + +Fix::Rep* +Fix::new_Fix(_G_uint16_t len, double d) +{ + Rep* z = _new_Fix(len); + + if ( d == max_value ) + { + z->s[0] = 0x7fff; + for ( int i=1; i < z->siz; i++ ) + z->s[i] = 0xffff; + } + else if ( d < min_value || d > max_value ) + range_error("declaration"); + else + { + if (d < 0) + d += 2.0; + d *= 32768; + for ( int i=0; i < z->siz; i++ ) + { + z->s[i] = (_G_uint16_t )d; + d -= z->s[i]; + d *= 65536; + } + if ( d >= 32768 ) + z->s[z->siz-1]++; + } + mask(z); + return z; +} + +// convert to a double + +double +value(const Fix& x) +{ + double d = 0.0; + for ( int i=x.rep->siz-1; i >= 0; i-- ) + { + d += x.rep->s[i]; + d *= 1./65536.; + } + d *= 2.; + return d < 1. ? d : d - 2.; +} + +// extract mantissa to Integer + +Integer +mantissa(const Fix& x) +{ + Integer a = 1, b=1; + for ( int i=0; i < x.rep->siz; i++ ) + { + a <<= 16; + a += x.rep->s[i]; + b <<= 16; + } + return a-b; +} + +// comparison functions + +inline static int +docmp(const _G_uint16_t* x, const _G_uint16_t* y, int siz) +{ + int diff = (_G_int16_t )*x - (_G_int16_t )*y; + while ( --siz && !diff ) + diff = (_G_int32_t )(_G_uint32_t )*++x - (_G_int32_t )(_G_uint32_t )*++y; + return diff; +} + +inline static int +docmpz(const _G_uint16_t* x, int siz) +{ + while ( siz-- ) + if ( *x++ ) return 1; + return 0; +} + +int +Fix::compare(const Rep* x, const Rep* y) +{ + if ( x->siz == y->siz ) + return docmp(x->s, y->s, x->siz); + else + { + int r; + const Rep* longer, *shorter; + if ( x->siz > y->siz ) + { + longer = x; + shorter = y; + r = 1; + } + else + { + longer = y; + shorter = x; + r = -1; + } + int diff = docmp(x->s, y->s, shorter->siz); + if ( diff ) + return diff; + else if ( docmpz(&longer->s[shorter->siz], longer->siz-shorter->siz) ) + return r; + else + return 0; + } +} + +// arithmetic functions + +Fix::Rep* +Fix::add(const Rep* x, const Rep* y, Rep* r) +{ + _G_uint16_t xsign = x->s[0], ysign = y->s[0]; + const Rep* longer, *shorter; + if ( x->len >= y->len ) + longer = x, shorter = y; + else + longer = y, shorter = x; + if ( r == NULL ) + r = new_Fix(longer->len); + int i; + for ( i=r->siz-1; i >= longer->siz; i-- ) + r->s[i] = 0; + for ( ; i >= shorter->siz; i-- ) + r->s[i] = longer->s[i]; + _G_uint32_t sum = 0, carry = 0; + for ( ; i >= 0; i-- ) + { + sum = carry + (_G_uint32_t )x->s[i] + (_G_uint32_t )y->s[i]; + carry = sum >> 16; + r->s[i] = sum; + } + if ( (xsign ^ sum) & (ysign ^ sum) & 0x8000 ) + overflow_handler(r); + return r; +} + +Fix::Rep* +Fix::subtract(const Rep* x, const Rep* y, Rep* r) +{ + _G_uint16_t xsign = x->s[0], ysign = y->s[0]; + const Rep* longer, *shorter; + if ( x->len >= y->len ) + longer = x, shorter = y; + else + longer = y, shorter = x; + if ( r == NULL ) + r = new_Fix(longer->len); + int i; + for ( i=r->siz-1; i >= longer->siz; i-- ) + r->s[i] = 0; + for ( ; i >= shorter->siz; i-- ) + r->s[i] = (longer == x ? x->s[i] : -y->s[i]); + _G_int16_t carry = 0; + _G_uint32_t sum = 0; + for ( ; i >= 0; i-- ) + { + sum = (_G_int32_t )carry + (_G_uint32_t )x->s[i] - (_G_uint32_t )y->s[i]; + carry = sum >> 16; + r->s[i] = sum; + } + if ( (xsign ^ sum) & (~ysign ^ sum) & 0x8000 ) + overflow_handler(r); + return r; +} + +Fix::Rep* +Fix::multiply(const Rep* x, const Rep* y, Rep* r) +{ + if ( r == NULL ) + r = new_Fix(x->len + y->len); + int xsign = x->s[0] & 0x8000, + ysign = y->s[0] & 0x8000; + Fix X(x->len), Y(y->len); + if ( xsign ) + x = negate(x,X.rep); + if ( ysign ) + y = negate(y,Y.rep); + int i; + for ( i=0; i < r->siz; i++ ) + r->s[i] = 0; + for ( i=x->siz-1; i >= 0; i-- ) + { + _G_uint32_t carry = 0; + for ( int j=y->siz-1; j >= 0; j-- ) + { + int k = i + j + 1; + _G_uint32_t a = (_G_uint32_t )x->s[i] * (_G_uint32_t )y->s[j]; + _G_uint32_t b = ((a << 1) & 0xffff) + carry; + if ( k < r->siz ) + { + b += r->s[k]; + r->s[k] = b; + } + if ( k < (int)r->siz + 1 ) + carry = (a >> 15) + (b >> 16); + } + r->s[i] = carry; + } + if ( xsign != ysign ) + negate(r,r); + return r; +} + +Fix::Rep* +Fix::multiply(const Rep* x, int y, Rep* r) +{ + if ( y != (_G_int16_t )y ) + range_error("multiply by int -- int too large"); + if ( r == NULL ) + r = new_Fix(x->len); + int i; + for ( i=r->siz-1; i >= x->siz; i-- ) + r->s[i] = 0; + _G_int32_t a, carry = 0; + for ( ; i > 0; i-- ) + { + a = (_G_int32_t) (_G_uint32_t )x->s[i] * y + carry; + r->s[i] = a; + carry = a >> 16; // assumes arithmetic right shift + } + a = (_G_int32_t) (_G_int16_t )x->s[0] * y + carry; + r->s[0] = a; + a &= 0xffff8000L; + if ( a != (_G_int32_t)0xffff8000L && a != (_G_int32_t)0L ) { + r->s[0] = 0x8000 ^ x->s[0] ^ y; + overflow_handler(r); + } + return r; +} + +Fix::Rep* +Fix::divide(const Rep* x, const Rep* y, Rep* q, Rep* r) +{ + int xsign = x->s[0] & 0x8000, + ysign = y->s[0] & 0x8000; + if ( q == NULL ) + q = new_Fix(x->len); + copy(&Rep_0,q); + if ( r == NULL ) + r = new_Fix(x->len + y->len - 1); + if ( xsign ) + negate(x,r); + else + copy(x,r); + Fix Y(y->len); + Rep* y2 = ( ysign ? negate(y,Y.rep) : copy(y,Y.rep) ); + if ( !compare(y2) ) + range_error("division -- division by zero"); + else if ( compare(x,y2) >= 0 ) + if ( compare(x,y2) == 0 && (xsign ^ ysign) != 0 ) + { + copy(&Rep_m1,q); + copy(&Rep_0,r); + } + else + range_error("division"); + else + { + Rep* t; + Fix S(r->len), + W(q->len,&Rep_quotient_bump); + for ( int i=1; i < q->len; i++ ) + { + shift(y2,-1,y2); + subtract(r,y2,S.rep); + int s_status = compare(S.rep); + if ( s_status == 0 ) + { + t = r, r = S.rep, S.rep = t; + break; + } + else if ( s_status > 0 ) + { + t = r, r = S.rep, S.rep = t; + add(q,W.rep,q); + } + shift(W.rep,-1,W.rep); + } + if ( xsign ^ ysign ) + negate(q,q); + } + return q; +} + +Fix::Rep* +Fix::shift(const Rep* x, int y, Rep* r) +{ + if ( r == NULL ) + r = new_Fix(x->len); + if ( y == 0 ) + { + copy (x, r); + return r; + } + + int ay = abs((_G_int32_t) y), + ayh = ay >> 4, + ayl = ay & 0x0f; + int xl, u, ilow, ihigh; + _G_uint16_t *rs; + const _G_uint16_t *xsl, *xsr; + + if ( y > 0 ) + { + rs = r->s; + xsl = x->s + ayh; + xsr = xsl + 1; + xl = ayl; + u = 1; + ihigh = x->siz - ayh - 1; + ilow = 0; + } + else + { + rs = &r->s[r->siz - 1]; + xsr = &x->s[r->siz - 1] - ayh; + xsl = xsr - 1; + xl = 16 - ayl; + u = -1; + ihigh = r->siz - ayh - 1; + ilow = ihigh - x->siz; + } + + int xr = 16 - xl; + _G_uint16_t xrmask = 0xffffL >> xr; + int i; + for ( i=0; i < ilow; i++, rs+=u, xsl+=u, xsr+=u ) + *rs = 0; + for ( ; i < ihigh; i++, rs+=u, xsl+=u, xsr+=u ) + *rs = (*xsl << xl) + ((*xsr >> xr) & xrmask); + *rs = (y > 0 ? (*xsl << xl) : ((*xsr >> xr) & xrmask)); + rs += u; + for ( ; ++i < r->siz; rs+=u ) + *rs = 0; + return r; +} + +Fix::Rep* +Fix::negate(const Rep* x, Rep* r) +{ + if ( r == NULL ) + r = new_Fix(x->len); + _G_uint32_t carry = 1; + int i; + for ( i=r->siz-1; i >= x->siz; i-- ) + r->s[i] = 0; + for ( ; i >= 0; i-- ) + { + _G_uint32_t a = (_G_uint16_t )~x->s[i] + carry; // bug work-around + r->s[i] = a; + carry = a >> 16; + } + return r; +} + +// io functions + +Fix +atoF(const char* a, int len) +{ + return Fix(len,atof(a)); +} + +extern AllocRing _libgxx_fmtq; + +void +Fix::printon(ostream& s, int width) const +{ + double val = value(*this); + int old_precision = s.precision(width-3); + _G_int32_t old_flags = s.setf(ios::fixed, ios::fixed|ios::scientific); + if (val >= 0) + s << ' '; + s.width(width-2); + s << val; + s.precision(old_precision); + s.flags(old_flags); +} + +char* +Ftoa(Fix& x, int width) +{ + int wrksiz = width + 2; + char *fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + ostrstream stream(fmtbase, wrksiz); + + x.printon(stream, width); + stream << ends; + return fmtbase; +} + +extern Obstack _libgxx_io_ob; + +Fix +Fix::operator %= (int y) +{ + Fix r((int )rep->len + y, *this); return *this = r; +} + +istream& +operator >> (istream& s, Fix& y) +{ + int got_one = 0; + if (!s.ipfx(0)) + { + s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams. + return s; + } + + char sign = 0, point = 0; + char ch; + s >> ws; + if (!s.good()) + { + s.clear(ios::failbit|s.rdstate()); + return s; + } + while (s.get(ch)) + { + if (ch == '-') + { + if (sign == 0) + { + sign = 1; + _libgxx_io_ob.grow(ch); + } + else + break; + } + if (ch == '.') + { + if (point == 0) + { + point = 1; + _libgxx_io_ob.grow(ch); + } + else + break; + } + else if (ch >= '0' && ch <= '9') + { + got_one = 1; + _libgxx_io_ob.grow(ch); + } + else + break; + } + char * p = (char*)(_libgxx_io_ob.finish(0)); + if (s.good()) + s.putback(ch); + if (!got_one) + s.clear(ios::failbit|s.rdstate()); + else + y = atoF(p); + _libgxx_io_ob.free(p); + return s; +} + +void +show(const Fix& x) +{ + cout << "len = " << x.rep->len << "\n"; + cout << "siz = " << x.rep->siz << "\n"; + cout << "ref = " << x.rep->ref << "\n"; + cout << "man = "; +#ifdef _OLD_STREAMS + cout << Itoa(mantissa(x),16,4*x.rep->siz); +#else + int old_flags = cout.setf(ios::hex, ios::hex|ios::dec|ios::oct); + cout.width(4*x.rep->siz); + cout << mantissa(x); + cout.setf(old_flags, ios::hex|ios::dec|ios::oct); +#endif + cout << "\n"; + cout << "val = " << value(x) << "\n"; +} + +// parameter setting operations + +Fix::PEH Fix::set_overflow_handler(PEH new_handler) +{ + PEH old_handler = overflow_handler; + overflow_handler = new_handler; + return old_handler; +} + +int +Fix::set_default_length(int newlen) +{ + _G_uint16_t oldlen = default_length; + if ( newlen < min_length || newlen > max_length ) + error("illegal length in Fix::set_default_length"); + default_length = newlen; + return oldlen; +} + +// overflow handlers + +void +Fix::overflow_saturate(Rep* r) +{ + if ( (_G_int16_t) r->s[0] > 0 ) + { + r->s[0] = 0x8000; + for ( int i=1; i < r->siz; i++ ) + r->s[i] = 0; + } + else + { + r->s[0] = 0x7fff; + for ( int i = 1; i < (int)r->siz; i++ ) + r->s[i] = 0xffff; + mask(r); + } +} + +void +Fix::overflow_wrap(Rep*) +{} + +void +Fix::overflow_warning_saturate(Rep* r) +{ + overflow_warning(r); + overflow_saturate(r); +} + +void +Fix::overflow_warning(Rep*) +{ + cerr << "Fix: overflow warning\n"; +} + +void +Fix::overflow_error(Rep*) +{ + cerr << "Fix: overflow error\n"; + abort(); +} diff --git a/gnu/lib/libg++/libg++/src/Fix.h b/gnu/lib/libg++/libg++/src/Fix.h new file mode 100644 index 00000000000..ae9b9046e7b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix.h @@ -0,0 +1,523 @@ +// -*- C++ -*- +// Fix.h : variable length fixed point data type +// + +#ifndef _Fix_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Fix_h 1 + +#include +#include +#include +#include +#include + +class Fix +{ + struct Rep // internal Fix representation + { + _G_uint16_t len; // length in bits + _G_uint16_t siz; // allocated storage + _G_int16_t ref; // reference count + _G_uint16_t s[1]; // start of ushort array represention + }; + +public: + + typedef void (*PEH)(Rep*); + +private: + + Rep* rep; + + Fix(Rep*); + Fix(int, const Rep*); + + void unique(); + + static const _G_uint16_t min_length = 1; + static const _G_uint16_t max_length = 65535; + static const double min_value = -1.0; + static const double max_value = 1.0; + + static _G_uint16_t default_length; + static int default_print_width; + static Rep Rep_0; + static Rep Rep_m1; + static Rep Rep_quotient_bump; + + // internal class functions + static void mask(Rep*); + static int compare(const Rep*, const Rep* = &Rep_0); + + static Rep* new_Fix(_G_uint16_t); + static Rep* new_Fix(_G_uint16_t, const Rep*); + static Rep* new_Fix(_G_uint16_t, double); + + static Rep* copy(const Rep*, Rep*); + static Rep* negate(const Rep*, Rep* = NULL); + static Rep* add(const Rep*, const Rep*, Rep* = NULL); + static Rep* subtract(const Rep*, const Rep*, Rep* = NULL); + static Rep* multiply(const Rep*, const Rep*, Rep* = NULL); + static Rep* multiply(const Rep*, int, Rep* = NULL); + static Rep* divide(const Rep*, const Rep*, Rep* = NULL, + Rep* = NULL); + static Rep* shift(const Rep*, int, Rep* = NULL); + + static one_arg_error_handler_t error_handler; + static one_arg_error_handler_t range_error_handler; + + static PEH overflow_handler; + +public: + Fix(); + Fix(const Fix&); + Fix(double); + Fix(int); + Fix(_G_uint16_t); + Fix(int, const Fix&); + Fix(int, double); + + ~Fix(); + + Fix operator = (const Fix&); + Fix operator = (double); + + friend int operator == (const Fix&, const Fix&); + friend int operator != (const Fix&, const Fix&); + + friend int operator < (const Fix&, const Fix&); + friend int operator <= (const Fix&, const Fix&); + friend int operator > (const Fix&, const Fix&); + friend int operator >= (const Fix&, const Fix&); + + Fix& operator + (); + Fix operator - (); + + friend Fix operator + (const Fix&, const Fix&); + friend Fix operator - (const Fix&, const Fix&); + friend Fix operator * (const Fix&, const Fix&); + friend Fix operator / (const Fix&, const Fix&); + + friend Fix operator * (const Fix&, int); + friend Fix operator * (int, const Fix&); + friend Fix operator % (const Fix&, int); + friend Fix operator << (const Fix&, int); + friend Fix operator >> (const Fix&, int); + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + friend Fix operator ? (const Fix&, const Fix&); // max +#endif + + Fix operator += (const Fix&); + Fix operator -= (const Fix&); + Fix operator *= (const Fix&); + Fix operator /= (const Fix&); + + Fix operator *= (int); + Fix operator %= (int); + Fix operator <<=(int); + Fix operator >>=(int); + + friend char* Ftoa(const Fix&, int width = default_print_width); + void printon(ostream&, int width = default_print_width) const; + friend Fix atoF(const char*, int len = default_length); + + friend istream& operator >> (istream&, Fix&); + friend ostream& operator << (ostream&, const Fix&); + + // built-in functions + friend Fix abs(Fix); // absolute value + friend int sgn(const Fix&); // -1, 0, +1 + friend Integer mantissa(const Fix&); // integer representation + friend double value(const Fix&); // double value + friend int length(const Fix&); // field length + friend void show(const Fix&); // show contents + + // error handlers + static void error(const char* msg); // error handler + static void range_error(const char* msg); // range error handler + + static one_arg_error_handler_t set_error_handler(one_arg_error_handler_t f); + static one_arg_error_handler_t + set_range_error_handler(one_arg_error_handler_t f); + + static void default_error_handler (const char *); + static void default_range_error_handler (const char *); + + // non-operator versions for user + friend void negate(const Fix& x, Fix& r); + friend void add(const Fix& x, const Fix& y, Fix& r); + friend void subtract(const Fix& x, const Fix& y, Fix& r); + friend void multiply(const Fix& x, const Fix& y, Fix& r); + friend void divide(const Fix& x, const Fix& y, Fix& q, Fix& r); + friend void shift(const Fix& x, int y, Fix& r); + + // overflow handlers + static void overflow_saturate(Fix::Rep*); + static void overflow_wrap(Fix::Rep*); + static void overflow_warning_saturate(Fix::Rep*); + static void overflow_warning(Fix::Rep*); + static void overflow_error(Fix::Rep*); + + static PEH set_overflow_handler(PEH); + + static int set_default_length(int); +}; + +// function definitions + +inline void +Fix::unique() +{ + if ( rep->ref > 1 ) + { + rep->ref--; + rep = new_Fix(rep->len,rep); + } +} + +inline void +Fix::mask (Fix::Rep* x) +{ + int n = x->len & 0x0f; + if ( n ) + x->s[x->siz - 1] &= 0xffff0000 >> n; +} + +inline Fix::Rep* +Fix::copy(const Fix::Rep* from, Fix::Rep* to) +{ + _G_uint16_t *ts = to->s; + const _G_uint16_t *fs = from->s; + int ilim = to->siz < from->siz ? to->siz : from->siz; + int i; + for ( i=0; i < ilim; i++ ) + *ts++ = *fs++; + for ( ; i < to->siz; i++ ) + *ts++ = 0; + mask(to); + return to; +} + +inline +Fix::Fix(Rep* f) +{ + rep = f; +} + +inline +Fix::Fix() +{ + rep = new_Fix(default_length); +} + +inline +Fix::Fix(int len) +{ + if ( len < min_length || len > max_length ) + error("illegal length in declaration"); + rep = new_Fix((_G_uint16_t) len); +} + +inline +Fix::Fix(_G_uint16_t len) +{ + if ( len < min_length || len > max_length ) + error("illegal length in declaration"); + rep = new_Fix(len); +} + +inline +Fix::Fix(double d) +{ + rep = new_Fix(default_length,d); +} + +inline +Fix::Fix(const Fix& y) +{ + rep = y.rep; rep->ref++; +} + +inline +Fix::Fix(int len, const Fix& y) +{ + if ( len < Fix::min_length || len > Fix::max_length ) + error("illegal length in declaration"); + rep = new_Fix((_G_uint16_t) len,y.rep); +} + +inline +Fix::Fix(int len, const Rep* fr) +{ + if ( len < Fix::min_length || len > Fix::max_length ) + error("illegal length in declaration"); + rep = new_Fix((_G_uint16_t) len,fr); +} + +inline +Fix::Fix(int len, double d) +{ + if ( len < Fix::min_length || len > Fix::max_length ) + error("illegal length in declaration"); + rep = new_Fix((_G_uint16_t) len,d); +} + +inline +Fix::~Fix() +{ + if ( --rep->ref <= 0 ) delete rep; +} + +inline Fix +Fix::operator = (const Fix& y) +{ + if ( rep->len == y.rep->len ) { + ++y.rep->ref; + if ( --rep->ref <= 0 ) delete rep; + rep = y.rep; + } + else { + unique(); + copy(y.rep,rep); + } + return *this; +} + +inline Fix +Fix::operator = (double d) +{ + int oldlen = rep->len; + if ( --rep->ref <= 0 ) delete rep; + rep = new_Fix(oldlen,d); + return *this; +} + +inline int +operator == (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) == 0; +} + +inline int +operator != (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) != 0; +} + +inline int +operator < (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) < 0; +} + +inline int +operator <= (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) <= 0; +} + +inline int +operator > (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) > 0; +} + +inline int +operator >= (const Fix& x, const Fix& y) +{ + return Fix::compare(x.rep, y.rep) >= 0; +} + +inline Fix& +Fix::operator + () +{ + return *this; +} + +inline Fix +Fix::operator - () +{ + Rep* r = negate(rep); return r; +} + +inline Fix +operator + (const Fix& x, const Fix& y) +{ + Fix::Rep* r = Fix::add(x.rep, y.rep); return r; +} + +inline Fix +operator - (const Fix& x, const Fix& y) +{ + Fix::Rep* r = Fix::subtract(x.rep, y.rep); return r; +} + +inline Fix +operator * (const Fix& x, const Fix& y) +{ + Fix::Rep* r = Fix::multiply(x.rep, y.rep); return r; +} + +inline Fix +operator * (const Fix& x, int y) +{ + Fix::Rep* r = Fix::multiply(x.rep, y); return r; +} + +inline Fix +operator * (int y, const Fix& x) +{ + Fix::Rep* r = Fix::multiply(x.rep, y); return r; +} + +inline Fix +operator / (const Fix& x, const Fix& y) +{ + Fix::Rep* r = Fix::divide(x.rep, y.rep); return r; +} + +inline Fix +Fix::operator += (const Fix& y) +{ + unique(); Fix::add(rep, y.rep, rep); return *this; +} + +inline Fix +Fix::operator -= (const Fix& y) +{ + unique(); Fix::subtract(rep, y.rep, rep); return *this; +} + +inline Fix +Fix::operator *= (const Fix& y) +{ + unique(); Fix::multiply(rep, y.rep, rep); return *this; +} + +inline Fix +Fix::operator *= (int y) +{ + unique(); Fix::multiply(rep, y, rep); return *this; +} + +inline Fix +Fix::operator /= (const Fix& y) +{ + unique(); Fix::divide(rep, y.rep, rep); return *this; +} + +inline Fix +operator % (const Fix& x, int y) +{ + Fix r((int) x.rep->len + y, x); return r; +} + +inline Fix +operator << (const Fix& x, int y) +{ + Fix::Rep* rep = Fix::shift(x.rep, y); return rep; +} + +inline Fix +operator >> (const Fix& x, int y) +{ + Fix::Rep* rep = Fix::shift(x.rep, -y); return rep; +} + +inline Fix +Fix::operator <<= (int y) +{ + unique(); Fix::shift(rep, y, rep); return *this; +} + +inline Fix +Fix::operator >>= (int y) +{ + unique(); Fix::shift(rep, -y, rep); return *this; +} + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) +inline Fix +operator ? (const Fix& x, const Fix& y) +{ + if ( Fix::compare(x.rep, y.rep) >= 0 ) return x; else return y; +} +#endif + +inline Fix +abs(Fix x) +{ + Fix::Rep* r = (Fix::compare(x.rep) >= 0 ? Fix::new_Fix(x.rep->len,x.rep) : + Fix::negate(x.rep)); + return r; +} + +inline int +sgn(const Fix& x) +{ + int a = Fix::compare(x.rep); + return a == 0 ? 0 : (a > 0 ? 1 : -1); +} + +inline int +length(const Fix& x) +{ + return x.rep->len; +} + +inline ostream& +operator << (ostream& s, const Fix& y) +{ + if (s.opfx()) + y.printon(s); + return s; +} + +inline void +negate (const Fix& x, Fix& r) +{ + Fix::negate(x.rep, r.rep); +} + +inline void +add (const Fix& x, const Fix& y, Fix& r) +{ + Fix::add(x.rep, y.rep, r.rep); +} + +inline void +subtract (const Fix& x, const Fix& y, Fix& r) +{ + Fix::subtract(x.rep, y.rep, r.rep); +} + +inline void +multiply (const Fix& x, const Fix& y, Fix& r) +{ + Fix::multiply(x.rep, y.rep, r.rep); +} + +inline void +divide (const Fix& x, const Fix& y, Fix& q, Fix& r) +{ + Fix::divide(x.rep, y.rep, q.rep, r.rep); +} + +inline void +shift (const Fix& x, int y, Fix& r) +{ + Fix::shift(x.rep, y, r.rep); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Fix16.cc b/gnu/lib/libg++/libg++/src/Fix16.cc new file mode 100644 index 00000000000..dddab2495d3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix16.cc @@ -0,0 +1,238 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) + adapted for libg++ 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. +*/ + +// +// Fix.cc : fixed precision class support functions +// + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +// basic operators too large to be inline + +short Fix16::assign(double d) +{ + if (d == 1.0) + return Fix16_m_max; + else if (d > Fix16_max) + { + short i = Fix16_m_max; + range_error(i); + return i; + } + else if (d < Fix16_min) + { + short i = Fix16_m_min; + range_error(i); + return i; + } + else + return round(Fix16_mult * d); +} + +_G_int32_t Fix32::assign(double d) +{ + if (d == 1.0) + return Fix32_m_max; + else if (d > Fix32_max) + { + _G_int32_t i = Fix32_m_max; + range_error(i); + return i; + } + else if (d < Fix32_min) + { + _G_int32_t i = Fix32_m_min; + range_error(i); + return i; + } + else + return round(Fix32_mult * d); +} + + +Fix32 operator * (const Fix32& a, const Fix32& b) +{ +// break a and b into lo and hi parts, and do a multiple-precision +// multiply, with rounding + + int apos = (a.m >= 0); + _G_uint32_t ua = (apos)? a.m : - a.m; + ua <<= 1; // ua is biased so result will be 31 bit mantissa, not 30: + _G_uint32_t hi_a = (ua >> 16) & ((1 << 16) - 1); + _G_uint32_t lo_a = ua & ((1 << 16) - 1); + + int bpos = (b.m >= 0); + _G_uint32_t ub = (bpos)? b.m : -b.m; + _G_uint32_t hi_b = (ub >> 16) & ((1 << 16) - 1); + _G_uint32_t lo_b = ub & ((1 << 16) - 1); + + _G_uint32_t r = lo_a * lo_b + (1 << 15); + r = (r >> 16) + hi_a * lo_b + lo_a * hi_b + (1 << 15); + r = (r >> 16) + hi_a * hi_b; + _G_int32_t p = (apos != bpos)? -r : r; + return Fix32(p); +} + +Fix16 operator / (const Fix16& a, const Fix16& b) +{ + short q; + int apos = (a.m >= 0); + _G_int32_t la = (apos)? a.m : -a.m; + _G_int32_t scaled_a = la << 15; + int bpos = (b.m >= 0); + short sb = (bpos)? b.m: -b.m; + if (la >= sb) + { + q = (apos == bpos)? Fix16_m_max: Fix16_m_min; + a.range_error(q); + } + else + { + q = scaled_a / sb; + if ((scaled_a % sb) >= (sb / 2)) ++q; + if (apos != bpos) q = -q; + } + return Fix16(q); +} + +Fix32 operator / (const Fix32& a, const Fix32& b) +{ + _G_int32_t q; + int apos = (a.m >= 0); + _G_uint32_t la = (apos)? a.m : -a.m; + int bpos = (b.m >= 0); + _G_uint32_t lb = (bpos)? b.m: -b.m; + if (la >= lb) + { + q = (apos == bpos)? Fix32_m_max: Fix32_m_min; + a.range_error(q); + } + else // standard shift-based division alg + { + q = 0; + _G_int32_t r = la; + + for (int i = 32; i > 0; i--) + { + if ((unsigned)(r) > lb) { + q = (q << 1) | 1; + r -= lb; + } + else + q = (q << 1); + r <<= 1; + } + + if (apos != bpos) q = -q; // Fix sign + } + return Fix32(q); +} + + +// error handling + +void Fix16::overflow(short& i) const +{ + (*Fix16_overflow_handler)(i); +} + +void Fix32::overflow(_G_int32_t& i) const +{ + (*Fix32_overflow_handler)(i); +} + +void Fix16::range_error(short& i) const +{ + (*Fix16_range_error_handler)(i); +} + +void Fix32::range_error(_G_int32_t& i) const +{ + (*Fix32_range_error_handler)(i); +} + +// data definitions + +Fix16_peh Fix16_overflow_handler = Fix16_overflow_saturate; +Fix32_peh Fix32_overflow_handler = Fix32_overflow_saturate; + +Fix16_peh Fix16_range_error_handler = Fix16_warning; +Fix32_peh Fix32_range_error_handler = Fix32_warning; + +//function definitions + +Fix16_peh set_Fix16_overflow_handler(Fix16_peh new_handler) { + Fix16_peh old_handler = Fix16_overflow_handler; + Fix16_overflow_handler = new_handler; + return old_handler; +} + +Fix32_peh set_Fix32_overflow_handler(Fix32_peh new_handler) { + Fix32_peh old_handler = Fix32_overflow_handler; + Fix32_overflow_handler = new_handler; + return old_handler; +} + +void set_overflow_handler(Fix16_peh handler16, Fix32_peh handler32) { + set_Fix16_overflow_handler(handler16); + set_Fix32_overflow_handler(handler32); +} + +Fix16_peh set_Fix16_range_error_handler(Fix16_peh new_handler) { + Fix16_peh old_handler = Fix16_range_error_handler; + Fix16_range_error_handler = new_handler; + return old_handler; +} + +Fix32_peh set_Fix32_range_error_handler(Fix32_peh new_handler) { + Fix32_peh old_handler = Fix32_range_error_handler; + Fix32_range_error_handler = new_handler; + return old_handler; +} + +void set_range_error_handler(Fix16_peh handler16, Fix32_peh handler32) { + set_Fix16_range_error_handler(handler16); + set_Fix32_range_error_handler(handler32); +} + +void Fix16_overflow_saturate(short& i) + { i = (i > 0 ? Fix16_m_min : Fix16_m_max); } +void Fix16_ignore(short&) {} +void Fix16_warning(short&) + { cerr << "warning: Fix16 result out of range\n"; } +void Fix16_overflow_warning_saturate(short& i) + { cerr << "warning: Fix16 result out of range\n"; + Fix16_overflow_saturate(i); } +void Fix16_abort(short&) + { cerr << "error: Fix16 result out of range\n"; abort(); } + +void Fix32_ignore(_G_int32_t&) {} +void Fix32_overflow_saturate(_G_int32_t& i) + { i = (i > 0 ? Fix32_m_min : Fix32_m_max); } +void Fix32_warning(_G_int32_t&) + { cerr << "warning: Fix32 result out of range\n"; } +void Fix32_overflow_warning_saturate(_G_int32_t& i) + { cerr << "warning: Fix32 result out of range\n"; + Fix32_overflow_saturate(i); } +void Fix32_abort(_G_int32_t&) + { cerr << "error: Fix32 result out of range\n"; abort(); } + diff --git a/gnu/lib/libg++/libg++/src/Fix16.h b/gnu/lib/libg++/libg++/src/Fix16.h new file mode 100644 index 00000000000..7f1336b308c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix16.h @@ -0,0 +1,648 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) + adapted for libg++ 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. +*/ + +#ifndef _Fix16_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Fix16_h 1 + +#include +#include + +// constant definitions + +#define Fix16_fs ((double)((unsigned)(1 << 15))) + +#define Fix16_msb (1 << 15) +#define Fix16_m_max ((1 << 15) - 1) +#define Fix16_m_min ((short)(1 << 15)) + +#define Fix16_mult Fix16_fs +#define Fix16_div (1./Fix16_fs) +#define Fix16_max (1. - .5/Fix16_fs) +#define Fix16_min (-1.) + + +#define Fix32_fs ((double)((_G_uint32_t)(1 << 31))) + +#define Fix32_msb ((_G_uint32_t)(1 << 31)) +#define Fix32_m_max ((_G_int32_t)((1 << 31) - 1)) +#define Fix32_m_min ((_G_int32_t)(1 << 31)) + +#define Fix32_mult Fix32_fs +#define Fix32_div (1./Fix32_fs) +#define Fix32_max (1. - .5/Fix32_fs) +#define Fix32_min (-1.) + + +// +// Fix16 class: 16-bit Fixed point data type +// +// consists of a 16-bit mantissa (sign bit & 15 data bits). +// + +class Fix16 +{ + friend class Fix32; + + short m; + + short round(double d); + short assign(double d); + Fix16(short i); + Fix16(int i); + + operator double() const; + + +public: + Fix16(); + Fix16(const Fix16& f); + Fix16(double d); + Fix16(const Fix32& f); + + ~Fix16(); + + Fix16& operator=(const Fix16& f); + Fix16& operator=(double d); + Fix16& operator=(const Fix32& f); + + friend short& mantissa(Fix16& f); + friend const short& mantissa(const Fix16& f); + friend double value(const Fix16& f); + + Fix16 operator + () const; + Fix16 operator - () const; + + friend Fix16 operator + (const Fix16& f, const Fix16& g); + friend Fix16 operator - (const Fix16& f, const Fix16& g); + friend Fix32 operator * (const Fix16& f, const Fix16& g); + friend Fix16 operator / (const Fix16& f, const Fix16& g); + friend Fix16 operator << (const Fix16& f, int b); + friend Fix16 operator >> (const Fix16& f, int b); + + Fix16& operator += (const Fix16& f); + Fix16& operator -= (const Fix16& f); + Fix16& operator *= (const Fix16& ); + Fix16& operator /= (const Fix16& f); + + Fix16& operator <<=(int b); + Fix16& operator >>=(int b); + + friend int operator == (const Fix16& f, const Fix16& g); + friend int operator != (const Fix16& f, const Fix16& g); + friend int operator >= (const Fix16& f, const Fix16& g); + friend int operator <= (const Fix16& f, const Fix16& g); + friend int operator > (const Fix16& f, const Fix16& g); + friend int operator < (const Fix16& f, const Fix16& g); + + friend istream& operator >> (istream& s, Fix16& f); + friend ostream& operator << (ostream& s, const Fix16& f); + + void overflow(short&) const; + void range_error(short&) const; + + friend Fix16 operator * (const Fix16& f, int g); + friend Fix16 operator * (int g, const Fix16& f); + Fix16& operator *= (int g); +}; + + +// +// Fix32 class: 32-bit Fixed point data type +// +// consists of a 32-bit mantissa (sign bit & 31 data bits). +// + +class Fix32 +{ + friend class Fix16; + + _G_int32_t m; + + _G_int32_t round(double d); + _G_int32_t assign(double d); + + Fix32(_G_int32_t i); + operator double() const; + + +public: + Fix32(); + Fix32(const Fix32& f); + Fix32(const Fix16& f); + Fix32(double d); + ~Fix32(); + + Fix32& operator = (const Fix32& f); + Fix32& operator = (const Fix16& f); + Fix32& operator = (double d); + + friend _G_int32_t& mantissa(Fix32& f); + friend const _G_int32_t& mantissa(const Fix32& f); + friend double value(const Fix32& f); + + Fix32 operator + () const; + Fix32 operator - () const; + + friend Fix32 operator + (const Fix32& f, const Fix32& g); + friend Fix32 operator - (const Fix32& f, const Fix32& g); + friend Fix32 operator * (const Fix32& f, const Fix32& g); + friend Fix32 operator / (const Fix32& f, const Fix32& g); + friend Fix32 operator << (const Fix32& f, int b); + friend Fix32 operator >> (const Fix32& f, int b); + + friend Fix32 operator * (const Fix16& f, const Fix16& g); + + Fix32& operator += (const Fix32& f); + Fix32& operator -= (const Fix32& f); + Fix32& operator *= (const Fix32& f); + Fix32& operator /= (const Fix32& f); + Fix32& operator <<=(int b); + Fix32& operator >>=(int b); + + friend int operator == (const Fix32& f, const Fix32& g); + friend int operator != (const Fix32& f, const Fix32& g); + friend int operator >= (const Fix32& f, const Fix32& g); + friend int operator <= (const Fix32& f, const Fix32& g); + friend int operator > (const Fix32& f, const Fix32& g); + friend int operator < (const Fix32& f, const Fix32& g); + + friend istream& operator >> (istream& s, Fix32& f); + friend ostream& operator << (ostream& s, const Fix32& f); + + void overflow(_G_int32_t& i) const; + void range_error(_G_int32_t& i) const; + + friend Fix32 operator * (const Fix32& f, int g); + friend Fix32 operator * (int g, const Fix32& f); + Fix32& operator *= (int g); +}; + +// active error handler declarations + +typedef void (*Fix16_peh)(short&); +typedef void (*Fix32_peh)(_G_int32_t&); + +extern Fix16_peh Fix16_overflow_handler; +extern Fix32_peh Fix32_overflow_handler; + +extern Fix16_peh Fix16_range_error_handler; +extern Fix32_peh Fix32_range_error_handler; + +#if defined(SHORT_NAMES) || defined(VMS) +#define set_overflow_handler sohndl +#define set_range_error_handler srnghdl +#endif + + +// error handler declarations + +extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh); +extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh); +extern void set_overflow_handler(Fix16_peh, Fix32_peh); + +extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh); +extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh); +extern void set_range_error_handler(Fix16_peh, Fix32_peh); + +extern void + Fix16_ignore(short&), + Fix16_overflow_saturate(short&), + Fix16_overflow_warning_saturate(short&), + Fix16_warning(short&), + Fix16_abort(short&); + +extern void + Fix32_ignore(_G_int32_t&), + Fix32_overflow_saturate(_G_int32_t&), + Fix32_overflow_warning_saturate(_G_int32_t&), + Fix32_warning(_G_int32_t&), + Fix32_abort(_G_int32_t&); + + +inline Fix16::~Fix16() {} + +inline Fix32::~Fix32() {} + +inline short Fix16::round(double d) +{ + return short( (d >= 0)? d + 0.5 : d - 0.5); +} + +inline Fix16::Fix16(short i) +{ + m = i; +} + +inline Fix16::Fix16(int i) +{ + m = i; +} + +inline Fix16::operator double() const +{ + return Fix16_div * m; +} + +inline Fix16::Fix16() +{ + m = 0; +} + +inline Fix16::Fix16(const Fix16& f) +{ + m = f.m; +} + +inline Fix16::Fix16(double d) +{ + m = assign(d); +} + + +inline Fix16& Fix16::operator=(const Fix16& f) +{ + m = f.m; + return *this; +} + +inline Fix16& Fix16::operator=(double d) +{ + m = assign(d); + return *this; +} + + +inline Fix32::Fix32() +{ + m = 0; +} + +inline Fix32::Fix32(_G_int32_t i) +{ + m = i; +} + +inline Fix32:: operator double() const +{ + return Fix32_div * m; +} + + +inline Fix32::Fix32(const Fix32& f) +{ + m = f.m; +} + +inline Fix32::Fix32(const Fix16& f) +{ + m = _G_int32_t(f.m) << 16; +} + +inline Fix32::Fix32(double d) +{ + m = assign(d); +} + +inline Fix16::Fix16(const Fix32& f) +{ + m = f.m >> 16; +} + + +inline Fix16& Fix16::operator=(const Fix32& f) +{ + m = f.m >> 16; + return *this; +} + +inline Fix32& Fix32::operator=(const Fix32& f) +{ + m = f.m; + return *this; +} + +inline Fix32& Fix32::operator=(const Fix16& f) +{ + m = _G_int32_t(f.m) << 16; + return *this; +} + +inline Fix32& Fix32::operator=(double d) +{ + m = assign(d); + return *this; +} + +inline short& mantissa(Fix16& f) +{ + return f.m; +} + +inline const short& mantissa(const Fix16& f) +{ + return f.m; +} + +inline double value(const Fix16& f) +{ + return double(f); +} + +inline Fix16 Fix16::operator+() const +{ + return m; +} + +inline Fix16 Fix16::operator-() const +{ + return -m; +} + +inline Fix16 operator+(const Fix16& f, const Fix16& g) +{ + short sum = f.m + g.m; + if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb ) + f.overflow(sum); + return sum; +} + +inline Fix16 operator-(const Fix16& f, const Fix16& g) +{ + short sum = f.m - g.m; + if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb ) + f.overflow(sum); + return sum; +} + +inline Fix32 operator*(const Fix16& f, const Fix16& g) +{ + return Fix32( _G_int32_t( _G_int32_t(f.m) * _G_int32_t(g.m) << 1)); +} + +inline Fix16 operator<<(const Fix16& a, int b) +{ + return a.m << b; +} + +inline Fix16 operator>>(const Fix16& a, int b) +{ + return a.m >> b; +} + +inline Fix16& Fix16:: operator+=(const Fix16& f) +{ + return *this = *this + f; +} + +inline Fix16& Fix16:: operator-=(const Fix16& f) +{ + return *this = *this - f; +} + +inline Fix16& Fix16::operator*=(const Fix16& f) +{ + return *this = *this * f; +} + +inline Fix16& Fix16:: operator/=(const Fix16& f) +{ + return *this = *this / f; +} + +inline Fix16& Fix16:: operator<<=(int b) +{ + return *this = *this << b; +} + +inline Fix16& Fix16:: operator>>=(int b) +{ + return *this = *this >> b; +} + +inline int operator==(const Fix16& f, const Fix16& g) +{ + return f.m == g.m; +} + +inline int operator!=(const Fix16& f, const Fix16& g) +{ + return f.m != g.m; +} + +inline int operator>=(const Fix16& f, const Fix16& g) +{ + return f.m >= g.m; +} + +inline int operator<=(const Fix16& f, const Fix16& g) +{ + return f.m <= g.m; +} + +inline int operator>(const Fix16& f, const Fix16& g) +{ + return f.m > g.m; +} + +inline int operator<(const Fix16& f, const Fix16& g) +{ + return f.m < g.m; +} + +inline istream& operator>>(istream& s, Fix16& f) +{ + double d; + s >> d; + f = d; + return s; +} + +inline ostream& operator<<(ostream& s, const Fix16& f) +{ + return s << double(f); +} + + +inline Fix16 operator*(const Fix16& f, int g) +{ + return Fix16(short(f.m * g)); +} + +inline Fix16 operator*(int g, const Fix16& f) +{ + return f * g; +} + + +inline Fix16& Fix16::operator*=(int g) +{ + return *this = *this * g; +} + +inline _G_int32_t Fix32::round(double d) +{ + return _G_int32_t( (d >= 0)? d + 0.5 : d - 0.5); +} + +inline _G_int32_t& mantissa(Fix32& f) +{ + return f.m; +} + +inline const _G_int32_t& mantissa(const Fix32& f) +{ + return f.m; +} + +inline double value(const Fix32& f) +{ + return double(f); +} + +inline Fix32 Fix32::operator+() const +{ + return m; +} + +inline Fix32 Fix32::operator-() const +{ + return -m; +} + +inline Fix32 operator+(const Fix32& f, const Fix32& g) +{ + _G_int32_t sum = f.m + g.m; + if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb ) + f.overflow(sum); + return sum; +} + +inline Fix32 operator-(const Fix32& f, const Fix32& g) +{ + _G_int32_t sum = f.m - g.m; + if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb ) + f.overflow(sum); + return sum; +} + +inline Fix32 operator<<(const Fix32& a, int b) +{ + return a.m << b; +} + +inline Fix32 operator>>(const Fix32& a, int b) +{ + return a.m >> b; +} + +inline Fix32& Fix32::operator+=(const Fix32& f) +{ + return *this = *this + f; +} + +inline Fix32& Fix32::operator-=(const Fix32& f) +{ + return *this = *this - f; +} + +inline Fix32& Fix32::operator*=(const Fix32& f) +{ + return *this = *this * f; +} + +inline Fix32& Fix32::operator/=(const Fix32& f) +{ + return *this = *this / f; +} + + +inline Fix32& Fix32::operator<<=(int b) +{ + return *this = *this << b; +} + +inline Fix32& Fix32::operator>>=(int b) +{ + return *this = *this >> b; +} + +inline int operator==(const Fix32& f, const Fix32& g) +{ + return f.m == g.m; +} + +inline int operator!=(const Fix32& f, const Fix32& g) +{ + return f.m != g.m; +} + +inline int operator>=(const Fix32& f, const Fix32& g) +{ + return f.m >= g.m; +} + +inline int operator<=(const Fix32& f, const Fix32& g) +{ + return f.m <= g.m; +} + +inline int operator>(const Fix32& f, const Fix32& g) +{ + return f.m > g.m; +} + +inline int operator<(const Fix32& f, const Fix32& g) +{ + return f.m < g.m; +} + +inline istream& operator>>(istream& s, Fix32& f) +{ + double d; + s >> d; + f = d; + return s; +} + +inline ostream& operator<<(ostream& s, const Fix32& f) +{ + return s << double(f); +} + +inline Fix32 operator*(const Fix32& f, int g) +{ + return Fix32(_G_int32_t(f.m * g)); +} + +inline Fix32 operator*(int g, const Fix32& f) +{ + return f * g; +} + + + +inline Fix32& Fix32::operator*=(int g) +{ + return *this = *this * g; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Fix24.cc b/gnu/lib/libg++/libg++/src/Fix24.cc new file mode 100644 index 00000000000..41878bb7c5e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix24.cc @@ -0,0 +1,329 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) + adapted for libg++ 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. +*/ + +// +// Fix24.cc : fixed precision class support functions +// + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +// basic operators too large to be inline + +_G_int32_t Fix24::assign(double d) +{ + if (d == 1.0) + return Fix24_m_max; + else if (d > Fix24_max) + { + _G_int32_t i = Fix24_m_max; + range_error(i); + return i; + } + else if (d < Fix24_min) + { + _G_int32_t i = Fix24_m_min; + range_error(i); + return i; + } + else { + // Round to 24 bits + d = (_G_int32_t) (d * (1 << 24) + ((d >= 0)? 0.5 : -0.5)); + /* Convert to integer format */ + return ((_G_int32_t) d) << (Fix24_shift - 24); + } +} + +twolongs Fix48::assign(double d) +{ + if (d == 1.0) + return Fix48_m_max; + else if (d > Fix48_max) + { + twolongs i = Fix48_m_max; + range_error(i); + return i; + } + else if (d < Fix48_min) + { + twolongs i = Fix48_m_min; + range_error(i); + return i; + } + else { + twolongs i; + int sign = (d < 0); + +/* First, convert the absolute value of d to a 48-bit integer format */ + if (d < 0) d = -d; + i.u = ((_G_int32_t)(d *= Fix24_mult)) & 0xffffff00; + i.l = ((_G_uint32_t)((d - i.u)* (Fix24_mult / (1 << 7)))) & 0xffffff00; + +/* Calculate the two's complement if d was negative */ + if (sign) { + _G_uint32_t oldlower = i.l; + i.l = (~i.l + 1) & 0xffffff00; + i.u = (~i.u + (((oldlower ^ i.l) & Fix24_msb)? 0 : 1)) & ~0xffL; + } + return i; + } +} + + +Fix48 operator * (const Fix24& a, const Fix24& b) +{ +// break a and b into lo and hi parts, and do a multiple-precision +// multiply, with rounding + + int apos = (a.m >= 0); + _G_uint32_t ua = (apos)? a.m : - a.m; + ua <<= 1; // ua is biased so result will be 47 bit mantissa, not 46: + _G_uint32_t hi_a = (ua >> 16) & ((1 << 16) - 1); + _G_uint32_t lo_a = ua & ((1 << 16) - 1); + + int bpos = (b.m >= 0); + _G_uint32_t ub = (bpos)? b.m : -b.m; + _G_uint32_t hi_b = (ub >> 16) & ((1 << 16) - 1); + _G_uint32_t lo_b = ub & ((1 << 16) - 1); + + _G_uint32_t + hi_r = hi_a * hi_b, + mi_r = hi_a * lo_b + lo_a * hi_b, + lo_r = lo_a * lo_b, + rl = ((hi_r << 16) & 0x00ffffffL) + (mi_r & 0x00ffffffL) + (lo_r >> 16); + twolongs r; + r.u = (hi_r & 0xffffff00L) + ((mi_r >> 16) & 0x0000ff00L) + + ((rl >> 16) & 0x0000ff00L); + r.l = rl << 8; + + if ( apos != bpos ) { + _G_uint32_t l = r.l; + r.l = -r.l; + r.u = (~r.u + ((l ^ r.l) & Fix24_msb ? 0 : Fix24_lsb)) & 0xffffff00; + } + return r; +} + +Fix24 operator / (const Fix24& a, const Fix24& b) +{ + _G_int32_t q; + int apos = (a.m >= 0); + _G_uint32_t la = (apos)? a.m : -a.m; + int bpos = (b.m >= 0); + _G_uint32_t lb = (bpos)? b.m: -b.m; + if (la >= lb) + { + q = (apos == bpos)? Fix24_m_max: Fix24_m_min; + a.range_error(q); + } + else // standard shift-based division alg + { + q = 0; + _G_int32_t r = la; + + for (int i = 32; i > 0; i--) + { + if ((unsigned)(r) > lb) { + q = (q << 1) | 1; + r -= lb; + } + else + q = (q << 1); + r <<= 1; + } + + q += 0x80; // Round result to 24 bits + if (apos != bpos) q = -q; // Fix sign + } + return (q & ~0xff); +} + + +Fix48 operator + (const Fix48& f, const Fix48& g) +{ + _G_int32_t lo_r = (f.m.l >> 8) + (g.m.l >> 8); + twolongs r; + r.u = f.m.u + g.m.u + (lo_r & 0x01000000L ? 0x00000100L : 0); + r.l = lo_r << 8; + + if ( (f.m.u ^ r.u) & (g.m.u ^ r.u) & Fix24_msb ) + f.overflow(r); + return r; +} + +Fix48 operator - (const Fix48& f, const Fix48& g) +{ + unsigned lo_r = (f.m.l >> 8) - (g.m.l >> 8); + twolongs r; + r.u = f.m.u - g.m.u - (lo_r & 0x01000000L ? 0x00000100L: 0); + r.l = lo_r << 8; + + if ( ((f.m.u ^ r.u) & (-g.m.u ^ r.u) & Fix24_msb) && g.m.u ) + f.overflow(r); + return r; +} + +Fix48 operator * (const Fix48& a, int b) +{ + twolongs r; + int bpos = (b >= 0); + unsigned ub = (bpos)? b : -b; + if ( ub >= 65536L ) { + r = (bpos)? Fix48_m_max : Fix48_m_min; + a.range_error(r); + } + else { + _G_uint32_t + lo_r = (a.m.l & 0xffff) * ub, + mi_r = ((a.m.l >> 16) & 0xffff) * ub, + hi_r = a.m.u * ub; + r.l = lo_r + (mi_r << 16); + r.u = hi_r + ((mi_r >> 8) & 0x00ffff00L); + if ( !bpos ) { + _G_uint32_t l = r.l; + r.l = -r.l & 0xffffffff; + r.u = ~r.u + ((l ^ r.l) & Fix24_msb ? 0 : Fix24_lsb); + } + } + return r; +} + +Fix48 operator << (const Fix48& a, int b) +{ + twolongs r; r.u = 0; r.l = 0; + if ( b >= 0 ) + if ( b < 24 ) { + r.u = (a.m.u << b) + ((a.m.l >> (24 - b)) & 0xffffff00L); + r.l = a.m.l << b; + } + else if ( b < 48 ) { + r.u = a.m.l << (b - 24); + } + return r; +} + +Fix48 operator >> (const Fix48& a, int b) +{ + twolongs r; r.u = 0; r.l = 0; + if ( b >= 0 ) + if ( b < 24 ) { + r.l = ((a.m.u << (24 - b)) & 0xffffffffL) + ((a.m.l >> b) & 0xffffff00L); + r.u = (a.m.u >> b) & ~0xffL; + } + else if ( b < 48 ) { + r.l = (a.m.u >> (b - 24)) & 0xffffff00L; + r.u = (a.m.u >> 24) & ~0xffL; + } + else { + r.l = (a.m.u >> 24) & ~0xffL; + r.u = r.l; + } + return r; +} + +// error handling + +void Fix24::overflow(_G_int32_t& i) const +{ + (*Fix24_overflow_handler)(i); +} + +void Fix48::overflow(twolongs& i) const +{ + (*Fix48_overflow_handler)(i); +} + +void Fix24::range_error(_G_int32_t& i) const +{ + (*Fix24_range_error_handler)(i); +} + +void Fix48::range_error(twolongs& i) const +{ + (*Fix48_range_error_handler)(i); +} + +// data definitions + +Fix24_peh Fix24_overflow_handler = Fix24_overflow_saturate; +Fix48_peh Fix48_overflow_handler = Fix48_overflow_saturate; + +Fix24_peh Fix24_range_error_handler = Fix24_warning; +Fix48_peh Fix48_range_error_handler = Fix48_warning; + +//function definitions + +Fix24_peh set_Fix24_overflow_handler(Fix24_peh new_handler) { + Fix24_peh old_handler = Fix24_overflow_handler; + Fix24_overflow_handler = new_handler; + return old_handler; +} + +Fix48_peh set_Fix48_overflow_handler(Fix48_peh new_handler) { + Fix48_peh old_handler = Fix48_overflow_handler; + Fix48_overflow_handler = new_handler; + return old_handler; +} + +void set_overflow_handler(Fix24_peh handler24, Fix48_peh handler48) { + set_Fix24_overflow_handler(handler24); + set_Fix48_overflow_handler(handler48); +} + +Fix24_peh set_Fix24_range_error_handler(Fix24_peh new_handler) { + Fix24_peh old_handler = Fix24_range_error_handler; + Fix24_range_error_handler = new_handler; + return old_handler; +} + +Fix48_peh set_Fix48_range_error_handler(Fix48_peh new_handler) { + Fix48_peh old_handler = Fix48_range_error_handler; + Fix48_range_error_handler = new_handler; + return old_handler; +} + +void set_range_error_handler(Fix24_peh handler24, Fix48_peh handler48) { + set_Fix24_range_error_handler(handler24); + set_Fix48_range_error_handler(handler48); +} + +void Fix24_overflow_saturate(_G_int32_t& i) + { i = (i > 0 ? Fix24_m_min : Fix24_m_max); } +void Fix24_ignore(_G_int32_t&) {} +void Fix24_warning(_G_int32_t&) + { cerr << "warning: Fix24 result out of range\n"; } +void Fix24_overflow_warning_saturate(_G_int32_t& i) + { cerr << "warning: Fix24 result out of range\n"; + Fix24_overflow_saturate(i); } +void Fix24_abort(_G_int32_t&) + { cerr << "error: Fix24 result out of range\n"; abort(); } + +void Fix48_ignore(twolongs&) {} +void Fix48_overflow_saturate(twolongs& i) + { i = (i.u > 0 ? Fix48_m_min : Fix48_m_max); } +void Fix48_warning(twolongs&) + { cerr << "warning: Fix48 result out of range\n"; } +void Fix48_overflow_warning_saturate(twolongs& i) + { cerr << "warning: Fix48 result out of range\n"; + Fix48_overflow_saturate(i); } +void Fix48_abort(twolongs&) + { cerr << "error: Fix48 result out of range\n"; abort(); } + diff --git a/gnu/lib/libg++/libg++/src/Fix24.h b/gnu/lib/libg++/libg++/src/Fix24.h new file mode 100644 index 00000000000..215ded96af0 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Fix24.h @@ -0,0 +1,597 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) + adapted for libg++ 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. +*/ + +#ifndef _Fix24_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Fix24_h 1 + +#include +#include + +// extra type definitions + +typedef struct { + _G_int32_t u; + _G_uint32_t l; +} twolongs; + +// constant definitions + +static const int + Fix24_shift = 31; + +static const double + Fix24_fs = 2147483648., // 2^Fix24_shift + Fix24_mult = Fix24_fs, + Fix24_div = 1./Fix24_fs, + Fix24_max = 1. - .5/Fix24_fs, + Fix24_min = -1.; + +static const _G_uint32_t + Fix24_msb = 0x80000000L, + Fix24_lsb = 0x00000100L, + Fix24_m_max = 0x7fffff00L, + Fix24_m_min = 0x80000000L; + +static const double + Fix48_fs = 36028797018963968., // 2^(24+Fix24_shift) + Fix48_max = 1. - .5/Fix48_fs, + Fix48_min = -1., + Fix48_div_u = 1./Fix24_fs, + Fix48_div_l = 1./Fix48_fs; + +static const twolongs + Fix48_msb = { 0x80000000L, 0L }, + Fix48_lsb = { 0L, 0x00000100L }, + Fix48_m_max = { 0x7fffff00L, 0xffffff00L }, + Fix48_m_min = { 0x80000000L, 0L }; + +// +// Fix24 class: 24-bit Fixed point data type +// +// consists of a 24-bit mantissa (sign bit & 23 data bits). +// + +class Fix24 +{ + friend class Fix48; + + _G_int32_t m; + + _G_int32_t assign(double d); + operator double() const; + Fix24(long i); + Fix24(int i); + + +public: + Fix24(); + Fix24(const Fix24& f); + Fix24(double d); + Fix24(const Fix48& f); + + ~Fix24(); + + Fix24& operator=(const Fix24& f); + Fix24& operator=(double d); + Fix24& operator=(const Fix48& f); + + friend _G_int32_t& mantissa(Fix24& f); + friend const _G_int32_t& mantissa(const Fix24& f); + friend double value(const Fix24& f); + + Fix24 operator + () const; + Fix24 operator - () const; + + friend Fix24 operator + (const Fix24& f, const Fix24& g); + friend Fix24 operator - (const Fix24& f, const Fix24& g); + friend Fix48 operator * (const Fix24& f, const Fix24& g); + friend Fix24 operator * (const Fix24& f, int g); + friend Fix24 operator * (int g, const Fix24& f); + friend Fix24 operator / (const Fix24& f, const Fix24& g); + friend Fix24 operator << (const Fix24& f, int b); + friend Fix24 operator >> (const Fix24& f, int b); + + Fix24& operator += (const Fix24& f); + Fix24& operator -= (const Fix24& f); + Fix24& operator *= (const Fix24& f); + Fix24& operator *= (int b); + Fix24& operator /= (const Fix24& f); + + Fix24& operator <<=(int b); + Fix24& operator >>=(int b); + + friend int operator == (const Fix24& f, const Fix24& g); + friend int operator != (const Fix24& f, const Fix24& g); + friend int operator >= (const Fix24& f, const Fix24& g); + friend int operator <= (const Fix24& f, const Fix24& g); + friend int operator > (const Fix24& f, const Fix24& g); + friend int operator < (const Fix24& f, const Fix24& g); + + friend istream& operator >> (istream& s, Fix24& f); + friend ostream& operator << (ostream& s, const Fix24& f); + + void overflow(_G_int32_t&) const; + void range_error(_G_int32_t&) const; +}; + + +// +// Fix48 class: 48-bit Fixed point data type +// +// consists of a 48-bit mantissa (sign bit & 47 data bits). +// + +class Fix48 +{ + friend class Fix24; + + twolongs m; + + twolongs assign(double d); + operator double() const; + Fix48(twolongs i); + +public: + Fix48(); + Fix48(const Fix48& f); + Fix48(const Fix24& f); + Fix48(double d); + ~Fix48(); + + Fix48& operator = (const Fix48& f); + Fix48& operator = (const Fix24& f); + Fix48& operator = (double d); + + friend twolongs& mantissa(Fix48& f); + friend const twolongs& mantissa(const Fix48& f); + friend double value(const Fix48& f); + + Fix48 operator + () const; + Fix48 operator - () const; + + friend Fix48 operator + (const Fix48& f, const Fix48& g); + friend Fix48 operator - (const Fix48& f, const Fix48& g); + friend Fix48 operator * (const Fix48& f, int g); + friend Fix48 operator * (int g, const Fix48& f); + friend Fix48 operator << (const Fix48& f, int b); + friend Fix48 operator >> (const Fix48& f, int b); + + friend Fix48 operator * (const Fix24& f, const Fix24& g); + + Fix48& operator += (const Fix48& f); + Fix48& operator -= (const Fix48& f); + Fix48& operator *= (int b); + Fix48& operator <<=(int b); + Fix48& operator >>=(int b); + + friend int operator == (const Fix48& f, const Fix48& g); + friend int operator != (const Fix48& f, const Fix48& g); + friend int operator >= (const Fix48& f, const Fix48& g); + friend int operator <= (const Fix48& f, const Fix48& g); + friend int operator > (const Fix48& f, const Fix48& g); + friend int operator < (const Fix48& f, const Fix48& g); + + friend istream& operator >> (istream& s, Fix48& f); + friend ostream& operator << (ostream& s, const Fix48& f); + + void overflow(twolongs& i) const; + void range_error(twolongs& i) const; +}; + + +// active error handler declarations + +typedef void (*Fix24_peh)(_G_int32_t&); +typedef void (*Fix48_peh)(twolongs&); + +extern Fix24_peh Fix24_overflow_handler; +extern Fix48_peh Fix48_overflow_handler; + +extern Fix24_peh Fix24_range_error_handler; +extern Fix48_peh Fix48_range_error_handler; + + +// error handler declarations + +#if defined(SHORT_NAMES) || defined(VMS) +#define set_overflow_handler sohndl +#define set_range_error_handler srnghdl +#endif + +extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh); +extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh); +extern void set_overflow_handler(Fix24_peh, Fix48_peh); + +extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh); +extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh); +extern void set_range_error_handler(Fix24_peh, Fix48_peh); + +extern void + Fix24_ignore(_G_int32_t&), + Fix24_overflow_saturate(_G_int32_t&), + Fix24_overflow_warning_saturate(_G_int32_t&), + Fix24_warning(_G_int32_t&), + Fix24_abort(_G_int32_t&); + +extern void + Fix48_ignore(twolongs&), + Fix48_overflow_saturate(twolongs&), + Fix48_overflow_warning_saturate(twolongs&), + Fix48_warning(twolongs&), + Fix48_abort(twolongs&); + + +inline Fix24::~Fix24() {} + +inline Fix48::~Fix48() {} + +inline Fix24::Fix24(long i) +{ + m = i; +} + +inline Fix24::Fix24(int i) +{ + m = i; +} + +inline Fix24::operator double() const +{ + return Fix24_div * m; +} + +inline Fix24::Fix24() +{ + m = 0; +} + +inline Fix24::Fix24(const Fix24& f) +{ + m = f.m; +} + +inline Fix24::Fix24(double d) +{ + m = assign(d); +} + +inline Fix24::Fix24(const Fix48& f) +{ + m = f.m.u; +} + +inline Fix24& Fix24::operator=(const Fix24& f) +{ + m = f.m; + return *this; +} + +inline Fix24& Fix24::operator=(double d) +{ + m = assign(d); + return *this; +} + +inline Fix24& Fix24::operator=(const Fix48& f) +{ + m = f.m.u; + return *this; +} + +inline _G_int32_t& mantissa(Fix24& f) +{ + return f.m; +} + +inline const _G_int32_t& mantissa(const Fix24& f) +{ + return f.m; +} + +inline double value(const Fix24& f) +{ + return double(f); +} + +inline Fix24 Fix24::operator+() const +{ + return m; +} + +inline Fix24 Fix24::operator-() const +{ + return -m; +} + +inline Fix24 operator+(const Fix24& f, const Fix24& g) +{ + _G_int32_t sum = f.m + g.m; + if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb ) + f.overflow(sum); + return sum; +} + +inline Fix24 operator-(const Fix24& f, const Fix24& g) +{ + _G_int32_t sum = f.m - g.m; + if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb ) + f.overflow(sum); + return sum; +} + +inline Fix24 operator*(const Fix24& a, int b) +{ + return a.m * b; +} + +inline Fix24 operator*(int b, const Fix24& a) +{ + return a * b; +} + +inline Fix24 operator<<(const Fix24& a, int b) +{ + return a.m << b; +} + +inline Fix24 operator>>(const Fix24& a, int b) +{ + return (a.m >> b) & ~0xff; +} + +inline Fix24& Fix24:: operator+=(const Fix24& f) +{ + return *this = *this + f; +} + +inline Fix24& Fix24:: operator-=(const Fix24& f) +{ + return *this = *this - f; +} + +inline Fix24& Fix24::operator*=(const Fix24& f) +{ + return *this = *this * f; +} + +inline Fix24& Fix24:: operator/=(const Fix24& f) +{ + return *this = *this / f; +} + +inline Fix24& Fix24:: operator<<=(int b) +{ + return *this = *this << b; +} + +inline Fix24& Fix24:: operator>>=(int b) +{ + return *this = *this >> b; +} + +inline Fix24& Fix24::operator*=(int b) +{ + return *this = *this * b; +} + +inline int operator==(const Fix24& f, const Fix24& g) +{ + return f.m == g.m; +} + +inline int operator!=(const Fix24& f, const Fix24& g) +{ + return f.m != g.m; +} + +inline int operator>=(const Fix24& f, const Fix24& g) +{ + return f.m >= g.m; +} + +inline int operator<=(const Fix24& f, const Fix24& g) +{ + return f.m <= g.m; +} + +inline int operator>(const Fix24& f, const Fix24& g) +{ + return f.m > g.m; +} + +inline int operator<(const Fix24& f, const Fix24& g) +{ + return f.m < g.m; +} + +inline istream& operator>>(istream& s, Fix24& f) +{ + double d; + s >> d; + f = d; + return s; +} + +inline ostream& operator<<(ostream& s, const Fix24& f) +{ + return s << double(f); +} + +inline Fix48::Fix48(twolongs i) +{ + m = i; +} + +inline Fix48:: operator double() const +{ +/* + * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because + * m.u is signed and m.l is unsigned. + */ + return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l : + (Fix48_div_u * ((_G_uint32_t)(m.u & 0xffffff00)) + + Fix48_div_l * m.l) - 2; +} + +inline Fix48::Fix48() +{ + m.u = 0; + m.l = 0; +} + +inline Fix48::Fix48(const Fix48& f) +{ + m = f.m; +} + +inline Fix48::Fix48(const Fix24& f) +{ + m.u = f.m; + m.l = 0; +} + +inline Fix48::Fix48(double d) +{ + m = assign(d); +} + +inline Fix48& Fix48::operator=(const Fix48& f) +{ + m = f.m; + return *this; +} + +inline Fix48& Fix48::operator=(const Fix24& f) +{ + m.u = f.m; + m.l = 0; + return *this; +} + +inline Fix48& Fix48::operator=(double d) +{ + m = assign(d); + return *this; +} + +inline twolongs& mantissa(Fix48& f) +{ + return f.m; +} + +inline const twolongs& mantissa(const Fix48& f) +{ + return f.m; +} + +inline double value(const Fix48& f) +{ + return double(f); +} + +inline Fix48 Fix48::operator+() const +{ + return m; +} + +inline Fix48 Fix48::operator-() const +{ + twolongs n; + n.l = -m.l; + n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb); + return Fix48(n); +} + +inline Fix48 operator*(int b, const Fix48& a) +{ + return a * b; +} + +inline Fix48& Fix48::operator+=(const Fix48& f) +{ + return *this = *this + f; +} + +inline Fix48& Fix48::operator-=(const Fix48& f) +{ + return *this = *this - f; +} + +inline Fix48& Fix48::operator*=(int b) +{ + return *this = *this * b; +} + +inline Fix48& Fix48::operator<<=(int b) +{ + return *this = *this << b; +} + +inline Fix48& Fix48::operator>>=(int b) +{ + return *this = *this >> b; +} + +inline int operator==(const Fix48& f, const Fix48& g) +{ + return f.m.u == g.m.u && f.m.l == g.m.l; +} + +inline int operator!=(const Fix48& f, const Fix48& g) +{ + return f.m.u != g.m.u || f.m.l != g.m.l; +} + +inline int operator>=(const Fix48& f, const Fix48& g) +{ + return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l); +} + +inline int operator<=(const Fix48& f, const Fix48& g) +{ + return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l); +} + +inline int operator>(const Fix48& f, const Fix48& g) +{ + return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l); +} + +inline int operator<(const Fix48& f, const Fix48& g) +{ + return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l); +} + +inline istream& operator>>(istream& s, Fix48& f) +{ + double d; + s >> d; + f = d; + return s; +} + +inline ostream& operator<<(ostream& s, const Fix48& f) +{ + return s << double(f); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Geom.cc b/gnu/lib/libg++/libg++/src/Geom.cc new file mode 100644 index 00000000000..3e6372e5978 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Geom.cc @@ -0,0 +1,30 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double Geometric::operator()() +{ + int samples; + for (samples = 1; pGenerator -> asDouble() < pMean; samples++); + return((double) samples); +} + diff --git a/gnu/lib/libg++/libg++/src/Geom.h b/gnu/lib/libg++/libg++/src/Geom.h new file mode 100644 index 00000000000..064849ab8e6 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Geom.h @@ -0,0 +1,52 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Geometric_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Geometric_h + +#include + +class Geometric: public Random { +protected: + double pMean; +public: + Geometric(double mean, RNG *gen); + + double mean(); + double mean(double x); + + virtual double operator()(); + +}; + + +inline Geometric::Geometric(double mean, RNG *gen) : Random(gen) +{ + pMean = mean; +} + + +inline double Geometric::mean() { return pMean; } +inline double Geometric::mean(double x) { + double tmp = pMean; pMean = x; return tmp; +} + + +#endif diff --git a/gnu/lib/libg++/libg++/src/GetOpt.cc b/gnu/lib/libg++/libg++/src/GetOpt.cc new file mode 100644 index 00000000000..8dc54a1fe60 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/GetOpt.cc @@ -0,0 +1,253 @@ +/* +Getopt for GNU. +Copyright (C) 1987, 1989 Free Software Foundation, Inc. + +(Modified by Douglas C. Schmidt for use with GNU G++.) +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 +/* AIX requires the alloca decl to be the first thing in the file. */ +#ifdef __GNUC__ +#define alloca __builtin_alloca +#elif defined(sparc) +#include +extern "C" void *__builtin_alloca(...); +#elif defined(_AIX) +#pragma alloca +#else +char *alloca (); +#endif +#include + +char* GetOpt::nextchar = 0; +int GetOpt::first_nonopt = 0; +int GetOpt::last_nonopt = 0; + +GetOpt::GetOpt (int argc, char **argv, const char *optstring) + :opterr (1), nargc (argc), nargv (argv), noptstring (optstring) +{ + /* Initialize the internal data when the first call is made. + 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; + optarg = nextchar = 0; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + ordering = RETURN_IN_ORDER; + else if (getenv ("_POSIX_OPTION_ORDER") != 0) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; +} + +void +GetOpt::exchange (char **argv) +{ + int nonopts_size + = (last_nonopt - first_nonopt) * sizeof (char *); + char **temp = (char **) alloca (nonopts_size); + + /* Interchange the two blocks of data in argv. */ + + memcpy (temp, &argv[first_nonopt], nonopts_size); + memcpy (&argv[first_nonopt], &argv[last_nonopt], + (optind - last_nonopt) * sizeof (char *)); + memcpy (&argv[first_nonopt + optind - last_nonopt], temp, + nonopts_size); + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* 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 theoption 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. + A colon in OPTSTRING means that the previous character is an option + that wants an argument. The argument is taken from the rest of the + current ARGV-element, or from the following ARGV-element, + and returned in `optarg'. + + 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'. + + If OPTSTRING starts with `-', it requests a different method of handling the + non-option ARGV-elements. See the comments about RETURN_IN_ORDER, above. */ + +int +GetOpt::operator () (void) +{ + if (nextchar == 0 || *nextchar == 0) + { + 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 (nargv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < nargc + && (nargv[optind][0] != '-' + || nargv[optind][1] == 0)) + optind++; + last_nonopt = optind; + } + + /* 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 != nargc && !strcmp (nargv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange (nargv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = nargc; + + optind = nargc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == nargc) + { + /* 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 (nargv[optind][0] != '-' || nargv[optind][1] == 0) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = nargv[optind++]; + return 0; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = nargv[optind] + 1; + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + char *temp = (char *) strchr (noptstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == 0) + optind++; + + if (temp == 0 || c == ':') + { + if (opterr != 0) + { + if (c < 040 || c >= 0177) + fprintf (stderr, "%s: unrecognized option, character code 0%o\n", + nargv[0], c); + else + fprintf (stderr, "%s: unrecognized option `-%c'\n", + nargv[0], 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 = 0; + nextchar = 0; + } + 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 == nargc) + { + if (opterr != 0) + fprintf (stderr, "%s: no argument for `-%c' option\n", + nargv[0], c); + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = nargv[optind++]; + nextchar = 0; + } + } + return c; + } +} diff --git a/gnu/lib/libg++/libg++/src/GetOpt.h b/gnu/lib/libg++/libg++/src/GetOpt.h new file mode 100644 index 00000000000..c554cac8321 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/GetOpt.h @@ -0,0 +1,129 @@ +/* Getopt for GNU. + Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. + (Modified by Douglas C. Schmidt for use with GNU G++.) + +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. +*/ + + +/* 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 _POSIX_OPTION_ORDER 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. */ + +#ifndef GetOpt_h +#ifdef __GNUG__ +#pragma interface +#endif +#define GetOpt_h 1 + +#include +#include + +class GetOpt +{ +private: + /* 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; + + + /* Describe how to deal with options that follow non-option ARGV-elements. + + UNSPECIFIED means the caller did not specify anything; + the default is then REQUIRE_ORDER if the environment variable + _OPTIONS_FIRST 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. + + PERMUTE is the default. We permute the contents of `argv' as we scan, + so that eventually all the 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 zero. + Using `-' as the first character of the list of option characters + requests 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. */ + + enum OrderingEnum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; + OrderingEnum ordering; + + /* 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; + + void exchange (char **argv); +public: + /* 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; + + /* 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. */ + + int optind; + + /* Callers store zero here to inhibit the error message + for unrecognized options. */ + + int opterr; + + int nargc; + char **nargv; + const char *noptstring; + + GetOpt (int argc, char **argv, const char *optstring); + int operator () (void); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/HypGeom.cc b/gnu/lib/libg++/libg++/src/HypGeom.cc new file mode 100644 index 00000000000..a283caddbc1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/HypGeom.cc @@ -0,0 +1,30 @@ + +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double HyperGeometric::operator()() +{ + double d = (pGenerator -> asDouble() > pP) ? (1.0 - pP) : (pP); + return(-pMean * log(pGenerator -> asDouble()) / (2.0 * d) ); +} + diff --git a/gnu/lib/libg++/libg++/src/HypGeom.h b/gnu/lib/libg++/libg++/src/HypGeom.h new file mode 100644 index 00000000000..0aeeb7d78ee --- /dev/null +++ b/gnu/lib/libg++/libg++/src/HypGeom.h @@ -0,0 +1,70 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _HyperGeometric_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _HyperGeometric_h + +#include + +class HyperGeometric: public Random { +protected: + double pMean; + double pVariance; + double pP; + void setState(); + +public: + HyperGeometric(double mean, double variance, RNG *gen); + + double mean(); + double mean(double x); + double variance(); + double variance(double x); + + virtual double operator()(); +}; + + +inline void HyperGeometric::setState() { + double z = pVariance / (pMean * pMean); + pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 ))); +} + +inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen) +: Random(gen) { + pMean = mean; pVariance = variance; + setState(); +} + +inline double HyperGeometric::mean() { return pMean; }; + +inline double HyperGeometric::mean(double x) { + double t = pMean; pMean = x; + setState(); return t; +} + +inline double HyperGeometric::variance() { return pVariance; } + +inline double HyperGeometric::variance(double x) { + double t = pVariance; pVariance = x; + setState(); return t; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Incremental.h b/gnu/lib/libg++/libg++/src/Incremental.h new file mode 100644 index 00000000000..267970a8cfb --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Incremental.h @@ -0,0 +1,12 @@ +#ifndef Incremental_h +#ifdef __GNUG__ +#pragma interface +#endif +#define Incremental_h +#define DECLARE_INIT_FUNCTION(USER_INIT_FUNCTION) \ +static void USER_INIT_FUNCTION (); extern void (*_initfn)(); \ +static struct xyzzy { xyzzy () {_initfn = USER_INIT_FUNCTION;}; \ +~xyzzy () {};} __2xyzzy; +#else +#error Incremental.h was not the first file included in this module +#endif diff --git a/gnu/lib/libg++/libg++/src/Intdouble.cc b/gnu/lib/libg++/libg++/src/Intdouble.cc new file mode 100644 index 00000000000..065175b967a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Intdouble.cc @@ -0,0 +1,142 @@ +/* +Copyright (C) 1988, 1993 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. +*/ + +// Routines for converting between Integers and doubles. +// Split up into a separate file to avoid Integer.o's need +// for libm.a on some systems (including SunOS 4). + +#include +#include "Integer.hP" +#include +#include +#include + +#ifndef HUGE_VAL +#ifdef HUGE +#define HUGE_VAL HUGE +#else +#define HUGE_VAL DBL_MAX +#endif +#endif + +// convert to a double + +double Itodouble(const IntRep* rep) +{ + double d = 0.0; + double bound = DBL_MAX / 2.0; + for (int i = rep->len - 1; i >= 0; --i) + { + unsigned short a = I_RADIX >> 1; + while (a != 0) + { + if (d >= bound) + return (rep->sgn == I_NEGATIVE) ? -HUGE_VAL : HUGE_VAL; + d *= 2.0; + if (rep->s[i] & a) + d += 1.0; + a >>= 1; + } + } + if (rep->sgn == I_NEGATIVE) + return -d; + else + return d; +} + +// see whether op double() will work- +// have to actually try it in order to find out +// since otherwise might trigger fp exception + +int Iisdouble(const IntRep* rep) +{ + double d = 0.0; + double bound = DBL_MAX / 2.0; + for (int i = rep->len - 1; i >= 0; --i) + { + unsigned short a = I_RADIX >> 1; + while (a != 0) + { + if (d > bound || (d == bound && (i > 0 || (rep->s[i] & a)))) + return 0; + d *= 2.0; + if (rep->s[i] & a) + d += 1.0; + a >>= 1; + } + } + return 1; +} + +// real division of num / den + +double ratio(const Integer& num, const Integer& den) +{ + Integer q, r; + divide(num, den, q, r); + double d1 = q.as_double(); + + if (d1 >= DBL_MAX || d1 <= -DBL_MAX || sign(r) == 0) + return d1; + else // use as much precision as available for fractional part + { + double d2 = 0.0; + double d3 = 0.0; + int cont = 1; + for (int i = den.rep->len - 1; i >= 0 && cont; --i) + { + unsigned short a = I_RADIX >> 1; + while (a != 0) + { + if (d2 + 1.0 == d2) // out of precision when we get here + { + cont = 0; + break; + } + + d2 *= 2.0; + if (den.rep->s[i] & a) + d2 += 1.0; + + if (i < r.rep->len) + { + d3 *= 2.0; + if (r.rep->s[i] & a) + d3 += 1.0; + } + + a >>= 1; + } + } + + if (sign(r) < 0) + d3 = -d3; + return d1 + d3 / d2; + } +} + +double +Integer::as_double () const +{ + return Itodouble (rep); +} + +int +Integer::fits_in_double () const +{ + return Iisdouble(rep); +} diff --git a/gnu/lib/libg++/libg++/src/Integer.cc b/gnu/lib/libg++/libg++/src/Integer.cc new file mode 100644 index 00000000000..926b28ace68 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Integer.cc @@ -0,0 +1,2282 @@ +/* +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. +*/ + +/* + Some of the following algorithms are very loosely based on those from + MIT C-Scheme bignum.c, which is + Copyright (c) 1987 Massachusetts Institute of Technology + + with other guidance from Knuth, vol. 2 + + Thanks to the creators of the algorithms. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "Integer.hP" + +#undef OK + +IntRep _ZeroRep = {1, 0, 1, {0}}; +IntRep _OneRep = {1, 0, 1, {1}}; +IntRep _MinusOneRep = {1, 0, 0, {1}}; + + +// utilities to extract and transfer bits + +// get low bits + +inline static unsigned short extract(unsigned long x) +{ + return x & I_MAXNUM; +} + +// transfer high bits to low + +inline static unsigned long down(unsigned long x) +{ + return (x >> I_SHIFT) & I_MAXNUM; +} + +// transfer low bits to high + +inline static unsigned long up(unsigned long x) +{ + return x << I_SHIFT; +} + +// compare two equal-length reps + +inline static int docmp(const unsigned short* x, const unsigned short* y, int l) +{ + int diff = 0; + const unsigned short* xs = &(x[l]); + const unsigned short* ys = &(y[l]); + while (l-- > 0 && (diff = (*--xs) - (*--ys)) == 0); + return diff; +} + +// figure out max length of result of +, -, etc. + +inline static int calc_len(int len1, int len2, int pad) +{ + return (len1 >= len2)? len1 + pad : len2 + pad; +} + +// ensure len & sgn are correct + +inline static void Icheck(IntRep* rep) +{ + int l = rep->len; + const unsigned short* p = &(rep->s[l]); + while (l > 0 && *--p == 0) --l; + if ((rep->len = l) == 0) rep->sgn = I_POSITIVE; +} + + +// zero out the end of a rep + +inline static void Iclear_from(IntRep* rep, int p) +{ + unsigned short* cp = &(rep->s[p]); + const unsigned short* cf = &(rep->s[rep->len]); + while(cp < cf) *cp++ = 0; +} + +// copy parts of a rep + +static inline void scpy(const unsigned short* src, unsigned short* dest,int nb) +{ + while (--nb >= 0) *dest++ = *src++; +} + +// make sure an argument is valid + +static inline void nonnil(const IntRep* rep) +{ + if (rep == 0) + (*lib_error_handler)("Integer", "operation on uninitialized Integer"); +} + +// allocate a new Irep. Pad to something close to a power of two. + +inline static IntRep* Inew(int newlen) +{ + unsigned int siz = sizeof(IntRep) + newlen * sizeof(short) + + MALLOC_MIN_OVERHEAD; + unsigned int allocsiz = MINIntRep_SIZE; + while (allocsiz < siz) allocsiz <<= 1; // find a power of 2 + allocsiz -= MALLOC_MIN_OVERHEAD; + if (allocsiz >= MAXIntRep_SIZE * sizeof(short)) + (*lib_error_handler)("Integer", "Requested length out of range"); + + IntRep* rep = new (operator new (allocsiz)) IntRep; + rep->sz = (allocsiz - sizeof(IntRep) + sizeof(short)) / sizeof(short); + return rep; +} + +// allocate: use the bits in src if non-null, clear the rest + +IntRep* Ialloc(IntRep* old, const unsigned short* src, int srclen, int newsgn, + int newlen) +{ + IntRep* rep; + if (old == 0 || newlen > old->sz) + rep = Inew(newlen); + else + rep = old; + + rep->len = newlen; + rep->sgn = newsgn; + + scpy(src, rep->s, srclen); + Iclear_from(rep, srclen); + + if (old != rep && old != 0 && !STATIC_IntRep(old)) delete old; + return rep; +} + +// allocate and clear + +IntRep* Icalloc(IntRep* old, int newlen) +{ + IntRep* rep; + if (old == 0 || newlen > old->sz) + { + if (old != 0 && !STATIC_IntRep(old)) delete old; + rep = Inew(newlen); + } + else + rep = old; + + rep->len = newlen; + rep->sgn = I_POSITIVE; + Iclear_from(rep, 0); + + return rep; +} + +// reallocate + +IntRep* Iresize(IntRep* old, int newlen) +{ + IntRep* rep; + unsigned short oldlen; + if (old == 0) + { + oldlen = 0; + rep = Inew(newlen); + rep->sgn = I_POSITIVE; + } + else + { + oldlen = old->len; + if (newlen > old->sz) + { + rep = Inew(newlen); + scpy(old->s, rep->s, oldlen); + rep->sgn = old->sgn; + if (!STATIC_IntRep(old)) delete old; + } + else + rep = old; + } + + rep->len = newlen; + Iclear_from(rep, oldlen); + + return rep; +} + + +// same, for straight copy + +IntRep* Icopy(IntRep* old, const IntRep* src) +{ + if (old == src) return old; + IntRep* rep; + if (src == 0) + { + if (old == 0) + rep = Inew(0); + else + { + rep = old; + Iclear_from(rep, 0); + } + rep->len = 0; + rep->sgn = I_POSITIVE; + } + else + { + int newlen = src->len; + if (old == 0 || newlen > old->sz) + { + if (old != 0 && !STATIC_IntRep(old)) delete old; + rep = Inew(newlen); + } + else + rep = old; + + rep->len = newlen; + rep->sgn = src->sgn; + + scpy(src->s, rep->s, newlen); + } + + return rep; +} + +// allocate & copy space for a long + +IntRep* Icopy_long(IntRep* old, long x) +{ + int newsgn = (x >= 0); + IntRep* rep = Icopy_ulong(old, newsgn ? x : -x); + rep->sgn = newsgn; + return rep; +} + +IntRep* Icopy_ulong(IntRep* old, unsigned long x) +{ + unsigned short src[SHORT_PER_LONG]; + + unsigned short srclen = 0; + while (x != 0) + { + src[srclen++] = extract(x); + x = down(x); + } + + IntRep* rep; + if (old == 0 || srclen > old->sz) + { + if (old != 0 && !STATIC_IntRep(old)) delete old; + rep = Inew(srclen); + } + else + rep = old; + + rep->len = srclen; + rep->sgn = I_POSITIVE; + + scpy(src, rep->s, srclen); + + return rep; +} + +// special case for zero -- it's worth it! + +IntRep* Icopy_zero(IntRep* old) +{ + if (old == 0 || STATIC_IntRep(old)) + return &_ZeroRep; + + old->len = 0; + old->sgn = I_POSITIVE; + + return old; +} + +// special case for 1 or -1 + +IntRep* Icopy_one(IntRep* old, int newsgn) +{ + if (old == 0 || 1 > old->sz) + { + if (old != 0 && !STATIC_IntRep(old)) delete old; + return newsgn==I_NEGATIVE ? &_MinusOneRep : &_OneRep; + } + + old->sgn = newsgn; + old->len = 1; + old->s[0] = 1; + + return old; +} + +// convert to a legal two's complement long if possible +// if too big, return most negative/positive value + +long Itolong(const IntRep* rep) +{ + if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG)) + return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN; + else if (rep->len == 0) + return 0; + else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG)) + { + unsigned long a = rep->s[rep->len-1]; + if (SHORT_PER_LONG > 2) // normally optimized out + { + for (int i = rep->len - 2; i >= 0; --i) + a = up(a) | rep->s[i]; + } + return (rep->sgn == I_POSITIVE)? a : -((long)a); + } + else + { + unsigned long a = rep->s[SHORT_PER_LONG - 1]; + if (a >= I_MINNUM) + return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN; + else + { + a = up(a) | rep->s[SHORT_PER_LONG - 2]; + if (SHORT_PER_LONG > 2) + { + for (int i = SHORT_PER_LONG - 3; i >= 0; --i) + a = up(a) | rep->s[i]; + } + return (rep->sgn == I_POSITIVE)? a : -((long)a); + } + } +} + +// test whether op long() will work. +// careful about asymmetry between LONG_MIN & LONG_MAX + +int Iislong(const IntRep* rep) +{ + unsigned int l = rep->len; + if (l < SHORT_PER_LONG) + return 1; + else if (l > SHORT_PER_LONG) + return 0; + else if ((unsigned)(rep->s[SHORT_PER_LONG - 1]) < (unsigned)(I_MINNUM)) + return 1; + else if (rep->sgn == I_NEGATIVE && rep->s[SHORT_PER_LONG - 1] == I_MINNUM) + { + for (unsigned int i = 0; i < SHORT_PER_LONG - 1; ++i) + if (rep->s[i] != 0) + return 0; + return 1; + } + else + return 0; +} + +// comparison functions + +int compare(const IntRep* x, const IntRep* y) +{ + int diff = x->sgn - y->sgn; + if (diff == 0) + { + diff = x->len - y->len; + if (diff == 0) + diff = docmp(x->s, y->s, x->len); + if (x->sgn == I_NEGATIVE) + diff = -diff; + } + return diff; +} + +int ucompare(const IntRep* x, const IntRep* y) +{ + int diff = x->len - y->len; + if (diff == 0) + { + int l = x->len; + const unsigned short* xs = &(x->s[l]); + const unsigned short* ys = &(y->s[l]); + while (l-- > 0 && (diff = (*--xs) - (*--ys)) == 0); + } + return diff; +} + +int compare(const IntRep* x, long y) +{ + int xl = x->len; + int xsgn = x->sgn; + if (y == 0) + { + if (xl == 0) + return 0; + else if (xsgn == I_NEGATIVE) + return -1; + else + return 1; + } + else + { + int ysgn = y >= 0; + unsigned long uy = (ysgn)? y : -y; + int diff = xsgn - ysgn; + if (diff == 0) + { + diff = xl - SHORT_PER_LONG; + if (diff <= 0) + { + unsigned short tmp[SHORT_PER_LONG]; + int yl = 0; + while (uy != 0) + { + tmp[yl++] = extract(uy); + uy = down(uy); + } + diff = xl - yl; + if (diff == 0) + diff = docmp(x->s, tmp, xl); + } + if (xsgn == I_NEGATIVE) + diff = -diff; + } + return diff; + } +} + +int ucompare(const IntRep* x, long y) +{ + int xl = x->len; + if (y == 0) + return xl; + else + { + unsigned long uy = (y >= 0)? y : -y; + int diff = xl - SHORT_PER_LONG; + if (diff <= 0) + { + unsigned short tmp[SHORT_PER_LONG]; + int yl = 0; + while (uy != 0) + { + tmp[yl++] = extract(uy); + uy = down(uy); + } + diff = xl - yl; + if (diff == 0) + diff = docmp(x->s, tmp, xl); + } + return diff; + } +} + + + +// arithmetic functions + +IntRep* add(const IntRep* x, int negatex, + const IntRep* y, int negatey, IntRep* r) +{ + nonnil(x); + nonnil(y); + + int xl = x->len; + int yl = y->len; + + int xsgn = (negatex && xl != 0) ? !x->sgn : x->sgn; + int ysgn = (negatey && yl != 0) ? !y->sgn : y->sgn; + + int xrsame = x == r; + int yrsame = y == r; + + if (yl == 0) + r = Ialloc(r, x->s, xl, xsgn, xl); + else if (xl == 0) + r = Ialloc(r, y->s, yl, ysgn, yl); + else if (xsgn == ysgn) + { + if (xrsame || yrsame) + r = Iresize(r, calc_len(xl, yl, 1)); + else + r = Icalloc(r, calc_len(xl, yl, 1)); + r->sgn = xsgn; + unsigned short* rs = r->s; + const unsigned short* as; + const unsigned short* bs; + const unsigned short* topa; + const unsigned short* topb; + if (xl >= yl) + { + as = (xrsame)? r->s : x->s; + topa = &(as[xl]); + bs = (yrsame)? r->s : y->s; + topb = &(bs[yl]); + } + else + { + bs = (xrsame)? r->s : x->s; + topb = &(bs[xl]); + as = (yrsame)? r->s : y->s; + topa = &(as[yl]); + } + unsigned long sum = 0; + while (bs < topb) + { + sum += (unsigned long)(*as++) + (unsigned long)(*bs++); + *rs++ = extract(sum); + sum = down(sum); + } + while (sum != 0 && as < topa) + { + sum += (unsigned long)(*as++); + *rs++ = extract(sum); + sum = down(sum); + } + if (sum != 0) + *rs = extract(sum); + else if (rs != as) + while (as < topa) + *rs++ = *as++; + } + else + { + int comp = ucompare(x, y); + if (comp == 0) + r = Icopy_zero(r); + else + { + if (xrsame || yrsame) + r = Iresize(r, calc_len(xl, yl, 0)); + else + r = Icalloc(r, calc_len(xl, yl, 0)); + unsigned short* rs = r->s; + const unsigned short* as; + const unsigned short* bs; + const unsigned short* topa; + const unsigned short* topb; + if (comp > 0) + { + as = (xrsame)? r->s : x->s; + topa = &(as[xl]); + bs = (yrsame)? r->s : y->s; + topb = &(bs[yl]); + r->sgn = xsgn; + } + else + { + bs = (xrsame)? r->s : x->s; + topb = &(bs[xl]); + as = (yrsame)? r->s : y->s; + topa = &(as[yl]); + r->sgn = ysgn; + } + unsigned long hi = 1; + while (bs < topb) + { + hi += (unsigned long)(*as++) + I_MAXNUM - (unsigned long)(*bs++); + *rs++ = extract(hi); + hi = down(hi); + } + while (hi == 0 && as < topa) + { + hi = (unsigned long)(*as++) + I_MAXNUM; + *rs++ = extract(hi); + hi = down(hi); + } + if (rs != as) + while (as < topa) + *rs++ = *as++; + } + } + Icheck(r); + return r; +} + + +IntRep* add(const IntRep* x, int negatex, long y, IntRep* r) +{ + nonnil(x); + int xl = x->len; + int xsgn = (negatex && xl != 0) ? !x->sgn : x->sgn; + int xrsame = x == r; + + int ysgn = (y >= 0); + unsigned long uy = (ysgn)? y : -y; + + if (y == 0) + r = Ialloc(r, x->s, xl, xsgn, xl); + else if (xl == 0) + r = Icopy_long(r, y); + else if (xsgn == ysgn) + { + if (xrsame) + r = Iresize(r, calc_len(xl, SHORT_PER_LONG, 1)); + else + r = Icalloc(r, calc_len(xl, SHORT_PER_LONG, 1)); + r->sgn = xsgn; + unsigned short* rs = r->s; + const unsigned short* as = (xrsame)? r->s : x->s; + const unsigned short* topa = &(as[xl]); + unsigned long sum = 0; + while (as < topa && uy != 0) + { + unsigned long u = extract(uy); + uy = down(uy); + sum += (unsigned long)(*as++) + u; + *rs++ = extract(sum); + sum = down(sum); + } + while (sum != 0 && as < topa) + { + sum += (unsigned long)(*as++); + *rs++ = extract(sum); + sum = down(sum); + } + if (sum != 0) + *rs = extract(sum); + else if (rs != as) + while (as < topa) + *rs++ = *as++; + } + else + { + unsigned short tmp[SHORT_PER_LONG]; + int yl = 0; + while (uy != 0) + { + tmp[yl++] = extract(uy); + uy = down(uy); + } + int comp = xl - yl; + if (comp == 0) + comp = docmp(x->s, tmp, yl); + if (comp == 0) + r = Icopy_zero(r); + else + { + if (xrsame) + r = Iresize(r, calc_len(xl, yl, 0)); + else + r = Icalloc(r, calc_len(xl, yl, 0)); + unsigned short* rs = r->s; + const unsigned short* as; + const unsigned short* bs; + const unsigned short* topa; + const unsigned short* topb; + if (comp > 0) + { + as = (xrsame)? r->s : x->s; + topa = &(as[xl]); + bs = tmp; + topb = &(bs[yl]); + r->sgn = xsgn; + } + else + { + bs = (xrsame)? r->s : x->s; + topb = &(bs[xl]); + as = tmp; + topa = &(as[yl]); + r->sgn = ysgn; + } + unsigned long hi = 1; + while (bs < topb) + { + hi += (unsigned long)(*as++) + I_MAXNUM - (unsigned long)(*bs++); + *rs++ = extract(hi); + hi = down(hi); + } + while (hi == 0 && as < topa) + { + hi = (unsigned long)(*as++) + I_MAXNUM; + *rs++ = extract(hi); + hi = down(hi); + } + if (rs != as) + while (as < topa) + *rs++ = *as++; + } + } + Icheck(r); + return r; +} + + +IntRep* multiply(const IntRep* x, const IntRep* y, IntRep* r) +{ + nonnil(x); + nonnil(y); + int xl = x->len; + int yl = y->len; + int rl = xl + yl; + int rsgn = x->sgn == y->sgn; + int xrsame = x == r; + int yrsame = y == r; + int xysame = x == y; + + if (xl == 0 || yl == 0) + r = Icopy_zero(r); + else if (xl == 1 && x->s[0] == 1) + r = Icopy(r, y); + else if (yl == 1 && y->s[0] == 1) + r = Icopy(r, x); + else if (!(xysame && xrsame)) + { + if (xrsame || yrsame) + r = Iresize(r, rl); + else + r = Icalloc(r, rl); + unsigned short* rs = r->s; + unsigned short* topr = &(rs[rl]); + + // use best inner/outer loop params given constraints + unsigned short* currentr; + const unsigned short* bota; + const unsigned short* as; + const unsigned short* botb; + const unsigned short* topb; + if (xrsame) + { + currentr = &(rs[xl-1]); + bota = rs; + as = currentr; + botb = y->s; + topb = &(botb[yl]); + } + else if (yrsame) + { + currentr = &(rs[yl-1]); + bota = rs; + as = currentr; + botb = x->s; + topb = &(botb[xl]); + } + else if (xl <= yl) + { + currentr = &(rs[xl-1]); + bota = x->s; + as = &(bota[xl-1]); + botb = y->s; + topb = &(botb[yl]); + } + else + { + currentr = &(rs[yl-1]); + bota = y->s; + as = &(bota[yl-1]); + botb = x->s; + topb = &(botb[xl]); + } + + while (as >= bota) + { + unsigned long ai = (unsigned long)(*as--); + unsigned short* rs = currentr--; + *rs = 0; + if (ai != 0) + { + unsigned long sum = 0; + const unsigned short* bs = botb; + while (bs < topb) + { + sum += ai * (unsigned long)(*bs++) + (unsigned long)(*rs); + *rs++ = extract(sum); + sum = down(sum); + } + while (sum != 0 && rs < topr) + { + sum += (unsigned long)(*rs); + *rs++ = extract(sum); + sum = down(sum); + } + } + } + } + else // x, y, and r same; compute over diagonals + { + r = Iresize(r, rl); + unsigned short* botr = r->s; + unsigned short* topr = &(botr[rl]); + unsigned short* rs = &(botr[rl - 2]); + + const unsigned short* bota = (xrsame)? botr : x->s; + const unsigned short* loa = &(bota[xl - 1]); + const unsigned short* hia = loa; + + for (; rs >= botr; --rs) + { + const unsigned short* h = hia; + const unsigned short* l = loa; + unsigned long prod = (unsigned long)(*h) * (unsigned long)(*l); + *rs = 0; + + for(;;) + { + unsigned short* rt = rs; + unsigned long sum = prod + (unsigned long)(*rt); + *rt++ = extract(sum); + sum = down(sum); + while (sum != 0 && rt < topr) + { + sum += (unsigned long)(*rt); + *rt++ = extract(sum); + sum = down(sum); + } + if (h > l) + { + rt = rs; + sum = prod + (unsigned long)(*rt); + *rt++ = extract(sum); + sum = down(sum); + while (sum != 0 && rt < topr) + { + sum += (unsigned long)(*rt); + *rt++ = extract(sum); + sum = down(sum); + } + if (--h >= ++l) + prod = (unsigned long)(*h) * (unsigned long)(*l); + else + break; + } + else + break; + } + if (loa > bota) + --loa; + else + --hia; + } + } + r->sgn = rsgn; + Icheck(r); + return r; +} + + +IntRep* multiply(const IntRep* x, long y, IntRep* r) +{ + nonnil(x); + int xl = x->len; + + if (xl == 0 || y == 0) + r = Icopy_zero(r); + else if (y == 1) + r = Icopy(r, x); + else + { + int ysgn = y >= 0; + int rsgn = x->sgn == ysgn; + unsigned long uy = (ysgn)? y : -y; + unsigned short tmp[SHORT_PER_LONG]; + int yl = 0; + while (uy != 0) + { + tmp[yl++] = extract(uy); + uy = down(uy); + } + + int rl = xl + yl; + int xrsame = x == r; + if (xrsame) + r = Iresize(r, rl); + else + r = Icalloc(r, rl); + + unsigned short* rs = r->s; + unsigned short* topr = &(rs[rl]); + unsigned short* currentr; + const unsigned short* bota; + const unsigned short* as; + const unsigned short* botb; + const unsigned short* topb; + + if (xrsame) + { + currentr = &(rs[xl-1]); + bota = rs; + as = currentr; + botb = tmp; + topb = &(botb[yl]); + } + else if (xl <= yl) + { + currentr = &(rs[xl-1]); + bota = x->s; + as = &(bota[xl-1]); + botb = tmp; + topb = &(botb[yl]); + } + else + { + currentr = &(rs[yl-1]); + bota = tmp; + as = &(bota[yl-1]); + botb = x->s; + topb = &(botb[xl]); + } + + while (as >= bota) + { + unsigned long ai = (unsigned long)(*as--); + unsigned short* rs = currentr--; + *rs = 0; + if (ai != 0) + { + unsigned long sum = 0; + const unsigned short* bs = botb; + while (bs < topb) + { + sum += ai * (unsigned long)(*bs++) + (unsigned long)(*rs); + *rs++ = extract(sum); + sum = down(sum); + } + while (sum != 0 && rs < topr) + { + sum += (unsigned long)(*rs); + *rs++ = extract(sum); + sum = down(sum); + } + } + } + r->sgn = rsgn; + } + Icheck(r); + return r; +} + + +// main division routine + +static void do_divide(unsigned short* rs, + const unsigned short* ys, int yl, + unsigned short* qs, int ql) +{ + const unsigned short* topy = &(ys[yl]); + unsigned short d1 = ys[yl - 1]; + unsigned short d2 = ys[yl - 2]; + + int l = ql - 1; + int i = l + yl; + + for (; l >= 0; --l, --i) + { + unsigned short qhat; // guess q + if (d1 == rs[i]) + qhat = I_MAXNUM; + else + { + unsigned long lr = up((unsigned long)rs[i]) | rs[i-1]; + qhat = lr / d1; + } + + for(;;) // adjust q, use docmp to avoid overflow problems + { + unsigned short ts[3]; + unsigned long prod = (unsigned long)d2 * (unsigned long)qhat; + ts[0] = extract(prod); + prod = down(prod) + (unsigned long)d1 * (unsigned long)qhat; + ts[1] = extract(prod); + ts[2] = extract(down(prod)); + if (docmp(ts, &(rs[i-2]), 3) > 0) + --qhat; + else + break; + }; + + // multiply & subtract + + const unsigned short* yt = ys; + unsigned short* rt = &(rs[l]); + unsigned long prod = 0; + unsigned long hi = 1; + while (yt < topy) + { + prod = (unsigned long)qhat * (unsigned long)(*yt++) + down(prod); + hi += (unsigned long)(*rt) + I_MAXNUM - (unsigned long)(extract(prod)); + *rt++ = extract(hi); + hi = down(hi); + } + hi += (unsigned long)(*rt) + I_MAXNUM - (unsigned long)(down(prod)); + *rt = extract(hi); + hi = down(hi); + + // off-by-one, add back + + if (hi == 0) + { + --qhat; + yt = ys; + rt = &(rs[l]); + hi = 0; + while (yt < topy) + { + hi = (unsigned long)(*rt) + (unsigned long)(*yt++) + down(hi); + *rt++ = extract(hi); + } + *rt = 0; + } + if (qs != 0) + qs[l] = qhat; + } +} + +// divide by single digit, return remainder +// if q != 0, then keep the result in q, else just compute rem + +static int unscale(const unsigned short* x, int xl, unsigned short y, + unsigned short* q) +{ + if (xl == 0 || y == 1) + return 0; + else if (q != 0) + { + unsigned short* botq = q; + unsigned short* qs = &(botq[xl - 1]); + const unsigned short* xs = &(x[xl - 1]); + unsigned long rem = 0; + while (qs >= botq) + { + rem = up(rem) | *xs--; + unsigned long u = rem / y; + *qs-- = extract(u); + rem -= u * y; + } + int r = extract(rem); + return r; + } + else // same loop, a bit faster if just need rem + { + const unsigned short* botx = x; + const unsigned short* xs = &(botx[xl - 1]); + unsigned long rem = 0; + while (xs >= botx) + { + rem = up(rem) | *xs--; + unsigned long u = rem / y; + rem -= u * y; + } + int r = extract(rem); + return r; + } +} + + +IntRep* div(const IntRep* x, const IntRep* y, IntRep* q) +{ + nonnil(x); + nonnil(y); + int xl = x->len; + int yl = y->len; + if (yl == 0) (*lib_error_handler)("Integer", "attempted division by zero"); + + int comp = ucompare(x, y); + int xsgn = x->sgn; + int ysgn = y->sgn; + + int samesign = xsgn == ysgn; + + if (comp < 0) + q = Icopy_zero(q); + else if (comp == 0) + q = Icopy_one(q, samesign); + else if (yl == 1) + { + q = Icopy(q, x); + unscale(q->s, q->len, y->s[0], q->s); + } + else + { + IntRep* yy = 0; + IntRep* r = 0; + unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1])); + if (prescale != 1 || y == q) + { + yy = multiply(y, ((long)prescale & I_MAXNUM), yy); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + yy = (IntRep*)y; + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + int ql = xl - yl + 1; + + q = Icalloc(q, ql); + do_divide(r->s, yy->s, yl, q->s, ql); + + if (yy != y && !STATIC_IntRep(yy)) delete yy; + if (!STATIC_IntRep(r)) delete r; + } + q->sgn = samesign; + Icheck(q); + return q; +} + +IntRep* div(const IntRep* x, long y, IntRep* q) +{ + nonnil(x); + int xl = x->len; + if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero"); + + unsigned short ys[SHORT_PER_LONG]; + unsigned long u; + int ysgn = y >= 0; + if (ysgn) + u = y; + else + u = -y; + int yl = 0; + while (u != 0) + { + ys[yl++] = extract(u); + u = down(u); + } + + int comp = xl - yl; + if (comp == 0) comp = docmp(x->s, ys, xl); + + int xsgn = x->sgn; + int samesign = xsgn == ysgn; + + if (comp < 0) + q = Icopy_zero(q); + else if (comp == 0) + { + q = Icopy_one(q, samesign); + } + else if (yl == 1) + { + q = Icopy(q, x); + unscale(q->s, q->len, ys[0], q->s); + } + else + { + IntRep* r = 0; + unsigned short prescale = (I_RADIX / (1 + ys[yl - 1])); + if (prescale != 1) + { + unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0]; + ys[0] = extract(prod); + prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1]; + ys[1] = extract(prod); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + int ql = xl - yl + 1; + + q = Icalloc(q, ql); + do_divide(r->s, ys, yl, q->s, ql); + + if (!STATIC_IntRep(r)) delete r; + } + q->sgn = samesign; + Icheck(q); + return q; +} + + +void divide(const Integer& Ix, long y, Integer& Iq, long& rem) +{ + const IntRep* x = Ix.rep; + nonnil(x); + IntRep* q = Iq.rep; + int xl = x->len; + if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero"); + + unsigned short ys[SHORT_PER_LONG]; + unsigned long u; + int ysgn = y >= 0; + if (ysgn) + u = y; + else + u = -y; + int yl = 0; + while (u != 0) + { + ys[yl++] = extract(u); + u = down(u); + } + + int comp = xl - yl; + if (comp == 0) comp = docmp(x->s, ys, xl); + + int xsgn = x->sgn; + int samesign = xsgn == ysgn; + + if (comp < 0) + { + rem = Itolong(x); + q = Icopy_zero(q); + } + else if (comp == 0) + { + q = Icopy_one(q, samesign); + rem = 0; + } + else if (yl == 1) + { + q = Icopy(q, x); + rem = unscale(q->s, q->len, ys[0], q->s); + } + else + { + IntRep* r = 0; + unsigned short prescale = (I_RADIX / (1 + ys[yl - 1])); + if (prescale != 1) + { + unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0]; + ys[0] = extract(prod); + prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1]; + ys[1] = extract(prod); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + int ql = xl - yl + 1; + + q = Icalloc(q, ql); + + do_divide(r->s, ys, yl, q->s, ql); + + if (prescale != 1) + { + Icheck(r); + unscale(r->s, r->len, prescale, r->s); + } + Icheck(r); + rem = Itolong(r); + if (!STATIC_IntRep(r)) delete r; + } + rem = abs(rem); + if (xsgn == I_NEGATIVE) rem = -rem; + q->sgn = samesign; + Icheck(q); + Iq.rep = q; +} + + +void divide(const Integer& Ix, const Integer& Iy, Integer& Iq, Integer& Ir) +{ + const IntRep* x = Ix.rep; + nonnil(x); + const IntRep* y = Iy.rep; + nonnil(y); + IntRep* q = Iq.rep; + IntRep* r = Ir.rep; + + int xl = x->len; + int yl = y->len; + if (yl == 0) + (*lib_error_handler)("Integer", "attempted division by zero"); + + int comp = ucompare(x, y); + int xsgn = x->sgn; + int ysgn = y->sgn; + + int samesign = xsgn == ysgn; + + if (comp < 0) + { + q = Icopy_zero(q); + r = Icopy(r, x); + } + else if (comp == 0) + { + q = Icopy_one(q, samesign); + r = Icopy_zero(r); + } + else if (yl == 1) + { + q = Icopy(q, x); + int rem = unscale(q->s, q->len, y->s[0], q->s); + r = Icopy_long(r, rem); + if (rem != 0) + r->sgn = xsgn; + } + else + { + IntRep* yy = 0; + unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1])); + if (prescale != 1 || y == q || y == r) + { + yy = multiply(y, ((long)prescale & I_MAXNUM), yy); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + yy = (IntRep*)y; + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + int ql = xl - yl + 1; + + q = Icalloc(q, ql); + do_divide(r->s, yy->s, yl, q->s, ql); + + if (yy != y && !STATIC_IntRep(yy)) delete yy; + if (prescale != 1) + { + Icheck(r); + unscale(r->s, r->len, prescale, r->s); + } + } + q->sgn = samesign; + Icheck(q); + Iq.rep = q; + Icheck(r); + Ir.rep = r; +} + +IntRep* mod(const IntRep* x, const IntRep* y, IntRep* r) +{ + nonnil(x); + nonnil(y); + int xl = x->len; + int yl = y->len; + if (yl == 0) (*lib_error_handler)("Integer", "attempted division by zero"); + + int comp = ucompare(x, y); + int xsgn = x->sgn; + + if (comp < 0) + r = Icopy(r, x); + else if (comp == 0) + r = Icopy_zero(r); + else if (yl == 1) + { + int rem = unscale(x->s, xl, y->s[0], 0); + r = Icopy_long(r, rem); + if (rem != 0) + r->sgn = xsgn; + } + else + { + IntRep* yy = 0; + unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1])); + if (prescale != 1 || y == r) + { + yy = multiply(y, ((long)prescale & I_MAXNUM), yy); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + yy = (IntRep*)y; + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + do_divide(r->s, yy->s, yl, 0, xl - yl + 1); + + if (yy != y && !STATIC_IntRep(yy)) delete yy; + + if (prescale != 1) + { + Icheck(r); + unscale(r->s, r->len, prescale, r->s); + } + } + Icheck(r); + return r; +} + +IntRep* mod(const IntRep* x, long y, IntRep* r) +{ + nonnil(x); + int xl = x->len; + if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero"); + + unsigned short ys[SHORT_PER_LONG]; + unsigned long u; + int ysgn = y >= 0; + if (ysgn) + u = y; + else + u = -y; + int yl = 0; + while (u != 0) + { + ys[yl++] = extract(u); + u = down(u); + } + + int comp = xl - yl; + if (comp == 0) comp = docmp(x->s, ys, xl); + + int xsgn = x->sgn; + + if (comp < 0) + r = Icopy(r, x); + else if (comp == 0) + r = Icopy_zero(r); + else if (yl == 1) + { + int rem = unscale(x->s, xl, ys[0], 0); + r = Icopy_long(r, rem); + if (rem != 0) + r->sgn = xsgn; + } + else + { + unsigned short prescale = (I_RADIX / (1 + ys[yl - 1])); + if (prescale != 1) + { + unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0]; + ys[0] = extract(prod); + prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1]; + ys[1] = extract(prod); + r = multiply(x, ((long)prescale & I_MAXNUM), r); + } + else + { + r = Icalloc(r, xl + 1); + scpy(x->s, r->s, xl); + } + + do_divide(r->s, ys, yl, 0, xl - yl + 1); + + if (prescale != 1) + { + Icheck(r); + unscale(r->s, r->len, prescale, r->s); + } + } + Icheck(r); + return r; +} + +IntRep* lshift(const IntRep* x, long y, IntRep* r) +{ + nonnil(x); + int xl = x->len; + if (xl == 0 || y == 0) + { + r = Icopy(r, x); + return r; + } + + int xrsame = x == r; + int rsgn = x->sgn; + + long ay = (y < 0)? -y : y; + int bw = ay / I_SHIFT; + int sw = ay % I_SHIFT; + + if (y > 0) + { + int rl = bw + xl + 1; + if (xrsame) + r = Iresize(r, rl); + else + r = Icalloc(r, rl); + + unsigned short* botr = r->s; + unsigned short* rs = &(botr[rl - 1]); + const unsigned short* botx = (xrsame)? botr : x->s; + const unsigned short* xs = &(botx[xl - 1]); + unsigned long a = 0; + while (xs >= botx) + { + a = up(a) | ((unsigned long)(*xs--) << sw); + *rs-- = extract(down(a)); + } + *rs-- = extract(a); + while (rs >= botr) + *rs-- = 0; + } + else + { + int rl = xl - bw; + if (rl < 0) + r = Icopy_zero(r); + else + { + if (xrsame) + r = Iresize(r, rl); + else + r = Icalloc(r, rl); + int rw = I_SHIFT - sw; + unsigned short* rs = r->s; + unsigned short* topr = &(rs[rl]); + const unsigned short* botx = (xrsame)? rs : x->s; + const unsigned short* xs = &(botx[bw]); + const unsigned short* topx = &(botx[xl]); + unsigned long a = (unsigned long)(*xs++) >> sw; + while (xs < topx) + { + a |= (unsigned long)(*xs++) << rw; + *rs++ = extract(a); + a = down(a); + } + *rs++ = extract(a); + if (xrsame) topr = (unsigned short*)topx; + while (rs < topr) + *rs++ = 0; + } + } + r->sgn = rsgn; + Icheck(r); + return r; +} + +IntRep* lshift(const IntRep* x, const IntRep* yy, int negatey, IntRep* r) +{ + long y = Itolong(yy); + if (negatey) + y = -y; + + return lshift(x, y, r); +} + +IntRep* bitop(const IntRep* x, const IntRep* y, IntRep* r, char op) +{ + nonnil(x); + nonnil(y); + int xl = x->len; + int yl = y->len; + int xsgn = x->sgn; + int xrsame = x == r; + int yrsame = y == r; + if (xrsame || yrsame) + r = Iresize(r, calc_len(xl, yl, 0)); + else + r = Icalloc(r, calc_len(xl, yl, 0)); + r->sgn = xsgn; + unsigned short* rs = r->s; + unsigned short* topr = &(rs[r->len]); + const unsigned short* as; + const unsigned short* bs; + const unsigned short* topb; + if (xl >= yl) + { + as = (xrsame)? rs : x->s; + bs = (yrsame)? rs : y->s; + topb = &(bs[yl]); + } + else + { + bs = (xrsame)? rs : x->s; + topb = &(bs[xl]); + as = (yrsame)? rs : y->s; + } + + switch (op) + { + case '&': + while (bs < topb) *rs++ = *as++ & *bs++; + while (rs < topr) *rs++ = 0; + break; + case '|': + while (bs < topb) *rs++ = *as++ | *bs++; + while (rs < topr) *rs++ = *as++; + break; + case '^': + while (bs < topb) *rs++ = *as++ ^ *bs++; + while (rs < topr) *rs++ = *as++; + break; + } + Icheck(r); + return r; +} + +IntRep* bitop(const IntRep* x, long y, IntRep* r, char op) +{ + nonnil(x); + unsigned short tmp[SHORT_PER_LONG]; + unsigned long u; + int newsgn; + if (newsgn = (y >= 0)) + u = y; + else + u = -y; + + int l = 0; + while (u != 0) + { + tmp[l++] = extract(u); + u = down(u); + } + + int xl = x->len; + int yl = l; + int xsgn = x->sgn; + int xrsame = x == r; + if (xrsame) + r = Iresize(r, calc_len(xl, yl, 0)); + else + r = Icalloc(r, calc_len(xl, yl, 0)); + r->sgn = xsgn; + unsigned short* rs = r->s; + unsigned short* topr = &(rs[r->len]); + const unsigned short* as; + const unsigned short* bs; + const unsigned short* topb; + if (xl >= yl) + { + as = (xrsame)? rs : x->s; + bs = tmp; + topb = &(bs[yl]); + } + else + { + bs = (xrsame)? rs : x->s; + topb = &(bs[xl]); + as = tmp; + } + + switch (op) + { + case '&': + while (bs < topb) *rs++ = *as++ & *bs++; + while (rs < topr) *rs++ = 0; + break; + case '|': + while (bs < topb) *rs++ = *as++ | *bs++; + while (rs < topr) *rs++ = *as++; + break; + case '^': + while (bs < topb) *rs++ = *as++ ^ *bs++; + while (rs < topr) *rs++ = *as++; + break; + } + Icheck(r); + return r; +} + + + +IntRep* compl(const IntRep* src, IntRep* r) +{ + nonnil(src); + r = Icopy(r, src); + unsigned short* s = r->s; + unsigned short* top = &(s[r->len - 1]); + while (s < top) + { + unsigned short cmp = ~(*s); + *s++ = cmp; + } + unsigned short a = *s; + unsigned short b = 0; + while (a != 0) + { + b <<= 1; + if (!(a & 1)) b |= 1; + a >>= 1; + } + *s = b; + Icheck(r); + return r; +} + +void (setbit)(Integer& x, long b) +{ + if (b >= 0) + { + int bw = (unsigned long)b / I_SHIFT; + int sw = (unsigned long)b % I_SHIFT; + int xl = x.rep ? x.rep->len : 0; + if (xl <= bw) + x.rep = Iresize(x.rep, calc_len(xl, bw+1, 0)); + x.rep->s[bw] |= (1 << sw); + Icheck(x.rep); + } +} + +void clearbit(Integer& x, long b) +{ + if (b >= 0) + { + if (x.rep == 0) + x.rep = &_ZeroRep; + else + { + int bw = (unsigned long)b / I_SHIFT; + int sw = (unsigned long)b % I_SHIFT; + if (x.rep->len > bw) + x.rep->s[bw] &= ~(1 << sw); + } + Icheck(x.rep); + } +} + +int testbit(const Integer& x, long b) +{ + if (x.rep != 0 && b >= 0) + { + int bw = (unsigned long)b / I_SHIFT; + int sw = (unsigned long)b % I_SHIFT; + return (bw < x.rep->len && (x.rep->s[bw] & (1 << sw)) != 0); + } + else + return 0; +} + +// A version of knuth's algorithm B / ex. 4.5.3.34 +// A better version that doesn't bother shifting all of `t' forthcoming + +IntRep* gcd(const IntRep* x, const IntRep* y) +{ + nonnil(x); + nonnil(y); + int ul = x->len; + int vl = y->len; + + if (vl == 0) + return Ialloc(0, x->s, ul, I_POSITIVE, ul); + else if (ul == 0) + return Ialloc(0, y->s, vl, I_POSITIVE, vl); + + IntRep* u = Ialloc(0, x->s, ul, I_POSITIVE, ul); + IntRep* v = Ialloc(0, y->s, vl, I_POSITIVE, vl); + +// find shift so that both not even + + long k = 0; + int l = (ul <= vl)? ul : vl; + int cont = 1; + for (int i = 0; i < l && cont; ++i) + { + unsigned long a = (i < ul)? u->s[i] : 0; + unsigned long b = (i < vl)? v->s[i] : 0; + for (int j = 0; j < I_SHIFT; ++j) + { + if ((a | b) & 1) + { + cont = 0; + break; + } + else + { + ++k; + a >>= 1; + b >>= 1; + } + } + } + + if (k != 0) + { + u = lshift(u, -k, u); + v = lshift(v, -k, v); + } + + IntRep* t; + if (u->s[0] & 01) + t = Ialloc(0, v->s, v->len, !v->sgn, v->len); + else + t = Ialloc(0, u->s, u->len, u->sgn, u->len); + + while (t->len != 0) + { + long s = 0; // shift t until odd + cont = 1; + int tl = t->len; + for (int i = 0; i < tl && cont; ++i) + { + unsigned long a = t->s[i]; + for (int j = 0; j < I_SHIFT; ++j) + { + if (a & 1) + { + cont = 0; + break; + } + else + { + ++s; + a >>= 1; + } + } + } + + if (s != 0) t = lshift(t, -s, t); + + if (t->sgn == I_POSITIVE) + { + u = Icopy(u, t); + t = add(t, 0, v, 1, t); + } + else + { + v = Ialloc(v, t->s, t->len, !t->sgn, t->len); + t = add(t, 0, u, 0, t); + } + } + if (!STATIC_IntRep(t)) delete t; + if (!STATIC_IntRep(v)) delete v; + if (k != 0) u = lshift(u, k, u); + return u; +} + + + +long lg(const IntRep* x) +{ + nonnil(x); + int xl = x->len; + if (xl == 0) + return 0; + + long l = (xl - 1) * I_SHIFT - 1; + unsigned short a = x->s[xl-1]; + + while (a != 0) + { + a = a >> 1; + ++l; + } + return l; +} + +IntRep* power(const IntRep* x, long y, IntRep* r) +{ + nonnil(x); + int sgn; + if (x->sgn == I_POSITIVE || (!(y & 1))) + sgn = I_POSITIVE; + else + sgn = I_NEGATIVE; + + int xl = x->len; + + if (y == 0 || (xl == 1 && x->s[0] == 1)) + r = Icopy_one(r, sgn); + else if (xl == 0 || y < 0) + r = Icopy_zero(r); + else if (y == 1 || y == -1) + r = Icopy(r, x); + else + { + int maxsize = ((lg(x) + 1) * y) / I_SHIFT + 2; // pre-allocate space + IntRep* b = Ialloc(0, x->s, xl, I_POSITIVE, maxsize); + b->len = xl; + r = Icalloc(r, maxsize); + r = Icopy_one(r, I_POSITIVE); + for(;;) + { + if (y & 1) + r = multiply(r, b, r); + if ((y >>= 1) == 0) + break; + else + b = multiply(b, b, b); + } + if (!STATIC_IntRep(b)) delete b; + } + r->sgn = sgn; + Icheck(r); + return r; +} + +IntRep* abs(const IntRep* src, IntRep* dest) +{ + nonnil(src); + if (src != dest) + dest = Icopy(dest, src); + dest->sgn = I_POSITIVE; + return dest; +} + +IntRep* negate(const IntRep* src, IntRep* dest) +{ + nonnil(src); + if (src != dest) + dest = Icopy(dest, src); + if (dest->len != 0) + dest->sgn = !dest->sgn; + return dest; +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +Integer sqrt(const Integer& x) return r(x) +{ + int s = sign(x); + if (s < 0) x.error("Attempted square root of negative Integer"); + if (s != 0) + { + r >>= (lg(x) / 2); // get close + Integer q; + div(x, r, q); + while (q < r) + { + r += q; + r >>= 1; + div(x, r, q); + } + } + return; +} + +Integer lcm(const Integer& x, const Integer& y) return r +{ + if (!x.initialized() || !y.initialized()) + x.error("operation on uninitialized Integer"); + Integer g; + if (sign(x) == 0 || sign(y) == 0) + g = 1; + else + g = gcd(x, y); + div(x, g, r); + mul(r, y, r); +} + +#else +Integer sqrt(const Integer& x) +{ + Integer r(x); + int s = sign(x); + if (s < 0) x.error("Attempted square root of negative Integer"); + if (s != 0) + { + r >>= (lg(x) / 2); // get close + Integer q; + div(x, r, q); + while (q < r) + { + r += q; + r >>= 1; + div(x, r, q); + } + } + return r; +} + +Integer lcm(const Integer& x, const Integer& y) +{ + Integer r; + if (!x.initialized() || !y.initialized()) + x.error("operation on uninitialized Integer"); + Integer g; + if (sign(x) == 0 || sign(y) == 0) + g = 1; + else + g = gcd(x, y); + div(x, g, r); + mul(r, y, r); + return r; +} + +#endif + + + +IntRep* atoIntRep(const char* s, int base) +{ + int sl = strlen(s); + IntRep* r = Icalloc(0, sl * (lg(base) + 1) / I_SHIFT + 1); + if (s != 0) + { + char sgn; + while (isspace(*s)) ++s; + if (*s == '-') + { + sgn = I_NEGATIVE; + s++; + } + else if (*s == '+') + { + sgn = I_POSITIVE; + s++; + } + else + sgn = I_POSITIVE; + for (;;) + { + long digit; + if (*s >= '0' && *s <= '9') digit = *s - '0'; + else if (*s >= 'a' && *s <= 'z') digit = *s - 'a' + 10; + else if (*s >= 'A' && *s <= 'Z') digit = *s - 'A' + 10; + else break; + if (digit >= base) break; + r = multiply(r, base, r); + r = add(r, 0, digit, r); + ++s; + } + r->sgn = sgn; + } + return r; +} + + + +extern AllocRing _libgxx_fmtq; + +char* Itoa(const IntRep* x, int base, int width) +{ + int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width; + char* fmtbase = (char *) _libgxx_fmtq.alloc(fmtlen); + char* f = cvtItoa(x, fmtbase, fmtlen, base, 0, width, 0, ' ', 'X', 0); + return f; +} + +ostream& operator << (ostream& s, const Integer& y) +{ +#ifdef _OLD_STREAMS + return s << Itoa(y.rep); +#else + if (s.opfx()) + { + int base = (s.flags() & ios::oct) ? 8 : (s.flags() & ios::hex) ? 16 : 10; + int width = s.width(); + y.printon(s, base, width); + } + return s; +#endif +} + +void Integer::printon(ostream& s, int base /* =10 */, int width /* =0 */) const +{ + int align_right = !(s.flags() & ios::left); + int showpos = s.flags() & ios::showpos; + int showbase = s.flags() & ios::showbase; + char fillchar = s.fill(); + char Xcase = (s.flags() & ios::uppercase)? 'X' : 'x'; + const IntRep* x = rep; + int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width; + char* fmtbase = new char[fmtlen]; + char* f = cvtItoa(x, fmtbase, fmtlen, base, showbase, width, align_right, + fillchar, Xcase, showpos); + s.write(f, fmtlen); + delete [] fmtbase; +} + +char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, int showbase, + int width, int align_right, char fillchar, char Xcase, + int showpos) +{ + char* e = fmt + fmtlen - 1; + char* s = e; + *--s = 0; + + if (x->len == 0) + *--s = '0'; + else + { + IntRep* z = Icopy(0, x); + + // split division by base into two parts: + // first divide by biggest power of base that fits in an unsigned short, + // then use straight signed div/mods from there. + + // find power + int bpower = 1; + unsigned short b = base; + unsigned short maxb = I_MAXNUM / base; + while (b < maxb) + { + b *= base; + ++bpower; + } + for(;;) + { + int rem = unscale(z->s, z->len, b, z->s); + Icheck(z); + if (z->len == 0) + { + while (rem != 0) + { + char ch = rem % base; + rem /= base; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + if (!STATIC_IntRep(z)) delete z; + break; + } + else + { + for (int i = 0; i < bpower; ++i) + { + char ch = rem % base; + rem /= base; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--s = ch; + } + } + } + } + + if (base == 8 && showbase) + *--s = '0'; + else if (base == 16 && showbase) + { + *--s = Xcase; + *--s = '0'; + } + if (x->sgn == I_NEGATIVE) *--s = '-'; + else if (showpos) *--s = '+'; + int w = e - s - 1; + if (!align_right || w >= width) + { + while (w++ < width) + *--s = fillchar; + fmtlen = e - s - 1; + return s; + } + else + { + char* p = fmt; + for (char* t = s; *t != 0; ++t, ++p) *p = *t; + while (w++ < width) *p++ = fillchar; + *p = 0; + fmtlen = p - fmt; + return fmt; + } +} + +char* dec(const Integer& x, int width) +{ + return Itoa(x, 10, width); +} + +char* oct(const Integer& x, int width) +{ + return Itoa(x, 8, width); +} + +char* hex(const Integer& x, int width) +{ + return Itoa(x, 16, width); +} + +istream& operator >> (istream& stream, Integer& val) +{ + if (!stream.ipfx0()) + return stream; + int sign = ' '; + register streambuf* sb = stream.rdbuf(); + int base = 10; + int ndigits = 0; + register int ch = sb->sbumpc(); + while (ch != EOF && isspace(ch)) + ch = sb->sbumpc(); + if (ch == '+' || ch == '-') + { + sign = ch; + ch = sb->sbumpc(); + while (ch != EOF && isspace(ch)) + ch = sb->sbumpc(); + } + if (ch == EOF) goto eof_fail; + if (!(stream.flags() & ios::basefield)) + { + if (ch == '0') + { + ch = sb->sbumpc(); + if (ch == EOF) { } + else 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.rep = Icopy_zero(val.rep); + + 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 + goto done; + } + ndigits++; + switch (base) + { + case 8: + val <<= 3; + break; + case 16: + val <<= 4; + break; + default: + val *= base; + break; + } + val += digit; + ch = sb->sbumpc(); + } + fail: + stream.set(ios::failbit); + done: + if (sign == '-') + val.negate(); + return stream; + eof_fail: + stream.set(ios::failbit|ios::eofbit); + return stream; +} + +int Integer::OK() const +{ + if (rep != 0) + { + int l = rep->len; + int s = rep->sgn; + int v = l <= rep->sz || STATIC_IntRep(rep); // length within bounds + v &= s == 0 || s == 1; // legal sign + Icheck(rep); // and correctly adjusted + v &= rep->len == l; + v &= rep->sgn == s; + if (v) + return v; + } + error("invariant failure"); + return 0; +} + +void Integer::error(const char* msg) const +{ + (*lib_error_handler)("Integer", msg); +} + diff --git a/gnu/lib/libg++/libg++/src/Integer.h b/gnu/lib/libg++/libg++/src/Integer.h new file mode 100644 index 00000000000..f2e9b160a63 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Integer.h @@ -0,0 +1,1121 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +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. +*/ + +#ifndef _Integer_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Integer_h 1 + +#include + +#undef OK + +struct IntRep // internal Integer representations +{ + unsigned short len; // current length + unsigned short sz; // allocated space (0 means static). + short sgn; // 1 means >= 0; 0 means < 0 + unsigned short s[1]; // represented as ushort array starting here +}; + +// True if REP is staticly (or manually) allocated, +// and should not be deleted by an Integer destructor. +#define STATIC_IntRep(rep) ((rep)->sz==0) + +extern IntRep* Ialloc(IntRep*, const unsigned short *, int, int, int); +extern IntRep* Icalloc(IntRep*, int); +extern IntRep* Icopy_ulong(IntRep*, unsigned long); +extern IntRep* Icopy_long(IntRep*, long); +extern IntRep* Icopy(IntRep*, const IntRep*); +extern IntRep* Iresize(IntRep*, int); +extern IntRep* add(const IntRep*, int, const IntRep*, int, IntRep*); +extern IntRep* add(const IntRep*, int, long, IntRep*); +extern IntRep* multiply(const IntRep*, const IntRep*, IntRep*); +extern IntRep* multiply(const IntRep*, long, IntRep*); +extern IntRep* lshift(const IntRep*, long, IntRep*); +extern IntRep* lshift(const IntRep*, const IntRep*, int, IntRep*); +extern IntRep* bitop(const IntRep*, const IntRep*, IntRep*, char); +extern IntRep* bitop(const IntRep*, long, IntRep*, char); +extern IntRep* power(const IntRep*, long, IntRep*); +extern IntRep* div(const IntRep*, const IntRep*, IntRep*); +extern IntRep* mod(const IntRep*, const IntRep*, IntRep*); +extern IntRep* div(const IntRep*, long, IntRep*); +extern IntRep* mod(const IntRep*, long, IntRep*); +extern IntRep* compl(const IntRep*, IntRep*); +extern IntRep* abs(const IntRep*, IntRep*); +extern IntRep* negate(const IntRep*, IntRep*); +extern IntRep* pow(const IntRep*, long); +extern IntRep* gcd(const IntRep*, const IntRep* y); +extern int compare(const IntRep*, const IntRep*); +extern int compare(const IntRep*, long); +extern int ucompare(const IntRep*, const IntRep*); +extern int ucompare(const IntRep*, long); +extern char* Itoa(const IntRep* x, int base = 10, int width = 0); +extern char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, + int showbase, int width, int align_right, + char fillchar, char Xcase, int showpos); +extern IntRep* atoIntRep(const char* s, int base = 10); +extern long Itolong(const IntRep*); +extern int Iislong(const IntRep*); +extern long lg(const IntRep*); + +extern IntRep _ZeroRep, _OneRep, _MinusOneRep; + +class Integer +{ +protected: + IntRep* rep; +public: + Integer(); + Integer(int); + Integer(long); + Integer(unsigned long); + Integer(IntRep*); + Integer(const Integer&); + + ~Integer(); + Integer& operator = (const Integer&); + Integer& operator = (long); + +// unary operations to self + + Integer& operator ++ (); + Integer& operator -- (); + void negate(); // negate in-place + void abs(); // absolute-value in-place + void complement(); // bitwise complement in-place + +// assignment-based operations + + Integer& operator += (const Integer&); + Integer& operator -= (const Integer&); + Integer& operator *= (const Integer&); + Integer& operator /= (const Integer&); + Integer& operator %= (const Integer&); + Integer& operator <<=(const Integer&); + Integer& operator >>=(const Integer&); + Integer& operator &= (const Integer&); + Integer& operator |= (const Integer&); + Integer& operator ^= (const Integer&); + + Integer& operator += (long); + Integer& operator -= (long); + Integer& operator *= (long); + Integer& operator /= (long); + Integer& operator %= (long); + Integer& operator <<=(long); + Integer& operator >>=(long); + Integer& operator &= (long); + Integer& operator |= (long); + Integer& operator ^= (long); + +// (constructive binary operations are inlined below) + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + friend Integer operator ? (const Integer& x, const Integer& y); // max +#endif + +// builtin Integer functions that must be friends + + friend long lg (const Integer&); // floor log base 2 of abs(x) + friend double ratio(const Integer& x, const Integer& y); + // return x/y as a double + + friend Integer gcd(const Integer&, const Integer&); + friend int even(const Integer&); // true if even + friend int odd(const Integer&); // true if odd + friend int sign(const Integer&); // returns -1, 0, +1 + + friend void (setbit)(Integer& x, long b); // set b'th bit of x + friend void clearbit(Integer& x, long b); // clear b'th bit + friend int testbit(const Integer& x, long b); // return b'th bit + +// procedural versions of operators + + friend void abs(const Integer& x, Integer& dest); + friend void negate(const Integer& x, Integer& dest); + friend void complement(const Integer& x, Integer& dest); + + friend int compare(const Integer&, const Integer&); + friend int ucompare(const Integer&, const Integer&); + friend void add(const Integer& x, const Integer& y, Integer& dest); + friend void sub(const Integer& x, const Integer& y, Integer& dest); + friend void mul(const Integer& x, const Integer& y, Integer& dest); + friend void div(const Integer& x, const Integer& y, Integer& dest); + friend void mod(const Integer& x, const Integer& y, Integer& dest); + friend void divide(const Integer& x, const Integer& y, + Integer& q, Integer& r); + friend void and(const Integer& x, const Integer& y, Integer& dest); + friend void or(const Integer& x, const Integer& y, Integer& dest); + friend void xor(const Integer& x, const Integer& y, Integer& dest); + friend void lshift(const Integer& x, const Integer& y, Integer& dest); + friend void rshift(const Integer& x, const Integer& y, Integer& dest); + friend void pow(const Integer& x, const Integer& y, Integer& dest); + + friend int compare(const Integer&, long); + friend int ucompare(const Integer&, long); + friend void add(const Integer& x, long y, Integer& dest); + friend void sub(const Integer& x, long y, Integer& dest); + friend void mul(const Integer& x, long y, Integer& dest); + friend void div(const Integer& x, long y, Integer& dest); + friend void mod(const Integer& x, long y, Integer& dest); + friend void divide(const Integer& x, long y, Integer& q, long& r); + friend void and(const Integer& x, long y, Integer& dest); + friend void or(const Integer& x, long y, Integer& dest); + friend void xor(const Integer& x, long y, Integer& dest); + friend void lshift(const Integer& x, long y, Integer& dest); + friend void rshift(const Integer& x, long y, Integer& dest); + friend void pow(const Integer& x, long y, Integer& dest); + + friend int compare(long, const Integer&); + friend int ucompare(long, const Integer&); + friend void add(long x, const Integer& y, Integer& dest); + friend void sub(long x, const Integer& y, Integer& dest); + friend void mul(long x, const Integer& y, Integer& dest); + friend void and(long x, const Integer& y, Integer& dest); + friend void or(long x, const Integer& y, Integer& dest); + friend void xor(long x, const Integer& y, Integer& dest); + +// coercion & conversion + + int fits_in_long() const { return Iislong(rep); } + int fits_in_double() const; + + long as_long() const { return Itolong(rep); } + double as_double() const; + + friend char* Itoa(const Integer& x, int base = 10, int width = 0); + friend Integer atoI(const char* s, int base = 10); + void printon(ostream& s, int base = 10, int width = 0) const; + + friend istream& operator >> (istream& s, Integer& y); + friend ostream& operator << (ostream& s, const Integer& y); + +// error detection + + int initialized() const; + void error(const char* msg) const; + int OK() const; +}; + + +// (These are declared inline) + + int operator == (const Integer&, const Integer&); + int operator == (const Integer&, long); + int operator != (const Integer&, const Integer&); + int operator != (const Integer&, long); + int operator < (const Integer&, const Integer&); + int operator < (const Integer&, long); + int operator <= (const Integer&, const Integer&); + int operator <= (const Integer&, long); + int operator > (const Integer&, const Integer&); + int operator > (const Integer&, long); + int operator >= (const Integer&, const Integer&); + int operator >= (const Integer&, long); + Integer operator - (const Integer&); + Integer operator ~ (const Integer&); + Integer operator + (const Integer&, const Integer&); + Integer operator + (const Integer&, long); + Integer operator + (long, const Integer&); + Integer operator - (const Integer&, const Integer&); + Integer operator - (const Integer&, long); + Integer operator - (long, const Integer&); + Integer operator * (const Integer&, const Integer&); + Integer operator * (const Integer&, long); + Integer operator * (long, const Integer&); + Integer operator / (const Integer&, const Integer&); + Integer operator / (const Integer&, long); + Integer operator % (const Integer&, const Integer&); + Integer operator % (const Integer&, long); + Integer operator << (const Integer&, const Integer&); + Integer operator << (const Integer&, long); + Integer operator >> (const Integer&, const Integer&); + Integer operator >> (const Integer&, long); + Integer operator & (const Integer&, const Integer&); + Integer operator & (const Integer&, long); + Integer operator & (long, const Integer&); + Integer operator | (const Integer&, const Integer&); + Integer operator | (const Integer&, long); + Integer operator | (long, const Integer&); + Integer operator ^ (const Integer&, const Integer&); + Integer operator ^ (const Integer&, long); + Integer operator ^ (long, const Integer&); + + Integer abs(const Integer&); // absolute value + Integer sqr(const Integer&); // square + + Integer pow(const Integer& x, const Integer& y); + Integer pow(const Integer& x, long y); + Integer Ipow(long x, long y); // x to the y as Integer + + +extern char* dec(const Integer& x, int width = 0); +extern char* oct(const Integer& x, int width = 0); +extern char* hex(const Integer& x, int width = 0); +extern Integer sqrt(const Integer&); // floor of square root +extern Integer lcm(const Integer& x, const Integer& y); // least common mult + + +typedef Integer IntTmp; // for backward compatibility + +inline Integer::Integer() :rep(&_ZeroRep) {} + +inline Integer::Integer(IntRep* r) :rep(r) {} + +inline Integer::Integer(int y) :rep(Icopy_long(0, (long)y)) {} + +inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {} + +inline Integer::Integer(unsigned long y) :rep(Icopy_ulong(0, y)) {} + +inline Integer::Integer(const Integer& y) :rep(Icopy(0, y.rep)) {} + +inline Integer::~Integer() { if (rep && !STATIC_IntRep(rep)) delete rep; } + +inline Integer& Integer::operator = (const Integer& y) +{ + rep = Icopy(rep, y.rep); + return *this; +} + +inline Integer& Integer::operator = (long y) +{ + rep = Icopy_long(rep, y); + return *this; +} + +inline int Integer::initialized() const +{ + return rep != 0; +} + +// procedural versions + +inline int compare(const Integer& x, const Integer& y) +{ + return compare(x.rep, y.rep); +} + +inline int ucompare(const Integer& x, const Integer& y) +{ + return ucompare(x.rep, y.rep); +} + +inline int compare(const Integer& x, long y) +{ + return compare(x.rep, y); +} + +inline int ucompare(const Integer& x, long y) +{ + return ucompare(x.rep, y); +} + +inline int compare(long x, const Integer& y) +{ + return -compare(y.rep, x); +} + +inline int ucompare(long x, const Integer& y) +{ + return -ucompare(y.rep, x); +} + +inline void add(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = add(x.rep, 0, y.rep, 0, dest.rep); +} + +inline void sub(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = add(x.rep, 0, y.rep, 1, dest.rep); +} + +inline void mul(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = multiply(x.rep, y.rep, dest.rep); +} + +inline void div(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = div(x.rep, y.rep, dest.rep); +} + +inline void mod(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = mod(x.rep, y.rep, dest.rep); +} + +inline void and(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(x.rep, y.rep, dest.rep, '&'); +} + +inline void or(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(x.rep, y.rep, dest.rep, '|'); +} + +inline void xor(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(x.rep, y.rep, dest.rep, '^'); +} + +inline void lshift(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = lshift(x.rep, y.rep, 0, dest.rep); +} + +inline void rshift(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = lshift(x.rep, y.rep, 1, dest.rep); +} + +inline void pow(const Integer& x, const Integer& y, Integer& dest) +{ + dest.rep = power(x.rep, Itolong(y.rep), dest.rep); // not incorrect +} + +inline void add(const Integer& x, long y, Integer& dest) +{ + dest.rep = add(x.rep, 0, y, dest.rep); +} + +inline void sub(const Integer& x, long y, Integer& dest) +{ + dest.rep = add(x.rep, 0, -y, dest.rep); +} + +inline void mul(const Integer& x, long y, Integer& dest) +{ + dest.rep = multiply(x.rep, y, dest.rep); +} + +inline void div(const Integer& x, long y, Integer& dest) +{ + dest.rep = div(x.rep, y, dest.rep); +} + +inline void mod(const Integer& x, long y, Integer& dest) +{ + dest.rep = mod(x.rep, y, dest.rep); +} + +inline void and(const Integer& x, long y, Integer& dest) +{ + dest.rep = bitop(x.rep, y, dest.rep, '&'); +} + +inline void or(const Integer& x, long y, Integer& dest) +{ + dest.rep = bitop(x.rep, y, dest.rep, '|'); +} + +inline void xor(const Integer& x, long y, Integer& dest) +{ + dest.rep = bitop(x.rep, y, dest.rep, '^'); +} + +inline void lshift(const Integer& x, long y, Integer& dest) +{ + dest.rep = lshift(x.rep, y, dest.rep); +} + +inline void rshift(const Integer& x, long y, Integer& dest) +{ + dest.rep = lshift(x.rep, -y, dest.rep); +} + +inline void pow(const Integer& x, long y, Integer& dest) +{ + dest.rep = power(x.rep, y, dest.rep); +} + +inline void abs(const Integer& x, Integer& dest) +{ + dest.rep = abs(x.rep, dest.rep); +} + +inline void negate(const Integer& x, Integer& dest) +{ + dest.rep = negate(x.rep, dest.rep); +} + +inline void complement(const Integer& x, Integer& dest) +{ + dest.rep = compl(x.rep, dest.rep); +} + +inline void add(long x, const Integer& y, Integer& dest) +{ + dest.rep = add(y.rep, 0, x, dest.rep); +} + +inline void sub(long x, const Integer& y, Integer& dest) +{ + dest.rep = add(y.rep, 1, x, dest.rep); +} + +inline void mul(long x, const Integer& y, Integer& dest) +{ + dest.rep = multiply(y.rep, x, dest.rep); +} + +inline void and(long x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(y.rep, x, dest.rep, '&'); +} + +inline void or(long x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(y.rep, x, dest.rep, '|'); +} + +inline void xor(long x, const Integer& y, Integer& dest) +{ + dest.rep = bitop(y.rep, x, dest.rep, '^'); +} + + +// operator versions + +inline int operator == (const Integer& x, const Integer& y) +{ + return compare(x, y) == 0; +} + +inline int operator == (const Integer& x, long y) +{ + return compare(x, y) == 0; +} + +inline int operator != (const Integer& x, const Integer& y) +{ + return compare(x, y) != 0; +} + +inline int operator != (const Integer& x, long y) +{ + return compare(x, y) != 0; +} + +inline int operator < (const Integer& x, const Integer& y) +{ + return compare(x, y) < 0; +} + +inline int operator < (const Integer& x, long y) +{ + return compare(x, y) < 0; +} + +inline int operator <= (const Integer& x, const Integer& y) +{ + return compare(x, y) <= 0; +} + +inline int operator <= (const Integer& x, long y) +{ + return compare(x, y) <= 0; +} + +inline int operator > (const Integer& x, const Integer& y) +{ + return compare(x, y) > 0; +} + +inline int operator > (const Integer& x, long y) +{ + return compare(x, y) > 0; +} + +inline int operator >= (const Integer& x, const Integer& y) +{ + return compare(x, y) >= 0; +} + +inline int operator >= (const Integer& x, long y) +{ + return compare(x, y) >= 0; +} + + +inline Integer& Integer::operator += (const Integer& y) +{ + add(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator += (long y) +{ + add(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator ++ () +{ + add(*this, 1, *this); + return *this; +} + + +inline Integer& Integer::operator -= (const Integer& y) +{ + sub(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator -= (long y) +{ + sub(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator -- () +{ + add(*this, -1, *this); + return *this; +} + + + +inline Integer& Integer::operator *= (const Integer& y) +{ + mul(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator *= (long y) +{ + mul(*this, y, *this); + return *this; +} + + +inline Integer& Integer::operator &= (const Integer& y) +{ + and(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator &= (long y) +{ + and(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator |= (const Integer& y) +{ + or(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator |= (long y) +{ + or(*this, y, *this); + return *this; +} + + +inline Integer& Integer::operator ^= (const Integer& y) +{ + xor(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator ^= (long y) +{ + xor(*this, y, *this); + return *this; +} + + + +inline Integer& Integer::operator /= (const Integer& y) +{ + div(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator /= (long y) +{ + div(*this, y, *this); + return *this; +} + + +inline Integer& Integer::operator <<= (const Integer& y) +{ + lshift(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator <<= (long y) +{ + lshift(*this, y, *this); + return *this; +} + + +inline Integer& Integer::operator >>= (const Integer& y) +{ + rshift(*this, y, *this); + return *this; +} + +inline Integer& Integer::operator >>= (long y) +{ + rshift(*this, y, *this); + return *this; +} + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) +inline Integer operator ? (const Integer& x, const Integer& y) +{ + return (compare(x.rep, y.rep) >= 0)? x : y; +} +#endif + + +inline void Integer::abs() +{ + ::abs(*this, *this); +} + +inline void Integer::negate() +{ + ::negate(*this, *this); +} + + +inline void Integer::complement() +{ + ::complement(*this, *this); +} + + +inline int sign(const Integer& x) +{ + return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 ); +} + +inline int even(const Integer& y) +{ + return y.rep->len == 0 || !(y.rep->s[0] & 1); +} + +inline int odd(const Integer& y) +{ + return y.rep->len > 0 && (y.rep->s[0] & 1); +} + +inline char* Itoa(const Integer& y, int base, int width) +{ + return Itoa(y.rep, base, width); +} + + + +inline long lg(const Integer& x) +{ + return lg(x.rep); +} + +// constructive operations + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +inline Integer operator + (const Integer& x, const Integer& y) return r +{ + add(x, y, r); +} + +inline Integer operator + (const Integer& x, long y) return r +{ + add(x, y, r); +} + +inline Integer operator + (long x, const Integer& y) return r +{ + add(x, y, r); +} + +inline Integer operator - (const Integer& x, const Integer& y) return r +{ + sub(x, y, r); +} + +inline Integer operator - (const Integer& x, long y) return r +{ + sub(x, y, r); +} + +inline Integer operator - (long x, const Integer& y) return r +{ + sub(x, y, r); +} + +inline Integer operator * (const Integer& x, const Integer& y) return r +{ + mul(x, y, r); +} + +inline Integer operator * (const Integer& x, long y) return r +{ + mul(x, y, r); +} + +inline Integer operator * (long x, const Integer& y) return r +{ + mul(x, y, r); +} + +inline Integer sqr(const Integer& x) return r +{ + mul(x, x, r); +} + +inline Integer operator & (const Integer& x, const Integer& y) return r +{ + and(x, y, r); +} + +inline Integer operator & (const Integer& x, long y) return r +{ + and(x, y, r); +} + +inline Integer operator & (long x, const Integer& y) return r +{ + and(x, y, r); +} + +inline Integer operator | (const Integer& x, const Integer& y) return r +{ + or(x, y, r); +} + +inline Integer operator | (const Integer& x, long y) return r +{ + or(x, y, r); +} + +inline Integer operator | (long x, const Integer& y) return r +{ + or(x, y, r); +} + +inline Integer operator ^ (const Integer& x, const Integer& y) return r +{ + xor(x, y, r); +} + +inline Integer operator ^ (const Integer& x, long y) return r +{ + xor(x, y, r); +} + +inline Integer operator ^ (long x, const Integer& y) return r +{ + xor(x, y, r); +} + +inline Integer operator / (const Integer& x, const Integer& y) return r +{ + div(x, y, r); +} + +inline Integer operator / (const Integer& x, long y) return r +{ + div(x, y, r); +} + +inline Integer operator % (const Integer& x, const Integer& y) return r +{ + mod(x, y, r); +} + +inline Integer operator % (const Integer& x, long y) return r +{ + mod(x, y, r); +} + +inline Integer operator << (const Integer& x, const Integer& y) return r +{ + lshift(x, y, r); +} + +inline Integer operator << (const Integer& x, long y) return r +{ + lshift(x, y, r); +} + +inline Integer operator >> (const Integer& x, const Integer& y) return r; +{ + rshift(x, y, r); +} + +inline Integer operator >> (const Integer& x, long y) return r +{ + rshift(x, y, r); +} + +inline Integer pow(const Integer& x, long y) return r +{ + pow(x, y, r); +} + +inline Integer Ipow(long x, long y) return r(x) +{ + pow(r, y, r); +} + +inline Integer pow(const Integer& x, const Integer& y) return r +{ + pow(x, y, r); +} + + + +inline Integer abs(const Integer& x) return r +{ + abs(x, r); +} + +inline Integer operator - (const Integer& x) return r +{ + negate(x, r); +} + +inline Integer operator ~ (const Integer& x) return r +{ + complement(x, r); +} + +inline Integer atoI(const char* s, int base) return r +{ + r.rep = atoIntRep(s, base); +} + +inline Integer gcd(const Integer& x, const Integer& y) return r +{ + r.rep = gcd(x.rep, y.rep); +} + +#else /* NO_NRV */ + +inline Integer operator + (const Integer& x, const Integer& y) +{ + Integer r; add(x, y, r); return r; +} + +inline Integer operator + (const Integer& x, long y) +{ + Integer r; add(x, y, r); return r; +} + +inline Integer operator + (long x, const Integer& y) +{ + Integer r; add(x, y, r); return r; +} + +inline Integer operator - (const Integer& x, const Integer& y) +{ + Integer r; sub(x, y, r); return r; +} + +inline Integer operator - (const Integer& x, long y) +{ + Integer r; sub(x, y, r); return r; +} + +inline Integer operator - (long x, const Integer& y) +{ + Integer r; sub(x, y, r); return r; +} + +inline Integer operator * (const Integer& x, const Integer& y) +{ + Integer r; mul(x, y, r); return r; +} + +inline Integer operator * (const Integer& x, long y) +{ + Integer r; mul(x, y, r); return r; +} + +inline Integer operator * (long x, const Integer& y) +{ + Integer r; mul(x, y, r); return r; +} + +inline Integer sqr(const Integer& x) +{ + Integer r; mul(x, x, r); return r; +} + +inline Integer operator & (const Integer& x, const Integer& y) +{ + Integer r; and(x, y, r); return r; +} + +inline Integer operator & (const Integer& x, long y) +{ + Integer r; and(x, y, r); return r; +} + +inline Integer operator & (long x, const Integer& y) +{ + Integer r; and(x, y, r); return r; +} + +inline Integer operator | (const Integer& x, const Integer& y) +{ + Integer r; or(x, y, r); return r; +} + +inline Integer operator | (const Integer& x, long y) +{ + Integer r; or(x, y, r); return r; +} + +inline Integer operator | (long x, const Integer& y) +{ + Integer r; or(x, y, r); return r; +} + +inline Integer operator ^ (const Integer& x, const Integer& y) +{ + Integer r; xor(x, y, r); return r; +} + +inline Integer operator ^ (const Integer& x, long y) +{ + Integer r; xor(x, y, r); return r; +} + +inline Integer operator ^ (long x, const Integer& y) +{ + Integer r; xor(x, y, r); return r; +} + +inline Integer operator / (const Integer& x, const Integer& y) +{ + Integer r; div(x, y, r); return r; +} + +inline Integer operator / (const Integer& x, long y) +{ + Integer r; div(x, y, r); return r; +} + +inline Integer operator % (const Integer& x, const Integer& y) +{ + Integer r; mod(x, y, r); return r; +} + +inline Integer operator % (const Integer& x, long y) +{ + Integer r; mod(x, y, r); return r; +} + +inline Integer operator << (const Integer& x, const Integer& y) +{ + Integer r; lshift(x, y, r); return r; +} + +inline Integer operator << (const Integer& x, long y) +{ + Integer r; lshift(x, y, r); return r; +} + +inline Integer operator >> (const Integer& x, const Integer& y) +{ + Integer r; rshift(x, y, r); return r; +} + +inline Integer operator >> (const Integer& x, long y) +{ + Integer r; rshift(x, y, r); return r; +} + +inline Integer pow(const Integer& x, long y) +{ + Integer r; pow(x, y, r); return r; +} + +inline Integer Ipow(long x, long y) +{ + Integer r(x); pow(r, y, r); return r; +} + +inline Integer pow(const Integer& x, const Integer& y) +{ + Integer r; pow(x, y, r); return r; +} + + + +inline Integer abs(const Integer& x) +{ + Integer r; abs(x, r); return r; +} + +inline Integer operator - (const Integer& x) +{ + Integer r; negate(x, r); return r; +} + +inline Integer operator ~ (const Integer& x) +{ + Integer r; complement(x, r); return r; +} + +inline Integer atoI(const char* s, int base) +{ + Integer r; r.rep = atoIntRep(s, base); return r; +} + +inline Integer gcd(const Integer& x, const Integer& y) +{ + Integer r; r.rep = gcd(x.rep, y.rep); return r; +} + +#endif /* NO_NRV */ + +inline Integer& Integer::operator %= (const Integer& y) +{ + *this = *this % y; // mod(*this, y, *this) doesn't work. + return *this; +} + +inline Integer& Integer::operator %= (long y) +{ + *this = *this % y; // mod(*this, y, *this) doesn't work. + return *this; +} +#endif /* !_Integer_h */ diff --git a/gnu/lib/libg++/libg++/src/Integer.hP b/gnu/lib/libg++/libg++/src/Integer.hP new file mode 100644 index 00000000000..b8a80394265 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Integer.hP @@ -0,0 +1,30 @@ +// Stuff used to implement the Integer class. +// WARNING: Its internals WILL change! + +/* + Sizes of shifts for multiple-precision arithmetic. + These should not be changed unless Integer representation + as unsigned shorts is changed in the implementation files. +*/ + +#define I_SHIFT (sizeof(short) * CHAR_BIT) +#define I_RADIX ((unsigned long)(1L << I_SHIFT)) +#define I_MAXNUM ((unsigned long)((I_RADIX - 1))) +#define I_MINNUM ((unsigned long)(I_RADIX >> 1)) +#define I_POSITIVE 1 +#define I_NEGATIVE 0 + +/* All routines assume SHORT_PER_LONG > 1 */ +#define SHORT_PER_LONG ((unsigned)(((sizeof(long) + sizeof(short) - 1) / sizeof(short)))) +#define CHAR_PER_LONG ((unsigned)sizeof(long)) + +/* + minimum and maximum sizes for an IntRep +*/ + +#define MINIntRep_SIZE 16 +#define MAXIntRep_SIZE I_MAXNUM + +#ifndef MALLOC_MIN_OVERHEAD +#define MALLOC_MIN_OVERHEAD 4 +#endif diff --git a/gnu/lib/libg++/libg++/src/LogNorm.cc b/gnu/lib/libg++/libg++/src/LogNorm.cc new file mode 100644 index 00000000000..446a9fe7f84 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/LogNorm.cc @@ -0,0 +1,36 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +#include + +// +// See Simulation, Modelling & Analysis by Law & Kelton, pp260 +// +// + +double LogNormal::operator()() +{ + return exp (this->Normal::operator()() ); +} + + diff --git a/gnu/lib/libg++/libg++/src/LogNorm.h b/gnu/lib/libg++/libg++/src/LogNorm.h new file mode 100644 index 00000000000..18fc1f11d23 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/LogNorm.h @@ -0,0 +1,78 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _LogNormal_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _LogNormal_h + +#include + +class LogNormal: public Normal { +protected: + double logMean; + double logVariance; + void setState(); +public: + LogNormal(double mean, double variance, RNG *gen); + double mean(); + double mean(double x); + double variance(); + double variance(double x); + virtual double operator()(); +}; + + +inline void LogNormal::setState() +{ + double m2 = logMean * logMean; + pMean = log(m2 / sqrt(logVariance + m2) ); +// from ch@heike.informatik.uni-dortmund.de: +// (was pVariance = log((sqrt(logVariance + m2)/m2 )); ) + pStdDev = sqrt(log((logVariance + m2)/m2 )); +} + +inline LogNormal::LogNormal(double mean, double variance, RNG *gen) + : Normal(mean, variance, gen) +{ + logMean = mean; + logVariance = variance; + setState(); +} + +inline double LogNormal::mean() { + return logMean; +} + +inline double LogNormal::mean(double x) +{ + double t=logMean; logMean = x; setState(); + return t; +} + +inline double LogNormal::variance() { + return logVariance; +} + +inline double LogNormal::variance(double x) +{ + double t=logVariance; logVariance = x; setState(); + return t; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/MLCG.cc b/gnu/lib/libg++/libg++/src/MLCG.cc new file mode 100644 index 00000000000..8e624772f34 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/MLCG.cc @@ -0,0 +1,103 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 Free Software Foundation + +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 +// +// SEED_TABLE_SIZE must be a power of 2 +// + + +#define SEED_TABLE_SIZE 32 + +static _G_int32_t seedTable[SEED_TABLE_SIZE] = { +0xbdcc47e5, 0x54aea45d, 0xec0df859, 0xda84637b, +0xc8c6cb4f, 0x35574b01, 0x28260b7d, 0x0d07fdbf, +0x9faaeeb0, 0x613dd169, 0x5ce2d818, 0x85b9e706, +0xab2469db, 0xda02b0dc, 0x45c60d6e, 0xffe49d10, +0x7224fea3, 0xf9684fc9, 0xfc7ee074, 0x326ce92a, +0x366d13b5, 0x17aaa731, 0xeb83a675, 0x7781cb32, +0x4ec7c92d, 0x7f187521, 0x2cf346b4, 0xad13310f, +0xb89cff2b, 0x12164de1, 0xa865168d, 0x32b56cdf +}; + +MLCG::MLCG(_G_int32_t seed1, _G_int32_t seed2) +{ + initialSeedOne = seed1; + initialSeedTwo = seed2; + reset(); +} + +void +MLCG::reset() +{ + _G_int32_t seed1 = initialSeedOne; + _G_int32_t seed2 = initialSeedTwo; + + // + // Most people pick stupid seed numbers that do not have enough + // bits. In this case, if they pick a small seed number, we + // map that to a specific seed. + // + if (seed1 < 0) { + seed1 = (seed1 + 2147483561); + seed1 = (seed1 < 0) ? -seed1 : seed1; + } + + if (seed2 < 0) { + seed2 = (seed2 + 2147483561); + seed2 = (seed2 < 0) ? -seed2 : seed2; + } + + if (seed1 > -1 && seed1 < SEED_TABLE_SIZE) { + seedOne = seedTable[seed1]; + } else { + seedOne = seed1 ^ seedTable[seed1 & (SEED_TABLE_SIZE-1)]; + } + + if (seed2 > -1 && seed2 < SEED_TABLE_SIZE) { + seedTwo = seedTable[seed2]; + } else { + seedTwo = seed2 ^ seedTable[ seed2 & (SEED_TABLE_SIZE-1) ]; + } + seedOne = (seedOne % 2147483561) + 1; + seedTwo = (seedTwo % 2147483397) + 1; +} + +_G_uint32_t MLCG::asLong() +{ + _G_int32_t k = seedOne % 53668; + + seedOne = 40014 * (seedOne-k * 53668) - k * 12211; + if (seedOne < 0) { + seedOne += 2147483563; + } + + k = seedTwo % 52774; + seedTwo = 40692 * (seedTwo - k * 52774) - k * 3791; + if (seedTwo < 0) { + seedTwo += 2147483399; + } + + _G_int32_t z = seedOne - seedTwo; + if (z < 1) { + z += 2147483562; + } + return( (unsigned long) z); +} + diff --git a/gnu/lib/libg++/libg++/src/MLCG.h b/gnu/lib/libg++/libg++/src/MLCG.h new file mode 100644 index 00000000000..0ae817cd777 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/MLCG.h @@ -0,0 +1,87 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _MLCG_h +#define _MLCG_h 1 +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include + +// +// Multiplicative Linear Conguential Generator +// + +class MLCG : public RNG { + _G_int32_t initialSeedOne; + _G_int32_t initialSeedTwo; + _G_int32_t seedOne; + _G_int32_t seedTwo; + +protected: + +public: + MLCG(_G_int32_t seed1 = 0, _G_int32_t seed2 = 1); + // + // Return a long-words word of random bits + // + virtual _G_uint32_t asLong(); + virtual void reset(); + _G_int32_t seed1(); + void seed1(_G_int32_t); + _G_int32_t seed2(); + void seed2(_G_int32_t); + void reseed(_G_int32_t, _G_int32_t); +}; + +inline _G_int32_t +MLCG::seed1() +{ + return(seedOne); +} + +inline void +MLCG::seed1(_G_int32_t s) +{ + initialSeedOne = s; + reset(); +} + +inline _G_int32_t +MLCG::seed2() +{ + return(seedTwo); +} + +inline void +MLCG::seed2(_G_int32_t s) +{ + initialSeedTwo = s; + reset(); +} + +inline void +MLCG::reseed(_G_int32_t s1, _G_int32_t s2) +{ + initialSeedOne = s1; + initialSeedTwo = s2; + reset(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Makefile.in b/gnu/lib/libg++/libg++/src/Makefile.in new file mode 100644 index 00000000000..a161ad64801 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Makefile.in @@ -0,0 +1,75 @@ +# Makefile for libg++.a + +# Copyright (C) 1988, 1992, 1993 Free Software Foundation +# originally written by Doug Lea (dl@rocky.oswego.edu) + +# This file is part of libg++, the GNU C++ library. + +# GNU CC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY. No author or distributor +# accepts responsibility to anyone for the consequences of using it +# or for whether it serves any particular purpose or works at all, +# unless he says so in writing. Refer to the GNU CC General Public +# License for full details. + +# Everyone is granted permission to copy, modify and redistribute +# GNU CC, but only under the conditions described in the +# GNU CC General Public License. A copy of this license is +# supposed to have been given to you along with GNU CC so you +# can know your rights and responsibilities. It should be in a +# file named COPYING. Among other things, the copyright notice +# and this notice must be preserved on all copies. + +srcdir = . + +# +# declarations from here on should not normally need to be changed +# in order to compile libg++.a +# + +# library sources + +STREAM_OBJS = File.o ostream.o istream.o streambuf.o filebuf.o Filebuf.o \ + PlotFile.o SFile.o + +REGEX_OBJ= +BIT_OBJS = bitand.o bitany.o bitblt.o bitclear.o bitcopy.o bitcount.o\ + bitinvert.o bitlcomp.o bitset1.o bitxor.o +OBJS = AllocRing.o Obstack.o builtin.o \ + $(REGEX_OBJ) Regex.o String.o Intdouble.o Integer.o Rational.o \ + Random.o BitSet.o BitString.o LogNorm.o SmplHist.o SmplStat.o \ + Normal.o NegExp.o Weibull.o Erlang.o DiscUnif.o \ + Uniform.o Poisson.o HypGeom.o Geom.o Binomial.o \ + RNG.o ACG.o MLCG.o RndInt.o \ + Fix.o Fix16.o Fix24.o CursesW.o GetOpt.o \ + chr.o error.o gcd.o hash.o \ + lg.o fmtq.o ioob.o pow.o sqrt.o str.o timer.o \ + compare.o $(BIT_OBJS) \ + SLList.o DLList.o + +DEPEND_SOURCES = $(srcdir)/*.cc + +#### host, target, and site dependent Makefile fragments come in here. +## + +.PHONY: add-to-targetlib +# Invoked from other directories, overriding $(TARGETLIB). +add-to-targetlib: + $(AR) $(AR_FLAGS) $(TARGETLIB) $(OBJS) + +# This is invoked by the top-level libg++ Makefile, to: +# a) make sure $(OBJS) are up-to-date, and +# b) make a list of those files that should be added to libg++.a. +libgxx.list: stamp-picdir $(OBJS) + @echo "$(OBJS)" >libgxx.list + +install: + if [ -z "$(MULTISUBDIR)" ]; then \ + for FILE in `(cd ${srcdir}; echo *.h gen/*.ccP gen/*.hP)`; do \ + rm -f $(gxx_includedir)/$$FILE ; \ + $(INSTALL_DATA) ${srcdir}/$$FILE $(gxx_includedir)/$$FILE \ + || exit 1; \ + chmod a-x,a+r $(gxx_includedir)/$$FILE ; \ + done ; \ + else true ; \ + fi diff --git a/gnu/lib/libg++/libg++/src/NegExp.cc b/gnu/lib/libg++/libg++/src/NegExp.cc new file mode 100644 index 00000000000..f07769aff60 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/NegExp.cc @@ -0,0 +1,28 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double NegativeExpntl::operator()() +{ + return(-pMean * log(pGenerator -> asDouble())); +} + diff --git a/gnu/lib/libg++/libg++/src/NegExp.h b/gnu/lib/libg++/libg++/src/NegExp.h new file mode 100644 index 00000000000..08f17afde95 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/NegExp.h @@ -0,0 +1,55 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _NegativeExpntl_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _NegativeExpntl_h 1 + + +// +// Negative Exponential Random Numbers +// +// + +#include + +class NegativeExpntl: public Random { +protected: + double pMean; +public: + NegativeExpntl(double xmean, RNG *gen); + double mean(); + double mean(double x); + + virtual double operator()(); +}; + + +inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen) +: Random(gen) { + pMean = xmean; +} + +inline double NegativeExpntl::mean() { return pMean; } +inline double NegativeExpntl::mean(double x) { + double t = pMean; pMean = x; + return t; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Normal.cc b/gnu/lib/libg++/libg++/src/Normal.cc new file mode 100644 index 00000000000..29219b4a730 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Normal.cc @@ -0,0 +1,60 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include +// +// See Simulation, Modelling & Analysis by Law & Kelton, pp259 +// +// This is the ``polar'' method. +// + +double Normal::operator()() +{ + + if (haveCachedNormal == 1) { + haveCachedNormal = 0; + return(cachedNormal * pStdDev + pMean ); + } else { + + for(;;) { + double u1 = pGenerator -> asDouble(); + double u2 = pGenerator -> asDouble(); + double v1 = 2 * u1 - 1; + double v2 = 2 * u2 - 1; + double w = (v1 * v1) + (v2 * v2); + +// +// We actually generate two IID normal distribution variables. +// We cache the one & return the other. +// + if (w <= 1) { + double y = sqrt( (-2 * log(w)) / w); + double x1 = v1 * y; + double x2 = v2 * y; + + haveCachedNormal = 1; + cachedNormal = x2; + return(x1 * pStdDev + pMean); + } + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/Normal.h b/gnu/lib/libg++/libg++/src/Normal.h new file mode 100644 index 00000000000..5e19f7ae606 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Normal.h @@ -0,0 +1,66 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Normal_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Normal_h + +#include + +class Normal: public Random { + char haveCachedNormal; + double cachedNormal; + +protected: + double pMean; + double pVariance; + double pStdDev; + +public: + Normal(double xmean, double xvariance, RNG *gen); + double mean(); + double mean(double x); + double variance(); + double variance(double x); + virtual double operator()(); +}; + + +inline Normal::Normal(double xmean, double xvariance, RNG *gen) +: Random(gen) { + pMean = xmean; + pVariance = xvariance; + pStdDev = sqrt(pVariance); + haveCachedNormal = 0; +} + +inline double Normal::mean() { return pMean; }; +inline double Normal::mean(double x) { + double t=pMean; pMean = x; + return t; +} + +inline double Normal::variance() { return pVariance; } +inline double Normal::variance(double x) { + double t=pVariance; pVariance = x; + pStdDev = sqrt(pVariance); + return t; +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/Obstack.cc b/gnu/lib/libg++/libg++/src/Obstack.cc new file mode 100644 index 00000000000..abef732979f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Obstack.cc @@ -0,0 +1,127 @@ +/* +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 +#include +#include +#include + +/* 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 + +Obstack::Obstack(int size, int alignment) +{ + alignmentmask = alignment - 1; + chunksize = size; + chunk = 0; + nextfree = objectbase = 0; + chunklimit = 0; +} + +void Obstack::_free(void* obj) +{ + _obstack_chunk* lp; + _obstack_chunk* plp; + + lp = chunk; + while (lp != 0 && ((void*)lp > obj || (void*)(lp)->limit < obj)) + { + plp = lp -> prev; + delete [] (char*)lp; + lp = plp; + } + if (lp) + { + objectbase = nextfree = (char *)(obj); + chunklimit = lp->limit; + chunk = lp; + } + else if (obj != 0) + (*lib_error_handler)("Obstack", "deletion of nonexistent obj"); +} + +void Obstack::newchunk(int size) +{ + _obstack_chunk* old_chunk = chunk; + _obstack_chunk* new_chunk; + long new_size; + int obj_size = nextfree - objectbase; + + new_size = (obj_size + size) << 1; + if (new_size < chunksize) + new_size = chunksize; + + new_chunk = chunk = new (operator new (new_size)) _obstack_chunk; + new_chunk->prev = old_chunk; + new_chunk->limit = chunklimit = (char *) new_chunk + new_size; + + memcpy((void*)new_chunk->contents, (void*)objectbase, obj_size); + objectbase = new_chunk->contents; + nextfree = objectbase + obj_size; +} + +void* Obstack::finish() +{ + void* value = (void*) objectbase; + nextfree = __INT_TO_PTR (__PTR_TO_INT (nextfree + alignmentmask) + & ~alignmentmask); + if (nextfree - (char*)chunk > chunklimit - (char*)chunk) + nextfree = chunklimit; + objectbase = nextfree; + return value; +} + +int Obstack::contains(void* obj) // true if obj somewhere in Obstack +{ + _obstack_chunk* ch; + for (ch = chunk; + ch != 0 && (obj < (void*)ch || obj >= (void*)(ch->limit)); + ch = ch->prev); + + return ch != 0; +} + +int Obstack::OK() +{ + int v = chunksize > 0; // valid size + v &= alignmentmask != 0; // and alignment + v &= chunk != 0; + v &= objectbase >= chunk->contents; + v &= nextfree >= objectbase; + v &= nextfree <= chunklimit; + v &= chunklimit == chunk->limit; + _obstack_chunk* p = chunk; + // allow lots of chances to find bottom! + long x = LONG_MAX; + while (p != 0 && x != 0) { --x; p = p->prev; } + v &= x > 0; + if (!v) + (*lib_error_handler)("Obstack", "invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/Obstack.h b/gnu/lib/libg++/libg++/src/Obstack.h new file mode 100644 index 00000000000..8dd9d09c91b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Obstack.h @@ -0,0 +1,218 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Obstack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Obstack_h 1 + +#include + +#undef OK + +class Obstack +{ + struct _obstack_chunk + { + char* limit; + _obstack_chunk* prev; + char contents[4]; + }; + +protected: + long chunksize; + _obstack_chunk* chunk; + char* objectbase; + char* nextfree; + char* chunklimit; + int alignmentmask; + + void _free(void* obj); + void newchunk(int size); + +public: + Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop + + ~Obstack(); + + void* base(); + void* next_free(); + int alignment_mask(); + int chunk_size(); + int size(); + int room(); + int contains(void* p); // does Obstack hold pointer p? + + void grow(const void* data, int size); + void grow(const void* data, int size, char terminator); + void grow(const char* s); + void grow(char c); + void grow_fast(char c); + void blank(int size); + void blank_fast(int size); + + void* finish(); + void* finish(char terminator); + + void* copy(const void* data, int size); + void* copy(const void* data, int size, char terminator); + void* copy(const char* s); + void* copy(char c); + void* alloc(int size); + + void free(void* obj); + void shrink(int size = 1); // suggested by ken@cs.rochester.edu + + int OK(); // rep invariant +}; + + +inline Obstack::~Obstack() +{ + _free(0); +} + +inline void* Obstack::base() +{ + return objectbase; +} + +inline void* Obstack::next_free() +{ + return nextfree; +} + +inline int Obstack::alignment_mask() +{ + return alignmentmask; +} + +inline int Obstack::chunk_size() +{ + return chunksize; +} + +inline int Obstack::size() +{ + return nextfree - objectbase; +} + +inline int Obstack::room() +{ + return chunklimit - nextfree; +} + +inline void Obstack:: grow(const void* data, int size) +{ + if (nextfree+size > chunklimit) + newchunk(size); + memcpy(nextfree, data, size); + nextfree += size; +} + +inline void Obstack:: grow(const void* data, int size, char terminator) +{ + if (nextfree+size+1 > chunklimit) + newchunk(size+1); + memcpy(nextfree, data, size); + nextfree += size; + *(nextfree)++ = terminator; +} + +inline void Obstack:: grow(const char* s) +{ + grow((const void*)s, strlen(s), 0); +} + +inline void Obstack:: grow(char c) +{ + if (nextfree+1 > chunklimit) + newchunk(1); + *(nextfree)++ = c; +} + +inline void Obstack:: blank(int size) +{ + if (nextfree+size > chunklimit) + newchunk(size); + nextfree += size; +} + +inline void* Obstack::finish(char terminator) +{ + grow(terminator); + return finish(); +} + +inline void* Obstack::copy(const void* data, int size) +{ + grow (data, size); + return finish(); +} + +inline void* Obstack::copy(const void* data, int size, char terminator) +{ + grow(data, size, terminator); + return finish(); +} + +inline void* Obstack::copy(const char* s) +{ + grow((const void*)s, strlen(s), 0); + return finish(); +} + +inline void* Obstack::copy(char c) +{ + grow(c); + return finish(); +} + +inline void* Obstack::alloc(int size) +{ + blank(size); + return finish(); +} + +inline void Obstack:: free(void* obj) +{ + if (obj >= (void*)chunk && obj<(void*)chunklimit) + nextfree = objectbase = (char *) obj; + else + _free(obj); +} + +inline void Obstack:: grow_fast(char c) +{ + *(nextfree)++ = c; +} + +inline void Obstack:: blank_fast(int size) +{ + nextfree += size; +} + +inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu +{ + if (nextfree >= objectbase + size) + nextfree -= size; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Pix.h b/gnu/lib/libg++/libg++/src/Pix.h new file mode 100644 index 00000000000..be90525c631 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Pix.h @@ -0,0 +1,5 @@ + +#ifndef _Pix_h +#define _Pix_h 1 +typedef void* Pix; +#endif diff --git a/gnu/lib/libg++/libg++/src/Poisson.cc b/gnu/lib/libg++/libg++/src/Poisson.cc new file mode 100644 index 00000000000..b7fac8f5ca3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Poisson.cc @@ -0,0 +1,36 @@ + +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double Poisson::operator()() +{ + double bound = exp(-1.0 * pMean); + int count = 0; + + for (double product = 1.0; + product >= bound; + product *= pGenerator -> asDouble()) { + count++; + } + return(count - 1); +} diff --git a/gnu/lib/libg++/libg++/src/Poisson.h b/gnu/lib/libg++/libg++/src/Poisson.h new file mode 100644 index 00000000000..2566de5aa50 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Poisson.h @@ -0,0 +1,51 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Poisson_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Poisson_h + +#include + +class Poisson: public Random { +protected: + double pMean; +public: + Poisson(double mean, RNG *gen); + + double mean(); + double mean(double x); + + virtual double operator()(); +}; + + +inline Poisson::Poisson(double mean, RNG *gen) +: Random(gen) { + pMean = mean; +} + +inline double Poisson::mean() { return pMean; } +inline double Poisson::mean(double x) { + double t = pMean; + pMean = x; + return t; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/RNG.cc b/gnu/lib/libg++/libg++/src/RNG.cc new file mode 100644 index 00000000000..81f55a07f8c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/RNG.cc @@ -0,0 +1,131 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1989 Free Software Foundation + +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 +#include +#include + +// These two static fields get initialized by RNG::RNG(). +PrivateRNGSingleType RNG::singleMantissa; +PrivateRNGDoubleType RNG::doubleMantissa; + +// +// The scale constant is 2^-31. It is used to scale a 31 bit +// long to a double. +// + +//static const double randomDoubleScaleConstant = 4.656612873077392578125e-10; +//static const float randomFloatScaleConstant = 4.656612873077392578125e-10; + +static char initialized = 0; + +RNG::RNG() +{ + if (!initialized) + { + + assert (sizeof(double) == 2 * sizeof(_G_uint32_t)); + + // + // The following is a hack that I attribute to + // Andres Nowatzyk at CMU. The intent of the loop + // is to form the smallest number 0 <= x < 1.0, + // which is then used as a mask for two longwords. + // this gives us a fast way way to produce double + // precision numbers from longwords. + // + // I know that this works for IEEE and VAX floating + // point representations. + // + // A further complication is that gnu C will blow + // the following loop, unless compiled with -ffloat-store, + // because it uses extended representations for some of + // of the comparisons. Thus, we have the following hack. + // If we could specify #pragma optimize, we wouldn't need this. + // + + PrivateRNGDoubleType t; + PrivateRNGSingleType s; + +#if _IEEE == 1 + + t.d = 1.5; + if ( t.u[1] == 0 ) { // sun word order? + t.u[0] = 0x3fffffff; + t.u[1] = 0xffffffff; + } + else { + t.u[0] = 0xffffffff; // encore word order? + t.u[1] = 0x3fffffff; + } + + s.u = 0x3fffffff; +#else + volatile double x = 1.0; // volatile needed when fp hardware used, + // and has greater precision than memory doubles + double y = 0.5; + do { // find largest fp-number < 2.0 + t.d = x; + x += y; + y *= 0.5; + } while (x != t.d && x < 2.0); + + volatile float xx = 1.0; // volatile needed when fp hardware used, + // and has greater precision than memory floats + float yy = 0.5; + do { // find largest fp-number < 2.0 + s.s = xx; + xx += yy; + yy *= 0.5; + } while (xx != s.s && xx < 2.0); +#endif + // set doubleMantissa to 1 for each doubleMantissa bit + doubleMantissa.d = 1.0; + doubleMantissa.u[0] ^= t.u[0]; + doubleMantissa.u[1] ^= t.u[1]; + + // set singleMantissa to 1 for each singleMantissa bit + singleMantissa.s = 1.0; + singleMantissa.u ^= s.u; + + initialized = 1; + } +} + +float RNG::asFloat() +{ + PrivateRNGSingleType result; + result.s = 1.0; + result.u |= (asLong() & singleMantissa.u); + result.s -= 1.0; + assert( result.s < 1.0 && result.s >= 0); + return( result.s ); +} + +double RNG::asDouble() +{ + PrivateRNGDoubleType result; + result.d = 1.0; + result.u[0] |= (asLong() & doubleMantissa.u[0]); + result.u[1] |= (asLong() & doubleMantissa.u[1]); + result.d -= 1.0; + assert( result.d < 1.0 && result.d >= 0); + return( result.d ); +} + diff --git a/gnu/lib/libg++/libg++/src/RNG.h b/gnu/lib/libg++/libg++/src/RNG.h new file mode 100644 index 00000000000..cb3fbfb1732 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/RNG.h @@ -0,0 +1,58 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _RNG_h +#define _RNG_h 1 +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include +#include <_G_config.h> + +union PrivateRNGSingleType { // used to access floats as unsigneds + float s; + _G_uint32_t u; +}; + +union PrivateRNGDoubleType { // used to access doubles as unsigneds + double d; + _G_uint32_t u[2]; +}; + +// +// Base class for Random Number Generators. See ACG and MLCG for instances. +// +class RNG { + static PrivateRNGSingleType singleMantissa; // mantissa bit vector + static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector +public: + RNG(); + // + // Return a long-words word of random bits + // + virtual _G_uint32_t asLong() = 0; + virtual void reset() = 0; + // + // Return random bits converted to either a float or a double + // + float asFloat(); + double asDouble(); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/Random.cc b/gnu/lib/libg++/libg++/src/Random.cc new file mode 100644 index 00000000000..572a602cf7a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Random.cc @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include diff --git a/gnu/lib/libg++/libg++/src/Random.h b/gnu/lib/libg++/libg++/src/Random.h new file mode 100644 index 00000000000..2a6d0ee54a3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Random.h @@ -0,0 +1,54 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Random_h +#define _Random_h 1 +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include + +class Random { +protected: + RNG *pGenerator; +public: + Random(RNG *generator); + virtual double operator()() = 0; + + RNG *generator(); + void generator(RNG *p); +}; + + +inline Random::Random(RNG *gen) +{ + pGenerator = gen; +} + +inline RNG *Random::generator() +{ + return(pGenerator); +} + +inline void Random::generator(RNG *p) +{ + pGenerator = p; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Rational.cc b/gnu/lib/libg++/libg++/src/Rational.cc new file mode 100644 index 00000000000..07bcd4f1d17 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Rational.cc @@ -0,0 +1,416 @@ +/* +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 +#include +#include +#include +#include + +#undef OK + +void Rational::error(const char* msg) const +{ + (*lib_error_handler)("Rational", msg); +} + +static const Integer _Int_One(1); + +void Rational::normalize() +{ + int s = sign(den); + if (s == 0) + error("Zero denominator."); + else if (s < 0) + { + den.negate(); + num.negate(); + } + + Integer g = gcd(num, den); + if (ucompare(g, _Int_One) != 0) + { + num /= g; + den /= g; + } +} + +void add(const Rational& x, const Rational& y, Rational& r) +{ + if (&r != &x && &r != &y) + { + mul(x.num, y.den, r.num); + mul(x.den, y.num, r.den); + add(r.num, r.den, r.num); + mul(x.den, y.den, r.den); + } + else + { + Integer tmp; + mul(x.den, y.num, tmp); + mul(x.num, y.den, r.num); + add(r.num, tmp, r.num); + mul(x.den, y.den, r.den); + } + r.normalize(); +} + +void sub(const Rational& x, const Rational& y, Rational& r) +{ + if (&r != &x && &r != &y) + { + mul(x.num, y.den, r.num); + mul(x.den, y.num, r.den); + sub(r.num, r.den, r.num); + mul(x.den, y.den, r.den); + } + else + { + Integer tmp; + mul(x.den, y.num, tmp); + mul(x.num, y.den, r.num); + sub(r.num, tmp, r.num); + mul(x.den, y.den, r.den); + } + r.normalize(); +} + +void mul(const Rational& x, const Rational& y, Rational& r) +{ + mul(x.num, y.num, r.num); + mul(x.den, y.den, r.den); + r.normalize(); +} + +void div(const Rational& x, const Rational& y, Rational& r) +{ + if (&r != &x && &r != &y) + { + mul(x.num, y.den, r.num); + mul(x.den, y.num, r.den); + } + else + { + Integer tmp; + mul(x.num, y.den, tmp); + mul(y.num, x.den, r.den); + r.num = tmp; + } + r.normalize(); +} + + + + +void Rational::invert() +{ + Integer tmp = num; + num = den; + den = tmp; + int s = sign(den); + if (s == 0) + error("Zero denominator."); + else if (s < 0) + { + den.negate(); + num.negate(); + } +} + +int compare(const Rational& x, const Rational& y) +{ + int xsgn = sign(x.num); + int ysgn = sign(y.num); + int d = xsgn - ysgn; + if (d == 0 && xsgn != 0) d = compare(x.num * y.den, x.den * y.num); + return d; +} + +Rational::Rational(double x) +{ + num = 0; + den = 1; + if (x != 0.0) + { + int neg = x < 0; + if (neg) + x = -x; + + const long shift = 15; // a safe shift per step + const double width = 32768.0; // = 2^shift + const int maxiter = 20; // ought not be necessary, but just in case, + // max 300 bits of precision + int expt; + double mantissa = frexp(x, &expt); + long exponent = expt; + double intpart; + int k = 0; + while (mantissa != 0.0 && k++ < maxiter) + { + mantissa *= width; + mantissa = modf(mantissa, &intpart); + num <<= shift; + num += (long)intpart; + exponent -= shift; + } + if (exponent > 0) + num <<= exponent; + else if (exponent < 0) + den <<= -exponent; + if (neg) + num.negate(); + } + normalize(); +} + + +Integer trunc(const Rational& x) +{ + return x.num / x.den ; +} + + +Rational pow(const Rational& x, const Integer& y) +{ + long yy = y.as_long(); + return pow(x, yy); +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +Rational operator - (const Rational& x) return r(x) +{ + r.negate(); +} + +Rational abs(const Rational& x) return r(x) +{ + if (sign(r.num) < 0) r.negate(); +} + + +Rational sqr(const Rational& x) return r +{ + mul(x.num, x.num, r.num); + mul(x.den, x.den, r.den); + r.normalize(); +} + +Integer floor(const Rational& x) return q +{ + Integer r; + divide(x.num, x.den, q, r); + if (sign(x.num) < 0 && sign(r) != 0) --q; +} + +Integer ceil(const Rational& x) return q +{ + Integer r; + divide(x.num, x.den, q, r); + if (sign(x.num) >= 0 && sign(r) != 0) ++q; +} + +Integer round(const Rational& x) return q +{ + Integer r; + divide(x.num, x.den, q, r); + r <<= 1; + if (ucompare(r, x.den) >= 0) + { + if (sign(x.num) >= 0) + ++q; + else + --q; + } +} + +// power: no need to normalize since num & den already relatively prime + +Rational pow(const Rational& x, long y) return r +{ + if (y >= 0) + { + pow(x.num, y, r.num); + pow(x.den, y, r.den); + } + else + { + y = -y; + pow(x.num, y, r.den); + pow(x.den, y, r.num); + if (sign(r.den) < 0) + { + r.num.negate(); + r.den.negate(); + } + } +} + +#else + +Rational operator - (const Rational& x) +{ + Rational r(x); r.negate(); return r; +} + +Rational abs(const Rational& x) +{ + Rational r(x); + if (sign(r.num) < 0) r.negate(); + return r; +} + + +Rational sqr(const Rational& x) +{ + Rational r; + mul(x.num, x.num, r.num); + mul(x.den, x.den, r.den); + r.normalize(); + return r; +} + +Integer floor(const Rational& x) +{ + Integer q; + Integer r; + divide(x.num, x.den, q, r); + if (sign(x.num) < 0 && sign(r) != 0) --q; + return q; +} + +Integer ceil(const Rational& x) +{ + Integer q; + Integer r; + divide(x.num, x.den, q, r); + if (sign(x.num) >= 0 && sign(r) != 0) ++q; + return q; +} + +Integer round(const Rational& x) +{ + Integer q; + Integer r; + divide(x.num, x.den, q, r); + r <<= 1; + if (ucompare(r, x.den) >= 0) + { + if (sign(x.num) >= 0) + ++q; + else + --q; + } + return q; +} + +Rational pow(const Rational& x, long y) +{ + Rational r; + if (y >= 0) + { + pow(x.num, y, r.num); + pow(x.den, y, r.den); + } + else + { + y = -y; + pow(x.num, y, r.den); + pow(x.den, y, r.num); + if (sign(r.den) < 0) + { + r.num.negate(); + r.den.negate(); + } + } + return r; +} + +#endif + +ostream& operator << (ostream& s, const Rational& y) +{ + if (y.denominator() == 1L) + s << y.numerator(); + else + { + s << y.numerator(); + s << "/"; + s << y.denominator(); + } + return s; +} + +istream& operator >> (istream& s, Rational& y) +{ +#ifdef _OLD_STREAMS + if (!s.good()) + { + return s; + } +#else + if (!s.ipfx(0)) + { + s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams. + return s; + } +#endif + Integer n = 0; + Integer d = 1; + if (s >> n) + { + char ch = 0; + s.get(ch); + if (ch == '/') + { + s >> d; + } + else + { + s.putback(ch); + } + } + y = Rational(n, d); + return s; +} + +int Rational::OK() const +{ + int v = num.OK() && den.OK(); // have valid num and denom + if (v) + { + v &= sign(den) > 0; // denominator positive; + v &= ucompare(gcd(num, den), _Int_One) == 0; // relatively prime + } + if (!v) error("invariant failure"); + return v; +} + +int +Rational::fits_in_float() const +{ + return Rational (FLT_MIN) <= *this && *this <= Rational (FLT_MAX); +} + +int +Rational::fits_in_double() const +{ + return Rational (DBL_MIN) <= *this && *this <= Rational (DBL_MAX); +} diff --git a/gnu/lib/libg++/libg++/src/Rational.h b/gnu/lib/libg++/libg++/src/Rational.h new file mode 100644 index 00000000000..6542c49f9e4 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Rational.h @@ -0,0 +1,290 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +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. +*/ + +#ifndef _Rational_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Rational_h 1 + +#include +#include + +#undef OK + +class Rational +{ +protected: + Integer num; + Integer den; + + void normalize(); + +public: + Rational(); + Rational(double); + Rational(int n); + Rational(long n); + Rational(int n, int d); + Rational(long n, long d); + Rational(long n, unsigned long d); + Rational(unsigned long n, long d); + Rational(unsigned long n, unsigned long d); + Rational(const Integer& n); + Rational(const Integer& n, const Integer& d); + Rational(const Rational&); + + ~Rational(); + + Rational& operator = (const Rational& y); + + friend int operator == (const Rational& x, const Rational& y); + friend int operator != (const Rational& x, const Rational& y); + friend int operator < (const Rational& x, const Rational& y); + friend int operator <= (const Rational& x, const Rational& y); + friend int operator > (const Rational& x, const Rational& y); + friend int operator >= (const Rational& x, const Rational& y); + + friend Rational operator + (const Rational& x, const Rational& y); + friend Rational operator - (const Rational& x, const Rational& y); + friend Rational operator * (const Rational& x, const Rational& y); + friend Rational operator / (const Rational& x, const Rational& y); + + Rational& operator += (const Rational& y); + Rational& operator -= (const Rational& y); + Rational& operator *= (const Rational& y); + Rational& operator /= (const Rational& y); + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) + friend Rational operator ? (const Rational& x, const Rational& y); // max +#endif + + friend Rational operator - (const Rational& x); + + +// builtin Rational functions + + + void negate(); // x = -x + void invert(); // x = 1/x + + friend int sign(const Rational& x); // -1, 0, or +1 + friend Rational abs(const Rational& x); // absolute value + friend Rational sqr(const Rational& x); // square + friend Rational pow(const Rational& x, long y); + friend Rational pow(const Rational& x, const Integer& y); + const Integer& numerator() const; + const Integer& denominator() const; + +// coercion & conversion + + operator double() const; + friend Integer floor(const Rational& x); + friend Integer ceil(const Rational& x); + friend Integer trunc(const Rational& x); + friend Integer round(const Rational& x); + + friend istream& operator >> (istream& s, Rational& y); + friend ostream& operator << (ostream& s, const Rational& y); + + int fits_in_float() const; + int fits_in_double() const; + +// procedural versions of operators + + friend int compare(const Rational& x, const Rational& y); + friend void add(const Rational& x, const Rational& y, Rational& dest); + friend void sub(const Rational& x, const Rational& y, Rational& dest); + friend void mul(const Rational& x, const Rational& y, Rational& dest); + friend void div(const Rational& x, const Rational& y, Rational& dest); + +// error detection + + void error(const char* msg) const; + int OK() const; + +}; + +typedef Rational RatTmp; // backwards compatibility + +inline Rational::Rational() : num(&_ZeroRep), den(&_OneRep) {} +inline Rational::~Rational() {} + +inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {} + +inline Rational::Rational(const Integer& n) :num(n), den(&_OneRep) {} + +inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d) +{ + normalize(); +} + +inline Rational::Rational(long n) :num(n), den(&_OneRep) { } + +inline Rational::Rational(int n) :num(n), den(&_OneRep) { } + +inline Rational::Rational(long n, long d) :num(n), den(d) { normalize(); } +inline Rational::Rational(int n, int d) :num(n), den(d) { normalize(); } +inline Rational::Rational(long n, unsigned long d) :num(n), den(d) +{ + normalize(); +} +inline Rational::Rational(unsigned long n, long d) :num(n), den(d) +{ + normalize(); +} +inline Rational::Rational(unsigned long n, unsigned long d) :num(n), den(d) +{ + normalize(); +} + +inline Rational& Rational::operator = (const Rational& y) +{ + num = y.num; den = y.den; + return *this; +} + +inline int operator == (const Rational& x, const Rational& y) +{ + return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0; +} + +inline int operator != (const Rational& x, const Rational& y) +{ + return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0; +} + +inline int operator < (const Rational& x, const Rational& y) +{ + return compare(x, y) < 0; +} + +inline int operator <= (const Rational& x, const Rational& y) +{ + return compare(x, y) <= 0; +} + +inline int operator > (const Rational& x, const Rational& y) +{ + return compare(x, y) > 0; +} + +inline int operator >= (const Rational& x, const Rational& y) +{ + return compare(x, y) >= 0; +} + +inline int sign(const Rational& x) +{ + return sign(x.num); +} + +inline void Rational::negate() +{ + num.negate(); +} + + +inline Rational& Rational::operator += (const Rational& y) +{ + add(*this, y, *this); + return *this; +} + +inline Rational& Rational::operator -= (const Rational& y) +{ + sub(*this, y, *this); + return *this; +} + +inline Rational& Rational::operator *= (const Rational& y) +{ + mul(*this, y, *this); + return *this; +} + +inline Rational& Rational::operator /= (const Rational& y) +{ + div(*this, y, *this); + return *this; +} + +inline const Integer& Rational::numerator() const { return num; } +inline const Integer& Rational::denominator() const { return den; } +inline Rational::operator double() const { return ratio(num, den); } + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) +inline Rational operator ? (const Rational& x, const Rational& y) +{ + if (compare(x, y) >= 0) return x; else return y; +} +#endif + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +inline Rational operator + (const Rational& x, const Rational& y) return r +{ + add(x, y, r); +} + +inline Rational operator - (const Rational& x, const Rational& y) return r +{ + sub(x, y, r); +} + +inline Rational operator * (const Rational& x, const Rational& y) return r +{ + mul(x, y, r); +} + +inline Rational operator / (const Rational& x, const Rational& y) return r +{ + div(x, y, r); +} + +#else /* NO_NRV */ + +inline Rational operator + (const Rational& x, const Rational& y) +{ + Rational r; add(x, y, r); return r; +} + +inline Rational operator - (const Rational& x, const Rational& y) +{ + Rational r; sub(x, y, r); return r; +} + +inline Rational operator * (const Rational& x, const Rational& y) +{ + Rational r; mul(x, y, r); return r; +} + +inline Rational operator / (const Rational& x, const Rational& y) +{ + Rational r; div(x, y, r); return r; +} +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/src/Regex.cc b/gnu/lib/libg++/libg++/src/Regex.cc new file mode 100644 index 00000000000..1c27dd0e028 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Regex.cc @@ -0,0 +1,140 @@ +/* +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. +*/ + +/* + Regex class implementation + */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include + +extern "C" { +#if 1 +#include +#else +#include +#endif +} + +#include + +Regex::~Regex() +{ + if (buf->buffer) free(buf->buffer); + if (buf->fastmap) free(buf->fastmap); + delete(buf); + delete(reg); +} + +Regex::Regex(const char* t, int fast, int bufsize, + const char* transtable) +{ + int tlen = (t == 0)? 0 : strlen(t); + buf = new re_pattern_buffer; + memset (buf, 0, sizeof(re_pattern_buffer)); + reg = new re_registers; + if (fast) + buf->fastmap = (char*)malloc(256); + else + buf->fastmap = 0; + buf->translate = (unsigned char*)transtable; + if (tlen > bufsize) + bufsize = tlen; + buf->allocated = bufsize; + buf->buffer = (char *)malloc(buf->allocated); + const char* msg = re_compile_pattern((const char*)t, tlen, buf); + if (msg != 0) + (*lib_error_handler)("Regex", msg); + else if (fast) + re_compile_fastmap(buf); +} + +int Regex::match_info(int& start, int& length, int nth) const +{ + if ((unsigned)(nth) >= RE_NREGS) + return 0; + else + { + start = reg->start[nth]; + length = reg->end[nth] - start; + return start >= 0 && length >= 0; + } +} + +int Regex::search(const char* s, int len, int& matchlen, int startpos) const +{ + int matchpos, pos, range; + if (startpos >= 0) + { + pos = startpos; + range = len - startpos; + } + else + { + pos = len + startpos; + range = -pos; + } + matchpos = re_search_2(buf, 0, 0, (char*)s, len, pos, range, reg, len); + if (matchpos >= 0) + matchlen = reg->end[0] - reg->start[0]; + else + matchlen = 0; + return matchpos; +} + +int Regex::match(const char*s, int len, int p) const +{ + if (p < 0) + { + p += len; + if (p > len) + return -1; + return re_match_2(buf, 0, 0, (char*)s, p, 0, reg, p); + } + else if (p > len) + return -1; + else + return re_match_2(buf, 0, 0, (char*)s, len, p, reg, len); +} + +int Regex::OK() const +{ +// can't verify much, since we've lost the original string + int v = buf != 0; // have a regex buf + v &= buf->buffer != 0; // with a pat + if (!v) (*lib_error_handler)("Regex", "invariant failure"); + return v; +} + +/* + some built-in Regular expressions +*/ + +const Regex RXwhite("[ \n\t\r\v\f]+", 1); +const Regex RXint("-?[0-9]+", 1); +const Regex RXdouble("-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?", 1, 200); +const Regex RXalpha("[A-Za-z]+", 1); +const Regex RXlowercase("[a-z]+", 1); +const Regex RXuppercase("[A-Z]+", 1); +const Regex RXalphanum("[0-9A-Za-z]+", 1); +const Regex RXidentifier("[A-Za-z_][A-Za-z0-9_]*", 1); + diff --git a/gnu/lib/libg++/libg++/src/Regex.h b/gnu/lib/libg++/libg++/src/Regex.h new file mode 100644 index 00000000000..47f9a853a33 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Regex.h @@ -0,0 +1,78 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Regex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Regex_h 1 + +#undef OK + +#if defined(SHORT_NAMES) || defined(VMS) +#define re_compile_pattern recmppat +#define re_pattern_buffer repatbuf +#define re_registers reregs +#endif + +struct re_pattern_buffer; // defined elsewhere +struct re_registers; + +class Regex +{ +private: + + Regex(const Regex&) {} // no X(X&) + void operator = (const Regex&) {} // no assignment + +protected: + re_pattern_buffer* buf; + re_registers* reg; + +public: + Regex(const char* t, + int fast = 0, + int bufsize = 40, + const char* transtable = 0); + + ~Regex(); + + int match(const char* s, int len, int pos = 0) const; + int search(const char* s, int len, + int& matchlen, int startpos = 0) const; + int match_info(int& start, int& length, int nth = 0) const; + + int OK() const; // representation invariant +}; + +// some built in regular expressions + +extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" +extern const Regex RXint; // = "-?[0-9]+" +extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| + // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) + // \\([eE][---+]?[0-9]+\\)?" +extern const Regex RXalpha; // = "[A-Za-z]+" +extern const Regex RXlowercase; // = "[a-z]+" +extern const Regex RXuppercase; // = "[A-Z]+" +extern const Regex RXalphanum; // = "[0-9A-Za-z]+" +extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" + + +#endif diff --git a/gnu/lib/libg++/libg++/src/RndInt.cc b/gnu/lib/libg++/libg++/src/RndInt.cc new file mode 100644 index 00000000000..c09f1e504d3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/RndInt.cc @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include diff --git a/gnu/lib/libg++/libg++/src/RndInt.h b/gnu/lib/libg++/libg++/src/RndInt.h new file mode 100644 index 00000000000..7a73aee1c0b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/RndInt.h @@ -0,0 +1,176 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1990 Free Software Foundation + adapted from a submission from John Reidl + + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +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. +*/ + +#ifndef _RandomInteger_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _RandomInteger_h 1 + +// RandomInteger uses a random number generator to generate an integer +// in a specified range. By default the range is 0..1. Since in my +// experience random numbers are often needed for a wide variety of +// ranges in the same program, this generator accepts a new low or high value +// as an argument to the asLong and operator() methods to temporarily +// override stored values + +#include +#include + +class RandomInteger +{ + protected: + RNG *pGenerator; + long pLow; + long pHigh; + + long _asLong(long, long); + + public: + + RandomInteger(long low, long high, RNG *gen); + RandomInteger(long high, RNG *gen); + RandomInteger(RNG *gen); + +// read params + + long low() const; + long high() const; + RNG* generator() const; + +// change params + + long low(long x); + long high(long x); + RNG* generator(RNG *gen); + +// get a random number + + long asLong(); + long operator()(); // synonym for asLong + int asInt(); // (possibly) truncate as int + +// override params for one shot + + long asLong(long high); + long asLong(long low, long high); + + long operator () (long high); // synonyms + long operator () (long low, long high); + +}; + + +inline RandomInteger::RandomInteger(long low, long high, RNG *gen) + : pGenerator(gen), + pLow((low < high) ? low : high), + pHigh((low < high) ? high : low) + +{} + +inline RandomInteger::RandomInteger(long high, RNG *gen) + : pGenerator(gen), + pLow((0 < high) ? 0 : high), + pHigh((0 < high) ? high : 0) +{} + + +inline RandomInteger::RandomInteger(RNG *gen) + : pGenerator(gen), + pLow(0), + pHigh(1) +{} + +inline RNG* RandomInteger::generator() const { return pGenerator;} +inline long RandomInteger::low() const { return pLow; } +inline long RandomInteger::high() const { return pHigh; } + +inline RNG* RandomInteger::generator(RNG *gen) +{ + RNG *tmp = pGenerator; pGenerator = gen; return tmp; +} + +inline long RandomInteger::low(long x) +{ + long tmp = pLow; pLow = x; return tmp; +} + +inline long RandomInteger:: high(long x) +{ + long tmp = pHigh; pHigh = x; return tmp; +} + +inline long RandomInteger:: _asLong(long low, long high) +{ + return (pGenerator->asLong() % (high-low+1)) + low; +} + + +inline long RandomInteger:: asLong() +{ + return _asLong(pLow, pHigh); +} + +inline long RandomInteger:: asLong(long high) +{ + return _asLong(pLow, high); +} + +inline long RandomInteger:: asLong(long low, long high) +{ + return _asLong(low, high); +} + +inline long RandomInteger:: operator () () +{ + return _asLong(pLow, pHigh); +} + +inline long RandomInteger:: operator () (long high) +{ + return _asLong(pLow, high); +} + +inline long RandomInteger:: operator () (long low, long high) +{ + return _asLong(low, high); +} + + + + +inline int RandomInteger:: asInt() +{ + return int(asLong()); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/SLList.cc b/gnu/lib/libg++/libg++/src/SLList.cc new file mode 100644 index 00000000000..564e5997bde --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SLList.cc @@ -0,0 +1,247 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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. +*/ + +#ifndef _G_NO_TEMPLATES +#ifdef __GNUG__ +//#pragma implementation +#endif +#include +#include +#include +#include "SLList.h" + +void BaseSLList::error(const char* msg) const +{ + (*lib_error_handler)("SLList", msg); +} + +int BaseSLList::length() const +{ + int l = 0; + BaseSLNode* t = last; + if (t != 0) do { ++l; t = t->tl; } while (t != last); + return l; +} + +void BaseSLList::clear() +{ + if (last == 0) + return; + + BaseSLNode* p = last->tl; + last->tl = 0; + last = 0; + + while (p != 0) + { + BaseSLNode* nxt = p->tl; + delete_node(p); + p = nxt; + } +} + + +// Note: This is an internal method. It does *not* free old contents! + +void BaseSLList::copy(const BaseSLList& a) +{ + if (a.last == 0) + last = 0; + else + { + BaseSLNode* p = a.last->tl; + BaseSLNode* h = copy_node(p->item()); + last = h; + for (;;) + { + if (p == a.last) + { + last->tl = h; + return; + } + p = p->tl; + BaseSLNode* n = copy_node(p->item()); + last->tl = n; + last = n; + } + } +} + +BaseSLList& BaseSLList::operator = (const BaseSLList& a) +{ + if (last != a.last) + { + clear(); + copy(a); + } + return *this; +} + +Pix BaseSLList::prepend(const void *datum) +{ + return prepend(copy_node(datum)); +} + + +Pix BaseSLList::prepend(BaseSLNode* t) +{ + if (t == 0) return 0; + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + } + return Pix(t); +} + + +Pix BaseSLList::append(const void *datum) +{ + return append(copy_node(datum)); +} + +Pix BaseSLList::append(BaseSLNode* t) +{ + if (t == 0) return 0; + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + last = t; + } + return Pix(t); +} + +void BaseSLList::join(BaseSLList& b) +{ + BaseSLNode* t = b.last; + b.last = 0; + if (last == 0) + last = t; + else if (t != 0) + { + BaseSLNode* f = last->tl; + last->tl = t->tl; + t->tl = f; + last = t; + } +} + +Pix BaseSLList::ins_after(Pix p, const void *datum) +{ + BaseSLNode* u = (BaseSLNode*)p; + BaseSLNode* t = copy_node(datum); + if (last == 0) + t->tl = last = t; + else if (u == 0) // ins_after 0 means prepend + { + t->tl = last->tl; + last->tl = t; + } + else + { + t->tl = u->tl; + u->tl = t; + if (u == last) + last = t; + } + return Pix(t); +} + +void BaseSLList::del_after(Pix p) +{ + BaseSLNode* u = (BaseSLNode*)p; + if (last == 0 || u == last) error("cannot del_after last"); + if (u == 0) u = last; // del_after 0 means delete first + BaseSLNode* t = u->tl; + if (u == t) + last = 0; + else + { + u->tl = t->tl; + if (last == t) + last = u; + } + delete_node(t); +} + +int BaseSLList::owns(Pix p) const +{ + BaseSLNode* t = last; + if (t != 0 && p != 0) + { + do + { + if (Pix(t) == p) return 1; + t = t->tl; + } while (t != last); + } + return 0; +} + +int BaseSLList::remove_front(void *dst, int signal_error) +{ + if (last) + { + BaseSLNode* t = last->tl; + copy_item(dst, t->item()); + if (t == last) + last = 0; + else + last->tl = t->tl; + delete_node(t); + return 1; + } + if (signal_error) + error("remove_front of empty list"); + return 0; +} + +void BaseSLList::del_front() +{ + if (last == 0) error("del_front of empty list"); + BaseSLNode* t = last->tl; + if (t == last) + last = 0; + else + last->tl = t->tl; + delete_node(t); +} + +int BaseSLList::OK() const +{ + int v = 1; + if (last != 0) + { + BaseSLNode* t = last; + long count = LONG_MAX; // Lots of chances to find last! + do + { + count--; + t = t->tl; + } while (count > 0 && t != last); + v &= count > 0; + } + if (!v) error("invariant failure"); + return v; +} +#endif /*!_G_NO_TEMPLATES*/ diff --git a/gnu/lib/libg++/libg++/src/SLList.h b/gnu/lib/libg++/libg++/src/SLList.h new file mode 100644 index 00000000000..072f249fe1d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SLList.h @@ -0,0 +1,129 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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. +*/ + +#ifndef _SLList_h +#ifdef __GNUG__ +//#pragma interface +#endif +#define _SLList_h 1 + +#undef OK + +#include + +struct BaseSLNode +{ + union { + struct BaseSLNode *tl; + double dummy; /* To force correct alignment */ + }; + void *item() {return (void*)(this+1);} // Return ((SLNode*)this)->hd +}; + +template +class SLNode : public BaseSLNode +{ + public: + T hd; // Data part of node + SLNode() { } + SLNode(const T& h, SLNode* t = 0) + : hd(h) { tl = t; } + ~SLNode() { } +}; + +extern int __SLListLength(BaseSLNode *ptr); + +class BaseSLList { + protected: + BaseSLNode *last; + virtual void delete_node(BaseSLNode*node) = 0; + virtual BaseSLNode* copy_node(const void* datum) = 0; + virtual void copy_item(void *dst, void *src) = 0; + virtual ~BaseSLList() { } + BaseSLList() { last = 0; } + void copy(const BaseSLList&); + BaseSLList& operator = (const BaseSLList& a); + Pix ins_after(Pix p, const void *datum); + Pix prepend(const void *datum); + Pix append(const void *datum); + int remove_front(void *dst, int signal_error = 0); + void join(BaseSLList&); + public: + int length() const; + int empty() const { return last == 0; } + void clear(); + Pix prepend(BaseSLNode*); + Pix append(BaseSLNode*); + int OK() const; + void error(const char* msg) const; + void del_after(Pix p); + int owns(Pix p) const; + void del_front(); +}; + +template +class SLList : public BaseSLList +{ + private: + virtual void delete_node(BaseSLNode *node) { delete (SLNode*)node; } + virtual BaseSLNode* copy_node(const void *datum) + { return new SLNode(*(const T*)datum); } + virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } + +public: + SLList() : BaseSLList() { } + SLList(const SLList& a) : BaseSLList() { copy(a); } + SLList& operator = (const SLList& a) + { BaseSLList::operator=((const BaseSLList&) a); return *this; } + virtual ~SLList() { clear(); } + + Pix prepend(const T& item) {return BaseSLList::prepend(&item);} + Pix append(const T& item) {return BaseSLList::append(&item);} + Pix prepend(SLNode* node) {return BaseSLList::prepend(node);} + Pix append(SLNode* node) {return BaseSLList::append(node);} + + T& operator () (Pix p) { + if (p == 0) error("null Pix"); + return ((SLNode*)(p))->hd; } + const T& operator () (Pix p) const { + if (p == 0) error("null Pix"); + return ((SLNode*)(p))->hd; } + inline Pix first() const { return (last == 0) ? 0 : Pix(last->tl); } + void next(Pix& p) const + { p = (p == 0 || p == last) ? 0 : Pix(((SLNode*)(p))->tl); } + Pix ins_after(Pix p, const T& item) + { return BaseSLList::ins_after(p, &item); } + void join(SLList& a) { BaseSLList::join(a); } + + T& front() { + if (last == 0) error("front: empty list"); + return ((SLNode*)last->tl)->hd; } + T& rear() { + if (last == 0) error("rear: empty list"); + return ((SLNode*)last)->hd; } + const T& front() const { + if (last == 0) error("front: empty list"); + return ((SLNode*)last->tl)->hd; } + const T& rear() const { + if (last == 0) error("rear: empty list"); + return ((SLNode*)last)->hd; } + int remove_front(T& x) { return BaseSLList::remove_front(&x); } + T remove_front() { T dst; BaseSLList::remove_front(&dst, 1); return dst; } +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/Sample.cc b/gnu/lib/libg++/libg++/src/Sample.cc new file mode 100644 index 00000000000..7ac3b1ca589 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Sample.cc @@ -0,0 +1,241 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include +#include + +#ifndef HUGE_VAL +#ifdef HUGE +#define HUGE_VAL HUGE +#else +#define HUGE_VAL DBL_MAX +#endif +#endif + +// error handling + +void default_SampleStatistic_error_handler(const char* msg) +{ + cerr << "Fatal SampleStatistic error. " << msg << "\n"; + exit(1); +} + +one_arg_error_handler_t SampleStatistic_error_handler = default_SampleStatistic_error_handler; + +one_arg_error_handler_t set_SampleStatistic_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = SampleStatistic_error_handler; + SampleStatistic_error_handler = f; + return old; +} + +void SampleStatistic::error(const char* msg) +{ + (*SampleStatistic_error_handler)(msg); +} + +// t-distribution: given p-value and degrees of freedom, return t-value +// adapted from Peizer & Pratt JASA, vol63, p1416 + +double tval(double p, int df) +{ + double t; + int positive = p >= 0.5; + p = (positive)? 1.0 - p : p; + if (p <= 0.0 || df <= 0) + t = HUGE_VAL; + else if (p == 0.5) + t = 0.0; + else if (df == 1) + t = 1.0 / tan((p + p) * 1.57079633); + else if (df == 2) + t = sqrt(1.0 / ((p + p) * (1.0 - p)) - 2.0); + else + { + double ddf = df; + double a = sqrt(log(1.0 / (p * p))); + double aa = a * a; + a = a - ((2.515517 + (0.802853 * a) + (0.010328 * aa)) / + (1.0 + (1.432788 * a) + (0.189269 * aa) + + (0.001308 * aa * a))); + t = ddf - 0.666666667 + 1.0 / (10.0 * ddf); + t = sqrt(ddf * (exp(a * a * (ddf - 0.833333333) / (t * t)) - 1.0)); + } + return (positive)? t : -t; +} + +void +SampleStatistic::reset() +{ + n = 0; x = x2 = 0.0; + maxValue = -HUGE_VAL; + minValue = HUGE_VAL; +} + +void +SampleStatistic::operator+=(double value) +{ + n += 1; + x += value; + x2 += (value * value); + if ( minValue > value) minValue = value; + if ( maxValue < value) maxValue = value; +} + +double +SampleStatistic::mean() +{ + if ( n > 0) { + return (x / n); + } + else { + return ( 0.0 ); + } +} + +double +SampleStatistic::var() +{ + if ( n > 1) { + return(( x2 - ((x * x) / n)) / ( n - 1)); + } + else { + return ( 0.0 ); + } +} + +double +SampleStatistic::stdDev() +{ + if ( n <= 0 || this -> var() <= 0) { + return(0); + } else { + return( (double) sqrt( var() ) ); + } +} + +double +SampleStatistic::confidence(int interval) +{ + int df = n - 1; + if (df <= 0) return HUGE_VAL; + double t = tval(double(100 + interval) * 0.005, df); + if (t == HUGE_VAL) + return t; + else + return (t * stdDev()) / sqrt(double(n)); +} + +double +SampleStatistic::confidence(double p_value) +{ + int df = n - 1; + if (df <= 0) return HUGE_VAL; + double t = tval((1.0 + p_value) * 0.5, df); + if (t == HUGE_VAL) + return t; + else + return (t * stdDev()) / sqrt(double(n)); +} + + +#include + +const int SampleHistogramMinimum = -2; +const int SampleHistogramMaximum = -1; + +SampleHistogram::SampleHistogram(double low, double high, double width) +{ + if (high < low) { + double t = high; + high = low; + low = t; + } + + if (width == -1) { + width = (high - low) / 10; + } + + howManyBuckets = int((high - low) / width) + 2; + bucketCount = new int[howManyBuckets]; + bucketLimit = new double[howManyBuckets]; + double lim = low; + for (int i = 0; i < howManyBuckets; i++) { + bucketCount[i] = 0; + bucketLimit[i] = lim; + lim += width; + } + bucketLimit[howManyBuckets-1] = HUGE_VAL; /* from math.h */ +} + +SampleHistogram::~SampleHistogram() +{ + if (howManyBuckets > 0) { + delete bucketCount; + delete bucketLimit; + } +} + +void +SampleHistogram::operator+=(double value) +{ + int i; + for (i = 0; i < howManyBuckets; i++) { + if (value < bucketLimit[i]) break; + } + bucketCount[i]++; + this->SampleStatistic::operator+=(value); +} + +int +SampleHistogram::similarSamples(double d) +{ + int i; + for (i = 0; i < howManyBuckets; i++) { + if (d < bucketLimit[i]) return(bucketCount[i]); + } + return(0); +} + +void +SampleHistogram::printBuckets(ostream& s) +{ + for(int i = 0; i < howManyBuckets; i++) { + if (bucketLimit[i] >= HUGE_VAL) { + s << "< max : " << bucketCount[i] << "\n"; + } else { + s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n"; + } + } +} + +void +SampleHistogram::reset() +{ + this->SampleStatistic::reset(); + if (howManyBuckets > 0) { + for (register int i = 0; i < howManyBuckets; i++) { + bucketCount[i] = 0; + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/SmplHist.cc b/gnu/lib/libg++/libg++/src/SmplHist.cc new file mode 100644 index 00000000000..5dbe2c79327 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SmplHist.cc @@ -0,0 +1,112 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +#ifndef HUGE_VAL +#ifdef HUGE +#define HUGE_VAL HUGE +#else +#include +#define HUGE_VAL DBL_MAX +#endif +#endif + +const int SampleHistogramMinimum = -2; +const int SampleHistogramMaximum = -1; + +SampleHistogram::SampleHistogram(double low, double high, double width) +{ + if (high < low) { + double t = high; + high = low; + low = t; + } + + if (width == -1) { + width = (high - low) / 10; + } + + howManyBuckets = int((high - low) / width) + 2; + bucketCount = new int[howManyBuckets]; + bucketLimit = new double[howManyBuckets]; + double lim = low; + for (int i = 0; i < howManyBuckets; i++) { + bucketCount[i] = 0; + bucketLimit[i] = lim; + lim += width; + } + bucketLimit[howManyBuckets-1] = HUGE_VAL; /* from math.h */ +} + +SampleHistogram::~SampleHistogram() +{ + if (howManyBuckets > 0) { + delete bucketCount; + delete bucketLimit; + } +} + +void +SampleHistogram::operator+=(double value) +{ + int i; + for (i = 0; i < howManyBuckets; i++) { + if (value < bucketLimit[i]) break; + } + bucketCount[i]++; + this->SampleStatistic::operator+=(value); +} + +int +SampleHistogram::similarSamples(double d) +{ + int i; + for (i = 0; i < howManyBuckets; i++) { + if (d < bucketLimit[i]) return(bucketCount[i]); + } + return(0); +} + +void +SampleHistogram::printBuckets(ostream& s) +{ + for(int i = 0; i < howManyBuckets; i++) { + if (bucketLimit[i] >= HUGE_VAL) { + s << "< max : " << bucketCount[i] << "\n"; + } else { + s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n"; + } + } +} + +void +SampleHistogram::reset() +{ + this->SampleStatistic::reset(); + if (howManyBuckets > 0) { + for (register int i = 0; i < howManyBuckets; i++) { + bucketCount[i] = 0; + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/SmplHist.h b/gnu/lib/libg++/libg++/src/SmplHist.h new file mode 100644 index 00000000000..959d6d4bc7a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SmplHist.h @@ -0,0 +1,72 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ + +#ifndef SampleHistogram_h +#ifdef __GNUG__ +#pragma interface +#endif +#define SampleHistogram_h 1 + +#include +#include + +extern const int SampleHistogramMinimum; +extern const int SampleHistogramMaximum; + +class SampleHistogram : public SampleStatistic +{ +protected: + short howManyBuckets; + int *bucketCount; + double *bucketLimit; + +public: + + SampleHistogram(double low, double hi, double bucketWidth = -1.0); + + ~SampleHistogram(); + + virtual void reset(); + virtual void operator+=(double); + + int similarSamples(double); + + int buckets(); + + double bucketThreshold(int i); + int inBucket(int i); + void printBuckets(ostream&); + +}; + + +inline int SampleHistogram:: buckets() { return(howManyBuckets); }; + +inline double SampleHistogram:: bucketThreshold(int i) { + if (i < 0 || i >= howManyBuckets) + error("invalid bucket access"); + return(bucketLimit[i]); +} + +inline int SampleHistogram:: inBucket(int i) { + if (i < 0 || i >= howManyBuckets) + error("invalid bucket access"); + return(bucketCount[i]); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/SmplStat.cc b/gnu/lib/libg++/libg++/src/SmplStat.cc new file mode 100644 index 00000000000..9db3caa845d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SmplStat.cc @@ -0,0 +1,160 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +#ifndef HUGE_VAL +#ifdef HUGE +#define HUGE_VAL HUGE +#else +#include +#define HUGE_VAL DBL_MAX +#endif +#endif + +// error handling + +void default_SampleStatistic_error_handler(const char* msg) +{ + cerr << "Fatal SampleStatistic error. " << msg << "\n"; + exit(1); +} + +one_arg_error_handler_t SampleStatistic_error_handler = default_SampleStatistic_error_handler; + +one_arg_error_handler_t set_SampleStatistic_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = SampleStatistic_error_handler; + SampleStatistic_error_handler = f; + return old; +} + +void SampleStatistic::error(const char* msg) +{ + (*SampleStatistic_error_handler)(msg); +} + +// t-distribution: given p-value and degrees of freedom, return t-value +// adapted from Peizer & Pratt JASA, vol63, p1416 + +double tval(double p, int df) +{ + double t; + int positive = p >= 0.5; + p = (positive)? 1.0 - p : p; + if (p <= 0.0 || df <= 0) + t = HUGE_VAL; + else if (p == 0.5) + t = 0.0; + else if (df == 1) + t = 1.0 / tan((p + p) * 1.57079633); + else if (df == 2) + t = sqrt(1.0 / ((p + p) * (1.0 - p)) - 2.0); + else + { + double ddf = df; + double a = sqrt(log(1.0 / (p * p))); + double aa = a * a; + a = a - ((2.515517 + (0.802853 * a) + (0.010328 * aa)) / + (1.0 + (1.432788 * a) + (0.189269 * aa) + + (0.001308 * aa * a))); + t = ddf - 0.666666667 + 1.0 / (10.0 * ddf); + t = sqrt(ddf * (exp(a * a * (ddf - 0.833333333) / (t * t)) - 1.0)); + } + return (positive)? t : -t; +} + +void +SampleStatistic::reset() +{ + n = 0; x = x2 = 0.0; + maxValue = -HUGE_VAL; + minValue = HUGE_VAL; +} + +void +SampleStatistic::operator+=(double value) +{ + n += 1; + x += value; + x2 += (value * value); + if ( minValue > value) minValue = value; + if ( maxValue < value) maxValue = value; +} + +double +SampleStatistic::mean() +{ + if ( n > 0) { + return (x / n); + } + else { + return ( 0.0 ); + } +} + +double +SampleStatistic::var() +{ + if ( n > 1) { + return(( x2 - ((x * x) / n)) / ( n - 1)); + } + else { + return ( 0.0 ); + } +} + +double +SampleStatistic::stdDev() +{ + if ( n <= 0 || this -> var() <= 0) { + return(0); + } else { + return( (double) sqrt( var() ) ); + } +} + +double +SampleStatistic::confidence(int interval) +{ + int df = n - 1; + if (df <= 0) return HUGE_VAL; + double t = tval(double(100 + interval) * 0.005, df); + if (t == HUGE_VAL) + return t; + else + return (t * stdDev()) / sqrt(double(n)); +} + +double +SampleStatistic::confidence(double p_value) +{ + int df = n - 1; + if (df <= 0) return HUGE_VAL; + double t = tval((1.0 + p_value) * 0.5, df); + if (t == HUGE_VAL) + return t; + else + return (t * stdDev()) / sqrt(double(n)); +} + + diff --git a/gnu/lib/libg++/libg++/src/SmplStat.h b/gnu/lib/libg++/libg++/src/SmplStat.h new file mode 100644 index 00000000000..441692f8c7b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/SmplStat.h @@ -0,0 +1,69 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef SampleStatistic_h +#ifdef __GNUG__ +#pragma interface +#endif +#define SampleStatistic_h 1 + +#include + +#undef min +#undef max + +class SampleStatistic { +protected: + int n; + double x; + double x2; + double minValue, maxValue; + + public : + + SampleStatistic(); + inline virtual ~SampleStatistic(); + virtual void reset(); + + virtual void operator+=(double); + int samples(); + double mean(); + double stdDev(); + double var(); + double min(); + double max(); + double confidence(int p_percentage); + double confidence(double p_value); + + void error(const char* msg); +}; + +// error handlers + +extern void default_SampleStatistic_error_handler(const char*); +extern one_arg_error_handler_t SampleStatistic_error_handler; + +extern one_arg_error_handler_t + set_SampleStatistic_error_handler(one_arg_error_handler_t f); + +inline SampleStatistic:: SampleStatistic(){ reset();} +inline int SampleStatistic:: samples() {return(n);} +inline double SampleStatistic:: min() {return(minValue);} +inline double SampleStatistic:: max() {return(maxValue);} +inline SampleStatistic::~SampleStatistic() {} + +#endif diff --git a/gnu/lib/libg++/libg++/src/String.cc b/gnu/lib/libg++/libg++/src/String.cc new file mode 100644 index 00000000000..6ab515ca939 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/String.cc @@ -0,0 +1,1307 @@ +/* +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. +*/ + +/* + String class implementation + */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include +#include +#include +#include +#include +#include + +#undef OK + +void String::error(const char* msg) const +{ + (*lib_error_handler)("String", msg); +} + +String::operator const char*() const +{ + return (const char*)chars(); +} + +// globals + +StrRep _nilStrRep = { 0, 1, { 0 } }; // nil strings point here +String _nilString; // nil SubStrings point here + + + + +/* + the following inline fcts are specially designed to work + in support of String classes, and are not meant as generic replacements + for libc "str" functions. + + inline copy fcts - I like left-to-right from->to arguments. + all versions assume that `to' argument is non-null + + These are worth doing inline, rather than through calls because, + via procedural integration, adjacent copy calls can be smushed + together by the optimizer. +*/ + +// copy n bytes +inline static void ncopy(const char* from, char* to, int n) +{ + if (from != to) while (--n >= 0) *to++ = *from++; +} + +// copy n bytes, null-terminate +inline static void ncopy0(const char* from, char* to, int n) +{ + if (from != to) + { + while (--n >= 0) *to++ = *from++; + *to = 0; + } + else + to[n] = 0; +} + +// copy until null +inline static void scopy(const char* from, char* to) +{ + if (from != 0) while((*to++ = *from++) != 0); +} + +// copy right-to-left +inline static void revcopy(const char* from, char* to, short n) +{ + if (from != 0) while (--n >= 0) *to-- = *from--; +} + + +inline static int slen(const char* t) // inline strlen +{ + if (t == 0) + return 0; + else + { + const char* a = t; + while (*a++ != 0); + return a - 1 - t; + } +} + +// minimum & maximum representable rep size + +#define MAXStrRep_SIZE ((1 << (sizeof(short) * CHAR_BIT - 1)) - 1) +#define MINStrRep_SIZE 16 + +#ifndef MALLOC_MIN_OVERHEAD +#define MALLOC_MIN_OVERHEAD 4 +#endif + +// The basic allocation primitive: +// Always round request to something close to a power of two. +// This ensures a bit of padding, which often means that +// concatenations don't have to realloc. Plus it tends to +// be faster when lots of Strings are created and discarded, +// since just about any version of malloc (op new()) will +// be faster when it can reuse identically-sized chunks + +inline static StrRep* Snew(int newsiz) +{ + unsigned int siz = sizeof(StrRep) + newsiz + MALLOC_MIN_OVERHEAD; + unsigned int allocsiz = MINStrRep_SIZE; + while (allocsiz < siz) allocsiz <<= 1; + allocsiz -= MALLOC_MIN_OVERHEAD; + if (allocsiz >= MAXStrRep_SIZE) + (*lib_error_handler)("String", "Requested length out of range"); + + StrRep* rep = new (operator new (allocsiz)) StrRep; + rep->sz = allocsiz - sizeof(StrRep); + return rep; +} + +// Do-something-while-allocating routines. + +// We live with two ways to signify empty Sreps: either the +// null pointer (0) or a pointer to the nilStrRep. + +// We always signify unknown source lengths (usually when fed a char*) +// via len == -1, in which case it is computed. + +// allocate, copying src if nonull + +StrRep* Salloc(StrRep* old, const char* src, int srclen, int newlen) +{ + if (old == &_nilStrRep) old = 0; + if (srclen < 0) srclen = slen(src); + if (newlen < srclen) newlen = srclen; + StrRep* rep; + if (old == 0 || newlen > old->sz) + rep = Snew(newlen); + else + rep = old; + + rep->len = newlen; + ncopy0(src, rep->s, srclen); + + if (old != rep && old != 0) delete old; + + return rep; +} + +// reallocate: Given the initial allocation scheme, it will +// generally be faster in the long run to get new space & copy +// than to call realloc + +static StrRep* +Sresize(StrRep* old, int newlen) +{ + if (old == &_nilStrRep) old = 0; + StrRep* rep; + if (old == 0) + rep = Snew(newlen); + else if (newlen > old->sz) + { + rep = Snew(newlen); + ncopy0(old->s, rep->s, old->len); + delete old; + } + else + rep = old; + + rep->len = newlen; + + return rep; +} + +void +String::alloc (int newsize) +{ + unsigned short old_len = rep->len; + rep = Sresize(rep, newsize); + rep->len = old_len; +} + +// like allocate, but we know that src is a StrRep + +StrRep* Scopy(StrRep* old, const StrRep* s) +{ + if (old == &_nilStrRep) old = 0; + if (s == &_nilStrRep) s = 0; + if (old == s) + return (old == 0)? &_nilStrRep : old; + else if (s == 0) + { + old->s[0] = 0; + old->len = 0; + return old; + } + else + { + StrRep* rep; + int newlen = s->len; + if (old == 0 || newlen > old->sz) + { + if (old != 0) delete old; + rep = Snew(newlen); + } + else + rep = old; + rep->len = newlen; + ncopy0(s->s, rep->s, newlen); + return rep; + } +} + +// allocate & concatenate + +StrRep* Scat(StrRep* old, const char* s, int srclen, const char* t, int tlen) +{ + if (old == &_nilStrRep) old = 0; + if (srclen < 0) srclen = slen(s); + if (tlen < 0) tlen = slen(t); + int newlen = srclen + tlen; + StrRep* rep; + + if (old == 0 || newlen > old->sz || + (t >= old->s && t < &(old->s[old->len]))) // beware of aliasing + rep = Snew(newlen); + else + rep = old; + + rep->len = newlen; + + ncopy(s, rep->s, srclen); + ncopy0(t, &(rep->s[srclen]), tlen); + + if (old != rep && old != 0) delete old; + + return rep; +} + +// double-concatenate + +StrRep* Scat(StrRep* old, const char* s, int srclen, const char* t, int tlen, + const char* u, int ulen) +{ + if (old == &_nilStrRep) old = 0; + if (srclen < 0) srclen = slen(s); + if (tlen < 0) tlen = slen(t); + if (ulen < 0) ulen = slen(u); + int newlen = srclen + tlen + ulen; + StrRep* rep; + if (old == 0 || newlen > old->sz || + (t >= old->s && t < &(old->s[old->len])) || + (u >= old->s && u < &(old->s[old->len]))) + rep = Snew(newlen); + else + rep = old; + + rep->len = newlen; + + ncopy(s, rep->s, srclen); + ncopy(t, &(rep->s[srclen]), tlen); + ncopy0(u, &(rep->s[srclen+tlen]), ulen); + + if (old != rep && old != 0) delete old; + + return rep; +} + +// like cat, but we know that new stuff goes in the front of existing rep + +StrRep* Sprepend(StrRep* old, const char* t, int tlen) +{ + char* s; + int srclen; + if (old == &_nilStrRep || old == 0) + { + s = 0; old = 0; srclen = 0; + } + else + { + s = old->s; srclen = old->len; + } + if (tlen < 0) tlen = slen(t); + int newlen = srclen + tlen; + StrRep* rep; + if (old == 0 || newlen > old->sz || + (t >= old->s && t < &(old->s[old->len]))) + rep = Snew(newlen); + else + rep = old; + + rep->len = newlen; + + revcopy(&(s[srclen]), &(rep->s[newlen]), srclen+1); + ncopy(t, rep->s, tlen); + + if (old != rep && old != 0) delete old; + + return rep; +} + + +// string compare: first argument is known to be non-null + +inline static int scmp(const char* a, const char* b) +{ + if (b == 0) + return *a != 0; + else + { + signed char diff = 0; + while ((diff = *a - *b++) == 0 && *a++ != 0); + return diff; + } +} + + +inline static int ncmp(const char* a, int al, const char* b, int bl) +{ + int n = (al <= bl)? al : bl; + signed char diff; + while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff; + return al - bl; +} + +int fcompare(const String& x, const String& y) +{ + const char* a = x.chars(); + const char* b = y.chars(); + int al = x.length(); + int bl = y.length(); + int n = (al <= bl)? al : bl; + signed char diff = 0; + while (n-- > 0) + { + char ac = *a++; + char bc = *b++; + if ((diff = ac - bc) != 0) + { + if (ac >= 'a' && ac <= 'z') + ac = ac - 'a' + 'A'; + if (bc >= 'a' && bc <= 'z') + bc = bc - 'a' + 'A'; + if ((diff = ac - bc) != 0) + return diff; + } + } + return al - bl; +} + +// these are not inline, but pull in the above inlines, so are +// pretty fast + +int compare(const String& x, const char* b) +{ + return scmp(x.chars(), b); +} + +int compare(const String& x, const String& y) +{ + return scmp(x.chars(), y.chars()); +} + +int compare(const String& x, const SubString& y) +{ + return ncmp(x.chars(), x.length(), y.chars(), y.length()); +} + +int compare(const SubString& x, const String& y) +{ + return ncmp(x.chars(), x.length(), y.chars(), y.length()); +} + +int compare(const SubString& x, const SubString& y) +{ + return ncmp(x.chars(), x.length(), y.chars(), y.length()); +} + +int compare(const SubString& x, const char* b) +{ + if (b == 0) + return x.length(); + else + { + const char* a = x.chars(); + int n = x.length(); + signed char diff; + while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff; + return (*b == 0) ? 0 : -1; + } +} + +/* + index fcts +*/ + +int String::search(int start, int sl, char c) const +{ + const char* s = chars(); + if (sl > 0) + { + if (start >= 0) + { + const char* a = &(s[start]); + const char* lasta = &(s[sl]); + while (a < lasta) if (*a++ == c) return --a - s; + } + else + { + const char* a = &(s[sl + start + 1]); + while (--a >= s) if (*a == c) return a - s; + } + } + return -1; +} + +int String::search(int start, int sl, const char* t, int tl) const +{ + const char* s = chars(); + if (tl < 0) tl = slen(t); + if (sl > 0 && tl > 0) + { + if (start >= 0) + { + const char* lasts = &(s[sl - tl]); + const char* lastt = &(t[tl]); + const char* p = &(s[start]); + + while (p <= lasts) + { + const char* x = p++; + const char* y = t; + while (*x++ == *y++) if (y >= lastt) return --p - s; + } + } + else + { + const char* firsts = &(s[tl - 1]); + const char* lastt = &(t[tl - 1]); + const char* p = &(s[sl + start + 1]); + + while (--p >= firsts) + { + const char* x = p; + const char* y = lastt; + while (*x-- == *y--) if (y < t) return ++x - s; + } + } + } + return -1; +} + +int String::match(int start, int sl, int exact, const char* t, int tl) const +{ + if (tl < 0) tl = slen(t); + + if (start < 0) + { + start = sl + start - tl + 1; + if (start < 0 || (exact && start != 0)) + return -1; + } + else if (exact && sl - start != tl) + return -1; + + if (sl == 0 || tl == 0 || sl - start < tl || start >= sl) + return -1; + + int n = tl; + const char* s = &(rep->s[start]); + while (--n >= 0) if (*s++ != *t++) return -1; + return tl; +} + +void SubString::assign(const StrRep* ysrc, const char* ys, int ylen) +{ + if (&S == &_nilString) return; + + if (ylen < 0) ylen = slen(ys); + StrRep* targ = S.rep; + int sl = targ->len - len + ylen; + + if (ysrc == targ || sl >= targ->sz) + { + StrRep* oldtarg = targ; + targ = Sresize(0, sl); + ncopy(oldtarg->s, targ->s, pos); + ncopy(ys, &(targ->s[pos]), ylen); + scopy(&(oldtarg->s[pos + len]), &(targ->s[pos + ylen])); + delete oldtarg; + } + else if (len == ylen) + ncopy(ys, &(targ->s[pos]), len); + else if (ylen < len) + { + ncopy(ys, &(targ->s[pos]), ylen); + scopy(&(targ->s[pos + len]), &(targ->s[pos + ylen])); + } + else + { + revcopy(&(targ->s[targ->len]), &(targ->s[sl]), targ->len-pos-len +1); + ncopy(ys, &(targ->s[pos]), ylen); + } + targ->len = sl; + S.rep = targ; +} + + + +/* + * substitution + */ + + +int String::_gsub(const char* pat, int pl, const char* r, int rl) +{ + int nmatches = 0; + if (pl < 0) pl = slen(pat); + if (rl < 0) rl = slen(r); + int sl = length(); + if (sl <= 0 || pl <= 0 || sl < pl) + return nmatches; + + const char* s = chars(); + + // prepare to make new rep + StrRep* nrep = 0; + int nsz = 0; + char* x = 0; + + int si = 0; + int xi = 0; + int remaining = sl; + + while (remaining >= pl) + { + int pos = search(si, sl, pat, pl); + if (pos < 0) + break; + else + { + ++nmatches; + int mustfit = xi + remaining + rl - pl; + if (mustfit >= nsz) + { + if (nrep != 0) nrep->len = xi; + nrep = Sresize(nrep, mustfit); + nsz = nrep->sz; + x = nrep->s; + } + pos -= si; + ncopy(&(s[si]), &(x[xi]), pos); + ncopy(r, &(x[xi + pos]), rl); + si += pos + pl; + remaining -= pos + pl; + xi += pos + rl; + } + } + + if (nrep == 0) + { + if (nmatches == 0) + return nmatches; + else + nrep = Sresize(nrep, xi+remaining); + } + + ncopy0(&(s[si]), &(x[xi]), remaining); + nrep->len = xi + remaining; + + if (nrep->len <= rep->sz) // fit back in if possible + { + rep->len = nrep->len; + ncopy0(nrep->s, rep->s, rep->len); + delete(nrep); + } + else + { + delete(rep); + rep = nrep; + } + return nmatches; +} + +int String::_gsub(const Regex& pat, const char* r, int rl) +{ + int nmatches = 0; + int sl = length(); + if (sl <= 0) + return nmatches; + + if (rl < 0) rl = slen(r); + + const char* s = chars(); + + StrRep* nrep = 0; + int nsz = 0; + + char* x = 0; + + int si = 0; + int xi = 0; + int remaining = sl; + int pos, pl = 0; // how long is a regular expression? + + while (remaining > 0) + { + pos = pat.search(s, sl, pl, si); // unlike string search, the pos returned here is absolute + if (pos < 0 || pl <= 0) + break; + else + { + ++nmatches; + int mustfit = xi + remaining + rl - pl; + if (mustfit >= nsz) + { + if (nrep != 0) nrep->len = xi; + nrep = Sresize(nrep, mustfit); + x = nrep->s; + nsz = nrep->sz; + } + pos -= si; + ncopy(&(s[si]), &(x[xi]), pos); + ncopy(r, &(x[xi + pos]), rl); + si += pos + pl; + remaining -= pos + pl; + xi += pos + rl; + } + } + + if (nrep == 0) + { + if (nmatches == 0) + return nmatches; + else + nrep = Sresize(nrep, xi+remaining); + } + + ncopy0(&(s[si]), &(x[xi]), remaining); + nrep->len = xi + remaining; + + if (nrep->len <= rep->sz) // fit back in if possible + { + rep->len = nrep->len; + ncopy0(nrep->s, rep->s, rep->len); + delete(nrep); + } + else + { + delete(rep); + rep = nrep; + } + return nmatches; +} + + +/* + * deletion + */ + +void String::del(int pos, int len) +{ + if (pos < 0 || len <= 0 || (unsigned)(pos + len) > length()) return; + int nlen = length() - len; + int first = pos + len; + ncopy0(&(rep->s[first]), &(rep->s[pos]), length() - first); + rep->len = nlen; +} + +void String::del(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + del(first, mlen); +} + +void String::del(const char* t, int startpos) +{ + int tlen = slen(t); + int p = search(startpos, length(), t, tlen); + del(p, tlen); +} + +void String::del(const String& y, int startpos) +{ + del(search(startpos, length(), y.chars(), y.length()), y.length()); +} + +void String::del(const SubString& y, int startpos) +{ + del(search(startpos, length(), y.chars(), y.length()), y.length()); +} + +void String::del(char c, int startpos) +{ + del(search(startpos, length(), c), 1); +} + +/* + * substring extraction + */ + + +SubString String::at(int first, int len) +{ + return _substr(first, len); +} + +SubString String::operator() (int first, int len) +{ + return _substr(first, len); +} + +SubString String::before(int pos) +{ + return _substr(0, pos); +} + +SubString String::through(int pos) +{ + return _substr(0, pos+1); +} + +SubString String::after(int pos) +{ + return _substr(pos + 1, length() - (pos + 1)); +} + +SubString String::from(int pos) +{ + return _substr(pos, length() - pos); +} + +SubString String::at(const String& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + return _substr(first, y.length()); +} + +SubString String::at(const SubString& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + return _substr(first, y.length()); +} + +SubString String::at(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + return _substr(first, mlen); +} + +SubString String::at(const char* t, int startpos) +{ + int tlen = slen(t); + int first = search(startpos, length(), t, tlen); + return _substr(first, tlen); +} + +SubString String::at(char c, int startpos) +{ + int first = search(startpos, length(), c); + return _substr(first, 1); +} + +SubString String::before(const String& y, int startpos) +{ + int last = search(startpos, length(), y.chars(), y.length()); + return _substr(0, last); +} + +SubString String::before(const SubString& y, int startpos) +{ + int last = search(startpos, length(), y.chars(), y.length()); + return _substr(0, last); +} + +SubString String::before(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + return _substr(0, first); +} + +SubString String::before(char c, int startpos) +{ + int last = search(startpos, length(), c); + return _substr(0, last); +} + +SubString String::before(const char* t, int startpos) +{ + int tlen = slen(t); + int last = search(startpos, length(), t, tlen); + return _substr(0, last); +} + +SubString String::through(const String& y, int startpos) +{ + int last = search(startpos, length(), y.chars(), y.length()); + if (last >= 0) last += y.length(); + return _substr(0, last); +} + +SubString String::through(const SubString& y, int startpos) +{ + int last = search(startpos, length(), y.chars(), y.length()); + if (last >= 0) last += y.length(); + return _substr(0, last); +} + +SubString String::through(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + if (first >= 0) first += mlen; + return _substr(0, first); +} + +SubString String::through(char c, int startpos) +{ + int last = search(startpos, length(), c); + if (last >= 0) last += 1; + return _substr(0, last); +} + +SubString String::through(const char* t, int startpos) +{ + int tlen = slen(t); + int last = search(startpos, length(), t, tlen); + if (last >= 0) last += tlen; + return _substr(0, last); +} + +SubString String::after(const String& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + if (first >= 0) first += y.length(); + return _substr(first, length() - first); +} + +SubString String::after(const SubString& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + if (first >= 0) first += y.length(); + return _substr(first, length() - first); +} + +SubString String::after(char c, int startpos) +{ + int first = search(startpos, length(), c); + if (first >= 0) first += 1; + return _substr(first, length() - first); +} + +SubString String::after(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + if (first >= 0) first += mlen; + return _substr(first, length() - first); +} + +SubString String::after(const char* t, int startpos) +{ + int tlen = slen(t); + int first = search(startpos, length(), t, tlen); + if (first >= 0) first += tlen; + return _substr(first, length() - first); +} + +SubString String::from(const String& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + return _substr(first, length() - first); +} + +SubString String::from(const SubString& y, int startpos) +{ + int first = search(startpos, length(), y.chars(), y.length()); + return _substr(first, length() - first); +} + +SubString String::from(const Regex& r, int startpos) +{ + int mlen; + int first = r.search(chars(), length(), mlen, startpos); + return _substr(first, length() - first); +} + +SubString String::from(char c, int startpos) +{ + int first = search(startpos, length(), c); + return _substr(first, length() - first); +} + +SubString String::from(const char* t, int startpos) +{ + int tlen = slen(t); + int first = search(startpos, length(), t, tlen); + return _substr(first, length() - first); +} + + + +/* + * split/join + */ + + +int split(const String& src, String results[], int n, const String& sep) +{ + String x = src; + const char* s = x.chars(); + int sl = x.length(); + int i = 0; + int pos = 0; + while (i < n && pos < sl) + { + int p = x.search(pos, sl, sep.chars(), sep.length()); + if (p < 0) + p = sl; + results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos); + i++; + pos = p + sep.length(); + } + return i; +} + +int split(const String& src, String results[], int n, const Regex& r) +{ + String x = src; + const char* s = x.chars(); + int sl = x.length(); + int i = 0; + int pos = 0; + int p, matchlen; + while (i < n && pos < sl) + { + p = r.search(s, sl, matchlen, pos); + if (p < 0) + p = sl; + results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos); + i++; + pos = p + matchlen; + } + return i; +} + + +#if defined(__GNUG__) && !defined(_G_NO_NRV) +#define RETURN(r) return +#define RETURNS(r) return r; +#define RETURN_OBJECT(TYPE, NAME) /* nothing */ +#else /* _G_NO_NRV */ +#define RETURN(r) return r +#define RETURNS(r) /* nothing */ +#define RETURN_OBJECT(TYPE, NAME) TYPE NAME; +#endif + +String join(String src[], int n, const String& separator) RETURNS(x) +{ + RETURN_OBJECT(String,x) + String sep = separator; + int xlen = 0; + int i; + for (i = 0; i < n; ++i) + xlen += src[i].length(); + xlen += (n - 1) * sep.length(); + + x.rep = Sresize (x.rep, xlen); + + int j = 0; + + for (i = 0; i < n - 1; ++i) + { + ncopy(src[i].chars(), &(x.rep->s[j]), src[i].length()); + j += src[i].length(); + ncopy(sep.chars(), &(x.rep->s[j]), sep.length()); + j += sep.length(); + } + ncopy0(src[i].chars(), &(x.rep->s[j]), src[i].length()); + RETURN(x); +} + +/* + misc +*/ + + +StrRep* Sreverse(const StrRep* src, StrRep* dest) +{ + int n = src->len; + if (src != dest) + dest = Salloc(dest, src->s, n, n); + if (n > 0) + { + char* a = dest->s; + char* b = &(a[n - 1]); + while (a < b) + { + char t = *a; + *a++ = *b; + *b-- = t; + } + } + return dest; +} + + +StrRep* Supcase(const StrRep* src, StrRep* dest) +{ + int n = src->len; + if (src != dest) dest = Salloc(dest, src->s, n, n); + char* p = dest->s; + char* e = &(p[n]); + for (; p < e; ++p) if (islower(*p)) *p = toupper(*p); + return dest; +} + +StrRep* Sdowncase(const StrRep* src, StrRep* dest) +{ + int n = src->len; + if (src != dest) dest = Salloc(dest, src->s, n, n); + char* p = dest->s; + char* e = &(p[n]); + for (; p < e; ++p) if (isupper(*p)) *p = tolower(*p); + return dest; +} + +StrRep* Scapitalize(const StrRep* src, StrRep* dest) +{ + int n = src->len; + if (src != dest) dest = Salloc(dest, src->s, n, n); + + char* p = dest->s; + char* e = &(p[n]); + for (; p < e; ++p) + { + int at_word; + if (at_word = islower(*p)) + *p = toupper(*p); + else + at_word = isupper(*p) || isdigit(*p); + + if (at_word) + { + while (++p < e) + { + if (isupper(*p)) + *p = tolower(*p); + /* A '\'' does not break a word, so that "Nathan's" stays + "Nathan's" rather than turning into "Nathan'S". */ + else if (!islower(*p) && !isdigit(*p) && (*p != '\'')) + break; + } + } + } + return dest; +} + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +String replicate(char c, int n) return w; +{ + w.rep = Sresize(w.rep, n); + char* p = w.rep->s; + while (n-- > 0) *p++ = c; + *p = 0; +} + +String replicate(const String& y, int n) return w +{ + int len = y.length(); + w.rep = Sresize(w.rep, n * len); + char* p = w.rep->s; + while (n-- > 0) + { + ncopy(y.chars(), p, len); + p += len; + } + *p = 0; +} + +String common_prefix(const String& x, const String& y, int startpos) return r; +{ + const char* xchars = x.chars(); + const char* ychars = y.chars(); + const char* xs = &(xchars[startpos]); + const char* ss = xs; + const char* topx = &(xchars[x.length()]); + const char* ys = &(ychars[startpos]); + const char* topy = &(ychars[y.length()]); + int l; + for (l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l); + r.rep = Salloc(r.rep, ss, l, l); +} + +String common_suffix(const String& x, const String& y, int startpos) return r; +{ + const char* xchars = x.chars(); + const char* ychars = y.chars(); + const char* xs = &(xchars[x.length() + startpos]); + const char* botx = xchars; + const char* ys = &(ychars[y.length() + startpos]); + const char* boty = ychars; + int l; + for (l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l); + r.rep = Salloc(r.rep, ++xs, l, l); +} + +#else + +String replicate(char c, int n) +{ + String w; + w.rep = Sresize(w.rep, n); + char* p = w.rep->s; + while (n-- > 0) *p++ = c; + *p = 0; + return w; +} + +String replicate(const String& y, int n) +{ + String w; + int len = y.length(); + w.rep = Sresize(w.rep, n * len); + char* p = w.rep->s; + while (n-- > 0) + { + ncopy(y.chars(), p, len); + p += len; + } + *p = 0; + return w; +} + +String common_prefix(const String& x, const String& y, int startpos) +{ + String r; + const char* xchars = x.chars(); + const char* ychars = y.chars(); + const char* xs = &(xchars[startpos]); + const char* ss = xs; + const char* topx = &(xchars[x.length()]); + const char* ys = &(ychars[startpos]); + const char* topy = &(ychars[y.length()]); + int l; + for (int l; xs < topx && ys < topy && *xs++ == *ys++; ++l); + r.rep = Salloc(r.rep, ss, l, l); + return r; +} + +String common_suffix(const String& x, const String& y, int startpos) +{ + String r; + const char* xchars = x.chars(); + const char* ychars = y.chars(); + const char* xs = &(xchars[x.length() + startpos]); + const char* botx = xchars; + const char* ys = &(ychars[y.length() + startpos]); + const char* boty = ychars; + int l; + for (int l; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l); + r.rep = Salloc(r.rep, ++xs, l, l); + return r; +} + +#endif + +// IO + +istream& operator>>(istream& s, String& x) +{ + if (!s.ipfx(0) || (!(s.flags() & ios::skipws) && !ws(s))) + { + s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams. + return s; + } + int ch; + int i = 0; + x.rep = Sresize(x.rep, 20); + register streambuf *sb = s.rdbuf(); + while ((ch = sb->sbumpc()) != EOF) + { + if (isspace(ch)) + break; + if (i >= x.rep->sz - 1) + x.rep = Sresize(x.rep, i+1); + x.rep->s[i++] = ch; + } + x.rep->s[i] = 0; + x.rep->len = i; + int new_state = s.rdstate(); + if (i == 0) new_state |= ios::failbit; + if (ch == EOF) new_state |= ios::eofbit; + s.clear(new_state); + return s; +} + +int readline(istream& s, String& x, char terminator, int discard) +{ + if (!s.ipfx(0)) + return 0; + int ch; + int i = 0; + x.rep = Sresize(x.rep, 80); + register streambuf *sb = s.rdbuf(); + while ((ch = sb->sbumpc()) != EOF) + { + if (ch != terminator || !discard) + { + if (i >= x.rep->sz - 1) + x.rep = Sresize(x.rep, i+1); + x.rep->s[i++] = ch; + } + if (ch == terminator) + break; + } + x.rep->s[i] = 0; + x.rep->len = i; + if (ch == EOF) s.clear(ios::eofbit|s.rdstate()); + return i; +} + + +ostream& operator<<(ostream& s, const SubString& x) +{ + const char* a = x.chars(); + const char* lasta = &(a[x.length()]); + while (a < lasta) + s.put(*a++); + return(s); +} + +// from John.Willis@FAS.RI.CMU.EDU + +int String::freq(const SubString& y) const +{ + int found = 0; + for (unsigned int i = 0; i < length(); i++) + if (match(i,length(),0,y.chars(), y.length())>= 0) found++; + return(found); +} + +int String::freq(const String& y) const +{ + int found = 0; + for (unsigned int i = 0; i < length(); i++) + if (match(i,length(),0,y.chars(),y.length()) >= 0) found++; + return(found); +} + +int String::freq(const char* t) const +{ + int found = 0; + for (unsigned int i = 0; i < length(); i++) + if (match(i,length(),0,t) >= 0) found++; + return(found); +} + +int String::freq(char c) const +{ + int found = 0; + for (unsigned int i = 0; i < length(); i++) + if (match(i,length(),0,&c,1) >= 0) found++; + return(found); +} + + +int String::OK() const +{ + if (rep == 0 // don't have a rep + || rep->len > rep->sz // string oustide bounds + || rep->s[rep->len] != 0) // not null-terminated + error("invariant failure"); + return 1; +} + +int SubString::OK() const +{ + int v = S != (const char*)0; // have a String; + v &= S.OK(); // that is legal + v &= pos + len >= S.rep->len;// pos and len within bounds + if (!v) S.error("SubString invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/String.h b/gnu/lib/libg++/libg++/src/String.h new file mode 100644 index 00000000000..b3bfd707cf3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/String.h @@ -0,0 +1,1284 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _String_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _String_h 1 + +#include +#include + +#undef OK + +struct StrRep // internal String representations +{ + unsigned short len; // string length + unsigned short sz; // allocated space + char s[1]; // the string starts here + // (at least 1 char for trailing null) + // allocated & expanded via non-public fcts +}; + +// primitive ops on StrReps -- nearly all String fns go through these. + +StrRep* Salloc(StrRep*, const char*, int, int); +StrRep* Scopy(StrRep*, const StrRep*); +StrRep* Scat(StrRep*, const char*, int, const char*, int); +StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); +StrRep* Sprepend(StrRep*, const char*, int); +StrRep* Sreverse(const StrRep*, StrRep*); +StrRep* Supcase(const StrRep*, StrRep*); +StrRep* Sdowncase(const StrRep*, StrRep*); +StrRep* Scapitalize(const StrRep*, StrRep*); + +// These classes need to be defined in the order given + +class String; +class SubString; + +class SubString +{ + friend class String; +protected: + + String& S; // The String I'm a substring of + unsigned short pos; // starting position in S's rep + unsigned short len; // length of substring + + void assign(const StrRep*, const char*, int = -1); + SubString(String& x, int p, int l); + SubString(const SubString& x); + +public: + +// Note there are no public constructors. SubStrings are always +// created via String operations + + ~SubString(); + + SubString& operator = (const String& y); + SubString& operator = (const SubString& y); + SubString& operator = (const char* t); + SubString& operator = (char c); + +// return 1 if target appears anywhere in SubString; else 0 + + int contains(char c) const; + int contains(const String& y) const; + int contains(const SubString& y) const; + int contains(const char* t) const; + int contains(const Regex& r) const; + +// return 1 if target matches entire SubString + + int matches(const Regex& r) const; + +// IO + + friend ostream& operator<<(ostream& s, const SubString& x); + +// status + + unsigned int length() const; + int empty() const; + const char* chars() const; + + int OK() const; + +}; + + +class String +{ + friend class SubString; + +protected: + StrRep* rep; // Strings are pointers to their representations + +// some helper functions + + int search(int, int, const char*, int = -1) const; + int search(int, int, char) const; + int match(int, int, int, const char*, int = -1) const; + int _gsub(const char*, int, const char* ,int); + int _gsub(const Regex&, const char*, int); + SubString _substr(int, int); + +public: + +// constructors & assignment + + String(); + String(const String& x); + String(const SubString& x); + String(const char* t); + String(const char* t, int len); + String(char c); + + ~String(); + + String& operator = (const String& y); + String& operator = (const char* y); + String& operator = (char c); + String& operator = (const SubString& y); + +// concatenation + + String& operator += (const String& y); + String& operator += (const SubString& y); + String& operator += (const char* t); + String& operator += (char c); + + void prepend(const String& y); + void prepend(const SubString& y); + void prepend(const char* t); + void prepend(char c); + + +// procedural versions: +// concatenate first 2 args, store result in last arg + + friend inline void cat(const String&, const String&, String&); + friend inline void cat(const String&, const SubString&, String&); + friend inline void cat(const String&, const char*, String&); + friend inline void cat(const String&, char, String&); + + friend inline void cat(const SubString&, const String&, String&); + friend inline void cat(const SubString&, const SubString&, String&); + friend inline void cat(const SubString&, const char*, String&); + friend inline void cat(const SubString&, char, String&); + + friend inline void cat(const char*, const String&, String&); + friend inline void cat(const char*, const SubString&, String&); + friend inline void cat(const char*, const char*, String&); + friend inline void cat(const char*, char, String&); + +// double concatenation, by request. (yes, there are too many versions, +// but if one is supported, then the others should be too...) +// Concatenate first 3 args, store in last arg + + friend inline void cat(const String&,const String&, const String&,String&); + friend inline void cat(const String&,const String&,const SubString&,String&); + friend inline void cat(const String&,const String&, const char*, String&); + friend inline void cat(const String&,const String&, char, String&); + friend inline void cat(const String&,const SubString&,const String&,String&); + inline friend void cat(const String&,const SubString&,const SubString&,String&); + friend inline void cat(const String&,const SubString&, const char*, String&); + friend inline void cat(const String&,const SubString&, char, String&); + friend inline void cat(const String&,const char*, const String&, String&); + friend inline void cat(const String&,const char*, const SubString&, String&); + friend inline void cat(const String&,const char*, const char*, String&); + friend inline void cat(const String&,const char*, char, String&); + + friend inline void cat(const char*, const String&, const String&,String&); + friend inline void cat(const char*,const String&,const SubString&,String&); + friend inline void cat(const char*,const String&, const char*, String&); + friend inline void cat(const char*,const String&, char, String&); + friend inline void cat(const char*,const SubString&,const String&,String&); + friend inline void cat(const char*,const SubString&,const SubString&,String&); + friend inline void cat(const char*,const SubString&, const char*, String&); + friend inline void cat(const char*,const SubString&, char, String&); + friend inline void cat(const char*,const char*, const String&, String&); + friend inline void cat(const char*,const char*, const SubString&, String&); + friend inline void cat(const char*,const char*, const char*, String&); + friend inline void cat(const char*,const char*, char, String&); + + +// searching & matching + +// return position of target in string or -1 for failure + + int index(char c, int startpos = 0) const; + int index(const String& y, int startpos = 0) const; + int index(const SubString& y, int startpos = 0) const; + int index(const char* t, int startpos = 0) const; + int index(const Regex& r, int startpos = 0) const; + +// return 1 if target appears anyhere in String; else 0 + + int contains(char c) const; + int contains(const String& y) const; + int contains(const SubString& y) const; + int contains(const char* t) const; + int contains(const Regex& r) const; + +// return 1 if target appears anywhere after position pos +// (or before, if pos is negative) in String; else 0 + + int contains(char c, int pos) const; + int contains(const String& y, int pos) const; + int contains(const SubString& y, int pos) const; + int contains(const char* t, int pos) const; + int contains(const Regex& r, int pos) const; + +// return 1 if target appears at position pos in String; else 0 + + int matches(char c, int pos = 0) const; + int matches(const String& y, int pos = 0) const; + int matches(const SubString& y, int pos = 0) const; + int matches(const char* t, int pos = 0) const; + int matches(const Regex& r, int pos = 0) const; + +// return number of occurences of target in String + + int freq(char c) const; + int freq(const String& y) const; + int freq(const SubString& y) const; + int freq(const char* t) const; + +// SubString extraction + +// Note that you can't take a substring of a const String, since +// this leaves open the possiblility of indirectly modifying the +// String through the SubString + + SubString at(int pos, int len); + SubString operator () (int pos, int len); // synonym for at + + SubString at(const String& x, int startpos = 0); + SubString at(const SubString& x, int startpos = 0); + SubString at(const char* t, int startpos = 0); + SubString at(char c, int startpos = 0); + SubString at(const Regex& r, int startpos = 0); + + SubString before(int pos); + SubString before(const String& x, int startpos = 0); + SubString before(const SubString& x, int startpos = 0); + SubString before(const char* t, int startpos = 0); + SubString before(char c, int startpos = 0); + SubString before(const Regex& r, int startpos = 0); + + SubString through(int pos); + SubString through(const String& x, int startpos = 0); + SubString through(const SubString& x, int startpos = 0); + SubString through(const char* t, int startpos = 0); + SubString through(char c, int startpos = 0); + SubString through(const Regex& r, int startpos = 0); + + SubString from(int pos); + SubString from(const String& x, int startpos = 0); + SubString from(const SubString& x, int startpos = 0); + SubString from(const char* t, int startpos = 0); + SubString from(char c, int startpos = 0); + SubString from(const Regex& r, int startpos = 0); + + SubString after(int pos); + SubString after(const String& x, int startpos = 0); + SubString after(const SubString& x, int startpos = 0); + SubString after(const char* t, int startpos = 0); + SubString after(char c, int startpos = 0); + SubString after(const Regex& r, int startpos = 0); + + +// deletion + +// delete len chars starting at pos + void del(int pos, int len); + +// delete the first occurrence of target after startpos + + void del(const String& y, int startpos = 0); + void del(const SubString& y, int startpos = 0); + void del(const char* t, int startpos = 0); + void del(char c, int startpos = 0); + void del(const Regex& r, int startpos = 0); + +// global substitution: substitute all occurrences of pat with repl + + int gsub(const String& pat, const String& repl); + int gsub(const SubString& pat, const String& repl); + int gsub(const char* pat, const String& repl); + int gsub(const char* pat, const char* repl); + int gsub(const Regex& pat, const String& repl); + +// friends & utilities + +// split string into array res at separators; return number of elements + + friend int split(const String& x, String res[], int maxn, + const String& sep); + friend int split(const String& x, String res[], int maxn, + const Regex& sep); + + friend String common_prefix(const String& x, const String& y, + int startpos = 0); + friend String common_suffix(const String& x, const String& y, + int startpos = -1); + friend String replicate(char c, int n); + friend String replicate(const String& y, int n); + friend String join(String src[], int n, const String& sep); + +// simple builtin transformations + + friend inline String reverse(const String& x); + friend inline String upcase(const String& x); + friend inline String downcase(const String& x); + friend inline String capitalize(const String& x); + +// in-place versions of above + + void reverse(); + void upcase(); + void downcase(); + void capitalize(); + +// element extraction + + char& operator [] (int i); + const char& operator [] (int i) const; + char elem(int i) const; + char firstchar() const; + char lastchar() const; + +// conversion + + operator const char*() const; + const char* chars() const; + + +// IO + + friend inline ostream& operator<<(ostream& s, const String& x); + friend ostream& operator<<(ostream& s, const SubString& x); + friend istream& operator>>(istream& s, String& x); + + friend int readline(istream& s, String& x, + char terminator = '\n', + int discard_terminator = 1); + +// status + + unsigned int length() const; + int empty() const; + +// preallocate some space for String + void alloc(int newsize); + +// report current allocation (not length!) + + int allocation() const; + + + void error(const char* msg) const; + + int OK() const; +}; + +typedef String StrTmp; // for backward compatibility + +// other externs + +int compare(const String& x, const String& y); +int compare(const String& x, const SubString& y); +int compare(const String& x, const char* y); +int compare(const SubString& x, const String& y); +int compare(const SubString& x, const SubString& y); +int compare(const SubString& x, const char* y); +int fcompare(const String& x, const String& y); // ignore case + +extern StrRep _nilStrRep; +extern String _nilString; + +// status reports, needed before defining other things + +inline unsigned int String::length() const { return rep->len; } +inline int String::empty() const { return rep->len == 0; } +inline const char* String::chars() const { return &(rep->s[0]); } +inline int String::allocation() const { return rep->sz; } + +inline unsigned int SubString::length() const { return len; } +inline int SubString::empty() const { return len == 0; } +inline const char* SubString::chars() const { return &(S.rep->s[pos]); } + + +// constructors + +inline String::String() + : rep(&_nilStrRep) {} +inline String::String(const String& x) + : rep(Scopy(0, x.rep)) {} +inline String::String(const char* t) + : rep(Salloc(0, t, -1, -1)) {} +inline String::String(const char* t, int tlen) + : rep(Salloc(0, t, tlen, tlen)) {} +inline String::String(const SubString& y) + : rep(Salloc(0, y.chars(), y.length(), y.length())) {} +inline String::String(char c) + : rep(Salloc(0, &c, 1, 1)) {} + +inline String::~String() { if (rep != &_nilStrRep) delete rep; } + +inline SubString::SubString(const SubString& x) + :S(x.S), pos(x.pos), len(x.len) {} +inline SubString::SubString(String& x, int first, int l) + :S(x), pos(first), len(l) {} + +inline SubString::~SubString() {} + +// assignment + +inline String& String::operator = (const String& y) +{ + rep = Scopy(rep, y.rep); + return *this; +} + +inline String& String::operator=(const char* t) +{ + rep = Salloc(rep, t, -1, -1); + return *this; +} + +inline String& String::operator=(const SubString& y) +{ + rep = Salloc(rep, y.chars(), y.length(), y.length()); + return *this; +} + +inline String& String::operator=(char c) +{ + rep = Salloc(rep, &c, 1, 1); + return *this; +} + + +inline SubString& SubString::operator = (const char* ys) +{ + assign(0, ys); + return *this; +} + +inline SubString& SubString::operator = (char ch) +{ + assign(0, &ch, 1); + return *this; +} + +inline SubString& SubString::operator = (const String& y) +{ + assign(y.rep, y.chars(), y.length()); + return *this; +} + +inline SubString& SubString::operator = (const SubString& y) +{ + assign(y.S.rep, y.chars(), y.length()); + return *this; +} + +// Zillions of cats... + +inline void cat(const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); +} + +inline void cat(const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); +} + +inline void cat(const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); +} + +inline void cat(const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y, -1); +} + +inline void cat(const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, x, -1, &y, 1); +} + +inline void cat(const String& a, const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); +} + +inline void cat(const String& a, const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); +} + +inline void cat(const String& a, const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); +} + +inline void cat(const String& a, const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); +} + +inline void cat(const String& a, const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); +} + +inline void cat(const String& a, const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); +} + +inline void cat(const String& a, const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); +} + +inline void cat(const String& a, const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); +} + + +inline void cat(const char* a, const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); +} + +inline void cat(const char* a, const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* a, const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); +} + +inline void cat(const char* a, const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* a, const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* a, const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* a, const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y, -1); +} + +inline void cat(const char* a, const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); +} + + +// operator versions + +inline String& String::operator +=(const String& y) +{ + cat(*this, y, *this); + return *this; +} + +inline String& String::operator +=(const SubString& y) +{ + cat(*this, y, *this); + return *this; +} + +inline String& String::operator += (const char* y) +{ + cat(*this, y, *this); + return *this; +} + +inline String& String:: operator +=(char y) +{ + cat(*this, y, *this); + return *this; +} + +// constructive concatenation + +#if defined(__GNUG__) && !defined(_G_NO_NRV) + +inline String operator + (const String& x, const String& y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const String& x, const SubString& y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const String& x, const char* y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const String& x, char y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const SubString& x, const String& y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const SubString& x, const SubString& y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const SubString& x, const char* y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const SubString& x, char y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const char* x, const String& y) return r; +{ + cat(x, y, r); +} + +inline String operator + (const char* x, const SubString& y) return r; +{ + cat(x, y, r); +} + +inline String reverse(const String& x) return r; +{ + r.rep = Sreverse(x.rep, r.rep); +} + +inline String upcase(const String& x) return r; +{ + r.rep = Supcase(x.rep, r.rep); +} + +inline String downcase(const String& x) return r; +{ + r.rep = Sdowncase(x.rep, r.rep); +} + +inline String capitalize(const String& x) return r; +{ + r.rep = Scapitalize(x.rep, r.rep); +} + +#else /* NO_NRV */ + +inline String operator + (const String& x, const String& y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const String& x, const SubString& y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const String& x, const char* y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const String& x, char y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const SubString& x, const String& y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const SubString& x, const SubString& y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const SubString& x, const char* y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const SubString& x, char y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const char* x, const String& y) +{ + String r; cat(x, y, r); return r; +} + +inline String operator + (const char* x, const SubString& y) +{ + String r; cat(x, y, r); return r; +} + +inline String reverse(const String& x) +{ + String r; r.rep = Sreverse(x.rep, r.rep); return r; +} + +inline String upcase(const String& x) +{ + String r; r.rep = Supcase(x.rep, r.rep); return r; +} + +inline String downcase(const String& x) +{ + String r; r.rep = Sdowncase(x.rep, r.rep); return r; +} + +inline String capitalize(const String& x) +{ + String r; r.rep = Scapitalize(x.rep, r.rep); return r; +} + +#endif + +// prepend + +inline void String::prepend(const String& y) +{ + rep = Sprepend(rep, y.chars(), y.length()); +} + +inline void String::prepend(const char* y) +{ + rep = Sprepend(rep, y, -1); +} + +inline void String::prepend(char y) +{ + rep = Sprepend(rep, &y, 1); +} + +inline void String::prepend(const SubString& y) +{ + rep = Sprepend(rep, y.chars(), y.length()); +} + +// misc transformations + + +inline void String::reverse() +{ + rep = Sreverse(rep, rep); +} + + +inline void String::upcase() +{ + rep = Supcase(rep, rep); +} + + +inline void String::downcase() +{ + rep = Sdowncase(rep, rep); +} + + +inline void String::capitalize() +{ + rep = Scapitalize(rep, rep); +} + +// element extraction + +inline char& String::operator [] (int i) +{ + if (((unsigned)i) >= length()) error("invalid index"); + return rep->s[i]; +} + +inline const char& String::operator [] (int i) const +{ + if (((unsigned)i) >= length()) error("invalid index"); + return rep->s[i]; +} + +inline char String::elem (int i) const +{ + if (((unsigned)i) >= length()) error("invalid index"); + return rep->s[i]; +} + +inline char String::firstchar() const +{ + return elem(0); +} + +inline char String::lastchar() const +{ + return elem(length() - 1); +} + +// searching + +inline int String::index(char c, int startpos) const +{ + return search(startpos, length(), c); +} + +inline int String::index(const char* t, int startpos) const +{ + return search(startpos, length(), t); +} + +inline int String::index(const String& y, int startpos) const +{ + return search(startpos, length(), y.chars(), y.length()); +} + +inline int String::index(const SubString& y, int startpos) const +{ + return search(startpos, length(), y.chars(), y.length()); +} + +inline int String::index(const Regex& r, int startpos) const +{ + int unused; return r.search(chars(), length(), unused, startpos); +} + +inline int String::contains(char c) const +{ + return search(0, length(), c) >= 0; +} + +inline int String::contains(const char* t) const +{ + return search(0, length(), t) >= 0; +} + +inline int String::contains(const String& y) const +{ + return search(0, length(), y.chars(), y.length()) >= 0; +} + +inline int String::contains(const SubString& y) const +{ + return search(0, length(), y.chars(), y.length()) >= 0; +} + +inline int String::contains(char c, int p) const +{ + return match(p, length(), 0, &c, 1) >= 0; +} + +inline int String::contains(const char* t, int p) const +{ + return match(p, length(), 0, t) >= 0; +} + +inline int String::contains(const String& y, int p) const +{ + return match(p, length(), 0, y.chars(), y.length()) >= 0; +} + +inline int String::contains(const SubString& y, int p) const +{ + return match(p, length(), 0, y.chars(), y.length()) >= 0; +} + +inline int String::contains(const Regex& r) const +{ + int unused; return r.search(chars(), length(), unused, 0) >= 0; +} + +inline int String::contains(const Regex& r, int p) const +{ + return r.match(chars(), length(), p) >= 0; +} + + +inline int String::matches(const SubString& y, int p) const +{ + return match(p, length(), 1, y.chars(), y.length()) >= 0; +} + +inline int String::matches(const String& y, int p) const +{ + return match(p, length(), 1, y.chars(), y.length()) >= 0; +} + +inline int String::matches(const char* t, int p) const +{ + return match(p, length(), 1, t) >= 0; +} + +inline int String::matches(char c, int p) const +{ + return match(p, length(), 1, &c, 1) >= 0; +} + +inline int String::matches(const Regex& r, int p) const +{ + int l = (p < 0)? -p : length() - p; + return r.match(chars(), length(), p) == l; +} + + +inline int SubString::contains(const char* t) const +{ + return S.search(pos, pos+len, t) >= 0; +} + +inline int SubString::contains(const String& y) const +{ + return S.search(pos, pos+len, y.chars(), y.length()) >= 0; +} + +inline int SubString::contains(const SubString& y) const +{ + return S.search(pos, pos+len, y.chars(), y.length()) >= 0; +} + +inline int SubString::contains(char c) const +{ + return S.search(pos, pos+len, c) >= 0; +} + +inline int SubString::contains(const Regex& r) const +{ + int unused; return r.search(chars(), len, unused, 0) >= 0; +} + +inline int SubString::matches(const Regex& r) const +{ + return r.match(chars(), len, 0) == len; +} + + +inline int String::gsub(const String& pat, const String& r) +{ + return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); +} + +inline int String::gsub(const SubString& pat, const String& r) +{ + return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); +} + +inline int String::gsub(const Regex& pat, const String& r) +{ + return _gsub(pat, r.chars(), r.length()); +} + +inline int String::gsub(const char* pat, const String& r) +{ + return _gsub(pat, -1, r.chars(), r.length()); +} + +inline int String::gsub(const char* pat, const char* r) +{ + return _gsub(pat, -1, r, -1); +} + + + +inline ostream& operator<<(ostream& s, const String& x) +{ + s << x.chars(); return s; +} + +// a zillion comparison operators + +inline int operator==(const String& x, const String& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const String& x, const String& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const String& x, const String& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const String& x, const String& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const String& x, const String& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const String& x, const String& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const String& x, const SubString& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const String& x, const SubString& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const String& x, const SubString& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const String& x, const SubString& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const String& x, const SubString& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const String& x, const SubString& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const String& x, const char* t) +{ + return compare(x, t) == 0; +} + +inline int operator!=(const String& x, const char* t) +{ + return compare(x, t) != 0; +} + +inline int operator>(const String& x, const char* t) +{ + return compare(x, t) > 0; +} + +inline int operator>=(const String& x, const char* t) +{ + return compare(x, t) >= 0; +} + +inline int operator<(const String& x, const char* t) +{ + return compare(x, t) < 0; +} + +inline int operator<=(const String& x, const char* t) +{ + return compare(x, t) <= 0; +} + +inline int operator==(const SubString& x, const String& y) +{ + return compare(y, x) == 0; +} + +inline int operator!=(const SubString& x, const String& y) +{ + return compare(y, x) != 0; +} + +inline int operator>(const SubString& x, const String& y) +{ + return compare(y, x) < 0; +} + +inline int operator>=(const SubString& x, const String& y) +{ + return compare(y, x) <= 0; +} + +inline int operator<(const SubString& x, const String& y) +{ + return compare(y, x) > 0; +} + +inline int operator<=(const SubString& x, const String& y) +{ + return compare(y, x) >= 0; +} + +inline int operator==(const SubString& x, const SubString& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const SubString& x, const SubString& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const SubString& x, const SubString& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const SubString& x, const SubString& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const SubString& x, const SubString& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const SubString& x, const SubString& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const SubString& x, const char* t) +{ + return compare(x, t) == 0; +} + +inline int operator!=(const SubString& x, const char* t) +{ + return compare(x, t) != 0; +} + +inline int operator>(const SubString& x, const char* t) +{ + return compare(x, t) > 0; +} + +inline int operator>=(const SubString& x, const char* t) +{ + return compare(x, t) >= 0; +} + +inline int operator<(const SubString& x, const char* t) +{ + return compare(x, t) < 0; +} + +inline int operator<=(const SubString& x, const char* t) +{ + return compare(x, t) <= 0; +} + + +// a helper needed by at, before, etc. + +inline SubString String::_substr(int first, int l) +{ + if (first < 0 || (unsigned)(first + l) > length() ) + return SubString(_nilString, 0, 0) ; + else + return SubString(*this, first, l); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Uniform.cc b/gnu/lib/libg++/libg++/src/Uniform.cc new file mode 100644 index 00000000000..0592b6d9781 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Uniform.cc @@ -0,0 +1,27 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +double Uniform::operator()() +{ + return( pLow + delta * pGenerator -> asDouble() ); +} diff --git a/gnu/lib/libg++/libg++/src/Uniform.h b/gnu/lib/libg++/libg++/src/Uniform.h new file mode 100644 index 00000000000..1a365b9a774 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Uniform.h @@ -0,0 +1,71 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Uniform_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Uniform_h 1 + +#include + +// +// The interval [lo..hi] +// + +class Uniform: public Random { + double pLow; + double pHigh; + double delta; +public: + Uniform(double low, double high, RNG *gen); + + double low(); + double low(double x); + double high(); + double high(double x); + + virtual double operator()(); +}; + + +inline Uniform::Uniform(double low, double high, RNG *gen) : Random(gen) +{ + pLow = (low < high) ? low : high; + pHigh = (low < high) ? high : low; + delta = pHigh - pLow; +} + +inline double Uniform::low() { return pLow; } + +inline double Uniform::low(double x) { + double tmp = pLow; + pLow = x; + delta = pHigh - pLow; + return tmp; +} + +inline double Uniform::high() { return pHigh; } + +inline double Uniform::high(double x) { + double tmp = pHigh; + pHigh = x; + delta = pHigh - pLow; + return tmp; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/Weibull.cc b/gnu/lib/libg++/libg++/src/Weibull.cc new file mode 100644 index 00000000000..d7987f5ece0 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Weibull.cc @@ -0,0 +1,33 @@ +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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 +#include +#include + +// +// See Simulation, Modelling & Analysis by Law & Kelton, pp259 +// +// This is the ``polar'' method. +// + +double Weibull::operator()() +{ + return( pow(pBeta * ( - log(1 - pGenerator -> asDouble()) ), pInvAlpha) ); +} diff --git a/gnu/lib/libg++/libg++/src/Weibull.h b/gnu/lib/libg++/libg++/src/Weibull.h new file mode 100644 index 00000000000..fd064d5e619 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/Weibull.h @@ -0,0 +1,74 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.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. +*/ +#ifndef _Weibull_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Weibull_h + +#include + +class Weibull: public Random { +protected: + double pAlpha; + double pInvAlpha; + double pBeta; + + void setState(); + +public: + Weibull(double alpha, double beta, RNG *gen); + + double alpha(); + double alpha(double x); + + double beta(); + double beta(double x); + + virtual double operator()(); +}; + + +inline void Weibull::setState() { + pInvAlpha = 1.0 / pAlpha; +} + +inline Weibull::Weibull(double alpha, double beta, RNG *gen) : Random(gen) +{ + pAlpha = alpha; + pBeta = beta; + setState(); +} + +inline double Weibull::alpha() { return pAlpha; } + +inline double Weibull::alpha(double x) { + double tmp = pAlpha; + pAlpha = x; + setState(); + return tmp; +} + +inline double Weibull::beta() { return pBeta; }; +inline double Weibull::beta(double x) { + double tmp = pBeta; + pBeta = x; + return tmp; +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/bitand.c b/gnu/lib/libg++/libg++/src/bitand.c new file mode 100644 index 00000000000..149a8ab7386 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitand.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT. + This will work even if psrc & pdst overlap. */ + +void +_BS_and (pdst, dstbit, psrc, srcbit, length) + register _BS_word* pdst; + int dstbit; + register const _BS_word* psrc; + int srcbit; + _BS_size_t length; +{ +#define COMBINE(dst, src) (dst) & (src) +#include "bitdo2.h" +} diff --git a/gnu/lib/libg++/libg++/src/bitany.c b/gnu/lib/libg++/libg++/src/bitany.c new file mode 100644 index 00000000000..5a978d030d9 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitany.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +int +_BS_any (ptr, offset, length) + register const _BS_word *ptr; + int offset; + _BS_size_t length; +{ +#undef DOIT +#define DOIT(WORD, MASK) if ((WORD) & (MASK)) return 1; +#include "bitdo1.h" + return 0; +} diff --git a/gnu/lib/libg++/libg++/src/bitblt.c b/gnu/lib/libg++/libg++/src/bitblt.c new file mode 100644 index 00000000000..b38fd3d9eb1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitblt.c @@ -0,0 +1,97 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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). + Based on ideas in the X11 MFB server. */ + +#include "bitprims.h" +#define ONES ((_BS_word)(~0)) + +/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT. + This will work even if psrc & pdst overlap. */ + +void +_BS_blt (op, pdst, dstbit, psrc, srcbit, length) + enum _BS_alu op; + register _BS_word* pdst; + int dstbit; + register const _BS_word* psrc; + int srcbit; + _BS_size_t length; +{ + _BS_word ca1, cx1, ca2, cx2; + switch (op) + { + case _BS_alu_clear: + _BS_clear (pdst, dstbit, length); + return; + case _BS_alu_and: + _BS_and (pdst, dstbit, psrc, srcbit, length); + return; + case _BS_alu_andReverse: + ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = 0; + break; + case _BS_alu_copy: + _BS_copy (pdst, dstbit, psrc, srcbit, length); + return; + case _BS_alu_andInverted: + ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = 0; + break; + case _BS_alu_noop: + return; + case _BS_alu_xor: + _BS_xor (pdst, dstbit, psrc, srcbit, length); + return; + case _BS_alu_or: + ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = 0; + break; + case _BS_alu_nor: + ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = ONES; + break; + case_BS_alu_equiv: + ca1 = 0; cx1 = ONES; ca2 = ONES; cx2 = ONES; + break; + case _BS_alu_invert: + _BS_invert (pdst, dstbit, length); + return; + case _BS_alu_orReverse: + ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = ONES; + break; + case _BS_alu_copyInverted: + ca1 = 0; cx1 = 0; ca2 = ONES; cx2 = ONES; + break; + case _BS_alu_orInverted: + ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = ONES; + break; + case _BS_alu_nand: + ca1 = ONES; cx1 = 0; ca2 = 0; cx2 = ONES; + break; + case _BS_alu_set: + _BS_set (pdst, dstbit, length); + return; + } + { +#define COMBINE(dst, src) ((dst) & ((src) & ca1 ^ cx1) ^ ((src) & ca2 ^ cx2)) +#include "bitdo2.h" + } +} diff --git a/gnu/lib/libg++/libg++/src/bitclear.c b/gnu/lib/libg++/libg++/src/bitclear.c new file mode 100644 index 00000000000..6dd94059ad6 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitclear.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +void +_BS_clear (ptr, offset, length) + register _BS_word *ptr; + int offset; + _BS_size_t length; +{ +#undef DOIT +#define DOIT(WORD, MASK) ((WORD) &= ~(MASK)) +#include "bitdo1.h" +} diff --git a/gnu/lib/libg++/libg++/src/bitcopy.c b/gnu/lib/libg++/libg++/src/bitcopy.c new file mode 100644 index 00000000000..aa48730e8d6 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitcopy.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT. + This will work even if psrc & pdst overlap. */ + +void +_BS_copy (pdst, dstbit, psrc, srcbit, length) + register _BS_word* pdst; + int dstbit; + register const _BS_word* psrc; + int srcbit; + _BS_size_t length; +{ +#define COMBINE(dst, src) (src) +#include "bitdo2.h" +} diff --git a/gnu/lib/libg++/libg++/src/bitcount.c b/gnu/lib/libg++/libg++/src/bitcount.c new file mode 100644 index 00000000000..9583a827e4a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitcount.c @@ -0,0 +1,64 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +/* bit_count[I] is number of '1' bits in I. */ +static const unsigned char +four_bit_count[16] = { + 0, 1, 1, 2, + 1, 2, 2, 3, + 1, 2, 2, 3, + 2, 3, 3, 4}; + +#if !defined(inline) && !defined(__GNUC__) && !defined(__cplusplus) +#define inline +#endif + +static inline int +_BS_count_word (word) + register _BS_word word; +{ + register int count = 0; + while (word > 0) + { + count += four_bit_count[word & 15]; + word >>= 4; + } + return count; +} + +int +_BS_count (ptr, offset, length) + register const _BS_word *ptr; + int offset; + _BS_size_t length; +{ + register int count = 0; +#undef DOIT +#define DOIT(WORD, MASK) count += _BS_count_word ((WORD) & (MASK)); +#include "bitdo1.h" + return count; +} diff --git a/gnu/lib/libg++/libg++/src/bitdo1.h b/gnu/lib/libg++/libg++/src/bitdo1.h new file mode 100644 index 00000000000..c234d41d406 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitdo1.h @@ -0,0 +1,32 @@ +#ifndef ONES +#define ONES ((_BS_word)(~0L)) +#endif + register int nwords; + register _BS_word mask; + if (offset == 0) + ; + else if (offset + length >= _BS_BITS_PER_WORD) + { + mask = ONES _BS_RIGHT offset; + DOIT(*ptr++, mask); + length -= _BS_BITS_PER_WORD - offset; + } + else + { + mask = (ONES _BS_RIGHT (_BS_BITS_PER_WORD - length)) + _BS_LEFT (_BS_BITS_PER_WORD - length - offset); + DOIT(*ptr, mask); + goto done; + } + nwords = _BS_INDEX(length); + while (--nwords >= 0) + { + DOIT(*ptr++, ONES); + } + length = _BS_POS (length); + if (length) + { + mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); + DOIT(*ptr, mask); + } + done: ; diff --git a/gnu/lib/libg++/libg++/src/bitdo2.h b/gnu/lib/libg++/libg++/src/bitdo2.h new file mode 100644 index 00000000000..6e995235372 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitdo2.h @@ -0,0 +1,184 @@ +#ifndef ONES +#define ONES ((_BS_word)(~0L)) +#endif + +#ifndef DOIT_SOLID +#ifdef DOIT +#define DOIT_SOLID(dst, src) DOIT(dst, src, (_BS_word)(~0)) +#else +#define DOIT_SOLID(dst, src) (dst) = (COMBINE(dst, src)) +#endif +#endif + +#ifndef DOIT +#define DOIT(dst, src, mask) \ + (dst) = ((COMBINE(dst, src)) & (mask)) | ((dst) & ~(mask)) +#endif + + _BS_word word0, mask; + int shift0, shift1; + + if (length == 0) + goto done; + + shift0 = srcbit - dstbit; + + /* First handle the case that only one destination word is touched. */ + if (length + dstbit <= _BS_BITS_PER_WORD) + { + _BS_word mask + = (ONES _BS_LEFT (_BS_BITS_PER_WORD - length)) _BS_RIGHT dstbit; + _BS_word word0 = *psrc++; + if (shift0 <= 0) /* dstbit >= srcbit */ + { + word0 = word0 _BS_RIGHT (-shift0); + } + else + { + word0 = word0 _BS_LEFT shift0; + if (length + srcbit > _BS_BITS_PER_WORD) + word0 = word0 | (*psrc _BS_RIGHT (_BS_BITS_PER_WORD - shift0)); + } + DOIT(*pdst, word0, mask); + goto done; + } + + /* Next optimize the case that the source and destination are aligned. */ + if (shift0 == 0) + { + _BS_word mask; + if (psrc > pdst) + { + if (srcbit) + { + mask = ONES _BS_RIGHT srcbit; + DOIT(*pdst, *psrc, mask); + pdst++; psrc++; + length -= _BS_BITS_PER_WORD - srcbit; + } + for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) + { + DOIT_SOLID(*pdst, *psrc); + pdst++; psrc++; + } + if (length) + { + mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); + DOIT(*pdst, *psrc, mask); + } + } + else if (psrc < pdst) + { + _BS_size_t span = srcbit + length; + pdst += span / (_BS_size_t)_BS_BITS_PER_WORD; + psrc += span / (_BS_size_t)_BS_BITS_PER_WORD; + span %= (_BS_size_t)_BS_BITS_PER_WORD; + if (span) + { + mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - span); + DOIT(*pdst, *psrc, mask); + length -= span; + } + pdst--; psrc--; + for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) + { + DOIT_SOLID(*pdst, *psrc); + pdst--; psrc--; + } + if (srcbit) + { + mask = ONES _BS_RIGHT srcbit; + DOIT(*pdst, *psrc, mask); + } + } + /* else if (psrc == pdst) --nothing to do--; */ + goto done; + } + + /* Now we assume shift!=0, and more than on destination word is changed. */ + if (psrc >= pdst) /* Do the updates in forward direction. */ + { + _BS_word word0 = *psrc++; + _BS_word mask = ONES _BS_RIGHT dstbit; + if (shift0 > 0) + { + _BS_word word1 = *psrc++; + shift1 = _BS_BITS_PER_WORD - shift0; + DOIT(*pdst, (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1), mask); + word0 = word1; + } + else /* dstbit > srcbit */ + { + shift1 = -shift0; + shift0 += _BS_BITS_PER_WORD; + DOIT(*pdst, word0 _BS_RIGHT shift1, mask); + } + pdst++; + length -= _BS_BITS_PER_WORD - dstbit; + + for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) + { + register _BS_word word1 = *psrc++; + DOIT_SOLID(*pdst, + (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1)); + pdst++; + word0 = word1; + } + if (length > 0) + { + _BS_size_t mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); + word0 = word0 _BS_LEFT shift0; + if (length > shift1) + word0 = word0 | (*psrc _BS_RIGHT shift1) ; + DOIT (*pdst, word0, mask); + } + } + else /* Do the updates in backward direction. */ + { + _BS_word word0; + + /* Make (psrc, srcbit) and (pdst, dstbit) point to *last* bit. */ + psrc += (srcbit + length - 1) / _BS_BITS_PER_WORD; + srcbit = (srcbit + length - 1) % _BS_BITS_PER_WORD; + pdst += (dstbit + length - 1) / _BS_BITS_PER_WORD; + dstbit = (dstbit + length - 1) % _BS_BITS_PER_WORD; + + shift0 = srcbit - dstbit; + + word0 = *psrc--; + mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - 1 - dstbit); + if (shift0 < 0) + { + _BS_word word1 = *psrc--; + shift1 = -shift0; + shift0 += _BS_BITS_PER_WORD; + DOIT (*pdst, (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0), + mask); + word0 = word1; + } + else + { + shift1 = _BS_BITS_PER_WORD - shift0; + DOIT(*pdst, word0 _BS_LEFT shift0, mask); + } + pdst--; + length -= dstbit + 1; + + for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) + { + register _BS_word word1 = *psrc--; + DOIT_SOLID(*pdst, + (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0)); + pdst--; + word0 = word1; + } + if (length > 0) + { + _BS_size_t mask = ONES _BS_RIGHT (_BS_BITS_PER_WORD - length); + word0 = word0 _BS_RIGHT shift1; + if (length > shift0) + word0 = word0 | (*psrc _BS_LEFT shift0) ; + DOIT (*pdst, word0, mask); + } + } + done: ; diff --git a/gnu/lib/libg++/libg++/src/bitinvert.c b/gnu/lib/libg++/libg++/src/bitinvert.c new file mode 100644 index 00000000000..558c397838c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitinvert.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +void +_BS_invert (ptr, offset, length) + register _BS_word *ptr; + int offset; + _BS_size_t length; +{ +#undef DOIT +#define DOIT(WORD, MASK) ((WORD) ^= (MASK)) +#include "bitdo1.h" +} diff --git a/gnu/lib/libg++/libg++/src/bitlcomp.c b/gnu/lib/libg++/libg++/src/bitlcomp.c new file mode 100644 index 00000000000..8b52943aa72 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitlcomp.c @@ -0,0 +1,81 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" +#include + +/* Return -1, 0, 1 depending on whether (ptr0, len0) is + lexicographically less than, equal, or greater than (ptr1, len1). + Both bitstrings must be left-aligned. */ + +int +_BS_lcompare_0 (ptr0, len0, ptr1, len1) + register _BS_word *ptr0; + _BS_size_t len0; + register _BS_word *ptr1; + _BS_size_t len1; +{ + _BS_size_t nwords0 = len0 / _BS_BITS_PER_WORD; + _BS_size_t nwords1 = len1 / _BS_BITS_PER_WORD; + register _BS_word word0, word1; + _BS_size_t nwords = nwords0 > nwords1 ? nwords1 : nwords0; + for (; nwords != 0; nwords--) + { + word0 = *ptr0++; + word1 = *ptr1++; + if (word0 != word1) + { +#if _BS_BIGENDIAN + return (word0 < word1) ? -1 : 1; +#else + { + _BS_word diff=(word0^word1); /* one's where different */ + _BS_word mask=diff&~(diff-1); /* first bit different */ + return (word0&mask)?1:-1; + } +#endif + } + } + len0 -= nwords0 * _BS_BITS_PER_WORD; + len1 -= nwords1 * _BS_BITS_PER_WORD; + if (len0 == 0 || len1 == 0) + return (len1 == 0) - (len0 == 0); + len0 &= _BS_BITS_PER_WORD - 1; + len1 &= _BS_BITS_PER_WORD - 1; + word0 = *ptr0++ & ~((_BS_word)(~0) _BS_RIGHT len0); + word1 = *ptr1++ & ~((_BS_word)(~0) _BS_RIGHT len1); + if (word0 == word1) + return len0 == len1 ? 0 : len0 < len1 ? -1 : 1; +#if _BS_BIGENDIAN + return (word0 < word1) ? -1 : 1; +#else + { + _BS_word diff=(word0^word1); /* one's where different */ + _BS_word mask=diff&~(diff-1); /* first bit different */ + return (word0&mask)?1:-1; + } +#endif +} + diff --git a/gnu/lib/libg++/libg++/src/bitprims.h b/gnu/lib/libg++/libg++/src/bitprims.h new file mode 100644 index 00000000000..737562dce89 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitprims.h @@ -0,0 +1,124 @@ +#ifndef _BS_PRIMS +#define _BS_PRIMS + +/* A bitstring is an array of _BS_word. */ +typedef unsigned long _BS_word; + +#define _BS_CHAR_BIT 8 +#define _BS_BITS_PER_WORD (_BS_CHAR_BIT*sizeof(_BS_word)) +#define _BS_WORDS_NEEDED(NBITS) ((NBITS+_BS_BITS_PER_WORD-1)/_BS_BITS_PER_WORD) + +/* For now, we number the bits in a _BS_word in little-endian order. + Later, might use machine order. */ +#ifdef CHILL_LIB +#ifndef BITS_BIG_ENDIAN +#include "config.h" +#endif +#define _BS_BIGENDIAN BITS_BIG_ENDIAN +#else +#define _BS_BIGENDIAN 0 +#endif + +/* By "left" we mean where bit number 0 is. + Hence, so left shift is << if we're numbering the bits in big-endian oder, + and >> if we're numbering the bits in little-endian order. + Currently, we always use little-endian order. + Later, we might use machine-endian order. */ +#if _BS_BIGENDIAN +#define _BS_LEFT << +#define _BS_RIGHT >> +#else +#define _BS_LEFT >> +#define _BS_RIGHT << +#endif + +#if _BS_BIGENDIAN +#define _BS_BITMASK(BITNO) ((_BS_word)1 << (_BS_BITS_PER_WORD - 1 - (BITNO))) +#else +#define _BS_BITMASK(BITNO) ((_BS_word)1 << (BITNO)) +#endif + +/* Given a PTR which may not be aligned on a _BS_word boundary, + set NEW_PTR to point to (the beginning of) the corresponding _BS_word. + Adjust the bit-offset OFFSET to compensate for the difference. */ +#define _BS_ADJUST_ALIGNED(NEW_PTR, PTR, OFFSET) \ + ( (NEW_PTR) = (_BS_word*)(((char*)(PTR)-(char*)0) & ~(sizeof(_BS_word)-1)), \ + (OFFSET) += (char*)(PTR) - (char*)(NEW_PTR) ) + +/* Given a bit point (PTR, OFFSET) normalize it so that + OFFSET < _BS_BITS_PER_WORD. */ +#define _BS_NORMALIZE(PTR, OFFSET) \ +{ _BS_size_t __tmp_ind = _BS_INDEX (OFFSET); \ + (PTR) += __tmp_ind; \ + (OFFSET) -= __tmp_ind * _BS_BITS_PER_WORD; } + +#define _BS_INDEX(I) ((unsigned)(I) / _BS_BITS_PER_WORD) +#define _BS_POS(I) ((I) & (_BS_BITS_PER_WORD -1 )) + +#ifndef _BS_size_t +#if __GNUC__ > 1 +#define _BS_size_t __SIZE_TYPE__ +#else +#define _BS_size_t unsigned long +#endif +#endif + +#ifndef __P +#ifdef __STDC__ +#define __P(protos) protos +#else +#define __P(protos) () +#endif +#endif /*!__P*/ +#if !defined(__STDC__) && !defined(const) +#define const +#endif +#if !defined(__STDC__) && !defined(void) +#define void int +#endif + +/* The 16 2-operand raster-ops: + These match the correspodning GX codes in X11. */ +enum _BS_alu { + _BS_alu_clear = 0 /* 0 */, + _BS_alu_and = 1 /* src & dst */, + _BS_alu_andReverse = 2 /* src & ~dst */, + _BS_alu_copy = 3 /* src */, + _BS_alu_andInverted = 4 /* ~src & dst */, + _BS_alu_noop = 5 /* dst */, + _BS_alu_xor = 6 /* src ^ dst */, + _BS_alu_or = 7 /* src | dst */, + _BS_alu_nor = 8 /* ~src & ~dst */, + _BS_alu_equiv = 9 /* ~(src ^ dst) */, + _BS_alu_invert = 10 /* ~dst */, + _BS_alu_orReverse = 11 /* src | ~dst */, + _BS_alu_copyInverted = 12 /* ~src */, + _BS_alu_orInverted = 13 /* ~src | dst */, + _BS_alu_nand = 14 /* ~src | d~st */, + _BS_alu_set = 15 /* ~src | dst */ +}; +#define _BS +#define _BS + +#ifdef __cplusplus +extern "C" { +#endif + +extern void _BS_and __P((_BS_word*,int, const _BS_word*, int, _BS_size_t)); +extern void _BS_blt __P((enum _BS_alu, + _BS_word*,int, const _BS_word*,int, _BS_size_t)); +extern void _BS_copy __P((_BS_word*,int, const _BS_word*,int, _BS_size_t)); +#define _BS_copy_0(DS, SS, LENGTH) _BS_copy(DS, 0, SS, 0, LENGTH) +extern int _BS_count __P((const _BS_word*, int, _BS_size_t)); +extern int _BS_any __P((const _BS_word*, int, _BS_size_t)); +extern void _BS_clear __P((_BS_word*, int, _BS_size_t)); +extern void _BS_set __P((_BS_word*, int, _BS_size_t)); +extern void _BS_invert __P((_BS_word*, int, _BS_size_t)); +int _BS_lcompare_0 __P((_BS_word*, _BS_size_t, _BS_word*, _BS_size_t)); +extern void _BS_xor __P((_BS_word*,int, const _BS_word*,int, _BS_size_t)); + +#ifdef __cplusplus +} +#endif + +#endif /* !_BS_PRIMS */ diff --git a/gnu/lib/libg++/libg++/src/bitset1.c b/gnu/lib/libg++/libg++/src/bitset1.c new file mode 100644 index 00000000000..bf0dd8de1e1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitset1.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +void +_BS_set (ptr, offset, length) + register _BS_word *ptr; + int offset; + _BS_size_t length; +{ +#undef DOIT +#define DOIT(WORD, MASK) ((WORD) |= (MASK)) +#include "bitdo1.h" +} diff --git a/gnu/lib/libg++/libg++/src/bitxor.c b/gnu/lib/libg++/libg++/src/bitxor.c new file mode 100644 index 00000000000..7690419036e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bitxor.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU BitString 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 "bitprims.h" + +/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT. + This will work even if psrc & pdst overlap. */ + +void +_BS_xor (pdst, dstbit, psrc, srcbit, length) + register _BS_word* pdst; + int dstbit; + register const _BS_word* psrc; + int srcbit; + _BS_size_t length; +{ +#define COMBINE(dst, src) (dst) ^ (src) +#include "bitdo2.h" +} diff --git a/gnu/lib/libg++/libg++/src/bool.h b/gnu/lib/libg++/libg++/src/bool.h new file mode 100644 index 00000000000..40a2956e6e5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/bool.h @@ -0,0 +1,24 @@ +// Defining TRUE and FALSE is usually a Bad Idea, +// because you will probably be inconsistent with anyone +// else who had the same clever idea. +// Therefore: DON'T USE THIS FILE. + +#ifndef _bool_h +#define _bool_h 1 + +#include <_G_config.h> + +#if _G_HAVE_BOOL +#undef TRUE +#undef FALSE +#define TRUE true +#define FALSE false +#else +#undef FALSE +#undef TRUE +#undef true +#undef false +enum bool { FALSE = 0, false = 0, TRUE = 1, true = 1 }; +#endif + +#endif diff --git a/gnu/lib/libg++/libg++/src/builtin.cc b/gnu/lib/libg++/libg++/src/builtin.cc new file mode 100644 index 00000000000..6b9abe5380c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/builtin.cc @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include diff --git a/gnu/lib/libg++/libg++/src/builtin.h b/gnu/lib/libg++/libg++/src/builtin.h new file mode 100644 index 00000000000..8d380828d77 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/builtin.h @@ -0,0 +1,125 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +Copyright (C) 1988, 1992 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. +*/ + +/* + arithmetic, etc. functions on built in types +*/ + + +#ifndef _builtin_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _builtin_h 1 + +#include +#include +#include + +#ifndef __GNUC__ +#define __attribute__(x) +#endif + +typedef void (*one_arg_error_handler_t)(const char*); +typedef void (*two_arg_error_handler_t)(const char*, const char*); + +long gcd(long, long); +long lg(unsigned long); +double pow(double, long); +long pow(long, long); + +extern "C" double start_timer(); +extern "C" double return_elapsed_time(double last_time = 0.0); + +char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6); + +unsigned int hashpjw(const char*); +unsigned int multiplicativehash(int); +unsigned int foldhash(double); + +extern void default_one_arg_error_handler(const char*) __attribute__ ((noreturn)); +extern void default_two_arg_error_handler(const char*, const char*) __attribute__ ((noreturn)); + +extern two_arg_error_handler_t lib_error_handler; + +extern two_arg_error_handler_t + set_lib_error_handler(two_arg_error_handler_t f); + + +#if !defined(IV) + +inline short abs(short arg) +{ + return (arg < 0)? -arg : arg; +} + +inline int sign(long arg) +{ + return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 ); +} + +inline int sign(double arg) +{ + return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 ); +} + +inline long sqr(long arg) +{ + return arg * arg; +} + +#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ +inline double sqr(double arg) +{ + return arg * arg; +} +#endif + +inline int even(long arg) +{ + return !(arg & 1); +} + +inline int odd(long arg) +{ + return (arg & 1); +} + +inline long lcm(long x, long y) +{ + return x / gcd(x, y) * y; +} + +inline void (setbit)(long& x, long b) +{ + x |= (1 << b); +} + +inline void clearbit(long& x, long b) +{ + x &= ~(1 << b); +} + +inline int testbit(long x, long b) +{ + return ((x & (1 << b)) != 0); +} + +#endif +#endif diff --git a/gnu/lib/libg++/libg++/src/chr.cc b/gnu/lib/libg++/libg++/src/chr.cc new file mode 100644 index 00000000000..5c112d8217f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/chr.cc @@ -0,0 +1,37 @@ +/* +Copyright (C) 1990 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 +#include + +extern AllocRing _libgxx_fmtq; + +char* chr(char ch, int width) +{ + int len = 1; + int wrksiz = len + width + 1; + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* fmt = fmtbase; + for (int blanks = width - len; blanks > 0; --blanks) + *fmt++ = ' '; + *fmt++ = ch; + *fmt = 0; + return fmtbase; +} diff --git a/gnu/lib/libg++/libg++/src/compare.cc b/gnu/lib/libg++/libg++/src/compare.cc new file mode 100644 index 00000000000..aae8409a2aa --- /dev/null +++ b/gnu/lib/libg++/libg++/src/compare.cc @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include diff --git a/gnu/lib/libg++/libg++/src/compare.h b/gnu/lib/libg++/libg++/src/compare.h new file mode 100644 index 00000000000..fb720749873 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/compare.h @@ -0,0 +1,91 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +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. +*/ + +#ifndef _compare_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _compare_h 1 + +#include + +int compare(int a, int b); +int compare(short a, short b); +int compare(unsigned long a, unsigned long b); +int compare(unsigned int a, unsigned int b); +int compare(unsigned short a, unsigned short b); +int compare(unsigned char a, unsigned char b); +int compare(signed char a, signed char b); +int compare(float a, float b); +int compare(double a, double b); +int compare(const char* a, const char* b); + + +inline int compare(int a, int b) +{ + return a - b; +} + +inline int compare(short a, short b) +{ + return a - b; +} + + +inline int compare(signed char a, signed char b) +{ + return a - b; +} + +inline int compare(unsigned long a, unsigned long b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(unsigned int a, unsigned int b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(unsigned short a, unsigned short b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(unsigned char a, unsigned char b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(float a, float b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(double a, double b) +{ + return (a < b)? -1 : (a > b)? 1 : 0; +} + +inline int compare(const char* a, const char* b) +{ + return strcmp(a,b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/configure.in b/gnu/lib/libg++/libg++/src/configure.in new file mode 100644 index 00000000000..f4829467bd2 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/configure.in @@ -0,0 +1,34 @@ +# 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. + +configdirs="" +srctrigger=Integer.cc +srcname="main libio sources files" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +LIBDIR=yes +TOLIBGXX=../ +ALL='$(OBJS)' +EXTRA_DISTCLEAN=rx.h +MOSTLYCLEAN='*.o pic stamp-picdir core libgxx.list' +XCINCLUDES='-I$(MULTITOP)/../../libio' + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +files=../../librx/rx.h +links=rx.h + +# post-target: + +rm -f ${package_makefile_frag} + +# We need multilib support. +. ${srcdir}/../../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libg++/src/depend b/gnu/lib/libg++/libg++/src/depend new file mode 100644 index 00000000000..1dddc123850 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/depend @@ -0,0 +1,889 @@ +# AUTOMATICALLY GENERATED BY 'make depend' - DO NOT EDIT + +ACG.o: $(srcdir)/ACG.cc \ + $(srcdir)/ACG.h \ + $(srcdir)/RNG.h \ + $(MULTITOP)/../../libio/_G_config.h +AllocRing.o: $(srcdir)/AllocRing.cc \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/AllocRing.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h +Binomial.o: $(srcdir)/Binomial.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Binomial.h +BitSet.o: $(srcdir)/BitSet.cc \ + $(srcdir)/BitSet.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/Obstack.h \ + $(srcdir)/AllocRing.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/../../libio/strstream.h \ + $(srcdir)/../../libio/strfile.h +BitString.o: $(srcdir)/BitString.cc \ + $(srcdir)/BitString.h \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/bitprims.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/Obstack.h \ + $(srcdir)/AllocRing.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/../../libio/strstream.h \ + $(srcdir)/../../libio/strfile.h +CursesW.o: $(srcdir)/CursesW.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/../../libio/strstream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(srcdir)/../../libio/strfile.h \ + $(srcdir)/CursesW.h +DLList.o: $(srcdir)/DLList.cc \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/builtin.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/DLList.h \ + $(srcdir)/Pix.h +DiscUnif.o: $(srcdir)/DiscUnif.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/DiscUnif.h +Erlang.o: $(srcdir)/Erlang.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Erlang.h +Fix.o: $(srcdir)/Fix.cc \ + $(srcdir)/Fix.h \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/Integer.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Obstack.h \ + $(srcdir)/AllocRing.h \ + $(srcdir)/../../libio/strstream.h \ + $(srcdir)/../../libio/strfile.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h +Fix16.o: $(srcdir)/Fix16.cc \ + $(srcdir)/Fix16.h \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h +Fix24.o: $(srcdir)/Fix24.cc \ + $(srcdir)/Fix24.h \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h +Geom.o: $(srcdir)/Geom.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Geom.h +GetOpt.o: $(srcdir)/GetOpt.cc \ + $(srcdir)/GetOpt.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h +HypGeom.o: $(srcdir)/HypGeom.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/HypGeom.h +Intdouble.o: $(srcdir)/Intdouble.cc \ + $(srcdir)/Integer.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/Integer.hP +Integer.o: $(srcdir)/Integer.cc \ + $(srcdir)/Integer.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/Obstack.h \ + $(srcdir)/AllocRing.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Integer.hP +LogNorm.o: $(srcdir)/LogNorm.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Normal.h \ + $(srcdir)/LogNorm.h +MLCG.o: $(srcdir)/MLCG.cc \ + $(srcdir)/MLCG.h \ + $(srcdir)/RNG.h \ + $(MULTITOP)/../../libio/_G_config.h +NegExp.o: $(srcdir)/NegExp.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/NegExp.h +Normal.o: $(srcdir)/Normal.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Normal.h +Obstack.o: $(srcdir)/Obstack.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Obstack.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h +Poisson.o: $(srcdir)/Poisson.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Poisson.h +RNG.o: $(srcdir)/RNG.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/RNG.h +Random.o: $(srcdir)/Random.cc \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(MULTITOP)/../../libio/_G_config.h +Rational.o: $(srcdir)/Rational.cc \ + $(srcdir)/Rational.h \ + $(srcdir)/Integer.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +Regex.o: $(srcdir)/Regex.cc \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + rx.h $(srcdir)/Regex.h +RndInt.o: $(srcdir)/RndInt.cc \ + $(srcdir)/RndInt.h \ + $(srcdir)/RNG.h \ + $(MULTITOP)/../../libio/_G_config.h +SLList.o: $(srcdir)/SLList.cc \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/builtin.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/SLList.h \ + $(srcdir)/Pix.h +Sample.o: $(srcdir)/Sample.cc \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/SmplStat.h \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/SmplHist.h +SmplHist.o: $(srcdir)/SmplHist.cc \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/SmplHist.h \ + $(srcdir)/SmplStat.h \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +SmplStat.o: $(srcdir)/SmplStat.cc \ + $(srcdir)/../../libio/stream.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/SmplStat.h \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +String.o: $(srcdir)/String.cc \ + $(srcdir)/String.h \ + $(srcdir)/../../libio/iostream.h \ + $(srcdir)/../../libio/streambuf.h \ + $(srcdir)/../../libio/libio.h \ + $(MULTITOP)/../../libio/_G_config.h $(srcdir)/Regex.h \ + $(srcdir)/std.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/new.h \ + $(srcdir)/../../libstdc++/std/new.h \ + $(srcdir)/builtin.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +Uniform.o: $(srcdir)/Uniform.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Uniform.h +Weibull.o: $(srcdir)/Weibull.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/Random.h \ + $(srcdir)/RNG.h \ + $(srcdir)/Weibull.h +builtin.o: $(srcdir)/builtin.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +chr.o: $(srcdir)/chr.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/AllocRing.h +compare.o: $(srcdir)/compare.cc \ + $(srcdir)/compare.h \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +dtoa.o: $(srcdir)/dtoa.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/AllocRing.h +error.o: $(srcdir)/error.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +fmtq.o: $(srcdir)/fmtq.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/AllocRing.h +gcd.o: $(srcdir)/gcd.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +hash.o: $(srcdir)/hash.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +ioob.o: $(srcdir)/ioob.cc \ + $(srcdir)/Obstack.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h +lg.o: $(srcdir)/lg.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +minmax.o: $(srcdir)/minmax.cc \ + $(srcdir)/minmax.h $(MULTITOP)/../../libio/_G_config.h +pow.o: $(srcdir)/pow.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +sqrt.o: $(srcdir)/sqrt.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h +str.o: $(srcdir)/str.cc \ + $(srcdir)/builtin.h \ + $(srcdir)/std.h $(MULTITOP)/../../libio/_G_config.h \ + $(srcdir)/../../libstdc++/stddef \ + $(srcdir)/../../libstdc++/std/stddef.h \ + $(srcdir)/../../libstdc++/std/cstddef.h \ + $(srcdir)/../../libstdc++/cstdlib \ + $(srcdir)/../../libstdc++/std/cstdlib.h \ + $(srcdir)/../../libstdc++/cstring \ + $(srcdir)/../../libstdc++/std/cstring.h \ + $(srcdir)/../../libstdc++/cstdio \ + $(srcdir)/../../libstdc++/std/cstdio.h \ + $(srcdir)/../../libstdc++/cerrno \ + $(srcdir)/../../libstdc++/std/cerrno.h \ + $(srcdir)/../../libstdc++/cmath \ + $(srcdir)/../../libstdc++/std/cmath.h \ + $(srcdir)/AllocRing.h +bitand.o: $(srcdir)/bitand.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo2.h +bitany.o: $(srcdir)/bitany.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo1.h +bitblt.o: $(srcdir)/bitblt.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo2.h +bitclear.o: $(srcdir)/bitclear.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo1.h +bitcopy.o: $(srcdir)/bitcopy.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo2.h +bitcount.o: $(srcdir)/bitcount.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo1.h +bitinvert.o: $(srcdir)/bitinvert.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo1.h +bitlcomp.o: $(srcdir)/bitlcomp.c \ + $(srcdir)/bitprims.h +bitset1.o: $(srcdir)/bitset1.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo1.h +bitxor.o: $(srcdir)/bitxor.c \ + $(srcdir)/bitprims.h \ + $(srcdir)/bitdo2.h +malloc.o: $(srcdir)/malloc.c +timer.o: $(srcdir)/timer.c \ + $(MULTITOP)/../../libio/_G_config.h diff --git a/gnu/lib/libg++/libg++/src/dtoa.cc b/gnu/lib/libg++/libg++/src/dtoa.cc new file mode 100644 index 00000000000..cdc69200e8a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/dtoa.cc @@ -0,0 +1,335 @@ +/* +Copyright (C) 1990 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 +#include +#include +#include + +extern AllocRing _libgxx_fmtq; + +#ifdef __GNUC__ /* cfront cannot compile this routine */ +// OBSOLETE ROUTINE! + +char* dtoa(double fpnum, char cvt, int width, int prec) +{ + // set up workspace + + // max possible digits <= those need to show all of prec + exp + // <= ceil(log10(HUGE)) plus space for null, etc. + + const int worksiz = int((M_LN2 / M_LN10) * DMAXEXP) + 8; + + // for fractional part + char fwork[worksiz]; + char* fw = fwork; + + // for integer part + char iwork[worksiz]; + char* iworkend = &iwork[sizeof(iwork) - 1]; + char* iw = iworkend; + *iw = 0; + + // for exponent part + + const int eworksiz = int(M_LN2 * _DEXPLEN) + 8; + char ework[eworksiz]; + char* eworkend = &ework[sizeof(ework) - 1]; + char* ew = eworkend; + *ew = 0; + +#if (_IEEE != 0) + if (isinf(fpnum)) + { + char* inffmt = (char *) _libgxx_fmtq.alloc(5); + char* inffmtp = inffmt; + if (fpnum < 0) + *inffmtp++ = '-'; + strcpy(inffmtp, "Inf"); + return inffmt; + } + + if (isnan(fpnum)) + { + char* nanfmt = (char *) _libgxx_fmtq.alloc(4); + strcpy(nanfmt, "NaN"); + return nanfmt; + } +#endif + + // grab sign & make non-negative + int is_neg = fpnum < 0; + if (is_neg) fpnum = -fpnum; + + // precision matters + + if (prec > worksiz - 2) // can't have more prec than supported + prec = worksiz - 2; + + double powprec; + if (prec == 6) + powprec = 1.0e6; + else + powprec = pow(10.0, (long) prec); + + double rounder = 0.5 / powprec; + + int f_fmt = cvt == 'f' || + ((cvt == 'g') && (fpnum == 0.0 || (fpnum >= 1e-4 && fpnum < powprec))); + + int iwidth = 0; + int fwidth = 0; + int ewidth = 0; + + if (f_fmt) // fixed format + { + double ipart; + double fpart = modf(fpnum, &ipart); + + // convert fractional part + + if (fpart >= rounder || cvt != 'g') + { + fpart += rounder; + if (fpart >= 1.0) + { + ipart += 1.0; + fpart -= 1.0; + } + double ffpart = fpart; + double ifpart; + for (int i = 0; i < prec; ++i) + { + ffpart = modf(ffpart * 10.0, &ifpart); + *fw++ = '0' + int(ifpart); + ++fwidth; + } + if (cvt == 'g') // inhibit trailing zeroes if g-fmt + { + for (char* p = fw - 1; p >= fwork && *p == '0'; --p) + { + *p = 0; + --fwidth; + } + } + } + + // convert integer part + if (ipart == 0.0) + { + if (cvt != 'g' || fwidth < prec || fwidth < width) + { + *--iw = '0'; ++iwidth; + } + } + else if (ipart <= double(MAXLONG)) // a useful speedup + { + long li = long(ipart); + while (li != 0) + { + *--iw = '0' + (li % 10); + li = li / 10; + ++iwidth; + } + } + else // the slow way + { + while (ipart > 0.5) + { + double ff = modf(ipart / 10.0, &ipart); + ff = (ff + 0.05) * 10.0; + *--iw = '0' + int(ff); + ++iwidth; + } + } + + // g-fmt: kill part of frac if prec/width exceeded + if (cvt == 'g') + { + int m = prec; + if (m < width) + m = width; + int adj = iwidth + fwidth - m; + if (adj > fwidth) + adj = fwidth; + if (adj > 0) + { + for (char* f = &fwork[fwidth-1]; f >= fwork && adj > 0; --adj, --f) + { + --fwidth; + char ch = *f; + *f = 0; + if (ch > '5') // properly round: unavoidable propagation + { + int carry = 1; + for (char* p = f - 1; p >= fwork && carry; --p) + { + ++*p; + if (*p > '9') + *p = '0'; + else + carry = 0; + } + if (carry) + { + for (p = iworkend - 1; p >= iw && carry; --p) + { + ++*p; + if (*p > '9') + *p = '0'; + else + carry = 0; + } + if (carry) + { + *--iw = '1'; + ++iwidth; + --adj; + } + } + } + } + } + } + + } + else // e-fmt + { + + // normalize + int exp = 0; + while (fpnum >= 10.0) + { + fpnum *= 0.1; + ++exp; + } + double almost_one = 1.0 - rounder; + while (fpnum > 0.0 && fpnum < almost_one) + { + fpnum *= 10.0; + --exp; + } + + double ipart; + double fpart = modf(fpnum, &ipart); + + + if (cvt == 'g') // used up one digit for int part... + { + --prec; + powprec /= 10.0; + rounder = 0.5 / powprec; + } + + // convert fractional part -- almost same as above + if (fpart >= rounder || cvt != 'g') + { + fpart += rounder; + if (fpart >= 1.0) + { + fpart -= 1.0; + ipart += 1.0; + if (ipart >= 10.0) + { + ++exp; + ipart /= 10.0; + fpart /= 10.0; + } + } + double ffpart = fpart; + double ifpart; + for (int i = 0; i < prec; ++i) + { + ffpart = modf(ffpart * 10.0, &ifpart); + *fw++ = '0' + int(ifpart); + ++fwidth; + } + if (cvt == 'g') // inhibit trailing zeroes if g-fmt + { + for (char* p = fw - 1; p >= fwork && *p == '0'; --p) + { + *p = 0; + --fwidth; + } + } + } + + + // convert exponent + + char eneg = exp < 0; + if (eneg) exp = - exp; + + while (exp > 0) + { + *--ew = '0' + (exp % 10); + exp /= 10; + ++ewidth; + } + + while (ewidth < 2) // ensure at least 2 zeroes + { + *--ew = '0'; + ++ewidth; + } + + *--ew = eneg ? '-' : '+'; + *--ew = 'e'; + + ewidth += 2; + + // convert the one-digit integer part + *--iw = '0' + int(ipart); + ++iwidth; + + } + + // arrange everything in returned string + + int showdot = cvt != 'g' || fwidth > 0; + + int fmtwidth = is_neg + iwidth + showdot + fwidth + ewidth; + + int pad = width - fmtwidth; + if (pad < 0) pad = 0; + + char* fmtbase = (char *) _libgxx_fmtq.alloc(fmtwidth + pad + 1); + char* fmt = fmtbase; + + for (int i = 0; i < pad; ++i) *fmt++ = ' '; + + if (is_neg) *fmt++ = '-'; + + for (i = 0; i < iwidth; ++i) *fmt++ = *iw++; + + if (showdot) + { + *fmt++ = '.'; + fw = fwork; + for (i = 0; i < fwidth; ++i) *fmt++ = *fw++; + } + + for (i = 0; i < ewidth; ++i) *fmt++ = *ew++; + + *fmt = 0; + + return fmtbase; +} +#endif diff --git a/gnu/lib/libg++/libg++/src/error.cc b/gnu/lib/libg++/libg++/src/error.cc new file mode 100644 index 00000000000..7d163d67631 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/error.cc @@ -0,0 +1,49 @@ +/* +Copyright (C) 1990 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 + +void default_one_arg_error_handler(const char* msg) +{ + fputs("Error: ", stderr); + fputs(msg, stderr); + fputs("\n", stderr); + abort(); +} + + +void default_two_arg_error_handler(const char* kind, const char* msg) +{ + fputs(kind, stderr); + fputs(" Error: ", stderr); + fputs(msg, stderr); + fputs("\n", stderr); + abort(); +} + +two_arg_error_handler_t lib_error_handler = default_two_arg_error_handler; + +two_arg_error_handler_t set_lib_error_handler(two_arg_error_handler_t f) +{ + two_arg_error_handler_t old = lib_error_handler; + lib_error_handler = f; + return old; +} + diff --git a/gnu/lib/libg++/libg++/src/fmtq.cc b/gnu/lib/libg++/libg++/src/fmtq.cc new file mode 100644 index 00000000000..2a01073699b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/fmtq.cc @@ -0,0 +1,29 @@ +/* +Copyright (C) 1990 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 +#include + +// AllocRings are used for output operations +// We guaranteee that the last _libgxx_maxfmt formats +// will be intact + +static const int _libgxx_maxfmt = 20; +AllocRing _libgxx_fmtq(_libgxx_maxfmt); diff --git a/gnu/lib/libg++/libg++/src/gcd.cc b/gnu/lib/libg++/libg++/src/gcd.cc new file mode 100644 index 00000000000..602b55f8796 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gcd.cc @@ -0,0 +1,52 @@ +/* +Copyright (C) 1990 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 + + +/* + common functions on built-in types +*/ + +long gcd(long x, long y) // euclid's algorithm +{ + long a = abs(x); + long b = abs(y); + + long tmp; + + if (b > a) + { + tmp = a; a = b; b = tmp; + } + for(;;) + { + if (b == 0) + return a; + else if (b == 1) + return b; + else + { + tmp = b; + b = a % b; + a = tmp; + } + } +} diff --git a/gnu/lib/libg++/libg++/src/gen/AVLMap.ccP b/gnu/lib/libg++/libg++/src/gen/AVLMap.ccP new file mode 100644 index 00000000000..0e2c63542ad --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVLMap.ccP @@ -0,0 +1,614 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include "..AVLMap.h" + + +/* + constants & inlines for maintaining balance & thread status in tree nodes +*/ + +#define AVLBALANCEMASK 3 +#define AVLBALANCED 0 +#define AVLLEFTHEAVY 1 +#define AVLRIGHTHEAVY 2 + +#define LTHREADBIT 4 +#define RTHREADBIT 8 + + +static inline int bf(AVLNode* t) +{ + return t->stat & AVLBALANCEMASK; +} + +static inline void set_bf(AVLNode* t, int b) +{ + t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); +} + + +static inline int rthread(AVLNode* t) +{ + return t->stat & RTHREADBIT; +} + +static inline void set_rthread(AVLNode* t, int b) +{ + if (b) + t->stat |= RTHREADBIT; + else + t->stat &= ~RTHREADBIT; +} + +static inline int lthread(AVLNode* t) +{ + return t->stat & LTHREADBIT; +} + +static inline void set_lthread(AVLNode* t, int b) +{ + if (b) + t->stat |= LTHREADBIT; + else + t->stat &= ~LTHREADBIT; +} + +/* + traversal primitives +*/ + + +AVLNode* AVLMap::leftmost() +{ + AVLNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +AVLNode* AVLMap::rightmost() +{ + AVLNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +AVLNode* AVLMap::succ(AVLNode* t) +{ + AVLNode* r = t->rt; + if (!rthread(t)) while (!lthread(r)) r = r->lt; + return r; +} + +AVLNode* AVLMap::pred(AVLNode* t) +{ + AVLNode* l = t->lt; + if (!lthread(t)) while (!rthread(l)) l = l->rt; + return l; +} + + +Pix AVLMap::seek( key) +{ + AVLNode* t = root; + if (t == 0) + return 0; + for (;;) + { + int cmp = CMP(key, t->item); + if (cmp == 0) + return Pix(t); + else if (cmp < 0) + { + if (lthread(t)) + return 0; + else + t = t->lt; + } + else if (rthread(t)) + return 0; + else + t = t->rt; + } +} + + +/* + The combination of threads and AVL bits make adding & deleting + interesting, but very awkward. + + We use the following statics to avoid passing them around recursively +*/ + +static int _need_rebalancing; // to send back balance info from rec. calls +static * _target_item; // add/del_item target +static AVLNode* _found_node; // returned added/deleted node +static int _already_found; // for deletion subcases + + +void AVLMap:: _add(AVLNode*& t) +{ + int cmp = CMP(*_target_item, t->item); + if (cmp == 0) + { + _found_node = t; + return; + } + else if (cmp < 0) + { + if (lthread(t)) + { + ++count; + _found_node = new AVLNode(*_target_item, def); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t->lt; + _found_node->rt = t; + t->lt = _found_node; + set_lthread(t, 0); + _need_rebalancing = 1; + } + else + _add(t->lt); + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + return; + case AVLLEFTHEAVY: + { + AVLNode* l = t->lt; + if (bf(l) == AVLLEFTHEAVY) + { + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + } + else + { + AVLNode* r = l->rt; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + return; + } + } + } + } + } + else + { + if (rthread(t)) + { + ++count; + _found_node = new AVLNode(*_target_item, def); + set_rthread(t, 0); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t; + _found_node->rt = t->rt; + t->rt = _found_node; + _need_rebalancing = 1; + } + else + _add(t->rt); + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = t->rt; + if (bf(r) == AVLRIGHTHEAVY) + { + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + } + else + { + AVLNode* l = r->lt; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + return; + } + } + } + } + } +} + + +& AVLMap::operator [] ( item) +{ + if (root == 0) + { + ++count; + root = new AVLNode(item, def); + set_rthread(root, 1); + set_lthread(root, 1); + return root->cont; + } + else + { + _target_item = &item; + _need_rebalancing = 0; + _add(root); + return _found_node->cont; + } +} + + +void AVLMap::_del(AVLNode* par, AVLNode*& t) +{ + int comp; + if (_already_found) + { + if (rthread(t)) + comp = 0; + else + comp = 1; + } + else + comp = CMP(*_target_item, t->item); + if (comp == 0) + { + if (lthread(t) && rthread(t)) + { + _found_node = t; + if (t == par->lt) + { + set_lthread(par, 1); + par->lt = t->lt; + } + else + { + set_rthread(par, 1); + par->rt = t->rt; + } + _need_rebalancing = 1; + return; + } + else if (lthread(t)) + { + _found_node = t; + AVLNode* s = succ(t); + if (s != 0 && lthread(s)) + s->lt = t->lt; + t = t->rt; + _need_rebalancing = 1; + return; + } + else if (rthread(t)) + { + _found_node = t; + AVLNode* p = pred(t); + if (p != 0 && rthread(p)) + p->rt = t->rt; + t = t->lt; + _need_rebalancing = 1; + return; + } + else // replace item & find someone deletable + { + AVLNode* p = pred(t); + t->item = p->item; + t->cont = p->cont; + _already_found = 1; + comp = -1; // fall through below to left + } + } + + if (comp < 0) + { + if (lthread(t)) + return; + _del(t, t->lt); + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + _need_rebalancing = 0; + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = t->rt; + switch (bf(r)) + { + case AVLBALANCED: + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLRIGHTHEAVY); + set_bf(r, AVLLEFTHEAVY); + _need_rebalancing = 0; + t = r; + return; + case AVLRIGHTHEAVY: + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + case AVLLEFTHEAVY: + { + AVLNode* l = r->lt; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + } + } + } + } + } + else + { + if (rthread(t)) + return; + _del(t, t->rt); + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + _need_rebalancing = 0; + return; + case AVLLEFTHEAVY: + { + AVLNode* l = t->lt; + switch (bf(l)) + { + case AVLBALANCED: + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLLEFTHEAVY); + set_bf(l, AVLRIGHTHEAVY); + _need_rebalancing = 0; + t = l; + return; + case AVLLEFTHEAVY: + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = l->rt; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + } + } + } + } + } +} + + + +void AVLMap::del( item) +{ + if (root == 0) return; + _need_rebalancing = 0; + _already_found = 0; + _found_node = 0; + _target_item = &item; + _del(root, root); + if (_found_node) + { + delete(_found_node); + if (--count == 0) + root = 0; + } +} + +void AVLMap::_kill(AVLNode* t) +{ + if (t != 0) + { + if (!lthread(t)) _kill(t->lt); + if (!rthread(t)) _kill(t->rt); + delete t; + } +} + + +AVLMap::AVLMap(AVLMap& b) :Map(b.def) +{ + root = 0; + count = 0; + for (Pix i = b.first(); i != 0; b.next(i)) + (*this)[b.key(i)] = b.contents(i); +} + + +int AVLMap::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + AVLNode* trail = leftmost(); + AVLNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/AVLMap.hP b/gnu/lib/libg++/libg++/src/gen/AVLMap.hP new file mode 100644 index 00000000000..a5c0884be0d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVLMap.hP @@ -0,0 +1,141 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _AVLMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _AVLMap_h 1 + +#include "..Map.h" + +struct AVLNode +{ + AVLNode* lt; + AVLNode* rt; + item; + cont; + char stat; + AVLNode( h, c, + AVLNode* l=0, AVLNode* r=0); + ~AVLNode(); +}; + +inline AVLNode::AVLNode( h, c, + AVLNode* l, AVLNode* r) + :lt(l), rt(r), item(h), cont(c), stat(0) {} + +inline AVLNode::~AVLNode() {} + +typedef AVLNode* AVLNodePtr; + + +class AVLMap : public Map +{ +protected: + AVLNode* root; + + AVLNode* leftmost(); + AVLNode* rightmost(); + AVLNode* pred(AVLNode* t); + AVLNode* succ(AVLNode* t); + void _kill(AVLNode* t); + void _add(AVLNode*& t); + void _del(AVLNode* p, AVLNode*& t); + +public: + AVLMap( dflt); + AVLMap(AVLMap& a); + inline ~AVLMap(); + + & operator [] ( key); + + void del( key); + + inline Pix first(); + inline void next(Pix& i); + inline & key(Pix i); + inline & contents(Pix i); + + Pix seek( key); + inline int contains( key); + + inline void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +inline AVLMap::~AVLMap() +{ + _kill(root); +} + +inline AVLMap::AVLMap( dflt) :Map(dflt) +{ + root = 0; +} + +inline Pix AVLMap::first() +{ + return Pix(leftmost()); +} + +inline Pix AVLMap::last() +{ + return Pix(rightmost()); +} + +inline void AVLMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((AVLNode*)i)); +} + +inline void AVLMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((AVLNode*)i)); +} + +inline & AVLMap::key(Pix i) +{ + if (i == 0) error("null Pix"); + return ((AVLNode*)i)->item; +} + +inline & AVLMap::contents(Pix i) +{ + if (i == 0) error("null Pix"); + return ((AVLNode*)i)->cont; +} + +inline void AVLMap::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int AVLMap::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/AVLSet.ccP b/gnu/lib/libg++/libg++/src/gen/AVLSet.ccP new file mode 100644 index 00000000000..98c07d18914 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVLSet.ccP @@ -0,0 +1,892 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".AVLSet.h" +#include + + +/* + constants & inlines for maintaining balance & thread status in tree nodes +*/ + +#define AVLBALANCEMASK 3 +#define AVLBALANCED 0 +#define AVLLEFTHEAVY 1 +#define AVLRIGHTHEAVY 2 + +#define LTHREADBIT 4 +#define RTHREADBIT 8 + + +static inline int bf(AVLNode* t) +{ + return t->stat & AVLBALANCEMASK; +} + +static inline void set_bf(AVLNode* t, int b) +{ + t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); +} + + +static inline int rthread(AVLNode* t) +{ + return t->stat & RTHREADBIT; +} + +static inline void set_rthread(AVLNode* t, int b) +{ + if (b) + t->stat |= RTHREADBIT; + else + t->stat &= ~RTHREADBIT; +} + +static inline int lthread(AVLNode* t) +{ + return t->stat & LTHREADBIT; +} + +static inline void set_lthread(AVLNode* t, int b) +{ + if (b) + t->stat |= LTHREADBIT; + else + t->stat &= ~LTHREADBIT; +} + +/* + traversal primitives +*/ + + +AVLNode* AVLSet::leftmost() +{ + AVLNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +AVLNode* AVLSet::rightmost() +{ + AVLNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +AVLNode* AVLSet::succ(AVLNode* t) +{ + AVLNode* r = t->rt; + if (!rthread(t)) while (!lthread(r)) r = r->lt; + return r; +} + +AVLNode* AVLSet::pred(AVLNode* t) +{ + AVLNode* l = t->lt; + if (!lthread(t)) while (!rthread(l)) l = l->rt; + return l; +} + + +Pix AVLSet::seek( key) +{ + AVLNode* t = root; + if (t == 0) + return 0; + for (;;) + { + int cmp = CMP(key, t->item); + if (cmp == 0) + return Pix(t); + else if (cmp < 0) + { + if (lthread(t)) + return 0; + else + t = t->lt; + } + else if (rthread(t)) + return 0; + else + t = t->rt; + } +} + + +/* + The combination of threads and AVL bits make adding & deleting + interesting, but very awkward. + + We use the following statics to avoid passing them around recursively +*/ + +static int _need_rebalancing; // to send back balance info from rec. calls +static * _target_item; // add/del_item target +static AVLNode* _found_node; // returned added/deleted node +static int _already_found; // for deletion subcases + +static AVLNode** _hold_nodes; // used for rebuilding trees +static int _max_hold_index; // # elements-1 in _hold_nodes + + +void AVLSet:: _add(AVLNode*& t) +{ + int cmp = CMP(*_target_item, t->item); + if (cmp == 0) + { + _found_node = t; + return; + } + else if (cmp < 0) + { + if (lthread(t)) + { + ++count; + _found_node = new AVLNode(*_target_item); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t->lt; + _found_node->rt = t; + t->lt = _found_node; + set_lthread(t, 0); + _need_rebalancing = 1; + } + else + _add(t->lt); + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + return; + case AVLLEFTHEAVY: + { + AVLNode* l = t->lt; + if (bf(l) == AVLLEFTHEAVY) + { + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + } + else + { + AVLNode* r = l->rt; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + return; + } + } + } + } + } + else + { + if (rthread(t)) + { + ++count; + _found_node = new AVLNode(*_target_item); + set_rthread(t, 0); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t; + _found_node->rt = t->rt; + t->rt = _found_node; + _need_rebalancing = 1; + } + else + _add(t->rt); + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = t->rt; + if (bf(r) == AVLRIGHTHEAVY) + { + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + } + else + { + AVLNode* l = r->lt; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + return; + } + } + } + } + } +} + + +Pix AVLSet::add( item) +{ + if (root == 0) + { + ++count; + root = new AVLNode(item); + set_rthread(root, 1); + set_lthread(root, 1); + return Pix(root); + } + else + { + _target_item = &item; + _need_rebalancing = 0; + _add(root); + return Pix(_found_node); + } +} + + +void AVLSet::_del(AVLNode* par, AVLNode*& t) +{ + int comp; + if (_already_found) + { + if (rthread(t)) + comp = 0; + else + comp = 1; + } + else + comp = CMP(*_target_item, t->item); + if (comp == 0) + { + if (lthread(t) && rthread(t)) + { + _found_node = t; + if (t == par->lt) + { + set_lthread(par, 1); + par->lt = t->lt; + } + else + { + set_rthread(par, 1); + par->rt = t->rt; + } + _need_rebalancing = 1; + return; + } + else if (lthread(t)) + { + _found_node = t; + AVLNode* s = succ(t); + if (s != 0 && lthread(s)) + s->lt = t->lt; + t = t->rt; + _need_rebalancing = 1; + return; + } + else if (rthread(t)) + { + _found_node = t; + AVLNode* p = pred(t); + if (p != 0 && rthread(p)) + p->rt = t->rt; + t = t->lt; + _need_rebalancing = 1; + return; + } + else // replace item & find someone deletable + { + AVLNode* p = pred(t); + t->item = p->item; + _already_found = 1; + comp = -1; // fall through below to left + } + } + + if (comp < 0) + { + if (lthread(t)) + return; + _del(t, t->lt); + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + _need_rebalancing = 0; + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = t->rt; + switch (bf(r)) + { + case AVLBALANCED: + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLRIGHTHEAVY); + set_bf(r, AVLLEFTHEAVY); + _need_rebalancing = 0; + t = r; + return; + case AVLRIGHTHEAVY: + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + case AVLLEFTHEAVY: + { + AVLNode* l = r->lt; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + } + } + } + } + } + else + { + if (rthread(t)) + return; + _del(t, t->rt); + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + _need_rebalancing = 0; + return; + case AVLLEFTHEAVY: + { + AVLNode* l = t->lt; + switch (bf(l)) + { + case AVLBALANCED: + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLLEFTHEAVY); + set_bf(l, AVLRIGHTHEAVY); + _need_rebalancing = 0; + t = l; + return; + case AVLLEFTHEAVY: + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + case AVLRIGHTHEAVY: + { + AVLNode* r = l->rt; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + } + } + } + } + } +} + + + +void AVLSet::del( item) +{ + if (root == 0) return; + _need_rebalancing = 0; + _already_found = 0; + _found_node = 0; + _target_item = &item; + _del(root, root); + if (_found_node) + { + delete(_found_node); + if (--count == 0) + root = 0; + } +} + +// build an ordered array of pointers to tree nodes back into a tree +// we know that at least one element exists + +static AVLNode* _do_treeify(int lo, int hi, int& h) +{ + int lh, rh; + int mid = (lo + hi) / 2; + AVLNode* t = _hold_nodes[mid]; + if (lo > mid - 1) + { + set_lthread(t, 1); + if (mid == 0) + t->lt = 0; + else + t->lt = _hold_nodes[mid-1]; + lh = 0; + } + else + { + set_lthread(t, 0); + t->lt = _do_treeify(lo, mid-1, lh); + } + if (hi < mid + 1) + { + set_rthread(t, 1); + if (mid == _max_hold_index) + t->rt = 0; + else + t->rt = _hold_nodes[mid+1]; + rh = 0; + } + else + { + set_rthread(t, 0); + t->rt = _do_treeify(mid+1, hi, rh); + } + if (lh == rh) + { + set_bf(t, AVLBALANCED); + h = lh + 1; + } + else if (lh == rh - 1) + { + set_bf(t, AVLRIGHTHEAVY); + h = rh + 1; + } + else if (rh == lh - 1) + { + set_bf(t, AVLLEFTHEAVY); + h = lh + 1; + } + else // can't happen + abort(); + + return t; +} + +static AVLNode* _treeify(int n) +{ + AVLNode* t; + if (n == 0) + t = 0; + else + { + int b; + _max_hold_index = n-1; + t = _do_treeify(0, _max_hold_index, b); + } + delete _hold_nodes; + return t; +} + + +void AVLSet::_kill(AVLNode* t) +{ + if (t != 0) + { + if (!lthread(t)) _kill(t->lt); + if (!rthread(t)) _kill(t->rt); + delete t; + } +} + + +AVLSet::AVLSet(AVLSet& b) +{ + if ((count = b.count) == 0) + { + root = 0; + } + else + { + _hold_nodes = new AVLNodePtr [count]; + AVLNode* t = b.leftmost(); + int i = 0; + while (t != 0) + { + _hold_nodes[i++] = new AVLNode(t->item); + t = b.succ(t); + } + root = _treeify(count); + } +} + + +int AVLSet::operator == (AVLSet& y) +{ + if (count != y.count) + return 0; + else + { + AVLNode* t = leftmost(); + AVLNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (!(EQ(t->item, u->item))) + return 0; + else + { + t = succ(t); + u = y.succ(u); + } + } + } +} + +int AVLSet::operator <= (AVLSet& y) +{ + if (count > y.count) + return 0; + else + { + AVLNode* t = leftmost(); + AVLNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (u == 0) + return 0; + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + return 0; + else + u = y.succ(u); + } + } +} + +void AVLSet::operator |=(AVLSet& y) +{ + AVLNode* t = leftmost(); + AVLNode* u = y.leftmost(); + int rsize = count + y.count; + _hold_nodes = new AVLNodePtr [rsize]; + int k = 0; + for (;;) + { + if (t == 0) + { + while (u != 0) + { + _hold_nodes[k++] = new AVLNode(u->item); + u = y.succ(u); + } + break; + } + else if (u == 0) + { + while (t != 0) + { + _hold_nodes[k++] = t; + t = succ(t); + } + break; + } + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + _hold_nodes[k++] = t; + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + { + _hold_nodes[k++] = t; + t = succ(t); + } + else + { + _hold_nodes[k++] = new AVLNode(u->item); + u = y.succ(u); + } + } + root = _treeify(k); + count = k; +} + +void AVLSet::operator &= (AVLSet& y) +{ + AVLNode* t = leftmost(); + AVLNode* u = y.leftmost(); + int rsize = (count < y.count)? count : y.count; + _hold_nodes = new AVLNodePtr [rsize]; + int k = 0; + for (;;) + { + if (t == 0) + break; + if (u == 0) + { + while (t != 0) + { + AVLNode* tmp = succ(t); + delete t; + t = tmp; + } + break; + } + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + _hold_nodes[k++] = t; + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + { + AVLNode* tmp = succ(t); + delete t; + t = tmp; + } + else + u = y.succ(u); + } + root = _treeify(k); + count = k; +} + + +void AVLSet::operator -=(AVLSet& y) +{ + AVLNode* t = leftmost(); + AVLNode* u = y.leftmost(); + int rsize = count; + _hold_nodes = new AVLNodePtr [rsize]; + int k = 0; + for (;;) + { + if (t == 0) + break; + else if (u == 0) + { + while (t != 0) + { + _hold_nodes[k++] = t; + t = succ(t); + } + break; + } + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + AVLNode* tmp = succ(t); + delete t; + t = tmp; + u = y.succ(u); + } + else if (cmp < 0) + { + _hold_nodes[k++] = t; + t = succ(t); + } + else + u = y.succ(u); + } + root = _treeify(k); + count = k; +} + +int AVLSet::owns(Pix i) +{ + if (i == 0) return 0; + for (AVLNode* t = leftmost(); t != 0; t = succ(t)) + if (Pix(t) == i) return 1; + return 0; +} + +int AVLSet::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + AVLNode* trail = leftmost(); + AVLNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/AVLSet.hP b/gnu/lib/libg++/libg++/src/gen/AVLSet.hP new file mode 100644 index 00000000000..c1aa8fad6ac --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVLSet.hP @@ -0,0 +1,152 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _AVL_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _AVL_h 1 + +#include ".Set.h" + +struct AVLNode +{ + AVLNode* lt; + AVLNode* rt; + item; + char stat; + AVLNode( h, AVLNode* l=0, AVLNode* r=0); + ~AVLNode(); +}; + +inline AVLNode::AVLNode( h, AVLNode* l, AVLNode* r) +:lt(l), rt(r), item(h), stat(0) {} + +inline AVLNode::~AVLNode() {} + +typedef AVLNode* AVLNodePtr; + + +class AVLSet : public Set +{ +protected: + AVLNode* root; + + AVLSet(AVLNode* p, int l); + + AVLNode* leftmost(); + AVLNode* rightmost(); + AVLNode* pred(AVLNode* t); + AVLNode* succ(AVLNode* t); + void _kill(AVLNode* t); + void _add(AVLNode*& t); + void _del(AVLNode* p, AVLNode*& t); + +public: + AVLSet(); + AVLSet(AVLSet& a); + inline ~AVLSet(); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + int owns(Pix i); + Pix seek( item); + + Pix last(); + void prev(Pix& i); + + void operator |= (AVLSet& b); + void operator -= (AVLSet& b); + void operator &= (AVLSet& b); + + int operator == (AVLSet& b); + int operator != (AVLSet& b); + int operator <= (AVLSet& b); + + int OK(); +}; + +inline AVLSet::~AVLSet() +{ + _kill(root); +} + +inline AVLSet::AVLSet() +{ + root = 0; + count = 0; +} + +inline AVLSet::AVLSet(AVLNode* p, int l) +{ + root = p; + count = l; +} + +inline int AVLSet::operator != (AVLSet& b) +{ + return ! ((*this) == b); +} + +inline Pix AVLSet::first() +{ + return Pix(leftmost()); +} + +inline Pix AVLSet::last() +{ + return Pix(rightmost()); +} + +inline void AVLSet::next(Pix& i) +{ + if (i != 0) i = Pix(succ((AVLNode*)i)); +} + +inline void AVLSet::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((AVLNode*)i)); +} + +inline & AVLSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((AVLNode*)i)->item; +} + +inline void AVLSet::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int AVLSet::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/AVec.ccP b/gnu/lib/libg++/libg++/src/gen/AVec.ccP new file mode 100644 index 00000000000..57a92708d9f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVec.ccP @@ -0,0 +1,397 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include +#include ".AVec.h" + +/* + The following brought to you by the department of redundancy department +*/ + +AVec& AVec::operator = (const AVec& v) +{ + if (len != 0 && len != v.capacity()) + error("nonconformant vectors."); + if (len == 0) + s = new [len = v.capacity()]; + if (s != v.vec()) + { + for (int i = 0; i < len; ++i) + s[i] = v.vec()[i]; + } + return *this; +} + +AVec& AVec::operator = ( f) +{ + for (int i = 0; i < len; ++i) s[i] = f; + return *this; +} + + +AVec concat(AVec & a, AVec & b) +{ + int newl = a.capacity() + b.capacity(); + * news = new [newl]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while (t < top) *p++ = *t++; + top = &(b.vec()[b.capacity()]); + t = b.vec(); + while (t < top) *p++ = *t++; + return AVec(newl, news); +} + + +AVec combine(Combiner f, AVec& a, AVec& b) +{ + int newl = (a.capacity() < b.capacity())? a.capacity() : b.capacity(); + * news = new [newl]; + * p = news; + * top = &(a.vec()[newl]); + * t = a.vec(); + * u = b.vec(); + while (t < top) *p++ = (*f)(*t++, *u++); + return AVec(newl, news); +} + +AVec reverse(AVec& a) +{ + * news = new [a.capacity()]; + if (a.capacity() != 0) + { + * lo = news; + * hi = &(news[a.capacity() - 1]); + while (lo < hi) + { + tmp = *lo; + *lo++ = *hi; + *hi-- = tmp; + } + } + return AVec(a.capacity(), news); +} + +AVec map(Mapper f, AVec& a) +{ + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while(t < top) *p++ = (*f)(*t++); + return AVec(a.capacity(), news); +} + +AVec AVec::at(int from, int n) +{ + int to; + if (n < 0) + { + n = len - from; + to = len - 1; + } + else + to = from + n - 1; + if ((unsigned)from > (unsigned)to) + range_error(); + * news = new [n]; + * p = news; + * t = &(s[from]); + * top = &(s[to]); + while (t <= top) *p++ = *t++; + return AVec(n, news); +} + +AVec merge(AVec & a, AVec & b, Comparator f) +{ + int newl = a.capacity() + b.capacity(); + * news = new [newl]; + * p = news; + * topa = &(a.vec()[a.capacity()]); + * as = a.vec(); + * topb = &(b.vec()[b.capacity()]); + * bs = b.vec(); + + for (;;) + { + if (as >= topa) + { + while (bs < topb) *p++ = *bs++; + break; + } + else if (bs >= topb) + { + while (as < topa) *p++ = *as++; + break; + } + else if ((*f)(*as, *bs) <= 0) + *p++ = *as++; + else + *p++ = *bs++; + } + return AVec(newl, news); +} + +AVec operator + (AVec& a, AVec& b) +{ + a.check_len(b.capacity()); + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + * u = b.vec(); + while (t < top) *p++ = *t++ + *u++; + return AVec(a.capacity(), news); +} + +AVec operator - (AVec& a, AVec& b) +{ + a.check_len(b.capacity()); + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + * u = b.vec(); + while (t < top) *p++ = *t++ - *u++; + return AVec(a.capacity(), news); +} + +AVec product (AVec& a, AVec& b) +{ + a.check_len(b.capacity()); + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + * u = b.vec(); + while (t < top) *p++ = *t++ * *u++; + return AVec(a.capacity(), news); +} + +AVec quotient(AVec& a, AVec& b) +{ + a.check_len(b.capacity()); + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + * u = b.vec(); + while (t < top) *p++ = *t++ / *u++; + return AVec(a.capacity(), news); +} + +AVec operator + (AVec& a, b) +{ + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while (t < top) *p++ = *t++ + b; + return AVec(a.capacity(), news); +} + +AVec operator - (AVec& a, b) +{ + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while (t < top) *p++ = *t++ - b; + return AVec(a.capacity(), news); +} + +AVec operator * (AVec& a, b) +{ + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while (t < top) *p++ = *t++ * b; + return AVec(a.capacity(), news); +} + +AVec operator / (AVec& a, b) +{ + * news = new [a.capacity()]; + * p = news; + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + while (t < top) *p++ = *t++ / b; + return AVec(a.capacity(), news); +} + +AVec AVec::operator - () +{ + * news = new [len]; + * p = news; + * top = &(s[len]); + * t = s; + while (t < top) *p++ = -(*t++); + return AVec(len, news); +} + +AVec& AVec::operator += (AVec& b) +{ + check_len(b.capacity()); + * u = b.vec(); + * top = &(s[len]); + * t = s; + while (t < top) *t++ += *u++; + return *this; +} + +AVec& AVec::operator -= (AVec& b) +{ + check_len(b.capacity()); + * u = b.vec(); + * top = &(s[len]); + * t = s; + while (t < top) *t++ -= *u++; + return *this; +} + +AVec& AVec::product(AVec& b) +{ + check_len(b.capacity()); + * u = b.vec(); + * top = &(s[len]); + * t = s; + while (t < top) *t++ *= *u++; + return *this; +} + +AVec& AVec::quotient(AVec& b) +{ + check_len(b.capacity()); + * u = b.vec(); + * top = &(s[len]); + * t = s; + while (t < top) *t++ /= *u++; + return *this; +} + +AVec& AVec::operator += ( b) +{ + * top = &(s[len]); + * t = s; + while (t < top) *t++ += b; + return *this; +} + +AVec& AVec::operator -= ( b) +{ + * top = &(s[len]); + * t = s; + while (t < top) *t++ -= b; + return *this; +} + +AVec& AVec::operator *= ( b) +{ + * top = &(s[len]); + * t = s; + while (t < top) *t++ *= b; + return *this; +} + +AVec& AVec::operator /= ( b) +{ + * top = &(s[len]); + * t = s; + while (t < top) *t++ /= b; + return *this; +} + + AVec::max() +{ + if (len == 0) + return 0; + * top = &(s[len]); + * t = s; + res = *t++; + for (; t < top; ++t) if (*t > res) res = *t; + return res; +} + +int AVec::max_index() +{ + if (len == 0) + return -1; + int ind = 0; + for (int i = 1; i < len; ++i) + if (s[i] > s[ind]) + ind = i; + return ind; +} + + AVec::min() +{ + if (len == 0) + return 0; + * top = &(s[len]); + * t = s; + res = *t++; + for (; t < top; ++t) if (*t < res) res = *t; + return res; +} + +int AVec::min_index() +{ + if (len == 0) + return -1; + int ind = 0; + for (int i = 1; i < len; ++i) + if (s[i] < s[ind]) + ind = i; + return ind; +} + + AVec::sum() +{ + res = 0; + * top = &(s[len]); + * t = s; + while (t < top) res += *t++; + return res; +} + + + AVec::sumsq() +{ + res = 0; + * top = &(s[len]); + * t = s; + for (; t < top; ++t) res += *t * *t; + return res; +} + + operator * (AVec& a, AVec& b) +{ + a.check_len(b.capacity()); + * top = &(a.vec()[a.capacity()]); + * t = a.vec(); + * u = b.vec(); + res = 0; + while (t < top) res += *t++ * *u++; + return res; +} diff --git a/gnu/lib/libg++/libg++/src/gen/AVec.hP b/gnu/lib/libg++/libg++/src/gen/AVec.hP new file mode 100644 index 00000000000..c59720e93cc --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/AVec.hP @@ -0,0 +1,118 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _AVec_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _AVec_h 1 + +#include ".Vec.h" + +class AVec : public Vec +{ +protected: + void check_len(int l); + * vec(); + const * vec() const; + AVec(int l, * d); + public: + AVec (); + AVec (int l); + AVec (int l, fill_value); + AVec (AVec&); + ~AVec (); + + AVec& operator = (const AVec& a); + AVec& operator = ( fill_value); + +// vector by scalar -> vector operations + + friend AVec operator + (AVec& a, b); + friend AVec operator - (AVec& a, b); + friend AVec operator * (AVec& a, b); + friend AVec operator / (AVec& a, b); + + AVec& operator += ( b); + AVec& operator -= ( b); + AVec& operator *= ( b); + AVec& operator /= ( b); + +// vector by vector -> vector operations + + friend AVec operator + (AVec& a, AVec& b); + friend AVec operator - (AVec& a, AVec& b); + AVec& operator += (AVec& b); + AVec& operator -= (AVec& b); + + AVec operator - (); + + friend AVec product(AVec& a, AVec& b); + AVec& product(AVec& b); + friend AVec quotient(AVec& a, AVec& b); + AVec& quotient(AVec& b); + +// vector -> scalar operations + + friend operator * (AVec& a, AVec& b); + + sum(); + min(); + max(); + sumsq(); + +// indexing + + int min_index(); + int max_index(); + +// redundant but necesssary + friend AVec concat(AVec& a, AVec& b); + friend AVec map(Mapper f, AVec& a); + friend AVec merge(AVec& a, AVec& b, Comparator f); + friend AVec combine(Combiner f, AVec& a, AVec& b); + friend AVec reverse(AVec& a); + AVec at(int from = 0, int n = -1); +}; + +inline AVec::AVec() {} +inline AVec::AVec(int l) :Vec(l) {} +inline AVec::AVec(int l, fill_value) : Vec (l, fill_value) {} +inline AVec::AVec(AVec& v) :Vec(v) {} +inline AVec::AVec(int l, * d) :Vec(l, d) {} +inline AVec::~AVec() {} + + +inline * AVec::vec() +{ + return s; +} + +inline const * AVec::vec() const +{ + return s; +} + +inline void AVec::check_len(int l) +{ + if (l != len) + error("nonconformant vectors."); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/BSTSet.ccP b/gnu/lib/libg++/libg++/src/gen/BSTSet.ccP new file mode 100644 index 00000000000..da7d73a3a03 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/BSTSet.ccP @@ -0,0 +1,377 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".BSTSet.h" + + +/* + traversal primitives +*/ + + +BSTNode* BSTSet::leftmost() +{ + BSTNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +BSTNode* BSTSet::rightmost() +{ + BSTNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +BSTNode* BSTSet::succ(BSTNode* t) +{ + if (t == 0) + return 0; + if (t->rt != 0) + { + t = t->rt; + while (t->lt != 0) t = t->lt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->lt) + return t->par; + else + t = t->par; + } + } +} + +BSTNode* BSTSet::pred(BSTNode* t) +{ + if (t == 0) + return 0; + else if (t->lt != 0) + { + t = t->lt; + while (t->rt != 0) t = t->rt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->rt) + return t->par; + else + t = t->par; + } + } +} + + +Pix BSTSet::seek( key) +{ + BSTNode* t = root; + for (;;) + { + if (t == 0) + return 0; + int comp = CMP(key, t->item); + if (comp == 0) + return Pix(t); + else if (comp < 0) + t = t->lt; + else + t = t->rt; + } +} + + +Pix BSTSet::add( item) +{ + if (root == 0) + { + ++count; + root = new BSTNode(item); + return Pix(root); + } + + BSTNode* t = root; + BSTNode* p = root; + for (;;) + { + int comp = CMP(t->item, item); + if (comp == 0) + return Pix(t); + else if (comp > 0) + t = t->lt; + else + t = t->rt; + if (t == 0) + { + ++count; + t = new BSTNode(item); + if (comp > 0) + p->lt = t; + else + p->rt = t; + t->par = p; + return Pix(t); + } + p = t; + } +} + + +void BSTSet::del( key) +{ + BSTNode* t = root; + BSTNode* p = root; + int comp; + for (;;) + { + if (t == 0) + return; + comp = CMP(key, t->item); + if (comp == 0) + { + --count; + BSTNode* repl; + if (t->lt == 0) + repl = t->rt; + else if (t->rt == 0) + repl = t->lt; + else + { + BSTNode* prepl = t; + repl = t->lt; + while (repl->rt != 0) + { + prepl = repl; + repl = repl->rt; + } + if (prepl != t) + { + prepl->rt = repl->lt; + if (prepl->rt != 0) prepl->rt->par = prepl; + repl->lt = t->lt; + if (repl->lt != 0) repl->lt->par = repl; + } + repl->rt = t->rt; + if (repl->rt != 0) repl->rt->par = repl; + } + if (t == root) + { + root = repl; + if (repl != 0) repl->par = 0; + } + else + { + if (t == p->lt) + p->lt = repl; + else + p->rt = repl; + if (repl != 0) repl->par = p; + } + delete t; + return; + } + p = t; + if (comp < 0) + t = t->lt; + else + t = t->rt; + } +} + + +void BSTSet::_kill(BSTNode* t) +{ + if (t != 0) + { + _kill(t->lt); + _kill(t->rt); + delete t; + } +} + +BSTNode* BSTSet::_copy(BSTNode* t) +{ + if (t == 0) + return 0; + else + { + BSTNode* u = new BSTNode(t->item, _copy(t->lt), _copy(t->rt)); + if (u->lt != 0) u->lt->par = u; + if (u->rt != 0) u->rt->par = u; + return u; + } +} + + +int BSTSet::operator == (BSTSet& y) +{ + if (count != y.count) + return 0; + else + { + BSTNode* t = leftmost(); + BSTNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (!EQ(t->item, u->item)) + return 0; + else + { + t = succ(t); + u = y.succ(u); + } + } + } +} + +int BSTSet::operator <= (BSTSet& y) +{ + if (count > y.count) + return 0; + else + { + BSTNode* t = leftmost(); + BSTNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (u == 0) + return 0; + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + return 0; + else + u = y.succ(u); + } + } +} + + +// linear-time, zero space overhead binary tree rebalancing from +// Stout & Warren, ``Tree rebalancing in linear space and time'' +// CACM, Sept, 1986, p902. + + +void BSTSet::balance() +{ + if (count <= 2) return; // don't bother -- + // also we assume non-null root, below + + // make re-attaching the root easy via trickery + + struct _fake_node { _fake_node *lt, *rt, *par; } fake_root; + + fake_root.rt = (_fake_node*)root; + fake_root.par = 0; + BSTNode* pseudo_root = (BSTNode*)&fake_root; + + // phase 1: tree-to-vine + + BSTNode* vine_tail = pseudo_root; + BSTNode* remainder = root; + + while (remainder != 0) + { + if (remainder->lt == 0) + { + vine_tail = remainder; + remainder = remainder->rt; + } + else + { + BSTNode* tmp = remainder->lt; + remainder->lt = tmp->rt; + if (remainder->lt != 0) remainder->lt->par = remainder; + tmp->rt = remainder; + remainder->par = tmp; + vine_tail->rt = remainder = tmp; + } + } + + // phase 2: vine-to-tree + + // Uses the slightly simpler version adapted from + // Day ``Balancing a binary tree'' Computer Journal, Nov. 1976, + // since it's not generally important whether the `stray' leaves are + // on the left or on the right. + + unsigned int spines = count - 1; + while (spines > 1) + { + int compressions = spines >> 1; // compress every other node + spines -= compressions + 1; // halve for next time + + BSTNode* scanner = pseudo_root; + while (compressions-- > 0) + { + BSTNode* child = scanner->rt; + BSTNode* grandchild = child->rt; + scanner->rt = grandchild; + grandchild->par = scanner; + child->rt = grandchild->lt; + if (child->rt != 0) child->rt->par = child; + grandchild->lt = child; + child->par = grandchild; + scanner = grandchild; + } + } + + root = pseudo_root->rt; + root->par = 0; +} + + +int BSTSet::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + BSTNode* trail = leftmost(); + BSTNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/BSTSet.hP b/gnu/lib/libg++/libg++/src/gen/BSTSet.hP new file mode 100644 index 00000000000..79a3dd36edf --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/BSTSet.hP @@ -0,0 +1,152 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _BSTSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _BSTSet_h 1 + +#include ".Set.h" + +#ifndef _BSTNode +#define _BSTNode 1 + +struct BSTNode +{ + BSTNode* lt; + BSTNode* rt; + BSTNode* par; + item; + BSTNode( h, BSTNode* l=0, BSTNode* r=0, + BSTNode* p = 0); + ~BSTNode(); +}; + +inline BSTNode::BSTNode( h, BSTNode* l, BSTNode* r, + BSTNode* p) +:lt(l), rt(r), par(p), item(h) {} + +inline BSTNode::~BSTNode() {} + +typedef BSTNode* BSTNodePtr; + +#endif + +class BSTSet : public Set +{ +protected: + BSTNode* root; + + BSTNode* leftmost(); + BSTNode* rightmost(); + BSTNode* pred(BSTNode* t); + BSTNode* succ(BSTNode* t); + void _kill(BSTNode* t); + BSTNode* _copy(BSTNode* t); + +public: + BSTSet(); + BSTSet(BSTSet& a); + inline ~BSTSet(); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item); + + Pix last(); + void prev(Pix& i); + + int operator == (BSTSet& b); + int operator != (BSTSet& b); + int operator <= (BSTSet& b); + + void balance(); + int OK(); +}; + +inline BSTSet::~BSTSet() +{ + _kill(root); +} + +inline BSTSet::BSTSet() +{ + root = 0; + count = 0; +} + + +inline BSTSet::BSTSet(BSTSet& a) +{ + count = a.count; + root = _copy(a.root); +} + +inline int BSTSet::operator != (BSTSet& b) +{ + return ! (*this == b); +} + +inline Pix BSTSet::first() +{ + return Pix(leftmost()); +} + +inline Pix BSTSet::last() +{ + return Pix(rightmost()); +} + +inline void BSTSet::next(Pix& i) +{ + if (i != 0) i = Pix(succ((BSTNode*)i)); +} + +inline void BSTSet::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((BSTNode*)i)); +} + +inline & BSTSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((BSTNode*)i)->item; +} + +inline void BSTSet::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int BSTSet::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Bag.ccP b/gnu/lib/libg++/libg++/src/gen/Bag.ccP new file mode 100644 index 00000000000..3f9f06c00bc --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Bag.ccP @@ -0,0 +1,74 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".Bag.h" + +// error handling + +void Bag::error(const char* msg) +{ + (*lib_error_handler)("Bag", msg); +} + + +Pix Bag::seek( item, Pix i) +{ + if (i == 0) + i = first(); + else + next(i); + for (;i != 0 && (!(EQ((*this)(i), item))); next(i)); + return i; +} + +int Bag::owns(Pix p) +{ + if (p == 0) return 0; + for (Pix i = first(); i != 0; next(i)) if (i == p) return 1; + return 0; +} + +void Bag::remove( item) +{ + int i = nof(item); + while (i-- > 0) del(item); +} + + +int Bag::nof( item) +{ + int n = 0; + for (Pix p = first(); p; next(p)) if (EQ((*this)(p), item)) ++n; + return n; +} + +void Bag::clear() +{ + Pix i = first(); + while (i != 0) + { + del((*this)(i)); + i = first(); + } +} + + diff --git a/gnu/lib/libg++/libg++/src/gen/Bag.hP b/gnu/lib/libg++/libg++/src/gen/Bag.hP new file mode 100644 index 00000000000..de6dc5c4ca0 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Bag.hP @@ -0,0 +1,79 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Bag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Bag_h 1 + +#include +#include ".defs.h" + +class Bag +{ +protected: + int count; + +public: + inline virtual ~Bag(); + + int length(); // current number of items + int empty(); + + virtual Pix add( item) = 0; // add item; return Pix + + virtual void del( item) = 0; // delete 1 occurrence of item +#undef remove + virtual void remove( item); // delete all occurrences + virtual void clear(); // delete all items + + inline virtual int contains( item); // is item in Bag? + virtual int nof( item); // how many in Bag? + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + + virtual & operator () (Pix i) = 0; // access item at i + + virtual Pix seek( item, Pix from=0); // Pix of next occurrence + virtual int owns(Pix i); // is i a valid Pix ? + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + +inline Bag::~Bag() {} + +inline int Bag::length() +{ + return count; +} + +inline int Bag::empty() +{ + return count == 0; +} + +inline int Bag::contains( item) +{ + return seek(item) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/CHBag.ccP b/gnu/lib/libg++/libg++/src/gen/CHBag.ccP new file mode 100644 index 00000000000..22c9d707a59 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHBag.ccP @@ -0,0 +1,210 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".CHBag.h" + +// The nodes are linked together serially via a version +// of a trick used in some vtables: odd pointers are +// actually links to the next table entry. +// Not terrible, but not wonderful either + +static inline int goodCHptr(CHNode* t) +{ + return ((((unsigned)t) & 1) == 0); +} + +static inline CHNode* index_to_CHptr(int i) +{ + return (CHNode*)((i << 1) + 1); +} + +static inline int CHptr_to_index(CHNode* t) +{ + return ( ((unsigned) t) >> 1); +} + +CHBag::CHBag(unsigned int sz) +{ + tab = (CHNode**)(new CHNodePtr[size = sz]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; +} + +CHBag::CHBag(CHBag& a) +{ + tab = (CHNode**)(new CHNodePtr[size = a.size]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; + for (Pix p = a.first(); p; a.next(p)) add(a(p)); +} + + +Pix CHBag::seek( key, Pix i) +{ + CHNode* p = (CHNode*)i; + if (p == 0 || !EQ(p->hd, key)) + { + unsigned int h = HASH(key) % size; + for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(key, t->hd)) + return Pix(t); + } + else + { + for (p = p->tl; goodCHptr(p); p = p->tl) + if (EQ(p->hd, key)) + return Pix(p); + } + return 0; +} + +int CHBag::nof( key) +{ + int n = 0; + unsigned int h = HASH(key) % size; + for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(key, t->hd)) ++n; + return n; +} + + +Pix CHBag::add( item) +{ + unsigned int h = HASH(item) % size; + CHNode* t = new CHNode(item); + t->tl = tab[h]; + tab[h] = t; + ++count; + return Pix(t); +} + +void CHBag::del( key) +{ + unsigned int h = HASH(key) % size; + + CHNode* t = tab[h]; + CHNode* trail = t; + while (goodCHptr(t)) + { + if (EQ(key, t->hd)) + { + if (trail == t) + tab[h] = t->tl; + else + trail->tl = t->tl; + delete t; + --count; + return; + } + trail = t; + t = t->tl; + } +} + +void CHBag::remove( key) +{ + unsigned int h = HASH(key) % size; + + CHNode* t = tab[h]; + CHNode* trail = t; + while (goodCHptr(t)) + { + if (EQ(key, t->hd)) + { + --count; + if (trail == t) + { + tab[h] = t->tl; + delete t; + t = trail = tab[h]; + } + else + { + trail->tl = t->tl; + delete t; + t = trail->tl; + } + } + else + { + trail = t; + t = t->tl; + } + } +} + + +void CHBag::clear() +{ + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p = tab[i]; + tab[i] = index_to_CHptr(i+1); + while (goodCHptr(p)) + { + CHNode* nxt = p->tl; + delete(p); + p = nxt; + } + } + count = 0; +} + +Pix CHBag::first() +{ + for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); + return 0; +} + +void CHBag::next(Pix& p) +{ + if (p == 0) return; + CHNode* t = ((CHNode*)p)->tl; + if (goodCHptr(t)) + p = Pix(t); + else + { + for (unsigned int i = CHptr_to_index(t); i < size; ++i) + { + if (goodCHptr(tab[i])) + { + p = Pix(tab[i]); + return; + } + } + p = 0; + } +} + +int CHBag::OK() +{ + int v = tab != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p; + for (p = tab[i]; goodCHptr(p); p = p->tl) ++n; + v &= CHptr_to_index(p) == i + 1; + } + v &= count == n; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/CHBag.hP b/gnu/lib/libg++/libg++/src/gen/CHBag.hP new file mode 100644 index 00000000000..b2fe61f6707 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHBag.hP @@ -0,0 +1,76 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _CHBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _CHBag_h 1 + +#include ".Bag.h" + + +#include ".CHNode.h" + +class CHBag : public Bag +{ +protected: + CHNode** tab; + unsigned int size; + +public: + CHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + CHBag(CHBag& a); + inline ~CHBag(); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +inline CHBag::~CHBag() +{ + clear(); + delete tab; +} + +inline int CHBag::contains( key) +{ + return seek(key) != 0; +} + +inline & CHBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((CHNode*)i)->hd; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/CHMap.ccP b/gnu/lib/libg++/libg++/src/gen/CHMap.ccP new file mode 100644 index 00000000000..af28fc305a8 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHMap.ccP @@ -0,0 +1,168 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 "..CHMap.h" + +// The nodes are linked together serially via a version +// of a trick used in some vtables: odd pointers are +// actually links to the next table entry. +// Not terrible, but not wonderful either + +static inline int goodCHptr(CHNode* t) +{ + return ((((unsigned)t) & 1) == 0); +} + +static inline CHNode* index_to_CHptr(int i) +{ + return (CHNode*)((i << 1) + 1); +} + +static inline int CHptr_to_index(CHNode* t) +{ + return ( ((unsigned) t) >> 1); +} + +CHMap::CHMap( dflt, unsigned int sz) + :Map(dflt) +{ + tab = (CHNode**)(new CHNodePtr[size = sz]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; +} + +CHMap::CHMap(CHMap& a) :Map(a.def) +{ + tab = (CHNode**)(new CHNodePtr[size = a.size]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; + for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); +} + + +Pix CHMap::seek( key) +{ + unsigned int h = HASH(key) % size; + + for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(key, t->hd)) + return Pix(t); + + return 0; +} + + +& CHMap::operator []( item) +{ + unsigned int h = HASH(item) % size; + CHNode* t; + + for (t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(item, t->hd)) + return t->cont; + + t = new CHNode(item, def, tab[h]); + tab[h] = t; + ++count; + return t->cont; +} + + +void CHMap::del( key) +{ + unsigned int h = HASH(key) % size; + + CHNode* t = tab[h]; + CHNode* trail = t; + while (goodCHptr(t)) + { + if (EQ(key, t->hd)) + { + if (trail == t) + tab[h] = t->tl; + else + trail->tl = t->tl; + delete t; + --count; + return; + } + trail = t; + t = t->tl; + } +} + + +void CHMap::clear() +{ + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p = tab[i]; + tab[i] = index_to_CHptr(i+1); + while (goodCHptr(p)) + { + CHNode* nxt = p->tl; + delete(p); + p = nxt; + } + } + count = 0; +} + +Pix CHMap::first() +{ + for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); + return 0; +} + +void CHMap::next(Pix& p) +{ + CHNode* t = ((CHNode*)p)->tl; + if (goodCHptr(t)) + p = Pix(t); + else + { + for (unsigned int i = CHptr_to_index(t); i < size; ++i) + { + if (goodCHptr(tab[i])) + { + p = Pix(tab[i]); + return; + } + } + p = 0; + } +} + + +int CHMap::OK() +{ + int v = tab != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p; + for (p = tab[i]; goodCHptr(p); p = p->tl) ++n; + v &= CHptr_to_index(p) == i + 1; + } + v &= count == n; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/CHMap.hP b/gnu/lib/libg++/libg++/src/gen/CHMap.hP new file mode 100644 index 00000000000..2b4e25a284b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHMap.hP @@ -0,0 +1,104 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _CHMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _CHMap_h 1 + +#include "..Map.h" + +#ifndef _CHNode_h +#define _CHNode_h 1 + +struct CHNode +{ + CHNode* tl; + hd; + cont; + CHNode(); + CHNode( h, c, CHNode* t = 0); + ~CHNode(); +}; + +inline CHNode::CHNode() {} + +inline CHNode::CHNode( h, c, CHNode* t) + : tl(t), hd(h), cont(c) {} + +inline CHNode::~CHNode() {} + +typedef CHNode* CHNodePtr; + +#endif + + +class CHMap : public Map +{ +protected: + CHNode** tab; + unsigned int size; + +public: + CHMap( dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY); + CHMap(CHMap& a); + inline ~CHMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + inline & key(Pix i); + inline & contents(Pix i); + + Pix seek( key); + inline int contains( key); + + void clear(); + int OK(); +}; + + +inline CHMap::~CHMap() +{ + clear(); + delete tab; +} + +inline int CHMap::contains( key) +{ + return seek(key) != 0; +} + +inline & CHMap::key(Pix p) +{ + if (p == 0) error("null Pix"); + return ((CHNode*)p)->hd; +} + +inline & CHMap::contents(Pix p) +{ + if (p == 0) error("null Pix"); + return ((CHNode*)p)->cont; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/CHNode.ccP b/gnu/lib/libg++/libg++/src/gen/CHNode.ccP new file mode 100644 index 00000000000..b9a1e176ef4 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHNode.ccP @@ -0,0 +1,21 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1992 Free Software Foundation + +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 ".CHNode.h" diff --git a/gnu/lib/libg++/libg++/src/gen/CHNode.hP b/gnu/lib/libg++/libg++/src/gen/CHNode.hP new file mode 100644 index 00000000000..af3acd1557c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHNode.hP @@ -0,0 +1,43 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1982 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. +*/ + +#ifndef _CHNode_h +#define _CHNode_h 1 +#ifdef __GNUG__ +#pragma interface +#endif +#include ".defs.h" + +struct CHNode +{ + CHNode* tl; + hd; + CHNode(); + CHNode( h, CHNode* t = 0); + ~CHNode(); +}; + +inline CHNode::CHNode() {} + +inline CHNode::CHNode( h, CHNode* t) :tl(t), hd(h) {} + +inline CHNode::~CHNode() {} + +typedef CHNode* CHNodePtr; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/CHSet.ccP b/gnu/lib/libg++/libg++/src/gen/CHSet.ccP new file mode 100644 index 00000000000..5a3727b7970 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHSet.ccP @@ -0,0 +1,273 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".CHSet.h" + +// A CHSet is implemented as an array (tab) of buckets, each of which +// contains a pointer to a list of CHNodes. Each node contains a +// pointer to the next node in the list, and a pointer to the . +// The end of the list is marked by a next node pointer which is odd +// when considered as an integer (least significant bit = 1). The +// assumption is that CHNodes will all begin on even addresses. If +// the odd pointer is right-shifted by one bit, it becomes the index +// within the tab array of the next bucket (that is, bucket i has +// next bucket pointer 2*(i+1)+1). + +// The bucket pointers are initialized by the constructor and +// used to support the next(Pix&) method. + +// This implementation is not portable to machines with different +// pointer and integer sizes, or on which CHNodes might be aligned on +// odd byte boundaries, but allows the same pointer to be used for +// chaining within a bucket and to the next bucket. + + +static inline int goodCHptr(CHNode* t) +{ + return ((((unsigned)t) & 1) == 0); +} + +static inline CHNode* index_to_CHptr(int i) +{ + return (CHNode*)((i << 1) + 1); +} + +static inline int CHptr_to_index(CHNode* t) +{ + return ( ((unsigned) t) >> 1); +} + +CHSet::CHSet(unsigned int sz) +{ + tab = (CHNode**)(new CHNodePtr[size = sz]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; +} + +CHSet::CHSet(CHSet& a) +{ + tab = (CHNode**)(new CHNodePtr[size = a.size]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; + for (Pix p = a.first(); p; a.next(p)) add(a(p)); +} + + +Pix CHSet::seek( key) +{ + unsigned int h = HASH(key) % size; + + for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(key, t->hd)) + return Pix(t); + + return 0; +} + + +Pix CHSet::add( item) +{ + unsigned int h = HASH(item) % size; + CHNode* t; + + for (t = tab[h]; goodCHptr(t); t = t->tl) + if (EQ(item, t->hd)) + return Pix(t); + + ++count; + t = new CHNode(item, tab[h]); + tab[h] = t; + return Pix(t); +} + + +void CHSet::del( key) +{ + unsigned int h = HASH(key) % size; + + CHNode* t = tab[h]; + CHNode* trail = t; + while (goodCHptr(t)) + { + if (EQ(key, t->hd)) + { + if (trail == t) + tab[h] = t->tl; + else + trail->tl = t->tl; + delete t; + --count; + return; + } + trail = t; + t = t->tl; + } +} + + +void CHSet::clear() +{ + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p = tab[i]; + tab[i] = index_to_CHptr(i+1); + while (goodCHptr(p)) + { + CHNode* nxt = p->tl; + delete(p); + p = nxt; + } + } + count = 0; +} + +Pix CHSet::first() +{ + for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); + return 0; +} + +void CHSet::next(Pix& p) +{ + if (p == 0) return; + CHNode* t = ((CHNode*)p)->tl; + if (goodCHptr(t)) + p = Pix(t); + else + { + for (unsigned int i = CHptr_to_index(t); i < size; ++i) + { + if (goodCHptr(tab[i])) + { + p = Pix(tab[i]); + return; + } + } + p = 0; + } +} + +int CHSet::operator == (CHSet& b) +{ + if (count != b.count) + return 0; + else + { + CHNode* p; + for (unsigned int i = 0; i < size; ++i) + for (p = tab[i]; goodCHptr(p); p = p->tl) + if (b.seek(p->hd) == 0) + return 0; + for (unsigned int i = 0; i < b.size; ++i) + for (p = b.tab[i]; goodCHptr(p); p = p->tl) + if (seek(p->hd) == 0) + return 0; + return 1; + } +} + +int CHSet::operator <= (CHSet& b) +{ + if (count > b.count) + return 0; + else + { + for (unsigned int i = 0; i < size; ++i) + for (CHNode* p = tab[i]; goodCHptr(p); p = p->tl) + if (b.seek(p->hd) == 0) + return 0; + return 1; + } +} + +void CHSet::operator |= (CHSet& b) +{ + if (&b == this || b.count == 0) + return; + for (unsigned int i = 0; i < b.size; ++i) + for (CHNode* p = b.tab[i]; goodCHptr(p); p = p->tl) + add(p->hd); +} + +void CHSet::operator &= (CHSet& b) +{ + for (unsigned int i = 0; i < size; ++i) + { + CHNode* t = tab[i]; + CHNode* trail = t; + while (goodCHptr(t)) + { + CHNode* nxt = t->tl; + if (b.seek(t->hd) == 0) + { + if (trail == tab[i]) + trail = tab[i] = nxt; + else + trail->tl = nxt; + delete t; + --count; + } + else + trail = t; + t = nxt; + } + } +} + +void CHSet::operator -= (CHSet& b) +{ + for (unsigned int i = 0; i < size; ++i) + { + CHNode* t = tab[i]; + CHNode* trail = t; + while (goodCHptr(t)) + { + CHNode* nxt = t->tl; + if (b.seek(t->hd) != 0) + { + if (trail == tab[i]) + trail = tab[i] = nxt; + else + trail->tl = nxt; + delete t; + --count; + } + else + trail = t; + t = nxt; + } + } +} + +int CHSet::OK() +{ + int v = tab != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + CHNode* p; + for (p = tab[i]; goodCHptr(p); p = p->tl) ++n; + v &= CHptr_to_index(p) == i + 1; + } + v &= count == n; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/CHSet.hP b/gnu/lib/libg++/libg++/src/gen/CHSet.hP new file mode 100644 index 00000000000..1fc2c8e994f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/CHSet.hP @@ -0,0 +1,84 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _CHSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _CHSet_h 1 + +#include ".Set.h" +#include ".CHNode.h" + +class CHSet : public Set +{ +protected: + CHNode** tab; + unsigned int size; + +public: + CHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + CHSet(CHSet& a); + inline ~CHSet(); + + Pix add( item); + void del( item); + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item); + + void operator |= (CHSet& b); + void operator -= (CHSet& b); + void operator &= (CHSet& b); + + int operator == (CHSet& b); + int operator != (CHSet& b); + int operator <= (CHSet& b); + + int OK(); +}; + +inline CHSet::~CHSet() +{ + clear(); + delete tab; +} + +inline int CHSet::contains( key) +{ + return seek(key) != 0; +} + +inline & CHSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((CHNode*)i)->hd; +} + +inline int CHSet::operator != (CHSet& b) +{ + return ! ((*this) == b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/DLDeque.ccP b/gnu/lib/libg++/libg++/src/gen/DLDeque.ccP new file mode 100644 index 00000000000..d5a0db7f910 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/DLDeque.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".DLDeque.h" diff --git a/gnu/lib/libg++/libg++/src/gen/DLDeque.hP b/gnu/lib/libg++/libg++/src/gen/DLDeque.hP new file mode 100644 index 00000000000..6d8cc70fd98 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/DLDeque.hP @@ -0,0 +1,130 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _DLDeque_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _DLDeque_h + +#include ".DLList.h" +#include ".Deque.h" + +class DLDeque : public Deque +{ + DLList p; + +public: + DLDeque(); + DLDeque(const DLDeque& d); + inline ~DLDeque(); + + void operator = (const DLDeque&); + + inline void push( item); // insert at front + inline void enq( item); // insert at rear + + inline & front(); + inline & rear(); + + inline deq(); + inline void del_front(); + inline void del_rear(); + + inline void clear(); + inline int empty(); + inline int full(); + inline int length(); + + inline int OK(); +}; + + +inline DLDeque::DLDeque() : p() {} +inline DLDeque::DLDeque(const DLDeque& d) : p(d.p) {} + +inline DLDeque::~DLDeque() {} + +inline void DLDeque::push(item) +{ + p.prepend(item); +} + +inline void DLDeque::enq(item) +{ + p.append(item); +} + +inline DLDeque::deq() +{ + return p.remove_front(); +} + +inline & DLDeque::front() +{ + return p.front(); +} + +inline & DLDeque::rear() +{ + return p.rear(); +} + +inline void DLDeque::del_front() +{ + p.del_front(); +} + +inline void DLDeque::del_rear() +{ + p.del_rear(); +} + +inline void DLDeque::operator =(const DLDeque& s) +{ + p.operator = (s.p); +} + + +inline int DLDeque::empty() +{ + return p.empty(); +} + +inline int DLDeque::full() +{ + return 0; +} + +inline int DLDeque::length() +{ + return p.length(); +} + +inline int DLDeque::OK() +{ + return p.OK(); +} + +inline void DLDeque::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/DLList.ccP b/gnu/lib/libg++/libg++/src/gen/DLList.ccP new file mode 100644 index 00000000000..c870dc18595 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/DLList.ccP @@ -0,0 +1,339 @@ +// This may look like C code, but it is really -*- C++ -*- +// WARNING: This file is obsolete. Use ../DLList.cc, if you can. +/* +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 +#include +#include +#include ".DLList.h" + +// error handling + + + +void DLList::error(const char* msg) +{ + (*lib_error_handler)("DLList", msg); +} + +int DLList::length() +{ + int l = 0; + DLListNode* t = h; + if (t != 0) do { ++l; t = t->fd; } while (t != h); + return l; +} + +DLList::DLList(const DLList& a) +{ + if (a.h == 0) + h = 0; + else + { + DLListNode* p = a.h; + DLListNode* t = new DLListNode(p->hd); + h = t; + p = p->fd; + while (p != a.h) + { + DLListNode* n = new DLListNode(p->hd); + t->fd = n; + n->bk = t; + t = n; + p = p->fd; + } + t->fd = h; + h->bk = t; + return; + } +} + +DLList& DLList::operator = (const DLList& a) +{ + if (h != a.h) + { + clear(); + if (a.h != 0) + { + DLListNode* p = a.h; + DLListNode* t = new DLListNode(p->hd); + h = t; + p = p->fd; + while (p != a.h) + { + DLListNode* n = new DLListNode(p->hd); + t->fd = n; + n->bk = t; + t = n; + p = p->fd; + } + t->fd = h; + h->bk = t; + } + } + return *this; +} + +void DLList::clear() +{ + if (h == 0) + return; + + DLListNode* p = h->fd; + h->fd = 0; + h = 0; + + while (p != 0) + { + DLListNode* nxt = p->fd; + delete(p); + p = nxt; + } +} + + +Pix DLList::prepend( item) +{ + DLListNode* t = new DLListNode(item); + if (h == 0) + t->fd = t->bk = h = t; + else + { + t->fd = h; + t->bk = h->bk; + h->bk->fd = t; + h->bk = t; + h = t; + } + return Pix(t); +} + +Pix DLList::append( item) +{ + DLListNode* t = new DLListNode(item); + if (h == 0) + t->fd = t->bk = h = t; + else + { + t->bk = h->bk; + t->bk->fd = t; + t->fd = h; + h->bk = t; + } + return Pix(t); +} + +Pix DLList::ins_after(Pix p, item) +{ + if (p == 0) return prepend(item); + DLListNode* u = (DLListNode*) p; + DLListNode* t = new DLListNode(item, u, u->fd); + u->fd->bk = t; + u->fd = t; + return Pix(t); +} + +Pix DLList::ins_before(Pix p, item) +{ + if (p == 0) error("null Pix"); + DLListNode* u = (DLListNode*) p; + DLListNode* t = new DLListNode(item, u->bk, u); + u->bk->fd = t; + u->bk = t; + if (u == h) h = t; + return Pix(t); +} + +void DLList::join(DLList& b) +{ + DLListNode* t = b.h; + b.h = 0; + if (h == 0) + h = t; + else if (t != 0) + { + DLListNode* l = t->bk; + h->bk->fd = t; + t->bk = h->bk; + h->bk = l; + l->fd = h; + } +} + +int DLList::owns(Pix p) +{ + DLListNode* t = h; + if (t != 0 && p != 0) + { + do + { + if (Pix(t) == p) return 1; + t = t->fd; + } while (t != h); + } + return 0; +} + +void DLList::del(Pix& p, int dir) +{ + if (p == 0) error("null Pix"); + DLListNode* t = (DLListNode*) p; + if (t->fd == t) + { + h = 0; + p = 0; + } + else + { + if (dir < 0) + { + if (t == h) + p = 0; + else + p = Pix(t->bk); + } + else + { + if (t == h->bk) + p = 0; + else + p = Pix(t->fd); + } + t->bk->fd = t->fd; + t->fd->bk = t->bk; + if (t == h) h = t->fd; + } + delete t; +} + +void DLList::del_after(Pix& p) +{ + if (p == 0) + { + del_front(); + return; + } + + DLListNode* b = (DLListNode*) p; + DLListNode* t = b->fd; + + if (b == t) + { + h = 0; + p = 0; + } + else + { + t->bk->fd = t->fd; + t->fd->bk = t->bk; + if (t == h) h = t->fd; + } + delete t; +} + + DLList::remove_front() +{ + if (h == 0) + error("remove_front of empty list"); + DLListNode* t = h; + res = t->hd; + if (h->fd == h) + h = 0; + else + { + h->fd->bk = h->bk; + h->bk->fd = h->fd; + h = h->fd; + } + delete t; + return res; +} + + +void DLList::del_front() +{ + if (h == 0) + error("del_front of empty list"); + DLListNode* t = h; + if (h->fd == h) + h = 0; + else + { + h->fd->bk = h->bk; + h->bk->fd = h->fd; + h = h->fd; + } + delete t; +} + + DLList::remove_rear() +{ + if (h == 0) + error("remove_rear of empty list"); + DLListNode* t = h->bk; + res = t->hd; + if (h->fd == h) + h = 0; + else + { + t->fd->bk = t->bk; + t->bk->fd = t->fd; + } + delete t; + return res; +} + + +void DLList::del_rear() +{ + if (h == 0) + error("del_rear of empty list"); + DLListNode* t = h->bk; + if (h->fd == h) + h = 0; + else + { + t->fd->bk = t->bk; + t->bk->fd = t->fd; + } + delete t; +} + + +int DLList::OK() +{ + int v = 1; + if (h != 0) + { + DLListNode* t = h; + long count = LONG_MAX; // Lots of chances to find h! + do + { + count--; + v &= t->bk->fd == t; + v &= t->fd->bk == t; + t = t->fd; + } while (v && count > 0 && t != h); + v &= count > 0; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/DLList.hP b/gnu/lib/libg++/libg++/src/gen/DLList.hP new file mode 100644 index 00000000000..8d1a3f45d7b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/DLList.hP @@ -0,0 +1,157 @@ +// This may look like C code, but it is really -*- C++ -*- +// WARNING: This file is obsolete. Use ../DLList.h, if you can. +/* +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. +*/ + + +#ifndef _DLList_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _DLList_h 1 + +#include +#include ".defs.h" + +#ifndef _DLListNode_h +#define _DLListNode_h 1 + +struct DLListNode +{ + DLListNode* bk; + DLListNode* fd; + hd; + DLListNode(); + DLListNode(const h, + DLListNode* p = 0, + DLListNode* n = 0); + ~DLListNode(); +}; + +inline DLListNode::DLListNode() {} + +inline DLListNode::DLListNode(const h, DLListNode* p, + DLListNode* n) + :bk(p), fd(n), hd(h) {} + +inline DLListNode::~DLListNode() {} + +typedef DLListNode* DLListNodePtr; + +#endif + +class DLList +{ + friend class DLListTrav; + + DLListNode* h; + +public: + DLList(); + DLList(const DLList& a); + ~DLList(); + + DLList& operator = (const DLList& a); + + int empty(); + int length(); + + void clear(); + + Pix prepend( item); + Pix append( item); + void join(DLList&); + + & front(); + remove_front(); + void del_front(); + + & rear(); + remove_rear(); + void del_rear(); + + & operator () (Pix p); + Pix first(); + Pix last(); + void next(Pix& p); + void prev(Pix& p); + int owns(Pix p); + Pix ins_after(Pix p, item); + Pix ins_before(Pix p, item); + void del(Pix& p, int dir = 1); + void del_after(Pix& p); + + void error(const char* msg); + int OK(); +}; + + +inline DLList::~DLList() +{ + clear(); +} + +inline DLList::DLList() +{ + h = 0; +} + +inline int DLList::empty() +{ + return h == 0; +} + + +inline void DLList::next(Pix& p) +{ + p = (p == 0 || p == h->bk)? 0 : Pix(((DLListNode*)p)->fd); +} + +inline void DLList::prev(Pix& p) +{ + p = (p == 0 || p == h)? 0 : Pix(((DLListNode*)p)->bk); +} + +inline Pix DLList::first() +{ + return Pix(h); +} + +inline Pix DLList::last() +{ + return (h == 0)? 0 : Pix(h->bk); +} + +inline & DLList::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return ((DLListNode*)p)->hd; +} + +inline & DLList::front() +{ + if (h == 0) error("front: empty list"); + return h->hd; +} + +inline & DLList::rear() +{ + if (h == 0) error("rear: empty list"); + return h->bk->hd; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Deque.ccP b/gnu/lib/libg++/libg++/src/gen/Deque.ccP new file mode 100644 index 00000000000..79a9b72c875 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Deque.ccP @@ -0,0 +1,11 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".Deque.h" + +Deque::~Deque() {} + +void Deque::error(const char* msg) +{ + (*lib_error_handler)("Deque", msg); +} diff --git a/gnu/lib/libg++/libg++/src/gen/Deque.hP b/gnu/lib/libg++/libg++/src/gen/Deque.hP new file mode 100644 index 00000000000..35764321f35 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Deque.hP @@ -0,0 +1,57 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _Deque_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Deque_h + +#include + +#include ".defs.h" + +class Deque +{ +public: + Deque() { } + virtual ~Deque(); + + virtual void push( item) = 0; // insert at front + virtual void enq( item) = 0; // insert at rear + + virtual & front() = 0; + virtual & rear() = 0; + + virtual deq() = 0; + virtual void del_front() = 0; + virtual void del_rear() = 0; + + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + virtual void clear() = 0; + + virtual int OK() = 0; + + void error(const char*); +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/FPQueue.ccP b/gnu/lib/libg++/libg++/src/gen/FPQueue.ccP new file mode 100644 index 00000000000..a358cacb60e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPQueue.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".FPQueue.h" diff --git a/gnu/lib/libg++/libg++/src/gen/FPQueue.hP b/gnu/lib/libg++/libg++/src/gen/FPQueue.hP new file mode 100644 index 00000000000..adf7e8d3159 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPQueue.hP @@ -0,0 +1,112 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _FPQueue_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _FPQueue_h + +#include ".FPlex.h" +#include ".Queue.h" + +class FPQueue : public Queue +{ + FPlex p; + +public: + FPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY); + FPQueue(const FPQueue& q); + ~FPQueue(); + + void operator = (const FPQueue&); + + void enq( item); + deq(); + & front(); + void del_front(); + + void clear(); + int empty(); + int full(); + int length(); + + int OK(); +}; + +inline FPQueue::FPQueue(int chunksize) : p(chunksize) {} +inline FPQueue::FPQueue(const FPQueue& q) : p(q.p) {} + +inline FPQueue::~FPQueue() {} + +inline void FPQueue::enq(item) +{ + p.add_high(item); +} + +inline FPQueue::deq() +{ + res = p.low_element(); + p.del_low(); + return res; +} + +inline & FPQueue::front() +{ + return p.low_element(); +} + + +inline void FPQueue::del_front() +{ + p.del_low(); +} + +inline void FPQueue::operator =(const FPQueue& s) +{ + p = s.p; +} + +inline int FPQueue::empty() +{ + return p.empty(); +} + +inline int FPQueue::full() +{ + return p.full(); +} + +inline int FPQueue::length() +{ + return p.length(); +} + +inline int FPQueue::OK() +{ + return p.OK(); +} + +inline void FPQueue::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/FPStack.ccP b/gnu/lib/libg++/libg++/src/gen/FPStack.ccP new file mode 100644 index 00000000000..954991193b7 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPStack.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".FPStack.h" diff --git a/gnu/lib/libg++/libg++/src/gen/FPStack.hP b/gnu/lib/libg++/libg++/src/gen/FPStack.hP new file mode 100644 index 00000000000..de1310465f9 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPStack.hP @@ -0,0 +1,114 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _FPStack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _FPStack_h + +#include ".FPlex.h" +#include ".Stack.h" + +class FPStack : public Stack +{ + FPlex p; + +public: + FPStack(int chunksize = DEFAULT_INITIAL_CAPACITY); + FPStack(const FPStack& s); + ~FPStack(); + + void operator = (const FPStack&); + + void push( item); + pop(); + & top(); + void del_top(); + + int empty(); + int full(); + int length(); + + void clear(); + + int OK(); + +}; + + +inline FPStack::FPStack(int chunksize) : p(chunksize) {} +inline FPStack::FPStack(const FPStack& s) : p(s.p) {} + +inline FPStack::~FPStack() {} + +inline void FPStack::push(item) +{ + p.add_high(item); +} + +inline FPStack::pop() +{ + res = p.high_element(); + p.del_high(); + return res; +} + +inline & FPStack::top() +{ + return p.high_element(); +} + +inline void FPStack::del_top() +{ + p.del_high(); +} + +inline void FPStack::operator =(const FPStack& s) +{ + p = s.p; +} + +inline int FPStack::empty() +{ + return p.empty(); +} + +inline int FPStack::full() +{ + return p.full(); +} + +inline int FPStack::length() +{ + return p.length(); +} + +inline int FPStack::OK() +{ + return p.OK(); +} + +inline void FPStack::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/FPlex.ccP b/gnu/lib/libg++/libg++/src/gen/FPlex.ccP new file mode 100644 index 00000000000..980870d8675 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPlex.ccP @@ -0,0 +1,167 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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 ".FPlex.h" + + +FPlex:: FPlex() +{ + lo = fnc = 0; + csize = DEFAULT_INITIAL_CAPACITY; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, csize); +} + +FPlex:: FPlex(int maxsize) +{ + if (maxsize == 0) error("invalid constructor specification"); + lo = fnc = 0; + if (maxsize > 0) + { + csize = maxsize; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, csize); + } + else + { + csize = -maxsize; + * data = new [csize]; + hd = new IChunk(data, maxsize, lo, fnc, fnc); + } +} + + +FPlex:: FPlex(int l, int maxsize) +{ + if (maxsize == 0) error("invalid constructor specification"); + lo = fnc = l; + if (maxsize > 0) + { + csize = maxsize; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, csize+lo); + } + else + { + csize = -maxsize; + * data = new [csize]; + hd = new IChunk(data, maxsize+lo, lo, fnc, fnc); + } +} + +FPlex:: FPlex(int l, int hi, const initval, int maxsize) +{ + lo = l; + fnc = hi + 1; + if (maxsize >= 0) + { + csize = maxsize; + if (csize < fnc - lo) + csize = fnc - lo; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, csize); + } + else + { + csize = -maxsize; + if (csize < fnc - lo) + csize = fnc - lo; + * data = new [csize]; + hd = new IChunk(data, -csize, lo, fnc, fnc); + } + fill(initval); +} + +FPlex::FPlex(const FPlex& a) +{ + lo = a.lo; + fnc = a.fnc; + csize = fnc - lo; + if (csize < a.csize) csize = a.csize; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, lo+csize); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; +} + +void FPlex::operator= (const FPlex& a) +{ + if (&a != this) + { + del_chunk(hd); + lo = a.lo; + fnc = a.fnc; + csize = fnc - lo; + if (csize < a.csize) csize = a.csize; + * data = new [csize]; + hd = new IChunk(data, lo, lo, fnc, lo+csize); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; + } +} + + +void FPlex::reverse() +{ + tmp; + int l = lo; + int h = fnc - 1; + while (l < h) + { + tmp = (*this)[l]; + (*this)[l] = (*this)[h]; + (*this)[h] = tmp; + next(l); + prev(h); + } +} + +void FPlex::fill(const x) +{ + for (int i = lo; i < fnc; ++i) (*this)[i] = x; +} + +void FPlex::fill(const x, int lo, int hi) +{ + for (int i = lo; i <= hi; ++i) (*this)[i] = x; +} + +void FPlex::clear() +{ + if (fnc != lo) + { + hd->clear(lo); + fnc = lo; + } +} + +int FPlex::OK () const +{ + int v = hd != 0; // hd exists + v &= hd->IChunk::OK(); // and is OK + v &= fnc - lo <= hd->size(); // and has enough space + v &= lo <= fnc; // plex indices consistent + v &= lo == hd->low_index(); // and match those + v &= fnc == hd->fence_index(); // of chunk + v &= one_chunk(); // and only one chunk + if (!v) error("invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/gen/FPlex.hP b/gnu/lib/libg++/libg++/src/gen/FPlex.hP new file mode 100644 index 00000000000..03cf96d20ba --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/FPlex.hP @@ -0,0 +1,253 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + +#ifndef _FPlex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _FPlex_h 1 + +#include ".Plex.h" + +class FPlex : public Plex +{ +public: + FPlex(); // set low = 0; + // fence = 0; + // csize = default + + FPlex(int maxsize); // low = 0; + // fence = 0; + // csize = maxsize + + FPlex(int lo, // low = lo; + int maxsize); // fence=lo + // csize = maxsize + + FPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int maxsize = 0); // csize = maxsize + // or fence - lo if 0 + + FPlex(const FPlex&); // X(X&) + + inline ~FPlex(); + + void operator= (const FPlex&); + +// virtuals + + inline & high_element (); + inline & low_element (); + + inline const & high_element () const; + inline const & low_element () const; + + inline Pix first() const; + inline Pix last() const; + inline void prev(Pix& ptr) const; + inline void next(Pix& ptr) const; + inline int owns(Pix p) const; + inline & operator () (Pix p); + inline const & operator () (Pix p) const; + + inline int low() const; + inline int high() const; + inline int valid(int idx) const; + inline void prev(int& idx) const; + inline void next(int& x) const; + inline & operator [] (int index); + inline const & operator [] (int index) const; + + inline int Pix_to_index(Pix p) const; + inline Pix index_to_Pix(int idx) const; + + inline int can_add_high() const; + inline int can_add_low() const; + inline int full() const; + + inline int add_high(const elem); + inline int del_high (); + inline int add_low (const elem); + inline int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + + int OK () const; +}; + + +inline int FPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int FPlex::low() const +{ + return lo; +} + +inline int FPlex::high() const +{ + return fnc - 1; +} + +inline Pix FPlex::first() const +{ + return (Pix)(hd->IChunk::first_pointer()); +} + +inline void FPlex::prev(Pix& p) const +{ + p = Pix(hd->IChunk::pred((*) p)); +} + +inline void FPlex::next(Pix& p) const +{ + p = Pix(hd->IChunk::succ((*) p)); +} + +inline Pix FPlex::last() const +{ + return Pix(hd->IChunk::last_pointer()); +} + +inline int FPlex::full () const +{ + return fnc - lo == csize; +} + +inline void FPlex::prev(int& idx) const +{ + --idx; +} + +inline void FPlex::next(int& idx) const +{ + ++idx; +} + +inline & FPlex:: operator [] (int idx) +{ + if (idx < lo || idx >= fnc) index_error(); + return *(hd->pointer_to(idx)); +} + +inline & FPlex:: operator () (Pix p) +{ + return *((*)p); +} + +inline & FPlex::low_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline & FPlex::high_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(fnc - 1)); +} + +inline const & FPlex:: operator [] (int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + return *(hd->pointer_to(idx)); +} + +inline const & FPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline const & FPlex::low_element () const +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline const & FPlex::high_element () const +{ + if (empty()) index_error(); + return *(hd->pointer_to(fnc - 1)); +} + +inline int FPlex::can_add_high() const +{ + return hd->can_grow_high(); +} + +inline int FPlex::can_add_low() const +{ + return hd->can_grow_low(); +} + +inline int FPlex::add_high(const elem) +{ + if (!can_add_high()) full_error(); + *((hd->IChunk::grow_high())) = elem; + return fnc++; +} + +inline int FPlex::del_high () +{ + if (empty()) empty_error(); + hd->IChunk::shrink_high(); + return --fnc - 1; +} + +inline int FPlex::add_low (const elem) +{ + if (!can_add_low()) full_error(); + *((hd->IChunk::grow_low())) = elem; + return --lo; +} + +inline int FPlex::del_low () +{ + if (empty()) empty_error(); + hd->IChunk::shrink_low(); + return ++lo; +} + +inline int FPlex::owns (Pix p) const +{ + return hd->actual_pointer((*)p); +} + +inline int FPlex::Pix_to_index(Pix p) const +{ + if (!hd->actual_pointer((const *)p)) index_error(); + return hd->index_of((const *)p); +} + +inline Pix FPlex::index_to_Pix(int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + return Pix(hd->pointer_to(idx)); +} + +inline FPlex::~FPlex() {} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/List.ccP b/gnu/lib/libg++/libg++/src/gen/List.ccP new file mode 100644 index 00000000000..f672cf2db63 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/List.ccP @@ -0,0 +1,972 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".List.h" + +ListNode NilListNode; + +class init_NilListNode +{ +public: + init_NilListNode() + { + NilListNode.tl = &NilListNode; + NilListNode.ref = -1; + } +}; + +static init_NilListNode NilListNode_initializer; + +List& List::operator = (const List& a) +{ + reference(a.P); + dereference(P); + P = a.P; + return *this; +} + + List::pop() +{ + res = P->hd; + ListNode* tail = P->tl; + reference(tail); + dereference(P); + P = tail; + return res; +} + +void List::set_tail(List& a) +{ + reference(a.P); + dereference(P->tl); + P->tl = a.P; +} + +List List::nth(int n) +{ + ListNode* p; + for ( p = P; n-- > 0; p = p->tl); + reference(p); + return List(p); +} + +List List::last() +{ + ListNode* p = P; + if (p != &NilListNode) while (p->tl != &NilListNode) p = p->tl; + reference(p); + return List(p); +} + +void List::append(List& l) +{ + ListNode* p = P; + ListNode* a = l.P; + reference(a); + if (p != &NilListNode) + { + while (p->tl != &NilListNode) p = p->tl; + p->tl = a; + } + else + P = a; +} + +int List::length() +{ + int l = 0; + for (ListNode* p = P; p != &NilListNode; p = p->tl) ++l; + return l; +} + +& List::operator [] (int n) +{ + ListNode* p; + for ( p = P; n-- > 0; p = p->tl); + return (p->hd); +} + +int operator == (const List& x, const List& y) +{ + ListNode* a = x.P; + ListNode* b = y.P; + + for (;;) + { + if (a == &NilListNode) + return b == &NilListNode; + else if (b == &NilListNode) + return 0; + else if (EQ(a->hd, b->hd)) + { + a = a->tl; + b = b->tl; + } + else + return 0; + } +} + + +void List::apply(Procedure f) +{ + for(ListNode* p = P; p != &NilListNode; p = p->tl) + (*f)((p->hd)); +} + +void List::subst( old, repl) +{ + for(ListNode* p = P; p != &NilListNode; p = p->tl) + if (EQ(p->hd, old)) + p->hd = repl; +} + + List::reduce(Combiner f, base) +{ + r = base; + for(ListNode* p = P; p != &NilListNode; p = p->tl) + r = (*f)(r, (p->hd)); + return r; +} + +int List::position( targ) +{ + int l = 0; + ListNode* p = P; + for (;;) + { + if (p == &NilListNode) + return -1; + else if (EQ(p->hd, targ)) + return l; + else + { + ++l; + p = p->tl; + } + } +} + +int List::contains( targ) +{ + ListNode* p = P; + for (;;) + { + if (p == &NilListNode) + return 0; + else if (EQ(p->hd, targ)) + return 1; + else + p = p->tl; + } +} + +List List::find( targ) +{ + ListNode* p = P; + while (p != &NilListNode && !EQ(p->hd, targ)) + p=p->tl; + reference(p); + return List(p); +} + +Pix List::seek( targ) const +{ + const ListNode* p = P; + for (;;) + { + if (p == &NilListNode) + return 0; + else if (EQ(p->hd, targ)) + return Pix(p); + else + p = p->tl; + } +} + +int List::owns(Pix i) +{ + ListNode* p = P; + for (;;) + { + if (p == &NilListNode) + return 0; + else if (Pix(p) == i) + return 1; + else + p = p->tl; + } +} + +List List::find(List& target) +{ + ListNode* targ = target.P; + if (targ == &NilListNode) + return List(targ); + + ListNode* p = P; + while (p != &NilListNode) + { + if (EQ(p->hd, targ->hd)) + { + ListNode* a = p->tl; + ListNode* t = targ->tl; + for(;;) + { + if (t == &NilListNode) + { + reference(p); + return List(p); + } + else if (a == &NilListNode || !EQ(a->hd, t->hd)) + break; + else + { + a = a->tl; + t = t->tl; + } + } + } + p = p->tl; + } + return List(&NilListNode); +} + +int List::contains(List& target) +{ + ListNode* targ = target.P; + if (targ == &NilListNode) + return 0; + + ListNode* p = P; + while (p != &NilListNode) + { + if (EQ(p->hd, targ->hd)) + { + ListNode* a = p->tl; + ListNode* t = targ->tl; + for(;;) + { + if (t == &NilListNode) + return 1; + else if (a == &NilListNode || !EQ(a->hd, t->hd)) + break; + else + { + a = a->tl; + t = t->tl; + } + } + } + p = p->tl; + } + return 0; +} + +void List::del( targ) +{ + ListNode* h = P; + // Former bug: targ can be a reference to a element in this list + // So do not dereference a element if targ is the element, + // until targ is no longer needed, as dereferencing it may destroy it. + ListNode* to_be_dereferenced = 0; + + for (;;) + { + if (h == &NilListNode) + { + P = h; + if (to_be_dereferenced) + dereference(to_be_dereferenced); + return; + } + else if (EQ(h->hd, targ)) + { + ListNode* nxt = h->tl; + reference(nxt); + if ((&targ == &h->hd) && (to_be_dereferenced == 0)) + to_be_dereferenced = h; + else + dereference(h); + h = nxt; + } + else + break; + } + + ListNode* trail = h; + ListNode* p = h->tl; + while (p != &NilListNode) + { + if (EQ(p->hd, targ)) + { + ListNode* nxt = p->tl; + reference(nxt); + if ((&targ == &p->hd) && (to_be_dereferenced == 0)) + to_be_dereferenced = p; + else + dereference(p); + trail->tl = nxt; + p = nxt; + } + else + { + trail = p; + p = p->tl; + } + } + P = h; + if (to_be_dereferenced) + dereference(to_be_dereferenced); +} + +void List::del(Predicate f) +{ + ListNode* h = P; + for (;;) + { + if (h == &NilListNode) + { + P = h; + return; + } + else if ((*f)(h->hd)) + { + ListNode* nxt = h->tl; + reference(nxt); + dereference(h); + h = nxt; + } + else + break; + } + + ListNode* trail = h; + ListNode* p = h->tl; + while (p != &NilListNode) + { + if ((*f)(p->hd)) + { + ListNode* nxt = p->tl; + reference(nxt); + dereference(p); + trail->tl = nxt; + p = nxt; + } + else + { + trail = p; + p = p->tl; + } + } + P = h; +} + +void List::select(Predicate f) +{ + ListNode* h = P; + for (;;) + { + if (h == &NilListNode) + { + P = h; + return; + } + else if (!(*f)(h->hd)) + { + ListNode* nxt = h->tl; + reference(nxt); + dereference(h); + h = nxt; + } + else + break; + } + ListNode* trail = h; + ListNode* p = h->tl; + while (p != &NilListNode) + { + if (!(*f)(p->hd)) + { + ListNode* nxt = p->tl; + reference(nxt); + dereference(p); + trail->tl = nxt; + p = nxt; + } + else + { + trail = p; + p = p->tl; + } + } + P = h; +} + +void List::reverse() +{ + ListNode* l = &NilListNode; + ListNode* p = P; + while (p != &NilListNode) + { + ListNode* nxt = p->tl; + p->tl = l; + l = p; + p = nxt; + } + P = l; +} + + +List copy(const List& x) +{ + const ListNode* a = x.P; + if (a == &NilListNode) + return List(&NilListNode); + else + { + ListNode* h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + } + trail->tl = &NilListNode; + return List(h); + } +} + + +List subst( old, repl, List& x) +{ + ListNode* a = x.P; + if (a == &NilListNode) + return List(a); + else + { + ListNode* h = new ListNode; + h->ref = 1; + if (EQ(a->hd, old)) + h->hd = repl; + else + h->hd = a->hd; + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = new ListNode; + n->ref = 1; + if (EQ(a->hd, old)) + n->hd = repl; + else + n->hd = a->hd; + trail->tl = n; + trail = n; + } + trail->tl = &NilListNode; + return List(h); + } +} + +List combine(Combiner f, List& x, List& y) +{ + ListNode* a = x.P; + ListNode* b = y.P; + if (a == &NilListNode || b == &NilListNode) + return List(&NilListNode); + else + { + ListNode* h = newListNode((*f)(a->hd, b->hd)); + ListNode* trail = h; + a = a->tl; + b = b->tl; + while (a != &NilListNode && b != &NilListNode) + { + ListNode* n = newListNode((*f)(a->hd, b->hd)); + trail->tl = n; + trail = n; + a = a->tl; + b = b->tl; + } + trail->tl = &NilListNode; + return List(h); + } +} + +List reverse(List& x) +{ + ListNode* a = x.P; + if (a == &NilListNode) + return List(a); + else + { + ListNode* l = newListNode(a->hd); + l->tl = &NilListNode; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = newListNode(a->hd); + n->tl = l; + l = n; + } + return List(l); + } +} + +List append(List& x, List& y) +{ + ListNode* a = x.P; + ListNode* b = y.P; + reference(b); + if (a != &NilListNode) + { + ListNode* h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + } + trail->tl = b; + return List(h); + } + else + return List(b); +} + +void List::prepend(List& y) +{ + ListNode* b = y.P; + if (b != &NilListNode) + { + ListNode* h = newListNode(b->hd); + ListNode* trail = h; + for(b = b->tl; b != &NilListNode; b = b->tl) + { + ListNode* n = newListNode(b->hd); + trail->tl = n; + trail = n; + } + trail->tl = P; + P = h; + } +} + +List concat(List& x, List& y) +{ + ListNode* a = x.P; + ListNode* b = y.P; + if (a != &NilListNode) + { + ListNode* h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + }; + for(;b != &NilListNode; b = b->tl) + { + ListNode* n = newListNode(b->hd); + trail->tl = n; + trail = n; + } + trail->tl = &NilListNode; + return List(h); + } + else if (b != &NilListNode) + { + ListNode* h = newListNode(b->hd); + ListNode* trail = h; + for(b = b->tl; b != &NilListNode; b = b->tl) + { + ListNode* n = newListNode(b->hd); + trail->tl = n; + trail = n; + } + trail->tl = &NilListNode; + return List(h); + } + else + return List(&NilListNode); +} + +List select(Predicate f, List& x) +{ + ListNode* a = x.P; + ListNode* h = &NilListNode; + while (a != &NilListNode) + { + if ((*f)(a->hd)) + { + h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + if ((*f)(a->hd)) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + } + } + trail->tl = &NilListNode; + break; + } + else + a = a->tl; + } + return List(h); +} + +List remove(Predicate f, List& x) +{ + ListNode* a = x.P; + ListNode* h = &NilListNode; + while (a != &NilListNode) + { + if (!(*f)(a->hd)) + { + h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + if (!(*f)(a->hd)) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + } + } + trail->tl = &NilListNode; + break; + } + else + a = a->tl; + } + return List(h); +} + +List remove( targ, List& x) +{ + ListNode* a = x.P; + ListNode* h = &NilListNode; + while (a != &NilListNode) + { + if (!(EQ(a->hd, targ))) + { + h = newListNode(a->hd); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + if (!EQ(a->hd, targ)) + { + ListNode* n = newListNode(a->hd); + trail->tl = n; + trail = n; + } + } + trail->tl = &NilListNode; + break; + } + else + a = a->tl; + } + return List(h); +} + +List map(Mapper f, List& x) +{ + ListNode* a = x.P; + ListNode* h = &NilListNode; + if (a != &NilListNode) + { + h = newListNode((*f)(a->hd)); + ListNode* trail = h; + for(a = a->tl; a != &NilListNode; a = a->tl) + { + ListNode* n = newListNode((*f)(a->hd)); + trail->tl = n; + trail = n; + } + trail->tl = &NilListNode; + } + return List(h); +} + + +List merge(List& x, List& y, Comparator f) +{ + ListNode* a = x.P; + ListNode* b = y.P; + + if (a == &NilListNode) + { + if (b == &NilListNode) + return List(&NilListNode); + else + return copy(y); + } + else if (b == &NilListNode) + return copy(x); + + ListNode* h = new ListNode; + h->ref = 1; + if ((*f)(a->hd, b->hd) <= 0) + { + h->hd = a->hd; + a = a->tl; + } + else + { + h->hd = b->hd; + b = b->tl; + } + + ListNode* r = h; + + for(;;) + { + if (a == &NilListNode) + { + while (b != &NilListNode) + { + ListNode* n = new ListNode; + n->ref = 1; + n->hd = b->hd; + r->tl = n; + r = n; + b = b->tl; + } + r->tl = &NilListNode; + return List(h); + } + else if (b == &NilListNode) + { + while (a != &NilListNode) + { + ListNode* n = new ListNode; + n->ref = 1; + n->hd = a->hd; + r->tl = n; + r = n; + a = a->tl; + } + r->tl = &NilListNode; + return List(h); + } + else if ((*f)(a->hd, b->hd) <= 0) + { + ListNode* n = new ListNode; + n->ref = 1; + n->hd = a->hd; + r->tl = n; + r = n; + a = a->tl; + } + else + { + ListNode* n = new ListNode; + n->ref = 1; + n->hd = b->hd; + r->tl = n; + r = n; + b = b->tl; + } + } +} + +void List::sort(Comparator f) +{ + // strategy: place runs in queue, merge runs until done + // This is often very fast + + if (P == &NilListNode || P->tl == &NilListNode) + return; + + int qlen = 250; // guess a good queue size, realloc if necessary + + ListNode** queue = (ListNode**)malloc(qlen * sizeof(ListNode*)); + + ListNode* h = P; + ListNode* a = h; + ListNode* b = a->tl; + int qin = 0; + + while (b != &NilListNode) + { + if ((*f)(a->hd, b->hd) > 0) + { + if (h == a) // minor optimization: ensure runlen >= 2 + { + h = b; + a->tl = b->tl; + b->tl = a; + b = a->tl; + } + else + { + if (qin >= qlen) + { + qlen *= 2; + queue = (ListNode**)realloc(queue, qlen * sizeof(ListNode*)); + } + queue[qin++] = h; + a->tl = &NilListNode; + h = a = b; + b = b->tl; + } + } + else + { + a = b; + b = b->tl; + } + } + + int count = qin; + queue[qin] = h; + if (++qin >= qlen) qin = 0; + int qout = 0; + + while (count-- > 0) + { + a = queue[qout]; + if (++qout >= qlen) qout = 0; + b = queue[qout]; + if (++qout >= qlen) qout = 0; + + if ((*f)(a->hd, b->hd) <= 0) + { + h = a; + a = a->tl; + } + else + { + h = b; + b = b->tl; + } + queue[qin] = h; + if (++qin >= qlen) qin = 0; + + for (;;) + { + if (a == &NilListNode) + { + h->tl = b; + break; + } + else if (b == &NilListNode) + { + h->tl = a; + break; + } + else if ((*f)(a->hd, b->hd) <= 0) + { + h->tl = a; + h = a; + a = a->tl; + } + else + { + h->tl = b; + h = b; + b = b->tl; + } + } + } + P = queue[qout]; + free(queue); +} + +int List::list_length() +{ + ListNode* fast = P; + if (fast == &NilListNode) + return 0; + + ListNode* slow = fast->tl; + if (slow == &NilListNode) + return 1; + + fast = slow->tl; + int n = 2; + + for (;;) + { + if (fast == &NilListNode) + return n; + else if (fast->tl == &NilListNode) + return n+1; + else if (fast == slow) + return -1; + else + { + n += 2; + fast = fast->tl->tl; + slow = slow->tl; + } + } +} + +void List::error(const char* msg) +{ + (*lib_error_handler)("List", msg); +} + +int List::OK() +{ + int v = P != 0; // have a node + // check that all nodes OK, even if circular: + + ListNode* fast = P; + if (fast != &NilListNode) + { + v &= fast->ref != 0; + ListNode* slow = fast->tl; + v &= slow->ref != 0; + if (v && slow != &NilListNode) + { + fast = slow->tl; + v &= fast->ref != 0; + while (v) + { + if (fast == &NilListNode) + break; + else if (fast->tl == &NilListNode) + break; + else if (fast == slow) + break; + else + { + v &= fast->ref != 0 && slow->ref != 0; + fast = fast->tl->tl; + slow = slow->tl; + } + } + } + } + if (!v) error ("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/List.hP b/gnu/lib/libg++/libg++/src/gen/List.hP new file mode 100644 index 00000000000..4551e3e47ef --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/List.hP @@ -0,0 +1,279 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _List_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _List_h 1 + +#include +#include ".defs.h" + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)(); +typedef (*Mapper)(); +typedef (*Combiner)(, ); +typedef int (*Predicate)(); +typedef int (*Comparator)(, ); +#endif + +struct ListNode +{ + ListNode* tl; + short ref; + hd; +}; + +extern ListNode NilListNode; + +class List +{ +protected: + ListNode* P; + + List(ListNode* p); +public: + List(); + List( head); + List( head, const List& tl); + List(List& a); + List(Pix p); + ~List(); + + List& operator = (const List& a); + + int null(); + int valid(); + operator const void* (); + int operator ! (); + + int length(); + int list_length(); + + & get(); + & head(); + & operator [] (int n); + + List nth(int n); + List tail(); + List last(); + + List find( targ); + List find(List& targ); + int contains( targ); + int contains(List& targ); + int position( targ); + + friend List copy(const List& a); + friend List concat(List& a, List& b); + friend List append(List& a, List& b); + friend List map(Mapper f, List& a); + friend List merge(List& a, List& b, Comparator f); + friend List combine(Combiner f, List& a, List& b); + friend List reverse(List& a); + friend List select(Predicate f, List& a); +#undef remove + friend List remove( targ, List& a); + friend List remove(Predicate f, List& a); + friend List subst( old, repl, List& a); + + void push( x); + pop(); + + void set_tail(List& p); + void append(List& p); + void prepend(List& p); + void del( targ); + void del(Predicate f); + void select(Predicate f); + void subst( old, repl); + void reverse(); + void sort(Comparator f); + + void apply(Procedure f); + reduce(Combiner f, base); + + friend int operator == (const List& a, const List& b); + friend inline int operator != (const List& a, const List& b); + + Pix first(); + void next(Pix& p); + Pix seek( item) const; + & operator () (Pix p); + const & operator () (Pix p) const; + int owns(Pix p); + + void error(const char*); + int OK(); +}; + + +inline void reference(ListNode* p) +{ + if (p->ref >= 0) ++p->ref; +} + +inline void dereference(ListNode* p) +{ + while (p->ref > 0 && --p->ref == 0) + { + ListNode* n = p->tl; + delete(p); + p = n; + } +} + + +inline ListNode* newListNode(const h) +{ + ListNode* p = new ListNode; + p->ref = 1; + p->hd = h; + return p; +} + +inline ListNode* newListNode( h, ListNode* t) +{ + ListNode* p = new ListNode; + p->ref = 1; + p->hd = h; + p->tl = t; + return p; +} + + +inline List::~List() +{ + dereference(P); +} + +inline List::List() +{ + P = &NilListNode; +} + +inline List::List(ListNode* p) +{ + P = p; +} + +inline List::List( head) +{ + P = newListNode(head); + P->tl = &NilListNode; +} + +inline List::List( head, const List& tl) +{ + P = newListNode(head, tl.P); + reference(P->tl); +} + +inline List::List(List& a) +{ + reference(a.P); + P = a.P; +} + + +inline & List::get() +{ + return P->hd; +} + +inline & List::head() +{ + return P->hd; +} + + +inline List List::tail() +{ + reference(P->tl); + return List(P->tl); +} + + + +inline int List::null() +{ + return P == &NilListNode; +} + +inline int List::valid() +{ + return P != &NilListNode; +} + +inline List::operator const void* () +{ + return (P == &NilListNode)? 0 : this; +} + +inline int List::operator ! () +{ + return (P == &NilListNode); +} + + +inline void List::push( head) +{ + ListNode* oldp = P; + P = newListNode(head, oldp); +} + + +inline int operator != (const List& x, const List& y) +{ + return !(x == y); +} + +inline Pix List::first() +{ + return (P == &NilListNode)? 0 : Pix(P); +} + +inline & List::operator () (Pix p) +{ + return ((ListNode*)p)->hd; +} + +inline const & List::operator () (Pix p) const +{ + return ((const ListNode*)p)->hd; +} + +inline void List::next(Pix& p) +{ + if (p != 0) + { + p = Pix(((ListNode*)p)->tl); + if (p == &NilListNode) p = 0; + } +} + +inline List::List(Pix p) +{ + P = (ListNode*)p; + reference(P); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/MPlex.ccP b/gnu/lib/libg++/libg++/src/gen/MPlex.ccP new file mode 100644 index 00000000000..8c306b5e8a6 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/MPlex.ccP @@ -0,0 +1,848 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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 ".MPlex.h" + +// MChunk support + + +MChunk::MChunk(* d, + int baseidx, + int lowidx, + int fenceidx, + int topidx) + : IChunk(d, baseidx, lowidx, fenceidx, topidx) +{ + unused = fence - low; + unsigned msize = (top - base)/_MAP_BITS + 1; + map = (unsigned long *) (new long[msize]); + memset((void*)map, 0, msize * sizeof(long)); +} + +void MChunk:: shrink_high () +{ + if (fence <= low) empty_error(); + --fence; + if (!valid(fence)) + --unused; + else + free(fence); + reset_high(); +} + +void MChunk:: shrink_low () +{ + if (fence <= low) empty_error(); + if (!valid(low)) + --unused; + else + free(low); + ++low; + reset_low(); +} + +void MChunk::clear(int lo) +{ + int s = top - base; + low = base = fence = lo; + top = base + s; + unused = 0; + memset((void*)map, 0, ((top - base)/_MAP_BITS + 1) * sizeof(long)); +} + +void MChunk::cleardown(int hi) +{ + int s = top - base; + low = top = fence = hi; + base = top - s; + unused = 0; + memset((void*)map, 0, ((top - base)/_MAP_BITS + 1) * sizeof(long)); +} + +int MChunk::del(int idx) +{ + if (idx < low || idx >= fence) index_error(); + int v = valid(idx); + if (v) + { + free(idx); + ++unused; + } + return v; +} + + +int MChunk::undel(int idx) +{ + if (idx < low || idx >= fence) index_error(); + int v = valid(idx); + if (!v) + { + mark(idx); + --unused; + } + return v; +} + +int MChunk::unused_index() const +{ + if (unused_indices() == 0) index_error(); + int slot; + if (low == base) // can traverse 32 slots at a time + { + int blk = 0; + while (map[blk] == ~0UL) ++blk; + slot = blk * _MAP_BITS + base; + } + else + slot = low; + + while(valid(slot)) ++slot; + return slot; +} + +int MChunk::first_index() const +{ + if (empty()) return fence; + int slot; + if (low == base) + { + int blk = 0; + while (map[blk] == 0) ++blk; + slot = blk * _MAP_BITS + base; + } + else + slot = low; + + while(!valid(slot)) ++slot; + return slot; +} + +int MChunk::last_index() const +{ + if (empty()) return low - 1; + int slot; + if (top == fence) + { + int blk = (top - base) / _MAP_BITS; + while (map[blk] == 0) --blk; + slot = blk * _MAP_BITS + base + _MAP_BITS - 1; + } + else + slot = fence - 1; + + while(!valid(slot)) --slot; + return slot; +} + + +int MChunk:: OK() const +{ + int v = data != 0; // have some data + v &= map != 0; // and a map + v &= base <= low; // ok, index-wise + v &= low <= fence; + v &= fence <= top; + + v &= ((MChunk*)(nxt->prev())) == this; // and links are OK + v &= ((MChunk*)(prv->next())) == this; + + int bitcount = 0; // and unused count correct + for (int i = low; i < fence; ++i) if (!valid(i)) ++bitcount; + v &= unused == bitcount; + + if (!v) error("invariant failure"); + return(v); +} + +* MChunk::succ(* p) const +{ + int i = ((int) p - (int) data) / sizeof() + base + 1; + if (p == 0 || i < low) return 0; + while (i < fence && !valid(i)) ++i; + if (i >= fence) return 0; + return pointer_to(i); +} + +* MChunk::pred(* p) const +{ + int i = ((int) p - (int) data) / sizeof() + base - 1; + if (p == 0 || i >= fence) return 0; + while (i >= low && !valid(i)) --i; + if (i < low) return 0; + return pointer_to(i); +} + +* MChunk::first_pointer() const +{ + if (empty()) return 0; + int slot; + if (low == base) + { + int blk = 0; + while (map[blk] == 0) ++blk; + slot = blk * _MAP_BITS + base; + } + else + slot = low; + + while(!valid(slot)) ++slot; + return pointer_to(slot); +} + +* MChunk::last_pointer() const +{ + if (empty()) return 0; + int slot; + if (top == fence) + { + int blk = (top - base) / _MAP_BITS; + while (map[blk] == 0) --blk; + slot = blk * _MAP_BITS + base + _MAP_BITS - 1; + } + else + slot = fence - 1; + + while(!valid(slot)) --slot; + return pointer_to(slot); +} + +MPlex:: MPlex() +{ + unused = 0; + lo = fnc = 0; + csize = DEFAULT_INITIAL_CAPACITY; + * data = new [csize]; + hd = ch = new MChunk(data, lo, lo, fnc, lo+csize); +} + +MPlex:: MPlex(int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + unused = 0; + lo = fnc = 0; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + hd = ch = new MChunk(data, lo, lo, fnc, csize); + } + else + { + csize = -chunksize; + * data = new [csize]; + hd = ch = new MChunk(data, chunksize, lo, fnc, fnc); + } +} + + +MPlex:: MPlex(int l, int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + unused = 0; + lo = fnc = l; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + hd = ch = new MChunk(data, lo, lo, fnc, csize+lo); + } + else + { + csize = -chunksize; + * data = new [csize]; + hd = ch = new MChunk(data, chunksize+lo, lo, fnc, fnc); + } +} + + +void MPlex::make_initial_chunks(int up) +{ + int need = fnc - lo; + hd = 0; + if (up) + { + int l = lo; + do + { + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + MChunk* h = new MChunk(data, l, l, l+sz, l+csize); + if (hd != 0) + h->link_to_next(hd); + else + hd = h; + l += sz; + need -= sz; + } while (need > 0); + } + else + { + int hi = fnc; + do + { + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + MChunk* h = new MChunk(data, hi-csize, hi-sz, hi, hi); + if (hd != 0) + h->link_to_next(hd); + hd = h; + hi -= sz; + need -= sz; + } while (need > 0); + } + ch = (MChunk*) hd; +} + +MPlex:: MPlex(int l, int hi, const initval, int chunksize) +{ + lo = l; + fnc = hi + 1; + if (chunksize == 0) + { + csize = fnc - l; + make_initial_chunks(1); + } + else if (chunksize < 0) + { + csize = -chunksize; + make_initial_chunks(0); + } + else + { + csize = chunksize; + make_initial_chunks(1); + } + unused = fnc - lo; + for (int i=lo; iMPlex::MPlex(const MPlex& a) +{ + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + unused = fnc - lo; + hd = 0; + const IChunk* p = a.hd; + do + { + * data = new [p->size()]; + MChunk* h = new MChunk(data, p->base_index(), + p->low_index(), p->fence_index(), p->top_index()); + if (hd != 0) + h->link_to_next(hd); + else + hd = h; + p = p->next(); + } while (p != a.hd); + ch = (MChunk*) hd; + for (int i = a.low(); i < a.fence(); a.next(i)) + { + undel_index(i); + (*this)[i] = a[i]; + } +} + +void MPlex::operator= (const MPlex& a) +{ + if (&a != this) + { + invalidate(); + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + unused = fnc - lo; + hd = 0; + const IChunk* p = a.hd; + do + { + * data = new [p->size()]; + MChunk* h = new MChunk(data, p->base_index(), + p->low_index(), p->fence_index(), + p->top_index()); + if (hd != 0) + h->link_to_next(hd); + else + hd = h; + p = p->next(); + } while (p != a.hd); + ch = (MChunk*) hd; + for (int i = a.low(); i < a.fence(); a.next(i)) + { + undel_index(i); + (*this)[i] = a[i]; + } + } +} + +int MPlex::valid(int idx) const +{ + const MChunk* tail = (MChunk*)tl(); + const MChunk* t = ch; + while (idx >= t->fence_index()) + { + if (t == tail) return 0; + t = ((MChunk*)(t->next())); + } + while (idx < t->low_index()) + { + if (t == (MChunk*)(hd)) return 0; + t = ((MChunk*)(t->prev())); + } + set_cache(t); + return t->MChunk::valid_index(idx); +} + +void MPlex::cache(int idx) const +{ + const MChunk* tail = (MChunk*)tl(); + const MChunk* t = ch; + while (idx >= t->fence_index()) + { + if (t == tail) index_error(); + t = ((MChunk*)(t->next())); + } + while (idx < t->low_index()) + { + if (t == (MChunk*)hd) index_error(); + t = ((MChunk*)(t->prev())); + } + if (!t->MChunk::valid_index(idx)) index_error(); + set_cache(t); +} + +void MPlex::cache(const * p) const +{ + const MChunk* old = ch; + const MChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = ((MChunk*)(t->next())); + if (t == old) index_error(); + } + if (!t->MChunk::valid_pointer(p)) index_error(); + set_cache(t); +} + +int MPlex::owns(Pix px) const +{ + * p = (*)px; + const MChunk* old = ch; + const MChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = ((MChunk*)(t->next())); + if (t == old) return 0; + } + set_cache(t); + return t->MChunk::valid_pointer(p); +} + +int MPlex::add_high(const elem) +{ + MChunk* t = ((MChunk*) tl()); + + if (!t->can_grow_high()) + { + * data = new [csize]; + t = (new MChunk(data, fnc,fnc,fnc,fnc+csize)); + t->link_to_prev(tl()); + } + + *((t->MChunk::grow_high())) = elem; + set_cache(t); + return fnc++; +} + +int MPlex::add_low (const elem) +{ + MChunk* t = ((MChunk*) hd); + if (!t->can_grow_low()) + { + * data = new [csize]; + hd = new MChunk(data, lo-csize, lo, lo, lo); + hd->link_to_next(t); + t = ((MChunk*) hd); + } + + *((t->MChunk::grow_low())) = elem; + set_cache(t); + return --lo; +} + +void MPlex::adjust_bounds() +{ + MChunk* t = ((MChunk*) tl()); + + // clean up tail + + t->reset_high(); + while (t->MChunk::empty() && !one_chunk()) + { + MChunk* pred = (MChunk*)(t->prev()); + del_chunk(t); + pred->reset_high(); + t = (pred); + } + if (one_chunk()) + t->reset_high(); + + int oldfnc = fnc; + fnc = t->fence_index(); + unused -= oldfnc - fnc; + + // and head.. + t = ((MChunk*) hd); + t->reset_low(); + while (t->MChunk::empty() && !one_chunk()) + { + hd = (MChunk*)(t->next()); + del_chunk(t); + t = ((MChunk*) hd); + t->reset_low(); + } + + int oldlo = lo; + lo = t->low_index(); + unused -= lo - oldlo; + + + set_cache(t); +} + +int MPlex::del_high () +{ + if (empty()) empty_error(); + MChunk* t = ((MChunk*) tl()); + while (t->MChunk::empty() && !one_chunk()) // possible stragglers + { + MChunk* pred = (MChunk*)(t->prev()); + del_chunk(t); + pred->reset_high(); + t = (pred); + } + t->MChunk::shrink_high(); + while (t->MChunk::empty() && !one_chunk()) + { + MChunk* pred = (MChunk*)(t->prev()); + del_chunk(t); + pred->reset_high(); + t = (pred); + } + int oldfnc = fnc; + fnc = t->fence_index(); + unused -= oldfnc - fnc - 1; + set_cache(t); + return fnc - 1; +} + +int MPlex::del_low () +{ + if (empty()) empty_error(); + MChunk* t = ((MChunk*) hd); + while (t->MChunk::empty() && !one_chunk()) + { + hd = (MChunk*)(t->next()); + del_chunk(t); + t = ((MChunk*) hd); + t->reset_low(); + } + t->MChunk::shrink_low(); + while (t->MChunk::empty() && !one_chunk()) + { + hd = (MChunk*)(t->next()); + del_chunk(t); + t = ((MChunk*) hd); + t->reset_low(); + } + int oldlo = lo; + lo = t->low_index(); + unused -= lo - oldlo - 1; + set_cache(t); + return lo; +} + +int MPlex::add(const elem) +{ + if (unused == 0) + return add_high(elem); + + MChunk* t; + for (t = ch; + t->unused_indices() == 0; + t = (MChunk*)(t->prev())) + ; + + int i = t->unused_index(); + set_cache(t); + undel_index(i); + (*this)[i] = elem; + return i; +} + +int MPlex::unused_index() const +{ + if (unused == 0) index_error(); + + MChunk* t; + for (t = ch; + t->unused_indices() == 0; + t = (MChunk*)(t->prev())) + ; + + set_cache(t); + return t->unused_index(); +} + +Pix MPlex::unused_Pix() const +{ + if (unused == 0) return 0; + + MChunk* t; + for (t = ch; + t->unused_indices() == 0; + t = (MChunk*)(t->prev())) + ; + + set_cache(t); + return t->pointer_to(t->unused_index()); +} + +int MPlex::del_index(int idx) +{ + if (idx < lo || idx >= fnc) index_error(); + if (MPlex::valid(idx)) + { + ++unused; + ch->MChunk::del(idx); + return 1; + } + else + return 0; +} + +int MPlex::dopred(int idx) const +{ + + if (idx >= fnc) idx = fnc; + if (idx <= lo) return lo - 1; + + const MChunk* t = ch; + + while (idx > t->fence_index()) + { + t = ((MChunk*)(t->next())); + } + while (idx <= t->low_index()) + { + t = ((MChunk*)(t->prev())); + } + int i = t->MChunk::pred(idx); + while (i < t->low_index() && i >= lo) + { + t = ((MChunk*)(t->prev())); + i = t->MChunk::last_index(); + } + set_cache(t); + return i; +} + + +int MPlex::dosucc(int idx) const +{ + if (idx < lo) idx = lo; + if (idx >= fnc - 1) return fnc; + + const MChunk* t = ch; + while (idx >= t->fence_index()) + { + t = ((MChunk*)(t->next())); + } + while (idx < t->low_index()) + { + t = ((MChunk*)(t->prev())); + } + int i = t->MChunk::succ(idx); + while (i >= t->fence_index() && i < fnc) + { + t = (MChunk*)(t->next()); + i = t->MChunk::first_index(); + } + set_cache(t); + return i; +} + +void MPlex::prev(Pix& i) const +{ + if (i == 0) return; + + * p = (*) i; + const MChunk* old = ch; + const MChunk* t = ch; + + while (!t->actual_pointer(p)) + { + t = ((MChunk*)(t->prev())); + if (t == old) + { + i = 0; + return; + } + } + * q = t->MChunk::pred(p); + while (q == 0 && t != (MChunk*)hd) + { + t = ((MChunk*)(t->prev())); + q = t->MChunk::last_pointer(); + } + + i = Pix(q); + set_cache(t); + return; +} + +void MPlex::next(Pix& i) const +{ + if (i == 0) return; + + * p = (*) i; + const MChunk* tail = (MChunk*)(tl()); + const MChunk* old = ch; + const MChunk* t = ch; + + while (!t->actual_pointer(p)) + { + t = ((MChunk*)(t->next())); + if (t == old) + { + i = 0; + return; + } + } + * q = t->MChunk::succ(p); + while (q == 0 && t != tail) + { + t = ((MChunk*)(t->next())); + q = t->MChunk::first_pointer(); + } + + i = Pix(q); + set_cache(t); + return; +} + + +void MPlex::undel_index(int idx) +{ + if (idx < lo || idx >= fnc) index_error(); + + MChunk* t = ch; + while (idx >= t->fence_index()) + { + t = ((MChunk*)(t->next())); + } + while (idx < t->low_index()) + { + t = ((MChunk*)(t->prev())); + } + int was_present = t->MChunk::undel(idx); + if (!was_present) + { + --unused; + } + set_cache(t); + return; +} + +void MPlex::clear() +{ + if (fnc != lo) + { + MChunk* t = ((MChunk*)tl()); + while (t != hd) + { + MChunk* prv = (MChunk*)(t->prev()); + del_chunk(t); + t = prv; + } + t->MChunk::clear(lo); + set_cache(t); + fnc = lo; + unused = 0; + } +} + +int MPlex::OK () const +{ + int v = hd != 0; // at least one chunk + + int found_ch = 0; // to make sure ch is in list; + + int count = 0; // to count unused slots + + const MChunk* t = (MChunk*)(hd); + + int gap = t->low_index() - lo; + v &= gap == 0; // hd lo not less than lo. + count += gap; + + for (;;) + { + if (t == ch) ++found_ch; + v &= t->MChunk::OK(); // each chunk is OK + count += t->unused_indices(); + if (t == (MChunk*)(tl())) + break; + else // and has indices less than succ + { + gap = t->next()->base_index() - t->top_index(); + v &= gap == 0; + count += gap; + + if (t != (MChunk*)hd) // internal chunks can't grow + v &= !t->can_grow_low() && !t->can_grow_high(); + + t = (const MChunk*)(t->next()); + } + } + gap = fnc - t->fence_index(); + v &= gap == 0; + count += gap; + + v &= count == unused; // chunk counts agree with plex + + v &= found_ch == 1; + if (!v) error("invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/gen/MPlex.hP b/gnu/lib/libg++/libg++/src/gen/MPlex.hP new file mode 100644 index 00000000000..c257f43de5a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/MPlex.hP @@ -0,0 +1,414 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + +#ifndef _MPlex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _MPlex_h 1 + + +#include ".Plex.h" + + +// Number of bits per long, used in MChunk bit map operations + +#define _MAP_BITS 32 + + +class MChunk : public IChunk +{ +protected: + + unsigned long* map; // bitmap of slots + int unused; // number of unused internal slots + + inline void mark(int); // bitmap operations + inline void free(int); + inline int valid(int) const; + +public: + + MChunk(* d, // ptr to array of elements + int base_idx, // initial indices + int low_idx, // & initially clear map + int fence_idx, + int top_idx); + + inline ~MChunk(); + +// virtuals + + int first_index() const; + int last_index() const; + inline int succ(int idx) const; + inline int pred(int idx) const; + * first_pointer() const; + * last_pointer() const; + * succ(*) const; + * pred(*) const; + inline int empty() const; + inline int full() const; + inline int valid_index(int i) const; + inline int valid_pointer(const * p) const; + inline * grow_high (); + inline * grow_low (); + void shrink_high (); + void shrink_low (); + void clear(int); + void cleardown(int); + int OK() const; + +// extensions + + int unused_indices() const; // how many free slot in low..fence? + + int unused_index() const; // return index of free slot + + int del(int i); // delete data indexed by i + // return true if was present + int undel(int idx); // un-delete data indexed by i + // return true if already present + + void reset_low(); // reset low = lowest valid index; + void reset_high(); // same for high + +}; + + +class MPlex: public Plex +{ + MChunk* ch; // cached chunk + int unused; // # of free slots between low & fence + + void make_initial_chunks(int up = 1); + void cache(int idx) const; + void cache(const * p) const; + int dopred(int) const; + int dosucc(int) const; + + void set_cache(const MChunk* t) const; // logically, + // not physically const + +public: + MPlex(); // set low = 0; + // fence = 0; + // csize = default + + MPlex(int ch_size); // low = 0; + // fence = 0; + // csize = ch_size + + MPlex(int lo, // low = lo; + int ch_size); // fence=lo + // csize = ch_size + + MPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int ch_size = 0); // csize= ch_size + // or fence-lo if 0 + + MPlex(const MPlex&); + + void operator= (const MPlex&); + +// virtuals + + inline & high_element (); + inline & low_element (); + inline const & high_element () const; + inline const & low_element () const; + + inline Pix first() const; + inline Pix last() const ; + void prev(Pix& ptr) const; + void next(Pix& ptr) const; + int owns(Pix p) const; + inline & operator () (Pix p); + inline const & operator () (Pix p) const; + + inline int low() const; + inline int high() const; + int valid(int idx) const; + inline void prev(int& idx) const; + inline void next(int& x) const; + inline & operator [] (int index); + inline const & operator [] (int index) const; + + inline int Pix_to_index(Pix p) const; + inline Pix index_to_Pix(int idx) const; + + inline int can_add_high() const; + inline int can_add_low() const; + inline int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + void clear(); + + int OK () const; + +// extensions + + int count() const; // # valid elements + int available() const; // # deleted elements + + int unused_index()const; // return index of a deleted elem + Pix unused_Pix() const; // return Pix of a deleted elem + + int del_index(int idx); // logically delete at idx; + // return true if was present + int del_Pix(Pix p); // delete at p + + void undel_index(int idx); // undelete at idx; + void undel_Pix(Pix p); // undelete at p; + + void adjust_bounds(); // reset lo, hi to lowest & + // highest valid indices + + int add(const elem); // add anywhere +}; + + +inline MChunk:: ~MChunk() +{ + delete map; +} + +inline void MChunk::mark(int idx) +{ + unsigned int i = idx - base; + map[i / _MAP_BITS] |= 1 << (i & (_MAP_BITS - 1)); +} + +inline void MChunk::free(int idx) +{ + unsigned int i = idx - base; + map[i / _MAP_BITS] &= ~(1 << (i & (_MAP_BITS - 1))); +} + +inline int MChunk::valid(int idx) const +{ + unsigned int i = idx - base; + return map[i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1))); +} + +inline int MChunk:: valid_index(int i) const +{ + return i >= low && i < fence && valid(i); +} + +inline int MChunk:: valid_pointer(const * p) const +{ + int i = ((int)p - (int)data) / sizeof(); + return i >= 0 && i < (fence - base) && + (map[(unsigned)i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1)))); +} + +inline int MChunk::empty() const +{ + return fence - low - unused == 0; +} + +inline int MChunk::full() const +{ + return unused + (top - fence) + (low - base) == 0; +} + +inline int MChunk::succ(int idx) const +{ + int i = (idx < low)? low : idx + 1; + while (i < fence && !valid(i)) ++i; + return i; +} + +inline int MChunk::pred(int idx) const +{ + int i = (idx > fence)? (fence - 1) : idx - 1; + while (i >= low && !valid(i)) --i; + return i; +} + +inline int MChunk::unused_indices() const +{ + return unused; +} + +inline * MChunk:: grow_high () +{ + if (!can_grow_high()) full_error(); + mark(fence); + return &(data[fence++ - base]); +} + +inline * MChunk:: grow_low () +{ + if (!can_grow_low()) full_error(); + mark(--low); + return &(data[low - base]); +} + +inline void MChunk::reset_low() +{ + while (low < fence && !valid(low)) + { + --unused; + ++low; + } +} + +inline void MChunk::reset_high() +{ + while (fence > low && !valid(fence - 1)) + { + --unused; + --fence; + } +} + +inline int MPlex::full () const +{ + return 0; +} + +inline int MPlex::can_add_high() const +{ + return 1; +} + +inline int MPlex::can_add_low() const +{ + return 1; +} + +inline int MPlex::available() const +{ + return unused; +} + +inline int MPlex::count() const +{ + return fnc - lo - unused; +} + +inline void MPlex::set_cache(const MChunk* t) const +{ + ((MPlex*)(this))->ch = (MChunk*)t; +} + +inline & MPlex:: operator [] (int idx) +{ + if (!ch->MChunk::valid_index(idx)) cache(idx); + return * (ch->pointer_to(idx)); +} + +inline const & MPlex:: operator [] (int idx) const +{ + if (!ch->MChunk::valid_index(idx)) cache(idx); + return * ((const *)(ch->pointer_to(idx))); +} + +inline int MPlex::Pix_to_index(Pix p) const +{ + if (!ch->MChunk::valid_pointer((*)p)) cache((*)p); + return ch->index_of((*)p); +} + +inline int MPlex::high() const +{ + return (((const MChunk*)tl())->MChunk::valid_index(fnc-1)) ? + fnc-1 : dopred(fnc-1); +} + +inline int MPlex::low() const +{ + return (((const MChunk*)hd)->MChunk::valid_index(lo))? lo : dosucc(lo); +} + +inline & MPlex::low_element () +{ + return (*this)[low()]; +} + +inline const & MPlex::low_element () const +{ + return (*this)[low()]; +} + +inline & MPlex::high_element () +{ + return (*this)[high()]; +} + +inline const & MPlex::high_element () const +{ + return (*this)[high()]; +} + +inline Pix MPlex::index_to_Pix(int idx) const +{ + if (!ch->MChunk::valid_index(idx)) cache(idx); + return Pix(ch->pointer_to(idx)); +} + +inline void MPlex::next(int& idx) const +{ + idx = (ch->MChunk::valid_index(idx+1))? idx+1 : dosucc(idx); +} + +inline void MPlex::prev(int& idx) const +{ + idx = (ch->MChunk::valid_index(idx-1))? idx-1 : dopred(idx); +} + +inline Pix MPlex::first() const +{ + return index_to_Pix(low()); +} + +inline Pix MPlex::last() const +{ + return index_to_Pix(high()); +} + + +inline void MPlex::undel_Pix(Pix p) +{ + undel_index(Pix_to_index(p)); +} + +inline int MPlex::del_Pix(Pix p) +{ + return del_index(Pix_to_index(p)); +} + +inline & MPlex:: operator () (Pix p) +{ + return *((*)p); +} + +inline const & MPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Map.ccP b/gnu/lib/libg++/libg++/src/gen/Map.ccP new file mode 100644 index 00000000000..146a2d2b2a9 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Map.ccP @@ -0,0 +1,59 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include "..Map.h" + + +Pix Map::seek( item) +{ + Pix i; + for (i = first(); i != 0 && !(EQ(key(i), item)); next(i)); + return i; +} + +int Map::owns(Pix idx) +{ + if (idx == 0) return 0; + for (Pix i = first(); i; next(i)) if (i == idx) return 1; + return 0; +} + +void Map::clear() +{ + Pix i = first(); + while (i != 0) + { + del(key(i)); + i = first(); + } +} + +int Map::contains ( item) +{ + return seek(item) != 0; +} + + +void Map::error(const char* msg) +{ + (*lib_error_handler)("Map", msg); +} diff --git a/gnu/lib/libg++/libg++/src/gen/Map.hP b/gnu/lib/libg++/libg++/src/gen/Map.hP new file mode 100644 index 00000000000..13a3fb14518 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Map.hP @@ -0,0 +1,87 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Map_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Map_h 1 + +#include +#include ".defs.h" + +class Map +{ +protected: + int count; + def; + +public: + Map( dflt); + inline virtual ~Map(); + + int length() const; // current number of items + int empty() const; + + virtual int contains( key); // is key mapped? + + virtual void clear(); // delete all items + + virtual & operator [] ( key) = 0; // access contents by key + + virtual void del( key) = 0; // delete entry + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual & key(Pix i) = 0; // access key at i + virtual & contents(Pix i) = 0; // access contents at i + + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek( key); // Pix of key + + & dflt(); // access default val + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + + +inline Map::~Map() {} + +inline int Map::length() const +{ + return count; +} + +inline int Map::empty() const +{ + return count == 0; +} + +inline & Map::dflt() +{ + return def; +} + +inline Map::Map( dflt) :def(dflt) +{ + count = 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/OSLBag.ccP b/gnu/lib/libg++/libg++/src/gen/OSLBag.ccP new file mode 100644 index 00000000000..285c2cfd000 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OSLBag.ccP @@ -0,0 +1,196 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".OSLBag.h" + + +Pix OSLBag::seek( item, Pix i) +{ + if (i == 0) i = p.first(); else next(i); + for (; i != 0; p.next(i)) + { + int cmp = CMP(item, p(i)); + if (cmp == 0) + return i; + else if (cmp < 0) + return 0; + } + return 0; +} + +int OSLBag::nof( item) +{ + int n = 0; + for (Pix i = p.first(); i != 0; p.next(i)) + { + int cmp = CMP(item, p(i)); + if (cmp == 0) + ++n; + else if (cmp < 0) + break; + } + return n; +} + +Pix OSLBag::add( item) +{ + Pix i = p.first(); + if (i == 0) + { + ++count; + return p.prepend(item); + } + int cmp = CMP(item, p(i)); + if (cmp <= 0) + { + ++count; + return p.prepend(item); + } + else + { + Pix trail = i; + p.next(i); + for (;;) + { + if (i == 0) + { + ++count; + return p.append(item); + } + cmp = CMP(item, p(i)); + if (cmp <= 0) + { + ++count; + return p.ins_after(trail, item); + } + else + { + trail = i; + p.next(i); + } + } + } +} + +void OSLBag::del( item) +{ + Pix i = p.first(); + if (i == 0) + return; + int cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + --count; + p.del_front(); + } + else + { + Pix trail = i; + p.next(i); + while (i != 0) + { + cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + --count; + p.del_after(trail); + return; + } + else + { + trail = i; + p.next(i); + } + } + } +} + +void OSLBag::remove( item) +{ + Pix i = p.first(); + if (i == 0) + return; + int cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + do + { + --count; + p.del_front(); + i = p.first(); + } while (i != 0 && EQ(item, p(i))); + } + else + { + Pix trail = i; + p.next(i); + while (i != 0) + { + cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + do + { + --count; + p.del_after(trail); + i = trail; + next(i); + } while (i != 0 && EQ(item, p(i))); + return; + } + else + { + trail = i; + p.next(i); + } + } + } +} + +int OSLBag::OK() +{ + int v = p.OK(); + v &= count == p.length(); + Pix trail = p.first(); + if (trail == 0) + v &= count == 0; + else + { + Pix i = trail; next(i); + while (i != 0) + { + v &= CMP(p(trail), p(i)) <= 0; + trail = i; + next(i); + } + } + if (!v) error("invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/gen/OSLBag.hP b/gnu/lib/libg++/libg++/src/gen/OSLBag.hP new file mode 100644 index 00000000000..5a657f0f3a1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OSLBag.hP @@ -0,0 +1,91 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _OSLBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _OSLBag_h 1 + +#include ".Bag.h" +#include ".SLList.h" + +class OSLBag : public Bag +{ +protected: + SLList p; + +public: + OSLBag(); + OSLBag(const OSLBag&); + + Pix add( item); + void del( item); + void remove(item); + + inline int contains( item); + int nof( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +inline OSLBag::OSLBag() : p() { count = 0; } + +inline OSLBag::OSLBag(const OSLBag& s) : p(s.p) { count = s.count; } + +inline Pix OSLBag::first() +{ + return p.first(); +} + +inline void OSLBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & OSLBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OSLBag::clear() +{ + count = 0; p.clear(); +} + +inline int OSLBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OSLBag::contains( item) +{ + return seek(item) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/OSLSet.ccP b/gnu/lib/libg++/libg++/src/gen/OSLSet.ccP new file mode 100644 index 00000000000..937d915a96b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OSLSet.ccP @@ -0,0 +1,321 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".OSLSet.h" + + +Pix OSLSet::seek( item) +{ + for (Pix i = p.first(); i != 0; p.next(i)) + { + int cmp = CMP(item, p(i)); + if (cmp == 0) + return i; + else if (cmp < 0) + return 0; + } + return 0; +} + +Pix OSLSet::add( item) +{ + Pix i = p.first(); + if (i == 0) + { + ++count; + return p.prepend(item); + } + int cmp = CMP(item, p(i)); + if (cmp == 0) + return i; + else if (cmp < 0) + { + ++count; + return p.prepend(item); + } + else + { + Pix trail = i; + p.next(i); + for (;;) + { + if (i == 0) + { + ++count; + return p.append(item); + } + cmp = CMP(item, p(i)); + if (cmp == 0) + return i; + else if (cmp < 0) + { + ++count; + return p.ins_after(trail, item); + } + else + { + trail = i; + p.next(i); + } + } + } +} + +void OSLSet::del( item) +{ + Pix i = p.first(); + if (i == 0) + return; + int cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + --count; + p.del_front(); + } + else + { + Pix trail = i; + p.next(i); + while (i != 0) + { + cmp = CMP(item, p(i)); + if (cmp < 0) + return; + else if (cmp == 0) + { + --count; + p.del_after(trail); + return; + } + else + { + trail = i; + p.next(i); + } + } + } +} + + +int OSLSet::operator <= (OSLSet& b) +{ + if (count > b.count) return 0; + Pix i = first(); + Pix j = b.first(); + for (;;) + { + if (i == 0) + return 1; + else if (j == 0) + return 0; + int cmp = CMP(p(i), b.p(j)); + if (cmp == 0) + { + next(i); b.next(j); + } + else if (cmp < 0) + return 0; + else + b.next(j); + } +} + +int OSLSet::operator == (OSLSet& b) +{ + if (count != b.count) return 0; + if (count == 0) return 1; + Pix i = p.first(); + Pix j = b.p.first(); + while (i != 0) + { + if (!EQ(p(i),b.p(j))) return 0; + next(i); + b.next(j); + } + return 1; +} + + +void OSLSet::operator |= (OSLSet& b) +{ + if (&b == this || b.count == 0) + return; + else + { + Pix j = b.p.first(); + Pix i = p.first(); + Pix trail = 0; + for (;;) + { + if (j == 0) + return; + else if (i == 0) + { + for (; j != 0; b.next(j)) + { + ++count; + p.append(b.p(j)); + } + return; + } + int cmp = CMP(p(i), b.p(j)); + if (cmp <= 0) + { + if (cmp == 0) b.next(j); + trail = i; + next(i); + } + else + { + ++count; + if (trail == 0) + trail = p.prepend(b.p(j)); + else + trail = p.ins_after(trail, b.p(j)); + b.next(j); + } + } + } +} + + +void OSLSet::operator -= (OSLSet& b) +{ + if (&b == this) + clear(); + else if (count != 0 && b.count != 0) + { + Pix i = p.first(); + Pix j = b.p.first(); + Pix trail = 0; + for (;;) + { + if (j == 0 || i == 0) + return; + int cmp = CMP(p(i), b.p(j)); + if (cmp == 0) + { + --count; + b.next(j); + if (trail == 0) + { + p.del_front(); + i = p.first(); + } + else + { + next(i); + p.del_after(trail); + } + } + else if (cmp < 0) + { + trail = i; + next(i); + } + else + b.next(j); + } + } +} + +void OSLSet::operator &= (OSLSet& b) +{ + if (b.count == 0) + clear(); + else if (&b != this && count != 0) + { + Pix i = p.first(); + Pix j = b.p.first(); + Pix trail = 0; + for (;;) + { + if (i == 0) + return; + else if (j == 0) + { + if (trail == 0) + { + p.clear(); + count = 0; + } + else + { + while (i != 0) + { + --count; + next(i); + p.del_after(trail); + } + } + return; + } + int cmp = CMP(p(i), b.p(j)); + + if (cmp == 0) + { + trail = i; + next(i); + b.next(j); + } + else if (cmp < 0) + { + --count; + if (trail == 0) + { + p.del_front(); + i = p.first(); + } + else + { + next(i); + p.del_after(trail); + } + } + else + b.next(j); + } + } +} + + +int OSLSet::OK() +{ + int v = p.OK(); + v &= count == p.length(); + Pix trail = p.first(); + if (trail == 0) + v &= count == 0; + else + { + Pix i = trail; next(i); + while (i != 0) + { + v &= CMP(p(trail), p(i)) < 0; + trail = i; + next(i); + } + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/OSLSet.hP b/gnu/lib/libg++/libg++/src/gen/OSLSet.hP new file mode 100644 index 00000000000..02ace589cba --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OSLSet.hP @@ -0,0 +1,101 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _OSLSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _OSLSet_h 1 + +#include ".Set.h" +#include ".SLList.h" + +class OSLSet : public Set +{ +protected: + SLList p; + +public: + OSLSet(); + OSLSet(const OSLSet&); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item); + + void operator |= (OSLSet& b); + void operator -= (OSLSet& b); + void operator &= (OSLSet& b); + + int operator == (OSLSet& b); + int operator != (OSLSet& b); + int operator <= (OSLSet& b); + + int OK(); +}; + + +inline OSLSet::OSLSet() : p() { count = 0; } + +inline OSLSet::OSLSet(const OSLSet& s) : p(s.p) { count = s.count; } + +inline Pix OSLSet::first() +{ + return p.first(); +} + +inline void OSLSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & OSLSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OSLSet::clear() +{ + count = 0; p.clear(); +} + +inline int OSLSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int OSLSet::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OSLSet::operator != (OSLSet& b) +{ + return !(*this == b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/OXPBag.ccP b/gnu/lib/libg++/libg++/src/gen/OXPBag.ccP new file mode 100644 index 00000000000..b81c3a0a373 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OXPBag.ccP @@ -0,0 +1,221 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".OXPBag.h" + + +Pix OXPBag::seek( item, Pix i) +{ + if (i == 0) + { + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + while (mid > p.low() && EQ(item, p[mid - 1])) --mid; + return p.index_to_Pix(mid); + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + return 0; + } + int cmp = CMP(item, p(i)); + if (cmp == 0) + { + next(i); + return (EQ(item, p(i)))? i : 0; + } + else if (cmp < 0) + { + int ind = p.Pix_to_index(i); + int l = ind; + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + cmp = CMP(item, p[mid]); + if (cmp == 0) + { + while (mid > ind && EQ(item, p[mid - 1])) --mid; + return p.index_to_Pix(mid); + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + return 0; + } + else + return 0; +} + +int OXPBag::nof( item) +{ + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + l = h = mid; + while (l > p.low() && EQ(item, p[l - 1])) --l; + while (h < p.high() && EQ(item, p[h + 1])) ++h; + return h - l + 1; + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + return 0; +} + +Pix OXPBag::add( item) +{ + if (count == 0) + { + ++count; + return p.index_to_Pix(p.add_high(item)); + } + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + l = mid; + break; + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + // add on whichever side is shortest + ++count; + if (l == p.fence()) + return p.index_to_Pix(p.add_high(item)); + else if (l == p.low()) + return p.index_to_Pix(p.add_low(item)); + else + { + if (p.high() - l < l - p.low()) + { + h = p.add_high(p.high_element()); + for (int i = h - 1; i > l; --i) p[i] = p[i-1]; + } + else + { + --l; + h = p.add_low(p.low_element()); + for (int i = h + 1; i < l; ++i) p[i] = p[i+1]; + } + p[l] = item; + return p.index_to_Pix(l); + } +} + +void OXPBag::del( item) +{ + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + --count; + if (p.high() - mid < mid - p.low()) + { + for (int i = mid; i < p.high(); ++i) p[i] = p[i+1]; + p.del_high(); + } + else + { + for (int i = mid; i > p.low(); --i) p[i] = p[i-1]; + p.del_low(); + } + return; + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } +} + +void OXPBag::remove( item) +{ + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + l = h = mid; + while (l > p.low() && EQ(item, p[l - 1])) --l; + while (h < p.high() && EQ(item, p[h + 1])) ++h; + int n = h - l + 1; + count -= n; + if (p.high() - h < l - p.low()) + { + h = p.high() - n; + for (int i = l; i <= h; ++i) p[i] = p[i+n]; + while (n-- > 0) p.del_high(); + } + else + { + l = p.low() + n; + for (int i = h; i >= l; --i) p[i] = p[i-n]; + while (n-- > 0) p.del_low(); + } + return; + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } +} + +int OXPBag::OK() +{ + int v = p.OK(); + v &= count == p.length(); + for (int i = p.low(); i < p.high(); ++i) v &= CMP(p[i], p[i+1]) <= 0; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/OXPBag.hP b/gnu/lib/libg++/libg++/src/gen/OXPBag.hP new file mode 100644 index 00000000000..c7a25141415 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OXPBag.hP @@ -0,0 +1,73 @@ +#ifndef _OXPBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _OXPBag_h 1 + +#include ".Bag.h" +#include ".XPlex.h" + +class OXPBag : public Bag +{ +protected: + XPlex p; + +public: + OXPBag(int chunksize = DEFAULT_INITIAL_CAPACITY); + OXPBag(const OXPBag&); + + Pix add( item); + void del( item); +#undef remove + void remove(item); + int nof( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +inline OXPBag::OXPBag(int chunksize) + : p(chunksize) { count = 0; } + +inline OXPBag::OXPBag(const OXPBag& s) : p(s.p) { count = s.count; } + +inline Pix OXPBag::first() +{ + return p.first(); +} + +inline void OXPBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & OXPBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OXPBag::clear() +{ + count = 0; p.clear(); +} + +inline int OXPBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OXPBag::contains( item) +{ + return seek(item) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/OXPSet.ccP b/gnu/lib/libg++/libg++/src/gen/OXPSet.ccP new file mode 100644 index 00000000000..397c2c986a2 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OXPSet.ccP @@ -0,0 +1,280 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".OXPSet.h" + + +Pix OXPSet::seek( item) +{ + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + return p.index_to_Pix(mid); + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + return 0; +} + +Pix OXPSet::add( item) +{ + if (count == 0) + { + ++count; + return p.index_to_Pix(p.add_high(item)); + } + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + return p.index_to_Pix(mid); + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } + // add on whichever side is shortest + ++count; + if (l == p.fence()) + return p.index_to_Pix(p.add_high(item)); + else if (l == p.low()) + return p.index_to_Pix(p.add_low(item)); + else + { + if (p.fence() - l < l - p.low()) + { + h = p.add_high(p.high_element()); + for (int i = h - 1; i > l; --i) p[i] = p[i-1]; + } + else + { + --l; + h = p.add_low(p.low_element()); + for (int i = h + 1; i < l; ++i) p[i] = p[i+1]; + } + p[l] = item; + return p.index_to_Pix(l); + } +} + +void OXPSet::del( item) +{ + int l = p.low(); + int h = p.high(); + while (l <= h) + { + int mid = (l + h) / 2; + int cmp = CMP(item, p[mid]); + if (cmp == 0) + { + --count; + if (p.high() - mid < mid - p.low()) + { + for (int i = mid; i < p.high(); ++i) p[i] = p[i+1]; + p.del_high(); + } + else + { + for (int i = mid; i > p.low(); --i) p[i] = p[i-1]; + p.del_low(); + } + return; + } + else if (cmp < 0) + h = mid - 1; + else + l = mid + 1; + } +} + +int OXPSet::operator <= (OXPSet& b) +{ + if (count > b.count) return 0; + int i = p.low(); + int j = b.p.low(); + for (;;) + { + if (i >= p.fence()) + return 1; + else if (j >= b.p.fence()) + return 0; + int cmp = CMP(p[i], b.p[j]); + if (cmp == 0) + { + ++i; ++j; + } + else if (cmp < 0) + return 0; + else + ++j; + } +} + +int OXPSet::operator == (OXPSet& b) +{ + int n = count; + if (n != b.count) return 0; + if (n == 0) return 1; + int i = p.low(); + int j = b.p.low(); + while (n-- > 0) if (!EQ(p[i++], b.p[j++])) return 0; + return 1; +} + + +void OXPSet::operator |= (OXPSet& b) +{ + if (&b == this || b.count == 0) + return; + else if (b.count <= 2) // small b -- just add + for (Pix i = b.first(); i; b.next(i)) add(b(i)); + else + { + // strategy: merge into top of p, simultaneously killing old bottom + int oldfence = p.fence(); + int i = p.low(); + int j = b.p.low(); + for (;;) + { + if (i == oldfence) + { + while (j < b.p.fence()) p.add_high(b.p[j++]); + break; + } + else if (j == b.p.fence()) + { + while (i++ < oldfence) + { + p.add_high(p.low_element()); + p.del_low(); + } + break; + } + int cmp = CMP(p[i], b.p[j]); + if (cmp <= 0) + { + ++i; + if (cmp == 0) ++j; + p.add_high(p.low_element()); + p.del_low(); + } + else + p.add_high(b.p[j++]); + } + count = p.length(); + } +} + + + +void OXPSet::operator -= (OXPSet& b) +{ + if (&b == this) + clear(); + else if (count != 0 && b.count != 0) + { + int i = p.low(); + int k = i; + int j = b.p.low(); + int oldfence = p.fence(); + for (;;) + { + if (i >= oldfence) + break; + else if (j >= b.p.fence()) + { + if (k != i) + while (i < oldfence) p[k++] = p[i++]; + else + k = oldfence; + break; + } + int cmp = CMP(p[i], b.p[j]); + if (cmp == 0) + { + ++i; ++j; + } + else if (cmp < 0) + { + if (k != i) p[k] = p[i]; + ++i; ++k; + } + else + j++; + } + while (k++ < oldfence) + { + --count; + p.del_high(); + } + } +} + +void OXPSet::operator &= (OXPSet& b) +{ + if (b.count == 0) + clear(); + else if (&b != this && count != 0) + { + int i = p.low(); + int k = i; + int j = b.p.low(); + int oldfence = p.fence(); + for (;;) + { + if (i >= oldfence || j >= b.p.fence()) + break; + int cmp = CMP(p[i], b.p[j]); + if (cmp == 0) + { + if (k != i) p[k] = p[i]; + ++i; ++k; ++j; + } + else if (cmp < 0) + ++i; + else + ++j; + } + while (k++ < oldfence) + { + --count; + p.del_high(); + } + } +} + +int OXPSet::OK() +{ + int v = p.OK(); + v &= count == p.length(); + for (int i = p.low(); i < p.high(); ++i) v &= CMP(p[i], p[i+1]) < 0; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/OXPSet.hP b/gnu/lib/libg++/libg++/src/gen/OXPSet.hP new file mode 100644 index 00000000000..cfa0f156fb9 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/OXPSet.hP @@ -0,0 +1,102 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _OXPSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _OXPSet_h 1 + +#include ".Set.h" +#include ".XPlex.h" + +class OXPSet : public Set +{ +protected: + XPlex p; + +public: + OXPSet(int chunksize = DEFAULT_INITIAL_CAPACITY); + OXPSet(const OXPSet&); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item); + + void operator |= (OXPSet& b); + void operator -= (OXPSet& b); + void operator &= (OXPSet& b); + + int operator == (OXPSet& b); + int operator != (OXPSet& b); + int operator <= (OXPSet& b); + + int OK(); +}; + + +inline OXPSet::OXPSet(int chunksize) + : p(chunksize) { count = 0; } + +inline OXPSet::OXPSet(const OXPSet& s) : p(s.p) { count = s.count; } + +inline Pix OXPSet::first() +{ + return p.first(); +} + +inline void OXPSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & OXPSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OXPSet::clear() +{ + count = 0; p.clear(); +} + +inline int OXPSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int OXPSet::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OXPSet::operator != (OXPSet& b) +{ + return !(*this == b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/PHPQ.ccP b/gnu/lib/libg++/libg++/src/gen/PHPQ.ccP new file mode 100644 index 00000000000..ae8cde6cd07 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PHPQ.ccP @@ -0,0 +1,339 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.edu) + adapted for libg++ 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 +#include ".PHPQ.h" + +// +// This defines a Pairing Heap structure +// +// See ``The Pairing Heap: A New Form of Self-Adjusting Heap'' +// Fredman, Segdewick et al, +// Algorithmica (1986) 1:111-129 +// +// In particular, this implements the pairing heap using the circular +// list. +// +// + +PHPQ::PHPQ(int sz) +{ + storage = 0; + root = 0; + count = 0; + size = 0; + prealloc(sz); +} + +PHPQ::PHPQ(PHPQ& a) +{ + storage = 0; + root = 0; + count = 0; + size = 0; + prealloc(a.size); + for (Pix i = a.first(); i != 0; a.next(i)) enq(a(i)); +} + + +void PHPQ::prealloc(int newsize) +{ + ++newsize; // leave a spot for freelist + if (size != 0) + { + int news = size; + while (news <= newsize) news = (news * 3) / 2; + newsize = news; + } + // see if indices are OK + PHPQNode test; + test.sibling = 0; + test.sibling = ~test.sibling; + if ((unsigned long)newsize > (unsigned long)(test.sibling)) + error("storage size exceeds index range"); + + if (storage == 0) + { + storage = new PHPQNode[size = newsize]; + for (int i = 0; i < size; ++i) + { + storage[i].sibling = i + 1; + storage[i].valid = 0; + } + storage[size-1].sibling = 0; + } + else + { + PHPQNode* newstor = new PHPQNode[newsize]; + for (int i = 1; i < size; ++i) + newstor[i] = storage[i]; + delete [] storage; + storage = newstor; + for (int i = size; i < newsize; ++i) + { + storage[i].sibling = i + 1; + storage[i].valid = 0; + } + storage[newsize-1].sibling = 0; + storage[0].sibling = size; + size = newsize; + } +} + + +void PHPQ::clear() +{ + for (int i = 0; i < size; ++i) + { + storage[i].sibling = i + 1; + storage[i].valid = 0; + } + storage[size-1].sibling = 0; + root = 0; + count = 0; +} + +Pix PHPQ::enq( item) +{ + ++count; + if (storage[0].sibling == 0) + prealloc(count); + + int cell = storage[0].sibling; + storage[0].sibling = storage[cell].sibling; + storage[cell].sibling = 0; + storage[cell].children = 0; + storage[cell].item = item; + storage[cell].valid = 1; + + if (root == 0) + { + root = cell; + return Pix(root); + } + else + { + int parent; + int child; + + if (LE(storage[root].item, storage[cell].item)) + { + parent = root; child = cell; + } + else + { + parent = cell; child = root; + } + int popsKid = storage[parent].children; + + if (popsKid == 0) + { + storage[parent].children = child; + storage[child].sibling = child; + } + else + { + int temp = storage[popsKid].sibling; + storage[popsKid].sibling = child; + storage[child].sibling = temp; + storage[parent].children = child; + } + root = parent; + return Pix(cell); + } +} + +// +// Item removal is the most complicated routine. +// +// We remove the root (should there be one) and then select a new +// root. The siblings of the root are in a circular list. We continue +// to pair elements in this list until there is a single element. +// This element will be the new root. + +void PHPQ::del_front() +{ + int valid = 0; + do + { + if (root == 0) return; + if ((valid = storage[root].valid)) + --count; + storage[root].valid = 0; + int child = storage[root].children; + storage[root].sibling = storage[0].sibling; + storage[0].sibling = root; + + if (child == 0) + { + root = 0; + return; + } + else + { + while(storage[child].sibling != child) + { + // We have at least two kids, but we may only have + // two kids. So, oneChild != child, but it is possible + // that twoChild == child. + + int oneChild = storage[child].sibling; + int twoChild = storage[oneChild].sibling; + + // Remove the two from the sibling list + + storage[child].sibling = storage[twoChild].sibling; + storage[oneChild].sibling = 0; + storage[twoChild].sibling = 0; + + int bestChild; + int worstChild; + + if (LE(storage[oneChild].item, storage[twoChild].item)) + { + bestChild = oneChild; worstChild = twoChild; + } + else + { + bestChild = twoChild; worstChild = oneChild; + } + int popsKid = storage[bestChild].children; + + if (popsKid == 0) + { + storage[bestChild].children = worstChild; + storage[worstChild].sibling = worstChild; + } + else + { + int temp = storage[popsKid].sibling; + storage[popsKid].sibling = worstChild; + storage[worstChild].sibling = temp; + storage[bestChild].children = worstChild; + } + if (twoChild == child) + { + // We have reduced the two to one, so we'll be exiting. + child = bestChild; + storage[child].sibling = child; + } + else + { + // We've removed two siblings, now we need to insert + // the better of the two + storage[bestChild].sibling = storage[child].sibling; + storage[child].sibling = bestChild; + child = storage[bestChild].sibling; + } + } + root = child; + } + } while ( !valid ); +} + +void PHPQ::del(Pix p) +{ + if (p == 0) error("null Pix"); + int i = int(p); + if (storage[i].valid) + { + if (i == root) + del_front(); + else + { + storage[i].valid = 0; + --count; + } + } +} + + +Pix PHPQ::seek( key) +{ + for (int i = 1; i < size; ++i) + if (storage[i].valid && EQ(storage[i].item, key)) + return Pix(i); + return 0; +} + +Pix PHPQ::first() +{ + for (int i = 1; i < size; ++i) + if (storage[i].valid) + return Pix(i); + return 0; +} + + +void PHPQ::next(Pix& p) +{ + if (p == 0) return; + for (int i = int(p)+1; i < size; ++i) + if (storage[i].valid) + { + p = Pix(i); + return; + } + p = 0; +} + +int PHPQ::OK() +{ + int v = storage != 0; + int n = 0; + for (int i = 0; i < size; ++i) if (storage[i].valid) ++n; + v &= n == count; + v &= check_sibling_list(root); + int ct = INT_MAX; + n = 0; + int f = storage[0].sibling; + while (f != 0 && ct-- > 0) + { + f = storage[f].sibling; + ++n; + } + v &= ct > 0; + v &= n <= size - count; + if (!v) error("invariant failure"); + return v; +} + + +int PHPQ::check_sibling_list(int t) +{ + if (t != 0) + { + int s = t; + long ct = LONG_MAX; // Lots of chances to find self! + do + { + if (storage[s].valid && !check_sibling_list(storage[s].children)) + return 0; + s = storage[s].sibling; + } while (ct-- > 0 && s != t && s != 0); + if (ct <= 0) return 0; + } + return 1; +} + + diff --git a/gnu/lib/libg++/libg++/src/gen/PHPQ.hP b/gnu/lib/libg++/libg++/src/gen/PHPQ.hP new file mode 100644 index 00000000000..1964ba40dc3 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PHPQ.hP @@ -0,0 +1,108 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.edu) + adapted for libg++ 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. +*/ + +#ifndef PHPQ_h +#ifdef __GNUG__ +#pragma interface +#endif +#define PHPQ_h 1 + +#include ".PQ.h" + +#ifndef PHPQIndex +#define PHPQIndex unsigned short +#endif + +struct PHPQNode +{ + PHPQIndex sibling; + PHPQIndex children; + item; + char valid; +}; + + +class PHPQ : public PQ +{ + PHPQNode* storage; // table -- freelist in storage[0].sibling + int root; + int size; + + void prealloc(int); + int check_sibling_list(int); + +public: + + PHPQ(int sz = DEFAULT_INITIAL_CAPACITY); + PHPQ(PHPQ&); + inline ~PHPQ(); + + Pix enq( item); + inline deq(); + + inline & front(); + void del_front(); + + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + void del(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + + +inline PHPQ::~PHPQ() +{ + delete [] storage; +} + + +inline PHPQ::deq() +{ + if (count == 0) error("deq of empty PQ"); + x = storage[root].item; + del_front(); + return x; +} + + +inline & PHPQ::front() +{ + if (count == 0) error("front of empty PQ"); + return storage[root].item; +} + +inline int PHPQ::contains( item) +{ + return seek(item) != 0; +} + +inline & PHPQ::operator() (Pix p) +{ + if (p == 0) error("null Pix"); + return storage[int(p)].item; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/PQ.ccP b/gnu/lib/libg++/libg++/src/gen/PQ.ccP new file mode 100644 index 00000000000..ec3bd06210c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PQ.ccP @@ -0,0 +1,63 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".PQ.h" + + + + PQ::deq() +{ + x = front(); + del_front(); + return x; +} + +Pix PQ::seek( item) +{ + Pix i; + for (i = first(); i != 0 && !(EQ((*this)(i), item)); next(i)); + return i; +} + +int PQ::owns(Pix idx) +{ + if (idx == 0) return 0; + for (Pix i = first(); i; next(i)) if (i == idx) return 1; + return 0; +} + +void PQ::clear() +{ + while (count != 0) del_front(); +} + +int PQ::contains ( item) +{ + return seek(item) != 0; +} + + +void PQ::error(const char* msg) +{ + (*lib_error_handler)("PQ", msg); +} + diff --git a/gnu/lib/libg++/libg++/src/gen/PQ.hP b/gnu/lib/libg++/libg++/src/gen/PQ.hP new file mode 100644 index 00000000000..efe18f87e7f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PQ.hP @@ -0,0 +1,78 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _PQ_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _PQ_h 1 + +#include +#include ".defs.h" + +class PQ +{ +protected: + + int count; + +public: + PQ(); + inline virtual ~PQ(); + + int length(); // current number of items + int empty(); + + virtual Pix enq( item) = 0; // add item; return Pix + virtual deq(); // return & remove min + + virtual & front() = 0; // access min item + virtual void del_front() = 0; // delete min item + + virtual int contains( item); // is item in PQ? + + virtual void clear(); // delete all items + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual & operator () (Pix i) = 0; // access item at i + virtual void del(Pix i) = 0; // delete item at i + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek( item); // Pix of item + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + + +inline PQ::PQ() :count(0) {} + +inline PQ::~PQ() {} + +inline int PQ::length() +{ + return count; +} + +inline int PQ::empty() +{ + return count == 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/PSList.hP b/gnu/lib/libg++/libg++/src/gen/PSList.hP new file mode 100644 index 00000000000..eacb34dbe35 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PSList.hP @@ -0,0 +1,32 @@ +/* : Light weight list: This will simply reuse code from a VoidP List, which +was genclassed from the SLList libg++ class. The classes generated from this file +will all be derived classes from class VoidSLList or intSLList. Note that class SLList does not +offer all the functionality of List classes, such as sharing of sub-lists. +However, no additional code is needed at all and no .cc file is generated. So it costs nothing +to use these type-safe lists. Only member functions needing type casting are re-defined */ + + +#ifndef _SList_h +#define _SList_h 1 + +#include "VoidP.SLList.h" +#include ".defs.h" + +class SList : public VoidPSLList +{ +public: + SList() {} + SList(SList& a) : (a) {} + ~SList() {} + + SList& operator = (SList& a) { + return (SList&) VoidPSLList::operator= (a); } + + & operator () (Pix p) { return (&) (VoidPSLList::operator() (p)); } + & front() { return (&) VoidPSLList::front(); } + & rear() { return (&) VoidPSLList::rear(); } + remove_front() { return () VoidPSLList::remove_front(); } + +}; + +#endif /* conditional include */ diff --git a/gnu/lib/libg++/libg++/src/gen/PVec.hP b/gnu/lib/libg++/libg++/src/gen/PVec.hP new file mode 100644 index 00000000000..de32482610b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/PVec.hP @@ -0,0 +1,79 @@ +/* : light weight Vector: This will simply reuse code from */ +/* a VoidP Vec, which was genclassed from the Vec libg++ class. */ +/* The classes generated from this file will all be derived classes */ +/* from class VoidVec or intVec. No .cc file is generated. So */ +/* it costs nothing to use these type-safe Vectors. Only member */ +/* functions needing type casting are re-defined. */ +/* */ + +#ifndef _Vec_h +#define _Vec_h 1 + +#include "VoidP.Vec.h" +#include ".defs.h" + + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)( ); +typedef (*Mapper)( ); +typedef (*Combiner)( , ); +typedef int (*Predicate)( ); +typedef int (*Comparator)( , ); +#endif + +class Vec : public VoidPVec +{ +protected: + Vec(int l, * d) : (l, (VoidP*) d) {}; +public: + Vec() {}; + Vec(int l) : (l) {}; + Vec(int l, fill_value) : (l, fill_value) {}; + Vec(Vec& v) : (v) {}; + Vec(VoidPVec& v) {fake_copy(v, s, len);} + ~Vec() {}; + + Vec& operator = (Vec& a) + {return (Vec&) VoidPVec::operator= (a);} + Vec at(int from, int n) {return (Vec) VoidPVec::at(from, n);} + + & operator [] (int n) {return (&)VoidPVec::operator[] (n);} + & elem(int n) {return (&)VoidPVec::elem(n);} + + friend Vec concat(Vec& a, Vec& b); + friend Vec map(Mapper f, Vec & a); + friend Vec merge(Vec & a, Vec & b, Comparator f); + friend Vec combine(Combiner f, Vec & a, Vec & b); + friend Vec reverse(Vec& a); + + void sort(Comparator f); + void apply(Procedure f); + reduce(Combiner f, base); +}; + +inline Vec concat(Vec& a, Vec& b) +{return (Vec)concat((VoidPVec&)a, (VoidPVec&)b);} + +inline Vec map(Mapper f, Vec & a) { + return (Vec)map((VoidPMapper)f, (VoidPVec&)a); } + +inline Vec merge(Vec & a, Vec & b, Comparator f) { + return (Vec)merge((VoidPVec&)a, (VoidPVec&)b, (VoidPComparator)f); } + +inline Vec combine(Combiner f, Vec & a, Vec & b) { + return (Vec)combine((VoidPCombiner)f, (VoidPVec&)a, (VoidPVec&)b); } + +inline Vec reverse(Vec& a) { + return (Vec)reverse((VoidPVec&)a);} + +inline void Vec::sort(Comparator f) { + VoidPVec::sort((VoidPComparator) f); } + +inline void Vec::apply(Procedure f) { + VoidPVec::apply((VoidPProcedure) f); } + +inline Vec::reduce(Combiner f, base) { + return ()VoidPVec::reduce((VoidPCombiner)f, base);} + +#endif /* conditional include */ diff --git a/gnu/lib/libg++/libg++/src/gen/Plex.ccP b/gnu/lib/libg++/libg++/src/gen/Plex.ccP new file mode 100644 index 00000000000..9a62571aca0 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Plex.ccP @@ -0,0 +1,222 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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 +#include +#include ".Plex.h" + +// IChunk support + +void IChunk::error(const char* msg) const +{ + (*lib_error_handler)("IChunk", msg); +} + +void IChunk::index_error() const +{ + error("attempt to use invalid index"); +} + +void IChunk::empty_error() const +{ + error("invalid use of empty chunk"); +} + +void IChunk::full_error() const +{ + error("attempt to extend chunk beyond bounds"); +} + +IChunk:: ~IChunk() {} + +IChunk::IChunk(* d, + int baseidx, + int lowidx, + int fenceidx, + int topidx) +{ + if (d == 0 || baseidx > lowidx || lowidx > fenceidx || fenceidx > topidx) + error("inconsistent specification"); + data = d; + base = baseidx; + low = lowidx; + fence = fenceidx; + top = topidx; + nxt = prv = this; +} + +void IChunk:: re_index(int lo) +{ + int delta = lo - low; + base += delta; + low += delta; + fence += delta; + top += delta; +} + + +void IChunk::clear(int lo) +{ + int s = top - base; + low = base = fence = lo; + top = base + s; +} + +void IChunk::cleardown(int hi) +{ + int s = top - base; + low = top = fence = hi; + base = top - s; +} + +int IChunk:: OK() const +{ + int v = data != 0; // have some data + v &= base <= low; // ok, index-wise + v &= low <= fence; + v &= fence <= top; + + v &= nxt->prv == this; // and links are OK + v &= prv->nxt == this; + if (!v) error("invariant failure"); + return(v); +} + + +// error handling + + +void Plex::error(const char* msg) const +{ + (*lib_error_handler)("Plex", msg); +} + +void Plex::index_error() const +{ + error("attempt to access invalid index"); +} + +void Plex::empty_error() const +{ + error("attempted operation on empty plex"); +} + +void Plex::full_error() const +{ + error("attempt to increase size of plex past limit"); +} + +// generic plex ops + +Plex:: ~Plex() +{ + invalidate(); +} + + +void Plex::append (const Plex& a) +{ + for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]); +} + +void Plex::prepend (const Plex& a) +{ + for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]); +} + +void Plex::reverse() +{ + tmp; + int l = low(); + int h = high(); + while (l < h) + { + tmp = (*this)[l]; + (*this)[l] = (*this)[h]; + (*this)[h] = tmp; + next(l); + prev(h); + } +} + + +void Plex::fill(const x) +{ + for (int i = lo; i < fnc; ++i) (*this)[i] = x; +} + +void Plex::fill(const x, int lo, int hi) +{ + for (int i = lo; i <= hi; ++i) (*this)[i] = x; +} + + +void Plex::del_chunk(IChunk* x) +{ + if (x != 0) + { + x->unlink(); + * data = (*)(x->invalidate()); + delete [] data; + delete x; + } +} + + +void Plex::invalidate() +{ + IChunk* t = hd; + if (t != 0) + { + IChunk* tail = tl(); + while (t != tail) + { + IChunk* nxt = t->next(); + del_chunk(t); + t = nxt; + } + del_chunk(t); + hd = 0; + } +} + +int Plex::reset_low(int l) +{ + int old = lo; + int diff = l - lo; + if (diff != 0) + { + lo += diff; + fnc += diff; + IChunk* t = hd; + do + { + t->re_index(t->low_index() + diff); + t = t->next(); + } while (t != hd); + } + return old; +} + + + + diff --git a/gnu/lib/libg++/libg++/src/gen/Plex.hP b/gnu/lib/libg++/libg++/src/gen/Plex.hP new file mode 100644 index 00000000000..d756167b15a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Plex.hP @@ -0,0 +1,494 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + +#ifndef _Plex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Plex_h 1 + +#include +#include +#include ".defs.h" + +// Plexes are made out of IChunks + +#include + +class IChunk +{ +//public: // kludge until C++ `protected' policies settled +protected: + + * data; // data, from client + + int base; // lowest possible index + int low; // lowest valid index + int fence; // highest valid index + 1 + int top; // highest possible index + 1 + + IChunk* nxt; // circular links + IChunk* prv; + +public: + +// constructors + + IChunk(* d, // ptr to array of elements + int base_idx, // initial indices + int low_idx, + int fence_idx, + int top_idx); + + virtual ~IChunk(); + +// status reports + + int size() const; // number of slots + + inline virtual int empty() const ; + inline virtual int full() const ; + + int can_grow_high () const ; // there is space to add data + int can_grow_low () const; + + int base_index() const; // lowest possible index; + int low_index() const; // lowest actual index; + inline virtual int first_index() const; // lowest valid index or fence if none + inline virtual int last_index() const; // highest valid index or low-1 if none + int fence_index() const; // highest actual index + 1 + int top_index() const; // highest possible index + 1 + +// indexing conversion + + int possible_index(int i) const; // i between base and top + int actual_index(int i) const; // i between low and fence + inline virtual int valid_index(int i) const; // i not deleted (mainly for mchunks) + + int possible_pointer(const * p) const; // same for ptr + int actual_pointer(const * p) const; + inline virtual int valid_pointer(const * p) const; + + * pointer_to(int i) const ; // pointer to data indexed by i + // caution: i is not checked for validity + int index_of(const * p) const; // index of data pointed to by p + // caution: p is not checked for validity + + inline virtual int succ(int idx) const; // next valid index or fence if none + inline virtual int pred(int idx) const; // previous index or low - 1 if none + + inline virtual * first_pointer() const; // pointer to first valid pos or 0 + inline virtual * last_pointer() const; // pointer to first valid pos or 0 + inline virtual * succ(* p) const; // next pointer or 0 + inline virtual * pred(* p) const; // previous pointer or 0 + +// modification + + inline virtual * grow_high (); // return spot to add an element + inline virtual * grow_low (); + + inline virtual void shrink_high (); // logically delete top index + inline virtual void shrink_low (); + + virtual void clear(int lo); // reset to empty ch with base = lo + virtual void cleardown(int hi); // reset to empty ch with top = hi + void re_index(int lo); // re-index so lo is new low + +// chunk traversal + + IChunk* next() const; + IChunk* prev() const; + + void link_to_prev(IChunk* prev); + void link_to_next(IChunk* next); + void unlink(); + +// state checks + + * invalidate(); // mark self as invalid; return data + // for possible deletion + + virtual int OK() const; // representation invariant + + void error(const char*) const; + void empty_error() const; + void full_error() const; + void index_error() const; +}; + +// Plex is a partly `abstract' class: few of the virtuals +// are implemented at the Plex level, only in the subclasses + +class Plex +{ +protected: + + IChunk* hd; // a chunk holding the data + int lo; // lowest index + int fnc; // highest index + 1 + int csize; // size of the chunk + + void invalidate(); // mark so OK() is false + void del_chunk(IChunk*); // delete a chunk + + IChunk* tl() const; // last chunk; + int one_chunk() const; // true if hd == tl() + +public: + +// constructors, etc. + + Plex(); // no-op + + virtual ~Plex(); + + +// Access functions + + virtual & operator [] (int idx) = 0; // access by index; + virtual & operator () (Pix p) = 0; // access by Pix; + + virtual & high_element () = 0; // access high element + virtual & low_element () = 0; // access low element + +// read-only versions for const Plexes + + virtual const & operator [] (int idx) const = 0; // access by index; + virtual const & operator () (Pix p) const = 0; // access by Pix; + + virtual const & high_element () const = 0; // access high element + virtual const & low_element () const = 0; // access low element + + +// Index functions + + virtual int valid (int idx) const = 0; // idx is an OK index + + virtual int low() const = 0; // lowest index or fence if none + virtual int high() const = 0; // highest index or low-1 if none + + int ecnef() const; // low limit index (low-1) + int fence() const; // high limit index (high+1) + + virtual void prev(int& idx) const= 0; // set idx to preceding index + // caution: pred may be out of bounds + + virtual void next(int& idx) const = 0; // set to next index + // caution: succ may be out of bounds + + virtual Pix first() const = 0; // Pix to low element or 0 + virtual Pix last() const = 0; // Pix to high element or 0 + virtual void prev(Pix& pix) const = 0; // preceding pix or 0 + virtual void next(Pix& pix) const = 0; // next pix or 0 + virtual int owns(Pix p) const = 0; // p is an OK Pix + +// index<->Pix + + virtual int Pix_to_index(Pix p) const = 0; // get index via Pix + virtual Pix index_to_Pix(int idx) const = 0; // Pix via index + +// Growth + + virtual int add_high(const elem) =0;// add new element at high end + // return new high + + virtual int add_low(const elem) = 0; // add new low element, + // return new low + +// Shrinkage + + virtual int del_high() = 0; // remove the element at high end + // return new high + virtual int del_low() = 0; // delete low element, return new lo + + // caution: del_low/high + // does not necessarily + // immediately call ::~ + + +// operations on multiple elements + + virtual void fill(const x); // set all elements = x + virtual void fill(const x, int from, int to); // fill from to to + virtual void clear() = 0; // reset to zero-sized Plex + virtual int reset_low(int newlow); // change low index,return old + virtual void reverse(); // reverse in-place + virtual void append(const Plex& a); // concatenate a copy + virtual void prepend(const Plex& a); // prepend a copy + +// status + + virtual int can_add_high() const = 0; + virtual int can_add_low() const = 0; + + int length () const; // number of slots + + int empty () const; // is the plex empty? + virtual int full() const = 0; // it it full? + + int chunk_size() const; // report chunk size; + + virtual int OK() const = 0; // representation invariant + + void error(const char* msg) const; + void index_error() const; + void empty_error() const; + void full_error() const; +}; + + +// IChunk ops + +inline int IChunk:: size() const +{ + return top - base; +} + + +inline int IChunk:: base_index() const +{ + return base; +} + +inline int IChunk:: low_index() const +{ + return low; +} + +inline int IChunk:: fence_index() const +{ + return fence; +} + +inline int IChunk:: top_index() const +{ + return top; +} + +inline * IChunk:: pointer_to(int i) const +{ + return &(data[i-base]); +} + +inline int IChunk:: index_of(const * p) const +{ + return ((int)p - (int)data) / sizeof() + base; +} + +inline int IChunk:: possible_index(int i) const +{ + return i >= base && i < top; +} + +inline int IChunk:: possible_pointer(const * p) const +{ + return p >= data && p < &(data[top-base]); +} + +inline int IChunk:: actual_index(int i) const +{ + return i >= low && i < fence; +} + +inline int IChunk:: actual_pointer(const * p) const +{ + return p >= data && p < &(data[fence-base]); +} + +inline int IChunk:: can_grow_high () const +{ + return fence < top; +} + +inline int IChunk:: can_grow_low () const +{ + return base < low; +} + +inline * IChunk:: invalidate() +{ + * p = data; + data = 0; + return p; +} + + +inline IChunk* IChunk::prev() const +{ + return prv; +} + +inline IChunk* IChunk::next() const +{ + return nxt; +} + +inline void IChunk::link_to_prev(IChunk* prev) +{ + nxt = prev->nxt; + prv = prev; + nxt->prv = this; + prv->nxt = this; +} + +inline void IChunk::link_to_next(IChunk* next) +{ + prv = next->prv; + nxt = next; + nxt->prv = this; + prv->nxt = this; +} + +inline void IChunk::unlink() +{ + IChunk* n = nxt; + IChunk* p = prv; + n->prv = p; + p->nxt = n; + prv = nxt = this; +} + +inline int IChunk:: empty() const +{ + return low == fence; +} + +inline int IChunk:: full() const +{ + return top - base == fence - low; +} + +inline int IChunk:: first_index() const +{ + return (low == fence)? fence : low; +} + +inline int IChunk:: last_index() const +{ + return (low == fence)? low - 1 : fence - 1; +} + +inline int IChunk:: succ(int i) const +{ + return (i < low) ? low : i + 1; +} + +inline int IChunk:: pred(int i) const +{ + return (i > fence) ? (fence - 1) : i - 1; +} + +inline int IChunk:: valid_index(int i) const +{ + return i >= low && i < fence; +} + +inline int IChunk:: valid_pointer(const * p) const +{ + return p >= &(data[low - base]) && p < &(data[fence - base]); +} + +inline * IChunk:: grow_high () +{ + if (!can_grow_high()) full_error(); + return &(data[fence++ - base]); +} + +inline * IChunk:: grow_low () +{ + if (!can_grow_low()) full_error(); + return &(data[--low - base]); +} + +inline void IChunk:: shrink_high () +{ + if (empty()) empty_error(); + --fence; +} + +inline void IChunk:: shrink_low () +{ + if (empty()) empty_error(); + ++low; +} + +inline * IChunk::first_pointer() const +{ + return (low == fence)? 0 : &(data[low - base]); +} + +inline * IChunk::last_pointer() const +{ + return (low == fence)? 0 : &(data[fence - base - 1]); +} + +inline * IChunk::succ(* p) const +{ + return ((p+1) < &(data[low - base]) || (p+1) >= &(data[fence - base])) ? + 0 : (p+1); +} + +inline * IChunk::pred(* p) const +{ + return ((p-1) < &(data[low - base]) || (p-1) >= &(data[fence - base])) ? + 0 : (p-1); +} + + +// generic Plex operations + +inline Plex::Plex() {} + +inline int Plex::chunk_size() const +{ + return csize; +} + +inline int Plex::ecnef () const +{ + return lo - 1; +} + + +inline int Plex::fence () const +{ + return fnc; +} + +inline int Plex::length () const +{ + return fnc - lo; +} + +inline int Plex::empty () const +{ + return fnc == lo; +} + +inline IChunk* Plex::tl() const +{ + return hd->prev(); +} + +inline int Plex::one_chunk() const +{ + return hd == hd->prev(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Queue.ccP b/gnu/lib/libg++/libg++/src/gen/Queue.ccP new file mode 100644 index 00000000000..fb48d952ff7 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Queue.ccP @@ -0,0 +1,14 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".Queue.h" + +Queue::~Queue() {} + + +// error handling + +void Queue::error(const char* msg) +{ + (*lib_error_handler)("Queue", msg); +} diff --git a/gnu/lib/libg++/libg++/src/gen/Queue.hP b/gnu/lib/libg++/libg++/src/gen/Queue.hP new file mode 100644 index 00000000000..c7e05ac6124 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Queue.hP @@ -0,0 +1,51 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Queue_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Queue_h + +#include + +#include ".defs.h" + +class Queue +{ +public: + Queue() { } + virtual ~Queue(); + + virtual void enq( item) = 0; + virtual deq() = 0; + virtual & front() = 0; + virtual void del_front() = 0; + + virtual void clear() = 0; + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + + void error(const char*); + + virtual int OK() = 0; +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/RAVLMap.ccP b/gnu/lib/libg++/libg++/src/gen/RAVLMap.ccP new file mode 100644 index 00000000000..9477250a6e6 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/RAVLMap.ccP @@ -0,0 +1,690 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include "..RAVLMap.h" + + +/* + constants & inlines for maintaining balance & thread status in tree nodes +*/ + +#define AVLBALANCEMASK 3 +#define AVLBALANCED 0 +#define AVLLEFTHEAVY 1 +#define AVLRIGHTHEAVY 2 + +#define LTHREADBIT 4 +#define RTHREADBIT 8 + + +static inline int bf(RAVLNode* t) +{ + return t->stat & AVLBALANCEMASK; +} + +static inline void set_bf(RAVLNode* t, int b) +{ + t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); +} + + +static inline int rthread(RAVLNode* t) +{ + return t->stat & RTHREADBIT; +} + +static inline void set_rthread(RAVLNode* t, int b) +{ + if (b) + t->stat |= RTHREADBIT; + else + t->stat &= ~RTHREADBIT; +} + +static inline int lthread(RAVLNode* t) +{ + return t->stat & LTHREADBIT; +} + +static inline void set_lthread(RAVLNode* t, int b) +{ + if (b) + t->stat |= LTHREADBIT; + else + t->stat &= ~LTHREADBIT; +} + +/* + traversal primitives +*/ + + +RAVLNode* RAVLMap::leftmost() +{ + RAVLNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +RAVLNode* RAVLMap::rightmost() +{ + RAVLNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +RAVLNode* RAVLMap::succ(RAVLNode* t) +{ + RAVLNode* r = t->rt; + if (!rthread(t)) while (!lthread(r)) r = r->lt; + return r; +} + +RAVLNode* RAVLMap::pred(RAVLNode* t) +{ + RAVLNode* l = t->lt; + if (!lthread(t)) while (!rthread(l)) l = l->rt; + return l; +} + + +Pix RAVLMap::seek( key) +{ + RAVLNode* t = root; + if (t == 0) + return 0; + for (;;) + { + int cmp = CMP(key, t->item); + if (cmp == 0) + return Pix(t); + else if (cmp < 0) + { + if (lthread(t)) + return 0; + else + t = t->lt; + } + else if (rthread(t)) + return 0; + else + t = t->rt; + } +} + + +int RAVLMap::rankof( key) +{ + int r; + RAVLNode* t = root; + if (t == 0) + return 0; + for (r=t->rank; t != 0; r+=t->rank) + { + int cmp = CMP(key, t->item); + if (cmp == 0) + return r; + else if (cmp < 0) + { + if (lthread(t)) + return 0; + else + { + r -= t->rank; + t = t->lt; + } + } + else if (rthread(t)) + return 0; + else + { + t = t->rt; + } + } + return 0; +} + +Pix RAVLMap::ranktoPix(int i) +{ + int r; + RAVLNode* t = root; + + if ((i<1)||(i>count)) + return 0; + for (r=t->rank; r!=i; r+=t->rank) + { + if (r>i) + { + r -= t->rank; + t = t->lt; + } + else + t = t->rt; + } + return Pix(t); +} + +/* + The combination of threads and AVL bits make adding & deleting + interesting, but very awkward. + + We use the following statics to avoid passing them around recursively +*/ + +static int _need_rebalancing; // to send back balance info from rec. calls +static * _target_item; // add/del_item target +static RAVLNode* _found_node; // returned added/deleted node +static int _already_found; // for deletion subcases +static int _rank_changed; // for rank computation + + +void RAVLMap:: _add(RAVLNode*& t) +{ + int cmp = CMP(*_target_item, t->item); + if (cmp == 0) + { + _found_node = t; + return; + } + else if (cmp < 0) + { + if (lthread(t)) + { + ++count; + _found_node = new RAVLNode(*_target_item, def); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t->lt; + _found_node->rt = t; + t->lt = _found_node; + set_lthread(t, 0); + _need_rebalancing = 1; + _rank_changed = 1; + } + else + _add(t->lt); + if (_rank_changed) ++t->rank; + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + return; + case AVLLEFTHEAVY: + { + RAVLNode* l = t->lt; + if (bf(l) == AVLLEFTHEAVY) + { + t->rank -= l->rank; + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + } + else + { + RAVLNode* r = l->rt; + r->rank += l->rank; + t->rank -= r->rank; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + return; + } + } + } + } + } + else + { + if (rthread(t)) + { + ++count; + _found_node = new RAVLNode(*_target_item, def); + set_rthread(t, 0); + set_lthread(_found_node, 1); + set_rthread(_found_node, 1); + _found_node->lt = t; + _found_node->rt = t->rt; + t->rt = _found_node; + _need_rebalancing = 1; + _rank_changed = 1; + } + else + _add(t->rt); + if (_need_rebalancing) + { + switch(bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + _need_rebalancing = 0; + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + return; + case AVLRIGHTHEAVY: + { + RAVLNode* r = t->rt; + if (bf(r) == AVLRIGHTHEAVY) + { + r->rank += t->rank; + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + _need_rebalancing = 0; + } + else + { + RAVLNode* l = r->lt; + r->rank -= l->rank; + l->rank += t->rank; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + _need_rebalancing = 0; + return; + } + } + } + } + } +} + + +& RAVLMap::operator [] ( item) +{ + if (root == 0) + { + ++count; + root = new RAVLNode(item, def); + set_rthread(root, 1); + set_lthread(root, 1); + return root->cont; + } + else + { + _target_item = &item; + _need_rebalancing = 0; + _rank_changed = 0; + _add(root); + return _found_node->cont; + } +} + + +void RAVLMap::_del(RAVLNode* par, RAVLNode*& t) +{ + int comp; + if (_already_found) + { + if (rthread(t)) + comp = 0; + else + comp = 1; + } + else + comp = CMP(*_target_item, t->item); + if (comp == 0) + { + if (lthread(t) && rthread(t)) + { + _found_node = t; + if (t == par->lt) + { + set_lthread(par, 1); + par->lt = t->lt; + } + else + { + set_rthread(par, 1); + par->rt = t->rt; + } + _need_rebalancing = 1; + _rank_changed = 1; + return; + } + else if (lthread(t)) + { + _found_node = t; + RAVLNode* s = succ(t); + if (s != 0 && lthread(s)) + s->lt = t->lt; + t = t->rt; + _need_rebalancing = 1; + _rank_changed = 1; + return; + } + else if (rthread(t)) + { + _found_node = t; + RAVLNode* p = pred(t); + if (p != 0 && rthread(p)) + p->rt = t->rt; + t = t->lt; + _need_rebalancing = 1; + _rank_changed = 1; + return; + } + else // replace item & find someone deletable + { + RAVLNode* p = pred(t); + t->item = p->item; + t->cont = p->cont; + _already_found = 1; + comp = -1; // fall through below to left + } + } + + if (comp < 0) + { + if (lthread(t)) + return; + _del(t, t->lt); + if (_rank_changed) --t->rank; + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLLEFTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLRIGHTHEAVY); + _need_rebalancing = 0; + return; + case AVLRIGHTHEAVY: + { + RAVLNode* r = t->rt; + switch (bf(r)) + { + case AVLBALANCED: + r->rank += t->rank; + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLRIGHTHEAVY); + set_bf(r, AVLLEFTHEAVY); + _need_rebalancing = 0; + t = r; + return; + case AVLRIGHTHEAVY: + r->rank += t->rank; + if (lthread(r)) + t->rt = r; + else + t->rt = r->lt; + set_rthread(t, lthread(r)); + r->lt = t; + set_lthread(r, 0); + set_bf(t, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + case AVLLEFTHEAVY: + { + RAVLNode* l = r->lt; + r->rank -= l->rank; + l->rank += t->rank; + set_lthread(r, rthread(l)); + if (rthread(l)) + r->lt = l; + else + r->lt = l->rt; + l->rt = r; + set_rthread(l, 0); + set_rthread(t, lthread(l)); + if (lthread(l)) + t->rt = l; + else + t->rt = l->lt; + l->lt = t; + set_lthread(l, 0); + if (bf(l) == AVLRIGHTHEAVY) + set_bf(t, AVLLEFTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(l) == AVLLEFTHEAVY) + set_bf(r, AVLRIGHTHEAVY); + else + set_bf(r, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + } + } + } + } + } + else + { + if (rthread(t)) + return; + _del(t, t->rt); + if (!_need_rebalancing) + return; + switch (bf(t)) + { + case AVLRIGHTHEAVY: + set_bf(t, AVLBALANCED); + return; + case AVLBALANCED: + set_bf(t, AVLLEFTHEAVY); + _need_rebalancing = 0; + return; + case AVLLEFTHEAVY: + { + RAVLNode* l = t->lt; + switch (bf(l)) + { + case AVLBALANCED: + t->rank -= l->rank; + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLLEFTHEAVY); + set_bf(l, AVLRIGHTHEAVY); + _need_rebalancing = 0; + t = l; + return; + case AVLLEFTHEAVY: + t->rank -= l->rank; + if (rthread(l)) + t->lt = l; + else + t->lt = l->rt; + set_lthread(t, rthread(l)); + l->rt = t; + set_rthread(l, 0); + set_bf(t, AVLBALANCED); + set_bf(l, AVLBALANCED); + t = l; + return; + case AVLRIGHTHEAVY: + { + RAVLNode* r = l->rt; + r->rank += l->rank; + t->rank -= r->rank; + set_rthread(l, lthread(r)); + if (lthread(r)) + l->rt = r; + else + l->rt = r->lt; + r->lt = l; + set_lthread(r, 0); + set_lthread(t, rthread(r)); + if (rthread(r)) + t->lt = r; + else + t->lt = r->rt; + r->rt = t; + set_rthread(r, 0); + if (bf(r) == AVLLEFTHEAVY) + set_bf(t, AVLRIGHTHEAVY); + else + set_bf(t, AVLBALANCED); + if (bf(r) == AVLRIGHTHEAVY) + set_bf(l, AVLLEFTHEAVY); + else + set_bf(l, AVLBALANCED); + set_bf(r, AVLBALANCED); + t = r; + return; + } + } + } + } + } +} + + +void RAVLMap::del( item) +{ + if (root == 0) return; + _need_rebalancing = 0; + _already_found = 0; + _found_node = 0; + _rank_changed = 0; + _target_item = &item; + _del(root, root); + if (_found_node) + { + delete(_found_node); + if (--count == 0) + root = 0; + } +} + +void RAVLMap::_kill(RAVLNode* t) +{ + if (t != 0) + { + if (!lthread(t)) _kill(t->lt); + if (!rthread(t)) _kill(t->rt); + delete t; + } +} + + +RAVLMap::RAVLMap(RAVLMap& b) :Map(b.def) +{ + root = 0; + count = 0; + for (Pix i = b.first(); i != 0; b.next(i)) + (*this)[b.key(i)] = b.contents(i); +} + + +int RAVLMap::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + RAVLNode* trail = leftmost(); + v &= rankof(trail->item) == n; + RAVLNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + v &= rankof(t->item) == n; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/RAVLMap.hP b/gnu/lib/libg++/libg++/src/gen/RAVLMap.hP new file mode 100644 index 00000000000..1009ef1a9a5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/RAVLMap.hP @@ -0,0 +1,147 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + ranking code from Paul Anderson (paul%lfcs.ed.ac.uk) + +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. +*/ + + +#ifndef _RAVLMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _RAVLMap_h 1 + +#include "..Map.h" + +struct RAVLNode +{ + RAVLNode* lt; + RAVLNode* rt; + item; + cont; + int rank; + char stat; + RAVLNode( h, c, + RAVLNode* l=0, RAVLNode* r=0, int k=1); + ~RAVLNode(); +}; + +inline RAVLNode::RAVLNode( h, c, + RAVLNode* l, RAVLNode* r, int k) + :lt(l), rt(r), item(h), cont(c), rank(k), stat(0) {} + +inline RAVLNode::~RAVLNode() {} + +typedef RAVLNode* RAVLNodePtr; + + +class RAVLMap : public Map +{ +protected: + RAVLNode* root; + + RAVLNode* leftmost(); + RAVLNode* rightmost(); + RAVLNode* pred(RAVLNode* t); + RAVLNode* succ(RAVLNode* t); + void _kill(RAVLNode* t); + void _add(RAVLNode*& t); + void _del(RAVLNode* p, RAVLNode*& t); + +public: + RAVLMap( dflt); + RAVLMap(RAVLMap& a); + inline ~RAVLMap(); + + & operator [] ( key); + + void del( key); + + inline Pix first(); + inline void next(Pix& i); + inline & key(Pix i); + inline & contents(Pix i); + + Pix seek( key); + inline int contains( key); + + Pix ranktoPix(int i); + int rankof( key); + + inline void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +inline RAVLMap::~RAVLMap() +{ + _kill(root); +} + +inline RAVLMap::RAVLMap( dflt) :Map(dflt) +{ + root = 0; +} + + +inline Pix RAVLMap::first() +{ + return Pix(leftmost()); +} + +inline Pix RAVLMap::last() +{ + return Pix(rightmost()); +} + +inline void RAVLMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((RAVLNode*)i)); +} + +inline void RAVLMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((RAVLNode*)i)); +} + +inline & RAVLMap::key(Pix i) +{ + if (i == 0) error("null Pix"); + return ((RAVLNode*)i)->item; +} + +inline & RAVLMap::contents(Pix i) +{ + if (i == 0) error("null Pix"); + return ((RAVLNode*)i)->cont; +} + +inline void RAVLMap::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int RAVLMap::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/RPlex.ccP b/gnu/lib/libg++/libg++/src/gen/RPlex.ccP new file mode 100644 index 00000000000..1707b5d0ab2 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/RPlex.ccP @@ -0,0 +1,477 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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 ".RPlex.h" + +typedef IChunk* _IChunk_ptr; + +RPlex:: RPlex() +{ + lo = fnc = 0; + csize = DEFAULT_INITIAL_CAPACITY; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, lo+csize)); + hd = ch; + maxch = MIN_NCHUNKS; + lch = maxch / 2; + fch = lch + 1; + base = ch->base_index() - lch * csize; + chunks = new _IChunk_ptr[maxch]; + chunks[lch] = ch; +} + +RPlex:: RPlex(int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + lo = fnc = 0; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, csize+lo)); + hd = ch; + } + else + { + csize = -chunksize; + * data = new [csize]; + set_cache(new IChunk(data, chunksize+lo, lo, fnc, fnc)); + hd = ch; + } + maxch = MIN_NCHUNKS; + lch = maxch / 2; + fch = lch + 1; + base = ch->base_index() - lch * csize; + chunks = new _IChunk_ptr[maxch]; + chunks[lch] = ch; +} + + +RPlex:: RPlex(int l, int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + lo = fnc = l; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, lo+csize)); + hd = ch; + } + else + { + csize = -chunksize; + * data = new [csize]; + set_cache(new IChunk(data, chunksize+lo, lo, fnc, fnc)); + hd = ch; + } + maxch = MIN_NCHUNKS; + lch = maxch / 2; + fch = lch + 1; + base = ch->base_index() - lch * csize; + chunks = new _IChunk_ptr[maxch]; + chunks[lch] = ch; +} + +void RPlex::make_initial_chunks(int up) +{ + int count = 0; + int need = fnc - lo; + hd = 0; + if (up) + { + int l = lo; + do + { + ++count; + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + IChunk* h = new IChunk(data, l, l, l+sz, l+csize); + if (hd != 0) + h->link_to_next(hd); + else + hd = h; + l += sz; + need -= sz; + } while (need > 0); + } + else + { + int hi = fnc; + do + { + ++count; + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + IChunk* h = new IChunk(data, hi-csize, hi-sz, hi, hi); + if (hd != 0) + h->link_to_next(hd); + hd = h; + hi -= sz; + need -= sz; + } while (need > 0); + } + set_cache((IChunk*)hd); + + maxch = MIN_NCHUNKS; + if (maxch < count * 2) + maxch = count * 2; + chunks = new _IChunk_ptr[maxch]; + lch = maxch / 3; + fch = lch + count; + base = ch->base_index() - csize * lch; + int k = lch; + do + { + chunks[k++] = ch; + set_cache(ch->next()); + } while (ch != hd); +} + +RPlex:: RPlex(int l, int hi, const initval, int chunksize) +{ + lo = l; + fnc = hi + 1; + if (chunksize == 0) + { + csize = fnc - l; + make_initial_chunks(1); + } + else if (chunksize < 0) + { + csize = -chunksize; + make_initial_chunks(0); + } + else + { + csize = chunksize; + make_initial_chunks(1); + } + fill(initval); +} + +RPlex::RPlex(const RPlex& a) +{ + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + make_initial_chunks(); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; +} + +void RPlex::operator= (const RPlex& a) +{ + if (&a != this) + { + invalidate(); + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + make_initial_chunks(); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; + } +} + + +void RPlex::cache(const * p) const +{ + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) index_error(); + } + set_cache(t); +} + +int RPlex::owns(Pix px) const +{ + * p = (*)px; + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) return 0; + } + set_cache(t); + return 1; +} + + +* RPlex::dosucc(const * p) const +{ + if (p == 0) return 0; + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) return 0; + } + int i = t->index_of(p) + 1; + if (i >= fnc) return 0; + if (i >= t->fence_index()) t = (t->next()); + set_cache(t); + return t->pointer_to(i); +} + +* RPlex::dopred(const * p) const +{ + if (p == 0) return 0; + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->prev()); + if (t == old) return 0; + } + int i = t->index_of(p) - 1; + if (i < lo) return 0; + if (i < t->low_index()) t = (t->prev()); + set_cache(t); + return (t->pointer_to(i)); +} + +int RPlex::add_high(const elem) +{ + IChunk* t = tl(); + if (!t->can_grow_high()) + { + if (t->IChunk::empty() && one_chunk()) + { + t->clear(fnc); + base = t->base_index() - lch * csize; + } + else + { + * data = new [csize]; + t = (new IChunk(data, fnc, fnc, fnc,fnc+csize)); + t->link_to_prev(tl()); + if (fch == maxch) + { + maxch *= 2; + IChunk** newch = new _IChunk_ptr [maxch]; + memcpy(newch, chunks, fch * sizeof(_IChunk_ptr)); + delete chunks; + chunks = newch; + } + chunks[fch++] = t; + } + } + *((t->IChunk::grow_high())) = elem; + set_cache(t); + return fnc++; +} + +int RPlex::del_high () +{ + if (empty()) empty_error(); + IChunk* t = tl(); + if (t->IChunk::empty()) // kill straggler first + { + IChunk* pred = t->prev(); + del_chunk(t); + t = (pred); + --fch; + } + t->IChunk::shrink_high(); + if (t->IChunk::empty() && !one_chunk()) + { + IChunk* pred = t->prev(); + del_chunk(t); + t = (pred); + --fch; + } + set_cache(t); + return --fnc - 1; +} + +int RPlex::add_low (const elem) +{ + IChunk* t = hd; + if (!t->can_grow_low()) + { + if (t->IChunk::empty() && one_chunk()) + { + t->cleardown(lo); + base = t->base_index() - lch * csize; + } + else + { + * data = new [csize]; + hd = new IChunk(data, lo-csize, lo, lo, lo); + hd->link_to_next(t); + t = ( hd); + if (lch == 0) + { + lch = maxch; + fch += maxch; + maxch *= 2; + IChunk** newch = new _IChunk_ptr [maxch]; + memcpy(&(newch[lch]), chunks, lch * sizeof(_IChunk_ptr)); + delete chunks; + chunks = newch; + base = t->base_index() - (lch - 1) * csize; + } + chunks[--lch] = t; + } + } + *((t->IChunk::grow_low())) = elem; + set_cache(t); + return --lo; +} + + +int RPlex::del_low () +{ + if (empty()) empty_error(); + IChunk* t = hd; + if (t->IChunk::empty()) + { + hd = t->next(); + del_chunk(t); + t = hd; + ++lch; + } + t->IChunk::shrink_low(); + if (t->IChunk::empty() && !one_chunk()) + { + hd = t->next(); + del_chunk(t); + t = hd; + ++lch; + } + set_cache(t); + return ++lo; +} + +void RPlex::reverse() +{ + tmp; + int l = lo; + int h = fnc - 1; + IChunk* loch = hd; + IChunk* hich = tl(); + while (l < h) + { + * lptr = loch->pointer_to(l); + * hptr = hich->pointer_to(h); + tmp = *lptr; + *lptr = *hptr; + *hptr = tmp; + if (++l >= loch->fence_index()) loch = loch->next(); + if (--h < hich->low_index()) hich = hich->prev(); + } +} + +void RPlex::fill(const x) +{ + for (int i = lo; i < fnc; ++i) (*this)[i] = x; +} + +void RPlex::fill(const x, int lo, int hi) +{ + for (int i = lo; i <= hi; ++i) (*this)[i] = x; +} + + +void RPlex::clear() +{ + for (int i = lch + 1; i < fch; ++i) + del_chunk(chunks[i]); + fch = lch + 1; + set_cache(chunks[lch]); + ch->IChunk::clear(lo); + fnc = lo; +} + +int RPlex::reset_low(int l) +{ + int old = lo; + int diff = l - lo; + if (diff != 0) + { + lo += diff; + fnc += diff; + IChunk* t = hd; + do + { + t->re_index(t->low_index() + diff); + t = t->next(); + } while (t != hd); + } + base = hd->base_index() - lch * csize; + return old; +} + + +int RPlex::OK () const +{ + int v = hd != 0 && ch != 0; // at least one chunk + + v &= fnc == tl()->fence_index(); // last chunk fnc == plex fnc + v &= lo == hd->IChunk::low_index(); // first lo == plex lo + + v &= base == hd->base_index() - lch * csize; // base is correct; + v &= lch < fch; + v &= fch <= maxch; // within allocation; + +// loop for others: + + int k = lch; // to cross-check nch + + int found_ch = 0; // to make sure ch is in list; + const IChunk* t = (hd); + for (;;) + { + v &= chunks[k++] == t; // each chunk is at proper index + if (t == ch) ++found_ch; + v &= t->IChunk::OK(); // each chunk is OK + if (t == tl()) + break; + else // and has indices contiguous to succ + { + v &= t->top_index() == t->next()->base_index(); + if (t != hd) // internal chunks full + { + v &= !t->empty(); + v &= !t->can_grow_low(); + v &= !t->can_grow_high(); + } + t = t->next(); + } + } + v &= found_ch == 1; + v &= fch == k; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/RPlex.hP b/gnu/lib/libg++/libg++/src/gen/RPlex.hP new file mode 100644 index 00000000000..546adaa3c5d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/RPlex.hP @@ -0,0 +1,257 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + +#ifndef _RPlex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _RPlex_h 1 + +#include ".Plex.h" + +// minimum number of chunks to index + +#ifndef MIN_NCHUNKS +#define MIN_NCHUNKS 16 +#endif + +class RPlex: public Plex +{ + int base; // base index of lowest chunk + int lch; // index of lowest used chunk + int fch; // 1 + index of highest used chunk + int maxch; // max chunks in array + IChunk** chunks; // array of chunks + IChunk* ch; // cached chunk + + void make_initial_chunks(int up = 1); + + void cache(int idx) const; + void cache(const * p) const; + * dopred(const * p) const; + * dosucc(const * p) const; + + inline void set_cache(const IChunk* t) const; // logically, + // not physically const + +public: + RPlex(); // set low = 0; + // fence = 0; + // csize = default + + RPlex(int ch_size); // low = 0; + // fence = 0; + // csize = ch_size + + RPlex(int lo, // low = lo; + int ch_size); // fence=lo + // csize = ch_size + + RPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int ch_size = 0); // csize= ch_size + // or fence-lo if 0 + + RPlex(const RPlex&); + + inline ~RPlex(); + + void operator= (const RPlex&); + +// virtuals + + inline & high_element (); + inline & low_element (); + + inline const & high_element () const; + inline const & low_element () const; + + inline Pix first() const; + inline Pix last() const; + inline void prev(Pix& ptr) const; + inline void next(Pix& ptr) const; + int owns(Pix p) const; + inline & operator () (Pix p); + inline const & operator () (Pix p) const; + + inline int low() const; + inline int high() const; + inline int valid(int idx) const; + inline void prev(int& idx) const; + inline void next(int& x) const; + inline & operator [] (int index); + inline const & operator [] (int index) const; + + inline int Pix_to_index(Pix p) const; + inline Pix index_to_Pix(int idx) const; + + inline int can_add_high() const; + inline int can_add_low() const; + inline int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + + int reset_low(int newlow); + + int OK () const; +}; + + +inline void RPlex::prev(int& idx) const +{ + --idx; +} + +inline void RPlex::next(int& idx) const +{ + ++idx; +} + +inline int RPlex::full () const +{ + return 0; +} + +inline int RPlex::can_add_high() const +{ + return 1; +} + +inline int RPlex::can_add_low() const +{ + return 1; +} + +inline int RPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int RPlex::low() const +{ + return lo; +} + +inline int RPlex::high() const +{ + return fnc - 1; +} + +inline void RPlex::set_cache(const IChunk* t) const +{ + ((RPlex*)(this))->ch = (IChunk*)t; +} + +inline void RPlex::cache(int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + set_cache(chunks[(idx - base) / csize]); +} + +inline & RPlex::low_element () +{ + cache(lo); return *(ch->pointer_to(lo)); +} + +inline & RPlex::high_element () +{ + cache(fnc-1); return *(ch->pointer_to(fnc - 1)); +} + +inline const & RPlex::low_element () const +{ + cache(lo); return *((const *)(ch->pointer_to(lo))); +} + +inline const & RPlex::high_element () const +{ + cache(fnc-1); return *((const *)(ch->pointer_to(fnc - 1))); +} + +inline int RPlex::Pix_to_index(Pix px) const +{ + * p = (*)px; + if (!ch->actual_pointer(p)) cache(p); + return ch->index_of(p); +} + +inline Pix RPlex::index_to_Pix(int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return (Pix)(ch->pointer_to(idx)); +} + +inline Pix RPlex::first() const +{ + return Pix(hd->IChunk::first_pointer()); +} + +inline Pix RPlex::last() const +{ + return Pix(tl()->IChunk::last_pointer()); +} + +inline void RPlex::prev(Pix& p) const +{ + Pix q = Pix(ch->IChunk::pred((*)p)); + p = (q == 0)? Pix(dopred((*)p)) : q; +} + +inline void RPlex::next(Pix& p) const +{ + Pix q = Pix(ch->IChunk::succ((*)p)); + p = (q == 0)? Pix(dosucc((*)p)) : q; +} + +inline & RPlex:: operator () (Pix p) +{ + return *((*)p); +} + + +inline & RPlex:: operator [] (int idx) +{ + cache(idx); return *(ch->pointer_to(idx)); +} + +inline const & RPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline const & RPlex:: operator [] (int idx) const +{ + cache(idx); return *((const *)(ch->pointer_to(idx))); +} + +inline RPlex::~RPlex() +{ + delete chunks; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SLBag.ccP b/gnu/lib/libg++/libg++/src/gen/SLBag.ccP new file mode 100644 index 00000000000..6b7c0faca5c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLBag.ccP @@ -0,0 +1,105 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".SLBag.h" + +int SLBag::OK() +{ + int v = p.OK(); + v &= count == p.length(); + if (!v) error("invariant failure"); + return v; +} + +Pix SLBag::seek( item, Pix i) +{ + if (i == 0) i = first(); else next(i); + for (; i != 0 && (!(EQ(p(i), item))); p.next(i)); + return i; +} + +int SLBag::nof( item) +{ + int n = 0; + for (Pix p = first(); p; next(p)) if (EQ((*this)(p), item)) ++n; + return n; +} + + +void SLBag::del( item) +{ + Pix i = p.first(); + if (i == 0) + return; + else if (EQ(p(i), item)) + { + --count; + p.del_front(); + } + else + { + Pix trail = i; + p.next(i); + while (i != 0) + { + if (EQ(p(i), item)) + { + --count; + p.del_after(trail); + return; + } + trail = i; + p.next(i); + } + } +} + +void SLBag::remove( item) +{ + Pix i = p.first(); + while (i != 0 && EQ(p(i), item)) + { + --count; + p.del_front(); + i = p.first(); + } + if (i != 0) + { + Pix trail = i; + p.next(i); + while (i != 0) + { + if (EQ(p(i), item)) + { + --count; + p.del_after(trail); + i = trail; + p.next(i); + } + else + { + trail = i; + p.next(i); + } + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/gen/SLBag.hP b/gnu/lib/libg++/libg++/src/gen/SLBag.hP new file mode 100644 index 00000000000..2bab7db64a9 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLBag.hP @@ -0,0 +1,96 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SLBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SLBag_h 1 + +#include ".Bag.h" +#include ".SLList.h" + +class SLBag : public Bag +{ +protected: + SLList p; + +public: + SLBag(); + SLBag(const SLBag&); + + inline Pix add( item); + void del( item); + void remove(item); + inline int contains( item); + int nof( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +inline SLBag::SLBag() : p() { count = 0; } + +inline SLBag::SLBag(const SLBag& s) : p(s.p) { count = s.count; } + +inline Pix SLBag::first() +{ + return p.first(); +} + +inline void SLBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & SLBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void SLBag::clear() +{ + count = 0; p.clear(); +} + +inline int SLBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline Pix SLBag::add( item) +{ + ++count; + return p.append(item); +} + +inline int SLBag::contains( item) +{ + return seek(item) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SLList.ccP b/gnu/lib/libg++/libg++/src/gen/SLList.ccP new file mode 100644 index 00000000000..3dbe22f3d38 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLList.ccP @@ -0,0 +1,292 @@ +// This may look like C code, but it is really -*- C++ -*- +// WARNING: This file is obsolete. Use ../SLList.cc, if you can. +/* +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 +#include +#include +#include ".SLList.h" + +void SLList::error(const char* msg) +{ + (*lib_error_handler)("SLList", msg); +} + +int SLList::length() +{ + int l = 0; + SLListNode* t = last; + if (t != 0) do { ++l; t = t->tl; } while (t != last); + return l; +} + +SLList::SLList(const SLList& a) +{ + if (a.last == 0) + last = 0; + else + { + SLListNode* p = a.last->tl; + SLListNode* h = new SLListNode(p->hd); + last = h; + for (;;) + { + if (p == a.last) + { + last->tl = h; + return; + } + p = p->tl; + SLListNode* n = new SLListNode(p->hd); + last->tl = n; + last = n; + } + } +} + +SLList& SLList::operator = (const SLList& a) +{ + if (last != a.last) + { + clear(); + if (a.last != 0) + { + SLListNode* p = a.last->tl; + SLListNode* h = new SLListNode(p->hd); + last = h; + for (;;) + { + if (p == a.last) + { + last->tl = h; + break; + } + p = p->tl; + SLListNode* n = new SLListNode(p->hd); + last->tl = n; + last = n; + } + } + } + return *this; +} + +void SLList::clear() +{ + if (last == 0) + return; + + SLListNode* p = last->tl; + last->tl = 0; + last = 0; + + while (p != 0) + { + SLListNode* nxt = p->tl; + delete(p); + p = nxt; + } +} + + +Pix SLList::prepend( item) +{ + SLListNode* t = new SLListNode(item); + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + } + return Pix(t); +} + + +Pix SLList::prepend(SLListNode* t) +{ + if (t == 0) return 0; + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + } + return Pix(t); +} + + +Pix SLList::append( item) +{ + SLListNode* t = new SLListNode(item); + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + last = t; + } + return Pix(t); +} + +Pix SLList::append(SLListNode* t) +{ + if (t == 0) return 0; + if (last == 0) + t->tl = last = t; + else + { + t->tl = last->tl; + last->tl = t; + last = t; + } + return Pix(t); +} + +void SLList::join(SLList& b) +{ + SLListNode* t = b.last; + b.last = 0; + if (last == 0) + last = t; + else if (t != 0) + { + SLListNode* f = last->tl; + last->tl = t->tl; + t->tl = f; + last = t; + } +} + +Pix SLList::ins_after(Pix p, item) +{ + SLListNode* u = (SLListNode*)p; + SLListNode* t = new SLListNode(item); + if (last == 0) + t->tl = last = t; + else if (u == 0) // ins_after 0 means prepend + { + t->tl = last->tl; + last->tl = t; + } + else + { + t->tl = u->tl; + u->tl = t; + if (u == last) + last = t; + } + return Pix(t); +} + + +void SLList::del_after(Pix p) +{ + SLListNode* u = (SLListNode*)p; + if (last == 0 || u == last) error("cannot del_after last"); + if (u == 0) u = last; // del_after 0 means delete first + SLListNode* t = u->tl; + if (u == t) + last = 0; + else + { + u->tl = t->tl; + if (last == t) + last = u; + } + delete t; +} + +int SLList::owns(Pix p) +{ + SLListNode* t = last; + if (t != 0 && p != 0) + { + do + { + if (Pix(t) == p) return 1; + t = t->tl; + } while (t != last); + } + return 0; +} + + SLList::remove_front() +{ + if (last == 0) error("remove_front of empty list"); + SLListNode* t = last->tl; + res = t->hd; + if (t == last) + last = 0; + else + last->tl = t->tl; + delete t; + return res; +} + +int SLList::remove_front(& x) +{ + if (last == 0) + return 0; + else + { + SLListNode* t = last->tl; + x = t->hd; + if (t == last) + last = 0; + else + last->tl = t->tl; + delete t; + return 1; + } +} + + +void SLList::del_front() +{ + if (last == 0) error("del_front of empty list"); + SLListNode* t = last->tl; + if (t == last) + last = 0; + else + last->tl = t->tl; + delete t; +} + +int SLList::OK() +{ + int v = 1; + if (last != 0) + { + SLListNode* t = last; + long count = LONG_MAX; // Lots of chances to find last! + do + { + count--; + t = t->tl; + } while (count > 0 && t != last); + v &= count > 0; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SLList.hP b/gnu/lib/libg++/libg++/src/gen/SLList.hP new file mode 100644 index 00000000000..cd89dee3309 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLList.hP @@ -0,0 +1,137 @@ +// This may look like C code, but it is really -*- C++ -*- +// WARNING: This file is obsolete. Use ../SLList.h, if you can. +/* +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. +*/ + + +#ifndef _SLList_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SLList_h 1 + +#include +#include ".defs.h" + +#ifndef _SLListNode_h +#define _SLListNode_h 1 + +struct SLListNode +{ + SLListNode* tl; + hd; + SLListNode() { } + SLListNode(const h, SLListNode* t = 0); + ~SLListNode() { } +}; + + +inline SLListNode::SLListNode(const h, SLListNode* t) +:tl(t), hd(h) {} + +typedef SLListNode* SLListNodePtr; + +#endif + + +class SLList +{ +protected: + SLListNode* last; + +public: + SLList(); + SLList(const SLList& a); + ~SLList(); + + SLList& operator = (const SLList& a); + + int empty(); + int length(); + + void clear(); + + Pix prepend( item); + Pix append( item); + + void join(SLList&); + + Pix prepend(SLListNode*); + Pix append(SLListNode*); + + & operator () (Pix p); + Pix first(); + void next(Pix& p); + int owns(Pix p); + Pix ins_after(Pix p, item); + void del_after(Pix p); + + & front(); + & rear(); + remove_front(); + int remove_front(& x); + void del_front(); + + void error(const char* msg); + int OK(); +}; + +inline SLList::~SLList() +{ + clear(); +} + +inline SLList::SLList() +{ + last = 0; +} + +inline int SLList::empty() +{ + return last == 0; +} + + +inline Pix SLList::first() +{ + return (last == 0)? 0 : Pix(last->tl); +} + +inline void SLList::next(Pix& p) +{ + p = (p == 0 || p == last)? 0 : Pix(((SLListNode*)(p))->tl); +} + +inline & SLList::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return ((SLListNode*)(p))->hd; +} + +inline & SLList::front() +{ + if (last == 0) error("front: empty list"); + return last->tl->hd; +} + +inline & SLList::rear() +{ + if (last == 0) error("rear: empty list"); + return last->hd; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SLQueue.ccP b/gnu/lib/libg++/libg++/src/gen/SLQueue.ccP new file mode 100644 index 00000000000..8a5935b7757 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLQueue.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".SLQueue.h" diff --git a/gnu/lib/libg++/libg++/src/gen/SLQueue.hP b/gnu/lib/libg++/libg++/src/gen/SLQueue.hP new file mode 100644 index 00000000000..84683b85a2c --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLQueue.hP @@ -0,0 +1,108 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + +#ifndef _SLQueue_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SLQueue_h + +#include ".SLList.h" +#include ".Queue.h" + +class SLQueue : public Queue +{ + SLList p; + +public: + SLQueue(); + SLQueue(const SLQueue& q); + inline ~SLQueue(); + + void operator = (const SLQueue&); + + inline void enq( item); + inline deq(); + inline & front(); + inline void del_front(); + + inline void clear(); + inline int empty(); + inline int full(); + inline int length(); + + inline int OK(); +}; + +inline SLQueue::SLQueue() :p() {} +inline SLQueue::SLQueue(const SLQueue& q) : p(q.p) {} + +inline SLQueue::~SLQueue() {} + +inline void SLQueue::enq(item) +{ + p.append(item); +} + +inline SLQueue::deq() +{ + return p.remove_front(); +} + +inline & SLQueue::front() +{ + return p.front(); +} + + +inline void SLQueue::del_front() +{ + p.del_front(); +} + +inline void SLQueue::operator =(const SLQueue& s) +{ + p = s.p; +} + +inline int SLQueue::empty() +{ + return p.empty(); +} + +inline int SLQueue::full() +{ + return 0; +} + +inline int SLQueue::length() +{ + return p.length(); +} + +inline int SLQueue::OK() +{ + return p.OK(); +} + +inline void SLQueue::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SLSet.ccP b/gnu/lib/libg++/libg++/src/gen/SLSet.ccP new file mode 100644 index 00000000000..7d2ac58d087 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLSet.ccP @@ -0,0 +1,77 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".SLSet.h" + +int SLSet::OK() +{ + int v = p.OK(); + v &= count == p.length(); + if (!v) error("invariant failure"); + return v; +} + +Pix SLSet::seek( item) +{ + Pix i; + for (i = p.first(); i != 0 && !EQ(p(i),item); p.next(i)); + return i; +} + +Pix SLSet::add( item) +{ + Pix i = seek(item); + if (i == 0) + { + ++count; + i = p.append(item); + } + return i; +} + +void SLSet::del( item) +{ + Pix i = p.first(); + if (i == 0) + return; + else if (EQ(p(i), item)) + { + --count; + p.del_front(); + } + else + { + Pix trail = i; + p.next(i); + while (i != 0) + { + if (EQ(p(i), item)) + { + --count; + p.del_after(trail); + return; + } + trail = i; + p.next(i); + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/gen/SLSet.hP b/gnu/lib/libg++/libg++/src/gen/SLSet.hP new file mode 100644 index 00000000000..fa94bb891ba --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLSet.hP @@ -0,0 +1,87 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SLSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SLSet_h 1 + +#include ".Set.h" +#include ".SLList.h" + +class SLSet : public Set +{ +protected: + SLList p; + +public: + SLSet(); + SLSet(const SLSet&); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item); + + int OK(); +}; + +inline SLSet::SLSet() : p() { count = 0; } + +inline SLSet::SLSet(const SLSet& s) : p(s.p) { count = s.count; } + +inline Pix SLSet::first() +{ + return p.first(); +} + +inline void SLSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & SLSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void SLSet::clear() +{ + count = 0; p.clear(); +} + +inline int SLSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int SLSet::owns (Pix idx) +{ + return p.owns(idx); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SLStack.ccP b/gnu/lib/libg++/libg++/src/gen/SLStack.ccP new file mode 100644 index 00000000000..3996b41fac5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLStack.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".SLStack.h" diff --git a/gnu/lib/libg++/libg++/src/gen/SLStack.hP b/gnu/lib/libg++/libg++/src/gen/SLStack.hP new file mode 100644 index 00000000000..466cfee53b4 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SLStack.hP @@ -0,0 +1,109 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SLStack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SLStack_h 1 + +#include ".SLList.h" +#include ".Stack.h" + +class SLStack : public Stack +{ + SLList p; + +public: + SLStack(); + SLStack(const SLStack& s); + inline ~SLStack(); + + void operator = (const SLStack&); + + inline void push( item); + inline pop(); + inline & top(); + inline void del_top(); + + inline int empty(); + inline int full(); + inline int length(); + + inline void clear(); + + inline int OK(); + +}; + +inline SLStack::SLStack() :p() {} +inline SLStack::SLStack(const SLStack& a) : p(a.p) {} +inline SLStack::~SLStack() {} + +inline void SLStack::push( item) +{ + p.prepend(item); +} + +inline SLStack::pop() +{ + return p.remove_front(); +} + +inline & SLStack::top() +{ + return p.front(); +} + +inline void SLStack::del_top() +{ + p.del_front(); +} + +inline void SLStack::operator =(const SLStack& s) +{ + p = s.p; +} + +inline int SLStack::empty() +{ + return p.empty(); +} + +inline int SLStack::full() +{ + return 0; +} + +inline int SLStack::length() +{ + return p.length(); +} + +inline int SLStack::OK() +{ + return p.OK(); +} + +inline void SLStack::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Set.ccP b/gnu/lib/libg++/libg++/src/gen/Set.ccP new file mode 100644 index 00000000000..b072339158d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Set.ccP @@ -0,0 +1,117 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".Set.h" + + +Pix Set::seek( item) +{ + Pix i; + for (i = first(); i != 0 && !(EQ((*this)(i), item)); next(i)); + return i; +} + +int Set::owns(Pix idx) +{ + if (idx == 0) return 0; + for (Pix i = first(); i; next(i)) if (i == idx) return 1; + return 0; +} + +void Set::clear() +{ + Pix i = first(); + while (i != 0) + { + del((*this)(i)); + i = first(); + } +} + +int Set::contains ( item) +{ + return seek(item) != 0; +} + +int Set::operator <= (Set& b) +{ + if (count > b.count) return 0; + if (count == 0) return 1; + for (Pix i = first(); i; next(i)) if (b.seek((*this)(i)) == 0) return 0; + return 1; +} + +int Set::operator == (Set& b) +{ + int n = count; + if (n != b.count) return 0; + if (n == 0) return 1; + Pix i = first(); + Pix j = b.first(); + while (n-- > 0) + { + if ((b.seek((*this)(i)) == 0) || (seek(b(j)) == 0)) return 0; + next(i); + b.next(j); + } + return 1; +} + +int Set::operator != (Set& b) +{ + return !(*this == b); +} + +void Set::operator |= (Set& b) +{ + if (&b != this) + for (Pix i = b.first(); i; b.next(i)) add(b(i)); +} + +void Set::operator -= (Set& b) +{ + if (&b == this) + clear(); + else + for (Pix i = b.first(); i; b.next(i)) del(b(i)); +} + + +void Set::operator &= (Set& b) +{ + if (&b != this) + { + Pix i = first(); + Pix n = i; + while (i != 0) + { + next(n); + if (b.seek((*this)(i)) == 0) del((*this)(i)); + i = n; + } + } +} + +void Set::error(const char* msg) +{ + (*lib_error_handler)("Set", msg); +} diff --git a/gnu/lib/libg++/libg++/src/gen/Set.hP b/gnu/lib/libg++/libg++/src/gen/Set.hP new file mode 100644 index 00000000000..8dd99e574ca --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Set.hP @@ -0,0 +1,78 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Set_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Set_h 1 + +#include +#include ".defs.h" + +class Set +{ +protected: + + int count; + +public: + inline virtual ~Set(); + + int length(); // current number of items + int empty(); + + virtual Pix add( item) = 0; // add item; return Pix + virtual void del( item) = 0; // delete item + virtual int contains( item); // is item in set? + + virtual void clear(); // delete all items + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual & operator () (Pix i) = 0; // access item at i + + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek( item); // Pix of item + + void operator |= (Set& b); // add all items in b + void operator -= (Set& b); // delete items also in b + void operator &= (Set& b); // delete items not in b + + int operator == (Set& b); + int operator != (Set& b); + int operator <= (Set& b); + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + +inline Set::~Set() {} + +inline int Set::length() +{ + return count; +} + +inline int Set::empty() +{ + return count == 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SkipBag.ccP b/gnu/lib/libg++/libg++/src/gen/SkipBag.ccP new file mode 100644 index 00000000000..9711d85c095 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipBag.ccP @@ -0,0 +1,322 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* +Copyright (C) 1991 Free Software Foundation + +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. +*/ + +/* + * Bags implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +#include +#include +#include ".SkipBag.h" + +MLCG* SkipBag::gen = 0; +int SkipBaginit::count = 0; + +static int countbits(long bits) +{ + int n = 0; + while(bits>>=1L) n++; + return n; +} + +SkipBag::SkipBag(long size) +: level(0), + header(new SkipBagNode (countbits(size)+1)), + max_levels (countbits(size)+1), + random_bits(gen->asLong()), + randoms_left(BITS_IN_RANDOM / 2) +{ + SkipBagNodePtr *buffer_start = header->forward; + SkipBagNodePtr *trav = &header->forward[max_levels]; + + count = 0; + while (trav > buffer_start) + *--trav = (SkipBagNodePtr) header; +} + +SkipBag::SkipBag(SkipBag& b) +: level (0), + header (new SkipBagNode (b.max_levels)), + max_levels (b.max_levels), + random_bits (gen->asLong()), + randoms_left (BITS_IN_RANDOM / 2) +{ + SkipBagNodePtr *buffer_start = header->forward; + SkipBagNodePtr *trav = &header->forward[max_levels]; + + count = 0; + + while (trav > buffer_start) + *--trav = (SkipBagNodePtr)header; + + for (SkipBagNodePtr t = b.leftmost(); t; t = b.succ(t)) + add(t->item); +} + +Pix SkipBag::add ( item) +{ + SkipBagNodePtr *update = new SkipBagNodePtr[max_levels+1]; + SkipBagNodePtr curr = (SkipBagNodePtr) this->header; + int l = level; + SkipBagNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, item) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if ((l = random_level ()) > level) + { + l = ++level; + update[l] = (SkipBagNodePtr)header; + }; + + temp = new RealSkipBagNode (item, l); + SkipBagNodePtr *temp_forward = temp->forward; + + do + { + SkipBagNodePtr *curr_forward = update[l]->forward; + + temp_forward[l] = curr_forward[l]; + curr_forward[l] = temp; + } + while (--l >= 0); + + count++; + delete update; + return Pix(temp); +} + +void SkipBag::del( key) +{ + + int l = level; + int curr_level = level; + SkipBagNodePtr *update = new SkipBagNodePtr[max_levels+1]; + SkipBagNodePtr curr = (SkipBagNodePtr)header; + SkipBagNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header + && CMP(temp->item,key) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if (CMP(temp->item,key)==0) + { + SkipBagNodePtr *temp_forward = temp->forward; + + for (l = 0; + l <= curr_level && (curr = update[l])->forward[l] == temp; + l++) + curr->forward[l] = temp_forward[l]; + + delete temp; + + SkipBagNodePtr *forward = header->forward; + + while (forward[curr_level]==header && curr_level > 0) + curr_level--; + + level = curr_level; + count--; + delete update; + return; + } +} + +SkipBagNodePtr SkipBag::rightmost() +{ + SkipBagNodePtr temp; + SkipBagNode* curr = header; + int l = level; + + do + while ((temp = curr->forward[l])!=header) + curr = temp; + while (--l >= 0); + + return temp==header ? 0 : temp; +} + +SkipBagNodePtr SkipBag::pred(SkipBagNodePtr t) +{ + SkipBagNodePtr temp, curr = (SkipBagNodePtr) header; + int l = level; + + do + while ((temp = curr->forward[l])!=t) + curr = temp; + while (--l >= 0); + + return curr == header ? 0 : curr; +} + +void SkipBag::_kill() +{ + SkipBagNode *p = this->header->forward[0]; + + while (p != header) + { + SkipBagNodePtr q = p->forward[0]; + delete p; + p = q; + } +} + +void SkipBag::clear() +{ + SkipBagNodePtr *buffer_start = header->forward; + SkipBagNodePtr *trav = &header->forward[level+1]; + _kill(); + count = 0; + + while (trav > buffer_start) + *--trav = (SkipBagNodePtr)header; +} + +Pix SkipBag::seek( key, Pix i) +{ + SkipBagNodePtr temp; + SkipBagNode *curr = header; + int l = level; + if (i) + curr = (SkipBagNode *)i; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, key) < 0) + curr = temp; + } + while (--l >= 0); + + if (CMP(temp->item, key) != 0) + return 0; + else + { + return Pix(temp); + } +} + + +int SkipBag::nof( item) +{ + int n = 0; + SkipBagNodePtr t = (SkipBagNodePtr)(seek(item)); + if (t != 0) + { + do + { + ++n; + t = succ(t); + } while (t != 0 && EQ(item, t->item)); + } + return n; +} + +void SkipBag::remove( key) +{ + Pix t = seek(key); + while (t != 0) + { + del(key); + t = seek(key); + } +} + + +/* + * random function for probabilistic balancing + * + * Hardwired for p = .25. Not too flexible, + * but fast. Changing this would require a constructor + * that would accept a different value for p, etc. + * Perhaps someone else would like to implement this? + * + */ +int SkipBag::random_level (void) +{ + int rlevel = 0; + int b; + + do + { + b = random_bits & 3L; + if (!b) + rlevel++; + random_bits >>= 2; + if (--randoms_left == 0) + { + random_bits = gen->asLong(); + randoms_left = BITS_IN_RANDOM / 2; + }; + } + while (!b); + + return rlevel > max_levels ? max_levels : rlevel; +} + +int SkipBag::OK() +{ + int v = 1; + if (header == 0) + v = 0; + else + { + int n = 0; + SkipBagNodePtr trail = leftmost(); + SkipBagNodePtr t = 0; + if (trail) t = succ(trail); + if (t) n++; + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} + +SkipBaginit::SkipBaginit() +{ + if (!count) + SkipBag::gen = new MLCG(time(0)); + count++; +} + +SkipBaginit::~SkipBaginit() +{ + count--; + if (!count) + delete SkipBag::gen; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SkipBag.hP b/gnu/lib/libg++/libg++/src/gen/SkipBag.hP new file mode 100644 index 00000000000..647711de373 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipBag.hP @@ -0,0 +1,171 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1991 Free Software Foundation + +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. +*/ + +/* + * Bags implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +#ifndef _SkipBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SkipBag_h 1 + +#include ".Bag.h" + +#include +#include + +class SkipBag; +class RealSkipBagNode; + +class SkipBagNode +{ +friend class SkipBag; + private: + RealSkipBagNode * * forward; + SkipBagNode(int size); +}; + +class RealSkipBagNode : public SkipBagNode +{ +friend class SkipBag; + private: + item; + RealSkipBagNode( h, int size); +}; + +typedef RealSkipBagNode* SkipBagNodePtr; + +inline SkipBagNode::SkipBagNode(int size) +: forward(new SkipBagNodePtr[size+1]) +{ +} + +inline RealSkipBagNode::RealSkipBagNode( h, int size) +: item(h), + SkipBagNode(size) +{ +} + +class SkipBag : public Bag +{ +friend class SkipBaginit; + protected: + SkipBagNode* header; + int level; + int max_levels; + int randoms_left; + long random_bits; + + static MLCG* gen; + int random_level(void); + + SkipBagNodePtr leftmost(void); + SkipBagNodePtr rightmost(void); + SkipBagNodePtr pred(SkipBagNodePtr t); + SkipBagNodePtr succ(SkipBagNodePtr t); + void _kill(void); + + private: + enum { BITS_IN_RANDOM = LONGBITS-1 }; + + public: + SkipBag(long size=DEFAULT_INITIAL_CAPACITY); + SkipBag(SkipBag& a); + ~SkipBag(void); + + Pix add( i); + void del( i); + void remove(i); + int nof( i); + int contains( i); + + void clear(void); + + Pix first(void); + void next(Pix& i); + & operator () (Pix i); + Pix seek( i, Pix from = 0); + + Pix last(void); + void prev(Pix& i); + + int OK(void); +}; + +inline SkipBagNodePtr SkipBag::leftmost(void) +{ + return header->forward[0]; +} + +inline SkipBagNodePtr SkipBag::succ(SkipBagNodePtr t) +{ + SkipBagNodePtr result = 0; + if (t->forward[0]!=header) result = t->forward[0]; + return result; +} + +inline Pix SkipBag::first(void) +{ + return Pix(leftmost()); +} + +inline Pix SkipBag::last(void) +{ + return Pix(rightmost()); +} + +inline void SkipBag::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SkipBagNodePtr)i)); +} + +inline & SkipBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SkipBagNodePtr)i)->item; +} + +inline void SkipBag::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SkipBagNodePtr)i)); +} + +inline int SkipBag::contains( key) +{ + return seek(key) != 0; +} + +inline SkipBag::~SkipBag() +{ + _kill(); + delete header; +} + +static class SkipBaginit +{ + public: + SkipBaginit(); + ~SkipBaginit(); + private: + static int count; +} skipBaginit; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SkipMap.ccP b/gnu/lib/libg++/libg++/src/gen/SkipMap.ccP new file mode 100644 index 00000000000..1d86ad4e303 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipMap.ccP @@ -0,0 +1,307 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1991 Free Software Foundation + +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 +#include +#include "..SkipMap.h" + +/* + * Bags implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +MLCG* SkipMap::gen = 0; +int SkipMapinit::count = 0; + +static int countbits(long bits) +{ + int n = 0; + while(bits>>=1) n++; + return n; +} + +SkipMap::SkipMap( dflt, long size) +: Map(dflt), + level(0), + header(new SkipMapNode (countbits(size)+1)), + max_levels (countbits(size)+1), + random_bits(gen->asLong()), + randoms_left(BITS_IN_RANDOM / 2) +{ + SkipMapNodePtr *buffer_start = header->forward; + SkipMapNodePtr *trav = &header->forward[max_levels]; + + count = 0; + while (trav > buffer_start) + *--trav = (SkipMapNodePtr) header; +} + +SkipMap::SkipMap(SkipMap& b) +: Map(b.def), + level (0), + header (new SkipMapNode (b.max_levels)), + max_levels (b.max_levels), + random_bits (gen->asLong()), + randoms_left (BITS_IN_RANDOM / 2) +{ + SkipMapNodePtr *buffer_start = header->forward; + SkipMapNodePtr *trav = &header->forward[max_levels]; + + count = 0; + + while (trav > buffer_start) + *--trav = (SkipMapNodePtr)header; + + for (SkipMapNodePtr t = b.leftmost(); t; t = b.succ(t)) + (*this)[t->item] = t->cont; +} + +& SkipMap::operator [] ( item) +{ + SkipMapNodePtr *update = new SkipMapNodePtr[max_levels+1]; + SkipMapNodePtr curr = + (SkipMapNodePtr) this->header; + int l = level; + SkipMapNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, item) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if (temp != header && CMP(temp->item, item) == 0) + { + delete update; + return temp->cont; + } + + if ((l = random_level ()) > level) + { + l = ++level; + update[l] = (SkipMapNodePtr)header; + }; + + temp = new RealSkipMapNode (item, def, l); + SkipMapNodePtr *temp_forward = temp->forward; + + do + { + SkipMapNodePtr *curr_forward = update[l]->forward; + + temp_forward[l] = curr_forward[l]; + curr_forward[l] = temp; + } + while (--l >= 0); + + count++; + delete update; + return temp->cont; +} + +void SkipMap::del( key) +{ + + int l = level; + int curr_level = level; + SkipMapNodePtr *update = new SkipMapNodePtr[max_levels+1]; + SkipMapNodePtr curr = (SkipMapNodePtr)header; + SkipMapNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header + && CMP(temp->item,key) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if (CMP(temp->item,key)==0) + { + SkipMapNodePtr *temp_forward = temp->forward; + + for (l = 0; + l <= curr_level && (curr = update[l])->forward[l] == temp; + l++) + curr->forward[l] = temp_forward[l]; + + delete temp; + + SkipMapNodePtr *forward = header->forward; + + while (forward[curr_level]==header && curr_level > 0) + curr_level--; + + level = curr_level; + count--; + delete update; + return; + } +} + +SkipMapNodePtr SkipMap::rightmost() +{ + SkipMapNodePtr temp; + SkipMapNode* curr = header; + int l = level; + + do + while ((temp = curr->forward[l])!=header) + curr = temp; + while (--l >= 0); + + return temp==header ? 0 : temp; +} + +SkipMapNodePtr SkipMap::pred(SkipMapNodePtr t) +{ + SkipMapNodePtr temp, curr = (SkipMapNodePtr) header; + int l = level; + + do + while ((temp = curr->forward[l])!=t) + curr = temp; + while (--l >= 0); + + return curr == header ? 0 : curr; +} + +void SkipMap::_kill() +{ + SkipMapNode *p = this->header->forward[0]; + + while (p != header) + { + SkipMapNodePtr q = p->forward[0]; + delete p; + p = q; + } +} + +void SkipMap::clear() +{ + SkipMapNodePtr *buffer_start = header->forward; + SkipMapNodePtr *trav = &header->forward[level+1]; + _kill(); + count = 0; + + while (trav > buffer_start) + *--trav = (SkipMapNodePtr)header; +} + +Pix SkipMap::seek( key) +{ + SkipMapNodePtr temp; + SkipMapNode *curr = header; + int l = level; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, key) < 0) + curr = temp; + } + while (--l >= 0); + + if (CMP(temp->item, key) != 0) + return 0; + else + { + return Pix(temp); + } +} + +/* + * random function for probabilistic balancing + * + * Hardwired for p = .25. Not too flexible, + * but fast. Changing this would require a constructor + * that would accept a different value for p, etc. + * Perhaps someone else would like to implement this? + * + */ +int SkipMap::random_level (void) +{ + int rlevel = 0; + int b; + + do + { + b = random_bits & 3L; + if (!b) + rlevel++; + random_bits >>= 2; + if (--randoms_left == 0) + { + random_bits = gen->asLong(); + randoms_left = BITS_IN_RANDOM / 2; + }; + } + while (!b); + + return rlevel > max_levels ? max_levels : rlevel; +} + +int SkipMap::OK() +{ + int v = 1; + if (header == 0) + v = 0; + else + { + int n = 0; + SkipMapNodePtr trail = leftmost(); + SkipMapNodePtr t = 0; + if (trail) t = succ(trail); + if (t) n++; + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} + +SkipMapinit::SkipMapinit() +{ + if (!count) + SkipMap::gen = new MLCG(time(0)); + count++; +} + +SkipMapinit::~SkipMapinit() +{ + count--; + if (!count) + delete SkipMap::gen; +} + + diff --git a/gnu/lib/libg++/libg++/src/gen/SkipMap.hP b/gnu/lib/libg++/libg++/src/gen/SkipMap.hP new file mode 100644 index 00000000000..8b48cf9da85 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipMap.hP @@ -0,0 +1,176 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1991 Free Software Foundation + +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. +*/ + +/* + * Bags implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +#ifndef _SkipMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SkipMap_h 1 + +#include "..Map.h" + +#include +#include + +class SkipMap; +class RealSkipMapNode; + +class SkipMapNode +{ +friend class SkipMap; + private: + RealSkipMapNode * * forward; + protected: + SkipMapNode(int size); +}; + +class RealSkipMapNode : public SkipMapNode +{ +friend class SkipMap; + private: + item; + cont; + RealSkipMapNode( h, i, int size); +}; + +typedef RealSkipMapNode* SkipMapNodePtr; + +inline SkipMapNode::SkipMapNode(int size) +: forward(new SkipMapNodePtr[size+1]) +{ +} + +inline RealSkipMapNode::RealSkipMapNode( h, i, int size) +: item(h), cont(i), + SkipMapNode(size) +{ +} + +class SkipMap : public Map +{ +friend class SkipMapinit; + protected: + SkipMapNode* header; + int level; + int max_levels; + int randoms_left; + long random_bits; + + static MLCG* gen; + int random_level(void); + + SkipMapNodePtr leftmost(); + SkipMapNodePtr rightmost(); + SkipMapNodePtr pred(SkipMapNodePtr t); + SkipMapNodePtr succ(SkipMapNodePtr t); + void _kill(); + private: + enum { BITS_IN_RANDOM = LONGBITS-1 }; + + public: + SkipMap( dflt, long size=DEFAULT_INITIAL_CAPACITY); + SkipMap(SkipMap& a); + ~SkipMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + & key(Pix i); + & contents(Pix i); + + Pix seek( key); + int contains( key); + void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +inline SkipMap::~SkipMap() +{ + _kill(); + delete header; +} + +inline SkipMapNodePtr SkipMap::leftmost() +{ + return header->forward[0]==header ? 0 : header->forward[0]; +} + +inline Pix SkipMap::first() +{ + return Pix(leftmost()); +} + +inline Pix SkipMap::last() +{ + return Pix(rightmost()); +} + +inline SkipMapNodePtr SkipMap::succ(SkipMapNodePtr t) +{ + return t->forward[0]==header ? 0 : t->forward[0]; +} + +inline void SkipMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SkipMapNodePtr)i)); +} + +inline void SkipMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SkipMapNodePtr)i)); +} + +inline & SkipMap::key (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SkipMapNodePtr)i)->item; +} + +inline & SkipMap::contents (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SkipMapNodePtr)i)->cont; +} + +inline int SkipMap::contains( key) +{ + return seek(key) != 0; +} + +static class SkipMapinit +{ + public: + SkipMapinit(); + ~SkipMapinit(); + private: + static int count; +} skipMapinit; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SkipSet.ccP b/gnu/lib/libg++/libg++/src/gen/SkipSet.ccP new file mode 100644 index 00000000000..97525be8830 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipSet.ccP @@ -0,0 +1,395 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1991 Free Software Foundation + +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. +*/ + +/* + * Sets implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +#include +#include + +#include ".SkipSet.h" + +MLCG* SkipSet::gen = 0; +int SkipSetinit::count = 0; + +static int countbits(long bits) +{ + int n = 0; + while(bits>>=1L) n++; + return n; +} + +SkipSet::SkipSet(long size) +: level(0), + header(new SkipSetNode (countbits(size)+1)), + max_levels (countbits(size)+1), + random_bits(gen->asLong()), + randoms_left(BITS_IN_RANDOM / 2) +{ + SkipSetNodePtr *buffer_start = header->forward; + SkipSetNodePtr *trav = &header->forward[max_levels]; + + count = 0; + while (trav > buffer_start) + *--trav = (SkipSetNodePtr) header; +} + +SkipSet::SkipSet(SkipSet& b) +: level (0), + header (new SkipSetNode (b.max_levels)), + max_levels (b.max_levels), + random_bits (gen->asLong()), + randoms_left (BITS_IN_RANDOM / 2) +{ + SkipSetNodePtr *buffer_start = header->forward; + SkipSetNodePtr *trav = &header->forward[max_levels]; + + count = 0; + + while (trav > buffer_start) + *--trav = (SkipSetNodePtr)header; + + for (SkipSetNodePtr t = b.leftmost(); t; t = b.succ(t)) + add(t->item); +} + +/* relationals */ + +int SkipSet::operator == (SkipSet& y) +{ + if (count != y.count) + return 0; + else + { + SkipSetNodePtr t = leftmost(); + SkipSetNodePtr u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (!EQ(t->item, u->item)) + return 0; + else + { + t = succ(t); + u = y.succ(u); + } + } + } +} + +int SkipSet::operator <= (SkipSet& y) +{ + if (count > y.count) + return 0; + else + { + SkipSetNodePtr t = leftmost(); + SkipSetNodePtr u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (u == 0) + return 0; + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + return 0; + else + u = y.succ(u); + } + } +} + + +void SkipSet::operator |=(SkipSet& y) +{ + if (&y == this) return; + SkipSetNodePtr u = y.leftmost(); + while (u != 0) + { + add(u->item); + u = y.succ(u); + } +} + +void SkipSet::operator &= (SkipSet& y) +{ + if (y.count == 0) + clear(); + else if (&y != this && count != 0) + { + SkipSetNodePtr t = leftmost(); + while (t != 0) + { + SkipSetNodePtr s = succ(t); + if (y.seek(t->item) == 0) del(t->item); + t = s; + } + } +} + + +void SkipSet::operator -=(SkipSet& y) +{ + if (&y == this) + clear(); + else if (y.count != 0) + { + SkipSetNodePtr t = leftmost(); + while (t != 0) + { + SkipSetNodePtr s = succ(t); + if (y.seek(t->item) != 0) del(t->item); + t = s; + } + } +} + +Pix SkipSet::add ( i) +{ + SkipSetNodePtr *update = new SkipSetNodePtr[max_levels+1]; + SkipSetNodePtr curr = (SkipSetNodePtr) this->header; + int l = level; + SkipSetNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, i) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if (temp != header && CMP(temp->item, i) == 0) + return Pix(temp); + + if ((l = random_level ()) > level) + { + l = ++level; + update[l] = (SkipSetNodePtr)header; + }; + + temp = new RealSkipSetNode (i, l); + SkipSetNodePtr *temp_forward = temp->forward; + + do + { + SkipSetNodePtr *curr_forward = update[l]->forward; + + temp_forward[l] = curr_forward[l]; + curr_forward[l] = temp; + } + while (--l >= 0); + + count++; + delete update; + return Pix(temp); +} + +void SkipSet::del( key) +{ + + int l = level; + int curr_level = level; + SkipSetNodePtr *update = new SkipSetNodePtr[max_levels+1]; + SkipSetNodePtr curr = (SkipSetNodePtr)header; + SkipSetNodePtr temp; + + do + { + while ((temp = curr->forward[l])!=header + && CMP(temp->item,key) < 0) + curr = temp; + update[l] = curr; + } + while (--l >= 0); + + if (CMP(temp->item,key)==0) + { + SkipSetNodePtr *temp_forward = temp->forward; + + for (l = 0; + l <= curr_level && (curr = update[l])->forward[l] == temp; + l++) + curr->forward[l] = temp_forward[l]; + + delete temp; + + SkipSetNodePtr *forward = header->forward; + + while (forward[curr_level]==header && curr_level > 0) + curr_level--; + + level = curr_level; + count--; + delete update; + return; + } +} + +SkipSetNodePtr SkipSet::rightmost() +{ + SkipSetNodePtr temp; + SkipSetNode* curr = header; + int l = level; + + do + while ((temp = curr->forward[l])!=header) + curr = temp; + while (--l >= 0); + + return temp==header ? 0 : temp; +} + +SkipSetNodePtr SkipSet::pred(SkipSetNodePtr t) +{ + SkipSetNodePtr temp, curr = (SkipSetNodePtr) header; + int l = level; + + do + while ((temp = curr->forward[l])!=t) + curr = temp; + while (--l >= 0); + + return curr == header ? 0 : curr; +} + +void SkipSet::_kill() +{ + SkipSetNode *p = this->header->forward[0]; + + while (p != header) + { + SkipSetNodePtr q = p->forward[0]; + delete p; + p = q; + } +} + +void SkipSet::clear() +{ + SkipSetNodePtr *buffer_start = header->forward; + SkipSetNodePtr *trav = &header->forward[level+1]; + _kill(); + count = 0; + + while (trav > buffer_start) + *--trav = (SkipSetNodePtr)header; +} + +Pix SkipSet::seek( key) +{ + SkipSetNodePtr temp; + SkipSetNode *curr = header; + int l = level; + + do + { + while ((temp = curr->forward[l])!=header && + CMP(temp->item, key) < 0) + curr = temp; + } + while (--l >= 0); + + if (CMP(temp->item, key) != 0) + return 0; + else + { + return Pix(temp); + } +} + + +/* + * random function for probabilistic balancing + * + * Hardwired for p = .25. Not too flexible, + * but fast. Changing this would require a constructor + * that would accept a different value for p, etc. + * Perhaps someone else would like to implement this? + * + */ +int SkipSet::random_level (void) +{ + int rlevel = 0; + int b; + + do + { + b = random_bits & 3L; + if (!b) + rlevel++; + random_bits >>= 2; + if (--randoms_left == 0) + { + random_bits = gen->asLong(); + randoms_left = BITS_IN_RANDOM / 2; + }; + } + while (!b); + + return rlevel > max_levels ? max_levels : rlevel; +} + +int SkipSet::OK() +{ + int v = 1; + if (header == 0) + v = 0; + else + { + int n = 0; + SkipSetNodePtr trail = leftmost(); + SkipSetNodePtr t = 0; + if (trail) t = succ(trail); + if (t) n++; + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} + +SkipSetinit::SkipSetinit() +{ + if (!count) + SkipSet::gen = new MLCG(time(0)); + count++; +} + +SkipSetinit::~SkipSetinit() +{ + count--; + if (!count) + delete SkipSet::gen; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SkipSet.hP b/gnu/lib/libg++/libg++/src/gen/SkipSet.hP new file mode 100644 index 00000000000..d4b782bbadf --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SkipSet.hP @@ -0,0 +1,187 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1991 Free Software Foundation + +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. +*/ + +/* + * Sets implemented via William Pugh SkipList algorithms. + * CACM, June 1990, p 668-676. + * + */ + +#ifndef _SkipSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SkipSet_h 1 + +#include ".Set.h" + +#include +#include + +class SkipSet; +class RealSkipSetNode; + +class SkipSetNode +{ +friend class SkipSet; + private: + RealSkipSetNode * * forward; + SkipSetNode(int size); +}; + +class RealSkipSetNode : public SkipSetNode +{ +friend class SkipSet; + private: + item; + RealSkipSetNode( h, int size); +}; + +typedef RealSkipSetNode* SkipSetNodePtr; + +inline SkipSetNode::SkipSetNode(int size) +: forward(new SkipSetNodePtr[size+1]) +{ +} + +inline RealSkipSetNode::RealSkipSetNode( h, int size) +: item(h), + SkipSetNode(size) +{ +} + +class SkipSet : public Set +{ +friend class SkipSetinit; + protected: + SkipSetNode* header; + int level; + int max_levels; + int randoms_left; + long random_bits; + + static MLCG* gen; + int random_level(void); + + SkipSetNodePtr leftmost(void); + SkipSetNodePtr rightmost(void); + SkipSetNodePtr pred(SkipSetNodePtr t); + SkipSetNodePtr succ(SkipSetNodePtr t); + void _kill(void); + + private: + enum { BITS_IN_RANDOM = LONGBITS-1 }; + public: + SkipSet(long size=DEFAULT_INITIAL_CAPACITY); + SkipSet(SkipSet& a); + ~SkipSet(); + + Pix add( i); + void del( i); + int contains( i); + + void clear(void); + + Pix first(void); + void next(Pix& i); + & operator () (Pix i); + Pix seek( i); + + Pix last(void); + void prev(Pix& i); + + void operator |= (SkipSet& b); + void operator -= (SkipSet& b); + void operator &= (SkipSet& b); + + int operator == (SkipSet& b); + int operator != (SkipSet& b); + int operator <= (SkipSet& b); + + int OK(void); +}; + +/* + * A little overkill on the inlines. + * + */ + +inline SkipSet::~SkipSet(void) +{ + _kill(); + delete header; +} + +inline int SkipSet::operator != (SkipSet& b) +{ + return ! (*this == b); +} + +inline SkipSetNodePtr SkipSet::leftmost(void) +{ + return header->forward[0]; +} + +inline SkipSetNodePtr SkipSet::succ(SkipSetNodePtr t) +{ + SkipSetNodePtr result = 0; + if (t->forward[0]!=header) result = t->forward[0]; + return result; +} + +inline Pix SkipSet::first(void) +{ + return Pix(leftmost()); +} + +inline Pix SkipSet::last(void) +{ + return Pix(rightmost()); +} + +inline void SkipSet::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SkipSetNodePtr)i)); +} + +inline void SkipSet::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SkipSetNodePtr)i)); +} + +inline & SkipSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SkipSetNodePtr)i)->item; +} + + +inline int SkipSet::contains( key) +{ + return seek(key) != 0; +} + +static class SkipSetinit +{ + public: + SkipSetinit(); + ~SkipSetinit(); + private: + static int count; +} skipSetinit; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SplayBag.ccP b/gnu/lib/libg++/libg++/src/gen/SplayBag.ccP new file mode 100644 index 00000000000..1ff1421db4d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayBag.ccP @@ -0,0 +1,445 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".SplayBag.h" + + +/* + + struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 + splay tree algorithms + + All routines use a version of their `simple top-down' splay alg. (p 669) + +*/ + +struct _dummySplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; +} _dummy_null; + + +/* + traversal primitives +*/ + + +SplayNode* SplayBag::leftmost() +{ + SplayNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +SplayNode* SplayBag::rightmost() +{ + SplayNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +SplayNode* SplayBag::succ(SplayNode* t) +{ + if (t == 0) + return 0; + if (t->rt != 0) + { + t = t->rt; + while (t->lt != 0) t = t->lt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->lt) + return t->par; + else + t = t->par; + } + } +} + +SplayNode* SplayBag::pred(SplayNode* t) +{ + if (t == 0) + return 0; + else if (t->lt != 0) + { + t = t->lt; + while (t->rt != 0) t = t->rt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->rt) + return t->par; + else + t = t->par; + } + } +} + + + +Pix SplayBag::seek( key, Pix i) +{ + if (root == 0) return 0; + + SplayNode* t = (SplayNode*) i; + if (t != 0) + { + int cmp = CMP(key, t->item); + if (cmp == 0) + { + t = succ(t); + if (t != 0 && EQ(key, t->item)) + return Pix(t); + else + return 0; + } + else if (cmp < 0) + return 0; + } + + t = root; + int comp = CMP(key, t->item); + if (comp == 0) + return Pix(t); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + break; + else + { + comp = CMP(key, tr->item); + if (comp <= 0 || tr->rt == 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + if (comp >= 0) + break; + } + else + { + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = tr->rt; + comp = CMP(key, t->item); + } + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + break; + else + { + comp = CMP(key, tl->item); + if (comp >= 0 || tl->lt == 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + if (comp <= 0) + break; + } + else + { + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tl->lt; + comp = CMP(key, t->item); + } + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + if (comp != 0) + return 0; + else + { + l = pred(t); + while (l != 0 && EQ(l->item, key)) { t = l; l = pred(l); } + return Pix(t); + } +} + +int SplayBag::nof( item) +{ + int n = 0; + SplayNode* t = (SplayNode*)(seek(item)); + if (t != 0) + { + do + { + ++n; + t = succ(t); + } while (t != 0 && EQ(item, t->item)); + } + return n; +} + +Pix SplayBag::add( item) +{ + ++count; + SplayNode* newnode = new SplayNode(item); + SplayNode* t = root; + if (t == 0) + { + root = newnode; + return Pix(root); + } + + int comp = CMP(item, t->item); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + int done = 0; + while (!done) + { + if (comp >= 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + { + tr = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tr->item); + + if (comp <= 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + } + else + { + SplayNode* trr = tr->rt; + if (trr == 0) + { + trr = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, trr->item); + + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = trr; + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + { + tl = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tl->item); + + if (comp >= 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + } + else + { + SplayNode* tll = tl->lt; + if (tll == 0) + { + tll = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tll->item); + + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tll; + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return Pix(root); +} + +void SplayBag::_del(SplayNode* t) +{ + if (t == 0) return; + + SplayNode* p = t->par; + + --count; + if (t->rt == 0) + { + if (t == root) + { + if ((root = t->lt) != 0) root->par = 0; + } + else if (t == p->lt) + { + if ((p->lt = t->lt) != 0) p->lt->par = p; + } + else + if ((p->rt = t->lt) != 0) p->rt->par = p; + } + else + { + SplayNode* r = t->rt; + SplayNode* l = r->lt; + for(;;) + { + if (l == 0) + { + if (t == root) + { + root = r; + r->par = 0; + } + else if (t == p->lt) + { + p->lt = r; + r->par = p; + } + else + { + p->rt = r; + r->par = p; + } + if ((r->lt = t->lt) != 0) r->lt->par = r; + break; + } + else + { + if ((r->lt = l->rt) != 0) r->lt->par = r; + l->rt = r; r->par = l; + r = l; + l = l->lt; + } + } + } + delete t; +} + + +void SplayBag::remove( key) +{ + SplayNode* t = (SplayNode*)(seek(key)); + while (t != 0) + { + _del(t); + t = (SplayNode*)(seek(key)); + } +} + + +void SplayBag::_kill(SplayNode* t) +{ + if (t != 0) + { + _kill(t->lt); + _kill(t->rt); + delete t; + } +} + + +SplayNode* SplayBag::_copy(SplayNode* t) +{ + if (t != 0) + { + SplayNode* l = _copy(t->lt); + SplayNode* r = _copy(t->rt); + SplayNode* x = new SplayNode(t->item, l, r); + if (l != 0) l->par = x; + if (r != 0) r->par = x; + return x; + } + else + return 0; +} + +int SplayBag::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + SplayNode* trail = leftmost(); + SplayNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) <= 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} + diff --git a/gnu/lib/libg++/libg++/src/gen/SplayBag.hP b/gnu/lib/libg++/libg++/src/gen/SplayBag.hP new file mode 100644 index 00000000000..9059d453df5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayBag.hP @@ -0,0 +1,126 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1982 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. +*/ + +#ifndef _SplayBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SplayBag_h 1 + +#include ".Bag.h" +#include ".SplayNode.h" + +class SplayBag : public Bag +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + void _del(SplayNode* t); + +public: + SplayBag(); + SplayBag(SplayBag& a); + inline ~SplayBag(); + + Pix add( item); + inline void del( item); + void remove(item); + int nof( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item, Pix from = 0); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + + +inline SplayBag::~SplayBag() +{ + _kill(root); +} + +inline SplayBag::SplayBag() +{ + root = 0; + count = 0; +} + +inline SplayBag::SplayBag(SplayBag& b) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayBag::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayBag::last() +{ + return Pix(rightmost()); +} + +inline void SplayBag::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayBag::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplayBag::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayBag::contains( key) +{ + return seek(key) != 0; +} + +inline void SplayBag::del( key) +{ + _del((SplayNode*)(seek(key))); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SplayMap.ccP b/gnu/lib/libg++/libg++/src/gen/SplayMap.ccP new file mode 100644 index 00000000000..5b9ffe96a96 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayMap.ccP @@ -0,0 +1,401 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include "..SplayMap.h" + + +/* + + struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 + splay tree algorithms + + All routines use a version of their `simple top-down' splay alg. (p 669) + +*/ + +struct _dummySplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; +} _dummy_null; + + +/* + traversal primitives +*/ + + +SplayNode* SplayMap::leftmost() +{ + SplayNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +SplayNode* SplayMap::rightmost() +{ + SplayNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +SplayNode* SplayMap::succ(SplayNode* t) +{ + if (t == 0) + return 0; + if (t->rt != 0) + { + t = t->rt; + while (t->lt != 0) t = t->lt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->lt) + return t->par; + else + t = t->par; + } + } +} + +SplayNode* SplayMap::pred(SplayNode* t) +{ + if (t == 0) + return 0; + else if (t->lt != 0) + { + t = t->lt; + while (t->rt != 0) t = t->rt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->rt) + return t->par; + else + t = t->par; + } + } +} + + +Pix SplayMap::seek( key) +{ + SplayNode* t = root; + if (t == 0) + return 0; + + int comp = CMP(key, t->item); + if (comp == 0) + return Pix(t); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + break; + else + { + comp = CMP(key, tr->item); + if (comp <= 0 || tr->rt == 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + if (comp >= 0) + break; + } + else + { + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = tr->rt; + comp = CMP(key, t->item); + } + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + break; + else + { + comp = CMP(key, tl->item); + if (comp >= 0 || tl->lt == 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + if (comp <= 0) + break; + } + else + { + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tl->lt; + comp = CMP(key, t->item); + } + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return (comp == 0) ? Pix(t) : 0; +} + + +& SplayMap::operator [] ( item) +{ + SplayNode* t = root; + if (t == 0) + { + ++count; + root = new SplayNode(item, def); + return root->cont; + } + int comp = CMP(item, t->item); + if (comp == 0) + return t->cont; + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + { + ++count; + tr = new SplayNode(item, def); + comp = 0; + } + else + comp = CMP(item, tr->item); + + if (comp <= 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + } + else + { + SplayNode* trr = tr->rt; + if (trr == 0) + { + ++count; + trr = new SplayNode(item, def); + comp = 0; + } + else + comp = CMP(item, trr->item); + + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = trr; + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + { + ++count; + tl = new SplayNode(item, def); + comp = 0; + } + else + comp = CMP(item, tl->item); + + if (comp >= 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + } + else + { + SplayNode* tll = tl->lt; + if (tll == 0) + { + ++count; + tll = new SplayNode(item, def); + comp = 0; + } + else + comp = CMP(item, tll->item); + + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tll; + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return root->cont; +} + +void SplayMap::del( key) +{ + SplayNode* t = (SplayNode*)(seek(key)); + if (t == 0) return; + + SplayNode* p = t->par; + + --count; + if (t->rt == 0) + { + if (t == root) + { + if ((root = t->lt) != 0) root->par = 0; + } + else if (t == p->lt) + { + if ((p->lt = t->lt) != 0) p->lt->par = p; + } + else + if ((p->rt = t->lt) != 0) p->rt->par = p; + } + else + { + SplayNode* r = t->rt; + SplayNode* l = r->lt; + for(;;) + { + if (l == 0) + { + if (t == root) + { + root = r; + r->par = 0; + } + else if (t == p->lt) + { + p->lt = r; + r->par = p; + } + else + { + p->rt = r; + r->par = p; + } + if ((r->lt = t->lt) != 0) r->lt->par = r; + break; + } + else + { + if ((r->lt = l->rt) != 0) r->lt->par = r; + l->rt = r; r->par = l; + r = l; + l = l->lt; + } + } + } + delete t; +} + + +void SplayMap::_kill(SplayNode* t) +{ + if (t != 0) + { + _kill(t->lt); + _kill(t->rt); + delete t; + } +} + + +SplayNode* SplayMap::_copy(SplayNode* t) +{ + if (t != 0) + { + SplayNode* l = _copy(t->lt); + SplayNode* r = _copy(t->rt); + SplayNode* x = new SplayNode(t->item, t->cont, l, r); + if (l != 0) l->par = x; + if (r != 0) r->par = x; + return x; + } + else + return 0; +} + + +int SplayMap::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + SplayNode* trail = leftmost(); + SplayNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SplayMap.hP b/gnu/lib/libg++/libg++/src/gen/SplayMap.hP new file mode 100644 index 00000000000..3acb1d4b14d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayMap.hP @@ -0,0 +1,154 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SplayMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SplayMap_h 1 + +#include "..Map.h" + +#ifndef _SplayNode +#define _SplayNode 1 + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + cont; + SplayNode( h, c, + SplayNode* l=0, + SplayNode* r=0); + ~SplayNode(); +}; + + +inline SplayNode::SplayNode( h, c, + SplayNode* l, + SplayNode* r) + :lt(l), rt(r), par(0), item(h), cont(c) {} + +inline SplayNode::~SplayNode() {} + +typedef SplayNode* SplayNodePtr; + +#endif + +class SplayMap : public Map +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplayMap( dflt); + SplayMap(SplayMap& a); + inline ~SplayMap(); + + & operator [] ( key); + + void del( key); + + inline Pix first(); + inline void next(Pix& i); + inline & key(Pix i); + inline & contents(Pix i); + + Pix seek( key); + inline int contains( key); + + inline void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + + +inline SplayMap::~SplayMap() +{ + _kill(root); +} + +inline SplayMap::SplayMap( dflt) :Map(dflt) +{ + root = 0; +} + +inline SplayMap::SplayMap(SplayMap& b) :Map(b.def) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayMap::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayMap::last() +{ + return Pix(rightmost()); +} + +inline void SplayMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayMap::key (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline & SplayMap::contents (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->cont; +} + +inline void SplayMap::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayMap::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SplayNode.ccP b/gnu/lib/libg++/libg++/src/gen/SplayNode.ccP new file mode 100644 index 00000000000..74f071140fe --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayNode.ccP @@ -0,0 +1,21 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1992 Free Software Foundation + +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 ".SplayNode.h" diff --git a/gnu/lib/libg++/libg++/src/gen/SplayNode.hP b/gnu/lib/libg++/libg++/src/gen/SplayNode.hP new file mode 100644 index 00000000000..e50ced51dcf --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayNode.hP @@ -0,0 +1,44 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1982 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. +*/ + +#ifndef _SplayNode +#define _SplayNode 1 +#ifdef __GNUG__ +#pragma interface +#endif +#include ".defs.h" + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + SplayNode( h, SplayNode* l=0, SplayNode* r=0); + ~SplayNode(); +}; + + +inline SplayNode::SplayNode( h, SplayNode* l, SplayNode* r) +:lt(l), rt(r), par(0), item(h) {} + +inline SplayNode::~SplayNode() {} + +typedef SplayNode* SplayNodePtr; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SplayPQ.ccP b/gnu/lib/libg++/libg++/src/gen/SplayPQ.ccP new file mode 100644 index 00000000000..890b9585e3a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayPQ.ccP @@ -0,0 +1,523 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".SplayPQ.h" + + +/* + + struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 + splay tree algorithms + + All routines use a version of their `simple top-down' splay alg. (p 669) + +*/ + +struct _dummySplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; +} _dummy_null; + + +/* + traversal primitives +*/ + + +SplayNode* SplayPQ::leftmost() +{ + SplayNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +SplayNode* SplayPQ::rightmost() +{ + SplayNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +SplayNode* SplayPQ::succ(SplayNode* t) +{ + if (t == 0) + return 0; + if (t->rt != 0) + { + t = t->rt; + while (t->lt != 0) t = t->lt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->lt) + return t->par; + else + t = t->par; + } + } +} + +SplayNode* SplayPQ::pred(SplayNode* t) +{ + if (t == 0) + return 0; + else if (t->lt != 0) + { + t = t->lt; + while (t->rt != 0) t = t->rt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->rt) + return t->par; + else + t = t->par; + } + } +} + + +Pix SplayPQ::seek( key) +{ + SplayNode* t = root; + if (t == 0) + return 0; + + int comp = CMP(key, t->item); + if (comp == 0) + return Pix(t); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + break; + else + { + comp = CMP(key, tr->item); + if (comp <= 0 || tr->rt == 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + if (comp >= 0) + break; + } + else + { + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = tr->rt; + comp = CMP(key, t->item); + } + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + break; + else + { + comp = CMP(key, tl->item); + if (comp >= 0 || tl->lt == 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + if (comp <= 0) + break; + } + else + { + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tl->lt; + comp = CMP(key, t->item); + } + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return (comp == 0) ? Pix(t) : 0; +} + + +Pix SplayPQ::enq( item) +{ + ++count; + SplayNode* newnode = new SplayNode(item); + SplayNode* t = root; + if (t == 0) + { + root = newnode; + return Pix(root); + } + + int comp = CMP(item, t->item); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + int done = 0; + while (!done) + { + if (comp >= 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + { + tr = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tr->item); + + if (comp <= 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + } + else + { + SplayNode* trr = tr->rt; + if (trr == 0) + { + trr = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, trr->item); + + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = trr; + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + { + tl = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tl->item); + + if (comp >= 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + } + else + { + SplayNode* tll = tl->lt; + if (tll == 0) + { + tll = newnode; + comp = 0; done = 1; + } + else + comp = CMP(item, tll->item); + + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tll; + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return Pix(root); +} + + +void SplayPQ::del(Pix pix) +{ + SplayNode* t = (SplayNode*)pix; + if (t == 0) return; + + SplayNode* p = t->par; + + --count; + if (t->rt == 0) + { + if (t == root) + { + if ((root = t->lt) != 0) root->par = 0; + } + else if (t == p->lt) + { + if ((p->lt = t->lt) != 0) p->lt->par = p; + } + else + if ((p->rt = t->lt) != 0) p->rt->par = p; + } + else + { + SplayNode* r = t->rt; + SplayNode* l = r->lt; + for(;;) + { + if (l == 0) + { + if (t == root) + { + root = r; + r->par = 0; + } + else if (t == p->lt) + { + p->lt = r; + r->par = p; + } + else + { + p->rt = r; + r->par = p; + } + if ((r->lt = t->lt) != 0) r->lt->par = r; + break; + } + else + { + if ((r->lt = l->rt) != 0) r->lt->par = r; + l->rt = r; r->par = l; + r = l; + l = l->lt; + } + } + } + delete t; +} + +& SplayPQ::front() +{ + if (root == 0) + error ("min: empty tree\n"); +// else + { + SplayNode* t = root; + SplayNode* l = root->lt; + for(;;) + { + if (l == 0) + { + root = t; + root->par = 0; + return root->item; + } + else + { + if ((t->lt = l->rt) != 0) t->lt->par = t; + l->rt = t; t->par = l; + t = l; + l = l->lt; + } + } + } +} + +void SplayPQ::del_front() +{ + if (root != 0) + { + --count; + SplayNode* t = root; + SplayNode* l = root->lt; + if (l == 0) + { + if ((root = t->rt) != 0) root->par = 0; + delete t; + } + else + { + for(;;) + { + SplayNode* ll = l->lt; + if (ll == 0) + { + if ((t->lt = l->rt) != 0) t->lt->par = t; + delete l; + break; + } + else + { + SplayNode* lll = ll->lt; + if (lll == 0) + { + if ((l->lt = ll->rt) != 0) l->lt->par = l; + delete ll; + break; + } + else + { + t->lt = ll; ll->par = t; + if ((l->lt = ll->rt) != 0) l->lt->par = l; + ll->rt = l; l->par = ll; + t = ll; + l = lll; + } + } + } + } + } +} + + SplayPQ::deq() +{ + if (root == 0) + error("deq: empty tree"); +// else + { + --count; + SplayNode* t = root; + SplayNode* l = root->lt; + if (l == 0) + { + if ((root = t->rt) != 0) root->par = 0; + res = t->item; + delete t; + return res; + } + else + { + for(;;) + { + SplayNode* ll = l->lt; + if (ll == 0) + { + if ((t->lt = l->rt) != 0) t->lt->par = t; + res = l->item; + delete l; + return res; + } + else + { + SplayNode* lll = ll->lt; + if (lll == 0) + { + if ((l->lt = ll->rt) != 0) l->lt->par = l; + res = ll->item; + delete ll; + return res; + } + else + { + t->lt = ll; ll->par = t; + if ((l->lt = ll->rt) != 0) l->lt->par = l; + ll->rt = l; l->par = ll; + t = ll; + l = lll; + } + } + } + } + } +} + + +void SplayPQ::_kill(SplayNode* t) +{ + if (t != 0) + { + _kill(t->lt); + _kill(t->rt); + delete t; + } +} + + +SplayNode* SplayPQ::_copy(SplayNode* t) +{ + if (t != 0) + { + SplayNode* l = _copy(t->lt); + SplayNode* r = _copy(t->rt); + SplayNode* x = new SplayNode(t->item, l, r); + if (l != 0) l->par = x; + if (r != 0) r->par = x; + return x; + } + else + return 0; +} + +int SplayPQ::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + SplayNode* trail = leftmost(); + SplayNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SplayPQ.hP b/gnu/lib/libg++/libg++/src/gen/SplayPQ.hP new file mode 100644 index 00000000000..1084892fc8f --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplayPQ.hP @@ -0,0 +1,123 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SplayPQ_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SplayPQ_h 1 + +#include ".PQ.h" +#include ".SplayNode.h" + +class SplayPQ : public PQ +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplayPQ(); + SplayPQ(SplayPQ& a); + inline virtual ~SplayPQ(); + + Pix enq( item); + deq(); + + & front(); + void del_front(); + + inline int contains( item); + + inline void clear(); + + inline Pix first(); + Pix last(); + inline void next(Pix& i); + void prev(Pix& i); + inline & operator () (Pix i); + void del(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + + +inline SplayPQ::~SplayPQ() +{ + _kill(root); +} + +inline SplayPQ::SplayPQ() +{ + root = 0; + count = 0; +} + +inline SplayPQ::SplayPQ(SplayPQ& b) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayPQ::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayPQ::last() +{ + return Pix(rightmost()); +} + +inline void SplayPQ::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayPQ::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayPQ::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplayPQ::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayPQ::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/SplaySet.ccP b/gnu/lib/libg++/libg++/src/gen/SplaySet.ccP new file mode 100644 index 00000000000..ebee425dbe4 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplaySet.ccP @@ -0,0 +1,499 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".SplaySet.h" + + +/* + + struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 + splay tree algorithms + + All routines use a version of their `simple top-down' splay alg. (p 669) + +*/ + +struct _dummySplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; +} _dummy_null; + + +/* + traversal primitives +*/ + + +SplayNode* SplaySet::leftmost() +{ + SplayNode* t = root; + if (t != 0) while (t->lt != 0) t = t->lt; + return t; +} + +SplayNode* SplaySet::rightmost() +{ + SplayNode* t = root; + if (t != 0) while (t->rt != 0) t = t->rt; + return t; +} + +SplayNode* SplaySet::succ(SplayNode* t) +{ + if (t == 0) + return 0; + if (t->rt != 0) + { + t = t->rt; + while (t->lt != 0) t = t->lt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->lt) + return t->par; + else + t = t->par; + } + } +} + +SplayNode* SplaySet::pred(SplayNode* t) +{ + if (t == 0) + return 0; + else if (t->lt != 0) + { + t = t->lt; + while (t->rt != 0) t = t->rt; + return t; + } + else + { + for (;;) + { + if (t->par == 0 || t == t->par->rt) + return t->par; + else + t = t->par; + } + } +} + + +Pix SplaySet::seek( key) +{ + SplayNode* t = root; + if (t == 0) + return 0; + + int comp = CMP(key, t->item); + if (comp == 0) + return Pix(t); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + break; + else + { + comp = CMP(key, tr->item); + if (comp <= 0 || tr->rt == 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + if (comp >= 0) + break; + } + else + { + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = tr->rt; + comp = CMP(key, t->item); + } + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + break; + else + { + comp = CMP(key, tl->item); + if (comp >= 0 || tl->lt == 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + if (comp <= 0) + break; + } + else + { + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tl->lt; + comp = CMP(key, t->item); + } + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return (comp == 0) ? Pix(t) : 0; +} + + + +Pix SplaySet::add( item) +{ + SplayNode* t = root; + if (t == 0) + { + ++count; + root = new SplayNode(item); + return Pix(root); + } + int comp = CMP(item, t->item); + if (comp == 0) + return Pix(t); + + SplayNode* dummy = (SplayNode*)(&_dummy_null); + SplayNode* l = dummy; + SplayNode* r = dummy; + dummy->rt = dummy->lt = dummy->par = 0; + + while (comp != 0) + { + if (comp > 0) + { + SplayNode* tr = t->rt; + if (tr == 0) + { + ++count; + tr = new SplayNode(item); + comp = 0; + } + else + comp = CMP(item, tr->item); + + if (comp <= 0) + { + l->rt = t; t->par = l; + l = t; + t = tr; + } + else + { + SplayNode* trr = tr->rt; + if (trr == 0) + { + ++count; + trr = new SplayNode(item); + comp = 0; + } + else + comp = CMP(item, trr->item); + + if ((t->rt = tr->lt) != 0) t->rt->par = t; + tr->lt = t; t->par = tr; + l->rt = tr; tr->par = l; + l = tr; + t = trr; + } + } + else + { + SplayNode* tl = t->lt; + if (tl == 0) + { + ++count; + tl = new SplayNode(item); + comp = 0; + } + else + comp = CMP(item, tl->item); + + if (comp >= 0) + { + r->lt = t; t->par = r; + r = t; + t = tl; + } + else + { + SplayNode* tll = tl->lt; + if (tll == 0) + { + ++count; + tll = new SplayNode(item); + comp = 0; + } + else + comp = CMP(item, tll->item); + + if ((t->lt = tl->rt) != 0) t->lt->par = t; + tl->rt = t; t->par = tl; + r->lt = tl; tl->par = r; + r = tl; + t = tll; + } + } + } + if ((r->lt = t->rt) != 0) r->lt->par = r; + if ((l->rt = t->lt) != 0) l->rt->par = l; + if ((t->lt = dummy->rt) != 0) t->lt->par = t; + if ((t->rt = dummy->lt) != 0) t->rt->par = t; + t->par = 0; + root = t; + return Pix(root); +} + +void SplaySet::del( key) +{ + SplayNode* t = (SplayNode*)(seek(key)); + if (t == 0) return; + + SplayNode* p = t->par; + + --count; + if (t->rt == 0) + { + if (t == root) + { + if ((root = t->lt) != 0) root->par = 0; + } + else if (t == p->lt) + { + if ((p->lt = t->lt) != 0) p->lt->par = p; + } + else + if ((p->rt = t->lt) != 0) p->rt->par = p; + } + else + { + SplayNode* r = t->rt; + SplayNode* l = r->lt; + for(;;) + { + if (l == 0) + { + if (t == root) + { + root = r; + r->par = 0; + } + else if (t == p->lt) + { + p->lt = r; + r->par = p; + } + else + { + p->rt = r; + r->par = p; + } + if ((r->lt = t->lt) != 0) r->lt->par = r; + break; + } + else + { + if ((r->lt = l->rt) != 0) r->lt->par = r; + l->rt = r; r->par = l; + r = l; + l = l->lt; + } + } + } + delete t; +} + + +void SplaySet::_kill(SplayNode* t) +{ + if (t != 0) + { + _kill(t->lt); + _kill(t->rt); + delete t; + } +} + + +SplayNode* SplaySet::_copy(SplayNode* t) +{ + if (t != 0) + { + SplayNode* l = _copy(t->lt); + SplayNode* r = _copy(t->rt); + SplayNode* x = new SplayNode(t->item, l, r); + if (l != 0) l->par = x; + if (r != 0) r->par = x; + return x; + } + else + return 0; +} + +/* relationals */ + +int SplaySet::operator == (SplaySet& y) +{ + if (count != y.count) + return 0; + else + { + SplayNode* t = leftmost(); + SplayNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (!EQ(t->item, u->item)) + return 0; + else + { + t = succ(t); + u = y.succ(u); + } + } + } +} + +int SplaySet::operator <= (SplaySet& y) +{ + if (count > y.count) + return 0; + else + { + SplayNode* t = leftmost(); + SplayNode* u = y.leftmost(); + for (;;) + { + if (t == 0) + return 1; + else if (u == 0) + return 0; + int cmp = CMP(t->item, u->item); + if (cmp == 0) + { + t = succ(t); + u = y.succ(u); + } + else if (cmp < 0) + return 0; + else + u = y.succ(u); + } + } +} + + +void SplaySet::operator |=(SplaySet& y) +{ + if (&y == this) return; + SplayNode* u = y.leftmost(); + while (u != 0) + { + add(u->item); + u = y.succ(u); + } +} + +void SplaySet::operator &= (SplaySet& y) +{ + if (y.count == 0) + clear(); + else if (&y != this && count != 0) + { + SplayNode* t = leftmost(); + while (t != 0) + { + SplayNode* s = succ(t); + if (y.seek(t->item) == 0) del(t->item); + t = s; + } + } +} + + +void SplaySet::operator -=(SplaySet& y) +{ + if (&y == this) + clear(); + else if (y.count != 0) + { + SplayNode* t = leftmost(); + while (t != 0) + { + SplayNode* s = succ(t); + if (y.seek(t->item) != 0) del(t->item); + t = s; + } + } +} + +int SplaySet::OK() +{ + int v = 1; + if (root == 0) + v = count == 0; + else + { + int n = 1; + SplayNode* trail = leftmost(); + SplayNode* t = succ(trail); + while (t != 0) + { + ++n; + v &= CMP(trail->item, t->item) < 0; + trail = t; + t = succ(t); + } + v &= n == count; + } + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/SplaySet.hP b/gnu/lib/libg++/libg++/src/gen/SplaySet.hP new file mode 100644 index 00000000000..e6935833481 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/SplaySet.hP @@ -0,0 +1,145 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _SplaySet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SplaySet_h 1 + +#include ".Set.h" +#include ".SplayNode.h" + +class SplaySet : public Set +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplaySet(); + SplaySet(SplaySet& a); + inline ~SplaySet(); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item); + + Pix last(); + void prev(Pix& i); + + SplaySet& operator = (const SplaySet& b); + void operator |= (SplaySet& b); + void operator -= (SplaySet& b); + void operator &= (SplaySet& b); + + int operator == (SplaySet& b); + int operator != (SplaySet& b); + int operator <= (SplaySet& b); + + int OK(); +}; + + +inline SplaySet::~SplaySet() +{ + _kill(root); +} + +inline SplaySet::SplaySet() +{ + root = 0; + count = 0; +} + +inline SplaySet::SplaySet(SplaySet& b) +{ + count = b.count; + root = _copy(b.root); +} + + +inline SplaySet& SplaySet::operator = (const SplaySet& b) +{ + if (this != &b) + { + _kill (root); + count = b.count; + root = _copy (b.root); + } + return *this; +} + +inline int SplaySet::operator != (SplaySet& b) +{ + return ! (*this == b); +} + +inline Pix SplaySet::first() +{ + return Pix(leftmost()); +} + +inline Pix SplaySet::last() +{ + return Pix(rightmost()); +} + +inline void SplaySet::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplaySet::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplaySet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplaySet::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplaySet::contains( key) +{ + return seek(key) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Stack.ccP b/gnu/lib/libg++/libg++/src/gen/Stack.ccP new file mode 100644 index 00000000000..efb6b8edbde --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Stack.ccP @@ -0,0 +1,11 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".Stack.h" + +Stack::~Stack() {} + +void Stack::error(const char* msg) +{ + (*lib_error_handler)("Stack", msg); +} diff --git a/gnu/lib/libg++/libg++/src/gen/Stack.hP b/gnu/lib/libg++/libg++/src/gen/Stack.hP new file mode 100644 index 00000000000..094676880fc --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Stack.hP @@ -0,0 +1,51 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Stack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Stack_h + +#include + +#include ".defs.h" + +class Stack +{ +public: + Stack() { } + virtual ~Stack(); + + virtual void push( item) = 0; + virtual pop() = 0; + virtual & top() = 0; + virtual void del_top() = 0; + + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + + virtual void clear() = 0; + + void error(const char*); + virtual int OK() = 0; +}; + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VHBag.ccP b/gnu/lib/libg++/libg++/src/gen/VHBag.ccP new file mode 100644 index 00000000000..daa8313beae --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHBag.ccP @@ -0,0 +1,264 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".VHBag.h" + +/* codes for status fields */ + +#define EMPTYCELL 0 +#define VALIDCELL 1 +#define DELETEDCELL 2 + + +VHBag::VHBag(unsigned int sz) +{ + tab = new [size = sz]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; +} + +VHBag::VHBag(VHBag& a) +{ + tab = new [size = a.size]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (Pix p = a.first(); p; a.next(p)) add(a(p)); +} + + +/* + * hashing method: double hash based on high bits of hash fct, + * followed by linear probe. Can't do too much better if table + * sizes not constrained to be prime. +*/ + + +static inline unsigned int doublehashinc(unsigned int h, unsigned int s) +{ + unsigned int dh = ((h / s) % s); + return (dh > 1)? dh : 1; +} + +Pix VHBag::seek( key, Pix p) +{ + * t = (*) p; + if (t == 0 || !EQ(*t, key)) + { + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return 0; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + return Pix(&tab[h]); + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + return 0; + } + else + { + int seent = 0; + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return 0; + else if (&tab[h] == t) + seent = 1; + else if (seent && status[h] == VALIDCELL && EQ(key, tab[h])) + return Pix(&tab[h]); + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + return 0; + } +} + +int VHBag::nof( item) +{ + int n = 0; + unsigned int hashval = HASH(item); + unsigned int h = hashval % size; + unsigned int firsth = size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return n; + else if (h != firsth && status[h] == VALIDCELL && EQ(item, tab[h])) + { + ++n; + if (firsth >= size) + firsth = h; + } + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + return n; +} + + +Pix VHBag::add( item) +{ + if (HASHTABLE_TOO_CROWDED(count, size)) + resize(); + unsigned int bestspot = size; + unsigned int hashval = HASH(item); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + { + if (bestspot >= size) bestspot = h; + tab[bestspot] = item; + status[bestspot] = VALIDCELL; + ++count; + return Pix(&tab[bestspot]); + } + else if (status[h] == DELETEDCELL) + { + if (bestspot >= size) bestspot = h; + } + + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + tab[bestspot] = item; + status[bestspot] = VALIDCELL; + ++count; + return Pix(&tab[bestspot]); +} + + +void VHBag::del( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + { + status[h] = DELETEDCELL; + --count; + return; + } + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } +} + +void VHBag::remove( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + { + status[h] = DELETEDCELL; + --count; + } + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } +} + +void VHBag::clear() +{ + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; +} + +void VHBag::resize(unsigned int newsize) +{ + if (newsize <= count) + { + newsize = DEFAULT_INITIAL_CAPACITY; + while (HASHTABLE_TOO_CROWDED(count, newsize)) newsize <<= 1; + } + * oldtab = tab; + char* oldstatus = status; + unsigned int oldsize = size; + tab = new [size = newsize]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (unsigned int i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); + delete [] oldtab; + delete oldstatus; +} + +Pix VHBag::first() +{ + for (unsigned int pos = 0; pos < size; ++pos) + if (status[pos] == VALIDCELL) return Pix(&tab[pos]); + return 0; +} + +void VHBag::next(Pix& i) +{ + if (i == 0) return; + unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; + for (; pos < size; ++pos) + if (status[pos] == VALIDCELL) + { + i = Pix(&tab[pos]); + return; + } + i = 0; +} + + +int VHBag::OK() +{ + int v = tab != 0; + v &= status != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL) ++n; + else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) + v = 0; + } + v &= n == count; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VHBag.hP b/gnu/lib/libg++/libg++/src/gen/VHBag.hP new file mode 100644 index 00000000000..7a7cc32e468 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHBag.hP @@ -0,0 +1,84 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _VHBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VHBag_h 1 + +#include ".Bag.h" + + +class VHBag : public Bag +{ +protected: + * tab; + char* status; + unsigned int size; + +public: + VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + VHBag(VHBag& a); + inline ~VHBag(); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item, Pix from = 0); + + int capacity(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + + +inline VHBag::~VHBag() +{ + delete [] tab; + delete status; +} + + +inline int VHBag::capacity() +{ + return size; +} + +inline int VHBag::contains( key) +{ + return seek(key) != 0; +} + +inline & VHBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VHMap.ccP b/gnu/lib/libg++/libg++/src/gen/VHMap.ccP new file mode 100644 index 00000000000..d3f2fcfc835 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHMap.ccP @@ -0,0 +1,210 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 "..VHMap.h" + +/* codes for status fields */ + +#define EMPTYCELL 0 +#define VALIDCELL 1 +#define DELETEDCELL 2 + + +VHMap::VHMap( dflt, unsigned int sz) + :Map(dflt) +{ + tab = new [size = sz]; + cont = new [size]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; +} + +VHMap::VHMap(VHMap& a) : Map(a.def) +{ + tab = new [size = a.size]; + cont = new [size]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); +} + + +/* + * hashing method: double hash based on high bits of hash fct, + * followed by linear probe. Can't do too much better if table + * sizes not constrained to be prime. +*/ + + +static inline unsigned int doublehashinc(unsigned int h, unsigned int s) +{ + unsigned int dh = ((h / s) % s); + return (dh > 1)? dh : 1; +} + +Pix VHMap::seek( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return 0; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + return Pix(&tab[h]); + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + return 0; +} + + +& VHMap::operator []( item) +{ + if (HASHTABLE_TOO_CROWDED(count, size)) + resize(); + + unsigned int bestspot = size; + unsigned int hashval = HASH(item); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + { + ++count; + if (bestspot >= size) bestspot = h; + tab[bestspot] = item; + status[bestspot] = VALIDCELL; + cont[bestspot] = def; + return cont[bestspot]; + } + else if (status[h] == DELETEDCELL) + { + if (bestspot >= size) bestspot = h; + } + else if (EQ(tab[h],item)) + return cont[h]; + + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + + ++count; + status[bestspot] = VALIDCELL; + tab[bestspot] = item; + cont[bestspot] = def; + return cont[bestspot]; +} + + +void VHMap::del( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + { + status[h] = DELETEDCELL; + --count; + return; + } + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } +} + + +void VHMap::clear() +{ + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; +} + +void VHMap::resize(unsigned int newsize) +{ + if (newsize <= count) + { + newsize = DEFAULT_INITIAL_CAPACITY; + while (HASHTABLE_TOO_CROWDED(count, newsize)) newsize <<= 1; + } + * oldtab = tab; + * oldcont = cont; + char* oldstatus = status; + unsigned int oldsize = size; + tab = new [size = newsize]; + cont = new [size]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (unsigned int i = 0; i < oldsize; ++i) + if (oldstatus[i] == VALIDCELL) + (*this)[oldtab[i]] = oldcont[i]; + delete [] oldtab; + delete [] oldcont; + delete oldstatus; +} + +Pix VHMap::first() +{ + for (unsigned int pos = 0; pos < size; ++pos) + if (status[pos] == VALIDCELL) return Pix(&tab[pos]); + return 0; +} + +void VHMap::next(Pix& i) +{ + if (i == 0) return; + unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; + for (; pos < size; ++pos) + if (status[pos] == VALIDCELL) + { + i = Pix(&tab[pos]); + return; + } + i = 0; +} + + +int VHMap::OK() +{ + int v = tab != 0; + v &= status != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL) ++n; + else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) + v = 0; + } + v &= n == count; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VHMap.hP b/gnu/lib/libg++/libg++/src/gen/VHMap.hP new file mode 100644 index 00000000000..ccc9328bcba --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHMap.hP @@ -0,0 +1,84 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _VHMap_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VHMap_h 1 + +#include "..Map.h" + + +class VHMap : public Map +{ +protected: + * tab; + * cont; + char* status; + unsigned int size; + +public: + VHMap( dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY); + VHMap(VHMap& a); + inline ~VHMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + inline & key(Pix i); + inline & contents(Pix i); + + Pix seek( key); + inline int contains( key); + + void clear(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + +inline VHMap::~VHMap() +{ + delete [] tab; + delete [] cont; + delete [] status; +} + +inline int VHMap::contains( key) +{ + return seek(key) != 0; +} + +inline & VHMap::key(Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +inline & VHMap::contents(Pix i) +{ + if (i == 0) error("null Pix"); + return cont[((unsigned)(i) - (unsigned)(tab)) / sizeof()]; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VHSet.ccP b/gnu/lib/libg++/libg++/src/gen/VHSet.ccP new file mode 100644 index 00000000000..414a7288207 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHSet.ccP @@ -0,0 +1,263 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".VHSet.h" + +/* codes for status fields */ + +#define EMPTYCELL 0 +#define VALIDCELL 1 +#define DELETEDCELL 2 + + +VHSet::VHSet(unsigned int sz) +{ + tab = new [size = sz]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; +} + +VHSet::VHSet(VHSet& a) +{ + tab = new [size = a.size]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (Pix p = a.first(); p; a.next(p)) add(a(p)); +} + + +/* + * hashing method: double hash based on high bits of hash fct, + * followed by linear probe. Can't do too much better if table + * sizes not constrained to be prime. +*/ + + +static inline unsigned int doublehashinc(unsigned int h, unsigned int s) +{ + unsigned int dh = ((h / s) % s); + return (dh > 1)? dh : 1; +} + +Pix VHSet::seek( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return 0; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + return Pix(&tab[h]); + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + return 0; +} + + +Pix VHSet::add( item) +{ + if (HASHTABLE_TOO_CROWDED(count, size)) + resize(); + + unsigned int bestspot = size; + unsigned int hashval = HASH(item); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + { + if (bestspot >= size) bestspot = h; + tab[bestspot] = item; + status[bestspot] = VALIDCELL; + ++count; + return Pix(&tab[bestspot]); + } + else if (status[h] == DELETEDCELL) + { + if (bestspot >= size) bestspot = h; + } + else if (EQ(tab[h],item)) + return Pix(&tab[h]); + + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } + tab[bestspot] = item; + status[bestspot] = VALIDCELL; + ++count; + return Pix(&tab[bestspot]); + +} + + +void VHSet::del( key) +{ + unsigned int hashval = HASH(key); + unsigned int h = hashval % size; + for (unsigned int i = 0; i <= size; ++i) + { + if (status[h] == EMPTYCELL) + return; + else if (status[h] == VALIDCELL && EQ(key, tab[h])) + { + status[h] = DELETEDCELL; + --count; + return; + } + if (i == 0) + h = (h + doublehashinc(hashval, size)) % size; + else if (++h >= size) + h -= size; + } +} + + +void VHSet::clear() +{ + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; +} + +void VHSet::resize(unsigned int newsize) +{ + if (newsize <= count) + { + newsize = DEFAULT_INITIAL_CAPACITY; + while (HASHTABLE_TOO_CROWDED(count, newsize)) newsize <<= 1; + } + * oldtab = tab; + char* oldstatus = status; + unsigned int oldsize = size; + tab = new [size = newsize]; + status = new char[size]; + for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = 0; + for (unsigned int i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); + delete [] oldtab; + delete oldstatus; +} + +Pix VHSet::first() +{ + for (unsigned int pos = 0; pos < size; ++pos) + if (status[pos] == VALIDCELL) return Pix(&tab[pos]); + return 0; +} + +void VHSet::next(Pix& i) +{ + if (i == 0) return; + unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; + for (; pos < size; ++pos) + if (status[pos] == VALIDCELL) + { + i = Pix(&tab[pos]); + return; + } + i = 0; +} + +int VHSet:: operator == (VHSet& b) +{ + if (count != b.count) + return 0; + else + { + for (unsigned int i = 0; i < size; ++i) + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + return 0; + for (unsigned int i = 0; i < b.size; ++i) + if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0) + return 0; + return 1; + } +} + +int VHSet::operator <= (VHSet& b) +{ + if (count > b.count) + return 0; + else + { + for (unsigned int i = 0; i < size; ++i) + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + return 0; + return 1; + } +} + +void VHSet::operator |= (VHSet& b) +{ + if (&b == this || b.count == 0) + return; + for (unsigned int i = 0; i < b.size; ++i) + if (b.status[i] == VALIDCELL) add(b.tab[i]); +} + +void VHSet::operator &= (VHSet& b) +{ + if (&b == this || count == 0) + return; + for (unsigned int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + { + status[i] = DELETEDCELL; + --count; + } + } +} + +void VHSet::operator -= (VHSet& b) +{ + for (unsigned int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL && b.seek(tab[i]) != 0) + { + status[i] = DELETEDCELL; + --count; + } + } +} + +int VHSet::OK() +{ + int v = tab != 0; + v &= status != 0; + int n = 0; + for (unsigned int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL) ++n; + else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) + v = 0; + } + v &= n == count; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VHSet.hP b/gnu/lib/libg++/libg++/src/gen/VHSet.hP new file mode 100644 index 00000000000..e7180b32020 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VHSet.hP @@ -0,0 +1,96 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _VHSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VHSet_h 1 + +#include ".Set.h" + + + +class VHSet : public Set +{ +protected: + * tab; + char* status; + unsigned int size; + +public: + VHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + VHSet(VHSet& a); + inline ~VHSet(); + + Pix add( item); + void del( item); + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item); + + void operator |= (VHSet& b); + void operator -= (VHSet& b); + void operator &= (VHSet& b); + + int operator == (VHSet& b); + int operator != (VHSet& b); + int operator <= (VHSet& b); + + int capacity(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + + +inline VHSet::~VHSet() +{ + delete [] tab; + delete status; +} + + +inline int VHSet::capacity() +{ + return size; +} + +inline int VHSet::contains( key) +{ + return seek(key) != 0; +} + +inline & VHSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +inline int VHSet::operator != (VHSet& b) +{ + return ! ((*this) == b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VOHSet.ccP b/gnu/lib/libg++/libg++/src/gen/VOHSet.ccP new file mode 100644 index 00000000000..252fdcb4c5b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VOHSet.ccP @@ -0,0 +1,305 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Doug Schmidt + +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 +#include ".VOHSet.h" + + +/* codes for status fields */ +#define EMPTYCELL 0 +#define VALIDCELL 1 +#define DELETEDCELL 2 + + +VOHSet::VOHSet(int sz) +{ +// The size of the hash table is always the smallest power of 2 >= the size +// indicated by the user. This allows several optimizations, including +// the use of actual double hashing and elimination of the mod instruction. + + size = 1; + while (size < sz) size <<= 1; + tab = new [size]; + status = new char[size]; + for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = cnt = 0; +} + +VOHSet::VOHSet(VOHSet& a) +{ + tab = new [size = a.size]; + status = new char[size]; + for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = cnt = 0; + for (Pix p = a.first(); p; a.next(p)) add(a(p)); +} + +Pix VOHSet::seek( key) +{ +// Uses ordered double hashing to perform a search of the table. +// This greatly speeds up the average-case time for an unsuccessful search. + + unsigned hashval = HASH(key); + + // We can avoid the mod operation since size is a power of 2. + unsigned h = hashval & (size - 1); + + // The increment must be odd, since all odd numbers are relatively + // prime to a power of 2!! + unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); + + // There is always at least 1 empty cell, so this loop is guaranteed to halt! + while (status[h] != EMPTYCELL) + { + int cmp = CMP (key, tab[h]); + if (cmp == 0) + { + if (status[h] == VALIDCELL) + return Pix(&tab[h]); + else + return 0; + } + else if (cmp < 0) + return 0; + else + h = ((h + inc) & (size - 1)); + } + return 0; +} + +// This adds an item if it doesn't already exist. By performing the initial +// comparison we assure that the table always contains at least 1 empty +// spot. This speeds up later searching by a constant factor. +// The insertion algorithm uses ordered double hashing. See Standish's +// 1980 ``Data Structure's Techniques'' book for details. + +Pix VOHSet::add( x) +{ + if (size <= cnt+1) + resize(); + + unsigned hashval = HASH(x); + unsigned h = hashval & (size - 1); + + if (status[h] != VALIDCELL) // save some work if possible + { + if (status[h] == EMPTYCELL) + cnt++; + count++; + tab[h] = x; + status[h] = VALIDCELL; + return Pix(&tab[h]); + } + + item = x; + Pix mypix = 0; + unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); + + for (;;) + { + if (status[h] != VALIDCELL) + { + if (status[h] == EMPTYCELL) + cnt++; + count++; + tab[h] = item; + status[h] = VALIDCELL; + return (mypix == 0)? Pix(&tab[h]) : mypix; + } + int cmp = CMP(item, tab[h]); + if (cmp == 0) + return (mypix == 0)? Pix(&tab[h]) : mypix; + else if (cmp < 0) + { + temp = tab[h]; + tab[h] = item; + item = temp; + if (mypix == 0) mypix = Pix(&tab[h]); + hashval = HASH(item); + h = hashval & (size - 1); + inc = ((((hashval / size) << 1) + 1) & (size - 1)); + } + else + h = ((h + inc) & (size - 1)); + } +} + + +void VOHSet::del( key) +{ +// This performs a deletion by marking the item's status field. +// Note that we only decrease the count, *not* the cnt, since this +// would cause trouble for subsequent steps in the algorithm. See +// Reingold and Hanson's ``Data Structure's'' book for a justification +// of this approach. + + unsigned hashval = HASH(key); + unsigned h = hashval & (size - 1); + unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); + + while (status[h] != EMPTYCELL) + { + int cmp = CMP(key, tab[h]); + if (cmp > 0) + h = ((h + inc) & (size - 1)); + else if (status[h] == VALIDCELL && cmp == 0) + { + status[h] = DELETEDCELL; + count--; + return; + } + else + return; + } +} + +void VOHSet::clear() +{ + for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = cnt = 0; +} + +void VOHSet::resize(int newsize) +{ + if (newsize <= count) + newsize = count; + int s = 1; + while (s <= newsize) s <<= 1; + newsize = s; + + * oldtab = tab; + char* oldstatus = status; + int oldsize = size; + tab = new [size = newsize]; + status = new char[size]; + for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; + count = cnt = 0; + + for (int i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); + delete [] oldtab; + delete oldstatus; +} + +Pix VOHSet::first() +{ + for (int pos = 0; pos < size; ++pos) + if (status[pos] == VALIDCELL) return Pix(&tab[pos]); + return 0; +} + +void VOHSet::next(Pix& i) +{ + if (i == 0) return; + int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; + for (; pos < size; ++pos) + if (status[pos] == VALIDCELL) + { + i = Pix(&tab[pos]); + return; + } + i = 0; +} + + +int VOHSet:: operator == (VOHSet& b) +{ + if (count != b.count) + return 0; + else + { + for (int i = 0; i < size; ++i) + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + return 0; + for (int i = 0; i < b.size; ++i) + if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0) + return 0; + return 1; + } +} + +int VOHSet:: operator != (VOHSet& b) +{ + return !(*this == b); +} + +int VOHSet::operator <= (VOHSet& b) +{ + if (count > b.count) + return 0; + else + { + for (int i = 0; i < size; ++i) + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + return 0; + return 1; + } +} + +void VOHSet::operator |= (VOHSet& b) +{ + if (&b == this || b.count == 0) + return; + for (int i = 0; i < b.size; ++i) + if (b.status[i] == VALIDCELL) add(b.tab[i]); +} + +void VOHSet::operator &= (VOHSet& b) +{ + if (&b == this || count == 0) + return; + for (int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) + { + status[i] = DELETEDCELL; + --count; + } + } +} + +void VOHSet::operator -= (VOHSet& b) +{ + for (int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL && b.seek(tab[i]) != 0) + { + status[i] = DELETEDCELL; + --count; + } + } +} + +int VOHSet::OK() +{ + int v = tab != 0; + v &= status != 0; + int n = 0; + for (int i = 0; i < size; ++i) + { + if (status[i] == VALIDCELL) ++n; + else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) + v = 0; + } + v &= n == count; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VOHSet.hP b/gnu/lib/libg++/libg++/src/gen/VOHSet.hP new file mode 100644 index 00000000000..a3ff2c81482 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VOHSet.hP @@ -0,0 +1,88 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Doug Schmidt + +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. +*/ + + +#ifndef _VOHSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VOHSet_h 1 + +#include ".Set.h" + + + +class VOHSet : public Set +{ + * tab; + char* status; + int size; + int cnt; // keeps track of VALIDCELLs and DELETEDCELLs + +public: + VOHSet(int sz = DEFAULT_INITIAL_CAPACITY); + VOHSet(VOHSet&); + inline ~VOHSet(); + + Pix add( item); + void del( item); + inline int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + inline & operator () (Pix i); + Pix seek( item); + + void operator |= (VOHSet& b); + void operator -= (VOHSet& b); + void operator &= (VOHSet& b); + + int operator == (VOHSet& b); + int operator != (VOHSet& b); + int operator <= (VOHSet& b); + + int capacity(); + void resize(int newsize = 0); + + int OK(); +}; + + +inline VOHSet::~VOHSet() +{ + delete [] tab; + delete status; +} + + +inline int VOHSet::contains( key) +{ + return seek(key) != 0; +} + + +inline & VOHSet::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return *((*)p); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VQueue.ccP b/gnu/lib/libg++/libg++/src/gen/VQueue.ccP new file mode 100644 index 00000000000..8eca22d1714 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VQueue.ccP @@ -0,0 +1,83 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".VQueue.h" + +VQueue::VQueue(VQueue& b) +:size(b.size), cnt(b.cnt), inp(b.inp), outp(b.outp), s(new [b.size]) +{ + int j = outp; + for (int i = 0; i < cnt; ++i) + { + s[j] = b.s[j]; + if (++j == size) j = 0; + } +} + +void VQueue::operator = (VQueue& b) +{ + if (&b == this) return; + if (size != b.size) + { + delete [] s; + s = new [b.size]; + size = b.size; + } + inp = b.inp; outp = b.outp; cnt = b.cnt; + int j = outp; + for (int i = 0; i < cnt; ++i) + { + s[j] = b.s[j]; + if (++j == size) j = 0; + } +} + + +void VQueue::resize(int newsz) +{ + if (newsz < cnt) + error("resize: new size too small"); + * news = new [newsz]; + int j = outp; + for (int i = 0; i < cnt; ++i) + { + news[i] = s[j]; + if (++j == size) j = 0; + } + inp = cnt; + outp = 0; + delete [] s; + s = news; + size = newsz; +} + +int VQueue::OK() +{ + int v = s != 0; // have space + v &= size >= 0; // a legal size + v &= inp >= 0 && inp <= size; // pointers with bounds + v &= outp >= 0 && outp <= size; + int c = (size + inp - outp) % size; + v &= cnt == size || cnt == c; // correct count + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VQueue.hP b/gnu/lib/libg++/libg++/src/gen/VQueue.hP new file mode 100644 index 00000000000..287a78187a1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VQueue.hP @@ -0,0 +1,130 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _VQueue_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VQueue_h 1 + +#include ".Queue.h" + +class VQueue : public Queue +{ +protected: + int size; + int cnt; + int inp; + int outp; + * s; + +public: + + VQueue(int sz = DEFAULT_INITIAL_CAPACITY); + VQueue(VQueue&); + inline ~VQueue(); + + void operator = (VQueue&); + + inline void enq( item); + inline deq(); + inline & front(); + inline void del_front(); + + inline int length(); + inline int empty(); + inline int full(); + + int capacity(); + void resize(int sz); + inline void clear(); + + int OK(); +}; + + +inline VQueue::VQueue(int sz) +{ + s = new [size = sz]; + cnt = inp = outp = 0; +} + +inline VQueue::~VQueue() +{ + delete [] s; +} + +inline void VQueue::clear() +{ + inp = outp = 0; + cnt = 0; +} + +inline int VQueue::empty() +{ + return cnt <= 0; +} + +inline int VQueue::capacity() +{ + return size; +} + +inline int VQueue::full() +{ + return cnt >= size; +} + +inline int VQueue::length() +{ + return cnt; +} + +inline void VQueue::enq( item) +{ + if (cnt >= size) error("enq to full Queue."); + ++cnt; + s[inp] = item; + if (++inp == size) inp = 0; +} + +inline VQueue::deq() +{ + if (cnt <= 0) error("deq from empty Queue."); + --cnt; + int i = outp; + if (++outp == size) outp = 0; + return s[i]; +} + + +inline void VQueue::del_front() +{ + if (cnt <= 0) error("delete from empty Queue."); + --cnt; + if (++outp == size) outp = 0; +} + +inline & VQueue::front() +{ + if (empty()) error("top from empty Queue."); + return s[outp]; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/VStack.ccP b/gnu/lib/libg++/libg++/src/gen/VStack.ccP new file mode 100644 index 00000000000..a5e8292fabf --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VStack.ccP @@ -0,0 +1,66 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include ".VStack.h" + +// error handling + + +VStack::VStack(VStack& b) +:size(b.size), ptr(b.ptr), s(new [b.size]) +{ + for (int i = 0; i < ptr; ++i) s[i] = b.s[i]; +} + +void VStack::operator = (VStack& b) +{ + if (&b == this) return; + if (size < b.ptr) + { + delete [] s; + s = new [b.size]; + size = b.size; + } + ptr = b.ptr; + for (int i = 0; i < ptr; ++i) s[i] = b.s[i]; +} + + +void VStack::resize(int newsz) +{ + if (newsz < ptr) error("resize: new size too small"); + * news = new [newsz]; + for (int i = 0; i < ptr; ++i) news[i] = s[i]; + delete [] s; + s = news; + size = newsz; +} + +int VStack::OK() +{ + int v = s != 0; // have space + v &= size >= 0; // a legal size + v &= ptr <= size; // ptr within bounds + v &= ptr >= 0; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/VStack.hP b/gnu/lib/libg++/libg++/src/gen/VStack.hP new file mode 100644 index 00000000000..c7f7631a4cc --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/VStack.hP @@ -0,0 +1,120 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _VStack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _VStack_h 1 + +#include ".Stack.h" + +class VStack : public Stack +{ +protected: + int size; + int ptr; + * s; + +public: + + VStack(int sz = DEFAULT_INITIAL_CAPACITY); + VStack(VStack&); + inline ~VStack(); + + void operator = (VStack&); + inline void push( item); + inline pop(); + inline & top(); + inline void del_top(); + + inline int length(); + inline int empty(); + inline int full(); + inline void clear(); + + void resize(int sz); + int capacity(); + + int OK(); +}; + + +inline VStack::VStack(int sz) +{ + s = new [size = sz]; + ptr = 0; +} + +inline VStack::~VStack() +{ + delete [] s; +} + +inline void VStack::clear() +{ + ptr = 0; +} + +inline int VStack::capacity() +{ + return size; +} + +inline int VStack::empty() +{ + return ptr == 0; +} + +inline int VStack::full() +{ + return ptr == size; +} + +inline int VStack::length() +{ + return ptr; +} + +inline void VStack::push( item) +{ + if (full()) error("push to full stack."); + s[ptr++] = item; +} + +inline VStack::pop() +{ + if (empty()) error("pop from empty stack."); + return s[--ptr]; +} + + +inline void VStack::del_top() +{ + if (empty()) error("del_top from empty stack."); + --ptr; +} + +inline & VStack::top() +{ + if (empty()) error("top from empty stack."); + return s[ptr-1]; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/Vec.ccP b/gnu/lib/libg++/libg++/src/gen/Vec.ccP new file mode 100644 index 00000000000..ac3825b0b8d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Vec.ccP @@ -0,0 +1,470 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 +#include +#include ".Vec.h" + +// error handling + + +void default_Vec_error_handler(const char* msg) +{ + cerr << "Fatal Vec error. " << msg << "\n"; + exit(1); +} + +one_arg_error_handler_t Vec_error_handler = default_Vec_error_handler; + +one_arg_error_handler_t set_Vec_error_handler(one_arg_error_handler_t f) +{ + one_arg_error_handler_t old = Vec_error_handler; + Vec_error_handler = f; + return old; +} + +void Vec::error(const char* msg) +{ + (*Vec_error_handler)(msg); +} + +void Vec::range_error() +{ + (*Vec_error_handler)("Index out of range."); +} + +Vec::Vec(const Vec& v) +{ + s = new [len = v.len]; + * top = &(s[len]); + * t = s; + const * u = v.s; + while (t < top) *t++ = *u++; +} + +Vec::Vec(int l, fill_value) +{ + s = new [len = l]; + * top = &(s[len]); + * t = s; + while (t < top) *t++ = fill_value; +} + + +Vec& Vec::operator = (const Vec& v) +{ + if (this != &v) + { + delete [] s; + s = new [len = v.len]; + * top = &(s[len]); + * t = s; + const * u = v.s; + while (t < top) *t++ = *u++; + } + return *this; +} + +void Vec::apply(Procedure f) +{ + * top = &(s[len]); + * t = s; + while (t < top) (*f)(*t++); +} + +// can't just realloc since there may be need for constructors/destructors +void Vec::resize(int newl) +{ + * news = new [newl]; + * p = news; + int minl = (len < newl)? len : newl; + * top = &(s[minl]); + * t = s; + while (t < top) *p++ = *t++; + delete [] s; + s = news; + len = newl; +} + +Vec concat(Vec & a, Vec & b) +{ + int newl = a.len + b.len; + * news = new [newl]; + * p = news; + * top = &(a.s[a.len]); + * t = a.s; + while (t < top) *p++ = *t++; + top = &(b.s[b.len]); + t = b.s; + while (t < top) *p++ = *t++; + return Vec(newl, news); +} + + +Vec combine(Combiner f, Vec& a, Vec& b) +{ + int newl = (a.len < b.len)? a.len : b.len; + * news = new [newl]; + * p = news; + * top = &(a.s[newl]); + * t = a.s; + * u = b.s; + while (t < top) *p++ = (*f)(*t++, *u++); + return Vec(newl, news); +} + + Vec::reduce(Combiner f, base) +{ + r = base; + * top = &(s[len]); + * t = s; + while (t < top) r = (*f)(r, *t++); + return r; +} + +Vec reverse(Vec& a) +{ + * news = new [a.len]; + if (a.len != 0) + { + * lo = news; + * hi = &(news[a.len - 1]); + while (lo < hi) + { + tmp = *lo; + *lo++ = *hi; + *hi-- = tmp; + } + } + return Vec(a.len, news); +} + +void Vec::reverse() +{ + if (len != 0) + { + * lo = s; + * hi = &(s[len - 1]); + while (lo < hi) + { + tmp = *lo; + *lo++ = *hi; + *hi-- = tmp; + } + } +} + +int Vec::index( targ) +{ + for (int i = 0; i < len; ++i) if (EQ(targ, s[i])) return i; + return -1; +} + +Vec map(Mapper f, Vec& a) +{ + * news = new [a.len]; + * p = news; + * top = &(a.s[a.len]); + * t = a.s; + while(t < top) *p++ = (*f)(*t++); + return Vec(a.len, news); +} + +int operator == (Vec& a, Vec& b) +{ + if (a.len != b.len) + return 0; + * top = &(a.s[a.len]); + * t = a.s; + * u = b.s; + while (t < top) if (!(EQ(*t++, *u++))) return 0; + return 1; +} + +void Vec::fill( val, int from, int n) +{ + int to; + if (n < 0) + to = len - 1; + else + to = from + n - 1; + if ((unsigned)from > (unsigned)to) + range_error(); + * t = &(s[from]); + * top = &(s[to]); + while (t <= top) *t++ = val; +} + +Vec Vec::at(int from, int n) +{ + int to; + if (n < 0) + { + n = len - from; + to = len - 1; + } + else + to = from + n - 1; + if ((unsigned)from > (unsigned)to) + range_error(); + * news = new [n]; + * p = news; + * t = &(s[from]); + * top = &(s[to]); + while (t <= top) *p++ = *t++; + return Vec(n, news); +} + +Vec merge(Vec & a, Vec & b, Comparator f) +{ + int newl = a.len + b.len; + * news = new [newl]; + * p = news; + * topa = &(a.s[a.len]); + * as = a.s; + * topb = &(b.s[b.len]); + * bs = b.s; + + for (;;) + { + if (as >= topa) + { + while (bs < topb) *p++ = *bs++; + break; + } + else if (bs >= topb) + { + while (as < topa) *p++ = *as++; + break; + } + else if ((*f)(*as, *bs) <= 0) + *p++ = *as++; + else + *p++ = *bs++; + } + return Vec(newl, news); +} + +static int gsort(*, int, Comparator); + +void Vec::sort (Comparator compar) +{ + gsort(s, len, compar); +} + + +// An adaptation of Schmidt's new quicksort + +static inline void SWAP(* A, * B) +{ + tmp = *A; *A = *B; *B = tmp; +} + +/* This should be replaced by a standard ANSI macro. */ +#define BYTES_PER_WORD 8 +#define BYTES_PER_LONG 4 + +/* The next 4 #defines implement a very fast in-line stack abstraction. */ + +#define STACK_SIZE (BYTES_PER_WORD * BYTES_PER_LONG) +#define PUSH(LOW,HIGH) do {top->lo = LOW;top++->hi = HIGH;} while (0) +#define POP(LOW,HIGH) do {LOW = (--top)->lo;HIGH = top->hi;} while (0) +#define STACK_NOT_EMPTY (stack < top) + +/* Discontinue quicksort algorithm when partition gets below this size. + This particular magic number was chosen to work best on a Sun 4/260. */ +#define MAX_THRESH 4 + + +/* Order size using quicksort. This implementation incorporates + four optimizations discussed in Sedgewick: + + 1. Non-recursive, using an explicit stack of pointer that + store the next array partition to sort. To save time, this + maximum amount of space required to store an array of + MAX_INT is allocated on the stack. Assuming a 32-bit integer, + this needs only 32 * sizeof (stack_node) == 136 bits. Pretty + cheap, actually. + + 2. Chose the pivot element using a median-of-three decision tree. + This reduces the probability of selecting a bad pivot value and + eliminates certain extraneous comparisons. + + 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving + insertion sort to order the MAX_THRESH items within each partition. + This is a big win, since insertion sort is faster for small, mostly + sorted array segements. + + 4. The larger of the two sub-partitions is always pushed onto the + stack first, with the algorithm then concentrating on the + smaller partition. This *guarantees* no more than log (n) + stack size is needed! */ + +static int gsort ( *base_ptr, int total_elems, Comparator cmp) +{ +/* Stack node declarations used to store unfulfilled partition obligations. */ + struct stack_node { *lo; *hi; }; + pivot_buffer; + int max_thresh = MAX_THRESH; + + if (total_elems > MAX_THRESH) + { + *lo = base_ptr; + *hi = lo + (total_elems - 1); + *left_ptr; + *right_ptr; + stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ + stack_node *top = stack + 1; + + while (STACK_NOT_EMPTY) + { + { + *pivot = &pivot_buffer; + { + /* Select median value from among LO, MID, and HI. Rearrange + LO and HI so the three values are sorted. This lowers the + probability of picking a pathological pivot value and + skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ + + *mid = lo + ((hi - lo) >> 1); + + if ((*cmp) (*mid, *lo) < 0) + SWAP (mid, lo); + if ((*cmp) (*hi, *mid) < 0) + { + SWAP (mid, hi); + if ((*cmp) (*mid, *lo) < 0) + SWAP (mid, lo); + } + *pivot = *mid; + pivot = &pivot_buffer; + } + left_ptr = lo + 1; + right_ptr = hi - 1; + + /* Here's the famous ``collapse the walls'' section of quicksort. + Gotta like those tight inner loops! They are the main reason + that this algorithm runs much faster than others. */ + do + { + while ((*cmp) (*left_ptr, *pivot) < 0) + left_ptr += 1; + + while ((*cmp) (*pivot, *right_ptr) < 0) + right_ptr -= 1; + + if (left_ptr < right_ptr) + { + SWAP (left_ptr, right_ptr); + left_ptr += 1; + right_ptr -= 1; + } + else if (left_ptr == right_ptr) + { + left_ptr += 1; + right_ptr -= 1; + break; + } + } + while (left_ptr <= right_ptr); + + } + + /* Set up pointers for next iteration. First determine whether + left and right partitions are below the threshold size. If so, + ignore one or both. Otherwise, push the larger partition's + bounds on the stack and continue sorting the smaller one. */ + + if ((right_ptr - lo) <= max_thresh) + { + if ((hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */ + POP (lo, hi); + else /* Ignore small left partition. */ + lo = left_ptr; + } + else if ((hi - left_ptr) <= max_thresh) /* Ignore small right partition. */ + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) /* Push larger left partition indices. */ + { + PUSH (lo, right_ptr); + lo = left_ptr; + } + else /* Push larger right partition indices. */ + { + PUSH (left_ptr, hi); + hi = right_ptr; + } + } + } + + /* Once the BASE_PTR array is partially sorted by quicksort the rest + is completely sorted using insertion sort, since this is efficient + for partitions below MAX_THRESH size. BASE_PTR points to the beginning + of the array to sort, and END_PTR points at the very last element in + the array (*not* one beyond it!). */ + + + { + *end_ptr = base_ptr + 1 * (total_elems - 1); + *run_ptr; + *tmp_ptr = base_ptr; + *thresh = (end_ptr < (base_ptr + max_thresh))? + end_ptr : (base_ptr + max_thresh); + + /* Find smallest element in first threshold and place it at the + array's beginning. This is the smallest array element, + and the operation speeds up insertion sort's inner loop. */ + + for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr += 1) + if ((*cmp) (*run_ptr, *tmp_ptr) < 0) + tmp_ptr = run_ptr; + + if (tmp_ptr != base_ptr) + SWAP (tmp_ptr, base_ptr); + + /* Insertion sort, running from left-hand-side up to `right-hand-side.' + Pretty much straight out of the original GNU qsort routine. */ + + for (run_ptr = base_ptr + 1; (tmp_ptr = run_ptr += 1) <= end_ptr; ) + { + + while ((*cmp) (*run_ptr, *(tmp_ptr -= 1)) < 0) + ; + + if ((tmp_ptr += 1) != run_ptr) + { + *trav; + + for (trav = run_ptr + 1; --trav >= run_ptr;) + { + c = *trav; + *hi, *lo; + + for (hi = lo = trav; (lo -= 1) >= tmp_ptr; hi = lo) + *hi = *lo; + *hi = c; + } + } + + } + } + return 1; +} diff --git a/gnu/lib/libg++/libg++/src/gen/Vec.hP b/gnu/lib/libg++/libg++/src/gen/Vec.hP new file mode 100644 index 00000000000..91993d1c4f1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/Vec.hP @@ -0,0 +1,135 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _Vec_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _Vec_h 1 + +#include +#include ".defs.h" + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)(); +typedef (*Mapper)(); +typedef (*Combiner)(, ); +typedef int (*Predicate)(); +typedef int (*Comparator)(, ); +#endif + + +class Vec +{ +protected: + int len; + *s; + + Vec(int l, * d); +public: + Vec (); + Vec (int l); + Vec (int l, fill_value); + Vec (const Vec&); + ~Vec (); + + Vec & operator = (const Vec & a); + Vec at(int from = 0, int n = -1); + + int capacity() const; + void resize(int newlen); + + & operator [] (int n); + & elem(int n); + + friend Vec concat(Vec & a, Vec & b); + friend Vec map(Mapper f, Vec & a); + friend Vec merge(Vec & a, Vec & b, Comparator f); + friend Vec combine(Combiner f, Vec & a, Vec & b); + friend Vec reverse(Vec & a); + + void reverse(); + void sort(Comparator f); + void fill( val, int from = 0, int n = -1); + + void apply(Procedure f); + reduce(Combiner f, base); + int index( targ); + + friend int operator == (Vec& a, Vec& b); + friend int operator != (Vec& a, Vec& b); + + void error(const char* msg); + void range_error(); +}; + +extern void default_Vec_error_handler(const char*); +extern one_arg_error_handler_t Vec_error_handler; + +extern one_arg_error_handler_t + set_Vec_error_handler(one_arg_error_handler_t f); + + +inline Vec::Vec() +{ + len = 0; s = 0; +} + +inline Vec::Vec(int l) +{ + s = new [len = l]; +} + + +inline Vec::Vec(int l, * d) :len(l), s(d) {} + + +inline Vec::~Vec() +{ + delete [] s; +} + + +inline & Vec::operator [] (int n) +{ + if ((unsigned)n >= (unsigned)len) + range_error(); + return s[n]; +} + +inline & Vec::elem(int n) +{ + return s[n]; +} + + +inline int Vec::capacity() const +{ + return len; +} + + + +inline int operator != (Vec& a, Vec& b) +{ + return !(a == b); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPBag.ccP b/gnu/lib/libg++/libg++/src/gen/XPBag.ccP new file mode 100644 index 00000000000..e2a7834077b --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPBag.ccP @@ -0,0 +1,72 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".XPBag.h" + +int XPBag::OK() +{ + int v = p.OK(); + v &= count == p.length(); + if (!v) error("invariant failure"); + return v; +} + +Pix XPBag::seek( item, Pix i) +{ + if (i == 0) i = p.first(); else next(i); + for (; i != 0; p.next(i)) if (EQ(p(i), item)) return i; + return 0; +} + +int XPBag::nof( item) +{ + int n = 0; + for (int i = p.low(); i < p.fence(); p.next(i)) if (EQ(p[i], item)) ++n; + return n; +} + +void XPBag::del( item) +{ + for (int i = p.low(); i < p.fence(); p.next(i)) + { + if (EQ(p[i], item)) + { + --count; + p[i] = p.low_element(); + p.del_low(); + return; + } + } +} + +void XPBag::remove( item) +{ + for (int i = p.low(); i < p.fence(); p.next(i)) + { + if (EQ(p[i], item)) + { + --count; + p[i] = p.low_element(); + p.del_low(); + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/gen/XPBag.hP b/gnu/lib/libg++/libg++/src/gen/XPBag.hP new file mode 100644 index 00000000000..da8c199e212 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPBag.hP @@ -0,0 +1,98 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _XPBag_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPBag_h 1 + +#include ".Bag.h" +#include ".XPlex.h" + +class XPBag : public Bag +{ +protected: + XPlex p; + +public: + XPBag(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPBag(const XPBag&); + + inline Pix add( item); + void del( item); +#undef remove + void remove(item); + int nof( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +inline XPBag::XPBag(int chunksize) + : p(chunksize) { count = 0; } + +inline XPBag::XPBag(const XPBag& s) : p(s.p) { count = s.count; } + +inline Pix XPBag::first() +{ + return p.first(); +} + +inline void XPBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void XPBag::clear() +{ + count = 0; p.clear(); +} + +inline int XPBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline Pix XPBag::add( item) +{ + ++count; + return p.index_to_Pix(p.add_high(item)); +} + +inline int XPBag::contains( item) +{ + return seek(item) != 0; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPDeque.ccP b/gnu/lib/libg++/libg++/src/gen/XPDeque.ccP new file mode 100644 index 00000000000..6b363d9bdc4 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPDeque.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".XPDeque.h" diff --git a/gnu/lib/libg++/libg++/src/gen/XPDeque.hP b/gnu/lib/libg++/libg++/src/gen/XPDeque.hP new file mode 100644 index 00000000000..a73d8fdada8 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPDeque.hP @@ -0,0 +1,133 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _XPDeque_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPDeque_h + +#include ".XPlex.h" +#include ".Deque.h" + +class XPDeque : public Deque +{ + XPlex p; + +public: + XPDeque(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPDeque(const XPDeque& d); + inline ~XPDeque(); + + void operator = (const XPDeque&); + + inline void push( item); // insert at front + inline void enq( item); // insert at rear + + inline & front(); + inline & rear(); + + inline deq(); + inline void del_front(); + inline void del_rear(); + + inline void clear(); + inline int empty(); + inline int full(); + inline int length(); + + inline int OK(); +}; + +inline XPDeque::XPDeque(int chunksize) + : p(chunksize) {} +inline XPDeque::XPDeque(const XPDeque& d) : p(d.p) {} + +inline XPDeque::~XPDeque() {} + +inline void XPDeque::push(item) +{ + p.add_low(item); +} + +inline void XPDeque::enq(item) +{ + p.add_high(item); +} + +inline XPDeque::deq() +{ + res = p.low_element(); + p.del_low(); + return res; +} + +inline & XPDeque::front() +{ + return p.low_element(); +} + +inline & XPDeque::rear() +{ + return p.high_element(); +} + +inline void XPDeque::del_front() +{ + p.del_low(); +} + +inline void XPDeque::del_rear() +{ + p.del_high(); +} + +inline void XPDeque::operator =(const XPDeque& s) +{ + p.operator = (s.p); +} + + +inline int XPDeque::empty() +{ + return p.empty(); +} + +inline int XPDeque::full() +{ + return p.full(); +} + +inline int XPDeque::length() +{ + return p.length(); +} + +inline int XPDeque::OK() +{ + return p.OK(); +} + +inline void XPDeque::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPPQ.ccP b/gnu/lib/libg++/libg++/src/gen/XPPQ.ccP new file mode 100644 index 00000000000..4d7a8644b12 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPPQ.ccP @@ -0,0 +1,143 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".XPPQ.h" + +int XPPQ::OK() +{ + int v = p.OK(); + v &= p.low() == 1; + v &= count == p.length(); + if (!v) error("invariant failure"); + return v; +} + +Pix XPPQ::seek( item) +{ + for (int i = p.low(); i < p.fence(); p.next(i)) + if (EQ(p[i],item)) return p.index_to_Pix(i); + return 0; +} + +// standard 2-ary heap ops +// pointers are used a lot to avoid thrashing across chunks with plexes + +Pix XPPQ::enq( item) +{ + p.add_high(item); + * pk = &(p.high_element()); + int par = ++count >> 1; + while (par != 0) + { + * ppar = &(p[par]); + if (!(LE(*ppar, item))) + { + *pk = *ppar; + pk = ppar; + par >>= 1; + } + else + break; + } + *pk = item; + return Pix(pk); +} + +void XPPQ::del_front() +{ + if (count == 0) error("empty PQ"); + --count; + * pk = &(p.low_element()); + * ph = &(p.high_element()); + int child = 2; + while (child <= count) + { + * pchild = &(p[child]); + if (child < count) + { + * prchild = &(p[child+1]); + if (!(LE(*pchild, *prchild))) + { + pchild = prchild; + ++child; + } + } + if (!(LE(*ph, *pchild))) + { + *pk = *pchild; + pk = pchild; + child <<= 1; + } + else + break; + } + *pk = *ph; + p.del_high(); +} + + +void XPPQ::del(Pix i) +{ + if (i == 0) error("null Pix"); + --count; + int k = p.Pix_to_index(i); + * pk = &(p[k]); + * ph = &(p.high_element()); + int child = k << 1; + while (child <= count) + { + * pchild = &(p[child]); + if (child < count) + { + * prchild = &(p[child+1]); + if (!(LE(*pchild, *prchild))) + { + pchild = prchild; + ++child; + } + } + if (!(LE(*ph, *pchild))) + { + *pk = *pchild; + pk = pchild; + child <<= 1; + } + else + break; + } + int par = child >> 2; + while (par != 0) + { + * ppar = &(p[par]); + if (!(LE(*ppar, *ph))) + { + *pk = *ppar; + pk = ppar; + par >>= 1; + } + else + break; + } + *pk = *ph; + p.del_high(); +} + + diff --git a/gnu/lib/libg++/libg++/src/gen/XPPQ.hP b/gnu/lib/libg++/libg++/src/gen/XPPQ.hP new file mode 100644 index 00000000000..472670009d7 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPPQ.hP @@ -0,0 +1,105 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _XPPQ_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPPQ_h 1 + +#include ".PQ.h" +#include ".XPlex.h" + +class XPPQ : public PQ +{ +protected: + XPlex p; + +public: + XPPQ(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPPQ(const XPPQ&); + + Pix enq( item); + inline deq(); + + inline & front(); + void del_front(); + + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + void del(Pix i); + inline int owns(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + +inline XPPQ::XPPQ(int chunksize) + : p(1, chunksize) { count = 0; } + +inline XPPQ::XPPQ(const XPPQ& s) : p(s.p) { count = s.count; } + +inline Pix XPPQ::first() +{ + return p.first(); +} + +inline void XPPQ::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPPQ::operator ()(Pix idx) +{ + return p(idx); +} + +inline & XPPQ::front () +{ + return p.low_element(); +} + +inline XPPQ::deq () +{ + x = p.low_element(); + del_front(); + return x; +} + +inline void XPPQ::clear() +{ + count = 0; p.clear(); +} + +inline int XPPQ::contains ( item) +{ + return seek(item) != 0; +} + +inline int XPPQ::owns (Pix idx) +{ + return p.owns(idx); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPQueue.ccP b/gnu/lib/libg++/libg++/src/gen/XPQueue.ccP new file mode 100644 index 00000000000..77bfd1c7a95 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPQueue.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".XPQueue.h" diff --git a/gnu/lib/libg++/libg++/src/gen/XPQueue.hP b/gnu/lib/libg++/libg++/src/gen/XPQueue.hP new file mode 100644 index 00000000000..a5baf7bd68e --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPQueue.hP @@ -0,0 +1,114 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _XPQueue_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPQueue_h + +#include ".XPlex.h" +#include ".Queue.h" + +class XPQueue : public Queue +{ +protected: + XPlex p; + +public: + XPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPQueue(const XPQueue& q); + inline ~XPQueue(); + + void operator = (const XPQueue&); + + inline void enq( item); + inline deq(); + inline & front(); + inline void del_front(); + + inline void clear(); + inline int empty(); + inline int full(); + inline int length(); + + inline int OK(); +}; + +inline XPQueue::XPQueue(int chunksize) + : p(chunksize) {} +inline XPQueue::XPQueue(const XPQueue& q) : p(q.p) {} + +inline XPQueue::~XPQueue() {} + +inline void XPQueue::enq(item) +{ + p.add_high(item); +} + +inline XPQueue::deq() +{ + res = p.low_element(); + p.del_low(); + return res; +} + +inline & XPQueue::front() +{ + return p.low_element(); +} + + +inline void XPQueue::del_front() +{ + p.del_low(); +} + +inline void XPQueue::operator =(const XPQueue& s) +{ + p.operator = (s.p); +} + +inline int XPQueue::empty() +{ + return p.empty(); +} + +inline int XPQueue::full() +{ + return p.full(); +} + +inline int XPQueue::length() +{ + return p.length(); +} + +inline int XPQueue::OK() +{ + return p.OK(); +} + +inline void XPQueue::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPSet.ccP b/gnu/lib/libg++/libg++/src/gen/XPSet.ccP new file mode 100644 index 00000000000..596fa8847ad --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPSet.ccP @@ -0,0 +1,63 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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 ".XPSet.h" + +int XPSet::OK() +{ + int v = p.OK(); + v &= count == p.length(); + if (!v) error("invariant failure"); + return v; +} + +Pix XPSet::seek( item) +{ + for (int i = p.low(); i < p.fence(); p.next(i)) + if (EQ(p[i],item)) return p.index_to_Pix(i); + return 0; +} + +Pix XPSet::add( item) +{ + Pix i = seek(item); + if (i == 0) + { + ++count; + i = p.index_to_Pix(p.add_high(item)); + } + return i; +} + +void XPSet::del( item) +{ + for (int i = p.low(); i < p.fence(); p.next(i)) + { + if (EQ(p[i], item)) + { + --count; + p[i] = p.low_element(); + p.del_low(); + return; + } + } +} + diff --git a/gnu/lib/libg++/libg++/src/gen/XPSet.hP b/gnu/lib/libg++/libg++/src/gen/XPSet.hP new file mode 100644 index 00000000000..a87d8eb0b55 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPSet.hP @@ -0,0 +1,89 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _XPSet_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPSet_h 1 + +#include ".Set.h" +#include ".XPlex.h" + +class XPSet : public Set +{ +protected: + XPlex p; + +public: + XPSet(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPSet(const XPSet&); + + Pix add( item); + void del( item); + inline int contains( item); + + inline void clear(); + + inline Pix first(); + inline void next(Pix& i); + inline & operator () (Pix i); + inline int owns(Pix i); + Pix seek( item); + + int OK(); +}; + + +inline XPSet::XPSet(int chunksize) + : p(chunksize) { count = 0; } + +inline XPSet::XPSet(const XPSet& s) : p(s.p) { count = s.count; } + +inline Pix XPSet::first() +{ + return p.first(); +} + +inline void XPSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void XPSet::clear() +{ + count = 0; p.clear(); +} + +inline int XPSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int XPSet::owns (Pix idx) +{ + return p.owns(idx); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPStack.ccP b/gnu/lib/libg++/libg++/src/gen/XPStack.ccP new file mode 100644 index 00000000000..fe24f0f044a --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPStack.ccP @@ -0,0 +1,4 @@ +#ifdef __GNUG__ +#pragma implementation +#endif +#include ".XPStack.h" diff --git a/gnu/lib/libg++/libg++/src/gen/XPStack.hP b/gnu/lib/libg++/libg++/src/gen/XPStack.hP new file mode 100644 index 00000000000..41f78adf5ce --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPStack.hP @@ -0,0 +1,115 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + + +#ifndef _XPStack_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPStack_h + +#include ".XPlex.h" +#include ".Stack.h" + +class XPStack : public Stack +{ + XPlex p; + +public: + XPStack(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPStack(const XPStack& s); + inline ~XPStack(); + + void operator = (const XPStack&); + + inline void push( item); + inline pop(); + inline & top(); + inline void del_top(); + + inline int empty(); + inline int full(); + inline int length(); + + inline void clear(); + + inline int OK(); + +}; + + +inline XPStack::XPStack(int chunksize) + : p(chunksize) {} +inline XPStack::XPStack(const XPStack& s) : p(s.p) {} + +inline XPStack::~XPStack() {} + +inline void XPStack::push(item) +{ + p.add_high(item); +} + +inline XPStack::pop() +{ + res = p.high_element(); + p.del_high(); + return res; +} + +inline & XPStack::top() +{ + return p.high_element(); +} + +inline void XPStack::del_top() +{ + p.del_high(); +} + +inline void XPStack::operator =(const XPStack& s) +{ + p.operator = (s.p); +} + +inline int XPStack::empty() +{ + return p.empty(); +} + +inline int XPStack::full() +{ + return p.full(); +} + +inline int XPStack::length() +{ + return p.length(); +} + +inline int XPStack::OK() +{ + return p.OK(); +} + +inline void XPStack::clear() +{ + p.clear(); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/XPlex.ccP b/gnu/lib/libg++/libg++/src/gen/XPlex.ccP new file mode 100644 index 00000000000..f5304222993 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPlex.ccP @@ -0,0 +1,397 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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 ".XPlex.h" + + +XPlex:: XPlex() +{ + lo = fnc = 0; + csize = DEFAULT_INITIAL_CAPACITY; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, lo+csize)); + hd = ch; +} + +XPlex:: XPlex(int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + lo = fnc = 0; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, csize)); + hd = ch; + } + else + { + csize = -chunksize; + * data = new [csize]; + set_cache(new IChunk(data, chunksize, lo, fnc, fnc)); + hd = ch; + } +} + + +XPlex:: XPlex(int l, int chunksize) +{ + if (chunksize == 0) error("invalid constructor specification"); + lo = fnc = l; + if (chunksize > 0) + { + csize = chunksize; + * data = new [csize]; + set_cache(new IChunk(data, lo, lo, fnc, csize+lo)); + hd = ch; + } + else + { + csize = -chunksize; + * data = new [csize]; + set_cache(new IChunk(data, chunksize+lo, lo, fnc, fnc)); + hd = ch; + } +} + +void XPlex::make_initial_chunks(int up) +{ + int need = fnc - lo; + hd = 0; + if (up) + { + int l = lo; + do + { + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + IChunk* h = new IChunk(data, l, l, l+sz, l+csize); + if (hd != 0) + h->link_to_next(hd); + else + hd = h; + l += sz; + need -= sz; + } while (need > 0); + } + else + { + int hi = fnc; + do + { + int sz; + if (need >= csize) + sz = csize; + else + sz = need; + * data = new [csize]; + IChunk* h = new IChunk(data, hi-csize, hi-sz, hi, hi); + if (hd != 0) + h->link_to_next(hd); + hd = h; + hi -= sz; + need -= sz; + } while (need > 0); + } + set_cache(hd); +} + +XPlex:: XPlex(int l, int hi, const initval, int chunksize) +{ + lo = l; + fnc = hi + 1; + if (chunksize == 0) + { + csize = fnc - l; + make_initial_chunks(1); + } + else if (chunksize < 0) + { + csize = -chunksize; + make_initial_chunks(0); + } + else + { + csize = chunksize; + make_initial_chunks(1); + } + fill(initval); +} + +XPlex::XPlex(const XPlex& a) +{ + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + make_initial_chunks(); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; +} + +void XPlex::operator= (const XPlex& a) +{ + if (&a != this) + { + invalidate(); + lo = a.lo; + fnc = a.fnc; + csize = a.csize; + make_initial_chunks(); + for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; + } +} + + +void XPlex::cache(int idx) const +{ + const IChunk* tail = tl(); + const IChunk* t = ch; + while (idx >= t->fence_index()) + { + if (t == tail) index_error(); + t = (t->next()); + } + while (idx < t->low_index()) + { + if (t == hd) index_error(); + t = (t->prev()); + } + set_cache(t); +} + + +void XPlex::cache(const * p) const +{ + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) index_error(); + } + set_cache(t); +} + +int XPlex::owns(Pix px) const +{ + * p = (*)px; + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) { set_cache(t); return 0; } + } + set_cache(t); + return 1; +} + + +* XPlex::dosucc(const * p) const +{ + if (p == 0) return 0; + const IChunk* old = ch; + const IChunk* t = ch; + + while (!t->actual_pointer(p)) + { + t = (t->next()); + if (t == old) return 0; + } + int i = t->index_of(p) + 1; + if (i >= fnc) return 0; + if (i >= t->fence_index()) t = (t->next()); + set_cache(t); + return (t->pointer_to(i)); +} + +* XPlex::dopred(const * p) const +{ + if (p == 0) return 0; + const IChunk* old = ch; + const IChunk* t = ch; + while (!t->actual_pointer(p)) + { + t = (t->prev()); + if (t == old) return 0; + } + int i = t->index_of(p) - 1; + if (i < lo) return 0; + if (i < t->low_index()) t = (t->prev()); + set_cache(t); + return (t->pointer_to(i)); +} + + +int XPlex::add_high(const elem) +{ + IChunk* t = tl(); + if (!t->can_grow_high()) + { + if (t->IChunk::empty() && one_chunk()) + t->clear(fnc); + else + { + * data = new [csize]; + t = (new IChunk(data, fnc, fnc, fnc,fnc+csize)); + t->link_to_prev(tl()); + } + } + *((t->IChunk::grow_high())) = elem; + set_cache(t); + return fnc++; +} + +int XPlex::del_high () +{ + if (empty()) empty_error(); + IChunk* t = tl(); + t->IChunk::shrink_high(); + if (t->IChunk::empty() && !one_chunk()) + { + IChunk* pred = t->prev(); + del_chunk(t); + t = pred; + } + set_cache(t); + return --fnc - 1; +} + +int XPlex::add_low (const elem) +{ + IChunk* t = hd; + if (!t->can_grow_low()) + { + if (t->IChunk::empty() && one_chunk()) + t->cleardown(lo); + else + { + * data = new [csize]; + hd = new IChunk(data, lo-csize, lo, lo, lo); + hd->link_to_next(t); + t = hd; + } + } + *((t->IChunk::grow_low())) = elem; + set_cache(t); + return --lo; +} + + +int XPlex::del_low () +{ + if (empty()) empty_error(); + IChunk* t = hd; + t->IChunk::shrink_low(); + if (t->IChunk::empty() && !one_chunk()) + { + hd = t->next(); + del_chunk(t); + t = hd; + } + set_cache(t); + return ++lo; +} + +void XPlex::reverse() +{ + tmp; + int l = lo; + int h = fnc - 1; + IChunk* loch = hd; + IChunk* hich = tl(); + while (l < h) + { + * lptr = loch->pointer_to(l); + * hptr = hich->pointer_to(h); + tmp = *lptr; + *lptr = *hptr; + *hptr = tmp; + if (++l >= loch->fence_index()) loch = loch->next(); + if (--h < hich->low_index()) hich = hich->prev(); + } +} + +void XPlex::fill(const x) +{ + for (int i = lo; i < fnc; ++i) (*this)[i] = x; +} + +void XPlex::fill(const x, int l, int hi) +{ + for (int i = l; i <= hi; ++i) (*this)[i] = x; +} + + +void XPlex::clear() +{ + if (fnc != lo) + { + IChunk* t = tl(); + while (t != hd) + { + IChunk* prv = t->prev(); + del_chunk(t); + t = prv; + } + t->IChunk::clear(lo); + set_cache(t); + fnc = lo; + } +} + + +int XPlex::OK () const +{ + int v = hd != 0 && ch != 0; // at least one chunk + + v &= fnc == tl()->fence_index();// last chunk fence == plex fence + v &= lo == ((hd))->IChunk::low_index(); // first lo == plex lo + +// loop for others: + int found_ch = 0; // to make sure ch is in list; + const IChunk* t = (hd); + for (;;) + { + if (t == ch) ++found_ch; + v &= t->IChunk::OK(); // each chunk is OK + if (t == tl()) + break; + else // and has indices contiguous to succ + { + v &= t->top_index() == t->next()->base_index(); + if (t != hd) // internal chunks full + { + v &= !t->empty(); + v &= !t->can_grow_low(); + v &= !t->can_grow_high(); + } + t = t->next(); + } + } + v &= found_ch == 1; + if (!v) error("invariant failure"); + return v; +} diff --git a/gnu/lib/libg++/libg++/src/gen/XPlex.hP b/gnu/lib/libg++/libg++/src/gen/XPlex.hP new file mode 100644 index 00000000000..82445b30874 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/XPlex.hP @@ -0,0 +1,238 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +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. +*/ + +#ifndef _XPlex_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _XPlex_h 1 + +#include ".Plex.h" + +class XPlex: public Plex +{ + IChunk* ch; // cached chunk + + void make_initial_chunks(int up = 1); + + void cache(int idx) const; + void cache(const * p) const; + + * dopred(const * p) const; + * dosucc(const * p) const; + + inline void set_cache(const IChunk* t) const; // logically, + // not physically const +public: + XPlex(); // set low = 0; + // fence = 0; + // csize = default + + XPlex(int ch_size); // low = 0; + // fence = 0; + // csize = ch_size + + XPlex(int lo, // low = lo; + int ch_size); // fence=lo + // csize = ch_size + + XPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int ch_size = 0); // csize= ch_size + // or fence-lo if 0 + + XPlex(const XPlex&); + + void operator= (const XPlex&); + +// virtuals + + + inline & high_element (); + inline & low_element (); + + inline const & high_element () const; + inline const & low_element () const; + + inline Pix first() const; + inline Pix last() const; + inline void prev(Pix& ptr) const; + inline void next(Pix& ptr) const; + int owns(Pix p) const; + inline & operator () (Pix p); + inline const & operator () (Pix p) const; + + inline int low() const; + inline int high() const; + inline int valid(int idx) const; + inline void prev(int& idx) const; + inline void next(int& x) const; + inline & operator [] (int index); + inline const & operator [] (int index) const; + + inline int Pix_to_index(Pix p) const; + inline Pix index_to_Pix(int idx) const; + + inline int can_add_high() const; + inline int can_add_low() const; + inline int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + + int OK () const; + +}; + + +inline void XPlex::prev(int& idx) const +{ + --idx; +} + +inline void XPlex::next(int& idx) const +{ + ++idx; +} + +inline int XPlex::full () const +{ + return 0; +} + +inline int XPlex::can_add_high() const +{ + return 1; +} + +inline int XPlex::can_add_low() const +{ + return 1; +} + +inline int XPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int XPlex::low() const +{ + return lo; +} + +inline int XPlex::high() const +{ + return fnc - 1; +} + +inline & XPlex:: operator [] (int idx) +{ + if (!ch->actual_index(idx)) cache(idx); + return *(ch->pointer_to(idx)); +} + +inline const & XPlex:: operator [] (int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return *((const *)(ch->pointer_to(idx))); +} + +inline & XPlex::low_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline const & XPlex::low_element () const +{ + if (empty()) index_error(); + return *((const *)(hd->pointer_to(lo))); +} + +inline & XPlex::high_element () +{ + if (empty()) index_error(); + return *(tl()->pointer_to(fnc - 1)); +} + +inline const & XPlex::high_element () const +{ + if (empty()) index_error(); + return *((const *)(tl()->pointer_to(fnc - 1))); +} + +inline int XPlex::Pix_to_index(Pix px) const +{ + * p = (*)px; + if (!ch->actual_pointer(p)) cache(p); + return ch->index_of(p); +} + +inline Pix XPlex::index_to_Pix(int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return (Pix)(ch->pointer_to(idx)); +} + +inline Pix XPlex::first() const +{ + return Pix(hd->IChunk::first_pointer()); +} + +inline Pix XPlex::last() const +{ + return Pix(tl()->IChunk::last_pointer()); +} + +inline void XPlex::prev(Pix& p) const +{ + Pix q = Pix(ch->IChunk::pred((*) p)); + p = (q == 0)? Pix(dopred((const *) p)) : q; +} + +inline void XPlex::next(Pix& p) const +{ + Pix q = Pix(ch->IChunk::succ((*) p)); + p = (q == 0)? Pix(dosucc((const *)p)) : q; +} + +inline & XPlex:: operator () (Pix p) +{ + return *((*)p); +} + +inline const & XPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline void XPlex::set_cache(const IChunk* t) const +{ + ((XPlex*)(this))->ch = (IChunk*)t; +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/defs.hP b/gnu/lib/libg++/libg++/src/gen/defs.hP new file mode 100644 index 00000000000..f03617594fe --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/defs.hP @@ -0,0 +1,57 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + + +#ifndef _defs_h +#define _defs_h 1 + + +// equality operator +#ifndef EQ +#define EQ(a, b) ((a) == (b)) +#endif + +// less-than-or-equal +#ifndef LE +#define LE(a, b) ((a) <= (b)) +#endif + +// comparison : less-than -> < 0; equal -> 0; greater-than -> > 0 +#ifndef CMP +#define CMP(a, b) ( ((a) <= (b))? (((a) == (b))? 0 : -1) : 1 ) +#endif + +// hash function +#ifndef HASH +extern unsigned int hash(); +#define HASH(x) hash(x) +#endif + +// initial capacity for structures requiring one + +#ifndef DEFAULT_INITIAL_CAPACITY +#define DEFAULT_INITIAL_CAPACITY 100 +#endif + +// HASHTABLE_TOO_CROWDED(COUNT, SIZE) is true iff a hash table with COUNT +// elements and SIZE slots is too full, and should be resized. +// This is so if available space is less than 1/8. + +#define HASHTABLE_TOO_CROWDED(COUNT, SIZE) ((SIZE) - ((SIZE) >> 3) <= (COUNT)) + +#endif diff --git a/gnu/lib/libg++/libg++/src/gen/intSList.hP b/gnu/lib/libg++/libg++/src/gen/intSList.hP new file mode 100644 index 00000000000..24aa3b6a685 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/intSList.hP @@ -0,0 +1,33 @@ +/* : Light weight List: This will simply reuse code from a int List, which +was genclassed from the SLList libg++ class. The classes generated from this file +will all be derived classes from class VoidSLList or intSLList. Note that class SLList does not +offer all the functionality of List classes, such as sharing of sub-Lists. +However, no additional code is needed at all and no .cc file is generated. So it costs nothing +to use these type-safe Lists. Only member functions needing type casting are re-defined */ + + +#ifndef _SList_h +#define _SList_h 1 + +#include "int.SLList.h" +#include ".defs.h" + +class SList : public intSLList +{ +public: + SList() {} + SList(SList& a) : (a) {} + ~SList() {} + + SList& operator = (SList& a) { + return (SList&) intSLList::operator= (a); } + + & operator () (Pix p) { return (&) (intSLList::operator() (p)); } + & front() { return (&) intSLList::front(); } + & rear() { return (&) intSLList::rear(); } + remove_front() { return () intSLList::remove_front(); } + +}; + +#endif /* conditional include */ + diff --git a/gnu/lib/libg++/libg++/src/gen/intVec.hP b/gnu/lib/libg++/libg++/src/gen/intVec.hP new file mode 100644 index 00000000000..e3838700251 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/gen/intVec.hP @@ -0,0 +1,80 @@ +/* : light weight Vector: This will simply reuse code from */ +/* a int Vec, which was genclassed from the Vec libg++ class. */ +/* The classes generated from this file will all be derived classes */ +/* from class VoidVec or intVec. No .cc file is generated. So */ +/* it costs nothing to use these type-safe Vectors. Only member */ +/* functions needing type casting are re-defined. */ +/* */ + +#ifndef _Vec_h +#define _Vec_h 1 + +#include "int.Vec.h" +#include ".defs.h" + + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)( ); +typedef (*Mapper)( ); +typedef (*Combiner)( , ); +typedef int (*Predicate)( ); +typedef int (*Comparator)( , ); +#endif + +class Vec : public intVec +{ +protected: + Vec(int l, * d) : (l, (int*) d) {}; +public: + Vec() {}; + Vec(int l) : (l) {}; + Vec(int l, fill_value) : (l, fill_value) {}; + Vec(Vec& v) : (v) {}; + Vec(intVec& v) {fake_copy(v, s, len);} + ~Vec() {}; + + Vec& operator = (Vec& a) + {return (Vec&) intVec::operator= (a);} + Vec at(int from, int n) {return (Vec) intVec::at(from, n);} + + & operator [] (int n) {return (&)intVec::operator[] (n);} + & elem(int n) {return (&)intVec::elem(n);} + + friend Vec concat(Vec& a, Vec& b); + friend Vec map(Mapper f, Vec & a); + friend Vec merge(Vec & a, Vec & b, Comparator f); + friend Vec combine(Combiner f, Vec & a, Vec & b); + friend Vec reverse(Vec& a); + + void sort(Comparator f); + void apply(Procedure f); + reduce(Combiner f, base); +}; + +inline Vec concat(Vec& a, Vec& b) +{return (Vec)concat((intVec&)a, (intVec&)b);} + +inline Vec map(Mapper f, Vec & a) { + return (Vec)map((intMapper)f, (intVec&)a); } + +inline Vec merge(Vec & a, Vec & b, Comparator f) { + return (Vec)merge((intVec&)a, (intVec&)b, (intComparator)f); } + +inline Vec combine(Combiner f, Vec & a, Vec & b) { + return (Vec)combine((intCombiner)f, (intVec&)a, (intVec&)b); } + +inline Vec reverse(Vec& a) { + return (Vec)reverse((intVec&)a);} + +inline void Vec::sort(Comparator f) { + intVec::sort((intComparator) f); } + +inline void Vec::apply(Procedure f) { + intVec::apply((intProcedure) f); } + +inline Vec::reduce(Combiner f, base) { + return ()intVec::reduce((intCombiner)f, base);} + +#endif /* conditional include */ + diff --git a/gnu/lib/libg++/libg++/src/generic.h b/gnu/lib/libg++/libg++/src/generic.h new file mode 100644 index 00000000000..d49a924afd1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/generic.h @@ -0,0 +1,54 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +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. +*/ + +#ifndef generic_h +#define generic_h 1 + +/* + * See the CPP manual, argument prescan section for explanation + */ + +#define name2(a,b) gEnErIc2(a,b) +#define gEnErIc2(a,b) a ## b + +#define name3(a,b,c) gEnErIc3(a,b,c) +#define gEnErIc3(a,b,c) a ## b ## c + +#define name4(a,b,c,d) gEnErIc4(a,b,c,d) +#define gEnErIc4(a,b,c,d) a ## b ## c ## d + +#define GENERIC_STRING(a) gEnErIcStRiNg(a) +#define gEnErIcStRiNg(a) #a + +#define declare(clas,t) name2(clas,declare)(t) +#define declare2(clas,t1,t2) name2(clas,declare2)(t1,t2) + +#define implement(clas,t) name2(clas,implement)(t) +#define implement2(clas,t1,t2) name2(clas,implement2)(t1,t2) + +//extern genericerror(int,char*); +typedef int (*GPT)(int,char*); + +#define set_handler(gen,type,x) name4(set_,type,gen,_handler)(x) + +#define errorhandler(gen,type) name3(type,gen,handler) + +#define callerror(gen,type,a,b) (*errorhandler(gen,type))(a,b) + + +#endif /* generic_h */ diff --git a/gnu/lib/libg++/libg++/src/getpagesize.h b/gnu/lib/libg++/libg++/src/getpagesize.h new file mode 100644 index 00000000000..17d84316bd5 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/getpagesize.h @@ -0,0 +1,27 @@ +#if defined(BSD) || defined(DGUX) +#ifndef BSD4_1 +#define HAVE_GETPAGESIZE +#endif +#endif + +#ifndef HAVE_GETPAGESIZE + +#include + +#ifdef EXEC_PAGESIZE +#define getpagesize() EXEC_PAGESIZE +#else +#ifdef NBPG +#define getpagesize() NBPG * CLSIZE +#ifndef CLSIZE +#define CLSIZE 1 +#endif /* no CLSIZE */ +#else /* no NBPG */ +#ifdef NBPC +#define getpagesize() NBPC +#endif /* NBPC */ +#endif /* no NBPG */ +#endif /* no EXEC_PAGESIZE */ + +#endif /* not HAVE_GETPAGESIZE */ + diff --git a/gnu/lib/libg++/libg++/src/hash.cc b/gnu/lib/libg++/libg++/src/hash.cc new file mode 100644 index 00000000000..670e53f2bda --- /dev/null +++ b/gnu/lib/libg++/libg++/src/hash.cc @@ -0,0 +1,56 @@ +/* +Copyright (C) 1990 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 + +/* + some useful hash functions +*/ + +unsigned int hashpjw(const char* x) // From Dragon book, p436 +{ + unsigned int h = 0; + unsigned int g; + + while (*x != 0) + { + h = (h << 4) + *x++; + if ((g = h & 0xf0000000) != 0) + h = (h ^ (g >> 24)) ^ g; + } + return h; +} + +unsigned int multiplicativehash(int x) +{ + // uses a const close to golden ratio * pow(2,32) + return ((unsigned)x) * 2654435767; +} + + +unsigned int foldhash(double x) +{ + union { unsigned int i[2]; double d; } u; + u.d = x; + unsigned int u0 = u.i[0]; + unsigned int u1 = u.i[1]; + return u0 ^ u1; +} + diff --git a/gnu/lib/libg++/libg++/src/ioob.cc b/gnu/lib/libg++/libg++/src/ioob.cc new file mode 100644 index 00000000000..08409a5d292 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/ioob.cc @@ -0,0 +1,32 @@ +/* +Copyright (C) 1990 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +// Obstacks are used as an easy way to allocate enough space +// for various builtin input operations + + +Obstack _libgxx_io_ob; diff --git a/gnu/lib/libg++/libg++/src/lg.cc b/gnu/lib/libg++/libg++/src/lg.cc new file mode 100644 index 00000000000..0397dd43f01 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/lg.cc @@ -0,0 +1,32 @@ +/* +Copyright (C) 1990 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 + +long lg(unsigned long x) +{ + long l = 0; + while (x > 1) + { + x = x >> 1; + ++l; + } + return l; +} diff --git a/gnu/lib/libg++/libg++/src/libc.h b/gnu/lib/libg++/libg++/src/libc.h new file mode 100644 index 00000000000..c8b49f26d17 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/libc.h @@ -0,0 +1 @@ +#include diff --git a/gnu/lib/libg++/libg++/src/malloc.c b/gnu/lib/libg++/libg++/src/malloc.c new file mode 100644 index 00000000000..c9fb04e14d7 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/malloc.c @@ -0,0 +1,1205 @@ +/* + A version of malloc/free/realloc written by Doug Lea and released to the + public domain. + + VERSION 2.5 + +* History: + Based loosely on libg++-1.2X malloc. (It retains some of the overall + structure of old version, but most details differ.) + trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) + fixups Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) + * removed potential for odd address access in prev_chunk + * removed dependency on getpagesize.h + * misc cosmetics and a bit more internal documentation + * anticosmetics: mangled names in macros to evade debugger strangeness + * tested on sparc, hp-700, dec-mips, rs6000 + with gcc & native cc (hp, dec only) allowing + Detlefs & Zorn comparison study (to appear, SIGPLAN Notices.) + +* Overview + + This malloc, like any other, is a compromised design. + + Chunks of memory are maintained using a `boundary tag' method as + described in e.g., Knuth or Standish. The size of the chunk is + stored both in the front of the chunk and at the end. This makes + consolidating fragmented chunks into bigger chunks very fast. The + size field also hold a bit representing whether a chunk is free or + in use. + + Malloced chunks have space overhead of 8 bytes: The preceding and + trailing size fields. When a chunk is freed, 8 additional bytes are + needed for free list pointers. Thus, the minimum allocatable size is + 16 bytes. 8 byte alignment is currently hardwired into the design. + This seems to suffice for all current machines and C compilers. + Calling memalign will return a chunk that is both 8-byte aligned + and meets the requested (power of two) alignment. + + It is assumed that 32 bits suffice to represent chunk sizes. The + maximum size chunk is 2^31 - 8 bytes. malloc(0) returns a pointer + to something of the minimum allocatable size. Requests for negative + sizes (when size_t is signed) or with the highest bit set (when + unsigned) will also return a minimum-sized chunk. + + Available chunks are kept in doubly linked lists. The lists are + maintained in an array of bins using a power-of-two method, except + that instead of 32 bins (one for each 1 << i), there are 128: each + power of two is split in quarters. Chunk sizes up to 128 are + treated specially; they are categorized on 8-byte boundaries. This + both better distributes them and allows for special faster + processing. + + The use of very fine bin sizes closely approximates the use of one + bin per actually used size, without necessitating the overhead of + locating such bins. It is especially desirable in common + applications where large numbers of identically-sized blocks are + malloced/freed in some dynamic manner, and then later are all freed. + The finer bin sizes make finding blocks fast, with little wasted + overallocation. The consolidation methods ensure that once the + collection of blocks is no longer useful, fragments are gathered + into bigger chunks awaiting new roles. + + The bins av[i] serve as heads of the lists. Bins contain a dummy + header for the chunk lists. Each bin has two lists. The `dirty' list + holds chunks that have been returned (freed) and not yet either + re-malloc'ed or consolidated. (A third free-standing list contains + returned chunks that have not yet been processed at all.) The `clean' + list holds split-off fragments and consolidated space. All + procedures maintain the invariant that no clean chunk physically + borders another clean chunk. Thus, clean chunks never need to be + scanned during consolidation. + +* Algorithms + + Malloc: + + This is a very heavily disguised first-fit algorithm. + Most of the heuristics are designed to maximize the likelihood + that a usable chunk will most often be found very quickly, + while still minimizing fragmentation and overhead. + + The allocation strategy has several phases: + + 0. Convert the request size into a usable form. This currently + means to add 8 bytes overhead plus possibly more to obtain + 8-byte alignment. Call this size `nb'. + + 1. Check if the last returned (free()'d) or preallocated chunk + is of the exact size nb. If so, use it. `Exact' means no + more than MINSIZE (currently 16) bytes larger than nb. This + cannot be reduced, since a chunk with size < MINSIZE cannot + be created to hold the remainder. + + This check need not fire very often to be effective. It + reduces overhead for sequences of requests for the same + preallocated size to a dead minimum. + + 2. Look for a dirty chunk of exact size in the bin associated + with nb. `Dirty' chunks are those that have never been + consolidated. Besides the fact that they, but not clean + chunks require scanning for consolidation, these chunks are + of sizes likely to be useful because they have been + previously requested and then freed by the user program. + + Dirty chunks of bad sizes (even if too big) are never used + without consolidation. Among other things, this maintains the + invariant that split chunks (see below) are ALWAYS clean. + + 2a If there are dirty chunks, but none of the right size, + consolidate them all, as well as any returned chunks + (i.e., the ones from step 3). This is all a heuristic for + detecting and dealing with excess fragmentation and + random traversals through memory that degrade + performance especially when the user program is running + out of physical memory. + + 3. Pull other requests off the returned chunk list, using one if + it is of exact size, else distributing into the appropriate + bins. + + 4. Try to use the last chunk remaindered during a previous + malloc. (The ptr to this chunk is kept in var last_remainder, + to make it easy to find and to avoid useless re-binning + during repeated splits. The code surrounding it is fairly + delicate. This chunk must be pulled out and placed in a bin + prior to any consolidation, to avoid having other pointers + point into the middle of it, or try to unlink it.) If + it is usable, proceed to step 9. + + 5. Scan through clean chunks in the bin, choosing any of size >= + nb. Split later (step 9) if necessary below. (Unlike in step + 2, it is good to split here, because it creates a chunk of a + known-to-be-useful size out of a fragment that happened to be + close in size.) + + 6. Scan through the clean lists of all larger bins, selecting + any chunk at all. (It will surely be big enough since it is + in a bigger bin.) The scan goes upward from small bins to + large. It would be faster downward, but could lead to excess + fragmentation. If successful, proceed to step 9. + + 7. Consolidate chunks in other dirty bins until a large enough + chunk is created. Break out to step 9 when one is found. + + Bins are selected for consolidation in a circular fashion + spanning across malloc calls. This very crudely approximates + LRU scanning -- it is an effective enough approximation for + these purposes. + + 8. Get space from the system using sbrk. + + Memory is gathered from the system (via sbrk) in a way that + allows chunks obtained across different sbrk calls to be + consolidated, but does not require contiguous memory. Thus, + it should be safe to intersperse mallocs with other sbrk + calls. + + 9. If the selected chunk is too big, then: + + 9a If this is the second split request for nb bytes in a row, + use this chunk to preallocate up to MAX_PREALLOCS + additional chunks of size nb and place them on the + returned chunk list. (Placing them here rather than in + bins speeds up the most common case where the user + program requests an uninterrupted series of identically + sized chunks. If this is not true, the chunks will be + binned in step 3 next time.) + + 9b Split off the remainder and place in last_remainder. + Because of all the above, the remainder is always a + `clean' chunk. + + 10. Return the chunk. + + + Free: + Deallocation (free) consists only of placing the chunk on a list + of returned chunks. free(0) has no effect. Because freed chunks + may be overwritten with link fields, this malloc will often die + when freed memory is overwritten by user programs. This can be + very effective (albeit in an annoying way) in helping users track + down dangling pointers. + + Realloc: + Reallocation proceeds in the usual way. If a chunk can be extended, + it is, else a malloc-copy-free sequence is taken. + + Memalign, valloc: + memalign arequests more than enough space from malloc, finds a spot + within that chunk that meets the alignment request, and then + possibly frees the leading and trailing space. Overreliance on + memalign is a sure way to fragment space. + +* Other implementation notes + + This malloc is NOT designed to work in multiprocessing applications. + No semaphores or other concurrency control are provided to ensure + that multiple malloc or free calls don't run at the same time, which + could be disasterous. A single semaphore could be used across malloc, + realloc, and free. It would be hard to obtain finer granularity. + + The implementation is in straight, hand-tuned ANSI C. Among other + consequences, it uses a lot of macros. These would be nicer as + inlinable procedures, but using macros allows use with non-inlining + compilers, and also makes it a bit easier to control when they + should be expanded out by selectively embedding them in other macros + and procedures. (According to profile information, it is almost, but + not quite always best to expand.) + +*/ + + + +/* TUNABLE PARAMETERS */ + +/* + SBRK_UNIT is a good power of two to call sbrk with It should + normally be system page size or a multiple thereof. If sbrk is very + slow on a system, it pays to increase this. Otherwise, it should + not matter too much. +*/ + +#define SBRK_UNIT 8192 + +/* + MAX_PREALLOCS is the maximum number of chunks to preallocate. The + actual number to prealloc depends on the available space in a + selected victim, so typical numbers will be less than the maximum. + Because of this, the exact value seems not to matter too much, at + least within values from around 1 to 100. Since preallocation is + heuristic, making it too huge doesn't help though. It may blindly + create a lot of chunks when it turns out not to need any more, and + then consolidate them all back again immediatetly. While this is + pretty fast, it is better to avoid it. +*/ + +#define MAX_PREALLOCS 5 + + + + +/* preliminaries */ + +#include /* for size_t */ +#include /* needed for malloc_stats */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern void* sbrk(size_t); + +/* mechanics for getpagesize; adapted from bsd/gnu getpagesize.h */ + +#if defined(BSD) || defined(DGUX) || defined(sun) || defined(HAVE_GETPAGESIZE) + extern size_t getpagesize(); +# define malloc_getpagesize getpagesize() +#else +# include +# ifdef EXEC_PAGESIZE +# define malloc_getpagesize EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define malloc_getpagesize NBPG +# else +# define malloc_getpagesize (NBPG * CLSIZE) +# endif +# else +# ifdef NBPC +# define malloc_getpagesize NBPC +# else +# define malloc_getpagesize SBRK_UNIT /* just guess */ +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +}; /* end of extern "C" */ +#endif + + + +/* CHUNKS */ + + +struct malloc_chunk +{ + size_t size; /* Size in bytes, including overhead. */ + /* Or'ed with INUSE if in use. */ + + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; + +}; + +typedef struct malloc_chunk* mchunkptr; + +/* sizes, alignments */ + +#define SIZE_SZ (sizeof(size_t)) +#define MALLOC_MIN_OVERHEAD (SIZE_SZ + SIZE_SZ) +#define MALLOC_ALIGN_MASK (MALLOC_MIN_OVERHEAD - 1) +#define MINSIZE (sizeof(struct malloc_chunk) + SIZE_SZ) + + +/* pad request bytes into a usable size */ + +#define request2size(req) \ + (((long)(req) <= 0) ? MINSIZE : \ + (((req) + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) \ + & ~(MALLOC_ALIGN_MASK))) + + +/* Check if m has acceptable alignment */ + +#define aligned_OK(m) (((size_t)((m)) & (MALLOC_ALIGN_MASK)) == 0) + + +/* Check if a chunk is immediately usable */ + +#define exact_fit(ptr, req) ((unsigned)((ptr)->size - (req)) < MINSIZE) + +/* maintaining INUSE via size field */ + +#define INUSE 0x1 /* size field is or'd with INUSE when in use */ + /* INUSE must be exactly 1, so can coexist with size */ + +#define inuse(p) ((p)->size & INUSE) +#define set_inuse(p) ((p)->size |= INUSE) +#define clear_inuse(p) ((p)->size &= ~INUSE) + + + +/* Physical chunk operations */ + +/* Ptr to next physical malloc_chunk. */ + +#define next_chunk(p)\ + ((mchunkptr)( ((char*)(p)) + ((p)->size & ~INUSE) )) + +/* Ptr to previous physical malloc_chunk */ + +#define prev_chunk(p)\ + ((mchunkptr)( ((char*)(p)) - ( *((size_t*)((char*)(p) - SIZE_SZ)) & ~INUSE))) + +/* place size at front and back of chunk */ + +#define set_size(P, Sz) \ +{ \ + size_t Sss = (Sz); \ + (P)->size = *((size_t*)((char*)(P) + Sss - SIZE_SZ)) = Sss; \ +} \ + + +/* conversion from malloc headers to user pointers, and back */ + +#define chunk2mem(p) ((void*)((char*)(p) + SIZE_SZ)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - SIZE_SZ)) + + + + +/* BINS */ + +struct malloc_bin +{ + struct malloc_chunk dhd; /* dirty list header */ + struct malloc_chunk chd; /* clean list header */ +}; + +typedef struct malloc_bin* mbinptr; + + +/* field-extraction macros */ + +#define clean_head(b) (&((b)->chd)) +#define first_clean(b) ((b)->chd.fd) +#define last_clean(b) ((b)->chd.bk) + +#define dirty_head(b) (&((b)->dhd)) +#define first_dirty(b) ((b)->dhd.fd) +#define last_dirty(b) ((b)->dhd.bk) + + + + +/* The bins, initialized to have null double linked lists */ + +#define NBINS 128 /* for 32 bit addresses */ +#define LASTBIN (&(av[NBINS-1])) +#define FIRSTBIN (&(av[2])) /* 1st 2 bins unused but simplify indexing */ + +/* Bins < MAX_SMALLBIN_OFFSET are special-cased since they are 8 bytes apart */ + +#define MAX_SMALLBIN_OFFSET 18 +#define MAX_SMALLBIN_SIZE 144 /* Max size for which small bin rules apply */ + +/* Helper macro to initialize bins */ +#define IAV(i)\ + {{ 0, &(av[i].dhd), &(av[i].dhd) }, { 0, &(av[i].chd), &(av[i].chd) }} + +static struct malloc_bin av[NBINS] = +{ + IAV(0), IAV(1), IAV(2), IAV(3), IAV(4), + IAV(5), IAV(6), IAV(7), IAV(8), IAV(9), + IAV(10), IAV(11), IAV(12), IAV(13), IAV(14), + IAV(15), IAV(16), IAV(17), IAV(18), IAV(19), + IAV(20), IAV(21), IAV(22), IAV(23), IAV(24), + IAV(25), IAV(26), IAV(27), IAV(28), IAV(29), + IAV(30), IAV(31), IAV(32), IAV(33), IAV(34), + IAV(35), IAV(36), IAV(37), IAV(38), IAV(39), + IAV(40), IAV(41), IAV(42), IAV(43), IAV(44), + IAV(45), IAV(46), IAV(47), IAV(48), IAV(49), + IAV(50), IAV(51), IAV(52), IAV(53), IAV(54), + IAV(55), IAV(56), IAV(57), IAV(58), IAV(59), + IAV(60), IAV(61), IAV(62), IAV(63), IAV(64), + IAV(65), IAV(66), IAV(67), IAV(68), IAV(69), + IAV(70), IAV(71), IAV(72), IAV(73), IAV(74), + IAV(75), IAV(76), IAV(77), IAV(78), IAV(79), + IAV(80), IAV(81), IAV(82), IAV(83), IAV(84), + IAV(85), IAV(86), IAV(87), IAV(88), IAV(89), + IAV(90), IAV(91), IAV(92), IAV(93), IAV(94), + IAV(95), IAV(96), IAV(97), IAV(98), IAV(99), + IAV(100), IAV(101), IAV(102), IAV(103), IAV(104), + IAV(105), IAV(106), IAV(107), IAV(108), IAV(109), + IAV(110), IAV(111), IAV(112), IAV(113), IAV(114), + IAV(115), IAV(116), IAV(117), IAV(118), IAV(119), + IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), + IAV(125), IAV(126), IAV(127) +}; + + + +/* + Auxiliary lists + + Even though they use bk/fd ptrs, neither of these are doubly linked! + They are null-terminated since only the first is ever accessed. + returned_list is just singly linked for speed in free(). + last_remainder currently has length of at most one. + +*/ + +static mchunkptr returned_list = 0; /* List of (unbinned) returned chunks */ +static mchunkptr last_remainder = 0; /* last remaindered chunk from malloc */ + + + +/* + Indexing into bins + + Funny-looking mechanics: + For small bins, the index is just size/8. + For others, first find index corresponding to the power of 2 + closest to size, using a variant of standard base-2 log + calculation that starts with the first non-small index and + adjusts the size so that zero corresponds with it. On each + iteration, the index is incremented across the four quadrants + per power of two. (This loop runs a max of 27 iterations; + usually much less.) After the loop, the remainder is quartered + to find quadrant. The offsets for loop termination and + quartering allow bins to start, not end at powers. +*/ + + +#define findbin(Sizefb, Bfb) \ +{ \ + size_t Sfb = (Sizefb); \ + if (Sfb < MAX_SMALLBIN_SIZE) \ + (Bfb) = (av + (Sfb >> 3)); \ + else \ + { \ + /* Offset wrt small bins */ \ + size_t Ifb = MAX_SMALLBIN_OFFSET; \ + Sfb >>= 3; \ + /* find power of 2 */ \ + while (Sfb >= (MINSIZE * 2)) { Ifb += 4; Sfb >>= 1; } \ + /* adjust for quadrant */ \ + Ifb += (Sfb - MINSIZE) >> 2; \ + (Bfb) = av + Ifb; \ + } \ +} \ + + + + +/* Keep track of the maximum actually used clean bin, to make loops faster */ +/* (Not worth it to do the same for dirty ones) */ + +static mbinptr maxClean = FIRSTBIN; + +#define reset_maxClean \ +{ \ + while (maxClean > FIRSTBIN && clean_head(maxClean)==last_clean(maxClean)) \ + --maxClean; \ +} \ + + +/* Macros for linking and unlinking chunks */ + +/* take a chunk off a list */ + +#define unlink(Qul) \ +{ \ + mchunkptr Bul = (Qul)->bk; \ + mchunkptr Ful = (Qul)->fd; \ + Ful->bk = Bul; Bul->fd = Ful; \ +} \ + + +/* place a chunk on the dirty list of its bin */ + +#define dirtylink(Qdl) \ +{ \ + mchunkptr Pdl = (Qdl); \ + mbinptr Bndl; \ + mchunkptr Hdl, Fdl; \ + \ + findbin(Pdl->size, Bndl); \ + Hdl = dirty_head(Bndl); \ + Fdl = Hdl->fd; \ + \ + Pdl->bk = Hdl; Pdl->fd = Fdl; Fdl->bk = Hdl->fd = Pdl; \ +} \ + + + +/* Place a consolidated chunk on a clean list */ + +#define cleanlink(Qcl) \ +{ \ + mchunkptr Pcl = (Qcl); \ + mbinptr Bcl; \ + mchunkptr Hcl, Fcl; \ + \ + findbin(Qcl->size, Bcl); \ + Hcl = clean_head(Bcl); \ + Fcl = Hcl->fd; \ + if (Hcl == Fcl && Bcl > maxClean) maxClean = Bcl; \ + \ + Pcl->bk = Hcl; Pcl->fd = Fcl; Fcl->bk = Hcl->fd = Pcl; \ +} \ + + + +/* consolidate one chunk */ + +#define consolidate(Qc) \ +{ \ + for (;;) \ + { \ + mchunkptr Pc = prev_chunk(Qc); \ + if (!inuse(Pc)) \ + { \ + unlink(Pc); \ + set_size(Pc, Pc->size + (Qc)->size); \ + (Qc) = Pc; \ + } \ + else break; \ + } \ + for (;;) \ + { \ + mchunkptr Nc = next_chunk(Qc); \ + if (!inuse(Nc)) \ + { \ + unlink(Nc); \ + set_size((Qc), (Qc)->size + Nc->size); \ + } \ + else break; \ + } \ +} \ + + + +/* Place the held remainder in its bin */ +/* This MUST be invoked prior to ANY consolidation */ + +#define clear_last_remainder \ +{ \ + if (last_remainder != 0) \ + { \ + cleanlink(last_remainder); \ + last_remainder = 0; \ + } \ +} \ + + +/* Place a freed chunk on the returned_list */ + +#define return_chunk(Prc) \ +{ \ + (Prc)->fd = returned_list; \ + returned_list = (Prc); \ +} \ + + + +/* Misc utilities */ + +/* A helper for realloc */ + +static void free_returned_list() +{ + clear_last_remainder; + while (returned_list != 0) + { + mchunkptr p = returned_list; + returned_list = p->fd; + clear_inuse(p); + dirtylink(p); + } +} + +/* Utilities needed below for memalign */ +/* Standard greatest common divisor algorithm */ + +static size_t gcd(size_t a, size_t b) +{ + size_t tmp; + + if (b > a) + { + tmp = a; a = b; b = tmp; + } + for(;;) + { + if (b == 0) + return a; + else if (b == 1) + return b; + else + { + tmp = b; + b = a % b; + a = tmp; + } + } +} + +static size_t lcm(size_t x, size_t y) +{ + return x / gcd(x, y) * y; +} + + + + + +/* Dealing with sbrk */ +/* This is one step of malloc; broken out for simplicity */ + +static size_t sbrked_mem = 0; /* Keep track of total mem for malloc_stats */ + +static mchunkptr malloc_from_sys(size_t nb) +{ + + /* The end of memory returned from previous sbrk call */ + static size_t* last_sbrk_end = 0; + + mchunkptr p; /* Will hold a usable chunk */ + size_t* ip; /* to traverse sbrk ptr in size_t units */ + + /* Find a good size to ask sbrk for. */ + /* Minimally, we need to pad with enough space */ + /* to place dummy size/use fields to ends if needed */ + + size_t sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) + / SBRK_UNIT) * SBRK_UNIT; + + ip = (size_t*)(sbrk(sbrk_size)); + if ((char*)ip == (char*)(-1)) /* sbrk returns -1 on failure */ + return 0; + + sbrked_mem += sbrk_size; + + if (last_sbrk_end != &ip[-1]) /* Is this chunk continguous with last? */ + { + /* It's either first time through or someone else called sbrk. */ + /* Arrange end-markers at front & back */ + + /* Shouldn't be necessary, but better to be safe */ + while (!aligned_OK(ip)) { ++ip; sbrk_size -= SIZE_SZ; } + + /* Mark the front as in use to prevent merging. (End done below.) */ + /* Note we can get away with only 1 word, not MINSIZE overhead here */ + + *ip++ = SIZE_SZ | INUSE; + + p = (mchunkptr)ip; + set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); + + } + else + { + mchunkptr l; + + /* We can safely make the header start at end of prev sbrked chunk. */ + /* We will still have space left at the end from a previous call */ + /* to place the end marker, below */ + + p = (mchunkptr)(last_sbrk_end); + set_size(p, sbrk_size); + + /* Even better, maybe we can merge with last fragment: */ + + l = prev_chunk(p); + if (!inuse(l)) + { + unlink(l); + set_size(l, p->size + l->size); + p = l; + } + + } + + /* mark the end of sbrked space as in use to prevent merging */ + + last_sbrk_end = (size_t*)((char*)p + p->size); + *last_sbrk_end = SIZE_SZ | INUSE; + + return p; +} + + + + +/* Consolidate dirty chunks until create one big enough for current req. */ +/* Call malloc_from_sys if can't create one. */ +/* This is just one phase of malloc, but broken out for sanity */ + +static mchunkptr malloc_find_space(size_t nb) +{ + /* Circularly traverse bins so as not to pick on any one too much */ + static mbinptr rover = LASTBIN; /* Circular roving ptr */ + + mbinptr origin = rover; + mbinptr b = rover; + + /* Preliminaries. */ + clear_last_remainder; + reset_maxClean; + + do + { + mchunkptr p; + + while ( (p = last_dirty(b)) != dirty_head(b)) + { + unlink(p); + consolidate(p); + + if (p->size >= nb) + { + rover = b; + return p; + } + else + cleanlink(p); + } + + b = (b == FIRSTBIN)? LASTBIN : b - 1; /* circularly sweep down */ + + } while (b != origin); + + /* If no return above, chain to the next step of malloc */ + return malloc_from_sys(nb); +} + + +/* Clear out dirty chunks from a bin, along with the free list. */ +/* Invoked from malloc when things look too fragmented */ + +static void malloc_clean_bin(mbinptr bin) +{ + mchunkptr p; + + clear_last_remainder; + + while ( (p = last_dirty(bin)) != dirty_head(bin)) + { + unlink(p); + consolidate(p); + cleanlink(p); + } + + while (returned_list != 0) + { + p = returned_list; + returned_list = p->fd; + clear_inuse(p); + consolidate(p); + cleanlink(p); + } +} + + + + +/* Finally, the user-level functions */ + + +void* malloc(size_t bytes) +{ + static size_t previous_request = 0; /* To control preallocation */ + + size_t nb = request2size(bytes); /* padded request size */ + mbinptr bin; /* corresponding bin */ + mchunkptr victim; /* will hold selected chunk */ + + /* ----------- Peek at returned_list; hope for luck */ + + if ((victim = returned_list) != 0 && + exact_fit(victim, nb)) /* size check works even though INUSE set */ + { + returned_list = victim->fd; + return chunk2mem(victim); + } + + findbin(nb, bin); /* Need to know bin for other traversals */ + + /* ---------- Scan dirty list of own bin */ + + /* Code for small bins special-cased out since */ + /* no size check or traversal needed and */ + /* clean bins are exact matches so might as well test now */ + + if (nb < MAX_SMALLBIN_SIZE) + { + if ( ((victim = first_dirty(bin)) != dirty_head(bin)) || + ((victim = last_clean(bin)) != clean_head(bin))) + { + unlink(victim); + set_inuse(victim); + return chunk2mem(victim); + } + } + else + { + if ( (victim = first_dirty(bin)) != dirty_head(bin)) + { + do + { + if (exact_fit(victim, nb)) + { + unlink(victim); + set_inuse(victim); + return chunk2mem(victim); + } + else victim = victim->fd; + } while (victim != dirty_head(bin)); + + /* If there were chunks in there but none matched, then */ + /* consolidate all chunks in this bin plus those on free list */ + /* to prevent further traversals and fragmentation. */ + + malloc_clean_bin(bin); + } + } + + /* ------------ Search free list */ + + if ( (victim = returned_list) != 0) + { + do + { + mchunkptr next = victim->fd; + if (exact_fit(victim, nb)) + { + returned_list = next; + return chunk2mem(victim); + } + else /* Place unusable chunks in their bins */ + { + clear_inuse(victim); + dirtylink(victim); + victim = next; + } + } while (victim != 0); + returned_list = 0; + } + + /* -------------- Try the remainder from last successful split */ + + if ( (victim = last_remainder) != 0 && victim->size >= nb) + { + last_remainder = 0; /* reset for next time */ + goto split; + } + + /* -------------- Scan through own clean bin */ + + /* (Traversing back-to-front tends to choose `old' */ + /* chunks that could not be further consolidated.) */ + + for (victim = last_clean(bin); victim != clean_head(bin); victim=victim->bk) + { + if (victim->size >= nb) + { + unlink(victim); + goto split; + } + } + + /* -------------- Try all bigger clean bins */ + + /* (Scanning upwards is slower but prevents fragmenting big */ + /* chunks that we might need later. If there aren't any smaller */ + /* ones, most likely we got a big one from last_remainder anyway.) */ + + { + mbinptr b; + + for (b = bin + 1; b <= maxClean; ++b) + { + if ( (victim = last_clean(b)) != clean_head(b) ) + { + unlink(victim); + goto split; + } + } + } + + /* ------------- Consolidate or sbrk */ + + victim = malloc_find_space(nb); + + if (victim == 0) /* propagate failure */ + return 0; + + /* -------------- Possibly split victim chunk */ + + split: + { + size_t room = victim->size - nb; + if (room >= MINSIZE) + { + mchunkptr v = victim; /* Hold so can break up in prealloc */ + + set_size(victim, nb); /* Adjust size of chunk to be returned */ + + /* ---------- Preallocate */ + + /* Try to preallocate some more of this size if */ + /* last (split) req was of same size */ + + if (previous_request == nb) + { + int i; + + for (i = 0; i < MAX_PREALLOCS && room >= nb + MINSIZE; ++i) + { + room -= nb; + + v = (mchunkptr)((char*)(v) + nb); + set_size(v, nb); + set_inuse(v); /* free-list chunks must have inuse set */ + return_chunk(v); /* add to free list */ + } + } + + previous_request = nb; /* record for next time */ + + /* ---------- Create remainder chunk */ + + /* Get rid of the old one first */ + if (last_remainder != 0) cleanlink(last_remainder); + + last_remainder = (mchunkptr)((char*)(v) + nb); + set_size(last_remainder, room); + } + + set_inuse(victim); + return chunk2mem(victim); + } +} + + + + +void free(void* mem) +{ + if (mem != 0) + { + mchunkptr p = mem2chunk(mem); + return_chunk(p); + } +} + + + + +void* realloc(void* mem, size_t bytes) +{ + if (mem == 0) + return malloc(bytes); + else + { + size_t nb = request2size(bytes); + mchunkptr p = mem2chunk(mem); + size_t oldsize; + long room; + mchunkptr nxt; + + if (p == returned_list) /* support realloc-last-freed-chunk idiocy */ + returned_list = returned_list->fd; + + clear_inuse(p); + oldsize = p->size; + + /* try to expand (even if already big enough), to clean up chunk */ + + free_returned_list(); /* make freed chunks available to consolidate */ + + while (!inuse(nxt = next_chunk(p))) /* Expand the chunk forward */ + { + unlink(nxt); + set_size(p, p->size + nxt->size); + } + + room = p->size - nb; + if (room >= 0) /* Successful expansion */ + { + if (room >= MINSIZE) /* give some back if possible */ + { + mchunkptr remainder = (mchunkptr)((char*)(p) + nb); + set_size(remainder, room); + cleanlink(remainder); + set_size(p, nb); + } + set_inuse(p); + return chunk2mem(p); + } + else /* Could not expand. Get another chunk and copy. */ + { + void* newmem; + size_t count; + size_t* src; + size_t* dst; + + set_inuse(p); /* don't let malloc consolidate us yet! */ + newmem = malloc(nb); + + /* Copy -- we know that alignment is at least `size_t' */ + + src = (size_t*) mem; + dst = (size_t*) newmem; + count = (oldsize - SIZE_SZ) / sizeof(size_t); + while (count-- > 0) *dst++ = *src++; + + free(mem); + return newmem; + } + } +} + + + +/* Return a pointer to space with at least the alignment requested */ +/* Alignment argument should be a power of two */ + +void* memalign(size_t alignment, size_t bytes) +{ + mchunkptr p; + size_t nb = request2size(bytes); + size_t room; + + /* find an alignment that both we and the user can live with: */ + /* least common multiple guarantees mutual happiness */ + size_t align = lcm(alignment, MALLOC_MIN_OVERHEAD); + + /* call malloc with worst case padding to hit alignment; */ + /* we will give back extra */ + + size_t req = nb + align + MINSIZE; + void* m = malloc(req); + + if (m == 0) return 0; /* propagate failure */ + + p = mem2chunk(m); + clear_inuse(p); + + + if (((size_t)(m) % align) != 0) /* misaligned */ + { + + /* find an aligned spot inside chunk */ + + mchunkptr ap = (mchunkptr)((((size_t)(m) + align-1) & -align) - SIZE_SZ); + + size_t gap = (size_t)(ap) - (size_t)(p); + + /* we need to give back leading space in a chunk of at least MINSIZE */ + + if (gap < MINSIZE) + { + /* This works since align >= MINSIZE */ + /* and we've malloc'd enough total room */ + + ap = (mchunkptr)( (size_t)(ap) + align ); + gap += align; + } + + room = p->size - gap; + + /* give back leader */ + set_size(p, gap); + dirtylink(p); /* Don't really know if clean or dirty; be safe */ + + /* use the rest */ + p = ap; + set_size(p, room); + } + + /* also give back spare room at the end */ + + room = p->size - nb; + if (room >= MINSIZE) + { + mchunkptr remainder = (mchunkptr)((char*)(p) + nb); + set_size(remainder, room); + dirtylink(remainder); /* Don't really know; be safe */ + set_size(p, nb); + } + + set_inuse(p); + return chunk2mem(p); + +} + + + +/* Derivatives */ + +void* valloc(size_t bytes) +{ + /* Cache result of getpagesize */ + static size_t malloc_pagesize = 0; + + if (malloc_pagesize == 0) malloc_pagesize = malloc_getpagesize; + return memalign (malloc_pagesize, bytes); +} + + +void* calloc(size_t n, size_t elem_size) +{ + size_t sz = n * elem_size; + void* p = malloc(sz); + char* q = (char*) p; + while (sz-- > 0) *q++ = 0; + return p; +} + +void cfree(void *mem) +{ + free(mem); +} + +size_t malloc_usable_size(void* mem) +{ + if (mem == 0) + return 0; + else + { + mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); + size_t sz = p->size & ~(INUSE); + /* report zero if not in use or detectably corrupt */ + if (p->size == sz || sz != *((size_t*)((char*)(p) + sz - SIZE_SZ))) + return 0; + else + return sz - MALLOC_MIN_OVERHEAD; + } +} + + +void malloc_stats() +{ + + /* Traverse through and count all sizes of all chunks */ + + size_t avail = 0; + size_t malloced_mem; + + mbinptr b; + + free_returned_list(); + + for (b = FIRSTBIN; b <= LASTBIN; ++b) + { + mchunkptr p; + + for (p = first_dirty(b); p != dirty_head(b); p = p->fd) + avail += p->size; + + for (p = first_clean(b); p != clean_head(b); p = p->fd) + avail += p->size; + } + + malloced_mem = sbrked_mem - avail; + + fprintf(stderr, "total mem = %10u\n", sbrked_mem); + fprintf(stderr, "in use = %10u\n", malloced_mem); + +} diff --git a/gnu/lib/libg++/libg++/src/minmax.cc b/gnu/lib/libg++/libg++/src/minmax.cc new file mode 100644 index 00000000000..3cbc7e48c01 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/minmax.cc @@ -0,0 +1,5 @@ +#ifdef _GNUG_ +#pragma implementation +#endif + +#include diff --git a/gnu/lib/libg++/libg++/src/minmax.h b/gnu/lib/libg++/libg++/src/minmax.h new file mode 100644 index 00000000000..ec2bfa335a7 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/minmax.h @@ -0,0 +1,65 @@ +/* +Copyright (C) 1992 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. +*/ + +#ifndef _minmax_h +#ifdef _GNUG_ +#pragma interface +#endif +#define _minmax_h 1 + +#include <_G_config.h> + +inline char min(char a, char b) { return (a < b)?a:b;} +#ifndef _G_BROKEN_SIGNED_CHAR +inline signed char min(signed char a, signed char b) { return (a < b)?a:b;} +#endif +inline unsigned char min(unsigned char a, unsigned char b) {return (a b)?a:b;} +#ifndef _G_BROKEN_SIGNED_CHAR +inline signed char max(signed char a, signed char b) {return (a > b)?a:b;} +#endif +inline unsigned char max(unsigned char a, unsigned char b) {return (a>b)?a:b;} + +inline short max(short a, short b) {return (a > b) ?a:b;} +inline unsigned short max(unsigned short a, unsigned short b) {return (a > b)?a:b;} + +inline int max(int a, int b) {return (a > b)?a:b;} +inline unsigned int max(unsigned int a, unsigned int b) {return (a > b)?a:b;} + +inline long max(long a, long b) {return (a > b)?a:b;} +inline unsigned long max(unsigned long a, unsigned long b) {return (a>b)?a:b;} + +inline float max(float a, float b) {return (a > b)?a:b;} + +inline double max(double a, double b) {return (a > b)?a:b;} + +#endif + diff --git a/gnu/lib/libg++/libg++/src/osfcn.h b/gnu/lib/libg++/libg++/src/osfcn.h new file mode 100644 index 00000000000..023b5c5b65d --- /dev/null +++ b/gnu/lib/libg++/libg++/src/osfcn.h @@ -0,0 +1,17 @@ + +#ifndef OSFCN_H +#define OSFCN_H 1 + +#include +#include +#include +#if _G_HAVE_SYS_SOCKET +#include +#endif +#if _G_HAVE_SYS_RESOURCE +#include +#include +#endif + + +#endif diff --git a/gnu/lib/libg++/libg++/src/pow.cc b/gnu/lib/libg++/libg++/src/pow.cc new file mode 100644 index 00000000000..497cb5b8b70 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/pow.cc @@ -0,0 +1,70 @@ +/* +Copyright (C) 1990 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 +#include + +double pow(double x, long p) +{ + if (p == 0) + return 1.0; + else if (x == 0.0) + return 0.0; + else + { + if (p < 0) + { + p = -p; + x = 1.0 / x; + } + + double r = 1.0; + for(;;) + { + if (p & 1) + r *= x; + if ((p >>= 1) == 0) + return r; + else + x *= x; + } + } +} + +long pow(long x, long p) +{ + if (p == 0) + return 1; + else if (p < 0 || x == 0) + return 0; + else + { + long r = 1; + for(;;) + { + if (p & 1) + r *= x; + if ((p >>= 1) == 0) + return r; + else + x *= x; + } + } +} diff --git a/gnu/lib/libg++/libg++/src/sqrt.cc b/gnu/lib/libg++/libg++/src/sqrt.cc new file mode 100644 index 00000000000..622895eed45 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/sqrt.cc @@ -0,0 +1,43 @@ +/* +Copyright (C) 1990 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 +#include + +long sqrt(long x) +{ + if (x <= 0) + return 0; // no int error handler, so ... + else if (x == 1) + return 1; + else + { + long r = x >> 1; + long q; + for(;;) + { + q = x / r; + if (q >= r) + return r; + else + r = (r + q) >> 1; + } + } +} diff --git a/gnu/lib/libg++/libg++/src/std.h b/gnu/lib/libg++/libg++/src/std.h new file mode 100644 index 00000000000..2cd73f24386 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/std.h @@ -0,0 +1,35 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992 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. +*/ + +#ifndef _std_h +#define _std_h 1 + +#include <_G_config.h> +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +int strcasecmp _G_ARGS((const char*, const char*)); +} + +#endif diff --git a/gnu/lib/libg++/libg++/src/str.cc b/gnu/lib/libg++/libg++/src/str.cc new file mode 100644 index 00000000000..bd8bc8a28d1 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/str.cc @@ -0,0 +1,38 @@ +/* +Copyright (C) 1990 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 +#include + +extern AllocRing _libgxx_fmtq; + +char* str(const char* s, int width) +{ + int len = strlen(s); + int wrksiz = len + width + 1; + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); + char* fmt = fmtbase; + for (int blanks = width - len; blanks > 0; --blanks) + *fmt++ = ' '; + while (*s != 0) + *fmt++ = *s++; + *fmt = 0; + return fmtbase; +} diff --git a/gnu/lib/libg++/libg++/src/strclass.h b/gnu/lib/libg++/libg++/src/strclass.h new file mode 100644 index 00000000000..57dbcc8cf90 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/strclass.h @@ -0,0 +1,5 @@ +#ifndef _strclass_h +#define _strclass_h +#include +typedef class String string; +#endif diff --git a/gnu/lib/libg++/libg++/src/swap.h b/gnu/lib/libg++/libg++/src/swap.h new file mode 100644 index 00000000000..005cb0e4648 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/swap.h @@ -0,0 +1,3 @@ +/* From Ron Guillmette; apparently needed for Hansen's code */ + +#define swap(a,b) ({ typeof(a) temp = (a); (a) = (b); (b) = temp; }) diff --git a/gnu/lib/libg++/libg++/src/sysent.h b/gnu/lib/libg++/libg++/src/sysent.h new file mode 100644 index 00000000000..0535f38e934 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/sysent.h @@ -0,0 +1,2 @@ +/* Provided for compatibity with other C++ compilers ONLY! */ +#include diff --git a/gnu/lib/libg++/libg++/src/timer.c b/gnu/lib/libg++/libg++/src/timer.c new file mode 100644 index 00000000000..a7e2242d529 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/timer.c @@ -0,0 +1,165 @@ +/* +Copyright (C) 1990, 1992, 1995 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 + +/* Timing functions from Doug Schmidt... */ + +/* no such thing as "negative time"! */ +#define TIMER_ERROR_VALUE -1.0 + +/* If this does not work on your system, change this to #if 0, and + report the problem. */ + +#if 1 + +#include <_G_config.h> +#include +#if _G_HAVE_SYS_RESOURCE +#include +#include +#endif +#if !_G_HAVE_SYS_RESOURCE || !defined(RUSAGE_SELF) +#if _G_HAVE_SYS_TIMES +#define USE_TIMES +#include +#include +#if !defined (HZ) && defined(CLK_TCK) +#define HZ CLK_TCK +#endif +static struct tms Old_Time; +static struct tms New_Time; +#else /* ! _G_HAVE_SYS_TIMES */ +#define USE_CLOCK +#include +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1 +#endif +clock_t Old_Time; +clock_t New_Time; +#endif /* ! _G_HAVE_SYS_TIMES */ +#else /* _G_HAVE_SYS_RESOURCE && defined(RUSAGE_SELF) */ +static struct rusage Old_Time; +static struct rusage New_Time; +#endif +static int Timer_Set = 0; + +double +start_timer() +{ + Timer_Set = 1; +#ifdef USE_CLOCK + Old_Time = clock() / CLOCKS_PER_SEC; + return((double) Old_Time); +#else +#ifdef USE_TIMES + times(&Old_Time); + return((double) Old_Time.tms_utime / HZ); +#else + getrusage(RUSAGE_SELF,&Old_Time); /* set starting process time */ + return(Old_Time.ru_utime.tv_sec + (Old_Time.ru_utime.tv_usec / 1000000.0)); +#endif +#endif +} + +/* Returns process time since Last_Time. + If parameter is 0.0, returns time since the Old_Time was set. + Returns TIMER_ERROR_VALUE if `start_timer' is not called first. */ + +double +return_elapsed_time(Last_Time) + double Last_Time; +{ + if (!Timer_Set) { + return(TIMER_ERROR_VALUE); + } + else { + /* get process time */ +#ifdef USE_CLOCK + New_Time = clock(); +#else +#ifdef USE_TIMES + times(&New_Time); +#else + getrusage(RUSAGE_SELF,&New_Time); +#endif +#endif + if (Last_Time == 0.0) { +#ifdef USE_CLOCK + return((double) (New_Time - Old_Time) / CLOCKS_PER_SEC); +#else +#ifdef USE_TIMES + return((double) (New_Time.tms_utime - Old_Time.tms_utime) / HZ); +#else + return((New_Time.ru_utime.tv_sec - Old_Time.ru_utime.tv_sec) + + ((New_Time.ru_utime.tv_usec - Old_Time.ru_utime.tv_usec) + / 1000000.0)); +#endif +#endif + } + else { +#ifdef USE_CLOCK + return((double) New_Time / CLOCKS_PER_SEC - Last_Time); +#else +#ifdef USE_TIMES + return((double) New_Time.tms_utime / HZ - Last_Time); +#else + return((New_Time.ru_utime.tv_sec + + (New_Time.ru_utime.tv_usec / 1000000.0)) - Last_Time); +#endif +#endif + } + } +} + +#ifdef VMS +void sys$gettim(unsigned int*) asm("sys$gettim"); + +getrusage(int dummy,struct rusage* time){ + double rtime; + unsigned int systime[2]; + int i; + sys$gettim(&systime[0]); + rtime=systime[1]; + for(i=0;i<4;i++) rtime *= 256; + rtime+= systime[0]; +/* we subtract an offset to make sure that the number fits in a long int*/ + rtime=rtime/1.0e+7-4.144e+9; + time->ru_utime.tv_sec= rtime; + rtime=(rtime-time->ru_utime.tv_sec)*1.0e6; + time->ru_utime.tv_usec= rtime; +} +#endif +#else /* dummy them out */ + +double start_timer() +{ + return TIMER_ERROR_VALUE; +} + +double +return_elapsed_time(Last_Time) + double Last_Time; +{ + return TIMER_ERROR_VALUE; +} + +#endif /* timing stuff */ + + diff --git a/gnu/lib/libg++/libg++/src/typemacros.h b/gnu/lib/libg++/libg++/src/typemacros.h new file mode 100644 index 00000000000..f2bd7877e36 --- /dev/null +++ b/gnu/lib/libg++/libg++/src/typemacros.h @@ -0,0 +1,8 @@ +#define _T(type) typeof(type) +#define pointer_to(type) _T(_T(type)*) +#define member_of(cls,type) _T(_T(type) cls::) +#define function(res, args) _T(_T(res) args) + +#define _xq_yq(x,y) x ## _ ## y +#define _x_y(x,y) _xq_yq(x,y) +#define _gensym(stem) _x_y(stem, __LINE__) diff --git a/gnu/lib/libg++/libg++/test-install/.cvsignore b/gnu/lib/libg++/libg++/test-install/.cvsignore new file mode 100644 index 00000000000..7abff1dbead --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/.cvsignore @@ -0,0 +1,2 @@ +Makefile +config.status diff --git a/gnu/lib/libg++/libg++/test-install/ChangeLog b/gnu/lib/libg++/libg++/test-install/ChangeLog new file mode 100644 index 00000000000..45208ea6dd9 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/ChangeLog @@ -0,0 +1,74 @@ +Thu Oct 19 21:39:12 1995 Fred Fish + + * Makefile.in: Remove extraneous tabs from otherwise empty + line. This confuses older non-GNU versions of "make". + +Fri Apr 15 13:25:09 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (COMPILE_FLAGS): Remove obsolete XTRAFLAGS. + +Tue Jun 1 16:54:46 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (do_main.diff): Prefix commands by '@' to avoid + unnecessarily alarming users with what looks like error messages. + +Mon Apr 19 00:25:36 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in, configure.in: Re-vamped configure scheme. + * Makefile.in (foo_main.diff): Print more expressive + error message, and refer to libg++/README. + +Tue Nov 17 22:20:02 1992 Per Bothner (bothner@rtl.cygnus.com) + + * bf.cc: Use different styles of initialization. + * bm.cc: $#include (for exit()). + +Wed Aug 12 00:37:34 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: da should be libked with libg++.a, but + foo_main.run should not be (since it tests that + constructors work *without* needing libg++.a). + +Thu May 14 15:13:31 1992 Per Bothner (bothner@rtl.cygnus.com) + + * foo_main.cc, foo_diff.cc: Change the strings naming the + two static static_foo variables to be the same, because + the language does not specify construction order. + * expected.out: Update accordingly. + * Makefile.in: Simplify, clean up. Now, if you 'make test-90S', + it will test using ../libg++.a and local include files. + But ../Makefile.in when testing installation, overrides + variables so as to use installed versions. Thus things + are more consistent and more flexible - and you can + do the test before installing, if you want to. + +Sat Mar 7 19:19:49 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: make test work when "." is not in PATH. + +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. + +Mon Jan 6 00:39:54 1992 John Gilmore (gnu at cygnus.com) + + * foo_main.cc: Reverse previous change. foo_main.cc should + never see SunOS assert.h; it should get gcc's assert.h. When + the compile fails, it means the wrong include files are in use! + +Mon Jan 6 00:21:13 1992 Per Bothner (bothner at cygnus.com) + + * foo_main.cc: Include , needed by broken SunOS assert.h. + +Fri Jan 3 09:17:17 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Cope with broken Sun Make VPATH. + * Foo.cc: Expect that Foo:init_foo() will *not* be called. + * foo_main.cc: Add comment about __init_start lossage. + * expected.out: Remove ``expected'' __init_start call. + +Sat Dec 28 16:46:25 1991 Michael Tiemann (tiemann at cygnus.com) + + * Makefile.in (CPP_FLAGS): Add $(srcdir). diff --git a/gnu/lib/libg++/libg++/test-install/Foo.cc b/gnu/lib/libg++/libg++/test-install/Foo.cc new file mode 100644 index 00000000000..313347652f4 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/Foo.cc @@ -0,0 +1,89 @@ +// Class Foo +//#pragma implementation + + +// We don't use header files, since we only want to see, whether the +// compiler is installed properly. +// +#if (__GNUG__ == 2) +typedef __SIZE_TYPE__ size_t; +#else +typedef unsigned int size_t; +#endif + +extern "C" { + char *strncpy (char* dest, const char* dest, size_t len); + int printf (const char*, ...); +}; + +#include "Foo.h" + +int Foo::foos = 0; + +void Foo::init_foo () +{ + printf ("BROKENLY calling Foo::init_foo from __init_start; size_of(Foo) = %d\n", sizeof(Foo)); + foos = FOOLISH_NUMBER; +} + + +Foo::Foo () +{ + i = ++foos; + strncpy (message, "default-foo", len); +#ifdef WITH_ADDR + printf ("Constructing Foo(%d) \"default-foo\" at %08x\n", i, this); +#else + printf ("Constructing Foo(%d) \"default-foo\"\n", i); +#endif +} + +Foo::Foo (char* msg) +{ + i = ++foos; + strncpy( message, msg, len); +#ifdef WITH_ADDR + printf ( "Constructing Foo(%d) \"%s\" at %08x\n", i, message, this); +#else + printf ( "Constructing Foo(%d) \"%s\"\n", i, message); +#endif +} + + +Foo::Foo (const Foo& foo) +{ + i = ++foos; +#ifdef WITH_ADDR + printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n", + i, foo.message, this, foo.i, &foo); +#else + printf ("Initializing Foo(%d) \"%s\" with Foo(%d)\n",i, foo.message, foo.i); +#endif + for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k]; +} + + +Foo& Foo::operator= (const Foo& foo) +{ +#ifdef WITH_ADDR + printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n", + foo.i, foo.message, &foo, i, this); +#else + printf ("Copying Foo(%d) \"%s\" to Foo(%d)\n", foo.i, foo.message, i); +#endif + for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k]; + return *this; +} + + +Foo::~Foo () +{ + foos--; +#ifdef WITH_ADDR + printf ("Destructing Foo(%d) \"%s\" at %08x (remaining foos: %d)\n", + i, message, this, foos); +#else + printf ("Destructing Foo(%d) \"%s\" (remaining foos: %d)\n", + i, message, foos); +#endif +} diff --git a/gnu/lib/libg++/libg++/test-install/Foo.h b/gnu/lib/libg++/libg++/test-install/Foo.h new file mode 100644 index 00000000000..0ba2d37b272 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/Foo.h @@ -0,0 +1,24 @@ +// Class Foo + +#pragma interface + +#define FOOLISH_NUMBER -4711 + +#ifndef FOO_MSG_LEN +#define FOO_MSG_LEN 80 +#endif + +class Foo { + static int foos; + int i; + const len = FOO_MSG_LEN; + char message[len]; +public: + static void init_foo (); + static int nb_foos() { return foos; } + Foo(); + Foo( char* message); + Foo(const Foo&); + Foo & operator= (const Foo&); + ~Foo (); +}; diff --git a/gnu/lib/libg++/libg++/test-install/Makefile.in b/gnu/lib/libg++/libg++/test-install/Makefile.in new file mode 100644 index 00000000000..32befa21a06 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/Makefile.in @@ -0,0 +1,170 @@ +###*####################################################################### +# +# Makefile to test the installation of g++ and libg++ +# (by hgs@cygnus.com) +# +# Usage: make foo_main test-90S test-90D PREFIX=prefix [other macros] + +srcdir = . + + +# +# Compilation macros +# +PREFIX = $(prefix) + +CFLAGS = +CXXFLAGS = +CPP_FLAGS = #-I$(srcdir)/../g++-include +OPTIMIZE_FLAGS = -O +DEBUG_FLAGS = -g -v #-Wall +COMPILE_FLAGS=$(NOSTDINC) -I.. -I$(srcdir) -I$(srcdir)/../src -I$(srcdir)/../$(IO_DIR) $(WRAP_C_INCLUDES) + +DEPEND_SOURCES = $(srcdir)/*.cc + + +T90 = $(T90S) $(T90D) +T90D = # dex_bar + +FLAGS_90 = \ + GXX="$(GXX)"\ + CPP_FLAGS="$(CPP_FLAGS)"\ + OPTIMIZE_FLAGS="$(OPTIMIZE_FLAGS)"\ + DEBUG_FLAGS="$(DEBUG_FLAGS)"\ + GXXLDFLAGS="$(GXXLDFLAGS)" + +#### package, host, target, and site dependent Makefile fragments come in here. +## + + +TEMP_FILES = *.o foo_main a b *foo_main.out *foo_main.diff *foo_main.run + +help: + @echo Usage: make foo_main test-40 test-90S test-90D PREFIX=prefix [other macros] + + +test-90S: foo_main a b + +test-90S-then-clean: test-90S + rm -f ${TEMP_FILES} + +test-90D: dfoo_main da db + +test-90D-then-clean: test-90D + rm -f ${TEMP_FILES} + +test: $(TEST) + for P in $(TEST) ; do if [ $$P != foo_main ]; then eval ./$$P; fi; done + +a : a.o + $(CXX) -o a a.o $(LIBS) +da : a.o + $(CXX) -o da -dynamic a.o $(LIBS) + + +b : bf.o bm.o + $(CXX) -o b bm.o bf.o $(LIBS) + +db : bf.o bm.o + $(CXX) -o db -dynamic bm.o bf.o $(LIBS) + + +foo_main: foo_main.diff + @true + +dfoo_main: dfoo_main.diff + @true + +foo_main.run: foo_main.o foo_func.o Foo.o expected.out + $(CXX) $(DEBUG_FLAGS) -o $@ foo_main.o foo_func.o Foo.o + +foo_main.out: foo_main.run + ./foo_main.run > foo_main.out + +foo_main.diff: foo_main.out $(srcdir)/expected.out + @echo "diff $(srcdir)/expected.out foo_main.out >foo_main.diff" + @diff $(srcdir)/expected.out foo_main.out >foo_main.diff \ + || (echo "Static constructor test failed - see libg++/README"; false) + +dfoo_main.run: foo_main.o foo_func.o Foo.o + $(CXX) $(DEBUG_FLAGS) -o $@ -dynamic foo_main.o foo_func.o Foo.o $(LIBS) + +dfoo_main.out: dfoo_main.run + ./dfoo_main.run > dfoo_main.out + +dfoo_main.diff: dfoo_main.out $(srcdir)/expected.out + diff $(srcdir)/expected.out dfoo_main.out + +ex_bar.o: ex_bar.cc + $(CXX) -fhandle-exceptions ex_bar.cc + +ex_bar: ex_bar.o + $(CXX) $(DEBUG_FLAGS) -o $@ ex_bar.o + +dex_bar: ex_bar.o + $(CXX) $(DEBUG_FLAGS) -o $@ -dynamic ex_bar.o + +# --- Generate depend rules --- + +SRCDIR=$(srcdir)/.. + +# The sed script below attempts to make the depend output portable by +# making the output use the same macros used elsewhere in the Makefile: +# - It replaces double // by a single /. +# - It replaces include files that match part of the GXX_INCLUDE_DIRS +# by names defined in terms of the macros used to define GXX_INCLUDE_DIRS. +# - It removes any absolute include file names that remain. +# - then remove lines, which contain only `\' +# +depend: depend.tmp + if [ "x$(DEPEND_SOURCES)" != "x" ] ; then \ + sed < depend.tmp \ + -e 's|//|/|g' \ + -e 's|$(srcdir)|$$(srcdir)|g' \ + -e 's| /[^ ]*[.]h||g' \ + -e 's|: *\$$(srcdir)/\(.*\.[cC]*\)|: \1|' \ + -e '/^[ ]*\\$$/d' -e 's/^[ ]*$$//' \ + | awk 'BEGIN { prev = "" } \ + /^( )*$$/ { if (prev ~ /\\$$/) \ + { prev = substr(prev,1,length(prev)-1); next } \ + } \ + { print prev; prev = $$0 } \ + END { if (prev !~ /^( )*$$/) print prev }' \ + > $(srcdir)/depend ;\ + fi + +depend.tmp: $(DEPEND_SOURCES) + if [ "x$(DEPEND_SOURCES)" = "x" ] ; then \ + echo "" > $(srcdir)/depend ;\ + else \ + echo "" >depend.tmp ; \ + $(SRCDIR)/utils/g++dep.sh -f depend.tmp $(GXX_INCLUDE_DIRS) \ + $(DEPEND_SOURCES) ;\ + fi + +do_depend: depend + if [ "$(SUBDIRS)" != "" ] ; then \ + for D in $(SUBDIRS) x ; do \ + if [ -d $$D ] ; then \ + echo "cd $$D; $(MAKE) do_depend" ; \ + (cd $$D ; $(MAKE) do_depend ); \ + fi ; \ + done ;\ + fi + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +Foo.o : Foo.cc \ + $(srcdir)/Foo.h +a.o : a.cc +bf.o : bf.cc +bm.o : bm.cc +ex_bar.o : ex_bar.cc \ + $(srcdir)/ex_bar.cc +foo_func.o : foo_func.cc \ + $(srcdir)/Foo.h +foo_main.o : foo_main.cc \ + $(srcdir)/Foo.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/test-install/a.cc b/gnu/lib/libg++/libg++/test-install/a.cc new file mode 100644 index 00000000000..b704ee07ada --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/a.cc @@ -0,0 +1,10 @@ +#include +#include + +String s1 = "Hello"; +String s2 = " world!\n"; + +main() +{ + cout << s1 << s2 ; +} diff --git a/gnu/lib/libg++/libg++/test-install/bf.cc b/gnu/lib/libg++/libg++/test-install/bf.cc new file mode 100644 index 00000000000..0a32b4c85c5 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/bf.cc @@ -0,0 +1,18 @@ +#include +#include + +// gcc-2.3.2 is buggy, and can't deal with the following. +// Take the wimpy way out for now until 2.3.3 is released. +#if 0 +String s1 = String("Hello "); +#else +String s1("Hello "); +#endif +String s2(" world!\n"); + +int f() +{ + cout << s1 + s2; + return cout.good(); +} + diff --git a/gnu/lib/libg++/libg++/test-install/bm.cc b/gnu/lib/libg++/libg++/test-install/bm.cc new file mode 100644 index 00000000000..bbca52a27fd --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/bm.cc @@ -0,0 +1,14 @@ +#include +#include +#include + +extern int f(); + +int main() +{ + // We (mis-)use errno supposedly to check that we got a good errno.h + // and libc. I don't quite buy it, but what the hell ... --Per + errno = f(); + fprintf(stderr, "Return-code: %d (should be 1)\n", errno); + exit(0); +} diff --git a/gnu/lib/libg++/libg++/test-install/configure.in b/gnu/lib/libg++/libg++/test-install/configure.in new file mode 100644 index 00000000000..ec8c85117aa --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/configure.in @@ -0,0 +1,25 @@ +# 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. + +configdirs="" +srctrigger=Foo.h +srcname="libg++ sanity checks" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +MOSTLYCLEAN='${TEMP_FILES} dfoo_main da db core ' +ALL='$(NOTHING)' + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/test-install/ex_bar.cc b/gnu/lib/libg++/libg++/test-install/ex_bar.cc new file mode 100644 index 00000000000..29f58903e5c --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/ex_bar.cc @@ -0,0 +1,123 @@ +// bar.cc - test the runtime support for GNU C++ exception handling. +// inspired by a PROLOG toplevel loop by Heinz Seidl (hgs@cygnus.com) + +#define S(s) SS(s) +#define SS(s) # s + +extern "C" { + int printf (const char*, ...); + void abort (); + int exit (int); +}; + +enum TERM { ATOM, INTEGER, DOUBLE, STRUCTURE, LIST, REF, EOF }; + +exception { + int number; + char * message; +} EX_IMPL; + +exception { + TERM Term; + char * message; +} EX_CALL; + +exception {} EX_EOF; + + +void pread (TERM & Term) +{ + // simulate an input buffer + // + static int p = 0; + TERM buffer[] = + { REF, + LIST, + STRUCTURE, + DOUBLE, + INTEGER, + ATOM + }; + const int blen = sizeof (buffer) / sizeof (TERM); + + if ( p < blen) + Term = buffer[p++]; + else + Term = EOF; +} + +void call (const TERM & Term) raises EX_CALL, EX_EOF, EX_IMPL +{ + switch (Term) + { + case REF: + raise EX_CALL (REF, + "Sorry - dereferencing not implemented (REF)."); + break; + case LIST: + raise EX_CALL (LIST, + "LISTs are not callable (LIST)."); + break; + case STRUCTURE: + raise EX_CALL (STRUCTURE, + "Undefined predicate (STRUCTURE)."); + break; + case DOUBLE: + raise EX_CALL (DOUBLE, + "DOUBLEs are not callable (DOUBLE)."); + break; + case INTEGER: + raise EX_CALL (INTEGER, + "INTEGERs are not callable (INTEGER)."); + case ATOM: + raise EX_CALL (ATOM, + "Undefined predicate (ATOM)."); + break; + case EOF: + raise EX_EOF (); + break; + default: + raise EX_IMPL ( Term, + "Implementation error in file " __FILE__ + " at line " S(__LINE__) " ."); + } +} + +void main() +{ + try { + while (1) { + try { + while (1) + { + TERM Term; + pread (Term); + call (Term); + } + } except ep { + EX_CALL { + printf ("EXCEPTION(%d) : %s\n", ep.Term, ep.message); + } + EX_EOF { + printf ("EOF encountered.\n"); + raise ep; + } + default { + raise ep; + } + } + } + } except ep { + EX_IMPL { + printf ("FATAL(%d): %s\n", ep.number, ep.message); + abort(); + } + EX_EOF { + printf ("Good bye.\n"); + } + default { + raise ep; + } + } + return 0; +} diff --git a/gnu/lib/libg++/libg++/test-install/expected.out b/gnu/lib/libg++/libg++/test-install/expected.out new file mode 100644 index 00000000000..39be0dbc2c7 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/expected.out @@ -0,0 +1,15 @@ +Constructing Foo(1) "static_foo" +Constructing Foo(2) "static_foo" +Constructing Foo(3) "automatic_foo" +Constructing Foo(4) "default-foo" +Initializing Foo(5) "default-foo" with Foo(4) +Destructing Foo(4) "default-foo" (remaining foos: 4) +Constructing Foo(5) "other_foo1" +Constructing Foo(6) "other_foo2" +Copying Foo(5) "other_foo1" to Foo(6) +Destructing Foo(6) "other_foo1" (remaining foos: 5) +Destructing Foo(5) "other_foo1" (remaining foos: 4) +Destructing Foo(5) "default-foo" (remaining foos: 3) +Destructing Foo(3) "automatic_foo" (remaining foos: 2) +Destructing Foo(2) "static_foo" (remaining foos: 1) +Destructing Foo(1) "static_foo" (remaining foos: 0) diff --git a/gnu/lib/libg++/libg++/test-install/foo_func.cc b/gnu/lib/libg++/libg++/test-install/foo_func.cc new file mode 100644 index 00000000000..ef941fbf18a --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/foo_func.cc @@ -0,0 +1,17 @@ +// test program for Class Foo + +#include "Foo.h" + +static Foo static_foo( "static_foo"); + +Foo f() +{ + Foo x; + return x; +} + +void g() +{ + Foo other_foo1 = Foo( "other_foo1"), other_foo2 = Foo( "other_foo2"); + other_foo2 = other_foo1; +} diff --git a/gnu/lib/libg++/libg++/test-install/foo_main.cc b/gnu/lib/libg++/libg++/test-install/foo_main.cc new file mode 100644 index 00000000000..bd235408ae5 --- /dev/null +++ b/gnu/lib/libg++/libg++/test-install/foo_main.cc @@ -0,0 +1,40 @@ +// main program for Class Foo + +extern "C" { +// Some implementations (e.g. SUNOS 4.1) are broken, +// in that they require . But, if gcc/g++ is installed +// correctly, you should get gcc's assert.h. +// If the compile fails, it means the wrong include files are in use! +#include +}; +#include "Foo.h" + +extern "C" void __init_start(); + +extern Foo f(void); +extern void g(void); + +/* This function should *not* be called by the environment. There is + no way in C++ to ``run something after the initializers but before main()''. + The library that depends on this (NIHCL) is broken. -- John Gilmore + We leave this here to test that future changes to the compiler + do not re-introduce this losing ``feature''. */ +void +__init_start() +{ + Foo::init_foo(); +} + +static Foo static_foo( "static_foo"); + +main() +{ + assert (Foo::nb_foos() == 2); + Foo automatic_foo( "automatic_foo"); + Foo bla_foo = f(); + assert (Foo::nb_foos() == 4); + g(); + assert (Foo::nb_foos() == 4); + // `automatic_foo' and `bla_foo' are destructed here +} + diff --git a/gnu/lib/libg++/libg++/tests/.cvsignore b/gnu/lib/libg++/libg++/tests/.cvsignore new file mode 100644 index 00000000000..196f012f94b --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/.cvsignore @@ -0,0 +1,135 @@ +*.out +Makefile +config.status +ffile +iAVLMap.cc +iAVLMap.h +iAVLSet.cc +iAVLSet.h +iAVec.cc +iAVec.h +iBSTSet.cc +iBSTSet.h +iBag.cc +iBag.h +iCHBag.cc +iCHBag.h +iCHMap.cc +iCHMap.h +iCHNode.cc +iCHNode.h +iCHSet.cc +iCHSet.h +iDLDeque.cc +iDLDeque.h +iDLList.cc +iDLList.h +iDeque.cc +iDeque.h +iFPlex.cc +iFPlex.h +iList.cc +iList.h +iMPlex.cc +iMPlex.h +iMap.cc +iMap.h +iOSLBag.cc +iOSLBag.h +iOSLSet.cc +iOSLSet.h +iOXPBag.cc +iOXPBag.h +iOXPSet.cc +iOXPSet.h +iPHPQ.cc +iPHPQ.h +iPQ.cc +iPQ.h +iPlex.cc +iPlex.h +iQueue.cc +iQueue.h +iRAVLMap.cc +iRAVLMap.h +iRPlex.cc +iRPlex.h +iSLBag.cc +iSLBag.h +iSLList.cc +iSLList.h +iSLQueue.cc +iSLQueue.h +iSLSet.cc +iSLSet.h +iSLStack.cc +iSLStack.h +iSet.cc +iSet.h +iSplayBag.cc +iSplayBag.h +iSplayMap.cc +iSplayMap.h +iSplayNode.cc +iSplayNode.h +iSplayPQ.cc +iSplayPQ.h +iSplaySet.cc +iSplaySet.h +iStack.cc +iStack.h +iVHBag.cc +iVHBag.h +iVHMap.cc +iVHMap.h +iVHSet.cc +iVHSet.h +iVOHSet.cc +iVOHSet.h +iVQueue.cc +iVQueue.h +iVStack.cc +iVStack.h +iVec.cc +iVec.h +iXPBag.cc +iXPBag.h +iXPDeque.cc +iXPDeque.h +iXPPQ.cc +iXPPQ.h +iXPQueue.cc +iXPQueue.h +iXPSet.cc +iXPSet.h +iXPStack.cc +iXPStack.h +iXPlex.cc +iXPlex.h +idefs.h +streamfile +tBag +tBitSet +tBitString +tComplex +tCurses +tDeque +tFile +tFix +tFix16 +tFix24 +tGetOpt +tInteger +tLList +tList +tMap +tObstack +tPQ +tPlex +tQueue +tRational +tSet +tStack +tString +tVec +test_h diff --git a/gnu/lib/libg++/libg++/tests/ChangeLog b/gnu/lib/libg++/libg++/tests/ChangeLog new file mode 100644 index 00000000000..f92f1c4c97d --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/ChangeLog @@ -0,0 +1,330 @@ +Fri Sep 1 16:56:27 1995 Per Bothner + + * tBitString.cc, tBitString.exp: Added test for operator +=, + from Curtis A. Snyder . + +Mon Aug 21 11:45:25 1995 Jason Merrill + + * configure.in (srctrigger): Use tObstack.cc instead of tComplex.cc. + + * Makefile.sh: Forget tComplex. + * tComplex.*: Remove. + +Sun Jun 11 12:22:21 1995 Jason Merrill + + * test_h.cc: Don't include . + +Fri May 5 13:04:17 1995 Mike Stump + + * Move `for' decl out of `for' statement. + +Fri Jan 20 00:19:57 1995 Jason Merrill + + * test_h.cc: No longer include complex.h. + +Wed Dec 14 18:49:12 1994 Per Bothner + + * tQueue.cc (test_resize), tQueue.inp: New test case from + Jocelyn Serot . + +Tue Dec 13 15:47:36 1994 Per Bothner + + * tiLList.cc (main): Add explicit variable to avoid warning + on passing non-lvalue by reference. + +Sat Nov 5 19:13:38 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.sh: Don't display the 'echo' command. + + * Makefile.in (LIBS): Remove. + +Sat Nov 5 14:29:00 1994 Per Bothner + + * tRational.cc (M_PI): #define it if it isn't defined. + + * tiLList.cc: Added new test from Magnus Nordborg. + * tiLList.exp: New file. + * Makefile.sh (check-tiLList): Merge with check-${TEST}. + +Mon Oct 24 16:03:14 1994 Per Bothner + + * Makefile.sh: Re-arrange so tFix* tCurses etc don't need LIBTEST. + +Thu Sep 29 03:23:24 1994 Philippe De Muyter (phdm@info.ucl.ac.be) + + * test_h.cc: do not include 3 times , some systems + do not like that. Include only if _G_HAVE_SYS_WAIT + +Mon Sep 5 13:07:01 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * test_h.cc: Remove #include . + +Thu Sep 1 17:35:33 1994 Jason Merrill (jason@deneb.cygnus.com) + + * tObstack.cc (main): Make output independent of size of pointers. + * tObstack.exp: Update accordingly. + +Fri Aug 12 17:36:44 1994 Brendan Kehoe (brendan@lisa.cygnus.com) + + * tFix24.cc (check): Add unsigned int version. + +Tue Jun 28 03:07:03 1994 Jason Merrill (jason@deneb.cygnus.com) + + * tFix.cc: Adjust to new organization of Fix class (overflow + handlers are now static members). + +Mon Jun 27 18:37:05 1994 Jason Merrill (jason@deneb.cygnus.com) + + * tVec.cc (print): Take parm by value. + + * tBitString.cc (accumtest): Make parms const refs. + +Wed Jun 15 11:04:47 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tString.cc (utiltest), tString.exp: Add a test to capitalize + a string with a bunch of apostrophes and single quotes. + +Wed Jun 1 13:59:53 1994 Jason Merrill (jason@deneb.cygnus.com) + + * tiLList.cc: Explicitly instantiate [SD]L{Node,List}. + +Wed May 25 15:42:21 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.sh: Fixes so that you don't need to build libtest.a + for tests that don't need it. + +Fri May 13 16:49:13 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tCurses.cc: Check _G_HAVE_CURSES, so we can compile + (though not do anything useful) if curses.h is missing. + +Wed May 11 00:40:43 1994 Jason Merrill (jason@deneb.cygnus.com) + + Make libg++ build with gcc -ansi -pedantic-errors + * tRational.cc: Wrap use of ? in #ifndef __STRICT_ANSI__ + * tBitSet.cc: Returns void. + +Thu Feb 10 16:44:04 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tBitSet.cc (test4), tBitSet.exp: Add a new test. + +Sat Dec 4 16:14:38 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * test_h.cc: Remove #include and . + They're included by , and the multiple inclusion + loses on some systems (e.g. Ultrix). Also, don't #include + , as it's non-Posix. + +Wed Nov 24 12:41:07 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * test_h.cc: Include limits.h rather than values.h. + +Mon Oct 11 15:16:52 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tSet.exp: Change VOHSet output to match new code. + +Wed Sep 15 14:46:40 1993 Mike Stump (mrs@cygnus.com) + + * Makefile.sh (LIB_FOR_tInteger): Add -lm for tInteger. + +Thu Aug 26 18:05:20 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tInteger.cc (iotest), tInteger.inp, tInteger.exp: + Test a couple of more things. + +Thu Aug 19 21:41:40 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in (CXXINCLUDES): Remove line - not needed. + +Thu Aug 19 12:44:14 1993 Mike Stump (mrs@cygnus.com) + + * configure.in (CXXINCLUDES): Add -I../../libio so that make check + works when srcdir != objdir. + +Sat Jul 24 17:50:52 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tComplex.cc: Add #include , for abs(double). + +Tue Jun 1 17:02:12 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.sh: Take out tFile, since it depends on GNU iostream. + * tInteger.cc (main), tInteger.exp: Add test for setbit/clearbit. + * tRational.cc (pitest): Only test >? and , not old . + +Tue Apr 27 13:53:46 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Removed bogus re-definition of WRAP_C_INCLUDES/ + * tString.cc, tFile.cc, tComplex, tRandom.cc (main): Return 0. + +Mon Apr 19 01:30:01 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in, configure.in: Re-vamped configure scheme. + * Makefile.sh: New shell scipt, used at configure time. + This generates the repetitive rules of the Makefile. + * tBitSet.cc, tBitString.cc: Prefer new "standardized" + method names prev() instead of previous(). + +Thu Jan 21 18:27:27 1993 Per Bothner (bothner@cygnus.com) + + * tFix.cc: Remove obsolete 'overload' declarations. + +Mon Jan 18 16:49:19 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * tString.cc: Include stream.h for dec(int) support. + +Sun Nov 1 14:44:13 1992 Per Bothner (bothner@cygnus.com) + + * tInteger.cc (modtest): New function, from a bug report. + * tInteger.exp: New output. + +Fri Oct 16 15:33:11 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Remove some obsolete junk. + +Fri Sep 25 11:32:47 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tiLList.cc: New files (derived from tList.cc) to + check template-based versions of SLList and DLList. + * Makefile.in: Use tiLList.cc. + +Mon Aug 10 15:11:42 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in (make-tests): New rule to build all the + tests without running them (useful when ross-compiling.) + * tSet.cc (main): Rename argc <-> argv. + * tSet.exp, tBag.exp, tMap.exp: Update to handle new hashing + policy for VH{Set,Bag,Map} classes. + +Mon Jul 20 15:45:29 1992 Mike Stump (mrs@cygnus.com) + + * tObstack.cc (main): Add cast from void * to char since it is + not a standard conversion. + +Fri Jun 26 11:46:53 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tRational.cc: Use the slightly more standard M_PI + instead of plain PI. + +Wed Jun 17 16:50:45 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Fix *clean rules. Add $(LDFLAGS) when linking. + Remove the '-' error suppressing prefix so that failing + checks cause the make to fail. + Clean out the remnants of the obsolete runtests rule. + * out.iostream, out.old-stream: Removed - no longer used. + * test_h.cc: Don't #include - it is non-standard. + +Thu May 14 15:08:37 1992 Per Bothner (bothner@rtl.cygnus.com) + + * test_h.cc: Only #include sys/socket.h and sys/resource.h + if these are available (according to _G_config.h). + +Fri May 8 15:41:12 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Pass $(NOSTDINC) to compiler. + +Thu May 7 00:48:11 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tList.cc (randseq): Evaluate 1st parameter of recursive + call to randeq() first (separately). (Unspecified order of + parameter evaluation was why the sun3 and sun4 versions + gave different results.) + +Wed May 6 01:10:58 1992 Per Bothner (bothner@rtl.cygnus.com) + + * tList.cc: For randseq(), use a dumb but portable + "random" number generator. (For unknown reason, the + old code gave different result on sun3 and sun4.) + * tList.exp: New output. + * Makefile.in: Don't run 'check-tRandom' as part of + 'check', because it isn't portable (byte-order problems?). + + * iostream.out: Split into multiple files, moving the + tFile output into tFile.exp, etc. + * Makefile.in: Add lots of new rules for check-tFile, + check-tObstack etc. THese run an individual test, + and compare the output to the matching *.exp file. + This makes it easier to track down problems, and + adds flexibility by making it easier to add or remove tests. + * test_h.cc: Don't include bool.h, which is deprecated + because it is likely to conflict with other header files. + +Fri Apr 17 14:48:26 1992 Per Bothner (bothner@cygnus.com) + + * tPQ.cc: Update delete of array to modern syntax. + * test_h.cc: #include _G_config.h. + Only #include if not SYSV. + +Tue Mar 10 18:16:28 1992 Per Bothner (bothner@cygnus.com) + + * tests_h.cc: Include sys/time.h before sys/resource.h, + according to traditional requirement. + +Fri Mar 6 15:11:36 1992 Per Bothner (bothner@cygnus.com) + + * tests_h.cc: Don't include malloc.h, since it is + not a standard include file. + +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. + +Fri Jan 31 17:07:30 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Add $(LSRCS) (the generated source files) + to DEPEND_SOURCES. (Otherwise, make fails to generate + some of the i*.h include files.) + + * Makefile.in: Add i{CH,Splay}Node.{cc,h,o} (because + CHNode and SplayNode have been moved into their own + include files). + * out.iostream: Change to match real output (now that + all discrepancies from old output are explained). + +Sat Jan 25 00:32:45 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Replace libtest.a by LIBTEST macro. + * out.iostream: "Fix". + * tFile.cc: New iostream class and classes derived from + it allow us to support much more of the fucntionality + of the old library. + +Thu Jan 16 18:00:04 1992 Per Bothner (bothner at cygnus.com) + + * expected.out, out_iostream, out.old_stream, Makefile.in: + Replace expected.out by two versions: One when using new + iostreams, and one for old streams. + * Makefile.in: Some tweaks to 'make depend.' + * tFix16.cc, tFix24.cc: Replace check macro by overloaded + inline functions. This forces side effects (including + error messages) when evaluating the operands to happen + before printing. + * tFile.cc: Comditionally compile depending on + _OLD_STREAMS macro (defined by stream.h) so that most + tests work for both new iostreams as well as old streams. + * test_h.cc: Remove obsolete include files. + +Sun Jan 5 00:03:06 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in, configure.in: Add 'make depend' support. + * tBag.cc, tMap.cc, tPQ.cc, tSet.cc: #include , + because new iostream library doesn't automatically include it. + * tFile.cc, test_h.cc: #ifdef out code that won't work with new + iostream library. Other tweaks for new library. diff --git a/gnu/lib/libg++/libg++/tests/Makefile.in b/gnu/lib/libg++/libg++/tests/Makefile.in new file mode 100644 index 00000000000..8faf11284a4 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/Makefile.in @@ -0,0 +1,22 @@ +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +GENCLASS = ../genclass/genclass +PROTODIR = $(srcdir)/../src/gen + +# compilation notes: +# The following g++ warnings are expected to appear: +# +# 2. Several warnings from genclass about classes with only .h, no .cc files +# +# 3. A few harmless reminder warnings that some classes have no data members. +# +# 4. Many harmless warnings that arguments to vector-delete are unnecessary +# when deleting arrays of builtin types. + +#--- NOTE: Lots of stuff gets added by ${srcdir}/Makefile.sh + +Makefile: $(srcdir)/Makefile.sh + diff --git a/gnu/lib/libg++/libg++/tests/Makefile.sh b/gnu/lib/libg++/libg++/tests/Makefile.sh new file mode 100644 index 00000000000..b57ab5ca427 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/Makefile.sh @@ -0,0 +1,178 @@ +cat <<'EOF' +# test files +TSRCS = tObstack.cc tString.cc tInteger.cc tRational.cc \ + tBitSet.cc tBitString.cc tRandom.cc tList.cc tPlex.cc \ + tLList.cc tVec.cc tStack.cc tQueue.cc tDeque.cc tPQ.cc tSet.cc tBag.cc \ + tMap.cc tFix.cc tFix16.cc tFix24.cc \ + tCurses.cc tGetOpt.cc \ + tiLList.cc +EOF + +TESTS0="tObstack tString tInteger tRational tBitSet"\ +" tBitString tFix tFix16 tFix24 tRandom" +TESTS1="tStack tQueue tDeque tPQ tSet tBag tMap tList tPlex tLList tVec" + +cat < ${TEST}.out 2>&1" + else + echo "check-${TEST}: ${TEST}" + echo " ./${TEST} > ${TEST}.out 2>&1" + fi + echo ' diff -b $(srcdir)/'"${TEST}.exp ${TEST}.out" +done + +cat <<'EOF' + +check-tGetOpt: tGetOpt $(srcdir)/tGetOpt.inp + ./tGetOpt -abc -de10 -2000 -h3i \ + <$(srcdir)/tGetOpt.inp >tGetOpt.out 2>&1 + diff -b $(srcdir)/tGetOpt.exp tGetOpt.out + +$(TOUTS): $(LIBGXX) + +LIBTEST=libtest.a + +# We don't do check-tRandom, because it is not portable. + +# Comment this out if your compiler doesn't handle templates: +CHECK_TEMPLATES=check-templates + +tests checktests: clean_tests test_h tCurses \ + check-tObstack check-tString check-tInteger \ + check-tRational check-tBitSet check-tBitString \ + check-tFix check-tFix16 check-tFix24 check-tGetOpt \ + check-tList check-tPlex check-tLList check-tVec \ + check-tStack check-tQueue check-tDeque check-tPQ \ + check-tSet check-tBag check-tMap $(CHECK_TEMPLATES) + ./test_h + @echo "(Must run tCurses manually from tty)" + +check-templates: check-tiLList + +# Build all the tests, but don't run them. (Useful when cross-compiling.) + +EOF + +cat <<'EOF' +make-tests: $(TOUTS) + +test_h: test_h.o + $(CXX) $(LDFLAGS) test_h.o -o $@ $(LIBS) -lm + + + +$(LIBTEST): $(LHDRS) $(LOBJS) + rm -f $(LIBTEST) + $(AR) r $(LIBTEST) $(LOBJS) + $(RANLIB) $(LIBTEST) + +# +# other tests +# +EOF + +LIB_FOR_tRational=-lm +LIB_FOR_tInteger=-lm +LIB_FOR_tRandom=-lm +LIB_FOR_tFix=-lm +LIB_FOR_tFix16=-lm +LIB_FOR_tFix24=-lm +LIB_FOR_tCurses="-lcurses -ltermcap" + +for TEST in $TESTS0 tiLList tCurses tGetOpt; do + echo "${TEST}: ${TEST}.o" + echo ' $(CXX) $(LDFLAGS)' "${TEST}.o" '-o $@ $(LIBS)' \ + `eval echo '$LIB_FOR_'$TEST` + echo "" +done +for TEST in twrapper tgwrapper $TESTS1; do + echo "${TEST}: " '$(LIBTEST)' " ${TEST}.o" + echo ' $(CXX) $(LDFLAGS)' "${TEST}.o" '-o $@ $(LIBTEST) $(LIBS)' + echo "" +done + +cat <<'EOF' +idefs.h: + PROTODIR=$(PROTODIR); export PROTODIR; $(GENCLASS) int val defs i +EOF + +for TEST in Set XPSet OXPSet SLSet OSLSet BSTSet AVLSet SplayNode SplaySet VHSet VOHSet CHSet CHNode Bag XPBag OXPBag SLBag OSLBag SplayBag VHBag CHBag PQ PHPQ SplayPQ XPPQ Stack Queue Deque SLStack SLQueue DLDeque List Plex FPlex XPlex MPlex RPlex FPStack XPStack FPQueue XPQueue XPDeque SLList DLList Vec AVec; do + echo "i$TEST.h i$TEST.cc:" + echo ' PROTODIR=$(PROTODIR); export PROTODIR; $(GENCLASS) int val' $TEST i +done + +for TEST in Map VHMap CHMap SplayMap AVLMap RAVLMap; do + echo "i${TEST}.h i$TEST.cc:" + echo ' PROTODIR=$(PROTODIR); export PROTODIR; $(GENCLASS) -2 int val int val' $TEST i +done + +cat <<'EOF' +iVStack.h iVStack.cc: iStack.h + PROTODIR=$(PROTODIR); export PROTODIR; $(GENCLASS) int val VStack i +iVQueue.h iVQueue.cc: iQueue.h + PROTODIR=$(PROTODIR); export PROTODIR; $(GENCLASS) int val VQueue i + +relink: force + rm -f $(TOUTS) + +.PHONY: clean_tests +clean_tests: force + rm -f *.out + +force: +EOF diff --git a/gnu/lib/libg++/libg++/tests/configure.in b/gnu/lib/libg++/libg++/tests/configure.in new file mode 100644 index 00000000000..5608fb750be --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/configure.in @@ -0,0 +1,27 @@ +# 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. + +configdirs= +srctrigger=tObstack.cc +srcname="tests for libg++" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +ALL=force +MOSTLYCLEAN='*.out *.o \#* core trie-gen ffile streamfile i*.cc i*.h CXX.hack* test.bye test.bye2 test.shell $(LIBTEST) $(TOUTS)' +CLEAN= + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +(. ${srcdir}/Makefile.sh) >>Makefile +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/tests/depend b/gnu/lib/libg++/libg++/tests/depend new file mode 100644 index 00000000000..dbd33e1774c --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/depend @@ -0,0 +1,161 @@ + + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +tBag.o : tBag.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iBag.h \ + iXPBag.h \ + iSLBag.h \ + iVHBag.h \ + iCHBag.h \ + iOXPBag.h \ + iOSLBag.h \ + iSplayBag.h +tBitSet.o : tBitSet.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tBitString.o : tBitString.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tComplex.o : tComplex.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tCurses.o : tCurses.cc +tDeque.o : tDeque.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iDeque.h \ + iXPDeque.h \ + iDLDeque.h +tFile.o : tFile.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + $(srcdir)/../$(IO_DIR)/strstream.h \ + $(srcdir)/../$(IO_DIR)/SFile.h \ + $(srcdir)/../$(IO_DIR)/fstream.h \ + $(srcdir)/../$(IO_DIR)/PlotFile.h +tFix.o : tFix.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tFix16.o : tFix16.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tFix24.o : tFix24.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tGetOpt.o : tGetOpt.cc +tInteger.o : tInteger.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tLList.o : tLList.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iSLList.h \ + iDLList.h +tList.o : tList.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iList.h +tMap.o : tMap.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iMap.h \ + iSplayMap.h \ + iVHMap.h \ + iCHMap.h \ + iAVLMap.h \ + iRAVLMap.h +tObstack.o : tObstack.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tPQ.o : tPQ.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iPQ.h \ + iXPPQ.h \ + iPHPQ.h \ + iSplayPQ.h +tPlex.o : tPlex.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iPlex.h \ + iFPlex.h \ + iXPlex.h \ + iMPlex.h \ + iRPlex.h +tQueue.o : tQueue.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iQueue.h \ + iXPQueue.h \ + iVQueue.h \ + iSLQueue.h +tRandom.o : tRandom.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tRational.o : tRational.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tSet.o : tSet.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iSet.h \ + iXPSet.h \ + iSLSet.h \ + iVHSet.h \ + iVOHSet.h \ + iCHSet.h \ + iOXPSet.h \ + iOSLSet.h \ + iBSTSet.h \ + iAVLSet.h \ + iSplaySet.h +tStack.o : tStack.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iStack.h \ + iXPStack.h \ + iVStack.h \ + iSLStack.h +tString.o : tString.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h +tVec.o : tVec.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + iVec.h \ + iAVec.h +test_h.o : test_h.cc \ + $(srcdir)/../$(IO_DIR)/stream.h \ + $(srcdir)/../$(IO_DIR)/iostream.h \ + $(srcdir)/../$(IO_DIR)/streambuf.h \ + $(srcdir)/../$(IO_DIR)/istream.h \ + $(srcdir)/../$(IO_DIR)/ostream.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/gnu/lib/libg++/libg++/tests/tBag.cc b/gnu/lib/libg++/libg++/tests/tBag.cc new file mode 100644 index 00000000000..aa99ec13901 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBag.cc @@ -0,0 +1,540 @@ +/* + a test file for Bags +*/ + + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + +#include "iBag.h" + +unsigned int hash(int x) { return multiplicativehash(x) ; } + +int SIZE; + +int *nums; +int *odds; +int *dups; + +void add(int x[], intBag& a) +{ + for (int i = 0; i < SIZE; ++i) a.add(x[i]); +} + + +#include + +MLCG randgen; + +void permute(int x[]) +{ + for (int i = 1; i < SIZE; ++i) + { + int j = randgen.asLong() % (i + 1); + int tmp = x[i]; x[i] = x[j]; x[j] = tmp; + } +} + +void makenums() +{ + for (int i = 0; i < SIZE; ++i) nums[i] = i + 1; +} + +void makeodds() +{ + for (int i = 0; i < SIZE; ++i) odds[i] = 2 * i + 1; + permute(odds); +} + +void makedups() +{ + for (int i = 0; i < SIZE; i += 2) dups[i] = dups[i+1] = i/2 + 1; + permute(dups); +} + +void printBag(intBag& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + Pix i; + for (i = a.first(); i != 0 && k < maxprint; a.next(i),++k) + cout << a(i) << " "; + if (i != 0) cout << "...]\n"; + else cout << "]\n"; +} + + +void generictest(intBag& a, intBag& b, intBag& c) +{ + c.clear(); + assert(c.empty()); + Pix k; + for (k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); +} + +#include "iXPBag.h" + +void XPtest() +{ + intXPBag a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intXPBag b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intXPBag c(SIZE); + add(dups, c); + assert(c.length() == SIZE); + intXPBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (int j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +#include "iSLBag.h" + +void SLtest() +{ + intSLBag a; + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intSLBag b; + add(odds, b); + assert(b.length() == SIZE); + intSLBag c; + add(dups, c); + assert(c.length() == SIZE); + intSLBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +#include "iVHBag.h" + +void VHtest() +{ + intVHBag a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intVHBag b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intVHBag c(SIZE); + add(dups, c); + assert(c.length() == SIZE); + intVHBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iCHBag.h" + +void CHtest() +{ + intCHBag a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intCHBag b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intCHBag c(SIZE); + add(dups, c); + assert(c.length() == SIZE); + intCHBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iOXPBag.h" + +void OXPtest() +{ + intOXPBag a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intOXPBag b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intOXPBag c(SIZE); + add(dups, c); + assert(c.length() == SIZE); + intOXPBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +#include "iOSLBag.h" + +void OSLtest() +{ + intOSLBag a; + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intOSLBag b; + add(odds, b); + assert(b.length() == SIZE); + intOSLBag c; + add(dups, c); + assert(c.length() == SIZE); + intOSLBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iSplayBag.h" + +void Splaytest() +{ + intSplayBag a; + add(nums, a); + assert(a.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intSplayBag b; + add(odds, b); + assert(b.length() == SIZE); + intSplayBag c; + add(dups, c); + assert(c.length() == SIZE); + intSplayBag d(a); + add(nums, d); + assert(d.length() == SIZE*2); + cout << "a: "; printBag(a); + cout << "b: "; printBag(b); + cout << "c: "; printBag(c); + cout << "d: "; printBag(d); + for (j = 1; j <= SIZE; ++j) assert(d.nof(j) == 2); + d.del(1); + assert(d.nof(1) == 1); + d.del(1); + assert(d.nof(1) == 0); + d.remove(2); + assert(!d.contains(2)); + for (Pix l = c.first(); l; c.next(l)) d.remove(c(l)); + assert(d.length() == SIZE); + + c.clear(); + assert(c.empty()); + for (Pix k = a.first(); k != 0; a.next(k)) c.add(a(k)); + for (Pix k = a.first(); k != 0; a.next(k)) assert(c.contains(a(k))); + c.del(a(a.first())); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = b.first(); k != 0; b.next(k)) c.add(b(k)); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + for (Pix k = a.first(); k != 0; a.next(k)) c.remove(a(k)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +double return_elapsed_time ( double ); +double start_timer ( void ); + +int main(int argv, char** argc) +{ + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + nums = new int[SIZE]; + odds = new int[SIZE]; + dups = new int[SIZE]; + makenums(); + makeodds(); + makedups(); + start_timer(); + cout << "VHtest\n"; VHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "CHtest\n"; CHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "SLtest\n"; SLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "XPtest\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "Splaytest\n"; Splaytest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "OSLtest\n"; OSLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "OXPtest\n"; OXPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tBag.exp b/gnu/lib/libg++/libg++/tests/tBag.exp new file mode 100644 index 00000000000..d86cf3461e6 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBag.exp @@ -0,0 +1,35 @@ +VHtest +a: [72 77 13 3 26 16 39 29 52 42 65 55 78 91 9 22 35 48 61 74 ...] +b: [167 77 13 3 193 39 139 29 93 47 65 55 155 109 91 9 117 171 35 143 ...] +c: [13 31 3 26 16 39 11 29 47 42 42 27 12 9 22 43 35 28 48 8 ...] +d: [85 3 26 29 52 21 61 17 55 78 13 57 22 48 74 70 30 74 26 15 ...] +CHtest +a: [72 36 85 49 13 3 98 62 26 16 75 39 29 88 52 42 6 65 55 19 ...] +b: [167 49 85 121 13 3 157 193 111 39 75 147 29 183 137 65 101 173 55 19 ...] +c: [36 36 49 13 13 49 3 3 26 26 16 16 39 39 29 29 6 42 6 42 ...] +d: [72 36 36 72 85 49 13 13 49 85 3 3 98 62 26 26 62 98 16 16 ...] +SLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 37 17 13 11 ...] +d: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +XPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 37 17 13 11 ...] +d: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +OSLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +OXPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] diff --git a/gnu/lib/libg++/libg++/tests/tBag.inp b/gnu/lib/libg++/libg++/tests/tBag.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tBitSet.cc b/gnu/lib/libg++/libg++/tests/tBitSet.cc new file mode 100644 index 00000000000..d98d3d453dc --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBitSet.cc @@ -0,0 +1,220 @@ +/* + a test/demo of BitSets +*/ + +#include + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << "OK\n"; \ + else cerr << "Fail\n"; } + + + +#include + + +void test3S(BitSet a, BitSet b, BitSet c) +{ +// neg + assert(~(~a) == a); +// commutative + assert((a | b) == (b | a)); + assert((a & b) == (b & a)); +// associative + assert((a | (b | c)) == ((a | b) | c)); + assert((a & (b & c)) == ((a & b) & c)); +// distrib + assert((a & (b | c)) == ((a & b) | (a & c))); + assert((a | (b & c)) == ((a | b) & (a | c))); +// absorption + assert((a & (a | b)) == a); + assert((a | (a & b)) == a); +// demorgan + assert((a | b) == ~(~a & ~b)); + assert((a & b) == ~(~a | ~b)); +// def of - + assert((a - b) == (a & ~b)); + assert(((a - b) | b) == (a | b)); +// def of disjoint union + assert((a ^ b) == ((a | b) & ~(a & b))); + assert((a ^ b) == ((a - b) | (b - a))); + + BitSet x = a; + x &= b; + assert(x == (a & b)); + x |= c; + assert(x == ((a & b) | c)); + x -= a; + assert(x == (((a & b) | c) - a)); + x ^= b; + assert(x == ((((a & b) | c) - a) ^ b)); + assert(x.OK()); +} + +/* This regression test found a bug in BitSetresize. + Based on a bug report from Joaquim Jorge .*/ + +void +test4() +{ + BitSet a; cout << "a: " << a << endl; + a.set(1, 2); cout << "after set(1,2): " << a << endl; + a = BitSet();cout << "after copy: " << a << endl; + a.set(1); cout << "after set(1): " << a << endl; +} + +int main() +{ + cout << "BitSet tests:\n"; + + BitSet a; + cout << "a = " << a << "\n"; + assert(a.OK()); + + BitSet b = longtoBitSet(1024); + cout << "b = " << b << "\n"; + assert(b.OK()); + assert(b[10] == 1); + assert(b.count() == 1); + b[0] = b[10]; + assert(b[0] == 1); + assert(b.count() == 2); + + BitSet c = atoBitSet("1010101010101010101010101010101010101010"); + cout << "c = " << c << "\n"; + assert(c.OK()); + assert(c.count() == 20); + for (int i = 0; i < 40; i += 2) + { + assert(c[i] == 1); + assert(c[i+1] == 0); + } + for (int p = 0; p < 5; ++p) + cout << "c[" << p << "] =" << int(c[p]) << "\n"; + + BitSet d = atoBitSet("0011001100110011001100110011001100110011"); + cout << "d = " << d << "\n"; + assert(d.OK()); + assert(d.count() == 20); + assert(d.count(0) == -1); + + BitSet e = atoBitSet("1111000011110000111100001111000011110000"); + cout << "e = " << e << "\n"; + assert(e.OK()); + assert(e.count() == 20); + + BitSet u = ~a; + cout << "u = ~a = " << u << "\n"; + assert(a == ~u); + + BitSet g = ~e; + cout << "g = ~e = " << g << "\n"; + + cout << "~c = " << (~c) << "\n"; + cout << "c & d = " << (c & d) << "\n"; + cout << "c | d = " << (c | d) << "\n"; + cout << "c - d = " << (c - d) << "\n"; + cout << "c ^ d = " << (c ^ d) << "\n"; + + test3S(b, c, d); + test3S(a, a, a); + test3S(a, b, c); + test3S(a, c, b); + test3S(c, b, a); + test3S(c, c, c); + test3S(c, d, e); + test3S(e, d, c); + + BitSet f = b; + cout << "f = b = " << f << "\n"; + f &= c; + cout << "f &= c = " << f << "\n"; + f |= d; + cout << "f |= d = " << f << "\n"; + f -= e; + cout << "f -= e = " << f << "\n"; + f ^= u; + cout << "f ^= u = " << f << "\n"; + assert(f.OK()); + + assert(c != d); + assert(!(c == d)); + assert(!(c < d)); + assert(!(c > d)); + assert(!(c <= d)); + assert(!(c >= d)); + + + BitSet h = d; + cout << "h = d\n:" << h << "\n"; + + assert(d == h); + assert(d <= h); + assert(d >= h); + assert(!(d != h)); + assert(!(d > h)); + assert(!(d < h)); + + h.set(0); + cout << "h.set(0):\n" << h << "\n"; + + assert(!(d == h)); + assert(!(d >= h)); + assert(!(d > h)); + assert((d != h)); + assert(d <= h); + assert((d < h)); + + h.set(65); + cout << "h.set(65):\n" << h << "\n"; + assert(h[65] == 1); + assert(h[64] == 0); + assert(h[66] == 0); + h.clear(2); + cout << "h.clear(2):\n" << h << "\n"; + assert(h[2] == 0); + assert(h[3] == 1); + assert(h[11] == 1); + h.invert(11,20); + cout << "h.invert(11,20):\n" << h << "\n"; + assert(h[11] == 0); + h.set(21,30); + cout << "h.set(21,30):\n" << h << "\n"; + assert(h[21] == 1); + h.clear(31,40); + cout << "h.clear(31, 40):\n" << h << "\n"; + assert(h[33] == 0); + cout << "h.test(0,5) = " << h.test(0, 5) << "\n"; + cout << "h.test(31,40) = " << h.test(31, 40) << "\n"; + + cout << "set bits in e:\n"; + for (int p = e.first(); p >= 0; p = e.next(p)) + { + assert(e[p] == 1); + cout << p << " "; + } + cout << "\n"; + + cout << "clear bits in g (reverse order):\n"; + for (int p = g.last(0); p >= 0; p = g.prev(p, 0)) + { + assert(g[p] == 0); + cout << p << " "; + } + cout << "\n"; + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + assert(e.OK()); + assert(f.OK()); + assert(g.OK()); + assert(h.OK()); + + test4(); + + cout << "\nEnd of test.\n"; + return 0; +} + diff --git a/gnu/lib/libg++/libg++/tests/tBitSet.exp b/gnu/lib/libg++/libg++/tests/tBitSet.exp new file mode 100644 index 00000000000..689874d00b3 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBitSet.exp @@ -0,0 +1,49 @@ +BitSet tests: +a = 0* +b = 000000000010* +c = 1010101010101010101010101010101010101010* +c[0] =1 +c[1] =0 +c[2] =1 +c[3] =0 +c[4] =1 +d = 00110011001100110011001100110011001100110* +e = 1111000011110000111100001111000011110* +u = ~a = 1* +g = ~e = 0000111100001111000011110000111100001* +~c = 0101010101010101010101010101010101010101* +c & d = 0010001000100010001000100010001000100010* +c | d = 10111011101110111011101110111011101110110* +c - d = 10001000100010001000100010001000100010* +c ^ d = 10011001100110011001100110011001100110010* +f = b = 100000000010* +f &= c = 100000000010* +f |= d = 10110011001100110011001100110011001100110* +f -= e = 00000011000000110000001100000011000000110* +f ^= u = 11111100111111001111110011111100111111001* +h = d +:00110011001100110011001100110011001100110* +h.set(0): +10110011001100110011001100110011001100110* +h.set(65): +1011001100110011001100110011001100110011000000000000000000000000010* +h.clear(2): +1001001100110011001100110011001100110011000000000000000000000000010* +h.invert(11,20): +1001001100101100110010110011001100110011000000000000000000000000010* +h.set(21,30): +1001001100101100110011111111111100110011000000000000000000000000010* +h.clear(31, 40): +1001001100101100110011111111111000000000000000000000000000000000010* +h.test(0,5) = 1 +h.test(31,40) = 0 +set bits in e: +0 1 2 3 8 9 10 11 16 17 18 19 24 25 26 27 32 33 34 35 +clear bits in g (reverse order): +35 34 33 32 27 26 25 24 19 18 17 16 11 10 9 8 3 2 1 0 +a: 0* +after set(1,2): 0110* +after copy: 0* +after set(1): 010* + +End of test. diff --git a/gnu/lib/libg++/libg++/tests/tBitSet.inp b/gnu/lib/libg++/libg++/tests/tBitSet.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tBitString.cc b/gnu/lib/libg++/libg++/tests/tBitString.cc new file mode 100644 index 00000000000..f397a2136dc --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBitString.cc @@ -0,0 +1,327 @@ +/* + a test/demo of BitStrings +*/ + +#include +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + + +#include + +void doubletest(BitString a) +{ + BitString x; + BitString y; + x = a + reverse(a); + for (int i = 0; i < 7; ++i) + { + y = x; + x += x; + assert(x == reverse(x)); + assert(x.index(y) == 0); + assert(x.index(y, -1) == x.length() / 2); + assert(x.OK()); + } +} + +// identities for equal-length args + +void identitytest(BitString a, BitString b, BitString c) +{ +// neg + assert(~(~a) == a); +// commutative + assert((a | b) == (b | a)); + assert((a & b) == (b & a)); +// associative + assert((a | (b | c)) == ((a | b) | c)); + assert((a & (b & c)) == ((a & b) & c)); +// distrib + assert((a & (b | c)) == ((a & b) | (a & c))); + assert((a | (b & c)) == ((a | b) & (a | c))); +// absorption + assert((a & (a | b)) == a); + assert((a | (a & b)) == a); +// demorgan + assert((a | b) == ~(~a & ~b)); + assert((a & b) == ~(~a | ~b)); +// def of - + assert((a - b) == (a & ~b)); + assert(((a - b) | b) == (a | b)); +// def of disjoint union + assert((a ^ b) == ((a | b) & ~(a & b))); + assert((a ^ b) == ((a - b) | (b - a))); +// shift + assert(((a << 1) >> 1) == a); +// concat + assert((a + (b + c)) == ((a + b) + c)); + + BitString x; + x = a + b; + assert(x.after(a) == b); + assert(x.before(b, -1) == a); + + x = a; + int l = x.length(); + x.set(l); + assert(x == (a + 1)); + x.clear(l); + assert(x == (a + 0)); +} + +void accumtest(const BitString& a, const BitString& b, const BitString& c) +{ + BitString x = a; + x &= b; + assert(x == (a & b)); + x |= c; + assert(x == ((a & b) | c)); + x -= a; + assert(x == (((a & b) | c) - a)); + x ^= b; + assert(x == ((((a & b) | c) - a) ^ b)); + x += c; + assert(x == (((((a & b) | c) - a) ^ b) + c)); + x <<= 7; + assert(x == ((((((a & b) | c) - a) ^ b) + c) << 7)); + x >>= 5; + assert(x == (((((((a & b) | c) - a) ^ b) + c) << 7) >> 5)); + x += 0; + assert(x == ((((((((a & b) | c) - a) ^ b) + c) << 7) >> 5) + 0)); + + assert(x.OK()); +} + + +void cmptest(BitString& x) +{ + BitString a = x; + a[0] = 0; + BitString b = a; + + assert(a == b); + assert(a <= b); + assert(a >= b); + assert(!(a != b)); + assert(!(a > b)); + assert(!(a < b)); + assert(lcompare(a, b) == 0); + assert(a.matches(b)); + assert(a.contains(b)); + + b[0] = 1; + cout << "b.set(0) :" << b << "\n"; + + assert(!(a == b)); + assert(!(a >= b)); + assert(!(a > b)); + assert((a != b)); + assert(a <= b); + assert((a < b)); + assert(lcompare(a, b) < 0); + assert(!a.matches(b)); + assert(!a.contains(b)); + assert(a.after(0) == b.after(0)); + + b.set(65); + cout << "b.set(65):\n" << b << "\n"; + assert(b[65] == 1); + assert(b[64] == 0); + assert(b.length() == 66); + b.clear(2); + cout << "b.clear(2):\n" << b << "\n"; + assert(b[2] == 0); + b.set(11); + b.invert(11,20); + cout << "b.invert(11,20):\n" << b << "\n"; + assert(b[11] == 0); + b.set(21,30); + cout << "b.set(21,30):\n" << b << "\n"; + assert(b[21] == 1); + b.clear(31,40); + cout << "b.clear(31, 40):\n" << b << "\n"; + assert(b.test(33, 38) == 0); +} + +void subtest(BitString c) +{ + BitString k = c.at(1, 4); + cout << "k = " << k << "\n"; + assert(c.index(k) == 1); + assert(c.index(k, -1) != -1); + + cout << "c.before(k) = " << c.before(k) << "\n"; + assert(c.before(k) == c.before(1)); + cout << "c.at(k) = " << c.at(k) << "\n"; + assert(c.at(k) == k); + cout << "c.after(k) = " << c.after(k) << "\n"; + assert(c.after(k) == c.after(4)); + c.after(k) = k; + cout << "c.after(k)=k :" << c << "\n"; + assert(c.after(4) == k); + c.before(k) = k; + cout << "c.before(k)=k:" << c << "\n"; + assert(c.after(c.after(k)) == k); + + assert(c.contains(k, 0)); + assert(common_prefix(c, k) == k); + assert(common_suffix(c, k) == k); + cout << "reverse(k) = " << reverse(k) << "\n"; + k.left_trim(0); + assert(k[0] == 1); + cout << "k.left_trim(0) : " << k << "\n"; + k.right_trim(1); + assert(k[k.length() - 1] == 0); + cout << "k.right_trim(1) : " << k << "\n"; +} + +int main() +{ + BitString a; + BitString b = atoBitString("1000000001"); + BitString c = atoBitString("10101010101010101010"); + BitString d = atoBitString("00110011001100110011"); + BitString e = atoBitString("11110000111100001111"); + BitString f = b; + BitString g = ~e; + BitString h = d; + BitString zz; + + assert(a.OK()); + assert(a.empty()); + assert(b.OK()); + assert(!b.empty()); + assert(c.OK()); + assert(c.count(1) == 10); + assert(c.count(0) == 10); + assert(d.OK()); + assert(c.count(1) == 10); + assert(c.count(0) == 10); + assert(e.OK()); + assert(e.count(1) == 12); + assert(e.count(0) == 8); + assert(f == b); + assert(h == d); + assert(g == ~e); + assert(~g == e); + assert(f.OK()); + assert(g.OK()); + assert(h.OK()); + + cout << "a = " << a << "\n"; + cout << "b = " << b << "\n"; + cout << "c = " << c << "\n"; + cout << "d = " << d << "\n"; + cout << "e = " << e << "\n"; + cout << "f = b = " << f << "\n"; + cout << "g = ~e = " << g << "\n"; + cout << "h = d = " << h << "\n"; + + for (int i = 0; i < 20; ++i) + { + assert(h[i] == d[i]); + assert(g[i] != e[i]); + assert(c[i] == !(i % 2)); + } + + cout << "bits in e:\n"; + for (int p = e.first(); p >= 0; p = e.next(p)) + { + assert(e[p] == 1); + cout << p << " "; + } + cout << "\n"; + + cout << "clear bits in g (reverse order):\n"; + for (int p = g.last(0); p >= 0; p = g.prev(p, 0)) + { + assert(g[p] == 0); + cout << p << " "; + } + cout << "\n"; + + cout << "~c = " << (~c) << "\n"; + cout << "c & d = " << (c & d) << "\n"; + cout << "c | d = " << (c | d) << "\n"; + cout << "c - d = " << (c - d) << "\n"; + cout << "c ^ d = " << (c ^ d) << "\n"; + cout << "c + d = " << (c + d) << "\n"; + cout << "c <<2 = " << (c << 2) << "\n"; + cout << "c >>2 = " << (c >> 2) << "\n"; + + f &= c; + cout << "f &= c = " << f << "\n"; + f |= d; + cout << "f |= d = " << f << "\n"; + f -= d; + cout << "f -= e = " << f << "\n"; + f ^= c; + cout << "f ^= c = " << f << "\n"; + f += b; + cout << "f += b = " << f << "\n"; + f <<= 5; + cout << "f <<=5 = " << f << "\n"; + f >>= 10; + cout << "f >>=10= " << f << "\n"; + + assert(c != d); + assert(!(c == d)); + assert(!(c < d)); + assert(!(c > d)); + assert(!(c <= d)); + assert(!(c >= d)); + assert(lcompare(c, d) > 0); + + + BitString l = c + d + c; + cout << "l = " << l << "\n"; + BitPattern pat(d, e); + assert(pat.OK()); + cout << "BitPattern pat = " << pat << "\n"; + cout << "pat.pattern = " << pat.pattern << "\n"; + cout << "pat.mask = " << pat.mask << "\n"; + assert(d.matches(pat)); + cout << "l.index(pat) = " << l.index(pat) << "\n"; + cout << "l.index(pat,-1)= " << l.index(pat, -1) << "\n"; + cout << "l.before(pat) = " << l.before(pat) << "\n"; + cout << "l.at(pat) = " << l.at(pat) << "\n"; + cout << "l.after(pat) = " << l.after(pat) << "\n"; + int eind = l.index(pat); + l.at(pat) = e; + assert(l.index(e) == eind); + + identitytest(d, g, h); + identitytest(a, a, a); + identitytest(c, d, e); + identitytest(e, d, c); + identitytest(longtoBitString(0), longtoBitString((unsigned)(~(0L))), + shorttoBitString(1025)); + identitytest(a+b+c+d+e+f+g+h, h+g+f+e+d+c+b+a, a+c+e+g+b+d+f+h); + + accumtest(d, g, h); + accumtest(a, b, c); + accumtest(c, d, e); + accumtest(e, d, c); + accumtest(a+b+c+d+e+f+g+h+l, f+e+d+c+b+a+pat.mask, e+g+b+d+f+h+pat.pattern); + + doubletest(a); + doubletest(b); + doubletest(c); + doubletest(a+b+c+d+e+f+g+h); + + cmptest(b); + cmptest(d); + + subtest(c); + subtest(d); + + for (int i=0; i<64; i++) { + zz += 1; + } + cout << "zz = " << zz << "\n"; + + cout << "\nEnd of test.\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tBitString.exp b/gnu/lib/libg++/libg++/tests/tBitString.exp new file mode 100644 index 00000000000..142187aa0d5 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tBitString.exp @@ -0,0 +1,79 @@ +a = +b = 1000000001 +c = 10101010101010101010 +d = 00110011001100110011 +e = 11110000111100001111 +f = b = 1000000001 +g = ~e = 00001111000011110000 +h = d = 00110011001100110011 +bits in e: +0 1 2 3 8 9 10 11 16 17 18 19 +clear bits in g (reverse order): +19 18 17 16 11 10 9 8 3 2 1 0 +~c = 01010101010101010101 +c & d = 00100010001000100010 +c | d = 10111011101110111011 +c - d = 10001000100010001000 +c ^ d = 10011001100110011001 +c + d = 1010101010101010101000110011001100110011 +c <<2 = 0010101010101010101010 +c >>2 = 101010101010101010 +f &= c = 1000000000 +f |= d = 10110011001100110011 +f -= e = 10000000000000000000 +f ^= c = 00101010101010101010 +f += b = 001010101010101010101000000001 +f <<=5 = 00000001010101010101010101000000001 +f >>=10= 0101010101010101000000001 +l = 101010101010101010100011001100110011001110101010101010101010 +BitPattern pat = 0011XXXX0011XXXX0011 +pat.pattern = 00110011001100110011 +pat.mask = 11110000111100001111 +l.index(pat) = 20 +l.index(pat,-1)= 20 +l.before(pat) = 10101010101010101010 +l.at(pat) = 00110011001100110011 +l.after(pat) = 10101010101010101010 +b.set(0) :1000000001 +b.set(65): +100000000100000000000000000000000000000000000000000000000000000001 +b.clear(2): +100000000100000000000000000000000000000000000000000000000000000001 +b.invert(11,20): +100000000100111111111000000000000000000000000000000000000000000001 +b.set(21,30): +100000000100111111111111111111100000000000000000000000000000000001 +b.clear(31, 40): +100000000100111111111111111111100000000000000000000000000000000001 +b.set(0) :10110011001100110011 +b.set(65): +101100110011001100110000000000000000000000000000000000000000000001 +b.clear(2): +100100110011001100110000000000000000000000000000000000000000000001 +b.invert(11,20): +100100110010110011001000000000000000000000000000000000000000000001 +b.set(21,30): +100100110010110011001111111111100000000000000000000000000000000001 +b.clear(31, 40): +100100110010110011001111111111100000000000000000000000000000000001 +k = 0101 +c.before(k) = 1 +c.at(k) = 0101 +c.after(k) = 010101010101010 +c.after(k)=k :101010101 +c.before(k)=k:010101010101 +reverse(k) = 1010 +k.left_trim(0) : 101 +k.right_trim(1) : 10 +k = 0110 +c.before(k) = 0 +c.at(k) = 0110 +c.after(k) = 011001100110011 +c.after(k)=k :001100110 +c.before(k)=k:011001100110 +reverse(k) = 0110 +k.left_trim(0) : 110 +k.right_trim(1) : 110 +zz = 1111111111111111111111111111111111111111111111111111111111111111 + +End of test. diff --git a/gnu/lib/libg++/libg++/tests/tBitString.inp b/gnu/lib/libg++/libg++/tests/tBitString.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tCurses.cc b/gnu/lib/libg++/libg++/tests/tCurses.cc new file mode 100644 index 00000000000..ae635dd3145 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tCurses.cc @@ -0,0 +1,80 @@ +#include <_G_config.h> +#if !_G_HAVE_CURSES + +#include +int main () +{ + cerr << "(CursesWindow is not supported on this system)"; +} +#else /* _G_HAVE_CURSES */ + +#include + +// a simple test/demo for CursesWindow + +int main() +{ + CursesWindow big(23, 79, 0, 0); + CursesWindow corner(10, 10, 0, 0); + CursesWindow small(10, 10, 5, 5); + CursesWindow sub(big, 10, 10, (big.height()>>1)-5, (big.width()>>1)-5); + CursesWindow sub2(big, 5, 5, big.height()-6, big.width()-6); + CursesWindow subsub(sub, 5, 5, 1, 1, 'r'); + + int i; + char c='A'; + + big.box('B','B'); + + sub.box('|','-'); + for (i=1;i<10;++i) + sub.mvaddch(i, i, '*'); + for (i=1;i<10;++i) + sub.mvaddch(10-i, i, '*'); + + big.refresh(); + + big.mvprintw(0,0,"begx=%d,maxx=%d,begy=%d,maxy=%d,height=%d,width=%d", + big.begx(), big.maxx(), big.begy(), big.maxy(), + big.height(), big.width()); + big.refresh(); + + sub2.box('2', '2'); + subsub.box('s', 's'); + + big.refresh(); + + i=13; + const char * cptr = "Cstar"; + + long l = 0xffffffff; + double d= 3.1415926; + float f= 10.0/d; + + big.mvprintw(2,2,"printw test:%d, %c, %s, %ld, %lf, %f\n",i,c,cptr,l,d,f); + big.refresh(); + + corner.box('c','c'); + big.mvprintw(5,20,"enter an int:"); + big.refresh(); + big.scanw("%d",&i); + big.move(6,20); + big.printw("number = %d\n",i); + big.refresh(); + corner.refresh(); + + small.box('S','S'); small.refresh(); + big.mvprintw(20,20,"enter a char:"); + big.refresh(); + big.scanw("%c",&c); + big.move(21,20); + big.printw("char = %c\n",c); + small.box(c, c); + big.refresh(); + small.refresh(); + corner.overlay(small); + big.overwrite(corner); + corner.refresh(); +} +#endif /* _G_HAVE_CURSES */ + diff --git a/gnu/lib/libg++/libg++/tests/tCurses.inp b/gnu/lib/libg++/libg++/tests/tCurses.inp new file mode 100644 index 00000000000..36247891672 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tCurses.inp @@ -0,0 +1,2 @@ +123 +a diff --git a/gnu/lib/libg++/libg++/tests/tDeque.cc b/gnu/lib/libg++/libg++/tests/tDeque.cc new file mode 100644 index 00000000000..0c1f561256c --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tDeque.cc @@ -0,0 +1,168 @@ +/* + test of Deques +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include + +#include "iDeque.h" + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + + +int SIZE; + +void print(intDeque& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + while (!a.empty() && k++ < maxprint) + cout << a.deq() << " "; + if (k == maxprint) + cout << "]\n"; + else + { + while (!a.empty()) a.del_front(); + cout << "...]\n"; + } + assert(a.empty()); +} + +#include "iXPDeque.h" + +void XPtest () +{ + intXPDeque d(SIZE); + assert(d.OK()); + for (int i = 0; i < SIZE; ++i) + { + if (i % 2 == 0) + d.enq(i); + else + d.push(i); + } + assert(d.length() == SIZE); + assert(d.front() == (SIZE-1)); + assert(d.rear() == (SIZE-2)); + assert(!d.full()); + intXPDeque d1(SIZE/2); + for (int i = (SIZE-1); i >= 0; --i) + { + int x; + if (i % 2 == 0) + { + x = d.rear(); + d.del_rear(); + } + else + { + x = d.front(); + d.del_front(); + } + d1.enq(x); + } + assert(d.empty()); + assert(d1.length() == SIZE); + assert(d1.front() == (SIZE-1)); + assert(d1.rear() == 0); + assert(d.OK()); + assert(d1.OK()); + intXPDeque d2 (d1); + assert(d2.length() == SIZE); + assert(d2.front() == (SIZE-1)); + assert(d2.OK()); + d1.clear(); + assert(d1.empty()); + d1 = d2; + assert(d1.length() == SIZE); + assert(d1.front() == (SIZE-1)); + cout << "d1:"; print(d1); + assert(d.OK()); + assert(d1.OK()); + assert(d2.OK()); +} + + +#include "iDLDeque.h" + +void DLtest () +{ + intDLDeque d; + assert(d.OK()); + for (int i = 0; i < SIZE; ++i) + { + if (i % 2 == 0) + d.enq(i); + else + d.push(i); + } + assert(d.length() == SIZE); + assert(d.front() == (SIZE-1)); + assert(d.rear() == (SIZE-2)); + assert(!d.full()); + intDLDeque d1; + for (int i = (SIZE-1); i >= 0; --i) + { + int x; + if (i % 2 == 0) + { + x = d.rear(); + d.del_rear(); + } + else + { + x = d.front(); + d.del_front(); + } + d1.enq(x); + } + assert(d.empty()); + assert(d1.length() == SIZE); + assert(d1.front() == (SIZE-1)); + assert(d1.rear() == 0); + assert(d.OK()); + assert(d1.OK()); + intDLDeque d2 (d1); + assert(d2.length() == SIZE); + assert(d2.front() == (SIZE-1)); + assert(d2.OK()); + d1.clear(); + assert(d1.empty()); + d1 = d2; + assert(d1.length() == SIZE); + assert(d1.front() == (SIZE-1)); + cout << "d1:"; print(d1); + + assert(d.OK()); + assert(d1.OK()); + assert(d2.OK()); +} + + +int main(int argv, char** argc) +{ + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + + start_timer(); + cout << "XP deques:\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "DL deques:\n"; DLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tDeque.exp b/gnu/lib/libg++/libg++/tests/tDeque.exp new file mode 100644 index 00000000000..2d60c350b75 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tDeque.exp @@ -0,0 +1,6 @@ +XP deques: +d1:[99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 ...] +DL deques: +d1:[99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 ...] + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tDeque.inp b/gnu/lib/libg++/libg++/tests/tDeque.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tFile.cc b/gnu/lib/libg++/libg++/tests/tFile.cc new file mode 100644 index 00000000000..d846f877df1 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFile.cc @@ -0,0 +1,371 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* + * a few tests for streams + * + */ + +#include +#ifndef _OLD_STREAMS +#include +#include "unistd.h" +#endif +#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()); + 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; + char mybuf[1000]; +#ifdef _OLD_STREAMS + cout << "creating string-based ostream...\n"; + ostream strout(1000, mybuf); +#else + cout << "creating ostrstream...\n"; + ostrstream strout(mybuf, 1000); +#endif + assert(strout.good()); + assert(strout.writable()); + strout << "This is a string-based stream.\n"; + strout << "With two lines.\n"; + strout.put(char(0)); + assert(strout.good()); + cout << "with contents:\n"; + 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"; + while (strin.get(ch)) cout.put(ch); +} + +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[] = "ffile"; + { + 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()); +} + +main() +{ + t1(); + t2(); + t3(); + t4(); + t5(); + t6(); + t7(); + t9(); + t8(); + + cout << "\nFinal 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"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tFile.exp b/gnu/lib/libg++/libg++/tests/tFile.exp new file mode 100644 index 00000000000..6827c5cf191 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFile.exp @@ -0,0 +1,49 @@ +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 + +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. + +Making filebuf streams fout and fin...contents of file: +Thisfilehasonelinetestingoutputstreams. + +Final names & states: +cin: (stdin) 0 +cout: (stdout) 0 +cerr: (stderr) 0 + +end of test. diff --git a/gnu/lib/libg++/libg++/tests/tFile.inp b/gnu/lib/libg++/libg++/tests/tFile.inp new file mode 100644 index 00000000000..436a5212c8d --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFile.inp @@ -0,0 +1,4 @@ +a +123 4567 89012 +123.456 -1.2e-2 +1 2 3 4 5 diff --git a/gnu/lib/libg++/libg++/tests/tFix.cc b/gnu/lib/libg++/libg++/tests/tFix.cc new file mode 100644 index 00000000000..96256f466dd --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix.cc @@ -0,0 +1,101 @@ +// +// testFix.cc : test Fix (variable length) classes +// + +#include + +void check(const char* x, Fix y) { cout << x << " = " << (y) << "\n"; } + +void check(const char* x, int y) { cout << x << " = " << (y) << "\n"; } + +void check(const char* x, long y) { cout << x << " = " << (y) << "\n"; } + +void check(const char* x, double y) { cout << x << " = " << (y) << "\n"; } + +void checkb(const char* x, const Fix y) +{ + cout << x << " = " << (y) << " [" << length(y) << "]"<< "\n"; +} + + + +int main() { + cout << "Fix: identities should be displayed\n" + << "[X] displays the precision of a given value\n" + << "[*] indicates that the full precision is not used for coding reasons\n"; + + Fix a; checkb("0 [16]",a); + Fix b = .5; checkb(".5 [16]",b); + Fix c(17,-.5); checkb("-.5 [17]",c); + Fix d(33,.1); checkb(".1 [33]",d); + Fix e = c; checkb("-.5 [17]",e); + + checkb(".3 [16]",a = .3); + checkb(".5 [16]",a = b); + checkb(".1 [16]",a = d); + checkb(".1 [33*]",d = a); + checkb("-.2 [17]",c = -.2); + checkb("-.5 [17]",e); + + check(".1 [16] == .1 [33*]",a == d); + d = .1; + check(".1 [16] == .1 [33]",a == d); + check(".1 [33] != .5 [16]",d != b); + check(".1 [33] > .5 [16]",d > b); + check(".1 [33] <= -.2 [17]",d <= c); + + e = .5; + check("1073741824",mantissa(e).as_double()); + check(".5",value(e)); + + checkb(".5 [17]",+e); + checkb("-.5 [17]",-e); + + checkb(".1 [33] + .5 [16]",d+b); + checkb(".1 [33] - .5 [16]",d-b); + checkb(".1 [33] * .5 [16]",d*b); + checkb(".1 [33] * 3",d*3); + checkb(".1 [33] * -3",d*-3); + checkb("-.1 [33] * 3",(-d)*3); + checkb("-.1 [33] * -3",(-d)*-3); + checkb(".5 [17] * -2",e*-2); + checkb(".1 [33] % 25",d%25); + checkb(".1 [33] % -25",d%-25); + checkb(".1 [33] / .5 [16]",d/b); + checkb(".1 [33] << 1",d<<1); + checkb("-.1 [33] >> 2",(-d)>>2); + + checkb("abs(-.2)",abs(c)); + checkb("abs(.2)",abs(-c)); + check("sgn(-.2)",sgn(c)); + check("sgn(.2)",sgn(-c)); + + cout << "\nshow .1 [33]\n"; + show(d); + + Fix g = .95; + + cout << "\nFix: range errors warned\n"; + + Fix f = 1.1; checkb("1.1 [16]",f); + + checkb(".5 [16] / .1 [33]",b/d); + checkb(".5 [16] / 0. [16]",b/Fix(0.)); + checkb(".5 [17] * 32768",e*32768); + + cout << "\nFix: overflows saturated\n"; + Fix::set_overflow_handler(Fix::overflow_saturate); + + checkb(".95 [16] + .1 [33]",g+d); + checkb("-.1 [33] - .95 [16]",-d-g); + checkb(".5 [17] * 2",e*2); + + cout << "\nFix: overflows generate warnings\n"; + Fix::set_overflow_handler(Fix::overflow_warning); + + checkb(".95 [16] + .1 [33]",g+d); + checkb("-.1 [33] - .95 [16]",-d-g); + checkb(".5 [17] * 2",e*2); + + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tFix.exp b/gnu/lib/libg++/libg++/tests/tFix.exp new file mode 100644 index 00000000000..3ab0051aab2 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix.exp @@ -0,0 +1,70 @@ +Fix: identities should be displayed +[X] displays the precision of a given value +[*] indicates that the full precision is not used for coding reasons +0 [16] = 0.00000 [16] +.5 [16] = 0.50000 [16] +-.5 [17] = -0.50000 [17] +.1 [33] = 0.10000 [33] +-.5 [17] = -0.50000 [17] +.3 [16] = 0.29999 [16] +.5 [16] = 0.50000 [16] +.1 [16] = 0.09998 [16] +.1 [33*] = 0.09998 [33] +-.2 [17] = -0.20001 [17] +-.5 [17] = -0.50000 [17] +.1 [16] == .1 [33*] = 1 +.1 [16] == .1 [33] = 0 +.1 [33] != .5 [16] = 1 +.1 [33] > .5 [16] = 0 +.1 [33] <= -.2 [17] = 0 +1073741824 = 1.07374e+09 +.5 = 0.5 +.5 [17] = 0.50000 [17] +-.5 [17] = -0.50000 [17] +.1 [33] + .5 [16] = 0.60000 [33] +.1 [33] - .5 [16] = -0.40000 [33] +.1 [33] * .5 [16] = 0.05000 [49] +.1 [33] * 3 = 0.30000 [33] +.1 [33] * -3 = -0.30000 [33] +-.1 [33] * 3 = -0.30000 [33] +-.1 [33] * -3 = 0.30000 [33] +.5 [17] * -2 = -1.00000 [17] +.1 [33] % 25 = 0.10000 [58] +.1 [33] % -25 = 0.09375 [8] +.1 [33] / .5 [16] = 0.20001 [33] +.1 [33] << 1 = 0.20000 [33] +-.1 [33] >> 2 = 0.47500 [33] +abs(-.2) = 0.20001 [17] +abs(.2) = 0.20001 [17] +sgn(-.2) = -1 +sgn(.2) = 1 + +show .1 [33] +len = 33 +siz = 3 +ref = 1 +man = ccccccc8000 +val = 0.1 + +Fix: range errors warned +Fix: range error in declaration +1.1 [16] = 0.00000 [16] +Fix: range error in division +.5 [16] / .1 [33] = 0.00000 [16] +Fix: range error in division -- division by zero +.5 [16] / 0. [16] = 0.00000 [16] +Fix: range error in multiply by int -- int too large +.5 [17] * 32768 = -1.00000 [17] + +Fix: overflows saturated +.95 [16] + .1 [33] = 1.00000 [33] +-.1 [33] - .95 [16] = -1.00000 [33] +.5 [17] * 2 = 0.99998 [17] + +Fix: overflows generate warnings +Fix: overflow warning +.95 [16] + .1 [33] = -0.94999 [33] +Fix: overflow warning +-.1 [33] - .95 [16] = 0.94999 [33] +Fix: overflow warning +.5 [17] * 2 = -0.49994 [17] diff --git a/gnu/lib/libg++/libg++/tests/tFix.inp b/gnu/lib/libg++/libg++/tests/tFix.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tFix16.cc b/gnu/lib/libg++/libg++/tests/tFix16.cc new file mode 100644 index 00000000000..beedc463faf --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix16.cc @@ -0,0 +1,110 @@ +// +// testFix16.cc : test Fix16/32 classes +// + +#include + +// This set of inlines (instead of a macro) is to force the side effects +// of evaluating y to happen before x is printed. + +inline void check(char *x, int y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, long y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, double y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, Fix16 y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, Fix32 y) { cout << x << " = " << (y) << "\n"; } + +void test16() { + cout << "Fix16: identities should be displayed\n"; + + Fix16 a; check("0",a); + Fix16 b = .5; check(".5",b); + Fix16 c = -.5; check("-.5",c); + Fix16 d = .1; check(".1",d); + Fix16 e = b; check(".5",e); + + check(".5",a = b); + check(".25",a = .25); + check("8192",mantissa(a)); + mantissa(a)=8192; + check(".25",a); + check(".25",value(a)); + + check(".25",+a); + check("-.25",-a); + + check(".1 + .5",d+b); + check(".1 - .5",d-b); + check(".1 * .5",d*b); + check(".1 * 3",d*3); + check(".1 * -3",d*-3); + check(".1 / .5",d/b); + check(".1 << 1",d<<1); + check("-.5 >> 2",c>>2); + + check(".1 == .5",d == b); + check(".1 != .5",d != b); + check(".1 > .5",d > b); + check(".5 <= -.5",b <= c); + + cout << "Fix16: range errors ignored and overflows saturated\n"; + set_Fix16_overflow_handler(Fix16_overflow_saturate); + set_Fix16_range_error_handler(Fix16_ignore); + + Fix16 f = 1.1; check("1.1",f); + + Fix16 g = .7; + check(".7 + .5",g+b); + check("-.5 - .7",c-g); + check(".5 / .1",b/d); +} + +void test32() { + cout << "Fix32: identities should be displayed\n"; + + Fix32 a; check("0",a); + Fix32 b = .5; check(".5",b); + Fix32 c = -.5; check("-.5",c); + Fix32 d = .1; check(".1",d); + Fix32 e = b; check(".5",e); + + check(".5",a = b); + check(".25",a = .25); + check("536870912",mantissa(a)); + mantissa(a)=536870912; + check(".25",a); + check(".25",value(a)); + + check(".25",+a); + check("-.25",-a); + + check(".1 + .5",d+b); + check(".1 - .5",d-b); + check(".1 * .5",d*b); + check(".1 * 3",d*3); + check(".1 * -3",d*-3); + check(".1 / .5",d/b); + check(".1 << 1",d<<1); + check("-.5 >> 2",c>>2); + + check(".1 == .5",d == b); + check(".1 != .5",d != b); + check(".1 > .5",d > b); + check(".5 <= -.5",b <= c); + + cout << "Fix32: range errors reported and overflows reported\n"; + set_Fix32_overflow_handler(Fix32_warning); + set_Fix32_range_error_handler(Fix32_warning); + + Fix32 f = 1.1; check("1.1",f); + + Fix32 g = .7; + check(".7 + .5",g+b); + check("-.5 - .7",c-g); + check(".5 / .1",b/d); +} + +int main() { + test16(); + test32(); + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tFix16.exp b/gnu/lib/libg++/libg++/tests/tFix16.exp new file mode 100644 index 00000000000..be40a2aae38 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix16.exp @@ -0,0 +1,64 @@ +Fix16: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.100006 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +8192 = 8192 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.600006 +.1 - .5 = -0.399994 +.1 * .5 = 0.0500031 +.1 * 3 = 0.300018 +.1 * -3 = -0.300018 +.1 / .5 = 0.200012 +.1 << 1 = 0.200012 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix16: range errors ignored and overflows saturated +1.1 = 0.999969 +.7 + .5 = 0.999969 +-.5 - .7 = -1 +.5 / .1 = 0.999969 +Fix32: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * .5 = 0.05 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 / .5 = 0.2 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix32: range errors reported and overflows reported +warning: Fix32 result out of range +1.1 = 1 +warning: Fix32 result out of range +.7 + .5 = -0.8 +warning: Fix32 result out of range +-.5 - .7 = 0.8 +warning: Fix32 result out of range +.5 / .1 = 1 diff --git a/gnu/lib/libg++/libg++/tests/tFix16.inp b/gnu/lib/libg++/libg++/tests/tFix16.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tFix24.cc b/gnu/lib/libg++/libg++/tests/tFix24.cc new file mode 100644 index 00000000000..08bd00994cb --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix24.cc @@ -0,0 +1,113 @@ +// +// testFix24.cc : test Fix24/48 classes +// + +#include + +// This a set of inlines instead of a macro to force the side effects +// of evaluating y to happen before x is printed. + +inline void check(char *x, int y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, unsigned int y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, long y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, unsigned long y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, double y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, Fix24 y) { cout << x << " = " << (y) << "\n"; } +inline void check(char *x, Fix48 y) { cout << x << " = " << (y) << "\n"; } + +void test24() { + cout << "Fix24: identities should be displayed\n"; + + Fix24 a; check("0",a); + Fix24 b = .5; check(".5",b); + Fix24 c = -.5; check("-.5",c); + Fix24 d = .1; check(".1",d); + Fix24 e = b; check(".5",e); + + check(".5",a = b); + check(".25",a = .25); + check("536870912",mantissa(a)); + mantissa(a)=536870912; + check(".25",a); + check(".25",value(a)); + + check(".25",+a); + check("-.25",-a); + + check(".1 + .5",d+b); + check(".1 - .5",d-b); + check(".1 * .5",d*b); + check(".1 * 3",d*3); + check(".1 * -3",d*-3); + check(".1 / .5",d/b); + check(".1 << 1",d<<1); + check("-.5 >> 2",c>>2); + + check(".1 == .5",d == b); + check(".1 != .5",d != b); + check(".1 > .5",d > b); + check(".5 <= -.5",b <= c); + + cout << "Fix24: range errors ignored and overflows saturated\n"; + set_Fix24_overflow_handler(Fix24_overflow_saturate); + set_Fix24_range_error_handler(Fix24_ignore); + + Fix24 f = 1.1; check("1.1",f); + + Fix24 g = .7; + check(".7 + .5",g+b); + check("-.5 - .7",c-g); + check(".5 / .1",b/d); +} + +void test48() { + cout << "Fix48: identities should be displayed\n"; + + Fix48 a; check("0",a); + Fix48 b = .5; check(".5",b); + Fix48 c = -.5; check("-.5",c); + Fix48 d = .1; check(".1",d); + Fix48 e = b; check(".5",e); + + check(".5",a = b); + check(".25",a = .25); + twolongs t; + t = mantissa(a); + check("536870912",t.u); + check("0",t.l); + mantissa(a)=t; + check(".25",a); + check(".25",value(a)); + + check(".25",+a); + check("-.25",-a); + + check(".1 + .5",d+b); + check(".1 - .5",d-b); + check(".1 * 3",d*3); + check(".1 * -3",d*-3); + check(".1 << 1",d<<1); + check("-.5 >> 2",c>>2); + + check(".1 == .5",d == b); + check(".1 != .5",d != b); + check(".1 > .5",d > b); + check(".5 <= -.5",b <= c); + + cout << "Fix48: range errors reported and overflows reported\n"; + set_Fix48_overflow_handler(Fix48_warning); + set_Fix48_range_error_handler(Fix48_warning); + + Fix48 f = 1.1; check("1.1",f); + + Fix48 g = .7; + check(".7 + .5",g+b); + check("-.5 - .7",c-g); +} + +int main() { + test24(); + test48(); + return 0; +} + diff --git a/gnu/lib/libg++/libg++/tests/tFix24.exp b/gnu/lib/libg++/libg++/tests/tFix24.exp new file mode 100644 index 00000000000..598f8054e69 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tFix24.exp @@ -0,0 +1,61 @@ +Fix24: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * .5 = 0.05 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 / .5 = 0.2 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix24: range errors ignored and overflows saturated +1.1 = 1 +.7 + .5 = 1 +-.5 - .7 = -1 +.5 / .1 = 1 +Fix48: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +0 = 0 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix48: range errors reported and overflows reported +warning: Fix48 result out of range +1.1 = 1 +warning: Fix48 result out of range +.7 + .5 = -0.8 +warning: Fix48 result out of range +-.5 - .7 = 0.8 diff --git a/gnu/lib/libg++/libg++/tests/tFix24.inp b/gnu/lib/libg++/libg++/tests/tFix24.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tGetOpt.cc b/gnu/lib/libg++/libg++/tests/tGetOpt.cc new file mode 100644 index 00000000000..c9eb7e7d1ce --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tGetOpt.cc @@ -0,0 +1,65 @@ + +#include + +int +main (int argc, char **argv) +{ + int digit_optind = 0; + GetOpt getopt (argc, argv, "abc:d:0123456789"); + + while (1) + { + int this_option_optind = getopt.optind; + int ch; + if ((ch = getopt ()) == EOF) + break; + char c = char(ch); + 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", getopt.optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (getopt.optind < argc) + { + printf ("non-option ARGV-elements: "); + while (getopt.optind < argc) + printf ("%s ", argv[getopt.optind++]); + printf ("\n"); + } + + return 0; +} + diff --git a/gnu/lib/libg++/libg++/tests/tGetOpt.exp b/gnu/lib/libg++/libg++/tests/tGetOpt.exp new file mode 100644 index 00000000000..827bb56abc2 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tGetOpt.exp @@ -0,0 +1,11 @@ +./tGetOpt: unrecognized option `-h' +./tGetOpt: unrecognized option `-i' +option a +option b +option c with value `-de10' +option 2 +option 0 +option 0 +option 0 +digits occur in two different argv-elements. +option 3 diff --git a/gnu/lib/libg++/libg++/tests/tGetOpt.inp b/gnu/lib/libg++/libg++/tests/tGetOpt.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tInteger.cc b/gnu/lib/libg++/libg++/tests/tInteger.cc new file mode 100644 index 00000000000..f0c335e5ac3 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tInteger.cc @@ -0,0 +1,437 @@ +/* + a test file for Integer class + */ + +#include +#include + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + + +Integer factorial(Integer n) +{ + Integer f; + if (n < 0) + f = 0; + else + { + f = 1; + while (n > 0) + { + f *= n; + --n; + } + } + return f; +} + +Integer fibonacci(long n) +{ + Integer f; + if (n <= 0) + f = 0; + else + { + f = 1; + Integer prev = 0; + Integer tmp; + while (n > 1) + { + tmp = f; + f += prev; + prev = tmp; + --n; + } + } + return f; +} + + +void identitytest(Integer& a, Integer& b, Integer& c) +{ + assert( -(-a) == a); + assert( (a + b) == (b + a)); + assert( (a + (-b)) == (a - b)); + assert( (a * b) == (b * a)); + assert( (a * (-b)) == -(a * b)); + assert( (a / (-b)) == -(a / b)); + assert( (a - b) == -(b - a)); + assert( (a + (b + c)) == ((a + b) + c)); + assert( (a * (b * c)) == ((a * b) * c)); + assert( (a * (b + c)) == ((a * b) + (a * c))); + assert( ((a - b) + b) == a); + assert( ((a + b) - b) == a); + assert( ((a * b) / b) == a); + assert( ((a * b) % b) == 0); + assert( (b * (a / b) + (a % b)) == a); + assert( ((a + b) % c) == ((a % c) + (b % c)) % c); +} + +void utiltest(Integer& a) +{ + assert(sqrt(sqr(a)) == a); + assert(sqr(sqrt(a)) <= a); + + Integer x = 1; + for (int i = 0; i < 10; ++i) + { + assert(pow(a, i) == x); + x *= a; + } + setbit(x, 0); + assert(testbit(x, 0)); + assert(odd(x)); + assert(!even(x)); + clearbit(x, 0); + clearbit(x, 1); + assert(even(x)); + assert(!odd(x)); + assert(x % 4 == 0); + +} + +void bittest(Integer& a, Integer& b, Integer& c) +{ + assert( (a | b) == (b | a)); + assert( (a & b) == (b & a)); + assert( (a ^ b) == (b ^ a)); + assert( (a | (b | c)) == ((a | b) | c)); + assert( (a & (b & c)) == ((a & b) & c)); + assert( (a & (b | c)) == ((a & b) | (a & c))); + assert( (a | (b & c)) == ((a | b) & (a | c))); + assert( (a & (a | b)) == a); + assert( (a | (a & b)) == a); +} + +void accumtest(Integer& a, Integer& b, Integer& c) +{ + Integer x = a; + x *= b; + assert(x == (a * b)); + x += c; + assert(x == ((a * b) + c)); + x -= a; + assert(x == (((a * b) + c) - a)); + x /= b; + assert(x == ((((a * b) + c) - a) / b)); + x %= c; + assert(x == (((((a * b) + c) - a) / b) % c)); + x &= a; + assert(x == ((((((a * b) + c) - a) / b) % c) & a)); + x |= b; + assert(x == (((((((a * b) + c) - a) / b) % c) & a) | b)); + x ^= c; + assert(x == ((((((((a * b) + c) - a) / b) % c) & a) | b) ^ c)); + + assert(x.OK()); +} + +void longidentitytest(Integer& a, long b, long c) +{ + assert( (a + b) == (b + a)); + assert( (a + (-b)) == (a - b)); + assert( (a * b) == (b * a)); + assert( (a * (-b)) == -(a * b)); + assert( (a / (-b)) == -(a / b)); + assert( (a - b) == -(b - a)); + assert( (a + (b + c)) == ((a + b) + c)); + assert( (a * (b * c)) == ((a * b) * c)); + assert( (a * (b + c)) == ((a * b) + (a * c))); + assert( ((a - b) + b) == a); + assert( ((a + b) - b) == a); + assert( ((a * b) / b) == a); + assert( ((a * b) % b) == 0); + assert( (b * (a / b) + (a % b)) == a); + assert( ((a + b) % c) == ((a % c) + (b % c)) % c); +} + +void longbittest(Integer& a, long b, long c) +{ + assert( (a | b) == (b | a)); + assert( (a & b) == (b & a)); + assert( (a ^ b) == (b ^ a)); + assert( (a | (b | c)) == ((a | b) | c)); + assert( (a & (b & c)) == ((a & b) & c)); + assert( (a & (b | c)) == ((a & b) | (a & c))); + assert( (a | (b & c)) == ((a | b) & (a | c))); + assert( (a & (a | b)) == a); + assert( (a | (a & b)) == a); +} + +void longaccumtest(Integer& a, long b, long c) +{ + Integer x = a; + x *= b; + assert(x == (a * b)); + x += c; + assert(x == ((a * b) + c)); + x -= a; + assert(x == (((a * b) + c) - a)); + x /= b; + assert(x == ((((a * b) + c) - a) / b)); + x %= c; + assert(x == (((((a * b) + c) - a) / b) % c)); + x &= a; + assert(x == ((((((a * b) + c) - a) / b) % c) & a)); + x |= b; + assert(x == (((((((a * b) + c) - a) / b) % c) & a) | b)); + x ^= c; + assert(x == ((((((((a * b) + c) - a) / b) % c) & a) | b) ^ c)); + + assert(x.OK()); +} + +void anothertest() +{ + Integer pow64 = Ipow(2, 64); + cout << "pow64 = Ipow(2, 64) = " << pow64 << "\n"; + assert(pow64.OK()); + cout << "lg(pow64) = " << lg(pow64) << "\n"; + assert(lg(pow64) == 64); + int k; + for (k = 0; k < 64; ++k) assert(testbit(pow64, k) == 0); + assert(testbit(pow64, k) != 0); + + Integer s64 = 1; + s64 <<= 64; + cout << "s64 = 1 << 64 = " << s64 << "\n"; + assert(s64.OK()); + + assert(s64 == pow64); + assert(s64 >= pow64); + assert(s64 <= pow64); + assert(!(s64 != pow64)); + assert(!(s64 > pow64)); + assert(!(s64 < pow64)); + + Integer s32 = s64 >> 32; + cout << "s32 = s64 >> 32 = " << s32 << "\n"; + assert(s32.OK()); + assert(lg(s32) == 32); + assert(!(pow64 == s32)); + assert(!(pow64 < s32)); + assert(!(pow64 <= s32)); + assert(pow64 != s32); + assert(pow64 >= s32); + assert(pow64 > s32); + + Integer comps64 = ~s64; + cout << "comps64 = ~s64 = " << comps64 << "\n"; + for (k = 0; k < 64; ++k) assert(testbit(comps64, k) == !testbit(s64, k)); + Integer result = (comps64 & s32); + cout << "comps64 & s32 = " << result << "\n"; + assert(result.OK()); + result = (comps64 | s32); + cout << "comps64 | s32 = " << result << "\n"; + assert(result.OK()); + result = (comps64 ^ s32); + cout << "comps64 ^ s32 = " << result << "\n"; + assert(result.OK()); + + identitytest(s64, s32, comps64); + bittest(s32, s64, comps64); + accumtest(comps64, s32, pow64); + utiltest(s32); + longidentitytest(s64, 1000, 50); + longbittest(s64, 12345, 67890); + longaccumtest(s32, 100000, 1); + +} + +void iotest() +{ + Integer result; + + cout << "\nenter an Integer: "; + cin.setf(0, ios::basefield); + cin >> result; + cout << "number = " << hex << result << dec << "\n"; + assert(result.OK()); + + cout << "enter another Integer: "; + cin >> result; + cout << "number = " << result << "\n"; + assert(result.OK()); + + cout << "enter another Integer: "; + cin >> dec >> result; + cout << "number = " << result << "\n"; + assert(result.OK()); + +} + +void fibtest() +{ + Integer fib50 = fibonacci(50); + cout << "fib50 = fibonacci(50) = " << fib50 << "\n"; + assert(fib50.OK()); + Integer fib48 = fibonacci(48); + cout << "fib48 = fibonacci(48) = " << fib48 << "\n"; + assert(fib48.OK()); + + Integer result = fib48 + fib50; + cout << "fib48 + fib50 = " << result << "\n"; + result = fib48 - fib50; + cout << "fib48 - fib50 = " << result << "\n"; + result = fib48 * fib50; + cout << "fib48 * fib50 = " << result << "\n"; + result = fib48 / fib50; + cout << "fib48 / fib50 = " << result << "\n"; + result = fib48 % fib50; + cout << "fib48 % fib50 = " << result << "\n"; + result = gcd(fib50, fib48); + cout << "gcd(fib50, fib48) = " << result << "\n"; + result = sqrt(fib50); + cout << "sqrt(fib50) = " << result << "\n"; + + identitytest(result, fib50, fib48); + bittest(result, fib50, fib48); + accumtest(result, fib50, fib48); + utiltest(fib48); + longidentitytest(fib50, 1000, 50); + longaccumtest(fib48, 100000, 1); +} + + +void facttest(Integer& one, Integer& two) +{ + Integer fact30(factorial(30)); + cout << "fact30 = factorial(30) = " << fact30 << "\n"; + assert(fact30.OK()); + + Integer fact28(factorial(28)); + cout << "fact28 = factorial(28) = " << fact28 << "\n"; + assert(fact28.OK()); + assert(fact30 == fact28 * 870); + + Integer result = fact30 + fact28; + cout << "fact30 + fact28 = " << result << "\n"; + result = fact30 - fact28; + cout << "fact30 - fact28 = " << result << "\n"; + result = fact30 * fact28; + cout << "fact30 * fact28 = " << result << "\n"; + result = fact30 / fact28; + cout << "fact30 / fact28 = " << result << "\n"; + result = fact30 % fact28; + cout << "fact30 % fact28 = " << result << "\n"; + + result = -fact30; + cout << "-fact30 = " << result << "\n"; + assert(abs(result) == fact30); + + cout << "lg(fact30) = " << lg(fact30) << "\n"; + assert(lg(fact30) == 107); + + result = gcd(fact30, fact28); + cout << "gcd(fact30, fact28) = " << result << "\n"; + assert(result == fact28); + + result = sqrt(fact30); + cout << "sqrt(fact30) = " << result << "\n"; + + Integer negfact31 = fact30 * -31; + Integer posfact31 = abs(negfact31); + assert(negfact31.OK()); + assert(posfact31.OK()); + cout << "negfact31 = " << negfact31 << "\n"; + result = fact30 + negfact31; + cout << "fact30 + negfact31 = " << result << "\n"; + result = fact30 - negfact31; + cout << "fact30 - negfact31 = " << result << "\n"; + result = fact30 * negfact31; + cout << "fact30 * negfact31 = " << result << "\n"; + result = fact30 / negfact31; + cout << "fact30 / negfact31 = " << result << "\n"; + result = fact30 % negfact31; + cout << "fact30 % negfact31 = " << result << "\n"; + result = gcd(fact30, negfact31); + cout << "gcd(fact30, negfact31) = " << result << "\n"; + assert(result == fact30); + + identitytest(one, one, one); + identitytest(one, one, one); + identitytest(one, two, fact30); + identitytest(fact30, posfact31, fact28); + identitytest(fact30, negfact31, fact28); + identitytest(negfact31, posfact31, fact28); + + bittest(one, one, one); + bittest(one, one, one); + bittest(one, two, fact30); + bittest(fact30, posfact31, fact28); + + accumtest(one, one, one); + accumtest(one, one, one); + accumtest(one, two, fact30); + accumtest(fact30, posfact31, fact28); + + utiltest(one); + utiltest(fact30); + utiltest(posfact31); + + longidentitytest(one, 1, 1); + longidentitytest(one, 2, 3); + longidentitytest(fact30, 3, -20); + longidentitytest(fact30, 4, 20000); + longidentitytest(negfact31, -100, 20000); + + longbittest(one, 1, 1); + longbittest(one, 2, 3); + longbittest(fact30, 4, 20000); + longbittest(fact28, 1000, 50); + + longaccumtest(one, 1, 1); + longaccumtest(one, 2, 3); + longaccumtest(fact30, 4, 20000); + longaccumtest(fact30, 1000, 50); + longaccumtest(fact28, 10000000, 100000000); +} + +void modtest() +{ + Integer b, e, m; + + m = 1; m <<= 32; + b = m + 1; + + e = Ipow( 2, 32 ); + b = Ipow( 2, 32 ); // use b as a comparison + cout << "2^32 = " << e << "\n"; + + e %= (e-1); // do same op two ways... + b = b % (b - 1); + + cout << "2^32 % (2^32-1) = " << e << "\n"; // e is incorrect here + cout << "2^32 % (2^32-1) = " << b << "\n"; // but b is ok +} + +int main() +{ + Integer one = 1; + cout << "one = " << one << "\n"; + assert(one.OK()); + assert(one == 1); + cout << "one + 1 = " << (one + 1) << "\n"; + + Integer two = 2; + cout << "two = " << two << "\n"; + assert(two.OK()); + assert(two == 2); + +/* inbox/1782 */ + Integer n (0); + setbit (n, 8); + clearbit (n, 16); + cout << "twofiftysix = " << n << '\n'; + + facttest(one, two); + fibtest(); + anothertest(); + iotest(); + modtest(); + + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tInteger.exp b/gnu/lib/libg++/libg++/tests/tInteger.exp new file mode 100644 index 00000000000..6a0d7e61fb8 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tInteger.exp @@ -0,0 +1,48 @@ +one = 1 +one + 1 = 2 +two = 2 +twofiftysix = 256 +fact30 = factorial(30) = 265252859812191058636308480000000 +fact28 = factorial(28) = 304888344611713860501504000000 +fact30 + fact28 = 265557748156802772496809984000000 +fact30 - fact28 = 264947971467579344775806976000000 +fact30 * fact28 = 80872505331661933764010628483512781121876047953920000000000000 +fact30 / fact28 = 870 +fact30 % fact28 = 0 +-fact30 = -265252859812191058636308480000000 +lg(fact30) = 107 +gcd(fact30, fact28) = 304888344611713860501504000000 +sqrt(fact30) = 16286585271694955 +negfact31 = -8222838654177922817725562880000000 +fact30 + negfact31 = -7957585794365731759089254400000000 +fact30 - negfact31 = 8488091513990113876361871360000000 +fact30 * negfact31 = -2181131468794922353615366650200339706856997013317222400000000000000 +fact30 / negfact31 = 0 +fact30 % negfact31 = 265252859812191058636308480000000 +gcd(fact30, negfact31) = 265252859812191058636308480000000 +fib50 = fibonacci(50) = 12586269025 +fib48 = fibonacci(48) = 4807526976 +fib48 + fib50 = 17393796001 +fib48 - fib50 = -7778742049 +fib48 * fib50 = 60508827864880718400 +fib48 / fib50 = 0 +fib48 % fib50 = 4807526976 +gcd(fib50, fib48) = 1 +sqrt(fib50) = 112188 +pow64 = Ipow(2, 64) = 18446744073709551616 +lg(pow64) = 64 +s64 = 1 << 64 = 18446744073709551616 +s32 = s64 >> 32 = 4294967296 +comps64 = ~s64 = 18446744073709551615 +comps64 & s32 = 4294967296 +comps64 | s32 = 18446744073709551615 +comps64 ^ s32 = 18446744069414584319 + +enter an Integer: number = 1234abdecf99fed123 +enter another Integer: number = 0 +enter another Integer: number = -12345678901234567890 +2^32 = 4294967296 +2^32 % (2^32-1) = 1 +2^32 % (2^32-1) = 1 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tInteger.inp b/gnu/lib/libg++/libg++/tests/tInteger.inp new file mode 100644 index 00000000000..3dee0b82c9a --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tInteger.inp @@ -0,0 +1,3 @@ +0x1234abdecf99FED123 +0 +-012345678901234567890 diff --git a/gnu/lib/libg++/libg++/tests/tLList.cc b/gnu/lib/libg++/libg++/tests/tLList.cc new file mode 100644 index 00000000000..b491438a264 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tLList.cc @@ -0,0 +1,236 @@ +/* + test/demo of linked structures +*/ + + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + +#include +#include "iSLList.h" + + +void printlist(intSLList& l) +{ + for (Pix p = l.first(); p != 0; l.next(p)) cout << l(p) << " "; + cout << "\n"; +} + + +void SLtest() +{ + int i; + intSLList a; + assert(a.OK()); + assert(a.empty()); + cout << "prepending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == i); + a.prepend(i); + assert(a.front() == i); + } + cout << "a: "; printlist(a); + cout << "appending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == 10 + i); + a.append(i); + assert(a.rear() == i); + } + cout << "a: "; printlist(a); + intSLList b = a; + cout << "b = a: " << "\n"; printlist(b); + assert(b.OK()); + assert(b.length() == a.length()); + assert(b.front() == a.front()); + assert(b.rear() == a.rear()); + cout << "remove_front of first 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(b.length() == 20 - i); + assert(b.front() == 9 - i); + b.remove_front(); + } + assert(b.length() == 10); + cout << "b: "; printlist(b); + + cout << "inserting 100 after sixth element...\n"; + Pix bp = b.first(); + for (i = 0; i < 5; ++i) b.next(bp); + b.ins_after(bp, 100); + assert(b.length() == 11); + cout << "b: "; printlist(b); + a.join(b); + cout << "after a.join(b)\n"; printlist(a); + assert(b.empty()); + assert(a.length() == 31); + cout << "b: " << "\n"; printlist(b); + b.prepend(999); + cout << "b: " << "\n"; printlist(b); + assert(b.length() == 1); + assert(b.front() == 999); + assert(b.rear() == 999); + assert(b.OK()); + intSLList bb = b; + cout << "bb: " << "\n"; printlist(bb); + assert(bb.OK()); + assert(bb.length() == 1); + assert(bb.front() == 999); + assert(bb.rear() == 999); + assert(bb.remove_front() == 999); + b.prepend(1234); + assert(b.length() == 2); + b.del_after(b.first()); + assert(b.rear() == 1234); + assert(b.length() == 1); + b.del_after(0); + assert(b.length() == 0); + + assert(a.OK()); + assert(b.OK()); + assert(bb.OK()); +} + +#include "iDLList.h" + +void printDlist(intDLList& l) +{ + for (Pix p = l.first(); p != 0; l.next(p)) cout << l(p) << " "; + cout << "\n"; +} + +void DLtest() +{ + int i; + intDLList a; + assert(a.OK()); + assert(a.empty()); + assert(a.length() == 0); + cout << "prepending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == i); + a.prepend(i); + assert(a.front() == i); + } + cout << "a: " << "\n"; printDlist(a); + cout << "appending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == 10 + i); + a.append(i); + assert(a.rear() == i); + } + cout << "a: "; printDlist(a); + intDLList b = a; + assert(b.OK()); + assert(b.length() == a.length()); + assert(b.front() == a.front()); + assert(b.rear() == a.rear()); + cout << "b = a: "; printDlist(b); + cout << "remove_front of first 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(b.length() == 20 - i); + assert(b.front() == 9 - i); + b.remove_front(); + } + assert(b.length() == 10); + cout << "b: "; printDlist(b); + + cout << "inserting 100 after sixth element...\n"; + Pix bp = b.first(); + for (i = 0; i < 5; ++i) b.next(bp); + b.ins_after(bp, 100); + assert(b.length() == 11); + cout << "b: "; printDlist(b); + intDLList aa = a; + aa.join(b); + cout << "after aa = a; aa.join(b)\n"; printDlist(aa); + assert(aa.length() == 31); + assert(b.empty()); + cout << "b: " << "\n"; printDlist(b); + b.prepend(999); + cout << "b: " << "\n"; printDlist(b); + assert(b.length() == 1); + assert(b.front() == 999); + assert(b.rear() == 999); + assert(b.OK()); + intDLList bb = b; + cout << "bb: " << "\n"; printDlist(bb); + assert(bb.OK()); + assert(bb.length() == 1); + assert(bb.front() == 999); + assert(bb.rear() == 999); + assert(bb.remove_front() == 999); + assert(bb.OK()); + b.prepend(1234); + assert(b.length() == 2); + bp = b.first(); + b.next(bp); + b.del(bp, -1); + assert(b.rear() == 1234); + assert(b.length() == 1); + b.del(bp); + assert(b.length() == 0); + + intDLList z = a; + cout << "z = a: "; printDlist(z); + assert(z.OK()); + assert(z.length() == 20); + cout << "remove_rear of last 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(z.length() == 20 - i); + assert(z.rear() == 9 - i); + z.remove_rear(); + } + assert(z.length() == 10); + + cout << "z: "; printDlist(z); + + cout << "inserting 100 before alternate elements...\n"; + Pix zp; + for (zp = z.first(); zp; z.next(zp)) + { + z.ins_before(zp, 100); + } + assert(z.length() == 20); + cout << "z: "; printDlist(z); + + cout << "inserting 200 after sixth element...\n"; + zp = z.first(); + for (i = 0; i < 5; ++i) z.next(zp); + z.ins_after(zp, 200); + assert(z.length() == 21); + cout << "z: "; printDlist(z); + + cout << "deleting alternate elements of z..."; + for (zp = z.first(); zp; z.next(zp)) + { + cout << z(zp) << " "; + z.del(zp); + } + cout << "\n"; + assert(z.length() == 10); + cout << "z: "; printDlist(z); + + cout << "z in reverse order:\n"; + for (zp = z.last(); zp; z.prev(zp)) cout << z(zp) << " "; + cout << "\n"; + z.clear(); + assert(z.OK()); + assert(z.empty()); + assert(a.OK()); + assert(b.OK()); +} + +main() +{ + SLtest(); + DLtest(); + cout << "\nEnd of test\n"; +} diff --git a/gnu/lib/libg++/libg++/tests/tLList.exp b/gnu/lib/libg++/libg++/tests/tLList.exp new file mode 100644 index 00000000000..727f9b538c7 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tLList.exp @@ -0,0 +1,49 @@ +prepending... +a: 9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after a.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +prepending... +a: +9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after aa = a; aa.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +z = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_rear of last 10 elements: +z: 9 8 7 6 5 4 3 2 1 0 +inserting 100 before alternate elements... +z: 100 9 100 8 100 7 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +inserting 200 after sixth element... +z: 100 9 100 8 100 7 200 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +deleting alternate elements of z...100 100 100 200 6 5 4 3 2 1 0 +z: 9 8 7 100 100 100 100 100 100 100 +z in reverse order: +100 100 100 100 100 100 100 7 8 9 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tLList.inp b/gnu/lib/libg++/libg++/tests/tLList.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tList.cc b/gnu/lib/libg++/libg++/tests/tList.cc new file mode 100644 index 00000000000..b508b5526d9 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tList.cc @@ -0,0 +1,129 @@ +/* + test/demo of generic lists +*/ + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + +#include +#include "iList.h" + +int int_compare(int a, int b) +{ + return a - b; +} + +int inc(int x) +{ + return x + 1; +} + +int plus(int x, int y) +{ + return x + y; +} + +void printint(int x) +{ + cout << x << " "; +} + +void print(intList& l) +{ + l.apply(printint); + cout << "\n"; +} + +int is_odd(int x) +{ + return x & 1; +} + +int is_even(int x) +{ + return (x & 1) == 0; +} + +intList sequence(int lo, int hi) +{ + if (lo > hi) + return intList(); + else + return intList(lo, sequence(lo+1, hi)); +} + +int old_rand = 9999; + +int get_rand() +{ + old_rand = ((long)old_rand * (long)1243) % (long)971; + return old_rand; +} + +intList randseq(int n) +{ + if (n <= 0) + return intList(); + int value = get_rand() % 50; + return intList(value, randseq(--n)); +} + +main() +{ + intList a = sequence(1, 20); + cout << "\nintList a = sequence(1, 20);\n"; print(a); + assert(a.OK()); + for (int i = 0; i < 20; ++i) assert(a[i] == i + 1); + assert(a.position(2) == 1); + intList b = randseq(20); + cout << "\nintList b = randseq(20);\n"; print(b); + intList c = concat(a, b); + cout << "\nintList c = concat(a, b);\n"; print(c); + assert(c.contains(a)); + assert(c.contains(b)); + assert(!(c.find(a).null())); + assert(c.find(b) == b); + intList d = map(inc, a); + for (int i = 0; i < 20; ++i) assert(d[i] == a[i] + 1); + cout << "\nintList d = map(inc, a);\n"; print(d); + intList e = reverse(a); + cout << "\nintList e = reverse(a);\n"; print(e); + for (int i = 0; i < 20; ++i) assert(e[i] == a[19 - i]); + intList f = select(is_odd, a); + cout << "\nintList f = select(is_odd, a);\n"; print(f); + intList ff = select(is_even, f); + assert(ff.null()); + int red = a.reduce(plus, 0); + cout << "\nint red = a.reduce(plus, 0);\n"; cout << red; + int second = a[2]; + cout << "\nint second = a[2];\n"; cout << second; + intList g = combine(plus, a, b); + cout << "\nintList g = combine(plus, a, b);\n"; print(g); + for (int i = 0; i < 20; ++i) assert(g[i] == a[i] + b[i]); + g.del((intPredicate)is_odd); + cout << "\ng.del(is_odd);\n"; print(g); + ff = select(is_odd, g); + assert(ff.null()); + b.sort(int_compare); + for (int i = 1; i < 20; ++i) assert(b[i] >= b[i-1]); + cout << "\nb.sort(int_compare);\n"; print(b); + intList h = merge(a, b, int_compare); + cout << "\nintList h = merge(a, b, int_compare);\n"; print(h); + for (int i = 1; i < 40; ++i) assert(h[i] >= h[i-1]); + for (Pix p = a.first(); p; a.next(p)) assert(h.contains(a(p))); + for (Pix p = b.first(); p; b.next(p)) assert(h.contains(b(p))); + cout << "\nh via Pix:\n"; + for (Pix p = h.first(); p; h.next(p)) cout << h(p) << ", "; + cout << "\n"; + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + assert(e.OK()); + assert(f.OK()); + assert(g.OK()); + assert(h.OK()); + cout << "\ndone\n"; +} diff --git a/gnu/lib/libg++/libg++/tests/tList.exp b/gnu/lib/libg++/libg++/tests/tList.exp new file mode 100644 index 00000000000..989137f1b92 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tList.exp @@ -0,0 +1,39 @@ + +intList a = sequence(1, 20); +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + +intList b = randseq(20); +28 27 5 17 44 6 9 40 15 26 49 35 15 48 13 27 25 25 9 6 + +intList c = concat(a, 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 + +intList d = map(inc, a); +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + +intList e = reverse(a); +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 + +intList 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 +intList 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 + +intList 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 Pix: +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, + +done diff --git a/gnu/lib/libg++/libg++/tests/tList.inp b/gnu/lib/libg++/libg++/tests/tList.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tMap.cc b/gnu/lib/libg++/libg++/tests/tMap.cc new file mode 100644 index 00000000000..ad03d4a1b1d --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tMap.cc @@ -0,0 +1,339 @@ +/* + a test file for Maps +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include + + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + +#include "iMap.h" + +unsigned int hash(int x) { return multiplicativehash(x) ; } + +int SIZE; + +int *nums; +int *odds; +int *perm; + +void add(int x[], int y[], intintMap& a) +{ + for (int i = 0; i < SIZE; ++i) a[x[i]] = y[i]; +} + +#include + +MLCG randgen; + +void permute(int x[]) +{ + for (int i = 1; i < SIZE; ++i) + { + int j = randgen.asLong() % (i + 1); + int tmp = x[i]; x[i] = x[j]; x[j] = tmp; + } +} + +void makenums() +{ + for (int i = 0; i < SIZE; ++i) nums[i] = i + 1; +} + +void makeodds() +{ + for (int i = 0; i < SIZE; ++i) odds[i] = 2 * i + 1; + permute(odds); +} + +void makeperm() +{ + for (int i = 0; i < SIZE; ++i) perm[i] = i + 1; + permute(perm); +} + +void printMap(intintMap& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + Pix i; + for (i = a.first(); i != 0 && k < maxprint; a.next(i),++k) + cout << "(" << a.key(i) << ", " << a.contents(i) << ") "; + if (i != 0) cout << "...]\n"; + else cout << "]\n"; +} + +#include "iSplayMap.h" + +void Splaytest() +{ + intintSplayMap a(-1); + add(nums, perm, a); + intintSplayMap b(-1); + add(perm, nums, b); + intintSplayMap c(-1); + add(perm, odds, c); + intintSplayMap d(a); + add(nums, nums, d); + cout << "a: "; printMap(a); + cout << "b: "; printMap(b); + cout << "c: "; printMap(c); + cout << "d: "; printMap(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + assert(a[SIZE+1] = -1); + + for (j = 1; j <= SIZE; ++j) assert(b.contains(j)); + + for (j = 1; j <= SIZE; ++j) assert(b[a[j]] == j); + for (j = 1; j <= SIZE; ++j) assert(a[b[j]] == j); + + for (j = 1; j <= SIZE; ++j) assert((c[j] & 1) != 0); + + for (j = 1; j <= SIZE; ++j) assert(d[j] == j); + + d.del(1); + assert(!d.contains(1)); + for (j = 1; j <= SIZE; ++j) d.del(j); + assert(d.empty()); + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + +} + +#include "iVHMap.h" + +void VHtest() +{ + intintVHMap a(-1, SIZE); + add(nums, perm, a); + intintVHMap b(-1, SIZE); + add(perm, nums, b); + intintVHMap c(-1, SIZE); + add(perm, odds, c); + intintVHMap d(a); + add(nums, nums, d); + cout << "a: "; printMap(a); + cout << "b: "; printMap(b); + cout << "c: "; printMap(c); + cout << "d: "; printMap(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + assert(a[SIZE+1] = -1); + + for (j = 1; j <= SIZE; ++j) assert(b.contains(j)); + + for (j = 1; j <= SIZE; ++j) assert(b[a[j]] == j); + for (j = 1; j <= SIZE; ++j) assert(a[b[j]] == j); + + for (j = 1; j <= SIZE; ++j) assert((c[j] & 1) != 0); + + for (j = 1; j <= SIZE; ++j) assert(d[j] == j); + + d.del(1); + assert(!d.contains(1)); + for (j = 1; j <= SIZE; ++j) d.del(j); + assert(d.empty()); + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + +} + +#include "iCHMap.h" + +void CHtest() +{ + intintCHMap a(-1, SIZE); + add(nums, perm, a); + intintCHMap b(-1, SIZE); + add(perm, nums, b); + intintCHMap c(-1, SIZE); + add(perm, odds, c); + intintCHMap d(a); + add(nums, nums, d); + cout << "a: "; printMap(a); + cout << "b: "; printMap(b); + cout << "c: "; printMap(c); + cout << "d: "; printMap(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + assert(a[SIZE+1] = -1); + + for (j = 1; j <= SIZE; ++j) assert(b.contains(j)); + + for (j = 1; j <= SIZE; ++j) assert(b[a[j]] == j); + for (j = 1; j <= SIZE; ++j) assert(a[b[j]] == j); + + for (j = 1; j <= SIZE; ++j) assert((c[j] & 1) != 0); + + for (j = 1; j <= SIZE; ++j) assert(d[j] == j); + + d.del(1); + assert(!d.contains(1)); + for (j = 1; j <= SIZE; ++j) d.del(j); + assert(d.empty()); + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + +} + +#include "iAVLMap.h" + +void AVLtest() +{ + intintAVLMap a(-1); + add(nums, perm, a); + intintAVLMap b(-1); + add(perm, nums, b); + intintAVLMap c(-1); + add(perm, odds, c); + intintAVLMap d(a); + add(nums, nums, d); + cout << "a: "; printMap(a); + cout << "b: "; printMap(b); + cout << "c: "; printMap(c); + cout << "d: "; printMap(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + assert(a[SIZE+1] = -1); + + for (j = 1; j <= SIZE; ++j) assert(b.contains(j)); + + for (j = 1; j <= SIZE; ++j) assert(b[a[j]] == j); + for (j = 1; j <= SIZE; ++j) assert(a[b[j]] == j); + + for (j = 1; j <= SIZE; ++j) assert((c[j] & 1) != 0); + + for (j = 1; j <= SIZE; ++j) assert(d[j] == j); + + d.del(1); + assert(!d.contains(1)); + for (j = 1; j <= SIZE; ++j) d.del(j); + assert(d.empty()); + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + +} + +#include "iRAVLMap.h" + +void RAVLtest() +{ + intintRAVLMap a(-1); + add(nums, perm, a); + intintRAVLMap b(-1); + add(perm, nums, b); + intintRAVLMap c(-1); + add(perm, odds, c); + intintRAVLMap d(a); + add(nums, nums, d); + cout << "a: "; printMap(a); + cout << "b: "; printMap(b); + cout << "c: "; printMap(c); + cout << "d: "; printMap(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + for (j = 1; j <= a.length(); ++j) assert(a.rankof(j) == j); + for (j = 1; j <= a.length(); ++j) assert(a.key(a.ranktoPix(j)) == j); + assert(a[SIZE+1] = -1); + + for (j = 1; j <= SIZE; ++j) assert(b.contains(j)); + + for (j = 1; j <= SIZE; ++j) assert(b[a[j]] == j); + for (j = 1; j <= SIZE; ++j) assert(a[b[j]] == j); + + for (j = 1; j <= SIZE; ++j) assert((c[j] & 1) != 0); + + for (j = 1; j <= SIZE; ++j) assert(d[j] == j); + + d.del(1); + assert(!d.contains(1)); + for (j = 1; j <= SIZE; ++j) d.del(j); + assert(d.empty()); + + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); + +} + +double return_elapsed_time ( double ); +double start_timer ( ); + +int main(int argv, char** argc) +{ + 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]; + makenums(); + makeodds(); + makeperm(); + start_timer(); + cout << "Splaytest\n"; Splaytest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "VHtest\n"; VHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "CHtest\n"; CHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "AVLtest\n"; AVLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "RAVLtest\n"; RAVLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tMap.exp b/gnu/lib/libg++/libg++/tests/tMap.exp new file mode 100644 index 00000000000..2d745ee0fa3 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tMap.exp @@ -0,0 +1,25 @@ +Splaytest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] +VHtest +a: [(72, 66) (77, 99) (13, 61) (3, 96) (26, 63) (16, 84) (39, 54) (29, 50) (52, 32) (42, 94) (65, 47) (55, 45) (78, 91) (91, 55) (9, 1) (22, 57) (35, 90) (48, 67) (61, 71) (74, 89) ...] +b: [(72, 41) (77, 43) (85, 38) (3, 2) (26, 19) (16, 57) (39, 23) (29, 53) (52, 14) (42, 21) (65, 1) (55, 91) (78, 95) (91, 78) (9, 6) (22, 20) (35, 27) (48, 33) (61, 13) (13, 50) ...] +c: [(72, 53) (77, 133) (85, 45) (3, 197) (26, 101) (16, 35) (39, 77) (29, 83) (52, 117) (42, 121) (65, 3) (55, 89) (78, 97) (91, 31) (9, 69) (22, 105) (35, 63) (48, 167) (61, 181) (13, 171) ...] +d: [(72, 72) (13, 13) (3, 3) (26, 26) (16, 16) (39, 39) (29, 29) (52, 52) (42, 42) (65, 65) (55, 55) (78, 78) (91, 91) (12, 12) (9, 9) (22, 22) (35, 35) (48, 48) (61, 61) (74, 74) ...] +CHtest +a: [(72, 66) (36, 25) (85, 92) (49, 10) (13, 61) (3, 96) (98, 8) (62, 5) (26, 63) (16, 84) (75, 51) (39, 54) (29, 50) (88, 81) (52, 32) (42, 94) (6, 9) (65, 47) (55, 45) (19, 26) ...] +b: [(72, 41) (36, 4) (49, 64) (13, 50) (85, 38) (3, 2) (62, 90) (98, 82) (26, 19) (16, 57) (75, 80) (39, 23) (29, 53) (88, 100) (52, 14) (6, 30) (42, 21) (65, 1) (55, 91) (19, 15) ...] +c: [(72, 53) (36, 161) (49, 67) (13, 171) (85, 45) (3, 197) (62, 177) (98, 95) (26, 101) (16, 35) (75, 25) (39, 77) (29, 83) (88, 47) (52, 117) (6, 135) (42, 121) (65, 3) (55, 89) (19, 173) ...] +d: [(36, 36) (72, 72) (13, 13) (49, 49) (85, 85) (3, 3) (26, 26) (62, 62) (98, 98) (16, 16) (39, 39) (75, 75) (29, 29) (52, 52) (88, 88) (6, 6) (42, 42) (65, 65) (19, 19) (55, 55) ...] +AVLtest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] +RAVLtest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] diff --git a/gnu/lib/libg++/libg++/tests/tMap.inp b/gnu/lib/libg++/libg++/tests/tMap.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tObstack.cc b/gnu/lib/libg++/libg++/tests/tObstack.cc new file mode 100644 index 00000000000..f1914021404 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tObstack.cc @@ -0,0 +1,80 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* + a little test of Obstacks + Thu Feb 18 11:16:28 1988 Doug Lea (dl at rocky.oswego.edu) +*/ + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + +#include +#include +#include +#include + +int +main() +{ + char* s[10000]; + int n = 0; + int got_one = 0; + Obstack os; + char c; + + s[n++] = (char *)os.copy("\nunique words:"); + assert(os.OK()); + assert(os.contains(s[0])); + + cout << "enter anything at all, end with an EOF(^D)\n"; + + while (cin.good() && n < 10000) + { + if (cin.get(c) && isalnum(c)) + { + got_one = 1; + os.grow(c); + } + else if (got_one) + { + char* current = (char *)os.finish(0); + for (int i = 0; i < n; ++i) // stupid, but this is only a test. + { + if (strcmp(s[i], current) == 0) + { + os.free(current); + current = 0; + break; + } + } + if (current != 0) + s[n++] = current; + got_one = 0; + } + } + assert(os.OK()); + + cout << s[0] << "\n"; + + for (int i = n - 1; i > 0; -- i) + { + assert(os.contains(s[i])); + cout << s[i] << "\n"; + os.free(s[i]); + } + + assert(os.OK()); + assert(os.contains(s[0])); + + cout << "\n\nObstack vars:\n"; + cout << "alignment_mask = " << os.alignment_mask() << "\n"; + cout << "chunk_size = " << os.chunk_size() << "\n"; + cout << "size = " << os.size() << "\n"; + cout << "room + chunk overhead = " << os.room() + 2*sizeof (char*) << "\n"; + + cout << "\nend of test\n"; + + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tObstack.exp b/gnu/lib/libg++/libg++/tests/tObstack.exp new file mode 100644 index 00000000000..32114e82b74 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tObstack.exp @@ -0,0 +1,32 @@ +enter anything at all, end with an EOF(^D) + +unique words: +deleted +redundant +with +this +in +words +the +list +simply +should +program +The +Obstacks +for +file +test +simple +a +is +This + + +Obstack vars: +alignment_mask = 3 +chunk_size = 4080 +size = 0 +room + chunk overhead = 4064 + +end of test diff --git a/gnu/lib/libg++/libg++/tests/tObstack.inp b/gnu/lib/libg++/libg++/tests/tObstack.inp new file mode 100644 index 00000000000..32dea332140 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tObstack.inp @@ -0,0 +1,5 @@ +This is a simple test file for Obstacks The test program should +simply list the words in this file with redundant words deleted +This is a simple test file for Obstacks The test program should +simply list the words in this file with redundant words deleted + diff --git a/gnu/lib/libg++/libg++/tests/tPQ.cc b/gnu/lib/libg++/libg++/tests/tPQ.cc new file mode 100644 index 00000000000..4cd144136ea --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tPQ.cc @@ -0,0 +1,275 @@ +/* + a test file for PQs +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + +#include "iPQ.h" + + +int SIZE; + +int *nums; +int *odds; +int *dups; + +void add(int x[], intPQ& a) +{ + for (int i = 0; i < SIZE; ++i) a.enq(x[i]); +} + +#include + +MLCG randgen; + +void permute(int x[]) +{ + for (int i = 1; i < SIZE; ++i) + { + int j = randgen.asLong() % (i + 1); + int tmp = x[i]; x[i] = x[j]; x[j] = tmp; + } +} + +void makenums() +{ + for (int i = 0; i < SIZE; ++i) nums[i] = i + 1; + permute(nums); +} + +void makeodds() +{ + for (int i = 0; i < SIZE; ++i) odds[i] = 2 * i + 1; + permute(odds); +} + +void makedups() +{ + for (int i = 0; i < SIZE; i += 2) dups[i] = dups[i+1] = i/2 + 1; + permute(dups); +} + +void printPQ(intPQ& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + Pix i; + for (i = a.first(); i != 0 && k < maxprint; a.next(i),++k) + cout << a(i) << " "; + if (i != 0) cout << "...]\n"; + else cout << "]\n"; +} + +#include "iXPPQ.h" + +void XPtest() +{ + intXPPQ a(SIZE); + add(nums, a); + intXPPQ b(SIZE); + add(odds, b); + intXPPQ c(SIZE); + add(dups, c); + intXPPQ d(a); + add(nums, d); + cout << "a: "; printPQ(a); + cout << "b: "; printPQ(b); + cout << "c: "; printPQ(c); + cout << "d: "; printPQ(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE*2); + assert(a.front() == 1); + assert(b.front() == 1); + assert(c.front() == 1); + assert(d.front() == 1); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + d.del_front(); + assert(d.front() == 1); + for (j = 1; j <= SIZE; ++j) assert(a.deq() == j); + assert(a.empty()); + for (j = 1; j <= SIZE*2; j+=2) assert(b.deq() == j); + assert(b.empty()); + Pix* indices = new Pix [SIZE]; + int m = 0; + for (Pix i = c.first(); i != 0; c.next(i), c.next(i)) indices[m++] = i; + assert(m == SIZE/2); + while (--m >= 0) c.del(indices[m]); + assert(c.length() == SIZE/2); + int last = -1; + j = 0; + while (!c.empty()) + { + int current = c.deq(); + assert(last <= current); + last = current; + ++j; + } + assert(j == SIZE/2); + + delete [] indices; + d.clear(); + assert(d.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); +} + +#include "iPHPQ.h" + +void PHtest() +{ + intPHPQ a(SIZE); + add(nums, a); + intPHPQ b(SIZE); + add(odds, b); + intPHPQ c(SIZE); + add(dups, c); + intPHPQ d(a); + add(nums, d); + cout << "a: "; printPQ(a); + cout << "b: "; printPQ(b); + cout << "c: "; printPQ(c); + cout << "d: "; printPQ(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE*2); + assert(a.front() == 1); + assert(b.front() == 1); + assert(c.front() == 1); + assert(d.front() == 1); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + d.del_front(); + assert(d.front() == 1); + for (j = 1; j <= SIZE; ++j) assert(a.deq() == j); + assert(a.empty()); + for (j = 1; j <= SIZE*2; j+=2) assert(b.deq() == j); + assert(b.empty()); + Pix* indices = new Pix [SIZE]; + int m = 0; + for (Pix i = c.first(); i != 0; c.next(i), c.next(i)) indices[m++] = i; + assert(m == SIZE/2); + while (--m >= 0) c.del(indices[m]); + assert(c.length() == SIZE/2); + int last = -1; + j = 0; + while (!c.empty()) + { + int current = c.deq(); + assert(last <= current); + last = current; + ++j; + } + assert(j == SIZE/2); + delete [] indices; + d.clear(); + assert(d.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); +} + +#include "iSplayPQ.h" + +void Splaytest() +{ + intSplayPQ a; + add(nums, a); + intSplayPQ b; + add(odds, b); + intSplayPQ c; + add(dups, c); + intSplayPQ d(a); + add(nums, d); + cout << "a: "; printPQ(a); + cout << "b: "; printPQ(b); + cout << "c: "; printPQ(c); + cout << "d: "; printPQ(d); + assert(a.length() == SIZE); + assert(b.length() == SIZE); + assert(c.length() == SIZE); + assert(d.length() == SIZE*2); + assert(a.front() == 1); + assert(b.front() == 1); + assert(c.front() == 1); + assert(d.front() == 1); + int j; + for (j = 1; j <= SIZE; ++j) assert(a.contains(j)); + d.del_front(); + assert(d.front() == 1); + for (j = 1; j <= SIZE; ++j) assert(a.deq() == j); + assert(a.empty()); + for (j = 1; j <= SIZE*2; j+=2) assert(b.deq() == j); + assert(b.empty()); + Pix* indices = new Pix[SIZE]; + int m = 0; + for (Pix i = c.first(); i != 0; c.next(i), c.next(i)) indices[m++] = i; + assert(m == SIZE/2); + while (--m >= 0) c.del(indices[m]); + assert(c.length() == SIZE/2); + int last = -1; + j = 0; + while (!c.empty()) + { + int current = c.deq(); + assert(last <= current); + last = current; + ++j; + } + assert(j == SIZE/2); + delete [] indices; + d.clear(); + assert(d.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + assert(d.OK()); +} + + + +int main(int argv, char** argc) +{ + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + nums = new int[SIZE]; + odds = new int[SIZE]; + dups = new int[SIZE]; + makenums(); + makeodds(); + makedups(); + start_timer(); + cout << "Splaytest\n"; Splaytest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "PHtest\n"; PHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "XPtest\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tPQ.exp b/gnu/lib/libg++/libg++/tests/tPQ.exp new file mode 100644 index 00000000000..f2d8e1156e0 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tPQ.exp @@ -0,0 +1,15 @@ +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +PHtest +a: [2 99 76 81 41 35 14 19 95 74 7 38 91 59 87 6 96 93 51 53 ...] +b: [129 5 191 71 147 17 139 193 1 47 199 33 121 103 37 167 145 67 51 43 ...] +c: [47 27 20 28 31 15 50 46 39 29 1 1 4 43 11 8 2 7 9 26 ...] +d: [2 99 76 81 41 35 14 19 95 74 7 38 91 59 87 6 96 93 51 53 ...] +XPtest +a: [1 3 2 7 4 5 18 29 12 6 10 8 17 21 26 34 36 15 16 19 ...] +b: [1 5 3 7 13 15 9 41 27 21 23 19 35 29 11 85 51 65 49 47 ...] +c: [1 2 1 3 5 2 8 4 5 6 14 3 9 11 10 7 15 12 6 28 ...] +d: [1 1 2 3 3 2 6 9 5 6 4 5 7 18 8 29 15 7 16 19 ...] diff --git a/gnu/lib/libg++/libg++/tests/tPQ.inp b/gnu/lib/libg++/libg++/tests/tPQ.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tPlex.cc b/gnu/lib/libg++/libg++/tests/tPlex.cc new file mode 100644 index 00000000000..cd3f90ad684 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tPlex.cc @@ -0,0 +1,719 @@ +/* + test of Plexes +*/ + +#include +#include +#include "iPlex.h" + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + + +void printplex(intPlex& a) +{ + cout << "["; + int maxprint = 20; + int k = 0; + int i; + for (i = a.low(); i < a.fence() && k < maxprint; ++i, ++k) + cout << a[i] << " "; + if (i < a.fence()) cout << "]\n"; + else cout << "...]\n"; +} + +#include "iFPlex.h" + +void FPtest () +{ + intFPlex p(50); + assert(p.OK()); + assert (p.empty()); + + p.add_high (1000); + Pix px = p.index_to_Pix(0); + assert (p.length() == 1); + assert(p.owns(px)); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 0); + + p.reset_low (10); + assert (p.length() == 1); + assert (p.low() == 10); + assert (p[10] == 1000); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 10); + assert(p.index_to_Pix(10) == px); + assert(p.OK()); + + int h = p.high_element(); + int l = p.low_element(); + assert ( (h==l) && (h==1000)); + p.fill(222); + assert(p(px) == 222); + + p.del_high(); + assert(p.empty()); + assert(!p.owns(px)); + + intFPlex q(10, -50); + q.add_low (-1000); + assert (q[9] == -1000); + q[9] = 21; + assert(!q.valid(10)); + assert(q.OK()); + + q.del_low(); + assert (q.empty()); + + p.reset_low (0); + q.reset_low (0); + + int i; + for (i = 0; i < 50; i++) + { + if (i % 2 == 0) + { + p.add_high (i); + assert (p.high() == i/2); + p[i/2] = p[i/4]; + assert (p.high_element() == i/4); + p[i/2] = i/2; + } + else + { + q.add_low (-i); + int ii = - (i/2) -1; + assert (q.low() == ii); + q.low_element() = ii; + assert (q[ii] == ii); + } + } + + cout << "q:"; printplex(q); + assert (p.length() == 25); + assert (q.length() == 25); + + assert(p.valid(0)); + assert(p.owns(px)); + + px = p.first(); + i = 0; + for (int it1 = p.low(); it1 < p.fence(); p.next(it1)) + { + assert (p[it1] == it1); + assert(p(px) == p[it1]); + p.next(px); + ++i; + } + assert(px == 0); + px = q.last(); + for (int it1 = q.high(); it1 > q.ecnef(); q.prev(it1)) + { + assert (q[it1] == it1); + assert(p(px) == q[it1]); + q.prev(px); + ++i; + } + assert(i == 50); + q.reset_low (0); + assert (p.high() == q.high()); + assert(p.low() == 0); + + intFPlex p1 = p; + intFPlex p2 (p); + intFPlex p3 = p2; + assert (p1.length() == 25); + assert (p1.high() == 24); + assert(p1.low() == 0); + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + + i = 0; + for (int it5 = p.low(); it5 < p.fence(); p.next(it5)) + { + assert(p1.low() == it5); + p1.del_low(); + assert(!p1.valid(it5)); + p2.del_high (); + p3 [it5] = -it5; + ++i; + } + assert(i == 25); + + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + assert (p1.empty()); + assert (p2.empty()); + + p3.append (p); + assert(p3.OK()); + + p1.prepend (p); + p2.append (p); + assert(p1.length() == p.length()); + assert(p1.length() == p2.length()); + assert(p1.OK()); + assert(p2.OK()); + + p2.clear(); + assert(p2.OK()); + assert(p2.empty()); + p2 = p1; + assert(p2.OK()); + + p1 = p; + assert(p1.OK()); + p1.reset_low (p1.low_element()); + for (int it6 = p1.low(); it6 < p1.fence(); it6++) + { + assert (p1[it6] == it6); + } + p1[13] = 1313; + p1[7] = -7777; + p1[24] = 24242424; + assert(!p1.valid(25)); + assert(!p1.valid(-1)); + assert(p1.OK()); + +} + +#include "iXPlex.h" + +void XPtest () +{ + intXPlex p(3); + assert(p.OK()); + assert (p.empty()); + + p.add_high (1000); + Pix px = p.index_to_Pix(0); + assert(p.Pix_to_index(px) == 0); + assert (p.length() == 1); + assert(p.owns(px)); + assert(p(px) == 1000); + + p.reset_low(10); + assert (p.length() == 1); + assert (p.low() == 10); + assert (p[10] == 1000); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 10); + assert(p.index_to_Pix(10) == px); + assert(p.OK()); + + int h = p.high_element(); + int l = p.low_element(); + assert ( (h==l) && (h==1000)); + p.fill(222); + assert(p(px) == 222); + + p.del_high(); + assert(p.empty()); + assert(!p.owns(px)); + + p.add_low(-1000); + assert (p[9] == -1000); + p[9] = 21; + assert(!p.valid(10)); + assert(p.OK()); + + p.del_low(); + assert (p.empty()); + p.reset_low (0); + + int i; + for (i = 0; i < 50; i++) + { + if (i % 2 == 0) + { + p.add_high (i); + assert (p.high() == i/2); + p[i/2] = p[i/4]; + assert (p.high_element() == i/4); + p[i/2] = i/2; + } + else + { + p.add_low (-i); + int ii = - (i/2) -1; + assert (p.low() == ii); + p.low_element() = ii; + assert (p[ii] == ii); + } + } + + assert (p.length() == 50); + cout << "p:"; printplex(p); + + assert(p.valid(0)); + assert(p.owns(px)); + + px = p.first(); + i = 0; + for (int it1 = p.low(); it1 < p.fence(); p.next(it1)) + { + assert (p[it1] == it1); + assert(p(px) == p[it1]); + p.next(px); + ++i; + } + assert(i == 50); + assert(px == 0); + p.reset_low (0); + assert (p.high() == 49); + assert(p.low() == 0); + + i = 0; + for (int it2 = p.high(); it2 > p.ecnef(); p.prev(it2)) + { + assert ( p[it2] == it2-25 ); + ++i; + } + assert(i == 50); + assert(p.OK()); + + intXPlex p1 = p; + intXPlex p2 (p); + intXPlex p3 = p2; + assert (p1.length() == 50); + assert (p1.high() == 49); + assert(p1.low() == 0); + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + + i = 0; + for (int it5 = p.low(); it5 < p.fence(); p.next(it5)) + { + assert(p1.low() == it5); + p1.del_low(); + assert(!p1.valid(it5)); + p2.del_high (); + p3 [it5] = -it5; + ++i; + } + assert(i == 50); + + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + assert (p1.empty()); + assert (p2.empty()); + + p3.append (p); + assert(p3.OK()); + + p1.prepend (p); + p2.append (p); + assert(p1.length() == p.length()); + assert(p1.length() == p2.length()); + assert(p1.OK()); + assert(p2.OK()); + + p2.clear(); + assert(p2.OK()); + assert(p2.empty()); + p2 = p1; + assert(p2.OK()); + + + p1 = p; + assert(p1.OK()); + p1.reset_low(p1.low_element()); + p1 [13] = 1313; + p1 [-7] = -7777; + p1 [-25] = -252525; + p1 [24] = 24242424; + assert(!p1.valid(25)); + assert(!p1.valid(-26)); + assert(p1.OK()); + + p1 = p; + p1.reset_low (p1.low_element()); + for (int it6 = p1.low(); it6 < p1.fence(); it6++) + { + assert (p1[it6] == it6); + } + p1.reverse(); + i = p1.high(); + for (int it6 = p1.low(); it6 < p1.fence(); it6++) + { + assert (p1[it6] == i); + --i; + } + assert(p1.OK()); + +} + +#include "iMPlex.h" + +void MPtest () +{ + intMPlex p(3); + assert(p.OK()); + assert (p.empty()); + + p.add_high (1000); + Pix px = p.index_to_Pix(0); + assert (p.length() == 1); + assert(p.owns(px)); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 0); + + p.reset_low (10); + assert (p.length() == 1); + assert (p.low() == 10); + assert (p[10] == 1000); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 10); + assert(p.index_to_Pix(10) == px); + assert(p.OK()); + + int h = p.high_element(); + int l = p.low_element(); + assert ( (h==l) && (h==1000)); + p.fill(222); + assert(p(px) == 222); + + p.del_high(); + assert(p.empty()); + assert(!p.owns(px)); + + p.add_low (-1000); + assert (p[9] == -1000); + p[9] = 21; + assert(!p.valid(10)); + assert(p.OK()); + + p.del_low(); + assert (p.empty()); + p.reset_low (0); + + int i; + for (i = 0; i < 50; i++) + { + if (i % 2 == 0) + { + p.add_high (i); + assert (p.high() == i/2); + p[i/2] = p[i/4]; + assert (p.high_element() == i/4); + p[i/2] = i/2; + } + else + { + p.add_low (-i); + int ii = - (i/2) -1; + assert (p.low() == ii); + p.low_element() = ii; + assert (p[ii] == ii); + } + } + + cout << "p:"; printplex(p); + assert (p.length() == 50); + assert (p.count() == 50); + + assert(p.available() == 0); + assert(p.valid(0)); + px = &p[0]; + assert(p.owns(px)); + p.del_index(0); + assert(p.count() == 49); + assert(p.available() == 1); + assert(p.unused_index() == 0); + assert(!p.valid(0)); + assert(!p.owns(px)); + p.undel_index(0); + p[0] = 0; + assert(p.count() == 50); + assert(p.available() == 0); + assert(p.valid(0)); + assert(p.owns(px)); + assert(p.OK()); + + p.del_index(0); + + px = p.first(); + i = 0; + for (int it1 = p.low(); it1 < p.fence(); p.next(it1)) + { + assert (p[it1] == it1); + assert(p(px) == p[it1]); + p.next(px); + ++i; + } + assert(i == 49); + assert(px == 0); + p.reset_low (0); + assert (p.high() == 49); + assert(p.low() == 0); + + i = 0; + for (int it2 = p.high(); it2 > p.ecnef(); p.prev(it2)) + { + assert ( p[it2] == it2-25 ); + assert(px != &p[it2]); + ++i; + } + assert(i == 49); + assert(p.OK()); + + p.del_index(1); + p.del_index(2); + assert (p.OK()); + assert (p.count() == 47); + + intMPlex p1 = p; + intMPlex p2 (p); + intMPlex p3 = p2; + assert (p1.length() == 50); + assert (p1.count() == 47); + assert (p1.high() == 49); + assert(p1.low() == 0); + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + + i = 0; + for (int it5 = p.low(); it5 < p.fence(); p.next(it5)) + { + assert(p1.low() == it5); + p1.del_low(); + assert(!p1.valid(it5)); + p2.del_high (); + p3 [it5] = -it5; + ++i; + } + assert(i == 47); + + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + assert (p1.empty()); + assert (p2.empty()); + + p3.append (p); + assert(p3.OK()); + + p1.prepend (p); + p2.append (p); + assert(p1.count() == p.count()); + assert(p1.count() == p2.count()); + assert(p1.OK()); + assert(p2.OK()); + + p2.clear(); + assert(p2.OK()); + assert(p2.empty()); + p2 = p1; + assert(p2.OK()); + + p1 = p; + p1.del_index(3); + p1.del_index(4); + p1.del_index(5); + p1.del_index(6); + p1.del_index(7); + p1.del_index(8); + p1.undel_index(6); + p1[6] = 6666; + p1[9] = 9999; + p1[0] = 0; + assert(p1[6] == 6666); + assert(!p1.valid(5)); + assert(!p1.valid(7)); + p1.del_low(); + assert(p1.low() == 6); + assert(p1.OK()); + +} + +#include "iRPlex.h" + +void RPtest () +{ + intRPlex p(3); + assert(p.OK()); + assert (p.empty()); + + p.add_high (1000); + Pix px = p.index_to_Pix(0); + assert(p.Pix_to_index(px) == 0); + assert (p.length() == 1); + assert(p.owns(px)); + assert(p(px) == 1000); + + p.reset_low(10); + assert (p.length() == 1); + assert (p.low() == 10); + assert (p[10] == 1000); + assert(p(px) == 1000); + assert(p.Pix_to_index(px) == 10); + assert(p.index_to_Pix(10) == px); + assert(p.OK()); + + int h = p.high_element(); + int l = p.low_element(); + assert ( (h==l) && (h==1000)); + p.fill(222); + assert(p(px) == 222); + + p.del_high(); + assert(p.empty()); + assert(!p.owns(px)); + + p.add_low(-1000); + assert (p[9] == -1000); + p[9] = 21; + assert(!p.valid(10)); + assert(p.OK()); + + p.del_low(); + assert (p.empty()); + p.reset_low (0); + + int i; + for (i = 0; i < 50; i++) + { + if (i % 2 == 0) + { + p.add_high (i); + assert (p.high() == i/2); + p[i/2] = p[i/4]; + assert (p.high_element() == i/4); + p[i/2] = i/2; + } + else + { + p.add_low (-i); + int ii = - (i/2) -1; + assert (p.low() == ii); + p.low_element() = ii; + assert (p[ii] == ii); + } + } + + assert (p.length() == 50); + cout << "p:"; printplex(p); + + assert(p.valid(0)); + assert(p.owns(px)); + + px = p.first(); + i = 0; + for (int it1 = p.low(); it1 < p.fence(); p.next(it1)) + { + assert (p[it1] == it1); + assert(p(px) == p[it1]); + p.next(px); + ++i; + } + assert(i == 50); + assert(px == 0); + p.reset_low (0); + assert (p.high() == 49); + assert(p.low() == 0); + + i = 0; + for (int it2 = p.high(); it2 > p.ecnef(); p.prev(it2)) + { + assert ( p[it2] == it2-25 ); + ++i; + } + assert(i == 50); + assert(p.OK()); + + intRPlex p1 = p; + intRPlex p2 (p); + intRPlex p3 = p2; + assert (p1.length() == 50); + assert (p1.high() == 49); + assert(p1.low() == 0); + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + + i = 0; + for (int it5 = p.low(); it5 < p.fence(); p.next(it5)) + { + assert(p1.low() == it5); + p1.del_low(); + assert(!p1.valid(it5)); + p2.del_high (); + p3 [it5] = -it5; + ++i; + } + assert(i == 50); + + assert(p.OK()); + assert(p1.OK()); + assert(p2.OK()); + assert(p3.OK()); + assert (p1.empty()); + assert (p2.empty()); + + p3.append (p); + assert(p3.OK()); + + p1.prepend (p); + p2.append (p); + assert(p1.length() == p.length()); + assert(p1.length() == p2.length()); + assert(p1.OK()); + assert(p2.OK()); + + p2.clear(); + assert(p2.OK()); + assert(p2.empty()); + p2 = p1; + assert(p2.OK()); + + + p1 = p; + assert(p1.OK()); + p1.reset_low(p1.low_element()); + p1 [13] = 1313; + p1 [-7] = -7777; + p1 [-25] = -252525; + p1 [24] = 24242424; + assert(!p1.valid(25)); + assert(!p1.valid(-26)); + assert(p1.OK()); + + p1 = p; + p1.reset_low (p1.low_element()); + for (int it6 = p1.low(); it6 < p1.fence(); it6++) + { + assert (p1[it6] == it6); + } + p1.reverse(); + i = p1.high(); + for (int it6 = p1.low(); it6 < p1.fence(); it6++) + { + assert (p1[it6] == i); + --i; + } + assert(p1.OK()); + +} + + +main() +{ + cout << "FPtest\n"; FPtest(); + cout << "XPtest\n"; XPtest(); + cout << "MPtest\n"; MPtest(); + cout << "RPtest\n"; RPtest(); + cout << "\nend of tests\n"; +} diff --git a/gnu/lib/libg++/libg++/tests/tPlex.exp b/gnu/lib/libg++/libg++/tests/tPlex.exp new file mode 100644 index 00000000000..42f939f9420 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tPlex.exp @@ -0,0 +1,10 @@ +FPtest +q:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +XPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +MPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +RPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] + +end of tests diff --git a/gnu/lib/libg++/libg++/tests/tPlex.inp b/gnu/lib/libg++/libg++/tests/tPlex.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tQueue.cc b/gnu/lib/libg++/libg++/tests/tQueue.cc new file mode 100644 index 00000000000..51615da020f --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tQueue.cc @@ -0,0 +1,209 @@ +/* + test of Queues +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include "iQueue.h" + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + + +int SIZE; + +void print(intQueue& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + while (!a.empty() && k++ < maxprint) + cout << a.deq() << " "; + if (k == maxprint) + cout << "]\n"; + else + { + while (!a.empty()) a.del_front(); + cout << "...]\n"; + } + assert(a.empty()); +} + +#include "iXPQueue.h" + +void XPtest () +{ + intXPQueue q(SIZE/2); + assert(q.OK()); + for (int i = 0; i < SIZE; ++i) + q.enq(i); + assert(q.length() == SIZE); + assert(q.front() == 0); + assert(!q.full()); + intXPQueue q1(SIZE*2); + for (int i = 0; i < SIZE; ++i) + { + int x = q.deq(); + assert(x == i); + q1.enq(x); + } + assert(q.empty()); + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q.OK()); + assert(q1.OK()); + intXPQueue q2 (q1); + assert(q2.length() == SIZE); + assert(q2.front() == 0); + assert(q2.OK()); + q1.clear(); + assert(q1.empty()); + q1 = q2; + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q1.OK()); + q1.del_front(); + assert(q1.length() == (SIZE-1)); + assert(q1.front() == 1); + cout << "q1:"; print(q1); + assert(q.OK()); + assert(q1.OK()); + assert(q2.OK()); +} + +#include "iVQueue.h" + +void Vtest () +{ + intVQueue q(SIZE); + assert(q.OK()); + for (int i = 0; i < SIZE; ++i) + q.enq(i); + assert(q.length() == SIZE); + assert(q.front() == 0); + assert(q.full()); + intVQueue q1(SIZE); + for (int i = 0; i < SIZE; ++i) + { + int x = q.deq(); + assert(x == i); + q1.enq(x); + } + assert(q.empty()); + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q.OK()); + assert(q1.OK()); + intVQueue q2 (q1); + assert(q2.length() == SIZE); + assert(q2.front() == 0); + assert(q2.OK()); + q1.clear(); + assert(q1.empty()); + q1 = q2; + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q1.OK()); + q1.del_front(); + assert(q1.length() == (SIZE-1)); + assert(q1.front() == 1); + cout << "q1:"; print(q1); + assert(q.OK()); + assert(q1.OK()); + assert(q2.OK()); +} + +#include "iSLQueue.h" + +void SLtest () +{ + intXPQueue q; + assert(q.OK()); + for (int i = 0; i < SIZE; ++i) + q.enq(i); + assert(q.length() == SIZE); + assert(q.front() == 0); + assert(!q.full()); + intXPQueue q1; + for (int i = 0; i < SIZE; ++i) + { + int x = q.deq(); + assert(x == i); + q1.enq(x); + } + assert(q.empty()); + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q.OK()); + assert(q1.OK()); + intXPQueue q2 (q1); + assert(q2.length() == SIZE); + assert(q2.front() == 0); + assert(q2.OK()); + q1.clear(); + assert(q1.empty()); + q1 = q2; + assert(q1.length() == SIZE); + assert(q1.front() == 0); + assert(q1.OK()); + q1.del_front(); + assert(q1.length() == (SIZE-1)); + assert(q1.front() == 1); + cout << "q1:"; print(q1); + assert(q.OK()); + assert(q1.OK()); + assert(q2.OK()); +} + +/* Test case from Jocelyn Serot */ +void +test_resize () +{ + intVQueue Q(4); + Q.enq(1); + Q.enq(2); + cout << Q.deq() << endl; + Q.enq(3); + Q.enq(4); + cout << Q.deq() << endl; + Q.enq(5); + Q.enq(6); + cout << Q.deq() << endl; + Q.enq(7); // Q is now full + Q.resize(8); // Lets grow it + Q.enq(8); // *** bug manifest at this point + cout << Q.deq() << endl; + cout << Q.deq() << endl; + cout << Q.deq() << endl; + cout << Q.deq() << endl; // Q is now empty +} + +int main(int argv, char** argc) +{ + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + start_timer(); + cout << "XP queues:\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "V queues:\n"; Vtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "SL queues:\n"; SLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + + test_resize (); + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tQueue.exp b/gnu/lib/libg++/libg++/tests/tQueue.exp new file mode 100644 index 00000000000..5571e7580a2 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tQueue.exp @@ -0,0 +1,15 @@ +XP queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +V queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +SL queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +1 +2 +3 +4 +5 +6 +7 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tQueue.inp b/gnu/lib/libg++/libg++/tests/tQueue.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tRandom.cc b/gnu/lib/libg++/libg++/tests/tRandom.cc new file mode 100644 index 00000000000..e41e4bf4df6 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tRandom.cc @@ -0,0 +1,103 @@ +/* + a test file for Random classes +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void demo(Random& r) +{ + SampleStatistic s; + cout << "five samples:\n"; + for (int i = 0; i < 5; ++i) + { + double x = r(); + cout << x << " "; + s += x; + } + cout << "\nStatistics for 100 samples:\n"; + for (; i < 100; ++i) + { + double x = r(); + s += x; + } + cout << "samples: " << s.samples() << " "; + cout << "min: " << s.min() << " "; + cout << "max: " << s.max() << "\n"; + cout << "mean: " << s.mean() << " "; + cout << "stdDev: " << s.stdDev() << " "; + cout << "var: " << s.var() << " "; + cout << "confidence(95): " << s.confidence(95) << "\n"; +} + +main() +{ + int i; + ACG gen1; + cout << "five random ACG integers:\n"; + for (i = 0; i < 5; ++i) + cout << gen1.asLong() << " "; + cout << "\n"; + + MLCG gen2; + cout << "five random MLCG integers:\n"; + for (i = 0; i < 5; ++i) + cout << gen2.asLong() << " "; + cout << "\n"; + + Binomial r1( 100, 0.5, &gen1); + cout << "Binomial r1( 100, 0.50, &gen1) ...\n"; + demo(r1); + Erlang r2( 2.0, 0.5, &gen1); + cout << "Erlang r2( 2.0, 0.5, &gen1) ...\n"; + demo(r2); + Geometric r3( 0.5, &gen1); + cout << "Geometric r3(&gen1, 0.5)...\n"; + demo(r3); + HyperGeometric r4( 10.0, 150.0, &gen1); + cout << "HyperGeometric r4( 10.0, 150.0, &gen1)...\n"; + demo(r4); + NegativeExpntl r5( 1.0, &gen1); + cout << "NegativeExpntl r5( 1.0, &gen1)...\n"; + demo(r5); + Normal r6( 0.0, 1.0, &gen1); + cout << "Normal r6( 0.0, 1.0, &gen1)...\n"; + demo(r6); + LogNormal r7( 1.0, 1.0, &gen1); + cout << "LogNormal r7( 1.0, 1.0, &gen1)...\n"; + demo(r7); + Poisson r8( 2.0, &gen1); + cout << "Poisson r8( 2.0, &gen1)...\n"; + demo(r8); + DiscreteUniform r9( 0, 1, &gen1); + cout << "DiscreteUniform r9( 0.0, 1.0, &gen1)...\n"; + demo(r9); + Uniform r10( 0.0, 1.0, &gen1); + cout << "Uniform r10( 0.0, 1.0, &gen1)...\n"; + demo(r10); + Weibull r11( 0.5, 1.0, &gen1); + cout << "Weibull r11( 0.5, 1.0, &gen1)...\n"; + demo(r11); + + cout << "SampleHistogram for 100 Normal samples\n"; + SampleHistogram h(-4.0, 4.0); + for (i = 0; i < 100; ++i) + h += r6(); + h.printBuckets(cout); + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tRandom.exp b/gnu/lib/libg++/libg++/tests/tRandom.exp new file mode 100644 index 00000000000..9906721b030 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tRandom.exp @@ -0,0 +1,85 @@ +five random ACG integers: +1525072166 1954057046 3406008937 226879594 4107049426 +five random MLCG integers: +1341853672 83475514 936613571 888739672 2097844081 +Binomial r1( 100, 0.50, &gen1) ... +five samples: +45 52 59 49 60 +Statistics for 100 samples: +samples: 100 min: 40 max: 64 +mean: 50.78 stdDev: 4.42577 var: 19.5875 confidence(95): 0.878369 +Erlang r2( 2.0, 0.5, &gen1) ... +five samples: +1.79909 1.92989 2.50816 2.31409 1.48158 +Statistics for 100 samples: +samples: 100 min: 0.592645 max: 3.81874 +mean: 1.96664 stdDev: 0.696406 var: 0.484981 confidence(95): 0.138213 +Geometric r3(&gen1, 0.5)... +five samples: +3 2 2 2 3 +Statistics for 100 samples: +samples: 100 min: 1 max: 7 +mean: 1.9 stdDev: 1.28315 var: 1.64646 confidence(95): 0.254662 +HyperGeometric r4( 10.0, 150.0, &gen1)... +five samples: +15.0752 5.25802 7.82211 20.4995 7.08199 +Statistics for 100 samples: +samples: 100 min: 0.0446068 max: 131.508 +mean: 12.6763 stdDev: 16.7567 var: 280.786 confidence(95): 3.32564 +NegativeExpntl r5( 1.0, &gen1)... +five samples: +1.90665 0.0921974 0.219318 1.79202 0.566202 +Statistics for 100 samples: +samples: 100 min: 0.00794624 max: 4.23124 +mean: 0.927343 stdDev: 0.8869 var: 0.786592 confidence(95): 0.17602 +Normal r6( 0.0, 1.0, &gen1)... +five samples: +-0.174892 0.148871 -0.479753 0.65432 -0.92688 +Statistics for 100 samples: +samples: 100 min: -2.22325 max: 2.61771 +mean: 0.141292 stdDev: 0.972041 var: 0.944864 confidence(95): 0.192918 +LogNormal r7( 1.0, 1.0, &gen1)... +five samples: +2.15572 0.985688 0.340019 0.959144 1.06052 +Statistics for 100 samples: +samples: 100 min: 0.0393323 max: 6.16358 +mean: 1.03547 stdDev: 0.963892 var: 0.929088 confidence(95): 0.191301 +Poisson r8( 2.0, &gen1)... +five samples: +0 2 1 2 1 +Statistics for 100 samples: +samples: 100 min: 0 max: 5 +mean: 2 stdDev: 1.31041 var: 1.71717 confidence(95): 0.260073 +DiscreteUniform r9( 0.0, 1.0, &gen1)... +five samples: +1 1 0 0 0 +Statistics for 100 samples: +samples: 100 min: 0 max: 1 +mean: 0.45 stdDev: 0.5 var: 0.25 confidence(95): 0.0992334 +Uniform r10( 0.0, 1.0, &gen1)... +five samples: +0.557314 0.529968 0.997197 0.25163 0.947497 +Statistics for 100 samples: +samples: 100 min: 0.00205286 max: 0.997197 +mean: 0.518789 stdDev: 0.321429 var: 0.103317 confidence(95): 0.0637931 +Weibull r11( 0.5, 1.0, &gen1)... +five samples: +10.4918 0.295112 0.184577 2.14799 0.10053 +Statistics for 100 samples: +samples: 100 min: 0.000236481 max: 15.4934 +mean: 1.96369 stdDev: 2.97642 var: 8.85906 confidence(95): 0.59072 +SampleHistogram for 100 Normal samples +< -4 : 0 +< -3.2 : 0 +< -2.4 : 0 +< -1.6 : 7 +< -0.8 : 15 +< -2.22045e-16 : 36 +< 0.8 : 15 +< 1.6 : 19 +< 2.4 : 7 +< 3.2 : 1 +< 4 : 0 +< max : 0 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tRandom.inp b/gnu/lib/libg++/libg++/tests/tRandom.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tRational.cc b/gnu/lib/libg++/libg++/tests/tRational.cc new file mode 100644 index 00000000000..2c49a814dea --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tRational.cc @@ -0,0 +1,194 @@ +/* + a test file for Rational class + */ + +#include + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + + +void identtest(Rational& a, Rational& b, Rational& c) +{ + Rational one(1, 1); + + assert(-(-a) == a); + assert((a + b) == (b + a)); + assert((a + (-b)) == (a - b)); + assert((a * b) == (b * a)); + assert((a * (-b)) == -(a * b)); + assert((a / (-b)) == -(a / b)); + assert((a / b) == (a * (one / b))); + assert((a / b) == (one / (b / a))); + assert((a - b) == -(b - a)); + assert((a + (b + c)) == ((a + b) + c)); + assert((a * (b * c)) == ((a * b) * c)); + assert((a * (b + c)) == ((a * b) + (a * c))); + assert(((a - b) + b) == a); + assert(((a + b) - b) == a); + assert(((a * b) / b) == a); + assert(((a / b) * b) == a); + + Rational x = a; + x *= b; + assert(x == (a * b)); + x += c; + assert(x == ((a * b) + c)); + x -= a; + assert(x == (((a * b) + c) - a)); + x /= b; + assert(x == ((((a * b) + c) - a) / b)); + + assert(x.OK()); +} + + + +void simpletest() +{ + Rational one = 1; + assert(one.OK()); + Rational third(1, 3); + assert(third.OK()); + Rational half(1, 2); + assert(half.OK()); + + Rational two(2); + Rational zero(0); + Rational r; + r = two+zero; + + cout << "one = " << one << "\n"; + cout << "two = " << r << "\n"; + cout << "third = " << third << "\n"; + cout << "half = " << half << "\n"; + + cout << "third + half = " << third + half << "\n"; + cout << "third - half = " << third - half << "\n"; + cout << "third * half = " << third * half << "\n"; + cout << "third / half = " << third / half << "\n"; + + Rational onePointTwo = 1.2; + cout << "onePointTwo = " << onePointTwo << "\n"; + cout << "double(onePointTwo) = " << double(onePointTwo) << "\n"; + + Rational a = one; + cout << "a = " << a << "\n"; + assert(a.OK()); + a += half; + cout << "a += half = " << a << "\n"; + assert(a == Rational(3, 2)); + a -= half; + cout << "a -= half = " << a << "\n"; + assert(a == Rational(1)); + a *= half; + cout << "a *= half = " << a << "\n"; + assert(a == half); + a /= half; + cout << "a /= half = " << a << "\n"; + assert(a == Rational(1)); + assert(a.OK()); + + identtest(one, one, one); + identtest(one, third, half); + identtest(third, half, one); + identtest(onePointTwo, half, a); +} + +void pitest() +{ + Rational half(1, 2); + Rational approxpi(355, 113); + assert(approxpi.OK()); + cout << "approxpi = " << approxpi << "\n"; + cout << "double(approxpi) = " << double(approxpi) << "\n"; + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + Rational rpi = Rational(M_PI); + cout << "rpi = Rational(PI) = " << rpi << "\n"; + assert(rpi.OK()); + cout << "double(rpi) = " << double(rpi) << "\n"; + + cout << "approxpi + rpi = " << approxpi + rpi << "\n"; + cout << "approxpi - rpi = " << approxpi - rpi << "\n"; + cout << "approxpi * rpi = " << approxpi * rpi << "\n"; + cout << "approxpi / rpi = " << approxpi / rpi << "\n"; + + Rational negapproxpi = -approxpi; + + cout << "-approxpi = " << negapproxpi << "\n"; + assert(sign(negapproxpi) < 0); + cout << "abs(negapproxpi) = " << abs(negapproxpi) << "\n"; + assert(abs(negapproxpi) == approxpi); + + assert(approxpi != rpi); + assert(approxpi >= rpi); + assert(approxpi > rpi); + assert(!(approxpi == rpi)); + assert(!(approxpi <= rpi)); + assert(!(approxpi < rpi)); +#if defined (__GNUC__) && ! defined (__STRICT_ANSI__) + assert((approxpi >? rpi) == approxpi); + assert((approxpi > a; + cout << "number = " << a << "\n"; + assert(a.OK()); +} + +// as a fct just to test Rational fcts +Rational estimate_e(long n) +{ + Rational x = Rational(n + 1, n); + Rational e = pow(x, n); + return e; +} + +void etest(long n) +{ + cout << "approximating e as pow(1+1/n),n) for n =" << n << "\n"; + Rational approxe = estimate_e(n); + assert(approxe.OK()); + cout << "double(approxe) = " << double(approxe) << "\n"; + cout << "log(approxe) = " << log(approxe) << "\n"; + assert(log(approxe) <= 1.0); + cout << "approxe = " << approxe << "\n"; +} + +int main() +{ + simpletest(); + pitest(); + IOtest(); + etest(10); + etest(100); + etest(1000); + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tRational.exp b/gnu/lib/libg++/libg++/tests/tRational.exp new file mode 100644 index 00000000000..743aadd8862 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tRational.exp @@ -0,0 +1,41 @@ +one = 1 +two = 2 +third = 1/3 +half = 1/2 +third + half = 5/6 +third - half = -1/6 +third * half = 1/6 +third / half = 2/3 +onePointTwo = 5404319552844595/4503599627370496 +double(onePointTwo) = 1.2 +a = 1 +a += half = 3/2 +a -= half = 1 +a *= half = 1/2 +a /= half = 1 +approxpi = 355/113 +double(approxpi) = 3.14159 +rpi = Rational(PI) = 884279719003555/281474976710656 +double(rpi) = 3.14159 +approxpi + rpi = 199847224979684595/31806672368304128 +approxpi - rpi = 8484881165/31806672368304128 +approxpi * rpi = 313919300246262025/31806672368304128 +approxpi / rpi = 19984723346456576/19984721649480343 +-approxpi = -355/113 +abs(negapproxpi) = 355/113 + +enter a Rational in form a/b or a: number = 61727839/49382716 +approximating e as pow(1+1/n),n) for n =10 +double(approxe) = 2.59374 +log(approxe) = 0.953102 +approxe = 25937424601/10000000000 +approximating e as pow(1+1/n),n) for n =100 +double(approxe) = 2.70481 +log(approxe) = 0.995033 +approxe = 270481382942152609326719471080753083367793838278100277689020104911710151430673927943945601434674459097335651375483564268312519281766832427980496322329650055217977882315938008175933291885667484249510001/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +approximating e as pow(1+1/n),n) for n =1000 +double(approxe) = 2.71692 +log(approxe) = 0.9995 +approxe = 2716923932235892457383088121947577188964315018836572803722354774868894945523768158997885697298661429053421034015406256924859461187617653889457753593083386399572063538500432650176144488046171044844121805479607648086607018742077798375087855857012278053105042704758822511824867218226931719410407150364389665913091822576819072281835735365786202176167228686198158460724641052407506305826211156964723064441295969498221919251479211700941935114755531972677360157561485144237786816579422141378066423317811515462669946309306263409027388915931082226854264858661420878279983534424128672461206356847463821364630504359665171573635397346037274752410368174877433941234543153511100471651472869116068528478976916600585383497180172395573924789047989563714318957536493108041591460911612078698461739084741934442448701416575483263891529095158013233115648534154086009312190489168546024398834243847135102411661996020129557921444666343641039137906807591342742464200991933722791531063202677650581946360422027765645970182463780273161113009717582155489902677095053354207944772439271656447869921825959042801322775729022491402012084605367784456090892987682547811360481731795980637847551788259384243997341190753089343387201753821360405430310320564488741142120089460368986590136324737459372963666586532443570474179352656517635333744783401695951969936296323256525034685525470426185224036844803487442831639483152362831735350269624668701702424450940840884555271325190876102665277858154695092765613639718577127438538649414492678358762110235621776218781360881010654696273264706319088453035858355052988808507775439561385232652305316287705653436727647681405618323757201022946801118770148072424021385261829594248369890171583993147934044232792517118743393217276416179842097554494269012251329134783596037733973478306188255291484352384699871420472711423079586319041837563678498472779422282261024744394844558738378027105699691260086532632930941478779680554645850778168703661423819000515895232903243738763481571999080702098369316199601942246247887808385073821861517636839926907458184604648942036355256683219218129910422822177336785268627274482037476294341444562207197209503659518266210432791078248321015453218019586608696207295299183111963158564162419152742807437346241667671688466998244424726765837682151606230638111654756595917019206453978024157097042546937345673337179165242325399648121877178987723999503839197328183925340949191821443698275476295245249466361817367207248089144718808572152781037112209285944844021186534832159964297181970584453756163204297111185823467744743465840230098261424789313315093951766314459027947176701489215746884363426961577348384651887153140609616362927338107686794499974902581579897076172716541504294334300741444106749994715713419630688719451362658288812132056854807330827050505064714442618243101018812153563795539024370219967801515099970721926240625418512417940854760415566229746248973756297569452302821563467574313259066016089521122779204844875998864114930516063910324359331903843040069467324167490917499501000001/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tRational.inp b/gnu/lib/libg++/libg++/tests/tRational.inp new file mode 100644 index 00000000000..c6aff5c4201 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tRational.inp @@ -0,0 +1 @@ +123455678/98765432 diff --git a/gnu/lib/libg++/libg++/tests/tSet.cc b/gnu/lib/libg++/libg++/tests/tSet.cc new file mode 100644 index 00000000000..f05ca34086a --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tSet.cc @@ -0,0 +1,744 @@ +/* + a test file for sets +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include + +#define tassert(ex) { cerr << #ex; \ + if ((ex)) cerr << " OK\n"; \ + else cerr << " Fail\n"; } + +unsigned int hash(int x) { return multiplicativehash(x) ; } + +#include "iSet.h" + +int SIZE; + +int *nums; +int *odds; +int *dups; + +void printset(intSet& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + Pix i; + for (i = a.first(); i != 0 && k < maxprint; a.next(i),++k) + cout << a(i) << " "; + if (i != 0) cout << "...]\n"; + else cout << "]\n"; +} + +void add(int x[], intSet& a) +{ + for (int i = 0; i < SIZE; ++i) a.add(x[i]); +} + +#include + +MLCG randgen; + +void permute(int x[]) +{ + for (int i = 1; i < SIZE; ++i) + { + int j = randgen.asLong() % (i + 1); + int tmp = x[i]; x[i] = x[j]; x[j] = tmp; + } +} + + +void makenums() +{ + for (int i = 0; i < SIZE; ++i) nums[i] = i + 1; +} + +void makeodds() +{ + for (int i = 0; i < SIZE; ++i) odds[i] = 2 * i + 1; + permute(odds); +} + +void makedups() +{ + for (int i = 0; i < SIZE; i += 2) dups[i] = dups[i+1] = i/2 + 1; + permute(dups); +} + + +void generictest(intSet& a, intSet& b, intSet& c) +{ + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); +} + +#include "iXPSet.h" + +void XPtest() +{ + intXPSet a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intXPSet b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intXPSet c(SIZE); + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intXPSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +#include "iSLSet.h" + +void SLtest() +{ + intSLSet a; + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intSLSet b; + add(odds, b); + assert(b.length() == SIZE); + intSLSet c; + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intSLSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +#include "iVHSet.h" + +void VHtest() +{ + intVHSet a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intVHSet b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intVHSet c(SIZE); + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intVHSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iVOHSet.h" + +void VOHtest() +{ + intVOHSet a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intVOHSet b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intVOHSet c(SIZE); + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intVOHSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iCHSet.h" + +void CHtest() +{ + intCHSet a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intCHSet b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intCHSet c(SIZE); + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intCHSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iOXPSet.h" + +void OXPtest() +{ + intOXPSet a(SIZE); + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intOXPSet b(SIZE); + add(odds, b); + assert(b.length() == SIZE); + intOXPSet c(SIZE); + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intOXPSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + + +#include "iOSLSet.h" + +void OSLtest() +{ + intOSLSet a; + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intOSLSet b; + add(odds, b); + assert(b.length() == SIZE); + intOSLSet c; + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intOSLSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iBSTSet.h" + +void BSTtest() +{ + intBSTSet a; + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + a.balance(); + assert(a.OK()); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intBSTSet b; + add(odds, b); + assert(b.length() == SIZE); + intBSTSet c; + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intBSTSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iAVLSet.h" + +void AVLtest() +{ + intAVLSet a; + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intAVLSet b; + add(odds, b); + assert(b.length() == SIZE); + intAVLSet c; + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intAVLSet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + +#include "iSplaySet.h" + +void Splaytest() +{ + intSplaySet a; + add(nums, a); + assert(a.length() == SIZE); + for (int j = 1; j <= SIZE; ++j) assert(a.contains(j)); + intSplaySet b; + add(odds, b); + assert(b.length() == SIZE); + intSplaySet c; + add(dups, c); + assert(c.length() == SIZE/2); + assert(c <= a); + intSplaySet d(a); + d &= b; + cout << "a: "; printset(a); + cout << "b: "; printset(b); + cout << "c: "; printset(c); + cout << "d: "; printset(d); + assert(d.length() == SIZE/2); + for (Pix p = d.first(); p; d.next(p)) assert((d(p) & 1) != 0); + a.del(1); + assert(a.length() == SIZE-1); + assert(!a.contains(1)); + + c.clear(); + assert(c.empty()); + c |= a; + assert(c == a); + assert(c <= a); + c.del(a(a.first())); + assert(c <= a); + assert(c != a); + Pix i = a.first(); + assert(!c.contains(a(i))); + for (a.next(i); i != 0; a.next(i)) assert(c.contains(a(i))); + c.add(a(a.first())); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c |= b; + assert(b <= c); + for (i = b.first(); i != 0; b.next(i)) assert(c.contains(b(i))); + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c &= a; + for (i = a.first(); i != 0; a.next(i)) assert(c.contains(a(i))); + c -= a; + assert(!(a <= c)); + for (i = a.first(); i != 0; a.next(i)) assert(!c.contains(a(i))); + for (i = b.first(); i != 0; b.next(i)) c.del(b(i)); + assert(c.empty()); + assert(a.OK()); + assert(b.OK()); + assert(c.OK()); + + generictest(a, b, c); +} + + +int main(int argc, char** argv) +{ + if (argc > 1) + { + SIZE = abs(atoi(argv[1])); + SIZE &= ~1; + } + else + SIZE = 100; + nums = new int[SIZE]; + odds = new int[SIZE]; + dups = new int[SIZE]; + makenums(); + makeodds(); + makedups(); + start_timer(); + cout << "VHtest\n"; VHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "VOHtest\n"; VOHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "CHtest\n"; CHtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "SLtest\n"; SLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "XPtest\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "OXPtest\n"; OXPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "OSLtest\n"; OSLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "BSTtest\n"; BSTtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "AVLtest\n"; AVLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "Splaytest\n"; Splaytest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tSet.exp b/gnu/lib/libg++/libg++/tests/tSet.exp new file mode 100644 index 00000000000..f014df48ec6 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tSet.exp @@ -0,0 +1,50 @@ +VHtest +a: [72 77 13 3 26 16 39 29 52 42 65 55 78 91 9 22 35 48 61 74 ...] +b: [167 77 13 3 193 39 139 29 93 47 65 55 155 109 91 9 117 171 35 143 ...] +c: [36 49 46 3 26 16 39 29 12 42 19 32 9 1 22 35 48 25 2 15 ...] +d: [13 3 39 29 65 55 91 9 35 61 15 41 67 25 93 11 47 87 37 73 ...] +VOHtest +a: [7 14 21 28 35 42 49 56 63 70 77 84 91 98 5 12 19 26 33 40 ...] +b: [7 163 21 133 35 49 63 199 77 129 91 181 105 119 5 155 19 187 33 193 ...] +c: [7 14 21 28 35 42 49 5 12 19 26 33 40 47 3 10 17 24 31 38 ...] +d: [7 21 35 49 63 77 91 5 19 33 47 61 75 89 3 17 31 45 59 73 ...] +CHtest +a: [72 36 85 49 13 3 98 62 26 16 75 39 29 88 52 42 6 65 55 19 ...] +b: [167 49 85 121 13 3 157 193 111 39 75 147 29 183 137 65 101 173 55 19 ...] +c: [36 13 49 3 26 16 39 29 6 42 19 32 45 9 22 35 12 48 25 38 ...] +d: [13 49 85 3 39 75 29 65 19 55 91 9 45 81 35 71 25 61 97 15 ...] +SLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 17 13 11 21 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +XPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 17 13 11 21 ...] +d: [51 13 53 27 55 7 57 29 59 15 61 31 63 1 65 33 67 17 69 35 ...] +OXPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +OSLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +BSTtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +AVLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] diff --git a/gnu/lib/libg++/libg++/tests/tSet.inp b/gnu/lib/libg++/libg++/tests/tSet.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tStack.cc b/gnu/lib/libg++/libg++/tests/tStack.cc new file mode 100644 index 00000000000..7435ec1d0ff --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tStack.cc @@ -0,0 +1,188 @@ +/* + test of stacks +*/ + +#ifdef PTIMES +const int ptimes = 1; +#else +const int ptimes = 0; +#endif + +#include +#include +#include "iStack.h" + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + + +int SIZE; + +void print(intStack& a) +{ + int maxprint = 20; + cout << "["; + int k = 0; + while (!a.empty() && k++ < maxprint) + cout << a.pop() << " "; + if (k == maxprint) + cout << "]\n"; + else + { + while (!a.empty()) a.del_top(); + cout << "...]\n"; + } + assert(a.empty()); +} + +#include "iXPStack.h" + +void XPtest () +{ + intXPStack s(SIZE/2); + assert(s.OK()); + for (int i = 0; i < SIZE; ++i) + s.push(i); + assert(s.length() == SIZE); + assert(s.top() == (SIZE-1)); + assert(!s.full()); + intXPStack s1(SIZE*2); + for (int i = 0; i < SIZE; ++i) + { + int x = s.pop(); + assert(x == (SIZE-1) - i); + s1.push(x); + } + assert(s.empty()); + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s.OK()); + assert(s1.OK()); + intXPStack s2 (s1); + assert(s2.length() == SIZE); + assert(s2.top() == 0); + assert(s2.OK()); + s1.clear(); + assert(s1.empty()); + s1 = s2; + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s1.OK()); + s1.del_top(); + assert(s1.length() == (SIZE-1)); + assert(s1.top() == 1); + cout << "s1:"; print(s1); + assert(s.OK()); + assert(s1.OK()); + assert(s2.OK()); +} + +#include "iVStack.h" + + +void Vtest () +{ + intVStack s(SIZE); + assert(s.OK()); + for (int i = 0; i < SIZE; ++i) + s.push(i); + assert(s.length() == SIZE); + assert(s.top() == (SIZE-1)); + assert(s.full()); + intVStack s1(SIZE); + for (int i = 0; i < SIZE; ++i) + { + int x = s.pop(); + assert(x == (SIZE-1) - i); + s1.push(x); + } + assert(s.empty()); + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s.OK()); + assert(s1.OK()); + intVStack s2 (s1); + assert(s2.length() == SIZE); + assert(s2.top() == 0); + assert(s2.OK()); + s1.clear(); + assert(s1.empty()); + s1 = s2; + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s1.OK()); + s1.del_top(); + assert(s1.length() == (SIZE-1)); + assert(s1.top() == 1); + cout << "s1:"; print(s1); + + assert(s.OK()); + assert(s1.OK()); + assert(s2.OK()); +} + +#include "iSLStack.h" + +void SLtest () +{ + intSLStack s; + assert(s.OK()); + for (int i = 0; i < SIZE; ++i) + s.push(i); + assert(s.length() == SIZE); + assert(s.top() == (SIZE-1)); + assert(!s.full()); + intSLStack s1; + for (int i = 0; i < SIZE; ++i) + { + int x = s.pop(); + assert(x == (SIZE-1) - i); + s1.push(x); + } + assert(s.empty()); + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s.OK()); + assert(s1.OK()); + intSLStack s2 (s1); + assert(s2.length() == SIZE); + assert(s2.top() == 0); + assert(s2.OK()); + s1.clear(); + assert(s1.empty()); + s1 = s2; + assert(s1.length() == SIZE); + assert(s1.top() == 0); + assert(s1.OK()); + s1.del_top(); + assert(s1.length() == (SIZE-1)); + assert(s1.top() == 1); + + cout << "s1:"; print(s1); + assert(s.OK()); + assert(s1.OK()); + assert(s2.OK()); +} + + +int main(int argv, char** argc) +{ + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + start_timer(); + cout << "XP stacks:\n"; XPtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "V stacks:\n"; Vtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + start_timer(); + cout << "SL stacks:\n"; SLtest(); + if (ptimes) cout << "\ntime = " << return_elapsed_time(0.0) << "\n"; + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tStack.exp b/gnu/lib/libg++/libg++/tests/tStack.exp new file mode 100644 index 00000000000..a7a937abe85 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tStack.exp @@ -0,0 +1,8 @@ +XP stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +V stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +SL stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tStack.inp b/gnu/lib/libg++/libg++/tests/tStack.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/tString.cc b/gnu/lib/libg++/libg++/tests/tString.cc new file mode 100644 index 00000000000..e3499bf39c7 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tString.cc @@ -0,0 +1,416 @@ +// This may look like C code, but it is really -*- C++ -*- + +/* + A test file for Strings +*/ + +#include +#include // see note below on `dec(20)' about why this will go away +#include +#include + +// can't nicely echo assertions because they contain quotes + +#define tassert(ex) {if (!(ex)) \ + { cerr << "failed assertion at " << __LINE__ << "\n"; \ + abort(); } } + + String X = "Hello"; + String Y = "world"; + String N = "123"; + String c; + char* s = ","; + Regex r = "e[a-z]*o"; + +void decltest() +{ + String x; + cout << "an empty String:" << x << "\n"; + assert(x.OK()); + assert(x == ""); + + String y = "Hello"; + cout << "A string initialized to Hello:" << y << "\n"; + assert(y.OK()); + 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.OK()); + assert(a == "Hello"); + assert(a == y); + + String b (a.at(1, 2)); + cout << "A string initialized to previous string.at(1, 2):" << b << "\n"; + assert(b.OK()); + assert(b == "el"); + + char ch = '@'; + String z(ch); + cout << "A string initialized to @:" << z << "\n"; + assert(z.OK()); + assert(z == "@"); + + // XXX: `dec' is obsolete. Since String.h includes iostream.h, and not + // stream.h, we include stream.h in this file for the time being. This + // test will be rewritten to be done the "right" way, but for now, let's + // save some time and go the easy route. + String n = dec(20); + cout << "A string initialized to dec(20):" << n << "\n"; + assert(n.OK()); + assert(n == "20"); + + int i = atoi(n); + double f = atof(n); + cout << "n = " << n << " atoi(n) = " << i << " atof(n) = " << f << "\n"; + assert(i == 20); + assert(f == 20); + + assert(X.OK()); + assert(Y.OK()); + assert(x.OK()); + assert(y.OK()); + assert(z.OK()); + assert(n.OK()); + assert(r.OK()); +} + +void cattest() +{ + String x = X; + String y = Y; + String z = x + y; + cout << "z = x + y = " << z << "\n"; + assert(x.OK()); + assert(y.OK()); + assert(z.OK()); + assert(z == "Helloworld"); + + x += y; + cout << "x += y; x = " << x << "\n"; + assert(x.OK()); + assert(y.OK()); + assert(x == "Helloworld"); + + y = Y; + x = X; + y.prepend(x); + cout << "y.prepend(x); y = " << y << "\n"; + assert(y == "Helloworld"); + + y = Y; + x = X; + cat(x, y, x, x); + cout << "cat(x, y, x, x); x = " << x << "\n"; + assert(x == "HelloworldHello"); + + y = Y; + x = X; + cat(y, x, x, x); + cout << "cat(y, x, x, x); x = " << x << "\n"; + assert(x == "worldHelloHello"); + + x = X; + y = Y; + z = x + s + ' ' + y.at("w") + y.after("w") + "."; + cout << "z = x + s + + y.at(w) + y.after(w) + . = " << z << "\n"; + assert(z.OK()); + 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.at(0, 4)); + assert (x < y); + assert(!(x >= z.at(0, 6))); + assert(x.contains("He")); + assert (z.contains(x)); + assert(x.contains(r)); + + assert(!(x.matches(r))); + assert(x.matches(RXalpha)); + assert(!(n.matches(RXalpha))); + assert(n.matches(RXint)); + assert(n.matches(RXdouble)); + + assert(x.index("lo") == 3); + assert(x.index("l", 2) == 2); + assert(x.index("l", -1) == 3); + assert(x.index(r) == 1); + assert(x.index(r, -2) == 1); + + assert(x.contains("el", 1)); + assert(x.contains("el")); + + assert(common_prefix(x, "Help") == "Hel"); + assert(common_suffix(x, "to") == "o"); + + assert(fcompare(x, "hELlo") == 0); + assert(fcompare(x, "hElp") < 0); +} + +void substrtest() +{ + String x = X; + + char ch = x[0]; + cout << "ch = x[0] = " << ch << "\n"; + assert(ch == 'H'); + + String z = x.at(2, 3); + cout << "z = x.at(2, 3) = " << z << "\n"; + assert(z.OK()); + assert(z == "llo"); + + x.at(2, 2) = "r"; + cout << "x.at(2, 2) = r; x = " << x << "\n"; + assert(x.OK()); + assert(x.at(2,2).OK()); + assert(x == "Hero"); + + x = X; + x.at(0, 1) = "j"; + cout << "x.at(0, 1) = j; x = " << x << "\n"; + assert(x.OK()); + assert(x == "jello"); + + x = X; + x.at("He") = "je"; + cout << "x.at(He) = je; x = " << x << "\n"; + assert(x.OK()); + assert(x == "jello"); + + x = X; + x.at("l", -1) = "i"; + cout << "x.at(l, -1) = i; x = " << x << "\n"; + assert(x.OK()); + assert(x == "Helio"); + + x = X; + z = x.at(r); + cout << "z = x.at(r) = " << z << "\n"; + assert(z.OK()); + assert(z == "ello"); + + z = x.before("o"); + cout << "z = x.before(o) = " << z << "\n"; + assert(z.OK()); + assert(z == "Hell"); + + x.before("ll") = "Bri"; + cout << "x.before(ll) = Bri; x = " << x << "\n"; + assert(x.OK()); + assert(x == "Brillo"); + + x = X; + z = x.before(2); + cout << "z = x.before(2) = " << z << "\n"; + assert(z.OK()); + assert(z == "He"); + + z = x.after("Hel"); + cout << "z = x.after(Hel) = " << z << "\n"; + assert(z.OK()); + assert(z == "lo"); + + x.after("Hel") = "p"; + cout << "x.after(Hel) = p; x = " << x << "\n"; + assert(x.OK()); + assert(x == "Help"); + + x = X; + z = x.after(3); + cout << "z = x.after(3) = " << z << "\n"; + assert(z.OK()); + assert(z == "o"); + + z = " a bc"; + z = z.after(RXwhite); + cout << "z = a bc; z = z.after(RXwhite); z =" << z << "\n"; + assert(z.OK()); + assert(z == "a bc"); +} + + +void utiltest() +{ + String x = X; + int matches = x.gsub("l", "ll"); + cout << "x.gsub(l, ll); x = " << x << "\n"; + assert(x.OK()); + assert(matches == 2); + assert(x == "Hellllo"); + + x = X; + assert(x.OK()); + matches = x.gsub(r, "ello should have been replaced by this string"); + assert(x.OK()); + cout << "x.gsub(r, ...); x = " << x << "\n"; + assert(x.OK()); + assert(matches == 1); + assert(x == "Hello should have been replaced by this string"); + + matches = x.gsub(RXwhite, "#"); + cout << "x.gsub(RXwhite, #); x = " << x << "\n"; + assert(matches == 7); + assert(x.OK()); + + String z = X + Y; + z.del("loworl"); + cout << "z = x+y; z.del(loworl); z = " << z << "\n"; + assert(z.OK()); + assert(z == "Held"); + + x = X; + z = reverse(x); + cout << "reverse(x) = " << z << "\n"; + assert(z.OK()); + assert(z == "olleH"); + + x.reverse(); + cout << "x.reverse() = " << x << "\n"; + assert(x.OK()); + assert(x == z); + + x = X; + z = upcase(x); + cout << "upcase(x) = " << z << "\n"; + assert(z.OK()); + assert(z == "HELLO"); + + z = downcase(x); + cout << "downcase(x) = " << z << "\n"; + assert(z.OK()); + assert(z == "hello"); + + z = capitalize(x); + cout << "capitalize(x) = " << z << "\n"; + assert(z.OK()); + assert(z == "Hello"); + + /* Let's see how apostrophe is handled. */ + z = "he asked:'this is nathan's book?'. 'no, it's not',i said."; + cout << "capitalize(z) = " << capitalize (z) << "\n"; + + z = replicate('*', 10); + cout << "z = replicate(*, 10) = " << z << "\n"; + assert(z.OK()); + assert(z == "**********"); + assert(z.length() == 10); +} + +void splittest() +{ + String z = "This string\thas\nfive words"; + cout << "z = " << z << "\n"; + String w[10]; + int nw = split(z, w, 10, RXwhite); + assert(nw == 5); + cout << "from split(z, RXwhite, w, 10), n words = " << nw << ":\n"; + for (int i = 0; i < nw; ++i) + { + assert(w[i].OK()); + cout << w[i] << "\n"; + } + assert(w[0] == "This"); + assert(w[1] == "string"); + assert(w[2] == "has"); + assert(w[3] == "five"); + assert(w[4] == "words"); + assert(w[5] == (char*)0); + + z = join(w, nw, "/"); + cout << "z = join(w, nw, /); z =" << z << "\n"; + assert(z.OK()); + assert(z == "This/string/has/five/words"); +} + + +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.prepend(a); + assert((a + b) == x); + assert((a + b) == y); + assert(x == y); + assert(x.after(a) == b); + assert(x.before(b, -1) == a); + assert(x.from(a) == x); + assert(x.through(b, -1) == x); + assert(x.at(a) == a); + assert(x.at(b) == b); + + assert(reverse(x) == reverse(b) + reverse(a)); + + assert((a + b + a) == (a + (b + a))); + + x.del(b, -1); + assert(x == a); + + y.before(b, -1) = b; + assert(y == (b + b)); + y.at(b) = a; + assert(y == (a + b)); + + x = a + reverse(a); + for (int i = 0; i < 7; ++i) + { + y = x; + x += x; + assert(x.OK()); + assert(x == reverse(x)); + assert(x.index(y) == 0); + assert(x.index(y, -1) == x.length() / 2); + } +} + +void freqtest() +{ + String x = "Hello World"; + SubString y = x.at(0,5); + assert(x.freq('l') == 3); // char + assert(x.freq("lo") == 1); // char* + assert(x.freq(x) == 1); // String + assert(x.freq(y) == 1); // SubString +} + +int main() +{ + decltest(); + cattest(); + comparetest(); + substrtest(); + utiltest(); + splittest(); + freqtest(); + 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/gnu/lib/libg++/libg++/tests/tString.exp b/gnu/lib/libg++/libg++/tests/tString.exp new file mode 100644 index 00000000000..4f06ffacb66 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tString.exp @@ -0,0 +1,50 @@ +an empty String: +A string initialized to Hello:Hello +A string initialized to previous string:Hello +A string initialized to previous string.at(1, 2):el +A string initialized to @:@ +A string initialized to dec(20):20 +n = 20 atoi(n) = 20 atof(n) = 20 +z = x + y = Helloworld +x += y; x = Helloworld +y.prepend(x); y = Helloworld +cat(x, y, x, x); x = HelloworldHello +cat(y, x, x, x); x = worldHelloHello +z = x + s + + y.at(w) + y.after(w) + . = Hello, world. +ch = x[0] = H +z = x.at(2, 3) = llo +x.at(2, 2) = r; x = Hero +x.at(0, 1) = j; x = jello +x.at(He) = je; x = jello +x.at(l, -1) = i; x = Helio +z = x.at(r) = ello +z = x.before(o) = Hell +x.before(ll) = Bri; x = Brillo +z = x.before(2) = He +z = x.after(Hel) = lo +x.after(Hel) = p; x = Help +z = x.after(3) = o +z = a bc; z = z.after(RXwhite); z =a bc +x.gsub(l, ll); x = Hellllo +x.gsub(r, ...); x = Hello should have been replaced by this string +x.gsub(RXwhite, #); x = Hello#should#have#been#replaced#by#this#string +z = x+y; z.del(loworl); z = Held +reverse(x) = olleH +x.reverse() = olleH +upcase(x) = HELLO +downcase(x) = hello +capitalize(x) = Hello +capitalize(z) = He Asked:'This Is Nathan's Book?'. 'No, It's Not',I Said. +z = replicate(*, 10) = ********** +z = This string has +five words +from split(z, RXwhite, w, 10), n words = 5: +This +string +has +five +words +z = join(w, nw, /); z =This/string/has/five/words +enter a word:word =abcdefghijklmnopqrstuvwxyz length = 26 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tString.inp b/gnu/lib/libg++/libg++/tests/tString.inp new file mode 100644 index 00000000000..b0883f382e1 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tString.inp @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/gnu/lib/libg++/libg++/tests/tVec.cc b/gnu/lib/libg++/libg++/tests/tVec.cc new file mode 100644 index 00000000000..54b27564a91 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tVec.cc @@ -0,0 +1,96 @@ +/* + test/demo of Vecs, AVecs +*/ + +#include +#include "iVec.h" +#include "iAVec.h" + +int int_compare(int a, int b) +{ + return a - b; +} + +int plus(int a, int b) +{ + return a + b; +} + +int inc(int a) +{ + return a + 1; +} + +void printint(int a) +{ + cout << a << " "; +} + +void print(intVec a) +{ + a.apply(printint); + cout << "\n"; +} + +#include + +MLCG randgen; + +int main() +{ + intVec a(20); + int i; + for (i = 0; i < a.capacity(); ++i) a[i] = randgen.asLong() % 100; + cout << "a: "; print(a); + a.sort(int_compare); + cout << "a.sort():"; print(a); + intVec b = map(inc, a); + cout << "b = map(inc, a): "; print(b); + intVec c = merge(a, b, int_compare); + cout << "c = merge(a, b): "; print(c); + intVec d = concat(a, b); + cout << "d = concat(a, b): "; print(d); + d.resize(10); + cout << "d.resize(10): "; print(d); + d.reverse(); + cout << "d.reverse(): "; print(d); + d.fill(0, 4, 4); + cout << "d.fill(0, 4, 4): "; print(d); + cout << "d.reduce(plus, 0) = " << d.reduce(plus, 0) << "\n"; + intVec e = d.at(2, 5); + cout << "e = d.at(2, 5): "; print(e); + + intAVec x(20); + for (i = 0; i < x.capacity(); ++i) x[i] = i; + cout << "x: "; print(x); + intAVec y(20); + for (i = 0; i < y.capacity(); ++i) y[i] = randgen.asLong() % 100 + 1; + cout << "y: "; print(y); + + cout << "x + y: "; print(x + y); + cout << "x - y: "; print(x - y); + cout << "product(x, y): "; print(product(x,y)); + cout << "quotient(x, y): "; print(quotient(x,y)); + cout << "x * y: " << (x * y) << "\n"; + + cout << "x + 2: "; print(x + 2); + cout << "x - 2: "; print(x - 2); + cout << "x * 2: "; print(x * 2); + cout << "x / 2: "; print(x / 2); + + intAVec z(20, 1); + cout << "z(20, 1): "; print(z); + cout << "z = -z: "; print(z = -z); + cout << "z += x: "; print(z += x); + cout << "z -= x: "; print(z -= x); + + cout << "x.sum(): " << x.sum() << "\n"; + cout << "x.sumsq(): " << x.sumsq() << "\n"; + cout << "x.min(): " << x.min() << "\n"; + cout << "x.max(): " << x.max() << "\n"; + cout << "x.min_index(): " << x.min_index() << "\n"; + cout << "x.max_index(): " << x.max_index() << "\n"; + + cout << "\nEnd of test\n"; + return 0; +} diff --git a/gnu/lib/libg++/libg++/tests/tVec.exp b/gnu/lib/libg++/libg++/tests/tVec.exp new file mode 100644 index 00000000000..9a65566e953 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tVec.exp @@ -0,0 +1,33 @@ +a: 72 14 71 72 81 29 86 49 59 84 69 10 94 41 69 95 57 78 62 82 +a.sort():10 14 29 41 49 57 59 62 69 69 71 72 72 78 81 82 84 86 94 95 +b = map(inc, a): 11 15 30 42 50 58 60 63 70 70 72 73 73 79 82 83 85 87 95 96 +c = merge(a, b): 10 11 14 15 29 30 41 42 49 50 57 58 59 60 62 63 69 69 70 70 71 72 72 72 73 73 78 79 81 82 82 83 84 85 86 87 94 95 95 96 +d = concat(a, b): 10 14 29 41 49 57 59 62 69 69 71 72 72 78 81 82 84 86 94 95 11 15 30 42 50 58 60 63 70 70 72 73 73 79 82 83 85 87 95 96 +d.resize(10): 10 14 29 41 49 57 59 62 69 69 +d.reverse(): 69 69 62 59 57 49 41 29 14 10 +d.fill(0, 4, 4): 69 69 62 59 0 0 0 0 14 10 +d.reduce(plus, 0) = 283 +e = d.at(2, 5): 62 59 0 0 0 +x: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +y: 93 96 14 74 87 41 65 6 38 17 63 37 73 46 34 50 38 55 15 76 +x + y: 93 97 16 77 91 46 71 13 46 26 73 48 85 59 48 65 54 72 33 95 +x - y: -93 -95 -12 -71 -83 -36 -59 1 -30 -8 -53 -26 -61 -33 -20 -35 -22 -38 3 -57 +product(x, y): 0 96 28 222 348 205 390 42 304 153 630 407 876 598 476 750 608 935 270 1444 +quotient(x, y): 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 +x * y: 8782 +x + 2: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 +x - 2: -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 +x * 2: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 +x / 2: 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 +z(20, 1): 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +z = -z: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +z += x: -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 +z -= x: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +x.sum(): 190 +x.sumsq(): 2470 +x.min(): 0 +x.max(): 19 +x.min_index(): 0 +x.max_index(): 19 + +End of test diff --git a/gnu/lib/libg++/libg++/tests/tVec.inp b/gnu/lib/libg++/libg++/tests/tVec.inp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gnu/lib/libg++/libg++/tests/test_h.cc b/gnu/lib/libg++/libg++/tests/test_h.cc new file mode 100644 index 00000000000..291a00da980 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/test_h.cc @@ -0,0 +1,102 @@ +// Use all the g++ headerfiles + +// $Author: niklas $ +// $Revision: 1.1.1.1 $ +// $Date: 1996/03/15 22:19:18 $ + +#include <_G_config.h> +// If we have the old iostream library, it defines _OLD_STREAMS +#include + +#include + +#include +#include +#include +#if _G_HAVE_SYS_WAIT +#include +#endif +#include +#include +#include + +#ifdef _OLD_STREAMS +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _IO_MAGIC +#include +#include +#include +#endif + +main() +{ + cout << "Could include all g++-include files\n"; + exit (0); +} diff --git a/gnu/lib/libg++/libg++/tests/tiLList.cc b/gnu/lib/libg++/libg++/tests/tiLList.cc new file mode 100644 index 00000000000..d9f43ca7e81 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tiLList.cc @@ -0,0 +1,271 @@ +#include <_G_config.h> + +#ifdef _G_NO_TEMPLATESS + +main() +{ + fprintf(stderr, "(template-based classes not available)\n"); + return 0; +} +#else + +/* + test/demo of linked structures +*/ + + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + +#include +#include "SLList.h" +#include "DLList.h" + +void printlist(SLList& l) +{ + for (Pix p = l.first(); p != 0; l.next(p)) cout << l(p) << " "; + cout << "\n"; +} + + +void SLtest() +{ + int i; + SLList a; + assert(a.OK()); + assert(a.empty()); + cout << "prepending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == i); + a.prepend(i); + assert(a.front() == i); + } + cout << "a: "; printlist(a); + cout << "appending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == 10 + i); + a.append(i); + assert(a.rear() == i); + } + cout << "a: "; printlist(a); + SLList b = a; + cout << "b = a: " << "\n"; printlist(b); + assert(b.OK()); + assert(b.length() == a.length()); + assert(b.front() == a.front()); + assert(b.rear() == a.rear()); + cout << "remove_front of first 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(b.length() == 20 - i); + assert(b.front() == 9 - i); + b.remove_front(); + } + assert(b.length() == 10); + cout << "b: "; printlist(b); + + cout << "inserting 100 after sixth element...\n"; + Pix bp = b.first(); + for (i = 0; i < 5; ++i) b.next(bp); + b.ins_after(bp, 100); + assert(b.length() == 11); + cout << "b: "; printlist(b); + a.join(b); + cout << "after a.join(b)\n"; printlist(a); + assert(b.empty()); + assert(a.length() == 31); + cout << "b: " << "\n"; printlist(b); + b.prepend(999); + cout << "b: " << "\n"; printlist(b); + assert(b.length() == 1); + assert(b.front() == 999); + assert(b.rear() == 999); + assert(b.OK()); + SLList bb = b; + cout << "bb: " << "\n"; printlist(bb); + assert(bb.OK()); + assert(bb.length() == 1); + assert(bb.front() == 999); + assert(bb.rear() == 999); + assert(bb.remove_front() == 999); + b.prepend(1234); + assert(b.length() == 2); + b.del_after(b.first()); + assert(b.rear() == 1234); + assert(b.length() == 1); + b.del_after(0); + assert(b.length() == 0); + + assert(a.OK()); + assert(b.OK()); + assert(bb.OK()); +} + +void printDlist(DLList& l) +{ + for (Pix p = l.first(); p != 0; l.next(p)) cout << l(p) << " "; + cout << "\n"; +} + +void DLtest() +{ + int i; + DLList a; + assert(a.OK()); + assert(a.empty()); + assert(a.length() == 0); + cout << "prepending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == i); + a.prepend(i); + assert(a.front() == i); + } + cout << "a: " << "\n"; printDlist(a); + cout << "appending...\n"; + for (i = 0; i < 10; ++i) + { + assert(a.length() == 10 + i); + a.append(i); + assert(a.rear() == i); + } + cout << "a: "; printDlist(a); + DLList b = a; + assert(b.OK()); + assert(b.length() == a.length()); + assert(b.front() == a.front()); + assert(b.rear() == a.rear()); + cout << "b = a: "; printDlist(b); + cout << "remove_front of first 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(b.length() == 20 - i); + assert(b.front() == 9 - i); + b.remove_front(); + } + assert(b.length() == 10); + cout << "b: "; printDlist(b); + + cout << "inserting 100 after sixth element...\n"; + Pix bp = b.first(); + for (i = 0; i < 5; ++i) b.next(bp); + b.ins_after(bp, 100); + assert(b.length() == 11); + cout << "b: "; printDlist(b); + DLList aa = a; + aa.join(b); + cout << "after aa = a; aa.join(b)\n"; printDlist(aa); + assert(aa.length() == 31); + assert(b.empty()); + cout << "b: " << "\n"; printDlist(b); + b.prepend(999); + cout << "b: " << "\n"; printDlist(b); + assert(b.length() == 1); + assert(b.front() == 999); + assert(b.rear() == 999); + assert(b.OK()); + DLList bb = b; + cout << "bb: " << "\n"; printDlist(bb); + assert(bb.OK()); + assert(bb.length() == 1); + assert(bb.front() == 999); + assert(bb.rear() == 999); + assert(bb.remove_front() == 999); + assert(bb.OK()); + b.prepend(1234); + assert(b.length() == 2); + bp = b.first(); + b.next(bp); + b.del(bp, -1); + assert(b.rear() == 1234); + assert(b.length() == 1); + b.del(bp); + assert(b.length() == 0); + + DLList z = a; + cout << "z = a: "; printDlist(z); + assert(z.OK()); + assert(z.length() == 20); + cout << "remove_rear of last 10 elements:\n"; + for (i = 0; i < 10; ++i) + { + assert(z.length() == 20 - i); + assert(z.rear() == 9 - i); + z.remove_rear(); + } + assert(z.length() == 10); + + cout << "z: "; printDlist(z); + + cout << "inserting 100 before alternate elements...\n"; + Pix zp; + for (zp = z.first(); zp; z.next(zp)) + { + z.ins_before(zp, 100); + } + assert(z.length() == 20); + cout << "z: "; printDlist(z); + + cout << "inserting 200 after sixth element...\n"; + zp = z.first(); + for (i = 0; i < 5; ++i) z.next(zp); + z.ins_after(zp, 200); + assert(z.length() == 21); + cout << "z: "; printDlist(z); + + cout << "deleting alternate elements of z..."; + for (zp = z.first(); zp; z.next(zp)) + { + cout << z(zp) << " "; + z.del(zp); + } + cout << "\n"; + assert(z.length() == 10); + cout << "z: "; printDlist(z); + + cout << "z in reverse order:\n"; + for (zp = z.last(); zp; z.prev(zp)) cout << z(zp) << " "; + cout << "\n"; + z.clear(); + assert(z.OK()); + assert(z.empty()); + assert(a.OK()); + assert(b.OK()); +} + +class X +{ +public: + X() { cout << "default ctor called\n"; } + X(const X&) { cout << "copy ctor called\n"; } + ~X() { cout << "dtor called\n"; } +}; + +main() +{ + SLtest(); + DLtest(); + + cout << "\n"; + /* Test case from Magnus Nordborg */ + DLList l; + l.append(X()); + Pix f = l.first(); + l.del(f); + + cout << "\nEnd of test\n"; + return 0; +} + +template class SLNode; +template class SLList; +template class DLNode; +template class DLList; + +template class DLNode; +template class DLList; +#endif diff --git a/gnu/lib/libg++/libg++/tests/tiLList.exp b/gnu/lib/libg++/libg++/tests/tiLList.exp new file mode 100644 index 00000000000..2e7646e5c04 --- /dev/null +++ b/gnu/lib/libg++/libg++/tests/tiLList.exp @@ -0,0 +1,54 @@ +prepending... +a: 9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after a.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +prepending... +a: +9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after aa = a; aa.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +z = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_rear of last 10 elements: +z: 9 8 7 6 5 4 3 2 1 0 +inserting 100 before alternate elements... +z: 100 9 100 8 100 7 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +inserting 200 after sixth element... +z: 100 9 100 8 100 7 200 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +deleting alternate elements of z...100 100 100 200 6 5 4 3 2 1 0 +z: 9 8 7 100 100 100 100 100 100 100 +z in reverse order: +100 100 100 100 100 100 100 7 8 9 + +default ctor called +copy ctor called +dtor called +dtor called + +End of test diff --git a/gnu/lib/libg++/libg++/utils/.cvsignore b/gnu/lib/libg++/libg++/utils/.cvsignore new file mode 100644 index 00000000000..bb9493e4c69 --- /dev/null +++ b/gnu/lib/libg++/libg++/utils/.cvsignore @@ -0,0 +1,4 @@ +Makefile +g++dep +etags +config.status diff --git a/gnu/lib/libg++/libg++/utils/Makefile.in b/gnu/lib/libg++/libg++/utils/Makefile.in new file mode 100644 index 00000000000..62f7fb380f7 --- /dev/null +++ b/gnu/lib/libg++/libg++/utils/Makefile.in @@ -0,0 +1,31 @@ +# Makefile for libg++.a + +# Copyright (C) 1988, 1992, 1993 Free Software Foundation +# written by Doug Lea (dl@rocky.oswego.edu) + +# This file is part of GNU CC. + +# GNU CC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY. No author or distributor +# accepts responsibility to anyone for the consequences of using it +# or for whether it serves any particular purpose or works at all, +# unless he says so in writing. Refer to the GNU CC General Public +# License for full details. + +# Everyone is granted permission to copy, modify and redistribute +# GNU CC, but only under the conditions described in the +# GNU CC General Public License. A copy of this license is +# supposed to have been given to you along with GNU CC so you +# can know your rights and responsibilities. It should be in a +# file named COPYING. Among other things, the copyright notice +# and this notice must be preserved on all copies. + +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + + +g++dep: g++dep.sh + cp $(srcdir)/g++dep.sh $@ + chmod +x $@ diff --git a/gnu/lib/libg++/libg++/utils/configure.in b/gnu/lib/libg++/libg++/utils/configure.in new file mode 100644 index 00000000000..093f463ddc3 --- /dev/null +++ b/gnu/lib/libg++/libg++/utils/configure.in @@ -0,0 +1,25 @@ +# 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. + +configdirs="" +srctrigger=g++dep.sh +srcname="misc libg++ utils" + +target_makefile_frag=../target-mkfrag +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TOLIBGXX=../ +CLEAN='g++dep' +ALL='g++dep' + +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +rm -f ${package_makefile_frag} diff --git a/gnu/lib/libg++/libg++/utils/g++dep.sh b/gnu/lib/libg++/libg++/utils/g++dep.sh new file mode 100644 index 00000000000..1eea85a2c32 --- /dev/null +++ b/gnu/lib/libg++/libg++/utils/g++dep.sh @@ -0,0 +1,73 @@ +#! /bin/sh + +# This utility is a lightly editted version of the freed Berkeley +# script `mkdep'. The current script is intended to work for GNU G++. + +# Here is the original BSD header: +# @(#)mkdep.sh 1.7 (Berkeley) 10/13/87 +# + +# PATH=/bin:/usr/bin:/usr/ucb:/usr/gnu:/usr/gnu/bin +# export PATH + +if [ $# = 0 ] ; then + echo 'usage: g++dep [-p] [-f makefile] [flags] file ...' + exit 1 +fi + +MAKE=Makefile # default makefile name is "Makefile" +case $1 in + # -f allows you to select a makefile name + -f) + MAKE=$2 + shift; shift ;; + + # the -p flag produces "program: program.c" style dependencies + # so .o's don't get produced + -p) + SED='-e s;\.o;;' + shift ;; +esac + +if [ ! -w $MAKE ]; then + echo "g++dep: no writeable file \"$MAKE\"" + exit 1 +fi + +TMP=/tmp/g++dep$$ + +trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 + +cp $MAKE ${MAKE}.bak + +sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP + +cat << _EOF_ >> $TMP +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +_EOF_ + +# put every dependency on one line +# +g++ -M $* | \ +sed -e 's; \./; ;g' $SED | \ +awk ' BEGIN { start = 1 } + /.* : .*.*/ { printf ("%s : %s \\\n", $1, $3) ; start = 4 } + { for ( i = start; i < NF ; i++ ) + if ( $i != "\\" ) print " ", $i, "\\" + if ( $i != "\\" ) print " ", $NF + start = 1 + } +' >> $TMP + +cat << _EOF_ >> $TMP + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +_EOF_ + +# copy to preserve permissions +cp $TMP $MAKE +rm -f ${MAKE}.bak $TMP +exit 0 + diff --git a/gnu/lib/libg++/libg++/utils/gendepend b/gnu/lib/libg++/libg++/utils/gendepend new file mode 100644 index 00000000000..072f0487cc9 --- /dev/null +++ b/gnu/lib/libg++/libg++/utils/gendepend @@ -0,0 +1,57 @@ +#!/bin/sh + +# to use this script, cd to the utils source directory and sh +# gendepend. + +gdep=`pwd`/g++dep.sh + +cd .. +popdir=`pwd` + +gxx_include=${popdir}/g\+\+-include +io_dir=${popdir}/iostream +src_dir=${popdir}/src +gxx_flags="-I. -I${gxx_include} -I${io_dir}" + + +for i in `find . -name depend -print` ; do + down=`dirname $i` + up=`echo $down | sed -e "s:/[-a-zA-Z0-9]*:/..:g" -e "s:^\./::"` + + cd ${popdir}/${down} + + echo "" > depend.tmp + ${gdep} -f depend.tmp ${gxx_flags} *.[cC]* +# --- Generate depend rules --- + +# The sed script below attempts to make the depend output portable by +# making the output use the same macros used elsewhere in the Makefile: +# - It replaces double // by a single /. +# - It replaces include files that match part of the GXX_INCLUDE_DIRS +# by names defined in terms of the macros used to define GXX_INCLUDE_DIRS. +# However, files in g++-include are ignored. +# - It removes any absolute include file names that remain. +# - then remove lines, which contain only `\' +# + +# -e 's|$(srcdir)|$$(srcdir)|g' +# -e 's|: *\$$(srcdir)/\(.*\.[cC]*\)|: \1|' + + sed < depend.tmp \ + -e 's|//|/|g' \ + -e "s|${io_dir}|\$(srcdir)/${up}/\$(IO_DIR)|g" \ + -e "s| ${gxx_include}/[^ ]*[.]h||g" \ + -e "s|${src_dir}|\$(srcdir)/${up}/src_dir|g" \ + -e 's| /[^ ]*[.]h||g' \ + -e '/^[ ]*\\$/d' -e 's/^[ ]*$//' \ + | awk 'BEGIN { prev = "" } \ + /^( )*$/ { if (prev ~ /\\$/) \ + { prev = substr(prev,1,length(prev)-1); next } \ + } \ + { print prev; prev = $0 } \ + END { if (prev !~ /^( )*$/) print prev }' \ + > depend + rm -f depend.tmp +done + +exit 0 diff --git a/gnu/lib/libg++/libg++/vms/AAAREADME.TXT b/gnu/lib/libg++/libg++/vms/AAAREADME.TXT new file mode 100644 index 00000000000..d924d548e1e --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/AAAREADME.TXT @@ -0,0 +1,260 @@ + This directory contains the VMS specific files for libg++. To +install, you will need to have both gcc and gxx (C++) already running, and +you must have write access to the directories that GNU_GXX_INCLUDE:[000000], +GNU_CC:[000000] and GNU_CC_INCLUDE:[000000] point to. If you have not figured +it out already, you must run the command file "make-l2.com" in the gcc 2.0 +distribution (which creates the library gcclib2.olb), and then you should +extract all of the object modules from this library and add them to +GNU_CC:[000000]GCCLIB.OLB. If you have write access to sys$library, then the +compiled libgxx_shr.exe will be copied there, and if you have CMKRNL +privilege, the installation procedure will run INSTALL to make it a known +image. If you do not have the correct privileges or write access to +sys$library, the compiled libgxx_shr.exe will be left in the directory where +it was built, and the installation procedure will continue. + The installation procedure will automatically copy all of the header +files from the directory where you unpacked the library to the appropriate +header directory (GNU_GXX_INCLUDE). To start the installation, simply +type: + + @VMS-INSTALL-LIBGXX + +and go get a cup of coffee. (This can be submitted to a batch queue if you +wish). + + For one reason or another, the installation procedure may bomb on +your system when it is running. For this reason, I will describe the +various steps that it takes in order to help you figure out what went wrong. + + 1) A Unix filesystem is case sensitive with respect to filenames + while VMS is not case-sensitive. Thus String.h and string.h appear + to be two different files under Unix, and would appear the same to + VMS. Unfortunately, there are a couple of cases where two files + differ only in the case of their names, and when you unpack libg++ + on a VMS system, you are left with two seperate versions of what + would appear to be the same file. + + The installation procedure knows about these cases and attempts to + rename the offending files by renaming String.h to sstring.h for + example. Next the installation procedure edits any files in the + distribution that contain references to these header files, and + changes the include directives to refer to the new names. + + This procedure may fail if a new file is added to the distribution + that has a name that needs to be changed, or if a current or new + file includes one of the existing files that was renamed. In this + case, you can simply hack the file VMS-INSTALL-LIBGXX.COM to handle + these new cases. + + * Next the install procedure moves all of the header files to + GNU_GXX_INCLUDE. This step is fairly robust, and the only problem + that could occur is if you run out of disk space/quota. If there + are already existing files present in the directory, the install + procedure copies the new set over the old ones, and you must purge + the old ones by hand. + + + * Finally, the install procedure will compile the source modules and + build the library. In addition, it will automatically move the + support files into the required directories. Building the library + should take several hours. After all of the compilation is complete + it will build a sharable image library, will be moved to sys$library, + if the account you are running this from has write access to + sys$library. It will also move the other files that are required by + libg++ into the GNU_CC:[000000] directory. + +After this, you should define the following commands in SYLOGIN.COM: + +$gxx:==gcc/plus +$genclass:==@gnu_cc:[000000]genclass +$cxlink:==@gnu_cc:[000000]cxlink !only if using non-shared libraries. +$cxlink:==@gnu_cc:[000000]cxshare !only if using shared libraries + +Finally, make sure that GCC_INSTALL.COM is in the system startup file, +if you have already installed C++, then you have probably already done this. + + Once you have built the library itself, you may wish to run the test +suite that is included with libgxx. To do this you simply need to execute +the command procedure VMS-TEST-LIBGXX.COM, which will compile and link all of the +source modules that are required to run the test. Once again, you should +expect this to take several hours. It will create a file RUN.COM, which can be +submitted to a batch queue, and you can compare the output to the file +EXPECTED.VMS + + There is one bit of oddness which is that programs running under +batch have spurious line breaks in the output if you use +cout << (anything). This is due to the +fact that the implementation of write in the VAX-C run time library inserts a +line break whenever a 512 byte buffer fills up. If you are running +interactively then the output will appear normally. If you use the $assign +command to redirect sys$output to a file, or if you use sethost/log to +try to capture the output, you will get the spurious line breaks. +At some point in the future, I may add some kind of primative I/O +routines that will only be used internally by libg++, which should work a +lot better than the brain-dead version in the VAX-C run time library. + +The files included in this directory are: + +AAAREADME.TXT This file. +CXLINK.COM Command file to link to the non-shared library. +CXSHARE.COM Command file to link to the shared version of the library. +EXPECTED.LIST List of the executables to be run to generate EXPECTED.VMS + Used by VMS-TEST-LIBGXX.COM to generate RUN.COM +EXPECTED.VMS Expected output from the test suite. Execute command file + VMS-TEST-LIBGXX, and then the file RUN.COM that is generated, and + compare the output to this file. +FNDVEC.C Source file to a program that will automatically generate + LIBGXX_VECTOR.C, the list of all of the transfer vectors. +GENCLASS.COM Command file to generate container classes. +GENCLASS.TPU TPU code called by GENCLASS.COM +GXX_MAIN_SHR.MAR + This does not contain any routines, but it does contain a + couple of psect definitions that are used by __MAIN to locate + any global objects in the sharable libg++, and initialize them. +OPTIONS.OPT Options file used when linking to the non-shared library. +VMS-BUILD-LIBGXX.COM + Command file that actually does the dirty work of building the + library. +VMS-CURSES.C A couple of routines that are needed by the curses module + in libg++. +VMS-GCCLIB.MAR Source to the modified version of module GCCLIB in library + GCCLIB.OLB +VMS-INSTALL-LIBGXX.COM + This command file builds the actual library, and moves any + assorted files required by libg++ to the correct directory. + This is not idiot proof, so beware. It will delete the obj's + after it is finished, and leave behind the lib. +VMS-TEST-LIBGXX.COM Command file to build the test suite and create RUN.COM +VMS_FIXINCLUDES.TPU + This file is used to fix include directives that refer to files + such as String.h (when there is also a string.h). + +************************************************ +A few comments are in order. + + 1) I strongly recommend that you use the sharable library if at all +possible. (See note 4 below) This is really quite painless. This is created by +default when you execute @LIBGXX_INSTALL. If you want to get the optimum +performance, and you expect a lot of people to use libg++, you have the option +of installing LIBGXX_SHR.EXE. Obviously, there are no special privileges +required for the image. + + 2) If you get warning messages from the assembler about g++ making +references to __vt.* as a routine, ignore them. There is a bug in the g++ +compiler, but the assembler catches them and fixes it before anything bad +happens. + + Also, the assembler, gas, has been patched to automatically do a +globaldef/globalref for all vtables. These are special variables that are +used internally by g++, and the names always begin with "_vt.". By doing +this, the object code generated from c++ programs will tend to work better +(although not perfectly) with the VMS librarian and the VMS linker. +See note 4 for more information. + + 3) You should have the proper versions of both the compiler and +assembler in order to use this version of libg++. In addition, there may be +times when there are patches to the compiler and/or the assembler which have +not made it into the distribution version. In the past, executables have been +made available via anonymous FTP from mango.miami.edu, which have the proper +patches. + + 4) Using the non-sharable version of the library is fairly risky. +The problem is that the VMS linker will only pull an object module out of +the library if it needs a procedure from that module. If the module +contains an initialized variable, or uses a global constructor to +initialize a variable, the module might not get pulled in, and you could +get very puzzling results indeed. I do want to point out that the g++ +compiler does not use inline functions when compiling with /nooptimize, +and instead generates function calls. Thus you may find that if you +compile with /nooptimize the program works (because the linker does need +a routine from a module that defines some data), and it fails when compiled +with /optimize (because the compiler has inlined the functions). + + As it stands with the 2.0 release, there are two modules in the +iostream portion of libg++ which do not have any entry points at all. +Unfortunately, these two modules contain the initialized structures for the +variables cout, cin, and cerr. If you really insist upon using the non- +sharable library, you will have to pull these out of the library, and +always include them explicitly to the linker. The modules that you +need are STDSTRBUFS and STDSTREAMS. + + The sharable library does not have any of these sorts of problems +because all modules are automatically linked into the image. + + 5) If you create your own libraries, you need to be *very* aware of +the problems outlined in note 4 above. The suggested remedy is to make +use of the GLOBALREF and GLOBALDEF macros defined in gnu_hacks.h. All you +need to do is place a GLOBALDEF in any source module that contains +initialized data or a global object that will be constructed, and place +a GLOBALREF in the header file that you use to declare those objects/ +variables as being external. When you do this, the object modules will +have special symbol references and definitions which the linker will use +to pull the appropriate modules out of the library. + + It would be fairly easy to hack the file VMS-BUILD-LIBGXX.COM to +build a sharable image library for your own applications. If you do this, +and you wish to use your library with libg++, it might be easiest to +modify VMS-BUILD-LIBGXX.COM merge your library with libg++ before fndvec +is compiled and run. The build procedure will automatically pick up any +all of your entry points and do the right thing. If you want to build +a sharable library from your own library, you can hack VMS_BUILD_LIBGXX.COM +to do the job with a very minimal amount of work. + + 6) As far as I can tell the curses module works, however I am no expert +on curses. If someone finds something that does not seem to work quite right +let me know. Keep in mind that you are interfacing to VAXCCURSES, and you are +stuck with all of the idiosyncrasies that it has. Currently the tCurses +program does not run perfectly, since the prompts do not appear on the screen. + + 7) In chapter 6 of the libg++ manual there is a description of what +are called the "container class prototypes". These are classes that can be +made for any type of data object. The way that this is done now, is to +use a simple text substitution to fill in data types where required. The +prototype files are in the GNU_GXX_INCLUDE:[GEN] directory, and they +have extensions .HP and .CCP. The GENCLASS command can be used to generate +the classes, where GENCLASS is defined as: + +$genclass:==@gnu_cc:[000000]genclass + +The command syntax is identical to that given in the libg++ manual (except that +the data type should be quoted). If there is one data type, then the syntax is: + +$genclass "var" mode class + +where var is the data type (quoted to preserve case). mode is either REF or +VAL, and class is the name of the container class. For a class with two data +types, the syntax is + +$genclass -2 "var1" mode1 "var2" mode2 class + +GENCLASS puts the output files in the current default directory. + + You should be aware that the g++ compiler does not use inline +functions when the /NOOPTIMIZE switch is used. The principal advatage of +this is that the compiler runs much faster, making it easier to debug +and develop your programs. + + + Any programs that were linked to the old sharable libg++ will not work +with the new libg++, since so many things have changed. You should +recompile and relink any such programs. Also, any programs linked to the +libg++ 2.0 sharable library will need to be relinked. + + The installation procedure is more robust, and more automatic, +which should in principle mean that there will be less maintainance required +for the VMS port. The general idea is that for the time being, you +will always have to relink any program linked to the sharable image library +each time you upgrade libg++. The reason for this is that it is a lot of +work trying to keep track of which entry points were used for what and so +forth (also that the library has been rapidly changing as bugs are fixed +and new methods added). The fndvec.c program can keep track of some of +this, but if modules or objects change names, then this can get thrown off. + + You *may* wish to keep the old sharable libgxx libraries, +especially if you have programs linked to the old library. + + 6/2/92 + Eric Youngdale + youngdale@v6550c.nrl.navy.mil + + +*************************************************************************** diff --git a/gnu/lib/libg++/libg++/vms/CXLINK.COM b/gnu/lib/libg++/libg++/vms/CXLINK.COM new file mode 100644 index 00000000000..e08dad0ff34 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/CXLINK.COM @@ -0,0 +1,6 @@ +$ v = 'f$verify(0) +$! THIS COMMAND FILE IS USED TO LINK C++ PROGRAMS TO THE libg++ library and +$! the C RUN TIME LIBRARY. The shared version of the library is used for +$! the C run time library ONLY. +$ link 'P1'+gnu_cc:[000000]OPTIONS.OPT/OPT +$if v then set verify diff --git a/gnu/lib/libg++/libg++/vms/CXSHARE.COM b/gnu/lib/libg++/libg++/vms/CXSHARE.COM new file mode 100644 index 00000000000..153f0092c6c --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/CXSHARE.COM @@ -0,0 +1,7 @@ +$ v = 'f$verify(0) +$! THIS COMMAND FILE IS USED TO LINK C++ PROGRAMS TO THE libg++ library and +$! the C RUN TIME LIBRARY. The shared version of the library is used for +$! both libraries. This is the most efficient use of disk space. +$ link 'P1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' - + +GNU_CC:[000000]OPTIONS_SHR.OPT/OPT +$if v then set verify diff --git a/gnu/lib/libg++/libg++/vms/EXPECTED.LIST b/gnu/lib/libg++/libg++/vms/EXPECTED.LIST new file mode 100644 index 00000000000..f1bec0f8474 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/EXPECTED.LIST @@ -0,0 +1,25 @@ +test_h +tFile +tObstack +tString +tInteger +tRational +tComplex +tBitSet +tBitString +tRandom +tFix +tFix16 +tFix24 +tGetOpt +tList +tPlex +tLList +tVec +tStack +tQueue +tDeque +tPQ +tSet +tBag +tMap diff --git a/gnu/lib/libg++/libg++/vms/EXPECTED.VMS b/gnu/lib/libg++/libg++/vms/EXPECTED.VMS new file mode 100644 index 00000000000..f1d6ea47600 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/EXPECTED.VMS @@ -0,0 +1,1027 @@ +test_h +Could include all g++-include files +tFile +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 + +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 o +strstream... +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. + +Making filebuf streams fout and fin...contents of file: +Thisfilehasonelinetestingoutputstreams. + +Final names & states: +cin: (stdin) 0 +cout: (stdout) 0 +cerr: (stderr) 0 + +end of test. +tObstack +enter anything at all, end with an EOF(^D) + +unique words: +deleted +redundant +with +this +in +words +the +list +simply +should +program +The +Obstacks +for +file +test +simple +a +is +This + + +Obstack vars: +alignment_mask = 3 +chunk_size = 4080 +size = 0 +room = 4056 + +end of test +tString +an empty String: +A string initialized to Hello:Hello +A string initialized to previous string:Hello +A string initialized to previous string.at(1, 2):el +A string initialized to @:@ +A string initialized to dec(20):20 +n = 20 atoi(n) = 20 atof(n) = 20 +z = x + y = Helloworld +x += y; x = Helloworld +y.prepend(x); y = Helloworld +cat(x, y, x, x); x = HelloworldHello +cat(y, x, x, x); x = worldHelloHello +z = x + s + + y.at(w) + y.after(w) + . = Hello, world. +ch = x[0] = H +z = x.at(2, 3) = llo +x.at(2, 2) = r; x = Hero +x.at(0, 1) = j; x = jello +x.at(He) = je; x = jello +x.at(l, -1) = i; x = Helio +z = x.at(r) = ello +z = x.before(o) = Hell +x.before(ll) = Bri; x = Brillo +z = x.before(2) = He +z = x.after(Hel) = lo +x.after(Hel) = p; x = Help +z = x.after(3) = o +z = a bc; z = z.after(RXwhite); z =a bc +x.gsub(l, ll); x = Hellllo +x.gsub(r, ...); x = Hello should have been replaced by this string +x.gsub(RXwhite, #); x = Hello#should#have#been#replaced#by#this#string +z = x+y; z.del(loworl); z = Held +reverse(x) = olleH +x.reverse() = + olleH +upcase(x) = HELLO +downcase(x) = hello +capitalize(x) = Hello +z = replicate(*, 10) = ********** +z = This string has +five words +from split(z, RXwhite, w, 10), n words = 5: +This +string +has +five +words +z = join(w, nw, /); z =This/string/has/five/words +enter a word: +word =abcdefghijklmnopqrstuvwxyz length = 26 + +End of test +tInteger +one = 1 +one + 1 = 2 +two = 2 +fact30 = factorial(30) = 265252859812191058636308480000000 +fact28 = factorial(28) = 304888344611713860501504000000 +fact30 + fact28 = 265557748156802772496809984000000 +fact30 - fact28 = 264947971467579344775806976000000 +fact30 * fact28 = 80872505331661933764010628483512781121876047953920000000000000 +fact30 / fact28 = 870 +fact30 % fact28 = 0 +-fact30 = -265252859812191058636308480000000 +lg(fact30) = 107 +gcd(fact30, fact28) = 304888344611713860501504000000 +sqrt(fact30) = 16286585271694955 +negfact31 = -8222838654177922817725562880000000 +fact30 + negfact31 = -7957585794365731759089254400000000 +fact30 - negfact31 = 8488091513990113876361871360000000 +fact30 * negfact31 = -2181131468794922353615366650200339706856997013317222400000000000000 +fact30 / negfact31 = 0 +fact30 % negfact31 = 265252859812191058636308480000000 +gcd(fact30, negfact31) = 265252859812191058636308480000000 +fib50 = fibonacci(50) = 12586269025 +fib48 = fibonacci(48) = 4807526976 +fib48 + fib50 = 17393796001 +fib48 - fib50 = -77 +78742049 +fib48 * fib50 = 60508827864880718400 +fib48 / fib50 = 0 +fib48 % fib50 = 4807526976 +gcd(fib50, fib48) = 1 +sqrt(fib50) = 112188 +pow64 = Ipow(2, 64) = 18446744073709551616 +lg(pow64) = 64 +s64 = 1 << 64 = 18446744073709551616 +s32 = s64 >> 32 = 4294967296 +comps64 = ~s64 = 18446744073709551615 +comps64 & s32 = 4294967296 +comps64 | s32 = 18446744073709551615 +comps64 ^ s32 = 18446744069414584319 + +enter an Integer: +number = 12345678901234567890 + +End of test +tRational +one = 1 +third = 1/3 +half = 1/2 +third + half = 5/6 +third - half = -1/6 +third * half = 1/6 +third / half = 2/3 +onePointTwo = 21617278211378381/18014398509481984 +double(onePointTwo) = 1.2 +a = 1 +a += half = 3/2 +a -= half = 1 +a *= half = 1/2 +a /= half = 1 +approxpi = 355/113 +double(approxpi) = 3.14159 +rpi = Rational(PI) = 28296951008113761/9007199254740992 +double(rpi) = 3.14159 +approxpi + rpi = 6395111199349907153/1017813515785732096 +approxpi - rpi = 271516197167/1017813515785732096 +approxpi * rpi = 10045417607880385155/1017813515785732096 +approxpi / rpi = 3197555735433052160/3197555463916854993 +-approxpi = -355/113 +abs(negapproxpi) = 355/113 + +enter a Rational in form a/b or a: +number = 61727839/49382716 +approximating e as pow(1+1/n),n) for n =10 +double(approxe) = 2.59374 +log(approxe) = 0.953102 +approxe = 25937424601/10000000000 +approximating e as pow(1+1/n),n) for n =100 +double(approxe) = 2.70481 +log(approxe) = 0.995033 +approxe = 27048138294215260932671947108075308336779383827810027768902010491171015143067392794394 +5601434674459097335651375483564268312519281766832427980496322329650055217977882315938008175933291885667484249510001/10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000 +approximating e as pow(1+1 +/n),n) for n =1000 +double(approxe) = 2.71692 +log(approxe) = 0.9995 +approxe = 271692393223589245738308812194757718896431501883657280372235477486889494552376815899788569729866142905342103401540625692485946118761765388945775359308338639957206353850043265017614448804617104484412180547960764808660701874207779837508785585701227 +805310504270475882251 +1824867218226931719410407150364389665913091822576819072281835735365786202176167228686198158460724641052407506305826211156964723064441295969498221919251479211700941935114755531972677360157561485144237786816579422141378066423317811515462669946309306263409027 +3889159310822268542648586614208782799835344241286724612063568474638213646305043596651715 +7363539734603727475241036817487743394123454315351110047165147286911606852847897691660058538349718017239557392478904798956371431895753649310804159146091161207869846173908474193444244870141657548326389152909515801323311564853415408600931219048916854602439883 +4243847135102411661996020129557921444666343641039137906807591342742464200991933722791531 +0632026776505819463604220277656459701824637802731611130097175821554899026770950533542079447724392716564478699218259590428013227757290224914020120846053677844560908929876825478113604817317959806378475517882593842439973411907530893433872017538213604054303103 +2056448874114212008946036898659013632473745937296366658653244357047417935265651763533374 +4783401695951969936296323256525034685525470426185224036844803487442831639483152362831735350269624668701702424450940840884555271325190876102665277858154695092765613639718577127438538649414492678358762110235621776218781360881010654696273264706319088453035858 +3550529888085077754395613852326523053162877056534367276476814056183237572010229468011187 +7014807242402138526182959424836989017158399314793404423279251711874339321727641617984209755449426901225132913478359603773397347830618825529148435238469987142047271142307958631904183756367849847277942228226102474439484455873837802710569969126008653263293094 +1478779680554645850778168703661423819000515895232903243738763481571999080702098369316199 +6019422462478878083850738218615176368399269074581846046489420363552566832192181299104228221773367852686272744820374762943414445622071972095036595182662104327910782483210154532180195866086962072952991831119631585641624191527428074373462416676716884669982444 +2472676583768215160623063811165475659591701920645397802415709704254693734567333717916524 +2325399648121877178987723999503839197328183925340949191821443698275476295245249466361817367207248089144718808572152781037112209285944844021186534832159964297181970584453756163204297111185823467744743465840230098261424789313315093951766314459027947176701489 +2157468843634269615773483846518871531406096163629273381076867944999749025815798970761727 +1654150429433430074144410674999471571341963068871945136265828881213205685480733082705050506471444261824310101881215356379553902437021996780151509997072192624062541851241794085476041556622974624897375629756945230282156346757431325906601608952112277920484487 +5998864114930516063910324359331903843040069467324167490917499501000001/10000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + +End of test +tComplex +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, b) or (a) or a: +number = (1.2, -34) + +End of test +tBitSet +BitSet tests: +a = 0* +b = 000000000010* +c = 1010101010101010101010101010101010101010* +c[0] =1 +c[1] =0 +c[2] =1 +c[3] =0 +c[4] =1 +d = 00110011001100110011001100110011001100110* +e = 1111000011110000111100001111000011110* +u = ~a = 1* +g = ~e = 0000111100001111000011110000111100001* +~c = 0101010101010101010101010101010101010101* +c & d = 0010001000100010001000100010001000100010* +c | d = 10111011101110111011101110111011101110110* +c - d = 10001000100010001000100010001000100010* +c ^ d = 10011001100110011001100110011001100110010* +f = b = 100000000010* +f &= c = 100000000010* +f |= d = 10110011001100110011001100110011001100110* +f -= e = 00000011000000110000001100000011000000110* +f ^= u = 11111100111111001111110011111100111111001* +h = d +:00110011001100110011001100110011001100110* +h.set(0): +10110011001100110011001100110011001100110* +h.set(65): +1011001100110011001100110011001100110011000000000000000000000000010* +h.clear(2): +1001001100110011001100110011001100110011000000000000000000000000010* +h.invert(11,20): +10010011001011001100 +10110011001100110011000000000000000000000000010* +h.set(21,30): +1001001100101100110011111111111100110011000000000000000000000000010* +h.clear(31, 40): +1001001100101100110011111111111000000000000000000000000000000000010* +h.test(0,5) = 1 +h.test(31,40) = 0 +set bits in e: +0 1 2 3 8 9 10 11 16 17 18 19 24 25 26 27 32 33 34 35 +clear bits in g (reverse order): +35 34 33 32 27 26 25 24 19 18 17 16 11 10 9 8 3 2 1 0 + +End of test. +tBitString +a = +b = 1000000001 +c = 10101010101010101010 +d = 00110011001100110011 +e = 11110000111100001111 +f = b = 1000000001 +g = ~e = 00001111000011110000 +h = d = 00110011001100110011 +bits in e: +0 1 2 3 8 9 10 11 16 17 18 19 +clear bits in g (reverse order): +19 18 17 16 11 10 9 8 3 2 1 0 +~c = 01010101010101010101 +c & d = 00100010001000100010 +c | d = 10111011101110111011 +c - d = 10001000100010001000 +c ^ d = 10011001100110011001 +c + d = 1010101010101010101000110011001100110011 +c <<2 = 0010101010101010101010 +c >>2 = 101010101010101010 +f &= c = 1000000000 +f |= d = 10110011001100110011 +f -= e = 10000000000000000000 +f ^= c = 00101010101010101010 +f += b = 001010101010101010101000000001 +f <<=5 = 00000001010101010101010101000000001 +f >>=10= 0101010101010101000000001 +l = 101010101010101010100011001100110011001110101010101010101010 +BitPattern pat = 0011XXXX0011XXXX0011 +pat.pattern = 00110011001100110011 +pat.mask = 11110000111100001111 +l.index(pat) = 20 +l.index(pat,-1)= 20 +l.before( +pat) = 10101010101010101010 +l.at(pat) = 00110011001100110011 +l.after(pat) = 10101010101010101010 +b.set(0) :1000000001 +b.set(65): +100000000100000000000000000000000000000000000000000000000000000001 +b.clear(2): +100000000100000000000000000000000000000000000000000000000000000001 +b.invert(11,20): +100000000100111111111000000000000000000000000000000000000000000001 +b.set(21,30): +100000000100111111111111111111100000000000000000000000000000000001 +b.clear(31, 40): +100000000100111111111111111111100000000000000000000000000000000001 +b.set(0) :10110011001100110011 +b.set(65): +101100110011001100110000000000000000000000000000000000000000000001 +b.clear(2): +100100110011001100110000000000000000000000000000000000000000000001 +b.invert(11,20): +100100110010110011001000000000000000000000000000000000000000000001 +b.set(21,30): +100100110010110011001111111111100000000000000000000000000000000001 +b.clear(31, 40): +100100110010110011001111111111100000000000000000000000000000000001 +k = 0101 +c.before(k) = 1 +c.at(k) = 0101 + +c.after(k) = 010101010101010 +c.after(k)=k :101010101 +c.before(k)=k:010101010101 +reverse(k) = 1010 +k.left_trim(0) : 101 +k.right_trim(1) : 10 +k = 0110 +c.before(k) = 0 +c.at(k) = 0110 +c.after(k) = 011001100110011 +c.after(k)=k :001100110 +c.before(k)=k:011001100110 +reverse(k) = 0110 +k.left_trim(0) : 110 +k.right_trim(1) : 110 + +End of test. +tRandom +five random ACG integers: +1525072166 1954057046 3406008937 226879594 4107049426 +five random MLCG integers: +1341853672 83475514 936613571 888739672 2097844081 +Binomial r1( 100, 0.50, &gen1) ... +five samples: +57 46 52 61 56 +Statistics for 100 samples: +samples: 100 min: 40 max: 62 +mean: 50.53 stdDev: 5.01 var: 25.1001 confidence(95): 0.994319 +Erlang r2( 2.0, 0.5, &gen1) ... +five samples: +1.27721 1.70393 2.3407 1.15325 2.09453 +Statistics for 100 samples: +samples: 100 min: 0.771934 max: 3.80676 +mean: 2.05519 stdDev: 0.650616 var: 0.423302 confidence(95): 0.129126 +Geometric r3(&gen1, 0.5)... +five samples: +1 1 1 1 2 +Statistics for 100 samples: +samples: 100 min: 1 max: 7 +mean: 2.07 stdDev: 1.63457 var: 2.67182 confidence(95): 0.324408 +HyperGeometric r4( 10.0, 150.0, &gen1)... +five samples: +2.13048 0.104043 1.31297 6.57471 0.101734 +Statistics for 100 samples: +samples: 100 min: 0.101734 max: 62.1168 +mean: 11.4967 stdDev: 13.067 var: 170.746 confidence(95): 2.59336 +NegativeExpntl r5( 1.0, &gen1)... +five samples: +0 +.602235 0.455596 0.384398 1.17291 1.02726 +Statistics for 100 samples: +samples: 100 min: 0.0197259 max: 3.73061 +mean: 0.917305 stdDev: 0.861547 var: 0.742263 confidence(95): 0.170988 +Normal r6( 0.0, 1.0, &gen1)... +five samples: +-1.07586 -0.118719 -0.87357 -0.418734 1.00821 +Statistics for 100 samples: +samples: 100 min: -2.60171 max: 2.12323 +mean: -0.0300151 stdDev: 0.962241 var: 0.925907 confidence(95): 0.190973 +LogNormal r7( 1.0, 1.0, &gen1)... +five samples: +1.6929 0.274591 0.650784 0.367421 0.707629 +Statistics for 100 samples: +samples: 100 min: 0.0809301 max: 4.92198 +mean: 1.0507 stdDev: 0.931829 var: 0.868306 confidence(95): 0.184937 +Poisson r8( 2.0, &gen1)... +five samples: +2 7 4 3 3 +Statistics for 100 samples: +samples: 100 min: 0 max: 8 +mean: 2.06 stdDev: 1.68067 var: 2.82465 confidence(95): 0.333557 +DiscreteUniform r9( 0.0, 1.0, &gen1)... +five samples: +0 1 1 1 1 +Statistics for 100 samples: +samples: 100 min: 0 max: 1 +mean: 0.53 stdDev: 0.501614 var: 0.251616 confidence(95): 0.0995536 +Uniform r10( 0.0, +1.0, &gen1)... +five samples: +0.594603 0.891786 0.0816672 0.38546 0.787308 +Statistics for 100 samples: +samples: 100 min: 0.00230213 max: 0.990595 +mean: 0.486712 stdDev: 0.311104 var: 0.0967857 confidence(95): 0.0617438 +Weibull r11( 0.5, 1.0, &gen1)... +five samples: +0.808854 0.0040815 2.51041 0.10183 0.511513 +Statistics for 100 samples: +samples: 100 min: 3.03027e-07 max: 31.2816 +mean: 2.38949 stdDev: 5.468 var: 29.899 confidence(95): 1.08522 +SampleHistogram for 100 Normal samples +< -4 : 0 +< -3.2 : 0 +< -2.4 : 0 +< -1.6 : 6 +< -0.8 : 22 +< -2.77556e-17 : 31 +< 0.8 : 18 +< 1.6 : 18 +< 2.4 : 5 +< 3.2 : 0 +< 4 : 0 +< max : 0 + +End of test +tFix +Fix: identities should be displayed +[X] displays the precision of a given value +[*] indicates that the full precision is not used for coding reasons +0 [16] = 0.00000 [16] +.5 [16] = 0.50000 [16] +-.5 [17] = -0.50000 [17] +.1 [33] = 0.10000 [33] +-.5 [17] = -0.50000 [17] +.3 [16] = 0.29999 [16] +.5 [16] = 0.50000 [16] +.1 [16] = 0.09998 [16] +.1 [33*] = 0.09998 [33] +-.2 [17] = -0.20001 [17] +-.5 [17] = -0.50000 [17] +.1 [16] == .1 [33*] = 1 +.1 [16] == .1 [33] = 0 +.1 [33] != .5 [16] = 1 +.1 [33] > .5 [16] = 0 +.1 [33] <= -.2 [17] = 0 +1073741824 = 1.07374e+09 +.5 = 0.5 +.5 [17] = 0.50000 [17] +-.5 [17] = -0.50000 [17] +.1 [33] + .5 [16] = 0.60000 [33] +.1 [33] - .5 [16] = -0.40000 [33] +.1 [33] * .5 [16] = 0.05000 [49] +.1 [33] * 3 = 0.30000 [33] +.1 [33] * -3 = -0.30000 [33] +-.1 [33] * 3 = -0.30000 [33] +-.1 [33] * -3 = 0.30000 [33] +.5 [17] * -2 = -1.00000 [17] +.1 [33] % 25 = 0.10000 [58] +.1 [33] % -25 = 0.09375 [8] +.1 [33] / .5 [16] = 0.20001 [33] +.1 [33] << 1 = 0.20000 [33] +-.1 [33] >> 2 = 0.47500 [33] +abs(-.2) + = 0.20001 [17] +abs(.2) = 0.20001 [17] +sgn(-.2) = -1 +sgn(.2) = 1 + +show .1 [33] +len = 33 +siz = 3 +ref = 1 +man = ccccccc8000 +val = 0.1 + +Fix: range errors warned +Fix: range error in +declaration + +1.1 [16] = 0.00000 [16] +Fix: range error in +division + +.5 [16] / .1 [33] = 0.00000 [16] +Fix: range error in +division -- division by zero + +.5 [16] / 0. [16] = 0.00000 [16] +Fix: range error in +multiply by int -- int too large + +.5 [17] * 32768 = -1.00000 [17] + +Fix: overflows saturated +.95 [16] + .1 [33] = 1.00000 [33] +-.1 [33] - .95 [16] = -1.00000 [33] +.5 [17] * 2 = 0.99998 [17] + +Fix: overflows generate warnings +Fix: overflow warning +.95 [16] + .1 [33] = -0.94999 [33] +Fix: overflow warning +-.1 [33] - .95 [16] = 0.94999 [33] +Fix: overflow warning +.5 [17] * 2 = -0.49994 [17] +tFix16 +Fix16: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.100006 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +8192 = 8192 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.600006 +.1 - .5 = -0.399994 +.1 * .5 = 0.0500031 +.1 * 3 = 0.300018 +.1 * -3 = -0.300018 +.1 / .5 = 0.200012 +.1 << 1 = 0.200012 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix16: range errors ignored and overflows saturated +1.1 = 0.999969 +.7 + .5 = 0.999969 +-.5 - .7 = -1 +.5 / .1 = 0.999969 +Fix32: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * .5 = 0.05 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 / .5 = 0.2 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix32: range errors reported and overflows reported +warning: Fix32 result out of range +1.1 = 1 +warning: Fix32 result out of range +.7 + .5 = -0.8 +warning: Fix32 result out of range +-.5 - .7 = 0.8 +warning: Fix32 result out of range +.5 / .1 = 1 +tFix24 +Fix24: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * .5 = 0.05 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 / .5 = 0.2 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix24: range errors ignored and overflows saturated +1.1 = 1 +.7 + .5 = 1 +-.5 - .7 = -1 +.5 / .1 = 1 +Fix48: identities should be displayed +0 = 0 +.5 = 0.5 +-.5 = -0.5 +.1 = 0.1 +.5 = 0.5 +.5 = 0.5 +.25 = 0.25 +536870912 = 536870912 +0 = 0 +.25 = 0.25 +.25 = 0.25 +.25 = 0.25 +-.25 = -0.25 +.1 + .5 = 0.6 +.1 - .5 = -0.4 +.1 * 3 = 0.3 +.1 * -3 = -0.3 +.1 << 1 = 0.2 +-.5 >> 2 = -0.125 +.1 == .5 = 0 +.1 != .5 = 1 +.1 > .5 = 0 +.5 <= -.5 = 0 +Fix48: range errors reported and overflows reported +warning: Fix48 result out of range +1.1 = 1 +warning: Fix48 result out of range +.7 + .5 = -0.8 +warning: Fix48 result out of range +-.5 - .7 = 0.8 +tGetOpt +tList + +intList a = sequence(1, 20); +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + +intList b = randseq(20); +22 14 21 22 31 29 36 49 9 34 19 10 44 41 19 45 7 28 12 32 + +intList c = concat(a, b); +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 14 21 22 31 29 36 49 9 34 19 10 44 41 19 45 7 28 12 32 + +intList d = map(inc, a); +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + +intList e = reverse(a); +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 + +intList 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 +intList g = combine(plus, a, b); +23 16 24 26 36 35 43 57 18 44 30 22 57 55 34 61 24 46 31 52 + +g.del(is_odd); +16 24 26 36 18 44 30 22 34 24 46 52 + +b.sort(int_compare); +7 9 10 12 14 19 19 21 22 22 28 29 31 32 34 36 41 44 45 49 + +intList h = merge(a, b, int_compare); +1 2 3 4 5 6 7 7 8 9 9 10 10 11 12 12 13 14 14 15 16 17 18 19 19 19 20 21 22 22 28 29 31 32 34 36 41 44 45 49 + +h via Pix: +1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 9, 10, 10, 11, 12, 12, 13, 14, +14, 15, 16, 17, 18, 19, 19, 19, 20, 21, 22, 22, 28, 29, 31, 32, 34, 36, 41, 44, 45, 49, + +done +tPlex +FPtest +q:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +XPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +MPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] +RPtest +p:[-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 ] + +end of tests +tLList +prepending... +a: 9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after a.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +prepending... +a: +9 8 7 6 5 4 3 2 1 0 +appending... +a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +b = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_front of first 10 elements: +b: 0 1 2 3 4 5 6 7 8 9 +inserting 100 after sixth element... +b: 0 1 2 3 4 5 100 6 7 8 9 +after aa = a; aa.join(b) +9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 100 6 7 8 9 +b: + +b: +999 +bb: +999 +z = a: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 +remove_rear of last 10 elements: +z: 9 8 7 6 5 4 3 2 1 0 +inserting 100 before alternate elements... +z: 100 9 100 8 100 7 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +inserting 200 after sixth element... +z: 100 9 100 8 100 7 + 200 100 6 100 5 100 4 100 3 100 2 100 1 100 0 +deleting alternate elements of z...100 100 100 200 6 5 4 3 2 1 0 +z: 9 8 7 100 100 100 100 100 100 100 +z in reverse order: +100 100 100 100 100 100 100 7 8 9 + +End of test +tVec +a: 72 14 71 72 81 29 86 49 59 84 69 10 94 41 69 95 57 78 62 82 +a.sort():10 14 29 41 49 57 59 62 69 69 71 72 72 78 81 82 84 86 94 95 +b = map(inc, a): 11 15 30 42 50 58 60 63 70 70 72 73 73 79 82 83 85 87 95 96 +c = merge(a, b): 10 11 14 15 29 30 41 42 49 50 57 58 59 60 62 63 69 69 70 70 71 72 72 72 73 73 78 79 81 82 82 83 84 85 86 87 94 95 95 96 +d = concat(a, b): 10 14 29 41 49 57 59 62 69 69 71 72 72 78 81 82 84 86 94 95 11 15 30 42 50 58 60 63 70 70 72 73 73 79 82 83 85 87 95 96 +d.resize(10): 10 14 29 41 49 57 59 62 69 69 +d.reverse(): 69 69 62 59 57 49 41 29 14 10 +d.fill(0, 4, 4): 69 69 62 59 0 0 0 0 14 10 +d.reduce(plus, 0) = 283 +e = d.at(2, 5): 62 59 0 0 0 +x: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +y: 93 96 14 74 87 41 65 6 38 17 63 37 73 46 34 50 38 55 15 76 +x + y: 93 97 16 77 91 46 71 13 46 26 73 48 85 59 48 65 54 72 33 95 +x - y: -93 -95 -12 -71 -83 -36 -59 1 -30 -8 -53 -26 -61 -33 -20 -35 -22 -38 3 -57 +product(x, y): 0 96 28 222 348 205 390 42 304 153 630 407 876 598 476 750 608 935 + 270 1444 +quotient(x, y): 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 +x * y: 8782 +x + 2: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 +x - 2: -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 +x * 2: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 +x / 2: 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 +z(20, 1): 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +z = -z: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +z += x: -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 +z -= x: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +x.sum(): 190 +x.sumsq(): 2470 +x.min(): 0 +x.max(): 19 +x.min_index(): 0 +x.max_index(): 19 + +End of test +tStack +XP stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +V stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +SL stacks: +s1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] + +End of test +tQueue +XP queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +V queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +SL queues: +q1:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] + +End of test +tDeque +XP deques: +d1:[99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 ...] +DL deques: +d1:[99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 ...] + +End of test +tPQ +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +PHtest +a: [2 99 76 81 41 35 14 19 95 74 7 38 91 59 87 6 96 93 51 53 ...] +b: [129 5 191 71 147 17 139 193 1 47 199 33 121 103 37 167 145 67 51 43 ...] +c: [47 27 20 28 31 15 50 46 39 29 1 1 4 43 11 8 2 7 9 26 ...] +d: [2 99 76 81 41 35 14 19 95 74 7 38 91 59 87 6 96 93 51 53 ...] +XPtest +a: [1 3 2 7 4 5 18 29 12 6 10 8 17 21 26 34 36 15 16 19 ...] +b: [1 5 3 7 13 15 9 41 27 21 23 19 35 29 11 85 51 65 49 47 ...] +c: [1 2 1 3 5 2 8 4 5 6 14 3 9 11 10 7 15 12 6 28 ...] +d: [1 1 2 3 3 2 6 9 5 6 4 5 7 18 8 29 15 7 16 19 ...] +tSet +VHtest +a: [36 20 89 13 64 3 26 91 16 39 62 29 85 87 42 65 98 19 78 37 ...] +b: [53 167 185 13 123 3 135 193 69 39 181 85 151 183 131 173 101 19 197 87 ...] +c: [36 49 46 3 26 16 39 29 12 42 19 32 9 1 22 35 48 25 2 15 ...] +d: [89 13 93 3 55 39 29 85 21 65 19 23 91 9 71 81 41 35 63 17 ...] +VOHtest +a: [7 14 21 28 35 42 49 56 63 70 77 84 91 98 5 12 19 26 33 40 ...] +b: [7 163 21 133 35 49 63 129 77 159 91 181 105 137 119 5 185 19 197 33 ...] +c: [7 14 21 28 35 42 49 5 12 19 26 33 40 47 3 10 17 24 31 38 ...] +d: [7 21 35 49 63 77 91 5 19 33 47 61 75 89 3 17 31 45 59 73 ...] +CHtest +a: [72 36 85 49 13 3 98 62 26 16 75 39 29 88 52 42 6 65 55 19 ...] +b: [167 49 85 121 13 3 157 193 111 39 75 147 29 183 137 65 101 173 55 19 ...] +c: [36 13 49 3 26 16 39 29 6 42 19 32 45 9 22 35 12 48 25 38 ...] +d: [13 49 85 3 39 75 29 65 19 55 91 9 45 81 35 71 25 61 97 15 ...] +SLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 3 +5 49 1 12 50 9 31 26 10 42 17 13 11 21 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +XPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 17 13 11 21 ...] +d: [51 13 53 27 55 7 57 29 59 15 61 31 63 1 65 33 67 17 69 35 ...] +OXPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +OSLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +BSTtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 3 +9 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +AVLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +d: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +tBag +VHtest +a: [36 20 89 13 64 3 26 91 16 39 62 29 85 87 42 65 98 19 78 37 ...] +b: [53 167 185 13 123 3 135 193 69 39 181 85 151 183 131 173 101 19 197 87 ...] +c: [36 37 14 49 46 3 26 3 16 39 19 29 42 12 42 35 39 19 28 5 ...] +d: [72 46 77 13 31 3 26 62 16 39 11 29 52 42 42 65 78 55 78 93 ...] +CHtest +a: [72 36 85 49 13 3 98 62 26 16 75 39 29 88 52 42 6 65 55 19 ...] +b: [167 49 85 121 13 3 157 193 111 39 75 147 29 183 137 65 101 173 55 19 ...] +c: [36 36 49 13 13 49 3 3 26 26 16 16 39 39 29 29 6 42 6 42 ...] +d: [72 36 36 72 85 49 13 13 49 85 3 3 98 62 26 26 62 98 16 16 ...] +SLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 50 9 31 26 10 42 37 17 13 11 ...] +d: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +XPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [3 197 151 161 81 69 27 37 189 147 13 75 181 117 173 11 191 185 101 105 ...] +c: [33 2 48 18 37 5 35 49 1 12 5 +0 9 31 26 10 42 37 17 13 11 ...] +d: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +Splaytest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +OSLtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +OXPtest +a: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...] +b: [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ...] +c: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +d: [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 ...] +tMap +Splaytest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] +VHtest +a: [(36, 25) (20, 22) (89, 56) (13, 61) (64, 49) (3, 96) (26, 63) (91, 55) (16, 84) (39, 54) (62, 5) (29, 50) (85, 92) (87, 7) (42, 94) (65, 47) (98, 8) (19, 26) (78, 91) (37, 33) ...] +b: [(36, 4) (20, 83) (34, 18) (85, 38) (68, 84) (3, 2) (26, 19) (14, 76) (16, 57) (39, 23) (62, 90) (29, +53) (52, 14) (46, 34) (42, 21) (65, 1) (37, 73) (19, 15) (78, 95) (80, 86) ...] +c: [(36, 161) (20, 93) (34, 185) (85, 45) (68, 7) (3, 197) (26, 101) (14, 137) (16, 35) (39, 77) (62, 177) (29, 83) (52, 117) (46, 143) (42, 121) (65, 3) (37, 157) (19, 173) (78, 97) (80, 139) ...] +d: [(72, 72) (77, 77) (13, 13) (3, 3) (26, 26) (16, 16) (39, 39) (29, 29) (52, 52) (42, 42) (65, 65) (55, 55) (78, 78) (91, 91) (9, 9) (22, 22) (35, 35) (48, 48) (61, 61) (74, 74) ...] +CHtest +a: [(72, 66) (36, 25) (85, 92) (49, 10) (13, 61) (3, 96) (98, 8) (62, 5) (26, 63) (16, 84) (75, 51) (39, 54) (29, 50) (88, 81) (52, 32) (42, 94) (6, 9) (65, 47) (55, 45) (19, 26) ...] +b: [(72, 41) (36, 4) (49, 64) (13, 50) (85, 38) (3, 2) (62, 90) (98, 82) (26, 19) (16, 57) (75, 80) (39, 23) (29, 53) (88, 100) (52, 14) (6, 30) (42, 21) (65, 1) (55, 91) (19, 15) ...] +c: [(72, 53) (36, 161) (49, 67) (13, 171) (85, 45) (3, 197) (62, 177) (98, 95) (26, 101) (16, 35) (75, 25) (39, 77) (29, 83) (88, 47) (52, 117) (6, 135) (42, 121) (65, 3) (55, 89) (19, +173) ...] +d: [(36, 36) (72, 72) (13, 13) (49, 49) (85, 85) (3, 3) (26, 26) (62, 62) (98, 98) (16, 16) (39, 39) (75, 75) (29, 29) (52, 52) (88, 88) (6, 6) (42, 42) (65, 65) (19, 19) (55, 55) ...] +AVLtest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] +RAVLtest +a: [(1, 65) (2, 3) (3, 96) (4, 36) (5, 74) (6, 9) (7, 70) (8, 97) (9, 1) (10, 24) (11, 100) (12 +, 17) (13, 61) (14, 52) (15, 19) (16, 84) (17, 73) (18, 34) (19, 26) (20, 22) ...] +b: [(1, 9) (2, 31) (3, 2) (4, 32) (5, 62) (6, 30) (7, 87) (8, 98) (9, 6) (10, 49) (11, 44) (12, 47) (13, 50) (14, 76) (15, 56) (16, 57) (17, 12) (18, 54) (19, 15) (20, 83) ...] +c: [(1, 189) (2, 195) (3, 197) (4, 57) (5, 125) (6, 135) (7, 149) (8, 129) (9, 69) (10, 9) (11, 163) (12, 59) (13, 171) (14, 137) (15, 141) (16, 35) (17, 75) (18, 49) (19, 173) (20, 93) ...] +d: [(1, 1) (2, 2) (3, 3) (4, 4) (5, 5) (6, 6) (7, 7) (8, 8) (9, 9) (10, 10) (11, 11) (12, 12) (13, 13) (14, 14) (15, 15) (16, 16) (17, 17) (18, 18) (19, 19) (20, 20) ...] diff --git a/gnu/lib/libg++/libg++/vms/FNDVEC.C b/gnu/lib/libg++/libg++/vms/FNDVEC.C new file mode 100644 index 00000000000..fcf6eda7696 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/FNDVEC.C @@ -0,0 +1,223 @@ +#include +#include + +char * strchr(const char *, char); + +struct vector{ + char flag; /* indicates if this has been commented out */ + char* name; + struct vector* next;}; + +FILE *marfile; +FILE *libfile; +char line[140]; +struct vector* vlist = (struct vector*) NULL; +struct vector* vpoint; +struct vector* vend = (struct vector*) NULL; +int vcount=0; +int vmax=0; /* maximum number of transfer vectors */ + /* this is used to reserve space for this many vectors*/ + +#ifndef GSMAJOR +#define GSMAJOR 0 +#endif + +#ifndef GSMINOR +#define GSMINOR 0 +#endif + +int gmajor = GSMAJOR; +int gminor = GSMINOR; + +readmar(){ + char *status; + char *pnt; + int cmpr; + int flag; + do{ + status=fgets(line,sizeof(line),marfile); + if(status==(char*) NULL) break; + cmpr=strncmp(line,"VMAX=",5); + if(cmpr==0){ + pnt=line+5; + sscanf(pnt,"%d",&vmax);}; + cmpr=strncmp(line," .IDENT ",8); + if(cmpr==0){ + pnt=line+8; + sscanf(pnt,"/%d-%d/",&gmajor,&gminor);}; + flag = 0; + if(line[0] == ';') flag = 1; + cmpr=strncmp(line+flag,"UNUSED",6); + if(cmpr == 0){ + flag += 2; + add_unused(); + continue; + }; + cmpr=strncmp(line+flag,"ROUTINE ",8); + if(cmpr!=0) continue; /* test for anything but the routine name */ + pnt=strchr(line,'\n'); + if(pnt!=(char*) NULL) *pnt='\0'; + pnt=line+8+flag; + checkvec(pnt,0,flag); /* add this vector to the list*/ + }while(1==1); +} + +readlib(){ + char *status; + char *pnt; + char *epnt; + char module[32]; + int i; + int cmpr; + for(i=0;i<8;i++) { + status=fgets(line,sizeof(line),libfile); + if(status==(char*)NULL) return 0;}; + do{ + status=fgets(line,sizeof(line),libfile); + if(status==(char*) NULL) break; + pnt=strchr(line,'\n'); + if(pnt!=(char*) NULL) *pnt='\0'; + if(strlen(line)==0) continue; /* and delete blank lines*/ + cmpr=strncmp(line,"Module ",7); + if(cmpr==0){ + printf("%s ",line); + continue;}; + pnt=line; + do{ + epnt=module; + while((*pnt!=' ')&&(*pnt!='\0')) *epnt++=*pnt++; + *epnt='\0'; + checkvec(module,1,0); /*see if this vector belongs on the list*/ + while(*pnt==' ') pnt++; /* trim the spaces inbetween the names*/ + if(strlen(pnt)==0) break; + }while(1==1); + }while(1==1); + return 1; +} + +add_unused(){ + vpoint=(struct vector*) calloc(sizeof(struct vector),1); + if(vlist==(struct vector*) NULL) + vlist=vpoint; + else + vend->next=vpoint; + vend=vpoint; + vend->name="\0"; + vend->flag = 2; +} + +checkvec(char* pnt,int cflag,int commflag){ + int i; + vpoint=vlist; +/* We do not need external visibility for the CTOR and DTOR lists. */ + if(strncmp(pnt,"_GLOBAL_.",9) == 0) return; +/* These two entry points are not used in the sharable image library. */ + if(strncmp(pnt,"_VT.",4) == 0) commflag |= 4; + if(strncmp(pnt,"__LIBGXX_DEFINED_",17) == 0) commflag |= 4; + if(strcmp(pnt,"__MAIN") == 0) return; + if(strcmp(pnt,"_GXX_VMS_STARTUP_2") == 0) return; + if((cflag==1)&&(vpoint!=(struct vector*) NULL)){ + do{ + if(strcmp(pnt,vpoint->name)==0) return; + vpoint=vpoint->next; + }while(vpoint!=(struct vector*) NULL);}; +/* if(cflag==1) printf("\n Adding %s",pnt);*/ + vpoint=(struct vector*) calloc(sizeof(struct vector),1); + if(vlist==(struct vector*) NULL) + vlist=vpoint; + else + vend->next=vpoint; + vend=vpoint; + vend->name=(char*) malloc(strlen(pnt)+1); + vend->flag = commflag; + strcpy(vend->name,pnt); + vcount++; +} + +writemar(char* pnt){ + char title[30]; + char* i; + strncpy(title,pnt,30); + i=strchr(title,'.'); + if(i!=(char*) NULL) *i='\0'; /*fix up the title*/ + fprintf(marfile,";\n"); + fprintf(marfile," .TITLE %s\n",title); + fprintf(marfile," .IDENT /%d-%4.4d/\n",gmajor,gminor); + if(vmax==0){ + vmax=1; + while(vmaxflag & 4) == 4) { + fprintf(marfile,";UNIVERSAL = %s\n",vpoint->name); + vpoint=vpoint->next; + continue; + }; + if((vpoint->flag & 1) == 1) fprintf(marfile,";"); + if((vpoint->flag & 2) == 2) fprintf(marfile,"UNUSED\n"); + else + fprintf(marfile,"ROUTINE %s\n",vpoint->name); + vpoint=vpoint->next; + }while(vpoint!=(struct vector*) NULL); + fprintf(marfile,"lend: .REPEAT VMAX - </8>\n"); + fprintf(marfile," .long 0\n"); + fprintf(marfile," .long 0\n"); + fprintf(marfile," .ENDR\n"); + fprintf(marfile," .END\n"); +} + +main(int argc,char *argv[]){ + int nvec1; + if(argc<2){ + printf(" Usage: fndvec marfile liblistfile"); + exit(1);}; + marfile=fopen(argv[1],"r"); + libfile=fopen(argv[2],"r"); + readmar(); + fclose(marfile); + printf(" There were %d transfer vectors in the old file.\n",vcount); + nvec1=vcount; + readlib(); + fclose(libfile); + printf(" There were %d transfer vectors after reading the library list.\n",vcount); + if(nvec1==vcount){ + printf("There were no new vectors - file not written.\n"); + return 1;}; + if(vcount>vmax && vmax != 0){ + printf("The number of transfer vectors has exceeded the number of positions allocated.\n"); + printf("This version of the library will NOT be compatible with previous versions.\n"); + gmajor++; + gminor=0; + vmax=0;}; + if (vmax != 0) gminor++; + marfile=fopen(argv[1],"w"); + writemar(argv[1]); + fclose(marfile); + return 1; +} diff --git a/gnu/lib/libg++/libg++/vms/GENCLASS.COM b/gnu/lib/libg++/libg++/vms/GENCLASS.COM new file mode 100644 index 00000000000..45b4a81f5a5 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/GENCLASS.COM @@ -0,0 +1,60 @@ +$ v='f$verify(0) +$! COMMAND FILE TO GENERATE CLASSES +$! ARGUMENTS ARE THE SAME AS IN THE UNIX CASE +$! @GENCLASS TYPE MODE FILE +$! OR +$! @GENCLASS -2 TYPE1 MODE1 TYPE2 MODE2 FILE +$NMODES=1 +$IF P1.EQS."-2" THEN GOTO TWOMODE +$TYPE1=P1 +$MODE1=P2 +$TYPE2="" +$MODE2="VAL" +$FILE=P3 +$OUTFILE=f$extract(0,1,TYPE1)+FILE +$IF ((MODE1.EQS."REF").OR.(MODE1.EQS."VAL")) THEN GOTO PROCESS +$GOTO ERREXIT +$TWOMODE: +$NMODES=2 +$TYPE1=P2 +$MODE1=P3 +$TYPE2=P4 +$MODE2=P5 +$FILE=P6 +$!OUTFILE=f$extract(0,1,TYPE1)+f$extract(0,1,TYPE2)+FILE +$OUTFILE=f$extract(0,1,TYPE1)+FILE +$IF ((MODE1.EQS."REF").OR.(MODE1.EQS."VAL")) THEN GOTO PROCESS1 +$GOTO ERREXIT +$PROCESS1: +$IF ((MODE2.EQS."REF").OR.(MODE2.EQS."VAL")) THEN GOTO PROCESS +$! +$PROCESS: +$IF F$SEARCH("GNU_GXX_INCLUDE:[GEN]''FILE'.CCP").NES."" THEN - + COPY GNU_GXX_INCLUDE:[GEN]'FILE'.CCP 'OUTFILE'.CC +$IF F$SEARCH("GNU_GXX_INCLUDE:[GEN]''FILE'.HP").NES."" THEN - + COPY GNU_GXX_INCLUDE:[GEN]'FILE'.HP 'OUTFILE'.H +$OPEN OFILE$ RPLC.COM/WRITE +$REPLACE:==EDIT/TPU/NODISPLAY/NOSECTION/COMMAND=GNU_CC:[000000]GENCLASS.TPU +$RPC1=" " +$IF MODE1.EQS."REF" THEN RPC1=" & " +$RPC2=" " +$IF MODE2.EQS."REF" THEN RPC2=" & " +$write ofile$ "$ REPLACE:=''REPLACE'" +$WRITE OFILE$ "$ REPLACE ''OUTFILE'.*" +$WRITE OFILE$ TYPE1 +$WRITE OFILE$ TYPE1+RPC1 +$WRITE OFILE$ TYPE2 +$WRITE OFILE$ TYPE2+RPC2 +$DOIT: +$CLOSE OFILE$ +$@RPLC +$del rplc.com;/nolog +$PUR 'OUTFILE'.*/NOLOG +$if v then set verify +$EXIT +$ERREXIT: +$WRITE SYS$OUTPUT "Bad arguments given to genclass." +$write sys$output "Syntax is: @genclass type mode file" +$ write sys$output "or @genclass -2 type1 mode1 type2 mode2 file" +$if v then set verify +$exit diff --git a/gnu/lib/libg++/libg++/vms/GENCLASS.TPU b/gnu/lib/libg++/libg++/vms/GENCLASS.TPU new file mode 100644 index 00000000000..1f919db22df --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/GENCLASS.TPU @@ -0,0 +1,49 @@ + + PROCEDURE pat_replace ( + oldstring, ! + newstring) ! + LOCAL range2, count ; + position (beginning_of (current_buffer)) ; + count := 0 ; + LOOP + range2 := search_quietly (oldstring, FORWARD, EXACT) ; + EXITIF range2 = 0 ; + position (beginning_of (range2)) ; + erase (range2) ; + copy_text (newstring) ; + count := count + 1 ; + ENDLOOP ; + IF (count > 0) THEN + message (fao('Replaced pattern !UL time!%S', count)) ; + ENDIF ; + ENDPROCEDURE ; + + new_string1 := read_line ("type1: ") ; + new_file1 := substr(new_string1,1,1) ; + mode_string1 := read_line ("type&1: ") ; + new_string2 := read_line ("type2: ") ; + new_file2 := substr(new_string2,1,0) ; + mode_string2 := read_line ("type&2: ") ; + filename := GET_INFO (COMMAND_LINE, 'file_name') ; + LOOP + exp_filename := FILE_SEARCH (filename) ; + EXITIF exp_filename = "" ; + mainbuffer := CREATE_BUFFER (exp_filename, exp_filename) ; + position (mainbuffer) ; + execute ("pat_replace (""."",new_file1)") ; + execute ("pat_replace ("""", new_string1)") ; + execute ("pat_replace ("""",mode_string1)") ; + IF LENGTH (new_string2) > 0 + THEN + execute ("pat_replace (""."", new_file2)") ; + execute ("pat_replace ("""", new_string2)") ; + execute ("pat_replace ("""",mode_string2)") ; + ENDIF; + IF get_info (mainbuffer, "modified") THEN + write_file (mainbuffer) + ELSE + message ('No changes made.') ENDIF ; + delete (mainbuffer) ; + ENDLOOP ; + quit ; + diff --git a/gnu/lib/libg++/libg++/vms/GXX_MAIN_SHR.MAR b/gnu/lib/libg++/libg++/vms/GXX_MAIN_SHR.MAR new file mode 100644 index 00000000000..bb6824dd61d --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/GXX_MAIN_SHR.MAR @@ -0,0 +1,16 @@ +.title gxx_main_shr + ; + ; Force these psects to be loaded + ; + .psect __gxx_init_0_shr,ovr,noexe,pic,rel,gbl,shr + .long 0 + + .psect __gxx_init_2_shr,ovr,noexe,pic,rel,gbl,shr + .long 0 + + .psect __gxx_clean_0_shr,ovr,noexe,pic,rel,gbl,shr + .long 0 + + .psect __gxx_clean_2_shr,ovr,noexe,pic,rel,gbl,shr + .long 0 +.end diff --git a/gnu/lib/libg++/libg++/vms/OPTIONS.OPT b/gnu/lib/libg++/libg++/vms/OPTIONS.OPT new file mode 100644 index 00000000000..0f26664d4d8 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/OPTIONS.OPT @@ -0,0 +1,8 @@ +gnu_cc:[000000]libgxx/libr +sys$share:vaxcrtl/share +psect_attr=curscr,noshr +psect_attr=stdscr,noshr +psect_attr=stdin,noshr +psect_attr=stdout,noshr +psect_attr=stderr,noshr +psect_attr=_ctype_,noshr diff --git a/gnu/lib/libg++/libg++/vms/VMS-BUILD-LIBGXX.COM b/gnu/lib/libg++/libg++/vms/VMS-BUILD-LIBGXX.COM new file mode 100644 index 00000000000..99fc7f49635 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS-BUILD-LIBGXX.COM @@ -0,0 +1,382 @@ +$! +$! provide support for submitting this directly... +$! +$flnm = f$enviroment("PROCEDURE") ! get current procedure name +$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")' +$! +$! this command procedure is used to build the LIBGXX library for VMS +$! it is assumed that the sources are in a subdirectory [-.SRC], and that +$! the support modules are in this directory [.VMS] +$! +$! this is provided as a seperate file, since there are occasions that you +$! might wish to rebuild just the library, since the other support files have +$! already been built. +$! +$! first do some consistency checking to make sure things are OK. +$say:== write sys$output +$filenm=f$search("[-.src]regex.cc;-1") +$if filenm.eqs."" then goto start +$ say "Use the VMS-INSTALL-LIBGXX.COM file to set some things up before" +$ say "attempting to use this command file. VMS_INSTALL-LIBGXX will also" +$ say "automatically call this command file to perform the build once" +$ say "things are set up." +$ exit 2 !return error condition +$start: +$! +$! Define a few symbols that we will use +$lib:=lib/nolog +$! +$lib [-]libgxx/create +$! +$! now compile the iostream +$! +$ call compile iostream-objs.list [-.iostream] c "strtoul" +$! +$! now compile the sources +$! +$ call compile src-objs.list [-.src] cc "new,delete,dtoa" +$! +$! We have a conflict with a file by the same name in iostream. +$ gcc/plus/debug [-.src]dtoa.cc/object=dtoaxx.obj +$ lib [-]libgxx dtoaxx.obj +$ delete/nolog dtoaxx.obj; +$! +$! now include the other miscelaneous modules +$! +$macro/nolist gxx_main_shr +$! +$lib gnu_cc:[000000]gcclib - + /extract=(ALLOCA,BCMP,BCOPY,BZERO,INDEX,RINDEX,L_EPRINTF, - + L_BUILTIN_NEW,L_CAPS_NEW,L_BUILTIN_DEL, - + L_LSHRDI3,L_NEGDI2,L_UDIVDI3,L_UMODDI3,L_UDIVMODDI4)/output=t.obj +$lib [-]libgxx t.obj +$delete/nolog t.obj; +$! +$macro/nolist vms-gcclib +$lib [-]libgxx vms-gcclib +$delete/nolog vms-gcclib.obj; +$! +$gcc/debug vms-curses +$lib [-]libgxx vms-curses +$delete/nolog vms-curses.obj; +$! +$write sys$output "Library has been rebuilt." +$! +$!**************************************************************** +$write sys$output "Now building sharable image library..." +$! +$! G++ 1.n used GSMAJOR=1 +$! G++ 2.0 uses GSMAJOR=2 +$! +$! These will be overridden by the values in the file [-]Makefile.in, +$! if it is possible for the following TPU procedure to find it. +$GSMAJOR := 2 +$GSMINOR := 1 +$! +$edit := edit +$edit/tpu/nosection/nodisplay/command=sys$input +! this is the start of the main procedure + filename := GET_INFO (COMMAND_LINE, 'file_name') ; + mainbuffer := CREATE_BUFFER ("Makefile.in", "[-]Makefile.in") ; + newbuffer := CREATE_BUFFER("outfile"); + position (beginning_of (mainbuffer)); + range1 := search_quietly (LINE_BEGIN & "LIBG++_DIST_VERSION" & + ((SPAN(" ") & "=") | "="), FORWARD, EXACT) ; + if range1 <> 0 then + position (end_of (range1)); + move_horizontal(1); + mark1 := MARK(NONE); + range1 := search_quietly (LINE_END, FORWARD, EXACT) ; + position (beginning_of (range1)); + mark2 := MARK(NONE); + range1 := CREATE_RANGE (mark1, mark2); + position (beginning_of(newbuffer)); + copy_text (range1); + position (beginning_of(newbuffer)); + LOOP + range1 := search_quietly (".", FORWARD, EXACT) ; + exitif range1 = 0; + position (beginning_of (range1)); + erase_character(1); + split_line; + ENDLOOP; + SET(OUTPUT_FILE, newbuffer, "libgxx_version.txt"); + write_file (newbuffer); + endif; + quit; +$! +$OPEN IFILE$ LIBGXX_VERSION.TXT +$READ/END=DONE IFILE$ GSMAJOR +$READ/END=DONE IFILE$ GSMINOR +$DONE:CLOSE IFILE$ +$if f$search("libgxx_version.txt").nes."" then delete/nolog libgxx_version.txt; +$! +$! +$! Since libgxx_vector.mar is not shipped, fndvec will bump gsmajor. +$gcc/debug fndvec.c/define=("GSMAJOR=''gsmajor'","GSMINOR=''gsminor'") +$link fndvec.obj+GNU_CC:[000000]gcclib/lib+sys$library:vaxcrtl/lib/nomap +$ +$! compile the transfer vectors for the sharable library +$LIB/LIST=T.TMP/names [-]libgxx.OLB +$name=f$environment("PROCEDURE") +$fndvec=="$"+f$parse(name,,,"DEVICE")+f$parse(name,,,"DIRECTORY")+"FNDVEC" +$fndvec libgxx_vector.mar t.tmp +$del/nolog t.tmp; +$macro/nolist libgxx_vector +$delete *.obj;*/nolog/excl=(gxx_main_shr.obj,libgxx_vector.obj) +$! and clean up a little bit +$delete fndvec.exe; +$! +$! Now generate options file that we need to link the sharable image +$! +$! First generate a list of writable psects. We do this by linking, which +$! will generate a link map, and then examining the map. +$! +$! Generate the options file without a list of writable psects. +$! +$call buildopt +$! +$! Some modules might not contain any entry points, so we force the linker +$! to use them all. +$! +$lib [-]libgxx/extract=*/output=libgxx.obj +$! +$! And link it. +$! +$! +$LINK/exe=nla0:LIBGXX.EXE/MAP=LIBGXX.MAP LIBGXX_SHR_BLD.OPT/OPTIONS +$search libgxx.map ", WRT,",", SHR,"/match=and/output=t.wrt +$osect=" " +$changeflag==0 +$if f$search("libgxx.cmn").eqs."" then create libgxx.cmn +$open ofile$ libgxx.cmn/append +$OPEN IFILE$ t.wrt +$loop1: +$read/end=quit ifile$ line +$if f$length(line).eq.0 then goto loop1 +$use_sect: +$ijk=f$locate(" ",line) +$sectnam=f$extract(0,ijk,line) +$! the same psect might have appeared on several pages, on the 2nd and +$! following pages the psect name and attributes appear again. +$if osect.eqs.sectnam then goto loop1 +$osect=sectnam +$write ofile$ sectnam +$changeflag==1 +$GOTO LOOP1 +$quit: +$close ifile$ +$close ofile$ +$del libgxx.map;/nolog +$del t.wrt;/nolog +$WRITE SYS$OUTPUT "List of writable psects written to libgxx.cmn" +$! +$! Now build the actual options file we need to finish the job... +$! +$call buildopt +$! +$ say:=write sys$output +$ say "Linking sharable image library..." +$ +$ LINK/NOMAP/SHAREABLE=[-]LIBGXX_SHR.EXE - + LIBGXX_SHR_BLD.OPT/OPTIONS +$! +$! Now clean up what we do not need. +$! +$purge/nolog *.opt +$delete/nolog libgxx_vector.obj; +$delete/nolog gxx_main_shr.obj; +$delete/nolog libgxx.obj; +$! +$! now we are done building the library - now figure out if we have libgxx +$!already installed. +$installed = 0 +$if f$search("gnu_cc:[000000]libgxx_shr.exe").eqs."" then goto cpy +$if f$file_attributes("gnu_cc:[000000]libgxx_shr.exe","KNOWN").eqs."TRUE" - + then installed = 1 +$cpy: +$! copy libgxx_shr.olb gnu_cc:[000000] +$on error then goto noclean +$ copy [-]libgxx_shr.exe gnu_cc:[000000] +$ lnm=f$trnlnm("GNU_CC")-".]"+"]libgxx_shr" +$ assign/system 'lnm' libgxx_shr +$ delete/nolog [-]libgxx_shr.exe; +$type/nopage sys$input +Finished building library. LIBGXX_SHR.EXE has been copied to gnu_cc:[000000]. +$if installed.eq.0 then goto done_build +$if f$privilege("CMKRNL").eqs."FALSE" then goto noinst +$install:==$install +$if installed.eq.1 then install replace gnu_cc:[000000]libgxx_shr.exe +$type/nopage sys$input +A previous version was installed before, it has been replaced by the new one. +$ goto done_build +$noinst: +$type/nopage sys$input +A previous version of libg++ was installed before, but this account does not +have CMKRNL, so the image has not been replaced. +$goto done_build +$not_inst: +$type/nopage sys$input +You have the option of installing the executable to make it a known image. +$ +$! +$noclean: +$type/nopage sys$input +Finished building library. LIBGXX_SHR.EXE has NOT been copied to gnu_cc:[000000] +since you ignored the instructions about having write access to gnu_cc:[000000]. +Not to worry, however, the file has been left in the parent directory of the +vms subdirectory, and you can copy the file by hand. Once you have done this, +you have the option of installing the executable to make it a known image. +$exit +$done_build: +$on error then exit +$! +$! and clean up a little bit. +$! +$! +$ if f$search("sys$library:libgxx_shr.olb").nes."" then - + delete/nolog sys$library:libgxx_shr.olb; +$exit +$! +$! +$! Subroutine to generate a linker options file. It requires as input the +$! file libgxx.cmn, listing the writable psects in the image, and it needs +$! to take a peek at libgxx_vector.mar to find out the gsnumbers. +$! The output is in the files libgxx_shr_bld.opt and options_shr.opt. +$! +$! When building the library we need the LCL modifier, to tell the linker +$! that the psect is local. When linking to the library we must not use it. +$buildopt: +$subroutine +$gsmajor = 1 +$gsminor = 1 +$open ofile$ libgxx_shr_bld.opt/WRITE +$open user_link_opt$ options_shr.opt/WRITE +$write user_link_opt$ "LIBGXX_SHR/SHARE" +$write user_link_opt$ "SYS$SHARE:VAXCRTL/SHARE" +$write user_link_opt$ "gnu_cc:[000000]gcclib/lib +$write user_link_opt$ "psect_attr=curscr,noshr" +$write user_link_opt$ "psect_attr=stdscr,noshr" +$write user_link_opt$ "psect_attr=stdin,noshr" +$write user_link_opt$ "psect_attr=stdout,noshr" +$write user_link_opt$ "psect_attr=stderr,noshr" +$write user_link_opt$ "psect_attr=_ctype_,noshr" +$write ofile$ "!" +$write ofile$ "NAME = libgxx_SHR" +$! +$! first find the gsmatch parameters from the ident field of libgxx_vector.mar +$open ifile$ libgxx_vector.mar +$gsloop: +$read/end=nogs ifile$ line +$ijk=f$locate(".IDENT",line) +$if ijk.eq.f$length(line) then goto gsloop +$ijk=f$locate("/",line)+1 +$line=f$extract(ijk,f$length(line)-ijk-1,line) +$ijk=f$locate("-",line) +$gsmajor='f$extract(0,ijk,line) +$gsminor='f$extract(ijk+1,f$length(line)-ijk-1,line) +$close ifile$ +$nogs: +$write ofile$ "IDENTIFICATION = """,gsmajor,".",gsminor,""" +$write ofile$ "! +$write ofile$ "! +$write ofile$ "! Increase the second number by one for each new routine added +$!write ofile$ "GSMATCH = LEQUAL,",gsmajor,",",gsminor +$write ofile$ "GSMATCH = EQUAL,",gsmajor,",",gsminor +$write ofile$ "! +$write ofile$ "PSECT_ATTR = $PDATA,PIC,EXE +$write ofile$ "PSECT_ATTR = $MACRO,PIC,EXE +$write ofile$ "PSECT_ATTR = $TOKEN,PIC,EXE +$write ofile$ "! +$write ofile$ "! If new routines add any more writable psects, give them PSECT_ATTR's of LCL +$write ofile$ "! and NOSHR +$if f$search("libgxx.cmn").eqs."" then goto nofile1 +$open ifile$ libgxx.cmn +$loop:read ifile$ line/end=done +$write ofile$ "PSECT_ATTR = ''line',LCL,NOSHR" +$write user_link_opt$ "PSECT_ATTR = ''line',NOSHR" +$goto loop +$done:close ifile$ +$! +$! Now add the universal symbols +$! +$if f$search("libgxx_vector.mar").eqs."" then goto nouniversal +$search libgxx_vector.mar "UNIVERSAL"/OUTPUT=universal.lst +$open ufile$ universal.lst +$uloop: +$read/end=udone ufile$ line +$write ofile$ f$extract(1,255,line) +$goto uloop +$udone:close ufile$ +$delete/nolog universal.lst; +$! +$nouniversal: +$write ofile$ "!" +$write ofile$ "! New writable psect names should be added to CLUSTER3" +$write ofile$ "COLLECT = CLUSTER1,$$$$libgxx_VECTOR" +$open ifile$ libgxx.cmn +$loop1:read ifile$ line/end=done1 +$write ofile$ "COLLECT = CLUSTER1,"+LINE +$GOTO LOOP1 +$DONE1:CLOSE IFILE$ +$nofile1: +$write ofile$ "COLLECT = CLUSTER2,$LOCAL,$BLANK" +$write ofile$ "COLLECT = CLUSTER2,$CODE,$PDATA" +$write ofile$ "!" +$write ofile$ "gxx_main_shr" +$write ofile$ "libgxx_VECTOR.OBJ" +$write ofile$ "libgxx.OBJ" +$write ofile$ "SYS$LIBRARY:VAXCRTL/SHARE" +$write ofile$ "psect_attr=curscr,noshr" +$write ofile$ "psect_attr=stdscr,noshr" +$write ofile$ "psect_attr=stdin,noshr" +$write ofile$ "psect_attr=stdout,noshr" +$write ofile$ "psect_attr=stderr,noshr" +$write ofile$ "psect_attr=_ctype_,noshr" +$close user_link_opt$ +$close ofile$ +$exit +$endsubroutine +$! +$! +$! This routine takes parameter p1 to be a linker options file with a list +$! of object files that are needed. It extracts the names, and compiles +$! each source module, one by one. +$! +$! Parameter P2 is a list of files which will appear in the options file +$! that should not be compiled. This allows us to handle special cases. +$! +$compile: +$subroutine +$on error then goto c_err +$on control_y then goto c_err +$open ifile$ 'p1' +$loop: read ifile$ line/end=c_done +$! +$i=0 +$loop1: +$flnm=f$element(i,",",line) +$i=i+1 +$if flnm.eqs."" then goto loop +$if flnm.eqs."," then goto loop +$if f$locate(flnm,"''p4'").nes.f$length("''p4'") then goto loop1 +$! +$name = f$edit("''p2'''flnm'.''p3'","collapse") +$set verify +$ gcc/plus/debug 'name' +$ lib [-]libgxx 'flnm'.obj +$ delete/nolog 'flnm'.obj; +$!'f$verify(0) +$goto loop1 +$! +$goto loop +$! +$! In case of error or abort, go here (In order to close file). +$! +$c_err: !'f$verify(0) +$close ifile$ +$exit %x2c +$! +$c_done: +$close ifile$ +$endsubroutine diff --git a/gnu/lib/libg++/libg++/vms/VMS-CURSES.C b/gnu/lib/libg++/libg++/vms/VMS-CURSES.C new file mode 100644 index 00000000000..83acf047de9 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS-CURSES.C @@ -0,0 +1,41 @@ +/* These are routines that are used in various places within libg++, which + do not actually appear within curses anywhere. */ + +struct _kb_st +{ + int _id; + unsigned char _flags; +}; + +struct _kb_st * stdkb __asm("_$$PsectAttributes_NOSHR$$stdkb"); + +extern int stdscr; /* This is the wrong type, but it does not matter. */ + +mvcur(int ly,int lx,int ny,int nx) +{ + wmove (stdscr, ny, nx); +} + +_setecho(int i) +{ + if(i) stdkb->_flags &= ~1; + else stdkb->_flags |= 1; +} + +_setnonl(int i) +{ + if(i) stdkb->_flags &= ~2; + else stdkb->_flags |= 2; +} + + +cbreak() +{ + stdkb->_flags &= ~4; + stdkb->_flags |= 2; +} + +nocbreak() +{ + stdkb->_flags |= 4; +} diff --git a/gnu/lib/libg++/libg++/vms/VMS-GCCLIB.MAR b/gnu/lib/libg++/libg++/vms/VMS-GCCLIB.MAR new file mode 100644 index 00000000000..70210f70aaf --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS-GCCLIB.MAR @@ -0,0 +1,56 @@ + .TITLE GCCLIB GNU CC compiler runtime support routines + .IDENT /1.00/ + +; +; The following routines implement runtime functions for code +; generated by GNU CC. +; + .PSECT $CODE,LONG,PIC,REL,SHR,EXE,RD,NOWRT + .ENTRY UDIV,^M + MOVL 4(AP),R0 + MOVL 8(AP),R2 + BEQL 1$ + CMPL R2,#1 + BLEQ 2$ +1$: CLRL R1 + EDIV R2,R0,R0,R2 + RET +2$: BEQL 10$ + CMPL R0,R2 + BGEQU 20$ + CLRL R0 + RET +20$: MOVL #1,R0 +10$: RET + + .ALIGN LONG + .ENTRY UREM,^M + MOVL 4(AP),R0 + MOVL 8(AP),R2 + BEQL 1$ + CMPL R2,#1 + BLEQ 2$ +1$: CLRL R1 + EDIV R2,R0,R2,R0 + RET +2$: BNEQ 10$ + CLRL R0 + RET +10$: CMPL R0,R2 + BLSSU 100$ + SUBL2 R2,R0 +100$: RET + + .ALIGN LONG + .ENTRY _LSHRSI3,^M<> + MOVL 4(AP),R0 + SUBL3 8(AP),#32,R1 + EXTZV 8(AP),R1,R0,R0 + RET + + .ALIGN LONG + .ENTRY _FIXUNS_TRUNCDFSI,^M<> + CVTDL 4(AP),R0 + RET + + .END diff --git a/gnu/lib/libg++/libg++/vms/VMS-INSTALL-LIBGXX.COM b/gnu/lib/libg++/libg++/vms/VMS-INSTALL-LIBGXX.COM new file mode 100644 index 00000000000..a4dbbbc6cd6 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS-INSTALL-LIBGXX.COM @@ -0,0 +1,326 @@ + +$! this command procedure calls make_libgxx to build libg++, and then installs +$! it on a VMS system. It is assumed that +$! GNU-C and GNU-C++ have already been installed. It is also assumed that the +$! sharable library will be used. In order to run this you will need to have +$! write access to GNU_CC:[000000] +$! +$! this hack lets us submit this file directly to a queue, without having to +$! specify the default directory - it assumes that the file is in the [.vms] +$! directory of the tree +$flnm = f$enviroment("PROCEDURE") ! get current procedure name +$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")' +$! +$! do some simple tests first... +$ if f$trnlnm("GNU_CC").eqs."" then goto errmess1 +$ if f$trnlnm("GNU_GXX_INCLUDE").eqs."" then goto errmess2 +$on error then exit +$ create gnu_cc:[000000]write_test.tmp +$delete/nolog gnu_cc:[000000]write_test.tmp; +$! +$! +$! First we use a crude hack to rename header files in +$! the case that there exist two different files in a case-sensitive +$! world, which become one file in a case insensitive world. +$! +$! This will fix things so they look like: +$! #ifdef VMS +$! #include +$! #else +$! #include +$! #endif +$! +$call fix_file "[-.src]Regex.cc" "RRegex.cc" +$! +$call fix_file "[-.src]Regex.h" "RRegex.h" +$call fix_file "[-.src]String.h" "SString.h" +$call fix_file "[-.src]Complex.h" "CComplex.h" +$! +$fix_includes:=EDIT/TPU/NODISPLAY/NOJOURNAL/NOSECTION - + /COMMAND=sys$disk:[]vms_fixincludes.tpu +$! +$fix_includes [-.src]RRegex.cc +$fix_includes [-.src]SString.h +$fix_includes [-.src]String.cc +$fix_includes [-.src]strclass.h +$fix_includes [-.src]complex.h +$fix_includes [-.src]Complex.cc +$fix_includes [-.tests]TComplex.cc +$fix_includes [-.tests]TString.cc +$fix_includes [-.tests]Test_H.cc +$ +$! +$! We must rename these so that the g++ compiler implements the classes. +$! +$if f$search("[-.src]Complex.cc").nes."" then - +$ rename [-.src]Complex.cc [-.src]CComplex.cc +$if f$search("[-.src]String.cc").nes."" then - +$ rename [-.src]String.cc [-.src]SString.cc +$! +$!************************************************************************* +$! Next we install the header files in the directory GNU_CC:[GXX_INCLUDE] +$!************************************************************************* +$! +$! this is the easiest way of installing the header files. +$ copy _g_config.h gnu_gxx_include:[000000] +$! backup [-.g__-include...]*.*; gnu_gxx_include:[000000...]*.*; +$ backup [-.iostream]*.h; gnu_gxx_include:[000000]*.*; +$ backup [-.src]*.h; gnu_gxx_include:[000000]*.*; +$ backup [-.src.gen...]*.*; gnu_gxx_include:[gen...]*.*; +$! +$! There are some header files that are called in libg++ and the test +$! suite for which an empty file works. Create these if needed. +$if f$search("gnu_cc_include:[000000]malloc.h").eqs."" then - +$ create gnu_cc_include:[000000]malloc.h +$if f$search("gnu_cc_include:[000000]fcntl.h").eqs."" then - +$ create gnu_cc_include:[000000]fcntl.h +$if f$search("gnu_cc_include:[000000]grp.h").eqs."" then - +$ create gnu_cc_include:[000000]grp.h +$if f$search("gnu_cc_include:[000000]pwd.h").eqs."" then - +$ create gnu_cc_include:[000000]pwd.h +$if f$search("gnu_cc_include:[sys]times.h").eqs."" then - +$ create gnu_cc_include:[sys]times.h +$if f$search("gnu_cc_include:[sys]signal.h").eqs."" then - +$ create gnu_cc_include:[sys]signal.h +$if f$search("gnu_cc_include:[sys]wait.h").eqs."" then - +$ create gnu_cc_include:[sys]wait.h +$if f$search("gnu_cc_include:[sys]resource.h").eqs."" then - +$ create gnu_cc_include:[sys]resource.h +$if f$search("gnu_cc_include:[sys]resourcetime.h").eqs."" then - +$ create gnu_cc_include:[sys]resourcetime.h +$if f$search("gnu_cc_include:[sys]socket.h").eqs."" then - +$ create gnu_cc_include:[sys]socket.h +$! +$get_makefile:=edit/tpu/nojournal/nosection/nodisplay/command=sys$input +$get_makefile + PROCEDURE makefile_lookup (TAG_NAME, outfile) + position (beginning_of (newbuffer)); + recursive_fetch_tag (TAG_NAME); +! +! Now fix up a few things in the output buffer +! + pat_replace (".o ",","); + pat_replace (".o",""); !appear at end of lines. +! +! Remove trailing commas, if present. +! + position (beginning_of (newbuffer)); + LOOP + range1:=search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END), FORWARD, EXACT); + exitif range1 = 0; + position (beginning_of (range1)); + erase(range1); + split_line; + ENDLOOP; +! get rid of leading spaces on lines. + position (beginning_of (current_buffer)) ; + LOOP + range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ; + EXITIF range1 = 0; + position (end_of (range1)); + erase_character(1); + ENDLOOP; +! +! Now write the output file. +! + SET(OUTPUT_FILE, newbuffer, outfile); + write_file (newbuffer); + erase (newbuffer); + ENDPROCEDURE; + +! +! Looks up a tag, copies it to newbuffer, and then translates any $(...) +! definitions that appear. The translation is put at the current point. +! + PROCEDURE recursive_fetch_tag (TAG_N); + fetch_tag (TAG_N); +! +! substitute any makefile symbols $(...) +! + position (beginning_of (current_buffer)) ; + LOOP + range1 := search_quietly ("$(" & + SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789") & ")", FORWARD, EXACT) ; + EXITIF range1 = 0; + position (beginning_of (range1)); + move_horizontal(2); + mark_1 := MARK (NONE); + position (end_of (range1)); + move_horizontal(-1); + mark_2 := MARK (NONE); + tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE); + position (end_of (range1)); + tag_string := STR (tag_range); + erase (range1); + fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "=")); + position (beginning_of (current_buffer)) ; + ENDLOOP; + ENDPROCEDURE; + +! +! Looks up the translation of a tag, and inserts it at the current location +! in the buffer +! + PROCEDURE fetch_tag (TAG_N); + LOCAL mark1, mark2, mark3, range2; + mark3 := MARK(NONE) ; + position (beginning_of (mainbuffer)) ; + range2 := search_quietly (TAG_N, FORWARD, EXACT) ; + IF (range2 = 0) then + position (mark3); + return; + endif; + position (end_of (range2)) ; + MOVE_HORIZONTAL(1); + mark1 := MARK(NONE) ; + position (beginning_of (range2)) ; + MOVE_VERTICAL(1); + MOVE_HORIZONTAL(-2); + LOOP + EXITIF CURRENT_CHARACTER <> "\" ; + ERASE_CHARACTER(1); + MOVE_HORIZONTAL(1); + MOVE_VERTICAL(1); + MOVE_HORIZONTAL(-2); + ENDLOOP; + MOVE_HORIZONTAL(1); + mark2 := MARK(NONE) ; + range2 := CREATE_RANGE(mark1, mark2, NONE) ; + position (mark3); + if (length(range2) = 0) then return; endif; + copy_text(range2); + ENDPROCEDURE; + + PROCEDURE pat_replace ( + oldstring, ! + newstring) ! + LOCAL range2; + position (beginning_of (current_buffer)) ; + LOOP + range2 := search_quietly (oldstring, FORWARD, EXACT) ; + EXITIF range2 = 0 ; + position (beginning_of (range2)) ; + erase (range2) ; + copy_text (newstring) ; + ENDLOOP ; + ENDPROCEDURE ; + +! +! this is the start of the main procedure. +! +! First get the iostream makefile, and find out which components we need to +! install. +! + filename := GET_INFO (COMMAND_LINE, 'file_name') ; + mainbuffer := CREATE_BUFFER ("iostream.in", "[-.iostream]Makefile.in") ; + newbuffer := CREATE_BUFFER("outfile"); + + makefile_lookup(LINE_BEGIN & "IOSTREAM_OBS" & ((SPAN(" ") & "=") | + "="),"iostream-objs.list"); + erase(mainbuffer); + delete(mainbuffer); +! +! Now do the same thing with the [-.src]Makefile.in +! + mainbuffer := CREATE_BUFFER ("src.in", "[-.src]Makefile.in") ; + position (beginning_of(mainbuffer)); +! +! Ooooooo I wish VMS were case sensitive like Unix was. This a a really +! gross hack. +! + pat_replace (" Regex.o"," RRegex.o"); + pat_replace (" Complex.o"," CComplex.o"); + pat_replace (" String.o"," SString.o"); + makefile_lookup(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="), + "src-objs.list"); + quit ; +! +$! next build the actual library. This will copy the result to gnu_cc:[000000] +$@vms-build-libgxx +$! +$! next install the files for container classes. +$copy genclass.* GNU_CC:[000000]*.* +$! +$! now install the options files required for linking. +$ copy options_shr.opt GNU_CC:[000000]*.* +$! copy options.opt GNU_CC:[000000]*.* !only required to link non-shared lib +$! +$! now install the command files required to link a user program to the library +$! +$copy cxshare.com GNU_CC:[000000]*.* +$!copy cxlink.com GNU_CC:[000000]*.* !used to link to non-shared library. +$! +$write sys$output "The installation is complete" +$exit 1 +$! +$! +$errmess1: +$say:=write sys$output +$ say "You must install GNU-C and then GNU-C++ before you attempt to build" +$ say "libg++. After you have installed GNU-C and GNU-C++ you can try this" +$ say "again." +$exit 0 +$! +$errmess2: +$ say "You must install GNU-C++ before you attempt to build" +$ say "libg++. After you have installed GNU-C++ you can try this again." +$exit 0 +$! +$type sys$input +You must have write access to GNU_CC to do this installation. If +you wish, you can create your own private directory, and use a logical +to point to it. An example would be: + ASSIGN DUA0:[FRED.GNU.]+F$TRNLNM("GNU_CC") GNU_CC +and any files created by this installation will be put in dua0:[fred.gnu] +$exit 0 +$! +$exit +$! +$! +$! +$!************************************************************************* +$! What follows are a series of subroutines used to install libg++ +$!************************************************************************* +$! +$! +$fix_file: +$subroutine +$! +$! First locate the file that needs to be renamed. +$! +$epos = f$length(p1) - 1 +$fix_loop: +$if f$extract(epos,1,p1).eqs."." then goto fix_loop_done +$epos=epos-1 +$if epos.ge.0 then goto fix_loop +$write sys$error "Ooops" +$exit +$! +$fix_loop_done: +$ name = p1 +$ extension = "" +$ if epos.ne.f$length(p1) then name = f$extract(0,epos,p1) +$ if epos.ne.f$length(p1) then extension = f$extract(epos,255,p1) +$epos = f$locate("]",name) +$ if epos.ne.f$length(name) then name = f$extract(epos+1,255,name) +$! +$write sys$output name +$target = name+"_h" +$if extension.nes.".h" then target=name+".h" +$assign nla0: sys$output +$assign nla0: sys$error +$fix_loop: +$flnm=f$search("''p1';*") +$if flnm.eqs."" then exit +$search 'flnm' "''target'"/exact +$if $status.ne.1 then goto fix_loop +$! +$! Now rename the header file... +$! +$deassign sys$output +$deassign sys$error +$jpos = f$locate("]",flnm) + 1 +$flnm1 = f$extract(0,jpos,flnm) + p2 +$write sys$output "rename "+flnm+" "+flnm1 +$rename 'flnm' 'flnm1' +$endsubroutine diff --git a/gnu/lib/libg++/libg++/vms/VMS-TEST-LIBGXX.COM b/gnu/lib/libg++/libg++/vms/VMS-TEST-LIBGXX.COM new file mode 100644 index 00000000000..4dbaf9532be --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS-TEST-LIBGXX.COM @@ -0,0 +1,108 @@ +$set noon +$! +$! go to the vms subdirectory in the libg++ distribution tree +$flnm = f$enviroment("PROCEDURE") ! get current procedure name +$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")' +$! +$! go to the directory where the test files reside. +$set def [-.tests] +$! make sure that the symbols are defined properly. +$genclass:==@gnu_cc:[000000]genclass +$cxshare:==@gnu_cc:[000000]cxshare +$! +$gloop: +$filenm = f$search("GNU_GXX_INCLUDE:[GEN]*.*",0) +$if filenm.eqs."" then goto gdone +$! if both a .HP and a .CCP file exist, do only one of them +$name = f$parse(filenm,,,"NAME") +$type = f$parse(filenm,,,"TYPE") +$if type.eqs.".HP" then goto generate +$file1 = f$parse(filenm-".CCP",".HP") +$if f$search(file1,1).nes."" then goto gloop +$! +$generate: +$set ver +$genclass -2 "int" val "int" val 'name' +$! 'f$verify(0) +$goto gloop +$gdone: +$! +$lib/create ilib +$create compile_these.list + ILIST ISLLIST IDLLIST IVEC IAVEC + IPLEX IFPLEX IXPLEX IRPLEX IMPLEX + ISET IBAG IMAP IPQ + IXPSET IOXPSET ISLSET IOSLSET IBSTSET ICHNODE + IAVLSET ISPLAYNODE ISPLAYSET IVHSET IVOHSET ICHSET + IXPBAG IOXPBAG ISLBAG IOSLBAG ISPLAYBAG IVHBAG ICHBAG + IVHMAP ICHMAP ISPLAYMAP IAVLMAP IRAVLMAP + ISPLAYPQ IPHPQ IXPPQ + IVSTACK IVQUEUE ISTACK IQUEUE IDEQUE + IXPSTACK ISLSTACK IXPQUEUE ISLQUEUE IXPDEQUE IDLDEQUE +$! +$! +$loop: +$filenm = f$search("i*.cc") +$name = f$parse(filenm,,,"NAME") +$if filenm.eqs."" then goto done +$assign nla0: sys$output +$assign nla0: sys$error +$search compile_these.list " ''name' "/OUTPUT=NLA0: +$stat1 = $status +$deassign sys$output +$deassign sys$error +$if stat1.ne.1 then goto loop +$! +$set ver +$gcc/plus/debug/nolist/define="__OPTIMIZE__" 'name'.CC +$lib ilib 'name' +$! 'f$verify(0) +$if $status then delete/nolog 'name'.obj; +$goto loop +$done: +$delete/nolog compile_these.list; +$! +$! +$tloop: +$filenm = f$search("t*.cc") +$name = f$parse(filenm,,,"NAME") +$if filenm.eqs."" then goto tdone +$set ver +$gcc/plus/debug/nolist/define=("unlink=remove") - + 'name'.CC +$cxshare 'name'+ilib/lib/nomap +$! 'f$verify(0) +$delete/nolog 'name'.obj; +$goto tloop +$tdone: +$! +$! +$open ofile$ run.com/write +$write ofile$ "$set nover" +$write ofile$ "$set default "+f$parse(flnm,,,"DEVICE") - + +f$parse(flnm,,,"DIRECTORY")-".VMS]"+".TESTS]" +$OPEN IFILE$ [-.vms]EXPECTED.LIST +$rloop: +$ read/end=finish ifile$ line +$ write ofile$ "$write sys$output ""''line'""" +$ write ofile$ "$run ''line'" +$ inp=f$search("''line'.INP",1) +$ if inp.eqs."" then goto rloop +$ open jfile$ 'line'.INP +$rloop1: +$ read jfile$/end=rdone line +$ write ofile$ line +$ goto rloop1 +$rdone: +$ close jfile$ +$goto rloop +$finish: +$close ofile$ +$close ifile$ +$write sys$output "Test suite is finished. Submit the command file RUN.COM" +$write sys$output "to a batch queue, and compare the output to the file" +$write sys$output "EXPECTED.VMS" +$! +$! and go home again. +$! +$set def [-.vms] diff --git a/gnu/lib/libg++/libg++/vms/VMS_FIXINCLUDES.TPU b/gnu/lib/libg++/libg++/vms/VMS_FIXINCLUDES.TPU new file mode 100644 index 00000000000..0bf4c2f4398 --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/VMS_FIXINCLUDES.TPU @@ -0,0 +1,53 @@ + + PROCEDURE vms_include_fix ( + oldstring, ! + newstring) ! + LOCAL range2, count ; + position (beginning_of (current_buffer)) ; + count := 0 ; + LOOP + range2 := search_quietly (LINE_BEGIN & "#include" & SPAN(" ") + & newstring, FORWARD, EXACT) ; + IF (range2 <> 0) THEN + message("This file has already been fixed."); + exit; + endif; + range2 := search_quietly (LINE_BEGIN & "#include" & SPAN(" ") + & oldstring, FORWARD, EXACT) ; + EXITIF range2 = 0 ; + position (beginning_of (range2)) ; + copy_text ("#ifdef VMS"); + split_line; + copy_text ("#include "); + copy_text (newstring) ; + split_line; + copy_text ("#else"); + split_line; + move_vertical(1); + copy_text ("#endif"); + split_line; + count := count + 1 ; + ENDLOOP ; + IF (count > 0) THEN + message (fao('Replaced pattern !UL time!%S', count)) ; + ENDIF ; + ENDPROCEDURE ; + + old_string := read_line ("old pattern: ") ; + new_string := read_line ("new string: ") ; + filename := GET_INFO (COMMAND_LINE, 'file_name') ; + LOOP + exp_filename := FILE_SEARCH (filename) ; + EXITIF exp_filename = "" ; + mainbuffer := CREATE_BUFFER (exp_filename, exp_filename) ; + position (mainbuffer) ; + vms_include_fix ("",""); + vms_include_fix ("",""); + vms_include_fix ("",""); + IF get_info (mainbuffer, "modified") THEN + write_file (mainbuffer) + ELSE + message ('No changes made.') ENDIF ; + delete (mainbuffer) ; + ENDLOOP ; + quit ; diff --git a/gnu/lib/libg++/libg++/vms/_G_config.h b/gnu/lib/libg++/libg++/vms/_G_config.h new file mode 100644 index 00000000000..429a06814be --- /dev/null +++ b/gnu/lib/libg++/libg++/vms/_G_config.h @@ -0,0 +1,44 @@ +/* This file is generated by hand, since the shell script will not run + * under VMS. I hope that someday something more automatic can be created. + */ +#ifndef _G_config_h +#define _G_config_h +#define _G_NAMES_HAVE_UNDERSCORE 1 +#define _G_DOLLAR_IN_LABEL 0 +#define _G_HAVE_ST_BLKSIZE 0 +#define _G_clock_t long +#define _G_dev_t char * +#define _G_fpos_t long +#define _G_gid_t long +#define _G_ino_t unsigned short +#define _G_mode_t unsigned long +#define _G_nlink_t unsigned long +#define _G_off_t long +#define _G_pid_t long +#define _G_ptrdiff_t int +#define _G_size_t unsigned int +#define _G_time_t long int +#define _G_uid_t unsigned short +#define _G_wchar_t long int +#define _G_ssize_t long /* deduced */ +/* #define _G_NEED_STDARG_H */ +#define _G_va_list char* /* default */ +#define _G_signal_return_type int +#define _G_sprintf_return_type int +#define _G_BUFSIZ 512 +#define _G_FOPEN_MAX 32 /* default */ +#define _G_FILENAME_MAX 1024 /* default */ +#define _G_NULL 0 /* default */ +#ifdef _G_USE_PROTOS +#define _G_ARGS(ARGLIST) ARGLIST +#else +#define _G_ARGS(ARGLIST) (...) +#endif +/* #define _G_SYSV */ +#define _G_HAVE_SYS_RESOURCE 1 +#define _G_HAVE_SYS_SOCKET 1 +#define _G_HAVE_UNISTD 0 +#define _G_HAVE_DIRENT 0 +#define _G_BROKEN_SIGNED_CHAR +#define _G_FRIEND_BUG +#endif /* !_G_config_h */ diff --git a/gnu/lib/libg++/libiberty/COPYING.LIB b/gnu/lib/libg++/libiberty/COPYING.LIB new file mode 100644 index 00000000000..eb685a5ec98 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/ChangeLog b/gnu/lib/libg++/libiberty/ChangeLog new file mode 100644 index 00000000000..b5d5e031bb5 --- /dev/null +++ b/gnu/lib/libg++/libiberty/ChangeLog @@ -0,0 +1,1695 @@ +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/gnu/lib/libg++/libiberty/Makefile.in b/gnu/lib/libg++/libiberty/Makefile.in new file mode 100644 index 00000000000..39c33eb78b6 --- /dev/null +++ b/gnu/lib/libg++/libiberty/Makefile.in @@ -0,0 +1,315 @@ +# +# Makefile +# Copyright (C) 1990, 1991, 1992, 1995 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)/lib + +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 +oldincludedir = +docdir = $(datadir)/doc + +SHELL = /bin/sh + +# Multilib support variables. +MULTITOP = . +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)" \ + "INCDIR=$(INCDIR)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LOADLIBES=$(LOADLIBES)" \ + "PICFLAG=$(PICFLAG)" \ + "RANLIB=$(RANLIB)" \ + "SHELL=$(SHELL)" + +all: stamp-picdir $(TARGETLIB) + @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)/../include + +COMPILE.c = $(CC) -c $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) +.c.o: + [ -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 basename.c bcmp.c bcopy.c bzero.c \ + clock.c concat.c cplus-dem.c fdmatch.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 \ + 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 xstrerror.c +# These are always included in the library. +REQUIRED_OFILES = argv.o basename.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 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)/$(TARGETLIB) + +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. + +needed-list: stamp-picdir $(NEEDED_LIST) + cp $(NEEDED_LIST) needed-list + +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 + +config.h: $(CONFIG_H) + cp $(CONFIG_H) config.h + +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 + +$(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 + rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir + @$(MULTICLEAN) multi-clean DO=mostlyclean +clean: mostlyclean + rm -f *.a + @$(MULTICLEAN) multi-clean DO=clean +distclean: clean + rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS + @$(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 +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 +obstack.o: $(INCDIR)/obstack.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 +xstrerror.o: $(INCDIR)/libiberty.h diff --git a/gnu/lib/libg++/libiberty/README b/gnu/lib/libg++/libiberty/README new file mode 100644 index 00000000000..5081bbac196 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/alloca-botch.h b/gnu/lib/libg++/libiberty/alloca-botch.h new file mode 100644 index 00000000000..c909573f58c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/alloca-norm.h b/gnu/lib/libg++/libiberty/alloca-norm.h new file mode 100644 index 00000000000..8d91b5ad429 --- /dev/null +++ b/gnu/lib/libg++/libiberty/alloca-norm.h @@ -0,0 +1,16 @@ +/* "Normal" configuration for alloca. */ + +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else /* not __GNUC__ */ +#ifdef sparc +#include +extern char *__builtin_alloca(); /* Stupid include file doesn't declare it */ +#else +#ifdef __STDC__ +PTR alloca (size_t); +#else +PTR alloca (); /* must agree with functions.def */ +#endif +#endif /* sparc */ +#endif /* not __GNUC__ */ diff --git a/gnu/lib/libg++/libiberty/alloca.c b/gnu/lib/libg++/libiberty/alloca.c new file mode 100644 index 00000000000..9c472ead6df --- /dev/null +++ b/gnu/lib/libg++/libiberty/alloca.c @@ -0,0 +1,475 @@ +/* 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__ +typedef void *pointer; +#else +typedef char *pointer; +#endif + +#define NULL 0 + +/* 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) + 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. */ + + 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/gnu/lib/libg++/libiberty/argv.c b/gnu/lib/libg++/libiberty/argv.c new file mode 100644 index 00000000000..40582abe408 --- /dev/null +++ b/gnu/lib/libg++/libiberty/argv.c @@ -0,0 +1,328 @@ +/* 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" + +#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__ */ + +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 /* __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/gnu/lib/libg++/libiberty/basename.c b/gnu/lib/libg++/libiberty/basename.c new file mode 100644 index 00000000000..689b0c2d39a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/bcmp.c b/gnu/lib/libg++/libiberty/bcmp.c new file mode 100644 index 00000000000..11e4417db15 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/bcopy.c b/gnu/lib/libg++/libiberty/bcopy.c new file mode 100644 index 00000000000..b655363d879 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/bzero.c b/gnu/lib/libg++/libiberty/bzero.c new file mode 100644 index 00000000000..d01644b7f4b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/clock.c b/gnu/lib/libg++/libiberty/clock.c new file mode 100644 index 00000000000..b60de1657a4 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/concat.c b/gnu/lib/libg++/libiberty/concat.c new file mode 100644 index 00000000000..5b132c85764 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config.table b/gnu/lib/libg++/libiberty/config.table new file mode 100644 index 00000000000..a25a2674faa --- /dev/null +++ b/gnu/lib/libg++/libiberty/config.table @@ -0,0 +1,73 @@ +# This file is used by both libiberty/configure.in and xiberty/configure.in. + +case "${xhost-${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[345]86-ncr-sysv4*) frag=mh-ncr3000 ;; + *-*-cxux7*) frag=mh-cxux7 ;; + *-*-lynxos*) frag=mh-lynxos ;; + *-*-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-*-win32) frag=mh-i386win32 ;; + + *-*-vxworks5*) + # VxWorks 5 needs special action when it is a target (xiberty), + # because the usual autoconfiguration scheme does not work. + if [ x${xhost} = x${target} ]; then + frag=mt-vxworks5 + fi + ;; +esac + +# xiberty sets xhost. Try to handle funky case of solaris 2 -> sun 4. +case "${target}" in + sparc-sun-sunos4.1.3) + if [ "${host}" != "${target}" ] ; then + frag=mt-sunos4 + fi + ;; +esac + +frags=$frag + +# If they didn't specify --enable-shared, don't generate shared libs. +if [ "${enable_shared}" = "yes" ]; then + if [ -n "${xhost}" ]; then + xhost_cpu=${target_cpu} + else + xhost_cpu=${host_cpu} + fi + case "${xhost-${host}}" in + hppa*-*-*) frags="${frags} ../../config/mh-papic" ;; + i[345]86-*-*) frags="${frags} ../../config/mh-x86pic" ;; + *-*-*) frags="${frags} ../../config/mh-${xhost_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 +${moveifchange} temp-frag xhost-mkfrag diff --git a/gnu/lib/libg++/libiberty/config/mh-a68bsd b/gnu/lib/libg++/libiberty/config/mh-a68bsd new file mode 100644 index 00000000000..3c5a237e60b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mh-aix b/gnu/lib/libg++/libiberty/config/mh-aix new file mode 100644 index 00000000000..c7b848d976a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mh-apollo68 b/gnu/lib/libg++/libiberty/config/mh-apollo68 new file mode 100644 index 00000000000..651770ce31c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mh-cxux7 b/gnu/lib/libg++/libiberty/config/mh-cxux7 new file mode 100644 index 00000000000..6d4d30bf46f --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-cxux7 @@ -0,0 +1,3 @@ +HDEFINES = -DHAVE_SYSCONF -DHARRIS_FLOAT_FORMAT +RANLIB=true +INSTALL = cp diff --git a/gnu/lib/libg++/libiberty/config/mh-go32 b/gnu/lib/libg++/libiberty/config/mh-go32 new file mode 100644 index 00000000000..7c9fe4fa0bf --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-go32 @@ -0,0 +1,4 @@ +HDEFINES=-DHAVE_GETRUSAGE +CC=i386-go32-gcc -O2 -fno-omit-frame-pointer +AR=i386-go32-ar +RANLIB=i386-go32-ranlib diff --git a/gnu/lib/libg++/libiberty/config/mh-hpbsd b/gnu/lib/libg++/libiberty/config/mh-hpbsd new file mode 100644 index 00000000000..ce11dcd6ac9 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-hpbsd @@ -0,0 +1,2 @@ +# HPPA hosts using BSD +RANLIB=true diff --git a/gnu/lib/libg++/libiberty/config/mh-hpux b/gnu/lib/libg++/libiberty/config/mh-hpux new file mode 100644 index 00000000000..ed4a269b265 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-hpux @@ -0,0 +1 @@ +EXTRA_OFILES = alloca.o diff --git a/gnu/lib/libg++/libiberty/config/mh-i386win32 b/gnu/lib/libg++/libiberty/config/mh-i386win32 new file mode 100644 index 00000000000..6b0856965f7 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-i386win32 @@ -0,0 +1,5 @@ +HDEFINES=-DHAVE_GETRUSAGE +CC=i386-win32-gcc -O2 +AR=i386-win32-ar +RANLIB=i386-win32-ranlib +CFLAGS= diff --git a/gnu/lib/libg++/libiberty/config/mh-irix4 b/gnu/lib/libg++/libiberty/config/mh-irix4 new file mode 100644 index 00000000000..ace76782712 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-irix4 @@ -0,0 +1,4 @@ +CC = cc -cckr +RANLIB = true +INSTALL = cp +EXTRA_OFILES = alloca.o diff --git a/gnu/lib/libg++/libiberty/config/mh-lynxos b/gnu/lib/libg++/libiberty/config/mh-lynxos new file mode 100644 index 00000000000..2f22110e880 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-lynxos @@ -0,0 +1 @@ +HDEFINES = -DLOSING_SYS_SIGLIST diff --git a/gnu/lib/libg++/libiberty/config/mh-ncr3000 b/gnu/lib/libg++/libiberty/config/mh-ncr3000 new file mode 100644 index 00000000000..3a45c22b128 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mh-riscix b/gnu/lib/libg++/libiberty/config/mh-riscix new file mode 100644 index 00000000000..0209279de56 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mh-sysv b/gnu/lib/libg++/libiberty/config/mh-sysv new file mode 100644 index 00000000000..eb102d55010 --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-sysv @@ -0,0 +1 @@ +RANLIB=true diff --git a/gnu/lib/libg++/libiberty/config/mh-sysv4 b/gnu/lib/libg++/libiberty/config/mh-sysv4 new file mode 100644 index 00000000000..4d1aa3cd61d --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mh-sysv4 @@ -0,0 +1,3 @@ +HDEFINES = -DHAVE_SYSCONF +RANLIB=true +INSTALL = cp diff --git a/gnu/lib/libg++/libiberty/config/mt-sunos4 b/gnu/lib/libg++/libiberty/config/mt-sunos4 new file mode 100644 index 00000000000..c25baa6ead6 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/config/mt-vxworks5 b/gnu/lib/libg++/libiberty/config/mt-vxworks5 new file mode 100644 index 00000000000..f1a46d361ae --- /dev/null +++ b/gnu/lib/libg++/libiberty/config/mt-vxworks5 @@ -0,0 +1,27 @@ +# 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 +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_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 sigsetmask.o waitpid.o >vxneeded-list; \ + fi diff --git a/gnu/lib/libg++/libiberty/configure.bat b/gnu/lib/libg++/libiberty/configure.bat new file mode 100644 index 00000000000..ed33777174b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/configure.in b/gnu/lib/libg++/libiberty/configure.in new file mode 100644 index 00000000000..7cd9057bf9d --- /dev/null +++ b/gnu/lib/libg++/libiberty/configure.in @@ -0,0 +1,63 @@ +# 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=getopt1.c +srcname="-liberty library" + +# per-host: + +files="alloca-norm.h" +links="alloca-conf.h" + +xhost=${target} +. ${srcdir}/config.table +host_makefile_frag=${frag} + +# per-target: + +# post-target: + +# 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.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_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! +sed -e "/^####/ r Makefile.tem" \ + -e '/INSTALL_DEST =/s/libdir/tooldir/' ${Makefile} > Makefile.tem3 +mv Makefile.tem3 ${Makefile} +rm -f Makefile.tem +fi + +if [ "${srcdir}" = "." ] ; then + echo "EXTRA_LINKS = ${source_links}" >>Makefile +fi + +# We need multilib support. +. ${srcdir}/../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libiberty/copysign.c b/gnu/lib/libg++/libiberty/copysign.c new file mode 100644 index 00000000000..0b5f8c3d9df --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/cplus-dem.c b/gnu/lib/libg++/libiberty/cplus-dem.c new file mode 100644 index 00000000000..a59e254aa9e --- /dev/null +++ b/gnu/lib/libg++/libiberty/cplus-dem.c @@ -0,0 +1,3001 @@ +/* Demangler for GNU C++ + Copyright 1989, 1991, 1994, 1995 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. */ + +#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)); + +char * +mystrstr (s1, s2) + char *s1, *s2; +{ + register 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 +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) + 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. */ + +char * +cplus_mangle_opname (opname, options) + 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 ((char *)optable[i].in); + } + return (0); +} + +/* check to see whether MANGLED can match TEXT in the first TEXT_LEN + characters. */ + +int cplus_match (mangled, text, text_len) + const char *mangled; + char *text; + int text_len; +{ + if (strncmp (mangled, text, text_len) != 0) { + return(0); /* cannot match either */ + } else { + return(1); /* matches mangled, may match demangled */ + } +} + +/* 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, "::"); + 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; + 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); + string_appendn (tname, *mangled, r); + *mangled += r; + string_append (tname, "<"); + /* 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; + 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': /* ??? */ + 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) + { + if (!get_count (mangled, &symbol_len)) + { + success = 0; + break; + } + string_appendn (tname, *mangled, symbol_len); + *mangled += symbol_len; + } + } + need_comma = 1; + } + 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, "::"); + 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, "::"); + (*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, "::"); + 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 + { + 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_appendn (&temp, "::", 2); + } + } + + /* 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_appendn (&temp, "::", 2); + 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_appendn (&temp, "::", 2); + } + 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)++; + 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)) + { + success = 0; + break; + } + n = consume_count (mangled); + if (strlen (*mangled) < n) + { + success = 0; + break; + } + string_append (&decl, ")"); + string_prepend (&decl, "::"); + string_prependn (&decl, *mangled, n); + string_prepend (&decl, "("); + *mangled += n; + 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; + 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 + +static void +demangle_it (mangled_name) + char *mangled_name; +{ + char *result; + + result = cplus_demangle (mangled_name, DMGL_PARAMS | DMGL_ANSI); + if (result == NULL) + { + printf ("%s\n", mangled_name); + } + else + { + printf ("%s\n", result); + free (result); + } +} + +#include "getopt.h" + +static char *program_name; +static char *program_version = VERSION; + +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'}, + {"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:", 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 '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, + DMGL_PARAMS | DMGL_ANSI); + 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/gnu/lib/libg++/libiberty/dummy.c b/gnu/lib/libg++/libiberty/dummy.c new file mode 100644 index 00000000000..08da647e30e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/fdmatch.c b/gnu/lib/libg++/libiberty/fdmatch.c new file mode 100644 index 00000000000..7af039f5a2b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/floatformat.c b/gnu/lib/libg++/libiberty/floatformat.c new file mode 100644 index 00000000000..655f4ea9264 --- /dev/null +++ b/gnu/lib/libg++/libiberty/floatformat.c @@ -0,0 +1,385 @@ +/* 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 +}; + +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; +} + +/* 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; + + 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; + exponent -= fmt->exp_bias; + + /* Build the result algebraically. Might go infinite, underflow, etc; + who cares. */ + while (mant_bits_left > 0) + { + int exp_bits; + exp_bits = mant_bits_left < 32 ? mant_bits_left : 32; + if (mant_bits_left == fmt->man_len + && exp_bits == 32 + && fmt->intbit == floatformat_intbit_no) + { + /* If there is no integer bit, we need to get only 31 bits + so we have room for an integer bit that we create. */ + mant_bits = 31; + } + else + mant_bits = exp_bits; + + mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, + mant_off, mant_bits); + if (mant_bits_left == fmt->man_len) + mant |= 0x80000000; + dto += ldexp ((double)mant, exponent - (exp_bits - 1)); + exponent -= exp_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; + memcpy (to, &dto, sizeof (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/gnu/lib/libg++/libiberty/functions.def b/gnu/lib/libg++/libiberty/functions.def new file mode 100644 index 00000000000..d9e9c3795a2 --- /dev/null +++ b/gnu/lib/libg++/libiberty/functions.def @@ -0,0 +1,65 @@ +/* + * 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(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 ) + +/* 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) diff --git a/gnu/lib/libg++/libiberty/getcwd.c b/gnu/lib/libg++/libiberty/getcwd.c new file mode 100644 index 00000000000..60c1dd84eed --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/getopt.c b/gnu/lib/libg++/libiberty/getopt.c new file mode 100644 index 00000000000..458dca22b44 --- /dev/null +++ b/gnu/lib/libg++/libiberty/getopt.c @@ -0,0 +1,757 @@ +/* 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 (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/gnu/lib/libg++/libiberty/getopt1.c b/gnu/lib/libg++/libiberty/getopt1.c new file mode 100644 index 00000000000..c3400e5b643 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/getpagesize.c b/gnu/lib/libg++/libiberty/getpagesize.c new file mode 100644 index 00000000000..e9784b8520b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/getruntime.c b/gnu/lib/libg++/libiberty/getruntime.c new file mode 100644 index 00000000000..1be3b4c4a2a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/hex.c b/gnu/lib/libg++/libiberty/hex.c new file mode 100644 index 00000000000..3a2eef03d4c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/index.c b/gnu/lib/libg++/libiberty/index.c new file mode 100644 index 00000000000..e5a00f54d94 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/insque.c b/gnu/lib/libg++/libiberty/insque.c new file mode 100644 index 00000000000..775019f8fff --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/makefile.dos b/gnu/lib/libg++/libiberty/makefile.dos new file mode 100644 index 00000000000..7eba62c3395 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/memchr.c b/gnu/lib/libg++/libiberty/memchr.c new file mode 100644 index 00000000000..93ef43d3f88 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/memcmp.c b/gnu/lib/libg++/libiberty/memcmp.c new file mode 100644 index 00000000000..127ae0c8019 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/memcpy.c b/gnu/lib/libg++/libiberty/memcpy.c new file mode 100644 index 00000000000..c28208a0f7e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/memmove.c b/gnu/lib/libg++/libiberty/memmove.c new file mode 100644 index 00000000000..818fc249662 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/memset.c b/gnu/lib/libg++/libiberty/memset.c new file mode 100644 index 00000000000..5f54831e83c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/mpw-config.in b/gnu/lib/libg++/libiberty/mpw-config.in new file mode 100644 index 00000000000..829d8e730d4 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/mpw-make.sed b/gnu/lib/libg++/libiberty/mpw-make.sed new file mode 100644 index 00000000000..53ed03bda4d --- /dev/null +++ b/gnu/lib/libg++/libiberty/mpw-make.sed @@ -0,0 +1,49 @@ +# 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. +/^###$/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} {DepDir}{Default}.c {LIBCFLAGS} {INCLUDES} {HDEFINES} @SEGMENT_FLAG@ -o {TargDir}{Default}.c.o\ + +# Remove dependency on needed-list, which we don't use. +/DO_ALSO =/s/needed-list// + +/INCDIR=/s/"{srcdir}":/"{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/gnu/lib/libg++/libiberty/mpw.c b/gnu/lib/libg++/libiberty/mpw.c new file mode 100644 index 00000000000..c1106048729 --- /dev/null +++ b/gnu/lib/libg++/libiberty/mpw.c @@ -0,0 +1,996 @@ +/* MPW-Unix compatibility library. + Copyright (C) 1993, 1994, 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. */ + +/* This should only be compiled and linked under MPW. */ + +#include "mpw.h" + +#include + +#ifndef USE_MW_HEADERS +#include +#include +#endif + +#include +#include + +/* Initialize to 0 at first, then set to errno_max() later. */ + +int sys_nerr = 0; + +int DebugPI = 0; + +void mpw_abort (void); + +void +mpwify_filename(char *unixname, char *macname) +{ + int i, j, in_middle, terminate = 0; + + /* (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); + terminate = 1; + } + /* Abs Unix path to abs Mac path. */ + if (*unixname == '/') + { + if (strncmp (unixname, "/tmp/", 6) == 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. */ + strncpy (macname, unixname, 255); + if (terminate) + macname[255] = '\0'; + macname[0] = ':'; + macname[4] = '_'; + } + else + { + /* Assume that the leading component is a valid disk name. */ + strncpy (macname, unixname + 1, 255); + } + } + else + { + /* If this is a "Unix-only" pathname, assume relative. */ + if (strchr (unixname, '/') && ! strchr (unixname, ':')) + { + macname[0] = ':'; + strncpy (macname + 1, unixname, 255); + } + else + { + /* Otherwise copy it verbatim. */ + /* ... but if of the form ":/foo", lose the extra colon; + the slash will be made into a colon shortly. */ + if (unixname[0] == ':' && unixname[1] == '/') + ++unixname; + strncpy (macname, unixname, 255); + } + } + if (terminate) + macname[255] = '\0'; + for (i = 0; macname[i] != '\0'; ++i) + { + if (macname[i] == '/') + macname[i] = ':'; + } + in_middle = 0; + j = 0; + for (i = 0; macname[i] != '\0'; ++i) + { + /* We're in the middle of the name when a char is not a colon. */ + if (macname[i] != ':') + in_middle = 1; + /* Copy chars verbatim, *unless* the char is the first of a pair + of colons in the middle of a pathname. */ + if (!(in_middle && macname[i] == ':' && macname[i+1] == ':')) + macname[j++] = macname[i]; + } + macname[j] = '\0'; + /* If we have a trailing ":.", make it into a ":". */ + if (j >= 2 && macname[j-2] == ':' && macname[j-1] == '.') + macname[j-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) + 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 + + char tmpname[256]; + + mpwify_filename (filename, tmpname); + return open (tmpname, arg2); +} + +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 (DebugPI) + fprintf (stderr, "# mpw_access (%s, %d)", tmpname, cmd); + 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, " -> %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 ((const char *) "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/gnu/lib/libg++/libiberty/msdos.c b/gnu/lib/libg++/libiberty/msdos.c new file mode 100644 index 00000000000..923e64d4ede --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/obstack.c b/gnu/lib/libg++/libiberty/obstack.c new file mode 100644 index 00000000000..05bf16e0ccd --- /dev/null +++ b/gnu/lib/libg++/libiberty/obstack.c @@ -0,0 +1,493 @@ +/* obstack.c - subroutines used implicitly by object stack macros + Copyright (C) 1988, 89, 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 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. */ + +#include "obstack.h" + +/* This is just to get __GNU_LIBRARY__ defined. */ +#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. */ + +/* CYGNUS LOCAL. No, don't comment the code out. We will be using + ../include/obstack.h, which was changed relatively recently in a + way that is not binary compatible. Until we feel confident that + nobody is using the old obstack.c code, force the use of this code. + This issue will arise anytime a change is made which is not binary + compatible. +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) +*/ +#if 1 + + +#ifdef __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)) \ + : (*(h)->chunkfun) ((size))) + +#define CALL_FREEFUN(h, old_chunk) \ + do { \ + if ((h) -> use_extra_arg) \ + (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ + else \ + (*(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. */ + +#ifdef __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. */ + +#ifdef __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 /* _LIBC or not __GNU_LIBRARY__. */ diff --git a/gnu/lib/libg++/libiberty/random.c b/gnu/lib/libg++/libiberty/random.c new file mode 100644 index 00000000000..e205719832b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/rename.c b/gnu/lib/libg++/libiberty/rename.c new file mode 100644 index 00000000000..ae26e2d0040 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/rindex.c b/gnu/lib/libg++/libiberty/rindex.c new file mode 100644 index 00000000000..061d1269f17 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/sigsetmask.c b/gnu/lib/libg++/libiberty/sigsetmask.c new file mode 100644 index 00000000000..2a09e6a6c5a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/spaces.c b/gnu/lib/libg++/libiberty/spaces.c new file mode 100644 index 00000000000..7ea8532d7f6 --- /dev/null +++ b/gnu/lib/libg++/libiberty/spaces.c @@ -0,0 +1,71 @@ +/* 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" + +const char * +spaces (count) + int count; +{ + register char *t; + static char *buf; + static int maxsize; + extern char *malloc (); + extern void free (); + + 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/gnu/lib/libg++/libiberty/strcasecmp.c b/gnu/lib/libg++/libiberty/strcasecmp.c new file mode 100644 index 00000000000..53387ca1b3e --- /dev/null +++ b/gnu/lib/libg++/libiberty/strcasecmp.c @@ -0,0 +1,81 @@ +/* + * 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 +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/gnu/lib/libg++/libiberty/strchr.c b/gnu/lib/libg++/libiberty/strchr.c new file mode 100644 index 00000000000..22976ce248a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strdup.c b/gnu/lib/libg++/libiberty/strdup.c new file mode 100644 index 00000000000..1785b34f274 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strerror.c b/gnu/lib/libg++/libiberty/strerror.c new file mode 100644 index 00000000000..9f3f92b3d1a --- /dev/null +++ b/gnu/lib/libg++/libiberty/strerror.c @@ -0,0 +1,829 @@ +/* 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 + +/* 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/gnu/lib/libg++/libiberty/strncasecmp.c b/gnu/lib/libg++/libiberty/strncasecmp.c new file mode 100644 index 00000000000..4485cac7a6a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strrchr.c b/gnu/lib/libg++/libiberty/strrchr.c new file mode 100644 index 00000000000..30f9e8a3658 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strsignal.c b/gnu/lib/libg++/libiberty/strsignal.c new file mode 100644 index 00000000000..c4dd63c8098 --- /dev/null +++ b/gnu/lib/libg++/libiberty/strsignal.c @@ -0,0 +1,627 @@ +/* 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" + +#ifdef LOSING_SYS_SIGLIST +#define sys_siglist no_such_symbol +#endif + +#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__ */ + +#ifdef LOSING_SYS_SIGLIST +#undef sys_siglist +#endif + + +#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 + +/* 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. + +*/ + +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); +} + + +/* + +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/gnu/lib/libg++/libiberty/strstr.c b/gnu/lib/libg++/libiberty/strstr.c new file mode 100644 index 00000000000..fab36e3fb3d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strtod.c b/gnu/lib/libg++/libiberty/strtod.c new file mode 100644 index 00000000000..c86c73de9b3 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strtol.c b/gnu/lib/libg++/libiberty/strtol.c new file mode 100644 index 00000000000..db27ee0a875 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/strtoul.c b/gnu/lib/libg++/libiberty/strtoul.c new file mode 100644 index 00000000000..40902452fed --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/tmpnam.c b/gnu/lib/libg++/libiberty/tmpnam.c new file mode 100644 index 00000000000..c0614677425 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/vasprintf.c b/gnu/lib/libg++/libiberty/vasprintf.c new file mode 100644 index 00000000000..3794cbd2c4f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/vfork.c b/gnu/lib/libg++/libiberty/vfork.c new file mode 100644 index 00000000000..86c45919f66 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/vfprintf.c b/gnu/lib/libg++/libiberty/vfprintf.c new file mode 100644 index 00000000000..ce3fdf9c474 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/vmsbuild.com b/gnu/lib/libg++/libiberty/vmsbuild.com new file mode 100644 index 00000000000..e1c203f9f47 --- /dev/null +++ b/gnu/lib/libg++/libiberty/vmsbuild.com @@ -0,0 +1,142 @@ +$! 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 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 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 +$ 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;* +$ +$! third pass: compile "missing" modules collected in pass 2 +$ 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'" +$ 'CC' 'f'.c +$ LIBR 'WORK_LIB' 'f'.obj /Insert +$ DELETE 'f'.obj;* +$ i = i + 1 +$ goto oloop +$odone: +$ 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/gnu/lib/libg++/libiberty/vprintf.c b/gnu/lib/libg++/libiberty/vprintf.c new file mode 100644 index 00000000000..63ac53c965a --- /dev/null +++ b/gnu/lib/libg++/libiberty/vprintf.c @@ -0,0 +1,11 @@ +#include +#include +#include +#undef vprintf +int +vprintf (format, ap) + const char *format; + va_list ap; +{ + return vfprintf (stdout, format, ap); +} diff --git a/gnu/lib/libg++/libiberty/vsprintf.c b/gnu/lib/libg++/libiberty/vsprintf.c new file mode 100644 index 00000000000..bf0760cf6d3 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/waitpid.c b/gnu/lib/libg++/libiberty/waitpid.c new file mode 100644 index 00000000000..23db0b932d2 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libiberty/win32.c b/gnu/lib/libg++/libiberty/win32.c new file mode 100644 index 00000000000..b10e2d3170c --- /dev/null +++ b/gnu/lib/libg++/libiberty/win32.c @@ -0,0 +1,64 @@ + +/* Win32-Unix compatibility library. + 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. */ + +/* sac@cygnus.com */ + +/* This should only be compiled and linked under Win32. */ + +#include +#include + +/* + +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). + + +*/ + + +char * +basename (name) + const char *name; +{ + const char *base = name; + + while (*name) + { + if (*name == '/' + || *name == '\\') + { + base = name+1; + } + name++; + } + return (char *) base; +} diff --git a/gnu/lib/libg++/libiberty/xatexit.c b/gnu/lib/libg++/libiberty/xatexit.c new file mode 100644 index 00000000000..7dd27e143f8 --- /dev/null +++ b/gnu/lib/libg++/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) (); + +#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/gnu/lib/libg++/libiberty/xexit.c b/gnu/lib/libg++/libiberty/xexit.c new file mode 100644 index 00000000000..98baeca475d --- /dev/null +++ b/gnu/lib/libg++/libiberty/xexit.c @@ -0,0 +1,36 @@ +/* xexit.c -- Run any exit handlers, then exit. + 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" + +#include + +/* This variable is set by xatexit if it is called. This way, xmalloc + doesn't drag xatexit into the link. */ +void (*_xexit_cleanup) (); + +void +xexit (code) + int code; +{ + if (_xexit_cleanup != NULL) + (*_xexit_cleanup) (); + exit (code); +} diff --git a/gnu/lib/libg++/libiberty/xmalloc.c b/gnu/lib/libg++/libiberty/xmalloc.c new file mode 100644 index 00000000000..95967abe300 --- /dev/null +++ b/gnu/lib/libg++/libiberty/xmalloc.c @@ -0,0 +1,106 @@ +/* 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 +#endif + +/* For systems with larger pointers than ints, these must be declared. */ +PTR malloc PARAMS ((size_t)); +PTR realloc PARAMS ((PTR, size_t)); + +/* 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/gnu/lib/libg++/libiberty/xstrerror.c b/gnu/lib/libg++/libiberty/xstrerror.c new file mode 100644 index 00000000000..d05369ac972 --- /dev/null +++ b/gnu/lib/libg++/libiberty/xstrerror.c @@ -0,0 +1,54 @@ +/* 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 "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/gnu/lib/libg++/libio/ChangeLog b/gnu/lib/libg++/libio/ChangeLog new file mode 100644 index 00000000000..bea01660f93 --- /dev/null +++ b/gnu/lib/libg++/libio/ChangeLog @@ -0,0 +1,1595 @@ +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/gnu/lib/libg++/libio/Makefile.in b/gnu/lib/libg++/libio/Makefile.in new file mode 100644 index 00000000000..37fd2fdb530 --- /dev/null +++ b/gnu/lib/libg++/libio/Makefile.in @@ -0,0 +1,122 @@ +# 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.7.1 +# 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) -o test test.o libio.a +tpipe: tpipe.o libio.a + $(CC) -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: + 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 \ + rm -f $(gxx_includedir)/$$FILE ; \ + $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ + chmod a-x $(gxx_includedir)/$$FILE ; \ + done ; \ + else true; \ + fi + @$(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/gnu/lib/libg++/libio/NEWS b/gnu/lib/libg++/libio/NEWS new file mode 100644 index 00000000000..4a4ade28370 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/PlotFile.cc b/gnu/lib/libg++/libio/PlotFile.cc new file mode 100644 index 00000000000..98b2d839555 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/PlotFile.h b/gnu/lib/libg++/libio/PlotFile.h new file mode 100644 index 00000000000..82b08bc4681 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/README b/gnu/lib/libg++/libio/README new file mode 100644 index 00000000000..c2d564965ca --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/SFile.cc b/gnu/lib/libg++/libio/SFile.cc new file mode 100644 index 00000000000..e5daa645695 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/SFile.h b/gnu/lib/libg++/libio/SFile.h new file mode 100644 index 00000000000..f07277cee49 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/builtinbuf.cc b/gnu/lib/libg++/libio/builtinbuf.cc new file mode 100644 index 00000000000..05e65a5c371 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/builtinbuf.h b/gnu/lib/libg++/libio/builtinbuf.h new file mode 100644 index 00000000000..0e0c6e85a9e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/cleanup.c b/gnu/lib/libg++/libio/cleanup.c new file mode 100644 index 00000000000..b4c8be927f9 --- /dev/null +++ b/gnu/lib/libg++/libio/cleanup.c @@ -0,0 +1,15 @@ +#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; +#endif /* _G_HAVE_ATEXIT */ diff --git a/gnu/lib/libg++/libio/config.shared b/gnu/lib/libg++/libio/config.shared new file mode 100644 index 00000000000..5c8278c9eb5 --- /dev/null +++ b/gnu/lib/libg++/libio/config.shared @@ -0,0 +1,460 @@ +# 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 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}../ +DOING_LIBGXX=${DOING_LIBGXX-false} +THIS_FILE="${srcdir}/${TOLIBGXX}config.shared" + +echo "# Start of package fragment generated by ${THIS_FILE}." +echo "" + +# Multilib support. +echo 'MULTITOP = .' +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. +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}$(MULTITOP)/'${TO_TOPDIR}} +echo '#' TOPDIR="${TOPDIR} invsubdir=${invsubdir} subdir=${subdir}" +SUBDIRS=${SUBDIRS-${configdirs}} + +echo "srcdir = ${srcdir}" +echo "SUBDIRS = ${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 = $(libdir)/g++-include' +echo 'docdir = $(datadir)/doc' +echo '' +echo 'SHELL = /bin/sh' +echo '' +case "$srcdir" in + /*) echo 'INSTALL = $(srcdir)'/"${TO_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`' +echo 'TEXIDIR=${srcdir}/'"${TO_TOPDIR}/texinfo" +echo 'TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi' +echo '' +echo 'CC = cc' +echo 'CXX = g++ -O' +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 -O3' +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./"'$(MULTITOP)'"/${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' +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 ' "RANLIB=$(RANLIB)" \' + echo ' "LIBCFLAGS=$(LIBCFLAGS)" \' + echo ' "LIBCXXFLAGS=$(LIBCXXFLAGS)" \' + echo ' "LOADLIBES=$(LOADLIBES)" \' + echo ' "LDFLAGS=$(LDFLAGS)" \' + echo ' "MAKEINFO=$(MAKEINFO)" \' + echo ' "PICFLAG=$(PICFLAG)"' +fi + +echo 'NOSTDINC = -nostdinc++' +if test -n "${XCXXINCLUDES}" ; then + echo "CXXINCLUDES = ${XCXXINCLUDES} "'$(NOSTDINC)' +elif test "${DOING_LIBGXX}" = "true" ; then + echo 'CXXINCLUDES = $(NOSTDINC) -I. -I$(MULTITOP)/'"${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 ' [ -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 ' [ -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 ' [ -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 [ "${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=$(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} `if test -n "${TOUCH_ON_COMPILE}"; then echo stamp; else true; fi`" +CLEAN="${CLEAN-${TARGETPROG} ${TARGETLIB}}" +DISTCLEAN="${DISTCLEAN-config.status Makefile *~ Make.pack ${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 the removes lines containing only "\\". +# It prepends '$(MULTITOP)/' to relative pathnames to other libg++ dirs. +# 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 + gcc -M $(CXXINCLUDES) $(DEPEND_SOURCES) \ + | sed -e 's|$(srcdir)/|$$(srcdir)/|g' \ + -e 's| /[^ ]*[.]h||g' \ + -e 's| [.]\([^ ]*/libio/[^ ]*[.]h\)| $$(MULTITOP)/.\1|g' \ + -e 's| [.]\([^ ]*/libstdc++/[^ ]*[.]h\)| $$(MULTITOP)/.\1|g' \ + -e '/^[ ]*\\$$/d' -e 's/^[ ]*$$//' \ + | 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/gnu/lib/libg++/libio/config/hpux.mt b/gnu/lib/libg++/libio/config/hpux.mt new file mode 100644 index 00000000000..fc95afa64fa --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/config/isc.mt b/gnu/lib/libg++/libio/config/isc.mt new file mode 100644 index 00000000000..15cbb8c36c2 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/config/linux.mt b/gnu/lib/libg++/libio/config/linux.mt new file mode 100644 index 00000000000..25d29c539a5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/config/netware.mt b/gnu/lib/libg++/libio/config/netware.mt new file mode 100644 index 00000000000..339a865717c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/config/sco4.mt b/gnu/lib/libg++/libio/config/sco4.mt new file mode 100644 index 00000000000..1d8f6f189c3 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/configure.in b/gnu/lib/libg++/libio/configure.in new file mode 100644 index 00000000000..6c03948f8c2 --- /dev/null +++ b/gnu/lib/libg++/libio/configure.in @@ -0,0 +1,78 @@ +# 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="tests dbz stdio" +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 libg++ 2.7.x is not" + echo " compatible with Linux libc through 5.2.x." + echo " YOU ARE ON YOUR OWN!" + frags=linux.mt ;; + *-sco3.2v4*) frags=sco4.mt ;; + *-isc*) frags=isc.mt ;; + *-netware*) frags=netware.mt ;; + *) frags=${target_cpu}.mt ;; +esac + +if [ "${enable_shared}" = "yes" ]; then + case "${target}" in + hppa*-*) frags="${frags} ../../config/mh-papic" ;; + i[345]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 libiostream.a' +XCINCLUDES='-I. -I$(srcdir)' +XCXXINCLUDES='-I. -I$(srcdir)' +MOSTLYCLEAN='*.o pic stamp-picdir core iostream.list' +DISTCLEAN='config.status Makefile *~ Make.pack target-mkfrag' +CLEAN='_G_config.h *.a' +INFO_FILES=iostream +(. ${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 [ ${host} != ${target} ] ; then + rm -f Makefile.tem + sed \ + -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ + Makefile >Makefile.tem + mv -f Makefile.tem Makefile +fi + +# We need multilib support. +. ${srcdir}/../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libio/dbz/Makefile.in b/gnu/lib/libg++/libio/dbz/Makefile.in new file mode 100644 index 00000000000..3f7833be840 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/README b/gnu/lib/libg++/libio/dbz/README new file mode 100644 index 00000000000..e7fa8765ad5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/altbytes b/gnu/lib/libg++/libio/dbz/altbytes new file mode 100644 index 00000000000..26cc9fb9e02 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/byteflip.c b/gnu/lib/libg++/libio/dbz/byteflip.c new file mode 100644 index 00000000000..55fc6d35bf2 --- /dev/null +++ b/gnu/lib/libg++/libio/dbz/byteflip.c @@ -0,0 +1,37 @@ +#include + +#define MAXWORD 32 + +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/gnu/lib/libg++/libio/dbz/case.c b/gnu/lib/libg++/libio/dbz/case.c new file mode 100644 index 00000000000..87b741ff54a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/case.h b/gnu/lib/libg++/libio/dbz/case.h new file mode 100644 index 00000000000..d5ef6961550 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/configure.in b/gnu/lib/libg++/libio/dbz/configure.in new file mode 100644 index 00000000000..4cb9b57ce0f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/dbz.1 b/gnu/lib/libg++/libio/dbz/dbz.1 new file mode 100644 index 00000000000..d2fff17af98 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/dbz.3z b/gnu/lib/libg++/libio/dbz/dbz.3z new file mode 100644 index 00000000000..6df25311c70 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/dbz.c b/gnu/lib/libg++/libio/dbz/dbz.c new file mode 100644 index 00000000000..b8b1886e7e0 --- /dev/null +++ b/gnu/lib/libg++/libio/dbz/dbz.c @@ -0,0 +1,1766 @@ +/* + +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 an offset into a file is a long, not an off_t, for some + * reason. This actually does simplify life a bit, but it's still nice + * to have a distinctive name for it. Beware, this is just for readability, + * don't try to change this. + */ +#define of_t long +#define SOF (sizeof(of_t)) + +/* + * We assume that unused areas of a binary file are zeros, and that the + * bit pattern of `(of_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 ((of_t)0) +#define BIAS(o) ((o)+1) /* make any valid of_t non-VACANT */ +#define UNBIAS(o) ((o)-1) /* reverse BIAS() effect */ + +/* + * In a Unix implementation, or indeed any in which an of_t is a byte + * count, there are a bunch of high bits free in an of_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 of_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 of_t tagbits; /* pre-shifted tag mask */ +static of_t taghere; /* pre-shifted tag-enable bit */ +static of_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 of_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 && (of_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 of_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; +{ + of_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 of_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, (of_t)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 of_t * /* pointer to copy, or NULL */ +getcore(f) +FILE *f; +{ + register of_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 = (of_t *)it + nread; + i = (size_t)conf.tsize - nread; + while (i-- > 0) + *p++ = VACANT; + return((of_t *)it); +} + +/* + - putcore - try to rewrite an in-core table + */ +static int /* 0 okay, -1 fail */ +putcore(tab, f) +of_t *tab; +FILE *f; +{ + if (fseek(f, (of_t)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 of_t /* NOTFOUND if we hit VACANT or error */ +search(sp) +register struct searcher *sp; +{ + register of_t dest; + register of_t value; + of_t val; /* buffer for value (can't fread register) */ + register of_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) +of_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; +of_t value; +{ + register of_t place = sp->place; + register of_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(of_t) of them. The 0th int + * is the byte number of the high-order byte in my of_t, and so forth. + */ +static void +mybytemap(map) +int map[]; /* -> int[SOF] */ +{ + union { + of_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 of_t from byte ordering map1 to map2 + */ +static of_t /* transformed result */ +bytemap(ino, map1, map2) +of_t ino; +int *map1; +int *map2; +{ + union oc { + of_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/gnu/lib/libg++/libio/dbz/dbz.h b/gnu/lib/libg++/libio/dbz/dbz.h new file mode 100644 index 00000000000..3d7e8ed702c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/dbzmain.c b/gnu/lib/libg++/libio/dbz/dbzmain.c new file mode 100644 index 00000000000..77e4100beaf --- /dev/null +++ b/gnu/lib/libg++/libio/dbz/dbzmain.c @@ -0,0 +1,518 @@ +/* + * 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: /home/cvs/src/gnu/lib/libg++/libio/dbz/Attic/dbzmain.c,v 1.1.1.1 1996/03/15 22:19:59 niklas 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 + */ +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/gnu/lib/libg++/libio/dbz/fake.c b/gnu/lib/libg++/libio/dbz/fake.c new file mode 100644 index 00000000000..707be8c105a --- /dev/null +++ b/gnu/lib/libg++/libio/dbz/fake.c @@ -0,0 +1,143 @@ +/* + * 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: /home/cvs/src/gnu/lib/libg++/libio/dbz/Attic/fake.c,v 1.1.1.1 1996/03/15 22:19:59 niklas 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 + */ +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/gnu/lib/libg++/libio/dbz/firstlast25 b/gnu/lib/libg++/libio/dbz/firstlast25 new file mode 100644 index 00000000000..4850468c0c2 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/getmap b/gnu/lib/libg++/libio/dbz/getmap new file mode 100644 index 00000000000..fd746cad7d9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/random.c b/gnu/lib/libg++/libio/dbz/random.c new file mode 100644 index 00000000000..1d8de3a2b44 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/revbytes b/gnu/lib/libg++/libio/dbz/revbytes new file mode 100644 index 00000000000..b3d80c2685f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/dbz/stdio.h b/gnu/lib/libg++/libio/dbz/stdio.h new file mode 100644 index 00000000000..80faee30ad9 --- /dev/null +++ b/gnu/lib/libg++/libio/dbz/stdio.h @@ -0,0 +1 @@ +#include "../iostdio.h" diff --git a/gnu/lib/libg++/libio/depend b/gnu/lib/libg++/libio/depend new file mode 100644 index 00000000000..4fd12739d9f --- /dev/null +++ b/gnu/lib/libg++/libio/depend @@ -0,0 +1,351 @@ + +PlotFile.o: $(srcdir)/PlotFile.cc \ + $(srcdir)/PlotFile.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h +SFile.o: $(srcdir)/SFile.cc \ + $(srcdir)/SFile.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h +builtinbuf.o: $(srcdir)/builtinbuf.cc \ + $(srcdir)/builtinbuf.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/iostreamP.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +editbuf.o: $(srcdir)/editbuf.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/editbuf.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +filebuf.o: $(srcdir)/filebuf.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/builtinbuf.h +fstream.o: $(srcdir)/fstream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +indstream.o: $(srcdir)/indstream.cc \ + $(srcdir)/indstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h +ioassign.o: $(srcdir)/ioassign.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +ioextend.o: $(srcdir)/ioextend.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h +iomanip.o: $(srcdir)/iomanip.cc \ + $(srcdir)/iomanip.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h +iostream.o: $(srcdir)/iostream.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/floatio.h +isgetline.o: $(srcdir)/isgetline.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +isgetsb.o: $(srcdir)/isgetsb.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +isscan.o: $(srcdir)/isscan.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +osform.o: $(srcdir)/osform.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +parsestream.o: $(srcdir)/parsestream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/parsestream.h \ + $(srcdir)/streambuf.h +pfstream.o: $(srcdir)/pfstream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/pfstream.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/procbuf.h +procbuf.o: $(srcdir)/procbuf.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/procbuf.h \ + $(srcdir)/streambuf.h +sbform.o: $(srcdir)/sbform.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/streambuf.h +sbgetline.o: $(srcdir)/sbgetline.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/streambuf.h +sbscan.o: $(srcdir)/sbscan.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/streambuf.h +stdiostream.o: $(srcdir)/stdiostream.cc \ + $(srcdir)/stdiostream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +stdstrbufs.o: $(srcdir)/stdstrbufs.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/stdiostream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +stdstreams.o: $(srcdir)/stdstreams.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/iostream.h +stream.o: $(srcdir)/stream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/stream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/strstream.h \ + $(srcdir)/strfile.h +streambuf.o: $(srcdir)/streambuf.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +strstream.o: $(srcdir)/strstream.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/strstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/strfile.h +cleanup.o: $(srcdir)/cleanup.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +filedoalloc.o: $(srcdir)/filedoalloc.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +fileops.o: $(srcdir)/fileops.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +floatconv.o: $(srcdir)/floatconv.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +genops.o: $(srcdir)/genops.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofclose.o: $(srcdir)/iofclose.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofdopen.o: $(srcdir)/iofdopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofflush.o: $(srcdir)/iofflush.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofgetpos.o: $(srcdir)/iofgetpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofgets.o: $(srcdir)/iofgets.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofopen.o: $(srcdir)/iofopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofprintf.o: $(srcdir)/iofprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofputs.o: $(srcdir)/iofputs.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofread.o: $(srcdir)/iofread.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofscanf.o: $(srcdir)/iofscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofsetpos.o: $(srcdir)/iofsetpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioftell.o: $(srcdir)/ioftell.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iofwrite.o: $(srcdir)/iofwrite.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iogetdelim.o: $(srcdir)/iogetdelim.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iogetline.o: $(srcdir)/iogetline.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iogets.o: $(srcdir)/iogets.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioignore.o: $(srcdir)/ioignore.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iopadn.o: $(srcdir)/iopadn.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioperror.o: $(srcdir)/ioperror.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iopopen.o: $(srcdir)/iopopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioprims.o: $(srcdir)/ioprims.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioprintf.o: $(srcdir)/ioprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioputs.o: $(srcdir)/ioputs.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioscanf.o: $(srcdir)/ioscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioseekoff.o: $(srcdir)/ioseekoff.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +ioseekpos.o: $(srcdir)/ioseekpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iosetbuffer.o: $(srcdir)/iosetbuffer.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iosetvbuf.o: $(srcdir)/iosetvbuf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iosprintf.o: $(srcdir)/iosprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iosscanf.o: $(srcdir)/iosscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iostrerror.o: $(srcdir)/iostrerror.c +ioungetc.o: $(srcdir)/ioungetc.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +iovfprintf.o: $(srcdir)/iovfprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/floatio.h +iovfscanf.o: $(srcdir)/iovfscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/floatio.h +iovsprintf.o: $(srcdir)/iovsprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/strfile.h +iovsscanf.o: $(srcdir)/iovsscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h \ + $(srcdir)/strfile.h +outfloat.o: $(srcdir)/outfloat.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +stdfiles.o: $(srcdir)/stdfiles.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h +strops.o: $(srcdir)/strops.c \ + $(srcdir)/strfile.h \ + $(srcdir)/libio.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h diff --git a/gnu/lib/libg++/libio/editbuf.cc b/gnu/lib/libg++/libio/editbuf.cc new file mode 100644 index 00000000000..22304820f8f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/editbuf.h b/gnu/lib/libg++/libio/editbuf.h new file mode 100644 index 00000000000..d15758f257e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/filebuf.cc b/gnu/lib/libg++/libio/filebuf.cc new file mode 100644 index 00000000000..8f4bdc8a020 --- /dev/null +++ b/gnu/lib/libg++/libio/filebuf.cc @@ -0,0 +1,198 @@ +/* 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 & (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/gnu/lib/libg++/libio/filedoalloc.c b/gnu/lib/libg++/libio/filedoalloc.c new file mode 100644 index 00000000000..6218135eaed --- /dev/null +++ b/gnu/lib/libg++/libio/filedoalloc.c @@ -0,0 +1,104 @@ +/* +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 + +/* If this function pointer is non-zero, we should call it. + It's supposed 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. */ +void (*_IO_cleanup_registration_needed)(); + +/* + * 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) + (*_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/gnu/lib/libg++/libio/fileops.c b/gnu/lib/libg++/libio/fileops.c new file mode 100644 index 00000000000..89381ec6997 --- /dev/null +++ b/gnu/lib/libg++/libio/fileops.c @@ -0,0 +1,738 @@ +/* +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 file_ptr(). + This 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, pbase() is non-NULL and equal to base(). + Also, epptr() == ebuf(). + Also, eback() == gptr() && gptr() == egptr(). + The un-flushed character are those between pbase() and pptr(). + 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, pbase()==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 sync_status, close_status; + if (!_IO_file_is_open(fp)) + return EOF; + + sync_status = _IO_file_sync (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 : sync_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 has 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; + 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. */ + 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/gnu/lib/libg++/libio/floatconv.c b/gnu/lib/libg++/libio/floatconv.c new file mode 100644 index 00000000000..a6183f9e9de --- /dev/null +++ b/gnu/lib/libg++/libio/floatconv.c @@ -0,0 +1,2349 @@ +/* +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). */ + +/* 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 + +#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 + +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 +#ifdef __GNUC__ +#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] +#define word1(x) ((unsigned32 *)&x)[LOWORD] +#define setword0(D,W) word0(D) = (W) +#define setword1(D,W) word1(D) = (W) +#define setwords(D,W0,W1) (setword0(D,W0),setword1(D,W1)) +#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; + d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> (32 - k); + y = xa > xa0 ? *--xa : 0; + d1 = z << k | y >> (32 - k); + } + else { + d0 = Exp_1 | y; + d1 = z; + } + 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; int *e, *bits; +#else + (Bigint *result, double d, int *e, int *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 + + 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 { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; + i = result->wds = 1; + k += 32; + } +#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 +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 +{ + int 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.; + 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. + */ + + int 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/gnu/lib/libg++/libio/floatio.h b/gnu/lib/libg++/libio/floatio.h new file mode 100644 index 00000000000..827767bde35 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/fstream.cc b/gnu/lib/libg++/libio/fstream.cc new file mode 100644 index 00000000000..8930e0b9271 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/fstream.h b/gnu/lib/libg++/libio/fstream.h new file mode 100644 index 00000000000..398cd31d75a --- /dev/null +++ b/gnu/lib/libg++/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 + filebuf __my_fb; +#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 (filebuf*)&__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/gnu/lib/libg++/libio/gen-params b/gnu/lib/libg++/libio/gen-params new file mode 100644 index 00000000000..ff1aefa53e2 --- /dev/null +++ b/gnu/lib/libg++/libio/gen-params @@ -0,0 +1,681 @@ +#!/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 + +# 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=" + /.*typedef *\\(.*[^ ]\\) *X*$t *;.*/{s||\1|;p;q;} + /.*typedef *\\(.*[^ a-zA-Z0-9_]\\)X*$t *;.*/{s||\1|;p;q;} + " + t=`${SED} -n "$sed_script" + 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 + +# Look for some standard macros. +for NAME in BUFSIZ FOPEN_MAX FILENAME_MAX NULL; do + IMPORTED=`eval 'echo $'"$NAME"` + if [ -n "${IMPORTED}" ] ; then + eval "$NAME='$IMPORTED /* specified */" + else + rm -f TMP + ${SED} -n -e 's| *;|;|g' -e "s|long X${NAME}= *\(.*\);|\1|w TMP" \ + /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__))); +#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 + +#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 */} +#define ${macro_prefix}NULL ${NULL-0 /* 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! + +rm -f dummy.c dummy.o dummy.h + +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 + +# 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/gnu/lib/libg++/libio/genops.c b/gnu/lib/libg++/libio/genops.c new file mode 100644 index 00000000000..7eb2d43ee19 --- /dev/null +++ b/gnu/lib/libg++/libio/genops.c @@ -0,0 +1,837 @@ +/* +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) +{ + if (fp->_IO_read_ptr > fp->_IO_read_base + && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c) + { + fp->_IO_read_ptr--; + return (unsigned char)c; + } + return _IO_PBACKFAIL (fp, c); +} + +int +DEFUN(_IO_sungetc, (fp), + register _IO_FILE *fp) +{ + if (fp->_IO_read_ptr > fp->_IO_read_base) + { + fp->_IO_read_ptr--; + return (unsigned char)*fp->_IO_read_ptr; + } + else + return _IO_PBACKFAIL (fp, EOF); +} + +#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/gnu/lib/libg++/libio/indstream.cc b/gnu/lib/libg++/libio/indstream.cc new file mode 100644 index 00000000000..e74f4dbac4f --- /dev/null +++ b/gnu/lib/libg++/libio/indstream.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 + +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()->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) + 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/gnu/lib/libg++/libio/indstream.h b/gnu/lib/libg++/libio/indstream.h new file mode 100644 index 00000000000..6afffdd9bc9 --- /dev/null +++ b/gnu/lib/libg++/libio/indstream.h @@ -0,0 +1,76 @@ +/* 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 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/gnu/lib/libg++/libio/ioassign.cc b/gnu/lib/libg++/libio/ioassign.cc new file mode 100644 index 00000000000..5b8e68bbf53 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioextend.cc b/gnu/lib/libg++/libio/ioextend.cc new file mode 100644 index 00000000000..e0ec0cb6499 --- /dev/null +++ b/gnu/lib/libg++/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 = (void*)0; + } + new_array[0].i = new_length; + new_array[0].p = (void*)0; + 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/gnu/lib/libg++/libio/iofclose.c b/gnu/lib/libg++/libio/iofclose.c new file mode 100644 index 00000000000..f3ae0964e82 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofdopen.c b/gnu/lib/libg++/libio/iofdopen.c new file mode 100644 index 00000000000..f8bc76869ad --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofflush.c b/gnu/lib/libg++/libio/iofflush.c new file mode 100644 index 00000000000..ecb816d4198 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofgetpos.c b/gnu/lib/libg++/libio/iofgetpos.c new file mode 100644 index 00000000000..5e7a8632102 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofgets.c b/gnu/lib/libg++/libio/iofgets.c new file mode 100644 index 00000000000..7b0b708a208 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofopen.c b/gnu/lib/libg++/libio/iofopen.c new file mode 100644 index 00000000000..96910520ce7 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofprintf.c b/gnu/lib/libg++/libio/iofprintf.c new file mode 100644 index 00000000000..11c76421809 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofputs.c b/gnu/lib/libg++/libio/iofputs.c new file mode 100644 index 00000000000..7a2580f7e35 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofread.c b/gnu/lib/libg++/libio/iofread.c new file mode 100644 index 00000000000..8516cf30c14 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofscanf.c b/gnu/lib/libg++/libio/iofscanf.c new file mode 100644 index 00000000000..3e12d9b5315 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofsetpos.c b/gnu/lib/libg++/libio/iofsetpos.c new file mode 100644 index 00000000000..ac8a3deb12d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioftell.c b/gnu/lib/libg++/libio/ioftell.c new file mode 100644 index 00000000000..d49ddaac821 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iofwrite.c b/gnu/lib/libg++/libio/iofwrite.c new file mode 100644 index 00000000000..eb3cd32b028 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iogetdelim.c b/gnu/lib/libg++/libio/iogetdelim.c new file mode 100644 index 00000000000..ee6c0bf1f19 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iogetline.c b/gnu/lib/libg++/libio/iogetline.c new file mode 100644 index 00000000000..278905d135d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iogets.c b/gnu/lib/libg++/libio/iogets.c new file mode 100644 index 00000000000..f45d9c16e3f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioignore.c b/gnu/lib/libg++/libio/ioignore.c new file mode 100644 index 00000000000..a7c2f286755 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iolibio.h b/gnu/lib/libg++/libio/iolibio.h new file mode 100644 index 00000000000..e5de77ea85c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iomanip.cc b/gnu/lib/libg++/libio/iomanip.cc new file mode 100644 index 00000000000..fddba55a2b9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iomanip.h b/gnu/lib/libg++/libio/iomanip.h new file mode 100644 index 00000000000..fe1156569b4 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iopadn.c b/gnu/lib/libg++/libio/iopadn.c new file mode 100644 index 00000000000..0e502b712c3 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioperror.c b/gnu/lib/libg++/libio/ioperror.c new file mode 100644 index 00000000000..55d822b63a6 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iopopen.c b/gnu/lib/libg++/libio/iopopen.c new file mode 100644 index 00000000000..d2030028d1f --- /dev/null +++ b/gnu/lib/libg++/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" +#if _IO_HAVE_SYS_WAIT +#include +#include +#ifdef __STDC__ +#include +#endif +#include +#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, NULL); + _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/gnu/lib/libg++/libio/ioprims.c b/gnu/lib/libg++/libio/ioprims.c new file mode 100644 index 00000000000..faa69e0feff --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioprintf.c b/gnu/lib/libg++/libio/ioprintf.c new file mode 100644 index 00000000000..0b99c2a6637 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioputs.c b/gnu/lib/libg++/libio/ioputs.c new file mode 100644 index 00000000000..f0a81642853 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioscanf.c b/gnu/lib/libg++/libio/ioscanf.c new file mode 100644 index 00000000000..405d1e2eb0f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioseekoff.c b/gnu/lib/libg++/libio/ioseekoff.c new file mode 100644 index 00000000000..06f4b9d2fe1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioseekpos.c b/gnu/lib/libg++/libio/ioseekpos.c new file mode 100644 index 00000000000..1884f9df8f7 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iosetbuffer.c b/gnu/lib/libg++/libio/iosetbuffer.c new file mode 100644 index 00000000000..eb78d75d9ab --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iosetvbuf.c b/gnu/lib/libg++/libio/iosetvbuf.c new file mode 100644 index 00000000000..cc664b41910 --- /dev/null +++ b/gnu/lib/libg++/libio/iosetvbuf.c @@ -0,0 +1,77 @@ +/* +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; + 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_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/gnu/lib/libg++/libio/iosprintf.c b/gnu/lib/libg++/libio/iosprintf.c new file mode 100644 index 00000000000..b873eb4455d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iosscanf.c b/gnu/lib/libg++/libio/iosscanf.c new file mode 100644 index 00000000000..58868778c48 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iostdio.h b/gnu/lib/libg++/libio/iostdio.h new file mode 100644 index 00000000000..8f90d9eedfe --- /dev/null +++ b/gnu/lib/libg++/libio/iostdio.h @@ -0,0 +1,110 @@ +/* +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 remove ??? __P((const char*)) +#define rename ??? __P((const char* _old, const char* _new)) +#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 tmpfile ??? __P((void)) +#define tmpnam ??? __P((char*)) +#define ungetc _IO_ungetc +#define vfprintf _IO_vfprintf +#define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args) +#define vsprintf _IO_vsprintf + +#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/gnu/lib/libg++/libio/iostream.cc b/gnu/lib/libg++/libio/iostream.cc new file mode 100644 index 00000000000..3bdfd59a054 --- /dev/null +++ b/gnu/lib/libg++/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. + 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 + 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/gnu/lib/libg++/libio/iostream.h b/gnu/lib/libg++/libio/iostream.h new file mode 100644 index 00000000000..fc3aaa84dd6 --- /dev/null +++ b/gnu/lib/libg++/libio/iostream.h @@ -0,0 +1,248 @@ +/* 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__) && !defined(__STRICT_ANSI__) + ostream& operator<<(long long n); + 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__) && !defined(__STRICT_ANSI__) + istream& operator>>(long long&); + 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&); +}; + +class _IO_ostream_withassign : public ostream { +public: + _IO_ostream_withassign& operator=(ostream&); +}; + +extern _IO_istream_withassign cin; +// clog->rdbuf() == cerr->rdbuf() +extern _IO_ostream_withassign cout, cerr, clog; + +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/gnu/lib/libg++/libio/iostream.info b/gnu/lib/libg++/libio/iostream.info new file mode 100644 index 00000000000..72e7fab0b18 --- /dev/null +++ b/gnu/lib/libg++/libio/iostream.info @@ -0,0 +1,73 @@ +This is Info file iostream.info, produced by Makeinfo-1.55 from the +input file /kalessin/giga/bothner/dist/devo/libio/iostream.texi. + +START-INFO-DIR-ENTRY +* iostream: (iostream). The C++ input/output facility. +END-INFO-DIR-ENTRY + + 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. + + 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. + + +Indirect: +iostream.info-1: 1033 +iostream.info-2: 50991 + +Tag Table: +(Indirect) +Node: Top1033 +Node: Introduction1519 +Node: Copying2089 +Node: Acknowledgements3302 +Node: Operators4286 +Node: Streams7051 +Node: Ios7533 +Node: States9134 +Node: Format Control12112 +Node: Manipulators17273 +Node: Extending19246 +Node: Synchronization21045 +Node: Streambuf from Ios22359 +Node: Ostream22709 +Node: Writing23843 +Node: Output Position25220 +Node: Ostream Housekeeping26378 +Node: Istream27634 +Node: Char Input29011 +Node: String Input29607 +Node: Input Position33115 +Node: Istream Housekeeping34322 +Node: Iostream36627 +Node: Files and Strings37918 +Node: Files38545 +Node: Strings43169 +Node: Streambuf45748 +Node: Areas46682 +Node: Overflow49181 +Node: Formatting50991 +Node: Stdiobuf52403 +Node: Procbuf53344 +Node: Backing Up54851 +Node: Indirectbuf57116 +Node: Stdio57658 +Node: Index58686 + +End Tag Table diff --git a/gnu/lib/libg++/libio/iostream.info-1 b/gnu/lib/libg++/libio/iostream.info-1 new file mode 100644 index 00000000000..57376cb9963 --- /dev/null +++ b/gnu/lib/libg++/libio/iostream.info-1 @@ -0,0 +1,1367 @@ +This is Info file iostream.info, produced by Makeinfo-1.55 from the +input file /kalessin/giga/bothner/dist/devo/libio/iostream.texi. + +START-INFO-DIR-ENTRY +* iostream: (iostream). The C++ input/output facility. +END-INFO-DIR-ENTRY + + 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. + + 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. + + +File: iostream.info, Node: Top, Next: Introduction, Prev: (DIR), Up: (DIR) + +The GNU C++ Iostream Library +**************************** + + This file provides reference information on the GNU C++ iostream +library (`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:: + + +File: iostream.info, Node: Introduction, Next: Operators, Prev: Top, Up: Top + +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. + + +File: iostream.info, Node: Copying, Next: Acknowledgements, Up: Introduction + +Licensing terms for `libio' +=========================== + + Since the `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 `libio.a': + + 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. + + The code is under the 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 `libg++' library; +if you link with that library instead of `libio', the GNU Library +General Public License applies. + + +File: iostream.info, Node: Acknowledgements, Prev: Copying, Up: Introduction + +Acknowledgements +================ + + Per Bothner wrote most of the `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 `libio' library. An early +version was originally distributed in `libg++', and they are still +included there as well, for convenience if you need other `libg++' +classes. Doug Lea was the original author of `libg++', and some of the +file-management code still in `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. + + +File: iostream.info, Node: Operators, Next: Streams, Prev: Introduction, Up: Top + +Operators and Default Streams +***************************** + + The GNU iostream library, `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 +`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: `<<' for output, and `>>' 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: + + - Variable: ostream cout + The standard output stream, analogous to the C `stdout'. + + - Variable: istream cin + The standard input stream, analogous to the C `stdin'. + + - Variable: ostream cerr + An alternative output stream for errors, analogous to the C + `stderr'. + +For example, this bare-bones C++ version of the traditional "hello" +program uses `<<' and `cout': + + #include + + int main(int argc, char **argv) + { + cout << "Well, hi there.\n"; + return 0; + } + + 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 `good'). *Note +Checking the state of a stream: States. You may also need to adjust +maximum input or output field widths, using manipulators like `setw' or +`setprecision'. + + - Operator on ostream: << + Write output to an open output stream of class `ostream'. Defined + by this library on any 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 `*this' (the open + stream it writes on), permitting statements like + cout << "The value of i is " << i << "\n"; + + - Operator on istream: >> + Read input from an open input stream of class `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 `*this' (the open + stream it reads), permitting multiple inputs in one statement. + + +File: iostream.info, Node: Streams, Next: Files and Strings, Prev: Operators, Up: Top + +Stream Classes +************** + + The previous chapter referred in passing to the classes `ostream' +and `istream', for output and input respectively. These classes share +certain properties, captured in their base class `ios'. + +* Menu: + +* Ios:: Shared properties. +* Ostream:: Managing output streams. +* Istream:: Managing input streams. +* Iostream:: Input and output together. + + +File: iostream.info, Node: Ios, Next: Ostream, Up: Streams + +Shared properties: class `ios' +============================== + + The base class `ios' provides methods to test and manage the state +of input or output streams. + + `ios' delegates the job of actually reading and writing bytes to the +abstract class `streambuf', which is designed to provide buffered +streams (compatible with C, in the GNU implementation). *Note Using +the `streambuf' layer: Streambuf, for information on the facilities +available at the `streambuf' level. + + - Constructor: ios::ios ([streambuf* SB [, ostream* TIE]) + The `ios' constructor by default initializes a new `ios', and if + you supply a `streambuf' SB to associate with it, sets the state + `good' in the new `ios' object. It also sets the default + properties of the new object. + + You can also supply an optional second argument TIE to the + constructor: if present, it is an initial value for `ios::tie', to + associate the new `ios' object with another stream. + + - Destructor: ios::~ios () + The `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. + +* 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. + + +File: iostream.info, Node: States, Next: Format Control, Up: Ios + +Checking the state of a stream +------------------------------ + + Use this collection of methods to test for (or signal) errors and +other exceptional conditions of streams: + + - 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 (`ios::fail' is not true). For example, + you might ask for input on `cin' only if all prior output + operations succeeded: + + if (cout) + { + // Everything OK so far + cin >> new_value; + ... + } + + - Method: ios::operator ! () const + In case it is more convenient to check whether something has + failed, the operator `!' returns true if `ios::fail' is true (an + operation has failed). For example, you might issue an error + message if input failed: + + if (!cin) + { + // Oops + cerr << "Eh?\n"; + } + + - Method: iostate ios::rdstate () const + Return the state flags for this stream. The value is from the + enumeration `iostate'. You can test for any combination of + + `goodbit' + There are no indications of exceptional states on this stream. + + `eofbit' + End of file. + + `failbit' + An operation has failed on this stream; this usually + indicates bad format of input. + + `badbit' + The stream is unusable. + + - Method: void ios::setstate (iostate STATE) + Set the state flag for this stream to STATE *in addition to* any + state flags already set. Synonym (for upward compatibility): + `ios::set'. + + See `ios::clear' to set the stream state without regard to existing + state flags. See `ios::good', `ios::eof', `ios::fail', and + `ios::bad', to test the state. + + - Method: int ios::good () const + Test the state flags associated with this stream; true if no error + indicators are set. + + - Method: int ios::bad () const + Test whether a stream is marked as unusable. (Whether + `ios::badbit' is set.) + + - Method: int ios::eof () const + True if end of file was reached on this stream. (If `ios::eofbit' + is set.) + + - Method: int ios::fail () const + Test for any kind of failure on this stream: *either* some + operation failed, *or* the stream is marked as bad. (If either + `ios::failbit' or `ios::badbit' is set.) + + - Method: void ios::clear (iostate STATE) + Set the state indication for this stream to the argument STATE. + You may call `ios::clear' with no argument, in which case the state + is set to `good' (no errors pending). + + See `ios::good', `ios::eof', `ios::fail', and `ios::bad', to test + the state; see `ios::set' or `ios::setstate' for an alternative + way of setting the state. + + +File: iostream.info, Node: Format Control, Next: Manipulators, Prev: States, Up: Ios + +Choices in formatting +--------------------- + + These methods control (or report on) settings for some details of +controlling streams, primarily to do with formatting output: + + - Method: char ios::fill () const + Report on the padding character in use. + + - Method: char ios::fill (char PADDING) + Set the padding character. You can also use the manipulator + `setfill'. *Note Changing stream properties in expressions: + Manipulators. + + Default: blank. + + - Method: int ios::precision () const + Report the number of significant digits currently in use for + output of floating point numbers. + + Default: `6'. + + - Method: int ios::precision (int SIGNIF) + Set the number of significant digits (for input and output numeric + conversions) to SIGNIF. + + You can also use the manipulator `setprecision' for this purpose. + *Note Changing stream properties using manipulators: Manipulators. + + - Method: int ios::width () const + Report the current output field width setting (the number of + characters to write on the next `<<' output operation). + + Default: `0', which means to use as many characters as necessary. + + - Method: int ios::width (int NUM) + Set the input field width setting to NUM. Return the *previous* + value for this stream. + + This value resets to zero (the default) every time you use `<<'; + it is essentially an additional implicit argument to that + operator. You can also use the manipulator `setw' for this + purpose. *Note Changing stream properties using manipulators: + Manipulators. + + - 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: + + `ios::dec' + `ios::oct' + `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 `setbase', or any of the manipulators `dec', + `oct', or `hex'; *note Changing stream properties in + expressions: Manipulators..) + + On input, if none of these flags is set, read numeric + constants according to the prefix: decimal if no prefix (or a + `.' suffix), octal if a `0' prefix is present, hexadecimal if + a `0x' prefix is present. + + Default: `dec'. + + `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 `ios::precision' to set precision. + + `ios::left' + `ios::right' + `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. + + `ios::scientific' + Use scientific (exponential) notation to display numbers. + + `ios::showbase' + Display the conventional prefix as a visual indicator of the + conversion base: no prefix for decimal, `0' for octal, `0x' + for hexadecimal. + + `ios::showpoint' + Display a decimal point and trailing zeros after it to fill + out numeric fields, even when redundant. + + `ios::showpos' + Display a positive sign on display of positive numbers. + + `ios::skipws' + Skip white space. (On by default). + + `ios::stdio' + Flush the C `stdio' streams `stdout' and `stderr' after each + output operation (for programs that mix C and C++ output + conventions). + + `ios::unitbuf' + Flush after each output operation. + + `ios::uppercase' + Use upper-case characters for the non-numeral elements in + numeric displays; for instance, `0X7A' rather than `0x7a', or + `3.14E+09' rather than `3.14e+09'. + + - Method: fmtflags ios::flags (fmtflags VALUE) + Set VALUE as the complete collection of flags controlling the + format state. The flag values are described under `ios::flags ()'. + + Use `ios::setf' or `ios::unsetf' to change one property at a time. + + - Method: fmtflags ios::setf (fmtflags FLAG) + Set one particular flag (of those described for `ios::flags ()'; + return the complete collection of flags *previously* in effect. + (Use `ios::unsetf' to cancel.) + + - Method: fmtflags ios::setf (fmtflags FLAG, fmtflags MASK) + Clear the flag values indicated by MASK, then set any of them that + are also in FLAG. (Flag values are described for `ios::flags + ()'.) Return the complete collection of flags *previously* in + effect. (See `ios::unsetf' for another way of clearing flags.) + + - Method: fmtflags ios::unsetf (fmtflags FLAG) + Make certain FLAG (a combination of flag values described for + `ios::flags ()') is not set for this stream; converse of + `ios::setf'. Returns the old values of those flags. + + +File: iostream.info, Node: Manipulators, Next: Extending, Prev: Format Control, Up: Ios + +Changing stream properties using manipulators +--------------------------------------------- + + For convenience, MANIPULATORS provide a way to change certain +properties of streams, or otherwise affect them, in the middle of +expressions involving `<<' or `>>'. For example, you might write + + cout << "|" << setfill('*') << setw(5) << 234 << "|"; + +to produce `|**234|' as output. + + - Manipulator: ws + Skip whitespace. + + - Manipulator: flush + Flush an output stream. For example, `cout << ... <'. + + - Manipulator: setw (int N) + You can change the value of `ios::width' in `<<' expressions with + the manipulator `setw(N)'; for example, + + cout << setw(5) << 234; + + prints ` 234' with two leading blanks. Requires `#include + '. + + - Manipulator: setbase (int BASE) + Where BASE is one of `10' (decimal), `8' (octal), or `16' + (hexadecimal), change the base value for numeric representations. + Requires `#include '. + + - Manipulator: dec + Select decimal base; equivalent to `setbase(10)'. + + - Manipulator: hex + Select hexadecimal base; equivalent to `setbase(16)'. + + - Manipulator: oct + Select octal base; equivalent to `setbase(8)'. + + - Manipulator: setfill (char PADDING) + Set the padding character, in the same way as `ios::fill'. + Requires `#include '. + + +File: iostream.info, Node: Extending, Next: Synchronization, Prev: Manipulators, Up: Ios + +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: + + - Method: static fmtflags ios::bitalloc () + Reserve a bit (the single bit on in the result) to use as a flag. + Using `bitalloc' guards against conflict between two packages that + use `ios' objects for different purposes. + + This method is available for upward compatibility, but is not in + the ANSI working paper. The number of bits available is limited; a + return value of `0' means no bit is available. + + - 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 + `ios::iword' or `ios::pword'. Use `xalloc' to arrange for + arbitrary special-purpose data in your `ios' objects, without risk + of conflict between packages designed for different purposes. + + - Method: long& ios::iword (int INDEX) + Return a reference to arbitrary data, of long integer type, stored + in an `ios' instance. INDEX, conventionally returned from + `ios::xalloc', identifies what particular data you need. + + - Method: long ios::iword (int INDEX) const + Return the actual value of a long integer stored in an `ios'. + + - Method: void*& ios::pword (int INDEX) + Return a reference to an arbitrary pointer, stored in an `ios' + instance. INDEX, originally returned from `ios::xalloc', + identifies what particular pointer you need. + + - Method: void* ios::pword (int INDEX) const + Return the actual value of a pointer stored in an `ios'. + + +File: iostream.info, Node: Synchronization, Next: Streambuf from Ios, Prev: Extending, Up: Ios + +Synchronizing related streams +----------------------------- + + You can use these methods to synchronize related streams with one +another: + + - Method: ostream* ios::tie () const + Report on what output stream, if any, is to be flushed before + accessing this one. A pointer value of `0' means no stream is + tied. + + - Method: ostream* ios::tie (ostream* ASSOC) + Declare that output stream ASSOC must be flushed before accessing + this stream. + + - Method: int ios::sync_with_stdio ([int SWITCH]) + Unless iostreams and C `stdio' are designed to work together, you + may have to choose between efficient C++ streams output and output + compatible with C `stdio'. Use `ios::sync_with_stdio()' to select + C compatibility. + + The argument SWITCH is a GNU extension; use `0' as the argument to + choose output that is not necessarily compatible with C `stdio'. + The default value for SWITCH is `1'. + + If you install the `stdio' implementation that comes with GNU + `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. + + +File: iostream.info, Node: Streambuf from Ios, Prev: Synchronization, Up: Ios + +Reaching the underlying `streambuf' +----------------------------------- + + Finally, you can use this method to access the underlying object: + + - Method: streambuf* ios::rdbuf () const + Return a pointer to the `streambuf' object that underlies this + `ios'. + + +File: iostream.info, Node: Ostream, Next: Istream, Prev: Ios, Up: Streams + +Managing output streams: class `ostream' +======================================== + + Objects of class `ostream' inherit the generic methods from `ios', +and in addition have the following methods available. Declarations for +this class come from `iostream.h'. + + - Constructor: ostream::ostream () + The simplest form of the constructor for an `ostream' simply + allocates a new `ios' object. + + - Constructor: ostream::ostream (streambuf* SB [, ostream TIE]) + This alternative constructor requires a first argument SB of type + `streambuf*', to use an existing open stream for output. It also + accepts an optional second argument TIE, to specify a related + `ostream*' as the initial value for `ios::tie'. + + If you give the `ostream' a `streambuf' explicitly, using this + constructor, the SB is *not* destroyed (or deleted or closed) when + the `ostream' is destroyed. + +* Menu: + +* Writing:: Writing on an ostream. +* Output Position:: Repositioning an ostream. +* Ostream Housekeeping:: Miscellaneous ostream utilities. + + +File: iostream.info, Node: Writing, Next: Output Position, Up: Ostream + +Writing on an `ostream' +----------------------- + + These methods write on an `ostream' (you may also use the operator +`<<'; *note Operators and Default Streams: Operators.). + + - Method: ostream& ostream::put (char C) + Write the single character C. + + - Method: ostream& ostream::write (STRING, int LENGTH) + Write LENGTH characters of a string to this `ostream', beginning + at the pointer STRING. + + STRING may have any of these types: `char*', `unsigned char*', + `signed char*'. + + - Method: ostream& ostream::form (const char *FORMAT, ...) + A GNU extension, similar to `fprintf(FILE, FORMAT, ...)'. + + FORMAT is a `printf'-style format control string, which is used to + format the (variable number of) arguments, printing the result on + this `ostream'. See `ostream::vform' for a version that uses an + argument list rather than a variable number of arguments. + + - Method: ostream& ostream::vform (const char *FORMAT, va_list ARGS) + A GNU extension, similar to `vfprintf(FILE, FORMAT, ARGS)'. + + FORMAT is a `printf'-style format control string, which is used to + format the argument list ARGS, printing the result on this + `ostream'. See `ostream::form' for a version that uses a variable + number of arguments rather than an argument list. + + +File: iostream.info, Node: Output Position, Next: Ostream Housekeeping, Prev: Writing, Up: Ostream + +Repositioning an `ostream' +-------------------------- + + You can control the output position (on output streams that actually +support positions, typically files) with these methods: + + - Method: streampos ostream::tellp () + Return the current write position in the stream. + + - Method: ostream& ostream::seekp (streampos LOC) + Reset the output position to LOC (which is usually the result of a + previous call to `ostream::tellp'). LOC specifies an absolute + position in the output stream. + + - Method: ostream& ostream::seekp (streamoff LOC, REL) + Reset the output position to LOC, relative to the beginning, end, + or current output position in the stream, as indicated by REL (a + value from the enumeration `ios::seekdir'): + + `beg' + Interpret LOC as an absolute offset from the beginning of the + file. + + `cur' + Interpret LOC as an offset relative to the current output + position. + + `end' + Interpret LOC as an offset from the current end of the output + stream. + + +File: iostream.info, Node: Ostream Housekeeping, Prev: Output Position, Up: Ostream + +Miscellaneous `ostream' utilities +--------------------------------- + + You may need to use these `ostream' methods for housekeeping: + + - Method: ostream& flush () + Deliver any pending buffered output for this `ostream'. + + - Method: int ostream::opfx () + `opfx' is a "prefix" method for operations on `ostream' objects; + it is designed to be called before any further processing. See + `ostream::osfx' for the converse. + + `opfx' tests that the stream is in state `good', and if so flushes + any stream tied to this one. + + The result is `1' when `opfx' succeeds; else (if the stream state + is not `good'), the result is `0'. + + - Method: void ostream::osfx () + `osfx' is a "suffix" method for operations on `ostream' objects; + it is designed to be called at the conclusion of any processing. + All the `ostream' methods end by calling `osfx'. See + `ostream::opfx' for the converse. + + If the `unitbuf' flag is set for this stream, `osfx' flushes any + buffered output for it. + + If the `stdio' flag is set for this stream, `osfx' flushes any + output buffered for the C output streams `stdout' and `stderr'. + + +File: iostream.info, Node: Istream, Next: Iostream, Prev: Ostream, Up: Streams + +Managing input streams: class `istream' +======================================= + + Class `istream' objects are specialized for input; as for `ostream', +they are derived from `ios', so you can use any of the general-purpose +methods from that base class. Declarations for this class also come +from `iostream.h'. + + - Constructor: istream::istream () + When used without arguments, the `istream' constructor simply + allocates a new `ios' object and initializes the input counter (the + value reported by `istream::gcount') to `0'. + + - Constructor: istream::istream (streambuf *SB [, ostream TIE]) + You can also call the constructor with one or two arguments. The + first argument SB is a `streambuf*'; if you supply this pointer, + the constructor uses that `streambuf' for input. You can use the + second optional argument TIE to specify a related output stream as + the initial value for `ios::tie'. + + If you give the `istream' a `streambuf' explicitly, using this + constructor, the SB is *not* destroyed (or deleted or closed) when + the `ostream' is destroyed. + +* Menu: + +* Char Input:: Reading one character. +* String Input:: Reading strings. +* Input Position:: Repositioning an istream. +* Istream Housekeeping:: Miscellaneous istream utilities. + + +File: iostream.info, Node: Char Input, Next: String Input, Up: Istream + +Reading one character +--------------------- + + Use these methods to read a single character from the input stream: + + - Method: int istream::get () + Read a single character (or `EOF') from the input stream, returning + it (coerced to an unsigned char) as the result. + + - Method: istream& istream::get (char& C) + Read a single character from the input stream, into `&C'. + + - Method: int istream::peek () + Return the next available input character, but *without* changing + the current input position. + + +File: iostream.info, Node: String Input, Next: Input Position, Prev: Char Input, Up: Istream + +Reading strings +--------------- + + Use these methods to read strings (for example, a line at a time) +from the input stream: + + - Method: istream& istream::get (char* C, int LEN [, char DELIM]) + Read a string from the input stream, into the array at C. + + The remaining arguments limit how much to read: up to `len-1' + characters, or up to (but not including) the first occurrence in + the input of a particular delimiter character DELIM--newline + (`\n') by default. (Naturally, if the stream reaches end of file + first, that too will terminate reading.) + + If DELIM was present in the input, it remains available as if + unread; to discard it instead, see `iostream::getline'. + + `get' writes `\0' at the end of the string, regardless of which + condition terminates the read. + + - Method: istream& istream::get (streambuf& SB [, char DELIM]) + Read characters from the input stream and copy them on the + `streambuf' object SB. Copying ends either just before the next + instance of the delimiter character DELIM (newline `\n' by + default), or when either stream ends. If DELIM was present in + the input, it remains available as if unread. + + - Method: istream& istream::getline (CHARPTR, int LEN [, char DELIM]) + Read a line from the input stream, into the array at CHARPTR. + cHARPTR may be any of three kinds of pointer: `char*', `unsigned + char*', or `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 DELIM--newline (`\n') by default, or up to `len-1' + characters (or to end of file, if that happens sooner). + + If `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 + `iostream::get'.) + + If DELIM was *not* found before LEN characters or end of file, + `getline' sets the `ios::fail' flag, as well as the `ios::eof' + flag if appropriate. + + `getline' writes a null character at the end of the string, + regardless of which condition terminates the read. + + - Method: istream& istream::read (POINTER, int LEN) + Read LEN bytes into the location at POINTER, unless the input ends + first. + + POINTER may be of type `char*', `void*', `unsigned char*', or + `signed char*'. + + If the `istream' ends before reading LEN bytes, `read' sets the + `ios::fail' flag. + + - Method: istream& istream::gets (char **S [, char DELIM]) + A GNU extension, to read an arbitrarily long string from the + current input position to the next instance of the DELIM character + (newline `\n' by default). + + To permit reading a string of arbitrary length, `gets' allocates + whatever memory is required. Notice that the first argument S is + an address to record a character pointer, rather than the pointer + itself. + + - Method: istream& istream::scan (const char *format ...) + A GNU extension, similar to `fscanf(FILE, FORMAT, ...)'. The + FORMAT is a `scanf'-style format control string, which is used to + read the variables in the remainder of the argument list from the + `istream'. + + - Method: istream& istream::vscan (const char *format, va_list args) + Like `istream::scan', but takes a single `va_list' argument. + + +File: iostream.info, Node: Input Position, Next: Istream Housekeeping, Prev: String Input, Up: Istream + +Repositioning an `istream' +-------------------------- + + Use these methods to control the current input position: + + - Method: streampos istream::tellg () + Return the current read position, so that you can save it and + return to it later with `istream::seekg'. + + - Method: istream& istream::seekg (streampos P) + Reset the input pointer (if the input device permits it) to P, + usually the result of an earlier call to `istream::tellg'. + + - Method: istream& istream::seekg (streamoff OFFSET, ios::seek_dir REF) + Reset the input pointer (if the input device permits it) to OFFSET + characters from the beginning of the input, the current position, + or the end of input. Specify how to interpret OFFSET with one of + these values for the second argument: + + `ios::beg' + Interpret LOC as an absolute offset from the beginning of the + file. + + `ios::cur' + Interpret LOC as an offset relative to the current output + position. + + `ios::end' + Interpret LOC as an offset from the current end of the output + stream. + + +File: iostream.info, Node: Istream Housekeeping, Prev: Input Position, Up: Istream + +Miscellaneous `istream' utilities +--------------------------------- + + Use these methods for housekeeping on `istream' objects: + + - Method: int istream::gcount () + Report how many characters were read from this `istream' in the + last unformatted input operation. + + - Method: int istream::ipfx (int KEEPWHITE) + Ensure that the `istream' object is ready for reading; check for + errors and end of file and flush any tied stream. `ipfx' skips + whitespace if you specify `0' as the KEEPWHITE argument, *and* + `ios::skipws' is set for this stream. + + To avoid skipping whitespace (regardless of the `skipws' setting on + the stream), use `1' as the argument. + + Call `istream::ipfx' to simplify writing your own methods for + reading `istream' objects. + + - Method: void istream::isfx () + A placeholder for compliance with the draft ANSI standard; this + method does nothing whatever. + + If you wish to write portable standard-conforming code on `istream' + objects, call `isfx' after any operation that reads from an + `istream'; if `istream::ipfx' has any special effects that must be + cancelled when done, `istream::isfx' will cancel them. + + - Method: istream& istream::ignore ([int N] [, int DELIM]) + Discard some number of characters pending input. The first + optional argument N specifies how many characters to skip. The + second optional argument DELIM specifies a "boundary" character: + `ignore' returns immediately if this character appears in the + input. + + By default, DELIM is `EOF'; that is, if you do not specify a + second argument, only the count N restricts how much to ignore + (while input is still available). + + If you do not specify how many characters to ignore, `ignore' + returns after discarding only one character. + + - Method: istream& istream::putback (char CH) + Attempts to back up one character, replacing the character + backed-up over by CH. Returns `EOF' if this is not allowed. + Putting back the most recently read character is always allowed. + (This method corresponds to the C function `ungetc'.) + + - Method: istream& istream::unget () + Attempt to back up one character. + + +File: iostream.info, Node: Iostream, Prev: Istream, Up: Streams + +Input and output together: class `iostream' +=========================================== + + If you need to use the same stream for input and output, you can use +an object of the class `iostream', which is derived from *both* +`istream' and `ostream'. + + The constructors for `iostream' behave just like the constructors +for `istream'. + + - Constructor: iostream::iostream () + When used without arguments, the `iostream' constructor simply + allocates a new `ios' object, and initializes the input counter + (the value reported by `istream::gcount') to `0'. + + - Constructor: iostream::iostream (streambuf* SB [, ostream* TIE]) + You can also call a constructor with one or two arguments. The + first argument SB is a `streambuf*'; if you supply this pointer, + the constructor uses that `streambuf' for input and output. + + You can use the optional second argument TIE (an `ostream*') to + specify a related output stream as the initial value for + `ios::tie'. + + As for `ostream' and `istream', `iostream' simply uses the `ios' +destructor. However, an `iostream' is not deleted by its destructor. + + You can use all the `istream', `ostream', and `ios' methods with an +`iostream' object. + + +File: iostream.info, Node: Files and Strings, Next: Streambuf, Prev: Streams, Up: Top + +Classes for Files and Strings +***************************** + + There are two very common special cases of input and output: using +files, and using strings in memory. + + `libio' defines four specialized classes for these cases: + +`ifstream' + Methods for reading files. + +`ofstream' + Methods for writing files. + +`istrstream' + Methods for reading strings from memory. + +`ostrstream' + Methods for writing strings in memory. + +* Menu: + +* Files:: Reading and writing files. +* Strings:: Reading and writing strings in memory. + + +File: iostream.info, Node: Files, Next: Strings, Up: Files and Strings + +Reading and writing files +========================= + + These methods are declared in `fstream.h'. + + You can read data from class `ifstream' with any operation from class +`istream'. There are also a few specialized facilities: + + - Constructor: ifstream::ifstream () + Make an `ifstream' associated with a new file for input. (If you + use this version of the constructor, you need to call + `ifstream::open' before actually reading anything) + + - Constructor: ifstream::ifstream (int FD) + Make an `ifstream' for reading from a file that was already open, + using file descriptor FD. (This constructor is compatible with + other versions of iostreams for POSIX systems, but is not part of + the ANSI working paper.) + + - Constructor: ifstream::ifstream (const char* FNAME [, int MODE + [, int PROT]]) + Open a file `*FNAME' for this `ifstream' object. + + By default, the file is opened for input (with `ios::in' as MODE). + If you use this constructor, the file will be closed when the + `ifstream' is destroyed. + + You can use the optional argument MODE to specify how to open the + file, by combining these enumerated values (with `|' bitwise or). + (These values are actually defined in class `ios', so that all + file-related streams may inherit them.) Only some of these modes + are defined in the latest draft ANSI specification; if portability + is important, you may wish to avoid the others. + + `ios::in' + Open for input. (Included in ANSI draft.) + + `ios::out' + Open for output. (Included in ANSI draft.) + + `ios::ate' + Set the initial input (or output) position to the end of the + file. + + `ios::app' + Seek to end of file before each write. (Included in ANSI + draft.) + + `ios::trunc' + Guarantee a fresh file; discard any contents that were + previously associated with it. + + `ios::nocreate' + Guarantee an existing file; fail if the specified file did + not already exist. + + `ios::noreplace' + Guarantee a new file; fail if the specified file already + existed. + + `ios::bin' + Open as a binary file (on systems where binary and text files + have different properties, typically how `\n' is mapped; + included in ANSI draft). + + The last optional argument PROT is specific to Unix-like systems; + it specifies the file protection (by default `644'). + + - Method: void ifstream::open (const char* FNAME [, int MODE [, int + PROT]]) + Open a file explicitly after the associated `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 `ifstream' constructor. + + You can write data to class `ofstream' with any operation from class +`ostream'. There are also a few specialized facilities: + + - Constructor: ofstream::ofstream () + Make an `ofstream' associated with a new file for output. + + - Constructor: ofstream::ofstream (int FD) + Make an `ofstream' for writing to a file that was already open, + using file descriptor FD. + + - Constructor: ofstream::ofstream (const char* FNAME [, int MODE + [, int PROT]]) + Open a file `*FNAME' for this `ofstream' object. + + By default, the file is opened for output (with `ios::out' as + MODE). You can use the optional argument MODE to specify how to + open the file, just as described for `ifstream::ifstream'. + + The last optional argument PROT specifies the file protection (by + default `644'). + + - Destructor: ofstream::~ofstream () + The files associated with `ofstream' objects are closed when the + corresponding object is destroyed. + + - Method: void ofstream::open (const char* FNAME [, int MODE [, int + PROT]]) + Open a file explicitly after the associated `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 `ofstream' constructor. + + The class `fstream' combines the facilities of `ifstream' and +`ofstream', just as `iostream' combines `istream' and `ostream'. + + The class `fstreambase' underlies both `ifstream' and `ofstream'. +They both inherit this additional method: + + - Method: void fstreambase::close () + Close the file associated with this object, and set `ios::fail' in + this object to mark the event. + + +File: iostream.info, Node: Strings, Prev: Files, Up: Files and Strings + +Reading and writing in memory +============================= + + The classes `istrstream', `ostrstream', and `strstream' provide some +additional features for reading and writing strings in memory--both +static strings, and dynamically allocated strings. The underlying +class `strstreambase' provides some features common to all three; +`strstreambuf' underlies that in turn. + + - Constructor: istrstream::istrstream (const char* STR [, int SIZE]) + Associate the new input string class `istrstream' with an existing + static string starting at STR, of size SIZE. If you do not + specify SIZE, the string is treated as a `NUL' terminated string. + + - Constructor: ostrstream::ostrstream () + Create a new stream for output to a dynamically managed string, + which will grow as needed. + + - Constructor: ostrstream::ostrstream (char* STR, int SIZE [,int + MODE]) + A new stream for output to a statically defined string of length + SIZE, starting at STR. You may optionally specify one of the + modes described for `ifstream::ifstream'; if you do not specify + one, the new stream is simply open for output, with mode + `ios::out'. + + - Method: int ostrstream::pcount () + Report the current length of the string associated with this + `ostrstream'. + + - Method: char* ostrstream::str () + A pointer to the string managed by this `ostrstream'. Implies + `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). + + - Method: void ostrstream::freeze ([int N]) + If N is nonzero (the default), declare that the string associated + with this `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 `ostrstream' is destroyed. Use + `freeze(1)' if you refer to the string as a pointer after creating + it via `ostrstream' facilities. + + `freeze(0)' cancels this declaration, allowing a dynamically + allocated string to be freed when its `ostrstream' is destroyed. + + If this `ostrstream' is already static--that is, if it was created + to manage an existing statically allocated string--`freeze' is + unnecessary, and has no effect. + + - Method: int ostrstream::frozen () + Test whether `freeze(1)' is in effect for this string. + + - Method: strstreambuf* strstreambase::rdbuf () + A pointer to the underlying `strstreambuf'. + + +File: iostream.info, Node: Streambuf, Next: Stdio, Prev: Files and Strings, Up: Top + +Using the `streambuf' Layer +*************************** + + The `istream' and `ostream' classes are meant to handle conversion +between objects in your program and their textual representation. + + By contrast, the underlying `streambuf' class is for transferring +raw bytes between your program, and input sources or output sinks. +Different `streambuf' subclasses connect to different kinds of sources +and sinks. + + The GNU implementation of `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. + + +File: iostream.info, Node: Areas, Next: Overflow, Up: Streambuf + +Areas of a `streambuf' +====================== + + Streambuf buffer management is fairly sophisticated (this is a nice +way to say "complicated"). The standard protocol has the following +"areas": + + * The "put area" contains characters waiting for output. + + * The "get area" contains characters available for reading. + + The GNU `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 `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.) + + - Method: char* streambuf::pbase () const + Returns a pointer to the start of the put area. + + - Method: char* streambuf::epptr () const + Returns a pointer to the end of the put area. + + - Method: char* streambuf::pptr () const + If `pptr() < epptr ()', the `pptr()' returns a pointer to the + current put position. (In that case, the next write will + overwrite `*pptr()', and increment `pptr()'.) Otherwise, there is + no put position available (and the next character written will + cause `streambuf::overflow' to be called). + + - Method: void streambuf::pbump (int N) + Add N to the current put pointer. No error checking is done. + + - Method: void streambuf::setp (char* P, char* E) + Sets the start of the put area to P, the end of the put area to E, + and the current put pointer to P (also). + + - Method: char* streambuf::eback () const + Returns a pointer to the start of the get area. + + - Method: char* streambuf::egptr () const + Returns a pointer to the end of the get area. + + - Method: char* streambuf::gptr () const + If `gptr() < egptr ()', then `gptr()' returns a pointer to the + current get position. (In that case the next read will read + `*gptr()', and possibly increment `gptr()'.) Otherwise, there is + no read position available (and the next read will cause + `streambuf::underflow' to be called). + + - Method: void streambuf:gbump (int N) + Add N to the current get pointer. No error checking is done. + + - Method: void streambuf::setg (char* B, char* P, char* E) + Sets the start of the get area to B, the end of the get area to E, + and the current put pointer to P. + + +File: iostream.info, Node: Overflow, Next: Formatting, Prev: Areas, Up: Streambuf + +Simple output re-direction by redefining `overflow' +=================================================== + + Suppose you have a function `write_to_window' that writes characters +to a `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). + + #include + /* Returns number of characters successfully written to 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"; + } + diff --git a/gnu/lib/libg++/libio/iostream.info-2 b/gnu/lib/libg++/libio/iostream.info-2 new file mode 100644 index 00000000000..ca46136a286 --- /dev/null +++ b/gnu/lib/libg++/libio/iostream.info-2 @@ -0,0 +1,429 @@ +This is Info file iostream.info, produced by Makeinfo-1.55 from the +input file /kalessin/giga/bothner/dist/devo/libio/iostream.texi. + +START-INFO-DIR-ENTRY +* iostream: (iostream). The C++ input/output facility. +END-INFO-DIR-ENTRY + + 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. + + 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. + + +File: iostream.info, Node: Formatting, Next: Stdiobuf, Prev: Overflow, Up: Streambuf + +C-style formatting for `streambuf' objects +========================================== + + The GNU `streambuf' class supports `printf'-like formatting and +scanning. + + - Method: int streambuf::vform (const char *FORMAT, ...) + Similar to `fprintf(FILE, FORMAT, ...)'. The FORMAT is a + `printf'-style format control string, which is used to format the + (variable number of) arguments, printing the result on the `this' + streambuf. The result is the number of characters printed. + + - Method: int streambuf::vform (const char *FORMAT, va_list ARGS) + Similar to `vfprintf(FILE, FORMAT, ARGS)'. The FORMAT is a + `printf'-style format control string, which is used to format the + argument list ARGS, printing the result on the `this' streambuf. + The result is the number of characters printed. + + - Method: int streambuf::scan (const char *FORMAT, ...) + Similar to `fscanf(FILE, FORMAT, ...)'. The FORMAT is a + `scanf'-style format control string, which is used to read the + (variable number of) arguments from the `this' streambuf. The + result is the number of items assigned, or `EOF' in case of input + failure before any conversion. + + - Method: int streambuf::vscan (const char *FORMAT, va_list ARGS) + Like `streambuf::scan', but takes a single `va_list' argument. + + +File: iostream.info, Node: Stdiobuf, Next: Procbuf, Prev: Formatting, Up: Streambuf + +Wrappers for C `stdio' +====================== + + A "stdiobuf" is a `streambuf' object that points to a `FILE' object +(as defined by `stdio.h'). All `streambuf' operations on the +`stdiobuf' are forwarded to the `FILE'. Thus the `stdiobuf' object +provides a wrapper around a `FILE', allowing use of `streambuf' +operations on a `FILE'. This can be useful when mixing C code with C++ +code. + + The pre-defined streams `cin', `cout', and `cerr' are normally +implemented as `stdiobuf' objects that point to respectively `stdin', +`stdout', and `stderr'. This is convenient, but it does cost some +extra overhead. + + If you set things up to use the implementation of `stdio' provided +with this library, then `cin', `cout', and `cerr' will be set up to to +use `stdiobuf' objects, since you get their benefits for free. *Note C +Input and Output: Stdio. + + +File: iostream.info, Node: Procbuf, Next: Backing Up, Prev: Stdiobuf, Up: Streambuf + +Reading/writing from/to a pipe +============================== + + The "procbuf" class is a GNU extension. It is derived from +`streambuf'. A `procbuf' can be "closed" (in which case it does +nothing), or "open" (in which case it allows communicating through a +pipe with some other program). + + - Constructor: procbuf::procbuf () + Creates a `procbuf' in a "closed" state. + + - Method: procbuf* procbuf::open (const char *COMMAND, int MODE) + Uses the shell (`/bin/sh') to run a program specified by COMMAND. + + If MODE is `ios::in', standard output from the program is sent to + a pipe; you can read from the pipe by reading from the `procbuf'. + (This is similar to `popen(COMMAND, "r")'.) + + If MODE is `ios::out', output written written to the `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 + `popen(COMMAND, "w")'.) + + The `procbuf' must start out in the "closed" state. Returns + `*this' on success, and `NULL' on failure. + + - Constructor: procbuf::procbuf (const char *COMMAND, int MODE) + Calls `procbuf::open (COMMAND, MODE)'. + + - Method: procbuf* procbuf::close () + Waits for the program to finish executing, and then cleans up the + resources used. Returns `*this' on success, and `NULL' on failure. + + - Destructor: procbuf::~procbuf () + Calls `procbuf::close'. + + +File: iostream.info, Node: Backing Up, Next: Indirectbuf, Prev: Procbuf, Up: Streambuf + +Backing up +========== + + The GNU iostream library allows you to ask a `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: + + // 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; + } + + - Constructor: streammarker::streammarker (streambuf* SBUF) + Create a `streammarker' associated with SBUF that remembers the + current position of the get pointer. + + - Method: int streammarker::delta (streammarker& MARK2) + Return the difference between the get positions corresponding to + `*this' and MARK2 (which must point into the same `streambuffer' + as `this'). + + - Method: int streammarker::delta () + Return the position relative to the streambuffer's current get + position. + + - Method: int streambuf::seekmark (streammarker& MARK) + Move the get pointer to where it (logically) was when MARK was + constructed. + + +File: iostream.info, Node: Indirectbuf, Prev: Backing Up, Up: Streambuf + +Forwarding I/O activity +======================= + + An "indirectbuf" is one that forwards all of its I/O requests to +another streambuf. + + 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)); } + }; + + +File: iostream.info, Node: Stdio, Next: Index, Prev: Streambuf, Up: Top + +C Input and Output +****************** + + `libio' is distributed with a complete implementation of the ANSI C +`stdio' facility. It is implemented using `streambuf' objects. *Note +Wrappers for C `stdio': Stdiobuf. + + The `stdio' package is intended as a replacement for the whatever +`stdio' is in your C library. Since `stdio' works best when you build +`libc' to contain it, and that may be inconvenient, it is not installed +by default. + + Extensions beyond ANSI: + + * A stdio `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. + + * If you create a new streambuf sub-class (in C++), you can use it + as a `FILE' from C. Thus the system is extensible using the + standard `streambuf' protocol. + + * You can arbitrarily mix reading and writing, without having to seek + in between. + + * Unbounded `ungetc()' buffer. + + +File: iostream.info, Node: Index, Prev: Stdio, Up: Top + +Index +***** + +* Menu: + +* (: States. +* (: States. +* << on ostream: Operators. +* >> on istream: Operators. +* iostream destructor: Iostream. +* badbit: States. +* beg: Output Position. +* cerr: Operators. +* cin: Operators. +* class fstreambase: Files. +* class fstream: Files. +* class ifstream: Files. +* class istrstream: Strings. +* class ostream: Files. +* class ostrstream: Strings. +* class strstreambase: Strings. +* class strstreambuf: Strings. +* class strstream: Strings. +* cout: Operators. +* cur: Output Position. +* dec: Manipulators. +* destructor for iostream: Iostream. +* end: Output Position. +* endl: Manipulators. +* ends: Manipulators. +* eofbit: States. +* failbit: States. +* flush: Ostream Housekeeping. +* flush: Manipulators. +* fstream: Files. +* fstreambase: Files. +* fstreambase::close: Files. +* get area: Areas. +* goodbit: States. +* hex: Manipulators. +* ifstream: Files and Strings. +* ifstream: Files. +* ifstream::ifstream: Files. +* ifstream::ifstream: Files. +* ifstream::ifstream: Files. +* ifstream::open: Files. +* ios::app: Files. +* ios::ate: Files. +* ios::bad: States. +* ios::beg: Input Position. +* ios::bin: Files. +* ios::bitalloc: Extending. +* ios::clear: States. +* ios::cur: Input Position. +* ios::dec: Format Control. +* ios::end: Input Position. +* ios::eof: States. +* ios::fail: States. +* ios::fill: Format Control. +* ios::fill: Format Control. +* ios::fixed: Format Control. +* ios::flags: Format Control. +* ios::flags: Format Control. +* ios::good: States. +* ios::hex: Format Control. +* ios::in: Files. +* ios::internal: Format Control. +* ios::ios: Ios. +* ios::iword: Extending. +* ios::iword: Extending. +* ios::left: Format Control. +* ios::nocreate: Files. +* ios::noreplace: Files. +* ios::oct: Format Control. +* ios::out: Files. +* ios::precision: Format Control. +* ios::precision: Format Control. +* ios::pword: Extending. +* ios::pword: Extending. +* ios::rdbuf: Streambuf from Ios. +* ios::rdstate: States. +* ios::right: Format Control. +* ios::scientific: Format Control. +* ios::seekdir: Output Position. +* ios::set: States. +* ios::setf: Format Control. +* ios::setf: Format Control. +* ios::setstate: States. +* ios::showbase: Format Control. +* ios::showpoint: Format Control. +* ios::showpos: Format Control. +* ios::skipws: Format Control. +* ios::stdio: Format Control. +* ios::sync_with_stdio: Synchronization. +* ios::tie: Synchronization. +* ios::tie: Synchronization. +* ios::trunc: Files. +* ios::unitbuf: Format Control. +* ios::unsetf: Format Control. +* ios::uppercase: Format Control. +* ios::width: Format Control. +* ios::width: Format Control. +* ios::xalloc: Extending. +* ios::~ios: Ios. +* iostream::iostream: Iostream. +* iostream::iostream: Iostream. +* istream::gcount: Istream Housekeeping. +* istream::get: Char Input. +* istream::get: Char Input. +* istream::get: String Input. +* istream::get: String Input. +* istream::getline: String Input. +* istream::gets: String Input. +* istream::ignore: Istream Housekeeping. +* istream::ipfx: Istream Housekeeping. +* istream::isfx: Istream Housekeeping. +* istream::istream: Istream. +* istream::istream: Istream. +* istream::peek: Char Input. +* istream::putback: Istream Housekeeping. +* istream::read: String Input. +* istream::scan: String Input. +* istream::seekg: Input Position. +* istream::seekg: Input Position. +* istream::tellg: Input Position. +* istream::unget: Istream Housekeeping. +* istream::vscan: String Input. +* istrstream: Strings. +* istrstream: Files and Strings. +* istrstream::istrstream: Strings. +* oct: Manipulators. +* ofstream: Files and Strings. +* ofstream::ofstream: Files. +* ofstream::ofstream: Files. +* ofstream::ofstream: Files. +* ofstream::open: Files. +* ofstream::~ofstream: Files. +* ostream: Files. +* ostream::form: Writing. +* ostream::opfx: Ostream Housekeeping. +* ostream::osfx: Ostream Housekeeping. +* ostream::ostream: Ostream. +* ostream::ostream: Ostream. +* ostream::put: Writing. +* ostream::seekp: Output Position. +* ostream::seekp: Output Position. +* ostream::tellp: Output Position. +* ostream::vform: Writing. +* ostream::write: Writing. +* ostrstream: Strings. +* ostrstream: Files and Strings. +* ostrstream::freeze: Strings. +* ostrstream::frozen: Strings. +* ostrstream::ostrstream: Strings. +* ostrstream::ostrstream: Strings. +* ostrstream::pcount: Strings. +* ostrstream::str: Strings. +* procbuf::close: Procbuf. +* procbuf::open: Procbuf. +* procbuf::procbuf: Procbuf. +* procbuf::procbuf: Procbuf. +* procbuf::~procbuf: Procbuf. +* put area: Areas. +* setbase: Manipulators. +* setfill: Manipulators. +* setprecision: Format Control. +* setprecision: Manipulators. +* setting ios::precision: Format Control. +* setting ios::width: Format Control. +* setw: Format Control. +* setw: Manipulators. +* streambuf::eback: Areas. +* streambuf::egptr: Areas. +* streambuf::epptr: Areas. +* streambuf::gptr: Areas. +* streambuf::pbase: Areas. +* streambuf::pbump: Areas. +* streambuf::pptr: Areas. +* streambuf::scan: Formatting. +* streambuf::seekmark: Backing Up. +* streambuf::setg: Areas. +* streambuf::setp: Areas. +* streambuf::vform: Formatting. +* streambuf::vform: Formatting. +* streambuf::vscan: Formatting. +* streambuf:gbump: Areas. +* streammarker::delta: Backing Up. +* streammarker::delta: Backing Up. +* streammarker::streammarker: Backing Up. +* strstream: Strings. +* strstreambase: Strings. +* strstreambase::rdbuf: Strings. +* strstreambuf: Strings. +* ws: Manipulators. + + diff --git a/gnu/lib/libg++/libio/iostream.texi b/gnu/lib/libg++/libio/iostream.texi new file mode 100644 index 00000000000..0239d9e6364 --- /dev/null +++ b/gnu/lib/libg++/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::vform (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/gnu/lib/libg++/libio/iostreamP.h b/gnu/lib/libg++/libio/iostreamP.h new file mode 100644 index 00000000000..c9c40cb6ba9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iostrerror.c b/gnu/lib/libg++/libio/iostrerror.c new file mode 100644 index 00000000000..65aa25d5e4e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ioungetc.c b/gnu/lib/libg++/libio/ioungetc.c new file mode 100644 index 00000000000..033f652a067 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iovfprintf.c b/gnu/lib/libg++/libio/iovfprintf.c new file mode 100644 index 00000000000..c6ba7957d71 --- /dev/null +++ b/gnu/lib/libg++/libio/iovfprintf.c @@ -0,0 +1,881 @@ +/* +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 + +/* + * 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; 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/gnu/lib/libg++/libio/iovfscanf.c b/gnu/lib/libg++/libio/iovfscanf.c new file mode 100644 index 00000000000..1220e0750b7 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iovsprintf.c b/gnu/lib/libg++/libio/iovsprintf.c new file mode 100644 index 00000000000..06d926d3590 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/iovsscanf.c b/gnu/lib/libg++/libio/iovsscanf.c new file mode 100644 index 00000000000..529778098a5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/isgetline.cc b/gnu/lib/libg++/libio/isgetline.cc new file mode 100644 index 00000000000..add26638b20 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/isgetsb.cc b/gnu/lib/libg++/libio/isgetsb.cc new file mode 100644 index 00000000000..55617e649a0 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/isscan.cc b/gnu/lib/libg++/libio/isscan.cc new file mode 100644 index 00000000000..64d4bc682f8 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/istream.h b/gnu/lib/libg++/libio/istream.h new file mode 100644 index 00000000000..f54ec1de9a1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/libio.h b/gnu/lib/libg++/libio/libio.h new file mode 100644 index 00000000000..7080d1359d7 --- /dev/null +++ b/gnu/lib/libg++/libio/libio.h @@ -0,0 +1,254 @@ +/* +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 +#define _IO_USE_DTOA +#define _IO_UNIFIED_JUMPTABLES 1 + +#if 0 +#ifdef _IO_NEED_STDARG_H +#include +#endif +#endif + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef NULL +#if !defined(__cplusplus) || defined(__GNUC__) +#define NULL ((void*)0) +#else +#define NULL (0) +#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 { + int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ +#define _IO_file_flags _flags + + /* The following pointers correspond to the C++ streambuf protocol. */ + 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/gnu/lib/libg++/libio/libioP.h b/gnu/lib/libg++/libio/libioP.h new file mode 100644 index 00000000000..1b32a59de64 --- /dev/null +++ b/gnu/lib/libg++/libio/libioP.h @@ -0,0 +1,481 @@ +/* +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 +/* 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) + +/* 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); + 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_attach __P((_IO_FILE*, int)); +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 +#if !defined(__cplusplus) || defined(__GNUC__) +#define NULL ((void*)0) +#else +#define NULL (0) +#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/gnu/lib/libg++/libio/osform.cc b/gnu/lib/libg++/libio/osform.cc new file mode 100644 index 00000000000..8c0011703da --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/ostream.h b/gnu/lib/libg++/libio/ostream.h new file mode 100644 index 00000000000..f54ec1de9a1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/outfloat.c b/gnu/lib/libg++/libio/outfloat.c new file mode 100644 index 00000000000..a74b1a2c3e1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/parsestream.cc b/gnu/lib/libg++/libio/parsestream.cc new file mode 100644 index 00000000000..320afd06d9b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/parsestream.h b/gnu/lib/libg++/libio/parsestream.h new file mode 100644 index 00000000000..326ab87a809 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/pfstream.cc b/gnu/lib/libg++/libio/pfstream.cc new file mode 100644 index 00000000000..3fa93c958f8 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/pfstream.h b/gnu/lib/libg++/libio/pfstream.h new file mode 100644 index 00000000000..3c5458baaa9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/procbuf.cc b/gnu/lib/libg++/libio/procbuf.cc new file mode 100644 index 00000000000..1c79ce4ce0f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/procbuf.h b/gnu/lib/libg++/libio/procbuf.h new file mode 100644 index 00000000000..b361a6a7c84 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/sbform.cc b/gnu/lib/libg++/libio/sbform.cc new file mode 100644 index 00000000000..c17bd08db15 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/sbgetline.cc b/gnu/lib/libg++/libio/sbgetline.cc new file mode 100644 index 00000000000..700e2ec7afc --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/sbscan.cc b/gnu/lib/libg++/libio/sbscan.cc new file mode 100644 index 00000000000..c0ec35c53db --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdfiles.c b/gnu/lib/libg++/libio/stdfiles.c new file mode 100644 index 00000000000..1d0ef85be90 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/ChangeLog b/gnu/lib/libg++/libio/stdio/ChangeLog new file mode 100644 index 00000000000..86288c8e95c --- /dev/null +++ b/gnu/lib/libg++/libio/stdio/ChangeLog @@ -0,0 +1,84 @@ +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/gnu/lib/libg++/libio/stdio/Makefile.in b/gnu/lib/libg++/libio/stdio/Makefile.in new file mode 100644 index 00000000000..8df66a7c193 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/clearerr.c b/gnu/lib/libg++/libio/stdio/clearerr.c new file mode 100644 index 00000000000..ee9780bdaf5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/configure.in b/gnu/lib/libg++/libio/stdio/configure.in new file mode 100644 index 00000000000..21e920acf47 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/fdopen.c b/gnu/lib/libg++/libio/stdio/fdopen.c new file mode 100644 index 00000000000..83e026ec7f7 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/feof.c b/gnu/lib/libg++/libio/stdio/feof.c new file mode 100644 index 00000000000..bd30c175f3c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/ferror.c b/gnu/lib/libg++/libio/stdio/ferror.c new file mode 100644 index 00000000000..ef95d7cd29d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/fgetc.c b/gnu/lib/libg++/libio/stdio/fgetc.c new file mode 100644 index 00000000000..cf6410a887f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/fileno.c b/gnu/lib/libg++/libio/stdio/fileno.c new file mode 100644 index 00000000000..c0bc55ce9a1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/fputc.c b/gnu/lib/libg++/libio/stdio/fputc.c new file mode 100644 index 00000000000..e87b042bfba --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/freopen.c b/gnu/lib/libg++/libio/stdio/freopen.c new file mode 100644 index 00000000000..da3dc1d6411 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/fseek.c b/gnu/lib/libg++/libio/stdio/fseek.c new file mode 100644 index 00000000000..b80067da1c0 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/getc.c b/gnu/lib/libg++/libio/stdio/getc.c new file mode 100644 index 00000000000..9db0987f71c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/getchar.c b/gnu/lib/libg++/libio/stdio/getchar.c new file mode 100644 index 00000000000..88610dc49e2 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/getline.c b/gnu/lib/libg++/libio/stdio/getline.c new file mode 100644 index 00000000000..6f4b677086e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/getw.c b/gnu/lib/libg++/libio/stdio/getw.c new file mode 100644 index 00000000000..1dfafbc1d4f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/popen.c b/gnu/lib/libg++/libio/stdio/popen.c new file mode 100644 index 00000000000..9f9f3f72f58 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/putc.c b/gnu/lib/libg++/libio/stdio/putc.c new file mode 100644 index 00000000000..2a3dcc36867 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/putchar.c b/gnu/lib/libg++/libio/stdio/putchar.c new file mode 100644 index 00000000000..a0a972fb539 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/putw.c b/gnu/lib/libg++/libio/stdio/putw.c new file mode 100644 index 00000000000..fd73261359c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/rewind.c b/gnu/lib/libg++/libio/stdio/rewind.c new file mode 100644 index 00000000000..01fe20a75dd --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/setbuf.c b/gnu/lib/libg++/libio/stdio/setbuf.c new file mode 100644 index 00000000000..5002e3d0733 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/setfileno.c b/gnu/lib/libg++/libio/stdio/setfileno.c new file mode 100644 index 00000000000..f7ccc6fdd66 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/setlinebuf.c b/gnu/lib/libg++/libio/stdio/setlinebuf.c new file mode 100644 index 00000000000..c447f954e9f --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/snprintf.c b/gnu/lib/libg++/libio/stdio/snprintf.c new file mode 100644 index 00000000000..5c70a444112 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/stdio.h b/gnu/lib/libg++/libio/stdio/stdio.h new file mode 100644 index 00000000000..27d0f8d293f --- /dev/null +++ b/gnu/lib/libg++/libio/stdio/stdio.h @@ -0,0 +1,179 @@ +/* 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 +#define TMP_MAX 999 /* Only limited by filename length */ + +#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, _G_va_list)); +extern int vprintf __P((char const *fmt, _G_va_list)); +extern int vsprintf __P((char* string, const char* format, _G_va_list)); + +#ifndef __STRICT_ANSI__ +extern int vfscanf __P((FILE*, const char *, _G_va_list)); +extern int vscanf __P((const char *, _G_va_list)); +extern int vsscanf __P((const char *, const char *, _G_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 *, _G_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/gnu/lib/libg++/libio/stdio/vfprintf.c b/gnu/lib/libg++/libio/stdio/vfprintf.c new file mode 100644 index 00000000000..fca62094452 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/vfscanf.c b/gnu/lib/libg++/libio/stdio/vfscanf.c new file mode 100644 index 00000000000..1759ee5ee01 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/vprintf.c b/gnu/lib/libg++/libio/stdio/vprintf.c new file mode 100644 index 00000000000..784f0d9b8df --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/vscanf.c b/gnu/lib/libg++/libio/stdio/vscanf.c new file mode 100644 index 00000000000..4ef4b52a21c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdio/vsnprintf.c b/gnu/lib/libg++/libio/stdio/vsnprintf.c new file mode 100644 index 00000000000..8db41b76187 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdiostream.cc b/gnu/lib/libg++/libio/stdiostream.cc new file mode 100644 index 00000000000..80db5e59bfd --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdiostream.h b/gnu/lib/libg++/libio/stdiostream.h new file mode 100644 index 00000000000..73d49f96c22 --- /dev/null +++ b/gnu/lib/libg++/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) : _file(__f), istream() { 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) : _file(__f), ostream() { 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/gnu/lib/libg++/libio/stdstrbufs.cc b/gnu/lib/libg++/libio/stdstrbufs.cc new file mode 100644 index 00000000000..8af259988a5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/stdstreams.cc b/gnu/lib/libg++/libio/stdstreams.cc new file mode 100644 index 00000000000..051ca574fc8 --- /dev/null +++ b/gnu/lib/libg++/libio/stdstreams.cc @@ -0,0 +1,149 @@ +/* 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) \ + _fake_ostream NAME = { {&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. */ +OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0) + +// 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/gnu/lib/libg++/libio/stream.cc b/gnu/lib/libg++/libio/stream.cc new file mode 100644 index 00000000000..db57bb47643 --- /dev/null +++ b/gnu/lib/libg++/libio/stream.cc @@ -0,0 +1,144 @@ +/* +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 "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); +} diff --git a/gnu/lib/libg++/libio/stream.h b/gnu/lib/libg++/libio/stream.h new file mode 100644 index 00000000000..2a791dffebe --- /dev/null +++ b/gnu/lib/libg++/libio/stream.h @@ -0,0 +1,57 @@ +/* +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. + +#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/gnu/lib/libg++/libio/streambuf.cc b/gnu/lib/libg++/libio/streambuf.cc new file mode 100644 index 00000000000..d66af097aa5 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/streambuf.h b/gnu/lib/libg++/libio/streambuf.h new file mode 100644 index 00000000000..9eab279759c --- /dev/null +++ b/gnu/lib/libg++/libio/streambuf.h @@ -0,0 +1,473 @@ +/* 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 __GNUC__ +#define NULL ((void*)0) +#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! */ + 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 }; + 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/gnu/lib/libg++/libio/strfile.h b/gnu/lib/libg++/libio/strfile.h new file mode 100644 index 00000000000..55783bb5c1c --- /dev/null +++ b/gnu/lib/libg++/libio/strfile.h @@ -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 +#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 +{ + /* The current length is max(_len, _IO_write_ptr-_IO_write_base). */ + _IO_size_t _len; + _IO_alloc_type _allocate_buffer; + _IO_free_type _free_buffer; +}; + +typedef struct _IO_strfile_ +{ + struct _IO_FILE _f; + const void *_vtable; + struct _IO_str_fields _s; +} _IO_strfile; diff --git a/gnu/lib/libg++/libio/strops.c b/gnu/lib/libg++/libio/strops.c new file mode 100644 index 00000000000..f4f45259fb3 --- /dev/null +++ b/gnu/lib/libg++/libio/strops.c @@ -0,0 +1,285 @@ +/* +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 + +#define LEN(fp) (((_IO_strfile*)(fp))->_s._len) + +#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 ... */ +#if 1 + int s; + size = 512; + /* Try increasing powers of 2, as long as we don't wrap around. + This can lose in pathological cases (ptr near the end + of the address space). A better solution might be to + adjust the size on underflow/overflow. FIXME. */ + for (s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; ) + size = s; + size = s; +#else + /* The following semi-portable kludge assumes that + sizeof(unsigned long) == sizeof(char*). Hence, + (unsigned long)(-1) should be the largest possible address. */ + unsigned long highest = (unsigned long)(-1); + /* Pointers are signed on some brain-damaged systems, in + which case we divide by two to get the maximum signed address. */ + if ((char*)highest < ptr) + highest >>= 1; + size = (char*)highest - ptr; +#endif + } + _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; + } + LEN(fp) = 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 = fp->_IO_write_ptr - fp->_IO_write_base; + _IO_size_t get_pos = fp->_IO_read_ptr - fp->_IO_read_base; + if (fp->_flags & _IO_NO_WRITES) + return flush_only ? 0 : EOF; + if (pos > LEN(fp)) LEN(fp) = pos; + if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING)) + { + pos = get_pos; + fp->_flags |= _IO_CURRENTLY_PUTTING; + get_pos = LEN(fp); + } + if (pos >= _IO_blen(fp) + flush_only) + { + if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */ + { +#ifdef TODO + if (indefinite size) + { + fp->_IO_buf_end += 512; + } + else +#endif + return EOF; + } + else + { + char *new_buf; + _IO_size_t new_size = 2 * _IO_blen(fp); + new_buf + = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size); + if (new_buf == NULL) + { + /* __ferror(fp) = 1; */ + return EOF; + } + memcpy(new_buf, fp->_IO_buf_base, _IO_blen(fp)); +#if 0 + if (lenp == &LEN(fp)) /* use '\0'-filling */ + memset(new_buf + pos, 0, blen() - pos); +#endif + if (fp->_IO_buf_base) + { + (*((_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; + } + _IO_setb(fp, new_buf, new_buf + new_size, 1); + fp->_IO_write_base = new_buf; + } + fp->_IO_write_end = fp->_IO_buf_end; + } + + fp->_IO_write_ptr = fp->_IO_buf_base + pos; + + fp->_IO_read_base = fp->_IO_buf_base; + fp->_IO_read_ptr = fp->_IO_buf_base + get_pos; + fp->_IO_read_end = fp->_IO_buf_base + LEN(fp); + + if (!flush_only) + *fp->_IO_write_ptr++ = (unsigned char) c; + return c; +} + +int +DEFUN(_IO_str_underflow, (fp), + register _IO_FILE* fp) +{ + _IO_size_t ppos = fp->_IO_write_ptr - fp->_IO_write_base; + if (ppos > LEN(fp)) LEN(fp) = ppos; + if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING)) + { + fp->_flags &= ~_IO_CURRENTLY_PUTTING; + fp->_IO_write_ptr = fp->_IO_write_end; + } + fp->_IO_read_end = fp->_IO_read_base + LEN(fp); + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *fp->_IO_read_ptr; + else + return EOF; +} + +_IO_ssize_t +DEFUN(_IO_str_count, (fp), + register _IO_FILE *fp) +{ + _IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base; + if (put_len < LEN(fp)) + put_len = LEN(fp); + return put_len; +} + +_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; + LEN(fp) = cur_size; + 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/gnu/lib/libg++/libio/strstream.cc b/gnu/lib/libg++/libio/strstream.cc new file mode 100644 index 00000000000..3e1d5a6bfa6 --- /dev/null +++ b/gnu/lib/libg++/libio/strstream.cc @@ -0,0 +1,168 @@ +/* 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; +} + +#if _IO_UNIFIED_JUMPTABLES +#define SET_STR_JUMPS(STRBUF) /* Nothing */ +#else +/* Set to use the _IO_str_jump jumptable, for efficiency */ + +#define SET_STR_JUMPS(STRBUF) \ + (STRBUF)->_jumps = &_IO_str_jumps,\ + (STRBUF)->_vtable() = builtinbuf_vtable; +#endif + +istrstream::istrstream(const char *cp, int n) +{ +#ifdef _IO_NEW_STREAMS + __my_sb.init_readonly (cp, n); + init (&__my_sb); +#else + init(new strstreambuf(cp, n)); + _flags &= ~ios::dont_close; +#endif + SET_STR_JUMPS(_strbuf); +} + +ostrstream::ostrstream() +{ +#ifdef _IO_NEW_STREAMS + init (&__my_sb); +#else + init(new strstreambuf()); + _flags &= ~ios::dont_close; +#endif + SET_STR_JUMPS(_strbuf); +} + +strstream::strstream() +{ +#ifdef _IO_NEW_STREAMS + init (&__my_sb); +#else + init(new strstreambuf()); + _flags &= ~ios::dont_close; +#endif + SET_STR_JUMPS(_strbuf); +} + +strstreambase::strstreambase(char *cp, int n, int mode) +#ifdef _IO_NEW_STREAMS +: __my_sb (cp, n, + (mode == ios::app || mode == ios::ate) ? cp + strlen(cp) : cp) +#endif +{ +#ifdef _IO_NEW_STREAMS + init (&__my_sb); +#else + char *pstart; + if (mode == ios::app || mode == ios::ate) + pstart = cp + strlen(cp); + else + pstart = cp; + init(new strstreambuf(cp, n, pstart)); + _flags &= ~ios::dont_close; +#endif + SET_STR_JUMPS(_strbuf); +} + +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._len = 0; + if (initial_size < 16) + initial_size = 16; + _s._allocate_buffer = alloc ? alloc : default_alloc; + _s._free_buffer = free ? free : default_free; + 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/gnu/lib/libg++/libio/strstream.h b/gnu/lib/libg++/libio/strstream.h new file mode 100644 index 00000000000..86a8a687587 --- /dev/null +++ b/gnu/lib/libg++/libio/strstream.h @@ -0,0 +1,123 @@ +/* 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 = 128); + void init_static(char *ptr, int size, char *pstart); + void init_readonly(const char *ptr, int size); + protected: + int is_static() const { return _s._allocate_buffer == (_IO_alloc_type)0; } + 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 is_static(). + int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; } + void freeze(int n=1) + { if (!is_static()) + { 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 { +#ifdef _IO_NEW_STREAMS + protected: + strstreambuf __my_sb; +#endif + public: +#ifdef _IO_NEW_STREAMS + strstreambuf* rdbuf() { return &__my_sb; } +#else + strstreambuf* rdbuf() { return (strstreambuf*)ios::rdbuf(); } +#endif + protected: + strstreambase() { } +#ifdef _IO_NEW_STREAMS + strstreambase(char *cp, int n); +#endif + 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/gnu/lib/libg++/libio/tests/ChangeLog b/gnu/lib/libg++/libio/tests/ChangeLog new file mode 100644 index 00000000000..077d0e628eb --- /dev/null +++ b/gnu/lib/libg++/libio/tests/ChangeLog @@ -0,0 +1,102 @@ +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/gnu/lib/libg++/libio/tests/Makefile.in b/gnu/lib/libg++/libio/tests/Makefile.in new file mode 100644 index 00000000000..bca52f7b323 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/Makefile.in @@ -0,0 +1,195 @@ +# 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 = ../libiostream.a ../../libiberty/libiberty.a +IOSTDIOLIB = ../libio.a ../../libiberty/libiberty.a + +DEPEND_SOURCES = $(srcdir)/*.C + +.PHONY: check check-iostream check-stdio +check: 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) -o tgetl tgetl.o $(IOLIBS) + +tFile: tFile.o + $(CXX) -o tFile tFile.o $(IOLIBS) + +tiomisc: tiomisc.o + $(CXX) -o tiomisc tiomisc.o $(IOLIBS) + +hounddog: hounddog.o + $(CXX) -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) -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) -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) -o twrseek twrseek.o $(STDIOLIBS) + +check-twrseek: twrseek + ./twrseek > twrseek.out 2>&1 + diff -c twrseek.out $(srcdir)/twrseek.exp + +trdseek: trdseek.o + $(CC) -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) -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) -o tstdiomisc tstdiomisc.o $(IOSTDIOLIB) + +check-tstdiomisc: tstdiomisc + ./tstdiomisc >tstdiomisc.out 2>&1 + diff -c tstdiomisc.out $(srcdir)/tstdiomisc.exp + +tpopen: tpopen.o + $(CC) -o tpopen tpopen.o $(STDIOLIBS) + +check-tpopen: tpopen + ./tpopen > tpopen.out 2>&1 + diff -c tpopen.out $(srcdir)/tpopen.exp + +trwseek: trwseek.o + $(CC) -o trwseek trwseek.o $(STDIOLIBS) + +check-trwseek: trwseek + ./trwsseek TMP r+ k w o + +foo: foo.o + $(CXX) -o foo foo.o $(STDIOLIBS) +foo+: foo+.o + $(CXX) -o foo+ foo+.o $(IOLIBS) diff --git a/gnu/lib/libg++/libio/tests/configure.in b/gnu/lib/libg++/libio/tests/configure.in new file mode 100644 index 00000000000..f832adfb236 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/hounddog.cc b/gnu/lib/libg++/libio/tests/hounddog.cc new file mode 100644 index 00000000000..29a92383647 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/hounddog.exp b/gnu/lib/libg++/libio/tests/hounddog.exp new file mode 100644 index 00000000000..2060807b431 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/hounddog.inp b/gnu/lib/libg++/libio/tests/hounddog.inp new file mode 100644 index 00000000000..370371bc203 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/hounddog.inp @@ -0,0 +1,7 @@ +hello! +doggie +hound +cat +hounddog rat +dog +foo diff --git a/gnu/lib/libg++/libio/tests/putbackdog.cc b/gnu/lib/libg++/libio/tests/putbackdog.cc new file mode 100644 index 00000000000..0e1ed61f559 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/tFile.cc b/gnu/lib/libg++/libio/tests/tFile.cc new file mode 100644 index 00000000000..d8a1ee301fa --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/tFile.exp b/gnu/lib/libg++/libio/tests/tFile.exp new file mode 100644 index 00000000000..154cd24dc0b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/tFile.inp b/gnu/lib/libg++/libio/tests/tFile.inp new file mode 100644 index 00000000000..5b821ef072b --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/tfformat.c b/gnu/lib/libg++/libio/tests/tfformat.c new file mode 100644 index 00000000000..f0f5ccf2177 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/tfformat.c @@ -0,0 +1,4145 @@ +#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; +#if defined(__cplusplus) && !defined(TEST_LIBIO) + + strstream sstr(buffer, BSIZE, ios::in|ios::out); + + for (dptr = sprint_doubles; dptr->line; dptr++) + { + 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++; + } + + 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++) + { + 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++; + } + + 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/gnu/lib/libg++/libio/tests/tiformat.c b/gnu/lib/libg++/libio/tests/tiformat.c new file mode 100644 index 00000000000..f28d646d72e --- /dev/null +++ b/gnu/lib/libg++/libio/tests/tiformat.c @@ -0,0 +1,5093 @@ +#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__, 0x000838d2, "838d2", "%.4x", +__LINE__, 0x0063be46, "63BE46", "%-6X", +__LINE__, -0x1b236c0, "-28456640", "%#0.d", +__LINE__, -0x0000003, "-3", "% 0d", +__LINE__, 0x0000ed51, "ed51", "%2.x", +__LINE__, -0x00001f2, "-498", "%1ld", +__LINE__, 0x0ea3e927, "EA3E927", "%+X", +__LINE__, 0xffbef8da, "FFBEF8DA", "%5X", +__LINE__, 0x62ff9f56, "62ff9f56", "%0x", +__LINE__, 0x00000ad2, "AD2", "%.0X", +__LINE__, 0x00000000, " ", "% 6.ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%1.4X", +__LINE__, 0x0000208c, " 208C", "%5X", +__LINE__, 0x0000003c, "3c", "%x", +__LINE__, 0xffff6177, "0xffff6177", "%+#x", +__LINE__, 0xffffdc8d, "ffffdc8d", "%+x", +__LINE__, 0x00000000, "0", "%X", +__LINE__, 0x00002434, "9268", "%0d", +__LINE__, 0xd2c72cdb, "d2c72cdb", "%-x", +__LINE__, 0xfe38012b, "0xfe38012b", "%+#7x", +__LINE__, 0x00000001, "0001", "%#.4d", +__LINE__, -0x008525a, "-0545370", "%06.7ld", +__LINE__, 0xffffffac, "ffffffac", "%3.7x", +__LINE__, 0x007424d2, "+7611602", "%+ld", +__LINE__, 0x00001a85, "1A85", "%.4X", +__LINE__, -0x0000019, "-25", "%3.d", +__LINE__, 0xfffffffe, "fffffffe", "%-x", +__LINE__, -0x34473b2, "-54817714", "% d", +__LINE__, 0x000000ea, "234", "%1.ld", +__LINE__, -0x0000004, "-4 ", "%-7.ld", +__LINE__, 0x00006c94, "27796", "%0d", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0x00000619, "619", "%1x", +__LINE__, 0x0000209c, "8348", "%ld", +__LINE__, -0x327f8ff, "-52951295", "%-0ld", +__LINE__, 0xffffff0b, "FFFFFF0B", "%2.X", +__LINE__, 0xf199d6ae, "F199D6AE", "%X", +__LINE__, 0x3ca5602e, "1017471022", "%-1.ld", +__LINE__, -0xfb2080b, "-263325707", "%3.5d", +__LINE__, 0x00001cb8, "7352", "%d", +__LINE__, 0x00000000, "0000000", "%3.7d", +__LINE__, 0xffffff40, "FFFFFF40", "%+X", +__LINE__, 0x14664450, "0x14664450", "%#x", +__LINE__, 0x0000002e, "2e", "%1x", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, 0xffff606a, "0XFFFF606A", "%#X", +__LINE__, 0xffffff33, "0XFFFFFF33", "%#X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, -0x0000012, "-00018", "%-2.5d", +__LINE__, 0x0001fbe6, "130022", "%1.d", +__LINE__, 0xfff59dd9, "fff59dd9", "%+x", +__LINE__, 0x00000002, "2", "%0.0d", +__LINE__, 0x00000fe1, "fe1 ", "%-7.x", +__LINE__, 0x001f8f6a, "1F8F6A", "%1.X", +__LINE__, 0x0000001b, "000001B", "%04.7X", +__LINE__, 0x126a2609, " 308946441", "% 4d", +__LINE__, 0xffffffe3, "0XFFFFFFE3", "%+#.1X", +__LINE__, 0x1858f1c9, "1858f1c9", "%.3x", +__LINE__, 0x003fc672, "3fc672", "%1x", +__LINE__, 0x00c0bddc, "12631516", "%#d", +__LINE__, 0x000006d6, "1750", "%#d", +__LINE__, 0x000006a0, "6A0", "%X", +__LINE__, 0x000007be, "7BE", "%X", +__LINE__, -0x1c7cd1a, "-29871386", "%ld", +__LINE__, 0x000000cc, "204", "%ld", +__LINE__, 0x000002db, "731 ", "%-#5d", +__LINE__, 0xffff67ad, "FFFF67AD", "% X", +__LINE__, 0x00000008, "8", "%d", +__LINE__, 0xffe07007, "FFE07007", "%5X", +__LINE__, -0x0000001, " -1", "% 7d", +__LINE__, 0xfffffffe, "fffffffe", "%x", +__LINE__, 0x00027b68, "+162664", "%+ld", +__LINE__, 0x0a7c1997, "+175905175", "%+2ld", +__LINE__, 0xfe300896, "fe300896", "%.4x", +__LINE__, 0x00000537, "537", "%-0.x", +__LINE__, 0x3e981779, "3e981779", "%.6x", +__LINE__, 0xfffff05e, "FFFFF05E", "%1.0X", +__LINE__, -0x07bc0cf, "-8110287", "%-7d", +__LINE__, -0x01371bc, "-1274300", "%.7ld", +__LINE__, -0x0000013, "-19", "%.2ld", +__LINE__, 0x000000d1, "0xd1", "%#x", +__LINE__, -0x0000003, "-3", "%-ld", +__LINE__, 0xfffffffc, "FFFFFFFC", "%4.1X", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, 0x0001c8af, "116911", "%d", +__LINE__, 0x000048c3, "48C3", "%X", +__LINE__, 0x00000079, "0x0000079", "%-#0.7x", +__LINE__, 0x0000615a, " 24922", "% d", +__LINE__, 0xfffffff5, "fffffff5", "%x", +__LINE__, 0x00000308, "0000308", "%+07.7x", +__LINE__, 0xfcadc983, "fcadc983", "%x", +__LINE__, 0x00000097, "151", "%#d", +__LINE__, 0x000001c5, "453", "%0.2ld", +__LINE__, 0x00000000, "00", "%-1.2x", +__LINE__, 0x00000001, "+1", "%+02.d", +__LINE__, 0x01eb4354, "1EB4354", "% X", +__LINE__, 0xffffa7d1, "ffffa7d1", "%5.x", +__LINE__, 0x0003170e, "0x3170e", "%#x", +__LINE__, 0x000001ce, "1CE", "% .2X", +__LINE__, 0x3a2991fb, "975802875", "%d", +__LINE__, -0xcdad8e2, "-215668962", "%-d", +__LINE__, 0xfe0261c3, "fe0261c3", "%x", +__LINE__, -0x0006ea7, "-28327", "% ld", +__LINE__, 0x032854a3, "0X32854A3", "% #6X", +__LINE__, 0x0000004b, "4b", "%x", +__LINE__, 0xffff6ca3, "FFFF6CA3", "%4.X", +__LINE__, 0x00000000, "0", "%X", +__LINE__, 0x00611f04, "611F04", "%.1X", +__LINE__, 0x00000000, " 0", "%#6d", +__LINE__, 0x0002c711, "2c711", "%-02.x", +__LINE__, -0x07a2fe4, "-8007652", "%d", +__LINE__, -0x0000547, "-1351", "%ld", +__LINE__, 0x00013954, "0x13954", "%#x", +__LINE__, -0x00523b7, "-336823", "%ld", +__LINE__, -0x00f6c6e, "-1010798", "%6.ld", +__LINE__, 0xffea6427, "FFEA6427", "%3X", +__LINE__, -0x0000005, "-5", "%d", +__LINE__, -0x04fe618, "-5236248", "% .7d", +__LINE__, 0xffa80a28, "ffa80a28", "%-0x", +__LINE__, 0x00000047, "71", "%ld", +__LINE__, 0x001dc6bb, "1951419", "%#4ld", +__LINE__, 0x00000868, " 2152", "%#6d", +__LINE__, 0x000002fb, "2fb", "%x", +__LINE__, 0x00607fa0, "6324128", "%4d", +__LINE__, 0xfffed161, "fffed161", "%x", +__LINE__, 0x0001c6e4, " 116452", "% 2.5d", +__LINE__, 0x0003dda8, "3DDA8", "%4X", +__LINE__, 0xfffffff8, "fffffff8", "%x", +__LINE__, 0xfacf664a, "facf664a", "%x", +__LINE__, 0x000000c1, "C1", "% 1X", +__LINE__, 0x0000839c, " 839C", "%6X", +__LINE__, 0xfffff69a, "FFFFF69A", "%X", +__LINE__, 0x000e5c2e, "+941102", "%+d", +__LINE__, -0x0000004, "-4", "%#d", +__LINE__, 0x00000000, "00000", "%#.5ld", +__LINE__, 0xfffffffe, "fffffffe", "%3.1x", +__LINE__, 0x0010ed68, "1109352", "%-ld", +__LINE__, 0xffffffe9, "ffffffe9", "%.6x", +__LINE__, 0x00000007, " 7", "% 4.ld", +__LINE__, 0x0000caba, "51898", "%ld", +__LINE__, -0x0000119, "-281", "% d", +__LINE__, 0x0c3012a9, "204477097", "%03.6ld", +__LINE__, -0x001c98f, "-117135", "%ld", +__LINE__, 0x000017b1, "+6065", "%+d", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, -0x0000019, "-25", "% .2d", +__LINE__, 0x0009ae28, "9AE28", "%X", +__LINE__, 0xe861c4fe, "e861c4fe", "%7.x", +__LINE__, 0xffac88d3, "FFAC88D3", "%X", +__LINE__, -0x00005df, "-01503", "%-5.5ld", +__LINE__, 0x0000013e, "318", "%-0d", +__LINE__, 0x04b6f58f, "4b6f58f", "%x", +__LINE__, 0xfffe3978, "fffe3978", "%+0.6x", +__LINE__, 0x57ee5244, "57ee5244", "%+7.4x", +__LINE__, 0xfffb5610, "fffb5610", "% 6x", +__LINE__, 0x00000006, " 6", "%#7d", +__LINE__, 0x0000000c, "0x0000c", "%#.5x", +__LINE__, -0xec59362, "-247829346", "%1.7d", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, -0x0007e4b, "-32331", "% d", +__LINE__, 0x0ececa6f, "248433263", "%0d", +__LINE__, 0x00000578, " 578", "%+6.x", +__LINE__, -0x0000003, "-3", "%ld", +__LINE__, 0x000002bb, "2bb", "% 0x", +__LINE__, -0x0000006, "-6", "%-ld", +__LINE__, 0x000002f9, "761", "%d", +__LINE__, 0xffffd736, "ffffd736", "%3.4x", +__LINE__, 0x0010ba79, "1096313", "%7.4d", +__LINE__, -0x0001244, "-4676", "%#.1d", +__LINE__, 0x00000dbe, "DBE", "%1X", +__LINE__, -0x0000015, "-21", "%-0.d", +__LINE__, 0xffffffff, "0xffffffff", "%#x", +__LINE__, -0x6cdf4a3, "-114160803", "%ld", +__LINE__, 0x00008ac9, "8AC9", "%1X", +__LINE__, 0x00000000, "00", "%.2X", +__LINE__, -0x2263dba, "-36060602", "%5.5d", +__LINE__, 0x00007da9, "32169", "%0d", +__LINE__, 0xfffffff7, "FFFFFFF7", "% 4.X", +__LINE__, 0xfbf36cca, "FBF36CCA", "%.1X", +__LINE__, 0x00000040, "64", "%.0ld", +__LINE__, 0x0000001c, " 28", "% d", +__LINE__, 0xfffffadb, "0xfffffadb", "%#.5x", +__LINE__, 0x0eb95847, "247027783", "%d", +__LINE__, 0xfffd7030, "FFFD7030", "%+02X", +__LINE__, 0x00000005, "00005", "%.5x", +__LINE__, 0xfffffffd, "FFFFFFFD", "%X", +__LINE__, 0x98975b15, "98975B15", "%02X", +__LINE__, -0x0000034, " -52", "%6ld", +__LINE__, 0xffd7d0cc, "ffd7d0cc", "% 5.6x", +__LINE__, 0xffffffa6, "FFFFFFA6", "%X", +__LINE__, 0xfff27132, "fff27132", "%x", +__LINE__, -0x065b74d, "-6666061", "%+6ld", +__LINE__, 0xf6ac99d6, "0XF6AC99D6", "%#X", +__LINE__, 0xfffff4bd, "FFFFF4BD", "%X", +__LINE__, 0xfffffb62, "FFFFFB62", "%6X", +__LINE__, 0xf8434543, "f8434543", "%-0x", +__LINE__, 0x0002b374, "0x2b374", "%-#6x", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xffb5751d, "ffb5751d", "%-3.x", +__LINE__, 0x34ea7347, "887780167", "%d", +__LINE__, -0x008f457, "-586839", "%0ld", +__LINE__, 0x00000001, " 1", "%#4d", +__LINE__, 0xc32d7ad4, "c32d7ad4", "%0x", +__LINE__, 0xfffffb80, "FFFFFB80", "%-.2X", +__LINE__, 0x00000756, "756 ", "%-6x", +__LINE__, 0xfffb020f, "FFFB020F", "%+.2X", +__LINE__, -0xe68619f, "-241721759", "%#1.6ld", +__LINE__, 0x180166cd, "402745037", "%3.7ld", +__LINE__, -0x0000001, "-1", "%+00d", +__LINE__, 0xfdbc3611, "fdbc3611", "%x", +__LINE__, -0x000005b, "-91", "%d", +__LINE__, 0xffffe77f, "ffffe77f", "%x", +__LINE__, -0x0000019, "-25", "%ld", +__LINE__, 0x00000016, "22", "%#d", +__LINE__, -0x0000025, "-37", "%ld", +__LINE__, 0xffffe43f, "ffffe43f", "%x", +__LINE__, 0x000050a5, "00050a5", "%.7x", +__LINE__, 0x0000000c, " 12", "% 5.ld", +__LINE__, -0x001faff, "-129791", "%4d", +__LINE__, 0x239d7cf2, "597523698", "%0.7ld", +__LINE__, 0x04092183, "4092183", "% 7X", +__LINE__, -0x0043498, "-275608", "%-ld", +__LINE__, -0x0018dbe, "-101822", "%d", +__LINE__, 0xff3e09c3, "FF3E09C3", "%X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, -0x15d57558, "-366310744", "%+0.7ld", +__LINE__, 0x0004fb06, "326406", "%0.0d", +__LINE__, 0x00000119, "0X119", "%#X", +__LINE__, -0x14c53e19, "-348470809", "%d", +__LINE__, 0x00000019, "0000019", "% .7X", +__LINE__, -0x0000654, "-1620", "%0.4ld", +__LINE__, -0xde5899b, "-233146779", "%#.1d", +__LINE__, 0x0013c1f0, "1294832", "%4.ld", +__LINE__, 0x0a9fe761, "A9FE761", "%X", +__LINE__, -0x00000e5, "-229", "%1ld", +__LINE__, 0x00000161, "000353", "%.6ld", +__LINE__, 0x6b04e4bd, "0x6b04e4bd", "%#7.0x", +__LINE__, -0x0000ef0, "-3824 ", "%-6.ld", +__LINE__, -0x026306e, "-2502766", "%ld", +__LINE__, 0x00000000, "0", "%-X", +__LINE__, 0xfffffe1f, "fffffe1f", "%-x", +__LINE__, 0x0003aecf, " 241359", "% 2.1ld", +__LINE__, -0x0000014, "-20", "%d", +__LINE__, 0x00000002, "0002", "%-.4ld", +__LINE__, 0xfffff662, "0XFFFFF662", "% #.6X", +__LINE__, 0x00000006, "6", "%0x", +__LINE__, 0x0001f4c4, " 128196", "% 0d", +__LINE__, 0xffffffff, "FFFFFFFF", "%5X", +__LINE__, 0x05605e38, "90201656", "%ld", +__LINE__, 0xffffffde, "0XFFFFFFDE", "% #X", +__LINE__, 0x000001e0, " 1e0", "%7.x", +__LINE__, 0x00000007, "7", "%X", +__LINE__, 0x00000001, "+1", "%+d", +__LINE__, 0xffffffe0, "FFFFFFE0", "% X", +__LINE__, 0xffd7f77a, "FFD7F77A", "%+00.1X", +__LINE__, 0xfffffffe, "0xfffffffe", "%-#x", +__LINE__, 0x01b0a63b, "1b0a63b", "%x", +__LINE__, -0x06554b7, "-6640823", "%d", +__LINE__, 0xfffffff8, "fffffff8", "%x", +__LINE__, 0x00000b2d, "b2d", "%x", +__LINE__, -0x2664ba2, "-40258466", "%-d", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, -0x0000552, " -1362", "%6.2ld", +__LINE__, 0x00000009, " 00009", "%6.5x", +__LINE__, 0x00035c72, "220274", "%05.ld", +__LINE__, -0x014d09d, "-1364125", "%d", +__LINE__, -0x0000002, " -2", "% 4d", +__LINE__, 0x00000001, "1", "%+X", +__LINE__, 0x00000028, "28", "%X", +__LINE__, 0xf25c9eb2, "F25C9EB2", "%7.X", +__LINE__, -0x7ae4b62, "-128863074", "%d", +__LINE__, 0x00630d87, "630D87", "%2X", +__LINE__, 0x000000f8, "F8", "%-X", +__LINE__, 0xfffffff9, "FFFFFFF9", "%X", +__LINE__, -0x0000007, "-7", "%0d", +__LINE__, -0x2518fcd, "-38899661", "% 3ld", +__LINE__, 0xfffff4b4, "FFFFF4B4", "%-5X", +__LINE__, 0x01cc36c8, "30160584", "%ld", +__LINE__, 0xffffffff, "ffffffff", "%-x", +__LINE__, 0x0000000b, " 11", "%6.ld", +__LINE__, 0x00010d55, " 68949", "% d", +__LINE__, -0x0c01306, "-12587782", "% 6.1ld", +__LINE__, 0x001719d7, "1513943", "%.1ld", +__LINE__, -0x0000002, " -2", "%+3.ld", +__LINE__, 0x0000018e, "398", "%d", +__LINE__, 0x000000a6, "0xa6", "%-#3x", +__LINE__, 0x00006f66, " 28518", "% #d", +__LINE__, 0x0000032a, "32A", "%X", +__LINE__, -0x0000145, "-325", "%0d", +__LINE__, 0xffffffff, "ffffffff", "%2.x", +__LINE__, 0x00287171, "2650481", "%ld", +__LINE__, 0x0000004b, "+75", "%+02.ld", +__LINE__, 0xfffffff8, "fffffff8", "%-0x", +__LINE__, 0x00000064, "64", "% X", +__LINE__, 0xfffffca2, "fffffca2", "%0x", +__LINE__, 0x000010b6, "10b6", "% .0x", +__LINE__, -0x003806f, "-229487", "%7d", +__LINE__, -0x00000b7, "-183", "%3ld", +__LINE__, 0xffffe5ba, "FFFFE5BA", "%0X", +__LINE__, 0x001f0da8, "1f0da8", "%+x", +__LINE__, 0x000ce185, "844165", "%0ld", +__LINE__, 0x00000c96, "3222", "%0d", +__LINE__, -0x0013099, "-77977", "%1.ld", +__LINE__, -0x5f3c47a, "-99861626", "%.6ld", +__LINE__, 0x00000cbf, " CBF", "%+5.X", +__LINE__, -0x0000001, "-1", "%+ld", +__LINE__, 0x0d793bc3, "d793bc3", "%6.x", +__LINE__, 0xfffffffd, "0xfffffffd", "%+#x", +__LINE__, -0x0000070, " -112", "%6.d", +__LINE__, 0xfffffb3f, "FFFFFB3F", "%.7X", +__LINE__, 0x037dfc78, "0X37DFC78", "%#X", +__LINE__, 0x00009ba5, "39845", "%3ld", +__LINE__, 0x0000004a, "4a", "%0x", +__LINE__, 0xffffff81, "ffffff81", "%5.5x", +__LINE__, -0x86ef222, "-141488674", "%ld", +__LINE__, -0xac5531e, "-180704030", "% 4ld", +__LINE__, 0x00002493, "2493", "%+X", +__LINE__, 0xffffffff, "FFFFFFFF", "%1.3X", +__LINE__, 0x0005c875, "378997", "%.0ld", +__LINE__, 0x0301d345, "50451269", "%d", +__LINE__, 0xfff6b589, "fff6b589", "%2.4x", +__LINE__, -0x00001db, "-475 ", "%-7.0d", +__LINE__, 0x0000d1e7, "0x000d1e7", "%#2.7x", +__LINE__, 0xf4c4d2bb, "f4c4d2bb", "%.6x", +__LINE__, 0x00c89f54, "13147988", "%ld", +__LINE__, -0x6599253c, "-1704535356", "%+ld", +__LINE__, 0xab7d61ea, "ab7d61ea", "% x", +__LINE__, 0x00000006, "6", "%1ld", +__LINE__, 0xffff5ab7, "ffff5ab7", "%0x", +__LINE__, -0x1cfeca5b, "-486459995", "%#ld", +__LINE__, 0x000000f3, " f3", "% 6.x", +__LINE__, -0x0000021, "-33", "%d", +__LINE__, 0xfe7246ac, "fe7246ac", "%-5.x", +__LINE__, 0x00000017, "00017", "%-.5X", +__LINE__, -0x0cc250a, "-13378826", "%0.0d", +__LINE__, -0x00010ae, "-04270", "%#.5ld", +__LINE__, -0x7952c8b, "-127216779", "% ld", +__LINE__, 0x0002a53e, "173374", "%4.0d", +__LINE__, 0x03801bbf, "3801BBF", "%0X", +__LINE__, 0x0368645f, "+57173087", "%+#0.6ld", +__LINE__, 0x0000002f, "47", "%d", +__LINE__, 0x00000003, "3", "%x", +__LINE__, 0x000005f7, "5F7", "%0X", +__LINE__, -0x06e5e76, "-7233142", "% 0.1ld", +__LINE__, 0x053da936, "53da936", "%1.4x", +__LINE__, -0x0df0c2f, "-14617647", "%.5ld", +__LINE__, 0xfffffffd, "FFFFFFFD", "%-0X", +__LINE__, 0x000104bf, "104BF", "%X", +__LINE__, 0x000353fc, "353FC", "%X", +__LINE__, 0x182a18dc, "+405412060", "%+ld", +__LINE__, 0x0000000e, " 14", "% 2d", +__LINE__, -0x0000091, "-145", "%+ld", +__LINE__, 0x0029a9d6, "2730454", "%d", +__LINE__, 0x00009d57, "009d57", "% .6x", +__LINE__, 0x4c4d4f79, "1280135033", "%5.ld", +__LINE__, -0x000075b, "-1883", "% 03d", +__LINE__, -0x001b718, "-112408", "%+d", +__LINE__, 0xfffaaf57, "FFFAAF57", "%+1X", +__LINE__, 0x00f44e52, "F44E52", "% 4X", +__LINE__, 0x00000002, "0X2", "%#X", +__LINE__, 0x000a85e9, "A85E9", "%+0X", +__LINE__, 0xffff70bb, "ffff70bb", "%6x", +__LINE__, 0x00004e15, "4e15", "%x", +__LINE__, 0x000eeb60, " 977760", "% ld", +__LINE__, 0xfffffff1, "fffffff1", "%0x", +__LINE__, -0x294d7e2, "-43309026", "% 02.d", +__LINE__, 0x0001aaeb, "0109291", "%02.7ld", +__LINE__, 0x000a01fc, "0xa01fc", "%-#.5x", +__LINE__, 0x002c3c30, "+2898992", "%+#d", +__LINE__, 0x015667ae, "+22439854", "%+5ld", +__LINE__, -0x05af42b, "-5960747", "%+d", +__LINE__, 0x0000be36, "be36", "%+2x", +__LINE__, 0x005e3f67, "5e3f67", "% x", +__LINE__, -0x0000020, "-32", "% ld", +__LINE__, -0x0003617, "-13847", "% d", +__LINE__, 0x00000014, "14 ", "%-4.X", +__LINE__, 0x00000001, "001", "%0.3d", +__LINE__, 0xfffffea9, "fffffea9", "%3.x", +__LINE__, 0xe447099e, "E447099E", "%0X", +__LINE__, 0x00049c71, "302193", "%d", +__LINE__, 0x76356ed3, "0x76356ed3", "%#4.1x", +__LINE__, 0x00000005, " 0X5", "%#5X", +__LINE__, 0x00004da2, "0x004da2", "%#1.6x", +__LINE__, 0xffdfb36c, "FFDFB36C", "%4X", +__LINE__, 0xffffe3c5, "FFFFE3C5", "%+4.X", +__LINE__, 0x00000006, "6", "%0x", +__LINE__, -0x914ff17, "-152370967", "% .5ld", +__LINE__, -0x0000002, "-2", "%0ld", +__LINE__, 0xffffff36, "FFFFFF36", "% 2X", +__LINE__, -0x0bb1598, "-12260760", "%-ld", +__LINE__, 0x00006db5, "28085", "%0.5ld", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, -0x0000001, "-1", "%0ld", +__LINE__, 0x0fa37e79, "FA37E79", "%1.X", +__LINE__, -0x00000ac, "-172", "%.2d", +__LINE__, 0xffffffd8, "ffffffd8", "%.7x", +__LINE__, -0x000a513, "-42259", "%ld", +__LINE__, 0x00001294, "4756", "%2ld", +__LINE__, -0x56bae0b4, "-1455087796", "%.1ld", +__LINE__, 0x3b26d5fa, "3b26d5fa", "%x", +__LINE__, 0xff657013, "ff657013", "%x", +__LINE__, -0x00005f5, "-1525", "%0.0ld", +__LINE__, -0x0000001, " -1", "% 7d", +__LINE__, -0x02396b2, "-2332338", "%d", +__LINE__, -0x0000003, "-000003", "%+7.6d", +__LINE__, 0xfd3ec7c1, "fd3ec7c1", "% 3.4x", +__LINE__, -0x076e338, "-7791416", "%0.d", +__LINE__, -0x000015e, "-350", "%3ld", +__LINE__, 0x0a0f0b71, "a0f0b71", "%x", +__LINE__, 0xfffe00ba, "FFFE00BA", "%X", +__LINE__, 0x00036bd8, " 36bd8", "% 06.x", +__LINE__, 0xfffff2df, "0XFFFFF2DF", "%#2.6X", +__LINE__, 0x004687fb, "4622331", "%ld", +__LINE__, -0x0000331, " -817", "%+6.d", +__LINE__, 0xfcd5b090, "fcd5b090", "%+0x", +__LINE__, 0x0334f94c, "334F94C", "%.6X", +__LINE__, 0x00000bce, "3022", "%.3ld", +__LINE__, 0xf28d9ddd, "f28d9ddd", "%x", +__LINE__, 0x00003a79, " 14969", "% ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%.7X", +__LINE__, 0x0043d7fe, "43D7FE", "%X", +__LINE__, -0x0000b82, "-2946", "%-ld", +__LINE__, -0x00e29d8, "-928216", "%d", +__LINE__, 0xffffffec, "ffffffec", "%-x", +__LINE__, 0x0aeaf557, "0xaeaf557", "%-#x", +__LINE__, 0x00c07fe6, "C07FE6", "%X", +__LINE__, 0x307414d8, "307414d8", "% 0x", +__LINE__, -0x045ef67, "-4583271", "%d", +__LINE__, 0x0000024a, " 0000586", "% .7d", +__LINE__, 0xfffffc42, "fffffc42", "%x", +__LINE__, 0xfc38c249, "fc38c249", "%5.x", +__LINE__, -0x000d096, "-53398", "%-d", +__LINE__, -0x213a345, "-34841413", "%ld", +__LINE__, -0x0000130, "-304", "%ld", +__LINE__, -0x000efd1, "-61393", "%ld", +__LINE__, 0xfffff867, "FFFFF867", "%2X", +__LINE__, 0x00113ed0, "0x113ed0", "%-#7x", +__LINE__, 0x00000677, " 1655", "% 3.ld", +__LINE__, 0x0000002f, "2f", "%x", +__LINE__, 0xfffffd38, "fffffd38", "%-4x", +__LINE__, -0x000b3cc, "-46028", "%1.2d", +__LINE__, 0x45da719b, "45DA719B", "%+0X", +__LINE__, -0x000a454, " -42068", "%7.3ld", +__LINE__, 0x01cc7c30, " 30178352", "% d", +__LINE__, -0x05ae80e, "-5957646", "%#.4ld", +__LINE__, 0x000000b9, "185", "%d", +__LINE__, 0x003fcaf4, "4180724", "%1.ld", +__LINE__, 0x02da1b74, "2DA1B74", "%X", +__LINE__, 0xffffffd9, "FFFFFFD9", "%X", +__LINE__, 0x00064359, "64359 ", "%-6X", +__LINE__, 0x000000f0, "240", "%ld", +__LINE__, -0x01715e5, "-1512933", "%ld", +__LINE__, 0xc8f6e118, "0XC8F6E118", "%#X", +__LINE__, 0xfffffd8f, "FFFFFD8F", "%X", +__LINE__, 0x0000176d, "5997 ", "%-6d", +__LINE__, 0x00003cab, "0x3cab", "%#0.3x", +__LINE__, 0x00000001, " 1", "% d", +__LINE__, 0xfffff610, "0XFFFFF610", "%#X", +__LINE__, 0xfffffffe, "FFFFFFFE", "%5.7X", +__LINE__, 0x00000001, "1", "%0x", +__LINE__, 0x00000001, "00001", "%.5ld", +__LINE__, -0x0000d51, "-3409", "%d", +__LINE__, -0x08639ee, "-8796654", "%ld", +__LINE__, 0x00003121, "12577", "%#1.2ld", +__LINE__, 0x0000004e, "78", "%d", +__LINE__, 0xfffff64f, "fffff64f", "%-x", +__LINE__, 0x0000002a, "2a", "%0x", +__LINE__, 0x00000020, "20", "%x", +__LINE__, -0x00000b8, "-184", "%#ld", +__LINE__, 0x0000000a, "10", "%-#d", +__LINE__, 0x00000364, "868", "%.1ld", +__LINE__, 0x00d1f9b6, "D1F9B6", "%0.X", +__LINE__, 0x008cfda1, "8CFDA1", "% 6.X", +__LINE__, 0xffd58cce, "FFD58CCE", "%X", +__LINE__, 0x00000008, "0000008", "%6.7ld", +__LINE__, 0x00000318, " 318", "%4X", +__LINE__, 0x000172d8, "94936", "%2ld", +__LINE__, -0x056ccbf, "-5688511", "%ld", +__LINE__, 0x000000c7, "+000199", "%+0.6d", +__LINE__, 0x00000002, "0X2", "%-#X", +__LINE__, 0xfffff634, "FFFFF634", "%.1X", +__LINE__, -0x00001f3, "-499", "%-ld", +__LINE__, -0x000081b, "-2075", "%-d", +__LINE__, 0x000000b5, "181", "%0d", +__LINE__, 0xfe961ee8, "fe961ee8", "%0x", +__LINE__, 0x000028a2, "10402", "%d", +__LINE__, 0xffffffff, "FFFFFFFF", "%.4X", +__LINE__, -0x000058a, "-1418", "%.3ld", +__LINE__, 0x00001ceb, "1CEB", "%X", +__LINE__, 0x00000021, "21", "% X", +__LINE__, 0x00000002, "2", "%0d", +__LINE__, -0x2f9bbf5, "-49921013", "%.4ld", +__LINE__, 0x00000e91, "03729", "%#.5ld", +__LINE__, 0xf1116740, "f1116740", "%2x", +__LINE__, 0x00014f72, "14F72", "%X", +__LINE__, 0xfffffced, "FFFFFCED", "%X", +__LINE__, 0xffffffff, "ffffffff", "%.5x", +__LINE__, 0x0017cf0c, " 1560332", "% 0ld", +__LINE__, 0x0000000a, "A", "% X", +__LINE__, 0xff3a39d4, "ff3a39d4", "%x", +__LINE__, 0xfffef05f, "FFFEF05F", "%X", +__LINE__, 0xfedfe708, "fedfe708", "%03.0x", +__LINE__, 0x000345a0, "345A0", "% X", +__LINE__, -0x1ed5b6f7, "-517322487", "%d", +__LINE__, 0xd2d56c22, "D2D56C22", "%0.X", +__LINE__, 0x00002cbf, "2CBF", "%.2X", +__LINE__, 0x00000db4, "db4", "%3x", +__LINE__, -0x000b154, "-45396", "%d", +__LINE__, 0x002bf4c7, "2BF4C7", "%X", +__LINE__, 0x6954abf4, "+1767156724", "%+d", +__LINE__, 0xfffffffb, "fffffffb", "%x", +__LINE__, -0x29e0050e, "-702547214", "%-0ld", +__LINE__, -0x0014989, "-84361", "%-#0.3ld", +__LINE__, 0x001a557c, "+1725820", "%+6.5d", +__LINE__, -0x56689a81, "-1449695873", "%.2d", +__LINE__, 0x00000016, " 16", "%05.X", +__LINE__, 0x0001da1e, " 121374", "% d", +__LINE__, -0x04deac7, "-5106375", "%03.4d", +__LINE__, 0x000012b1, "4785", "%d", +__LINE__, 0x0009a116, "9a116", "%-x", +__LINE__, -0x0000003, "-000003", "%4.6ld", +__LINE__, 0x00000000, "", "%.0x", +__LINE__, 0x0000000a, " A", "% 3X", +__LINE__, 0xfffffff0, "0xfffffff0", "%-#0.1x", +__LINE__, 0x00000086, "86", "%0X", +__LINE__, 0x0000001f, "31", "%-d", +__LINE__, 0x0386f706, "59176710", "%3.6ld", +__LINE__, 0xffe437ae, "0XFFE437AE", "%#X", +__LINE__, 0x0e5405c6, "e5405c6", "%-x", +__LINE__, 0xfffdee46, "FFFDEE46", "%+X", +__LINE__, 0xff861e9d, "FF861E9D", "%5.X", +__LINE__, 0xfffff570, "FFFFF570", "%-X", +__LINE__, 0x045c90bd, "45c90bd", "%0x", +__LINE__, 0x000000aa, "AA", "%+X", +__LINE__, -0x747262e, "-122103342", "%0ld", +__LINE__, 0xffffad89, "FFFFAD89", "%X", +__LINE__, 0x00000018, "18", "%0.2X", +__LINE__, 0x00057a2d, " 358957", "% #7.d", +__LINE__, 0x73a0e21d, "1939923485", "%ld", +__LINE__, -0x00021e1, "-8673", "%0d", +__LINE__, 0x000000e9, " 233", "% 06.3ld", +__LINE__, 0xffffcc0d, "ffffcc0d", "%x", +__LINE__, 0x00000052, "52", "%x", +__LINE__, 0x01c155af, "1C155AF", "%.5X", +__LINE__, 0xffffffff, "ffffffff", "%0.x", +__LINE__, -0x00400a4, "-262308", "%-d", +__LINE__, -0x0000001, "-0000001", "%#.7ld", +__LINE__, 0x01fb9c99, "1fb9c99", "% 03.5x", +__LINE__, 0xffffffff, "ffffffff", "%6.x", +__LINE__, 0xff5e5eea, "FF5E5EEA", "%X", +__LINE__, 0x0000000f, "F", "%+0X", +__LINE__, 0xfffffe3a, "fffffe3a", "% x", +__LINE__, 0xfffffffe, "FFFFFFFE", "%-X", +__LINE__, -0x0000007, "-7", "%0ld", +__LINE__, -0x002f635, "-194101", "%d", +__LINE__, -0x0000005, "-5", "%ld", +__LINE__, -0x0000059, "-89", "%0ld", +__LINE__, -0x1ccda96, "-30202518", "%d", +__LINE__, -0x0000002, "-2", "%-d", +__LINE__, 0xffffffda, "0XFFFFFFDA", "%#X", +__LINE__, 0x00036cc5, "224453", "%#d", +__LINE__, 0x00000010, "+16", "%+ld", +__LINE__, 0x0b6039c7, "190855623", "%d", +__LINE__, -0x0000002, "-002", "%#.3d", +__LINE__, 0xfff3e746, "FFF3E746", "%-4X", +__LINE__, 0x0361b3de, "361B3DE", "% 04X", +__LINE__, 0xffffe6a2, "ffffe6a2", "%-x", +__LINE__, 0x00032790, "0x0032790", "%#7.7x", +__LINE__, 0xffe33b4e, "ffe33b4e", "%-0x", +__LINE__, -0x0094663, "-607843", "%.3ld", +__LINE__, -0x00a3efa, "-671482", "%4d", +__LINE__, 0x000000e6, " 00E6", "%7.4X", +__LINE__, 0x000125cb, "125CB", "%+X", +__LINE__, 0x0000b97e, "b97e", "%x", +__LINE__, -0x0000039, "-57", "%+ld", +__LINE__, 0xffffe39a, "ffffe39a", "%5.4x", +__LINE__, 0xffffffff, "ffffffff", "%6.1x", +__LINE__, -0xdee910c, "-233738508", "%-#2d", +__LINE__, -0x14044930, "-335825200", "%6.ld", +__LINE__, 0x00a81259, "a81259", "%x", +__LINE__, 0x020e74c6, "20E74C6", "%X", +__LINE__, -0x00000fb, "-251", "%01.d", +__LINE__, 0x034ceb45, "34CEB45", "%5.X", +__LINE__, 0xfeacb66a, "feacb66a", "% x", +__LINE__, 0x00003eb6, "3EB6", "% X", +__LINE__, 0x000009ef, "9ef", "% x", +__LINE__, 0xf9d9dd07, "F9D9DD07", "%0X", +#ifndef __PCCNECV70__ + +__LINE__, 0x000154d7, "087255", "%.6ld", +__LINE__, -0x000036e, "-878", "%-ld", +__LINE__, -0x0007dcc, "-32204", "% d", +__LINE__, 0x000019dc, "6620", "%d", +__LINE__, 0xffffff6e, "FFFFFF6E", "%2X", +__LINE__, 0x00000016, "0x16", "%-#x", +__LINE__, 0xffdb3e96, "ffdb3e96", "%+.5x", +__LINE__, 0xffffffef, "FFFFFFEF", "% 04.X", +__LINE__, 0xffffffff, "FFFFFFFF", "%5X", +__LINE__, 0x000c08cd, "C08CD", "%-X", +__LINE__, 0x18de71ee, "18de71ee", "%x", +__LINE__, 0xffffffff, "ffffffff", "% x", +__LINE__, -0x00025bd, "-009661", "%#.6d", +__LINE__, 0x2f05de14, " 788913684", "% 6.4ld", +__LINE__, 0x0c99cf86, "211406726", "%.5d", +__LINE__, 0x09e6a21d, " 166109725", "% 0d", +__LINE__, -0x013da65, "-1301093", "%+ld", +__LINE__, 0x000003d0, " 976", "% 4.2d", +__LINE__, -0xef9e3cc, "-251257804", "%-7.0d", +__LINE__, 0x0000000c, "+12", "%+00ld", +__LINE__, 0xffffffe2, "ffffffe2", "%x", +__LINE__, 0x000000fe, "fe", "%-x", +__LINE__, 0xfffffc5f, "fffffc5f", "%x", +__LINE__, -0x0005c55, "-23637", "%d", +__LINE__, -0x0111ff2, "-1122290", "% 7.d", +__LINE__, -0x1a1746e5, "-437733093", "%.4ld", +__LINE__, 0x00001007, "004103", "%00.6d", +__LINE__, 0xffffffe1, "ffffffe1", "%x", +__LINE__, 0x0000d80f, "55311", "%d", +__LINE__, 0x00000004, "4", "%+X", +__LINE__, 0xfffffffd, "fffffffd", "%6x", +__LINE__, -0x2afbcc3c, "-721144892", "%4.6ld", +__LINE__, 0x00377f96, "377F96", "%6.X", +__LINE__, 0xffffffc8, "FFFFFFC8", "%0X", +__LINE__, 0x007ed9d1, "8313297", "%-3d", +__LINE__, 0x00000000, "0", "%-X", +__LINE__, 0x001e122d, "1970733", "%01.d", +__LINE__, -0x000029b, "-667", "%ld", +__LINE__, -0x002f563, "-193891", "% 2.5d", +__LINE__, 0xfffffffe, "fffffffe", "%+3.7x", +__LINE__, 0xfff7658c, "fff7658c", "%x", +__LINE__, -0x0006d08, "-0027912", "%7.7ld", +__LINE__, 0x00000080, "80", "%X", +__LINE__, 0x0000078f, " 1935", "% 6ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "% X", +__LINE__, 0x000000ae, " AE", "%7.X", +__LINE__, -0x000d6aa, "-54954", "%-ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%6.X", +__LINE__, 0x000003bf, "+959", "%+d", +__LINE__, -0x7242d04b, "-1916981323", "% ld", +__LINE__, 0xf0e6546f, "F0E6546F", "% .7X", +__LINE__, 0x047e196a, "75372906", "%ld", +__LINE__, 0x0240174e, "240174E", "%+0X", +__LINE__, -0x0000006, "-006", "%.3ld", +__LINE__, 0x00068aac, "428716", "%#ld", +__LINE__, 0xffffffa1, "ffffffa1", "%0x", +__LINE__, 0x000adab3, "adab3", "%x", +__LINE__, -0x00000ae, "-0000174", "%7.7ld", +__LINE__, 0x0f0a8f4b, "f0a8f4b", "% x", +__LINE__, 0xfee229bc, "fee229bc", "%x", +__LINE__, -0x275b8455, "-660309077", "%.2ld", +__LINE__, -0xca4b2a5, "-212120229", "%d", +__LINE__, 0x000000b5, " 181", "%04.d", +__LINE__, 0xfff213f2, "FFF213F2", "%X", +__LINE__, 0x00000003, "3", "%-X", +__LINE__, 0x0ebb978b, "247175051", "%.6ld", +__LINE__, 0xffffffca, "FFFFFFCA", "%X", +__LINE__, -0x0000003, "-03", "%+0.2d", +__LINE__, -0x178ff86, "-24706950", "%+d", +__LINE__, 0x0000003c, " 60", "%7.ld", +__LINE__, -0x001012d, "-65837", "%.5d", +__LINE__, 0x03673fd2, "3673fd2", "%.5x", +__LINE__, -0x001fe74, "-130676", "%#0.6ld", +__LINE__, 0x004f6226, "4f6226", "%-0x", +__LINE__, 0xfffffa0f, "fffffa0f", "%7x", +__LINE__, 0xfffffff8, "fffffff8", "%-.6x", +__LINE__, -0x0000001, "-1", "%#d", +__LINE__, 0xffffe43d, "ffffe43d", "%7x", +__LINE__, 0x00009d47, "0040263", "%7.7ld", +__LINE__, 0xff0fc79f, "FF0FC79F", "%-4.X", +__LINE__, 0x2d610907, "2d610907", "%x", +__LINE__, -0x00002de, "-734", "%04d", +__LINE__, 0x0000036b, " 36B", "%7.1X", +__LINE__, 0x00000002, "2", "%.0x", +__LINE__, -0x1f577b3e, "-525826878", "%d", +__LINE__, 0x0000002d, "45", "%#ld", +__LINE__, 0xfffffffb, "fffffffb", "%x", +__LINE__, -0x0000004, "-4", "%-.0d", +__LINE__, 0x00016ba4, "16ba4", "%x", +__LINE__, -0x1ad853d5, "-450384853", "% 0ld", +__LINE__, 0x00366899, "366899", "%2.x", +__LINE__, 0x1659158b, "1659158B", "%X", +__LINE__, 0x000076c7, "76c7", "%x", +__LINE__, 0x00000674, "674", "%0x", +__LINE__, 0x016c9d8a, "+23895434", "%+ld", +__LINE__, 0xfffffc43, "FFFFFC43", "%0X", +__LINE__, 0xfff249d2, "fff249d2", "%-2.x", +__LINE__, 0xffffffdd, "ffffffdd", "%5x", +__LINE__, 0xffffa7ef, "FFFFA7EF", "%0.3X", +__LINE__, 0x030d4d06, "30d4d06", "%x", +__LINE__, -0x0e4694b, "-14969163", "%d", +__LINE__, 0x00000078, "120", "%.3ld", +__LINE__, -0x16c1273e, "-381757246", "%0d", +__LINE__, 0xffffd183, "FFFFD183", "% 0X", +__LINE__, -0x2dfdadd, "-48224989", "%ld", +__LINE__, -0x5767fe5c, "-1466433116", "%ld", +__LINE__, 0x01bea036, "29270070", "%#4.3d", +__LINE__, 0x00000027, "27", "%-x", +__LINE__, 0x0004d183, "4D183", "%X", +__LINE__, 0xffdaf9c8, "FFDAF9C8", "%.7X", +__LINE__, 0xfffffd95, "fffffd95", "%x", +__LINE__, -0x0059acb, "-367307", "%00.d", +__LINE__, 0x017d8db4, "17d8db4", "% 05.x", +__LINE__, 0x0001f084, "001F084", "%5.7X", +__LINE__, 0x00000006, " 6", "% ld", +__LINE__, 0x011b0802, "18548738", "%.3ld", +__LINE__, 0x00000006, " 6", "%#3.d", +__LINE__, 0xffffffff, "ffffffff", "%6x", +__LINE__, 0x00000001, "1", "% x", +__LINE__, 0x00000750, " 01872", "% .5d", +__LINE__, 0xfffffff9, "fffffff9", "%x", +__LINE__, -0x00f842c, "-1016876", "%+d", +__LINE__, -0x001dcf0, "-122096", "%-0d", +__LINE__, 0x000000c9, "0XC9", "% #3X", +__LINE__, 0x1e368e86, "1e368e86", "%7x", +__LINE__, -0x0001157, "-4439", "% 03.4d", +__LINE__, 0xfff91e87, "FFF91E87", "%3.5X", +__LINE__, 0x00000006, "6", "%x", +__LINE__, 0x00000bca, "3018", "%ld", +__LINE__, 0x00495ff6, "495ff6", "%01.0x", +__LINE__, -0x0267f7a, "-2523002", "% #5d", +__LINE__, 0x00000060, "96", "%-d", +__LINE__, 0x000850c6, "544966", "%#.1d", +__LINE__, 0x00231457, "231457", "%-6.4X", +__LINE__, 0x0000000b, "11", "%-d", +__LINE__, 0x000003bd, "957", "%#d", +__LINE__, 0xfd51d970, "FD51D970", "%+.7X", +__LINE__, 0x000007bf, "1983", "%-ld", +__LINE__, 0x000034b2, "34B2", "%0.X", +__LINE__, 0x0000c18d, "C18D", "%0.X", +__LINE__, 0xffffbb83, "ffffbb83", "% 3x", +__LINE__, 0x000001d0, "0x1d0", "%#x", +__LINE__, -0x003c784, "-247684", "%#ld", +__LINE__, 0x0210cffa, "210CFFA", "%X", +__LINE__, -0x33093a1, "-53515169", "% 0d", +__LINE__, 0x00000001, " 1", "% #ld", +__LINE__, 0xffffaa53, "ffffaa53", "%-4.5x", +__LINE__, 0x2935c056, "691388502", "%1.d", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x000013d1, "0X013D1", "%+#2.5X", +__LINE__, -0x000035c, "-860", "%-.2d", +__LINE__, 0x00000000, " ", "%-4.X", +__LINE__, -0x0000147, "-327", "%d", +__LINE__, 0x0a317eb0, "171015856", "%.7d", +__LINE__, 0x00000003, "3", "%ld", +__LINE__, 0x000001d6, "1d6", "%-x", +__LINE__, 0x18185214, "404247060", "%-.2ld", +__LINE__, 0x00574140, "0574140", "%.7X", +__LINE__, 0x00002ea5, "02ea5", "%.5x", +__LINE__, 0x00000005, "5", "% x", +__LINE__, 0xffc47ed6, "ffc47ed6", "%-x", +__LINE__, 0x0001f5da, "0X1F5DA", "%#X", +__LINE__, 0xfffffcc9, "fffffcc9", "% x", +__LINE__, 0x02586c98, "2586C98", "%X", +__LINE__, -0x0000036, "-54", "% ld", +__LINE__, 0x00064b57, "412503", "%1.5d", +__LINE__, -0x0000007, "-7", "%#0.0ld", +__LINE__, 0x00023a03, "145923", "%ld", +__LINE__, -0x0000065, "-101", "%+#d", +__LINE__, 0x00000208, "208", "%X", +__LINE__, 0x00e97728, "15300392", "%-ld", +__LINE__, 0x0000030a, "+778", "%+d", +__LINE__, 0xf4d7deee, "F4D7DEEE", "%+X", +__LINE__, -0x000009a, "-154", "%+.3ld", +__LINE__, 0x000002c0, "+704", "%+ld", +__LINE__, 0x0067ec23, "67ec23", "%x", +__LINE__, 0x005ca7fc, "+6072316", "%+d", +__LINE__, 0xfffff5f1, "fffff5f1", "%x", +__LINE__, 0x00000601, " 0X601", "%#7.2X", +__LINE__, -0x0000057, "-87", "% ld", +__LINE__, -0x0000078, " -120", "%7.d", +__LINE__, -0x000001f, "-31 ", "%-6d", +__LINE__, 0x0160c000, "23117824", "%ld", +__LINE__, -0x0000007, "-7", "%0ld", +__LINE__, 0xfffffffe, "fffffffe", "%+x", +__LINE__, 0x5b6ef898, "5b6ef898", "%+0x", +__LINE__, 0x0009bfb6, "638902", "%d", +__LINE__, -0x0000145, " -325", "%#6.0d", +__LINE__, -0x508c048, "-84459592", "%-5.ld", +__LINE__, 0x00000002, " 0x2", "% #4x", +__LINE__, 0x0001486e, "84078", "%#d", +__LINE__, 0x006ac76a, "6997866", "%.6d", +__LINE__, 0xffffff98, "FFFFFF98", "%X", +__LINE__, 0xfffffe08, "fffffe08", "%6.x", +__LINE__, -0x24ef47e, "-38728830", "%1.6ld", +__LINE__, 0x39d1b2db, "39D1B2DB", "% X", +__LINE__, 0xfffc9ce2, "0xfffc9ce2", "%#x", +__LINE__, 0x59485e14, "1497914900", "%#4ld", +__LINE__, 0x000022eb, "22EB", "%3.X", +__LINE__, 0xfa410352, "FA410352", "%-X", +__LINE__, -0x4a342f0, "-77808368", "% ld", +__LINE__, 0xef5825a4, "EF5825A4", "%.6X", +__LINE__, 0x01b0185a, "0x1b0185a", "% #x", +__LINE__, -0x0004290, "-17040", "%.3d", +__LINE__, -0x10f88659, "-284722777", "%+6.2ld", +__LINE__, 0x00003216, "12822", "%-d", +__LINE__, 0x4a31a219, "1244766745", "%d", +__LINE__, 0xffffffb5, "FFFFFFB5", "%-X", +__LINE__, 0x0000d586, "D586", "%-2.X", +__LINE__, 0x00008496, "33942", "%1.d", +__LINE__, -0x0000011, "-17", "%1ld", +__LINE__, 0x0000003c, "3C", "%2.X", +__LINE__, 0xfffffffe, "FFFFFFFE", "%.3X", +__LINE__, 0x0000152a, "152A", "%X", +__LINE__, 0xfffe876e, "FFFE876E", "%X", +__LINE__, -0x0003874, "-14452", "%-ld", +__LINE__, -0x004918a, "-299402", "%#.6d", +__LINE__, -0x000000c, "-12", "%-d", +__LINE__, 0xffffd812, "FFFFD812", "%+X", +__LINE__, -0x000000c, "-12", "%0d", +__LINE__, -0x0000229, "-553", "%0d", +__LINE__, 0x00002ab8, "2AB8", "%4.X", +__LINE__, 0x0000004b, "+75", "%+ld", +__LINE__, 0x001c3178, " 1847672", "% ld", +__LINE__, -0x0000006, "-6", "%.0ld", +__LINE__, 0x0003be65, "245349", "%ld", +__LINE__, -0x0000001, "-1", "%#1ld", +__LINE__, 0x0000007f, "+127", "%+ld", +__LINE__, 0x0000020e, "526 ", "%-5ld", +__LINE__, 0x00000002, "2", "%d", +__LINE__, 0x03bd0873, "0X3BD0873", "%#X", +__LINE__, 0x00093a52, "604754", "%-2d", +__LINE__, -0x00823fc, "-0533500", "%+.7ld", +__LINE__, 0x00000000, " ", "%4.X", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0xfff09ede, "fff09ede", "%-x", +__LINE__, 0x01e28c24, "31624228", "%ld", +__LINE__, 0x00001dcc, "1DCC", "%X", +__LINE__, -0x0f0ea0d, "-15788557", "%-00.ld", +__LINE__, 0xffff73a1, "FFFF73A1", "%X", +__LINE__, -0x0004040, "-16448", "%+#d", +__LINE__, 0x0073b158, "0x73b158", "%#7x", +__LINE__, 0xfffff8ff, "FFFFF8FF", "% 5X", +__LINE__, -0x0000004, "-4", "%0d", +__LINE__, 0xffff56a3, "ffff56a3", "%1.6x", +__LINE__, -0x0000041, "-65", "%0d", +__LINE__, 0x00000009, "+0000009", "%+2.7d", +__LINE__, 0xffffe13d, "0XFFFFE13D", "%+#2.X", +__LINE__, -0x00002ce, "-00718", "%.5ld", +__LINE__, 0xffc53e28, "ffc53e28", "%03.4x", +__LINE__, 0x00000005, "0X5", "%#X", +__LINE__, 0x00000004, "4", "%x", +__LINE__, 0xe21b35eb, "e21b35eb", "%-x", +__LINE__, -0x0000098, "-152", "%-ld", +__LINE__, 0xffffff81, "FFFFFF81", "%2X", +__LINE__, 0x00000003, "00003", "%.5ld", +__LINE__, 0xfffffffc, "fffffffc", "%+x", +__LINE__, 0x000491f5, "299509", "%1.ld", +__LINE__, 0xf06bfd7d, "F06BFD7D", "%X", +__LINE__, -0x0000006, "-6", "%0d", +__LINE__, -0x0a4af7d, "-10792829", "%-0d", +__LINE__, -0x11a74ef, "-18511087", "%ld", +__LINE__, 0x2dc95e17, "768171543", "%-1.d", +__LINE__, -0x0000001, "-1", "%#ld", +__LINE__, 0x00000033, "51", "%-#d", +__LINE__, 0x002d0219, "2949657", "%ld", +__LINE__, 0xfffffffd, "FFFFFFFD", "%2.4X", +__LINE__, 0x00000f20, "+3872", "%+ld", +__LINE__, -0x0000047, "-071", "%4.3ld", +__LINE__, 0x00000010, " 16", "%6d", +__LINE__, 0x00000000, "0", "%0d", +__LINE__, 0xffffff57, "FFFFFF57", "%X", +__LINE__, -0x0000700, "-1792", "%-#d", +__LINE__, -0x0000064, "-100", "%-ld", +__LINE__, 0xff26d49a, "FF26D49A", "%-0X", +__LINE__, -0x0000006, "-6", "%.1ld", +__LINE__, 0x1391edc5, "1391edc5", "%.1x", +__LINE__, 0x0000014a, "330", "%-#ld", +__LINE__, 0x07ecd1e1, "7ecd1e1", "%6x", +__LINE__, -0xa2b8898, "-170625176", "%3.d", +__LINE__, 0x00035287, "0x35287", "%#.0x", +__LINE__, 0x00000000, "00000", "%0.5X", +__LINE__, -0x0000153, "-339", "%d", +__LINE__, 0x0000ad6e, " 44398", "% 0.d", +__LINE__, 0x00000001, "1", "%-X", +__LINE__, -0x000000d, "-13 ", "%-6.2d", +__LINE__, -0x01bff8a, "-1834890", "%d", +__LINE__, 0x000a0fa8, "+659368", "%+ld", +__LINE__, 0xac044dc0, "ac044dc0", "%.0x", +__LINE__, 0x0003a729, "239401", "%ld", +__LINE__, -0x00004f0, "-1264", "%+ld", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0x00000012, "12", "% x", +__LINE__, 0xffff770b, "ffff770b", "%7.1x", +__LINE__, 0xd7458572, "d7458572", "%x", +__LINE__, 0x01f1b4f9, "1f1b4f9", "% 0x", +__LINE__, 0xfffb2198, "0XFFFB2198", "% #1.X", +__LINE__, 0x00ef6189, " 15688073", "% ld", +__LINE__, -0x3f0ae63, "-66104931", "% #d", +__LINE__, -0x0006075, "-24693", "%ld", +__LINE__, 0x000000a1, "161", "%d", +__LINE__, 0xfffffffc, "fffffffc", "%3.2x", +__LINE__, 0xff6b4125, "FF6B4125", "%+5.X", +__LINE__, 0x00000001, " 1", "%6.d", +__LINE__, -0x0000001, "-1", "%+0d", +__LINE__, -0x000096c, "-2412", "%0.4d", +__LINE__, 0x00039c6f, "236655", "%.0d", +__LINE__, 0x3625286c, "908404844", "%.1d", +__LINE__, 0xfffffffa, "fffffffa", "%x", +__LINE__, 0x00000000, "0", "%X", +__LINE__, 0x00c34353, "12796755", "%#.4d", +__LINE__, 0x000002df, "735", "%ld", +__LINE__, 0xffff38fa, "FFFF38FA", "%5.1X", +__LINE__, -0x000002a, "-42", "%0.d", +__LINE__, 0x0000077e, "1918", "%ld", +__LINE__, 0x000001f7, "503", "%ld", +__LINE__, 0x00000004, "4", "%ld", +__LINE__, 0x0021fb02, "2226946", "%d", +__LINE__, 0x007c858d, "8160653", "%-0d", +__LINE__, -0x0000109, "-265", "%.0d", +__LINE__, 0xfffffffa, "fffffffa", "% x", +__LINE__, 0x0097932d, "97932d", "%+x", +__LINE__, 0xfffbbd03, "fffbbd03", "%-.5x", +__LINE__, -0x0000005, "-5", "%0d", +__LINE__, 0x03ee3a95, "65944213", "%ld", +__LINE__, -0x0000002, " -00002", "%7.5d", +__LINE__, 0xea1a4e54, "EA1A4E54", "%X", +__LINE__, -0x000a9d6, "-43478", "%+d", +__LINE__, -0x0fd8d65, "-16616805", "%5ld", +__LINE__, 0x00000001, "1", "%-d", +__LINE__, 0x00000072, "72", "%2.X", +__LINE__, 0xffffff94, "FFFFFF94", "%X", +__LINE__, 0x00000d2a, "D2A", "%+X", +__LINE__, 0xffff614f, "ffff614f", "%x", +__LINE__, -0x0000018, "-24", "%ld", +__LINE__, 0x0000003b, "059", "%2.3d", +__LINE__, 0x0000001a, "1A", "%0X", +__LINE__, -0x0000109, "-265", "%02ld", +__LINE__, 0x00000f9d, "3997", "%#1d", +__LINE__, 0x0000001b, "1b", "%x", +__LINE__, 0xffffff07, "ffffff07", "%x", +__LINE__, 0xfff1a425, "0xfff1a425", "%#x", +__LINE__, 0x00000005, "5", "%-1d", +__LINE__, -0x53a6efd, "-87715581", "%ld", +__LINE__, 0x042f37db, "42F37DB", "%6.X", +__LINE__, 0x00053bd5, "+342997", "%+5ld", +__LINE__, 0xffffffff, "ffffffff", "% x", +__LINE__, 0xffffffef, "FFFFFFEF", "%6.X", +__LINE__, -0x10ec29a, "-17744538", "%+2.d", +__LINE__, 0x01dcc901, "1dcc901", "%x", +__LINE__, 0x0007dc68, "515176", "%-3.d", +__LINE__, -0x0000062, "-0098", "%#2.4d", +__LINE__, 0x00000000, " ", "%3.0X", +__LINE__, -0x00000de, "-222", "%ld", +__LINE__, 0x000c1fb8, "C1FB8", "%0X", +__LINE__, 0x0005bf58, "5BF58", "%X", +__LINE__, -0x000dd1b, "-56603", "%-03.1d", +__LINE__, 0x00000b14, "B14", "%+3.X", +__LINE__, 0x00000799, "799", "%-x", +__LINE__, 0xfffffffa, "fffffffa", "%x", +__LINE__, 0x00000003, "0x00003", "% #7.5x", +__LINE__, -0x002b9f1, "-178673", "%+d", +__LINE__, -0x001b817, "-112663", "%0d", +__LINE__, 0xf6f98533, "f6f98533", "%.1x", +__LINE__, 0x00338ffc, "3379196", "%d", +__LINE__, 0x0409e9b5, "0X409E9B5", "%#X", +__LINE__, 0x00b8e98e, " 12118414", "% 0d", +__LINE__, -0x002a8f6, "-174326", "%ld", +__LINE__, 0x13bb9722, "331061026", "%0d", +__LINE__, 0x00063c71, "63c71", "%x", +__LINE__, 0xfffffe37, "FFFFFE37", "%.1X", +__LINE__, 0xffff7b3e, "ffff7b3e", "%+.1x", +__LINE__, 0x005eeab1, "5eeab1", "%+x", +__LINE__, 0xffc69e99, "ffc69e99", "%x", +__LINE__, -0x000005c, " -92", "%5ld", +__LINE__, 0x07d8fa8a, "7d8fa8a", "%x", +__LINE__, 0x00030e0a, "200202", "%-4.1d", +__LINE__, 0x00001dc1, "1DC1", "%.0X", +__LINE__, 0x00000008, "8", "%0ld", +__LINE__, -0x01b5397, "-1790871", "%3.d", +__LINE__, 0x27fbb4b5, "27fbb4b5", "%x", +__LINE__, -0xe3fdcfc, "-239066364", "%4ld", +__LINE__, 0x0008bcb1, "8bcb1", "%0x", +__LINE__, 0xffff039e, "ffff039e", "%.6x", +__LINE__, 0x000d0bd4, "d0bd4", "%-x", +__LINE__, 0x00000000, "+0", "%+d", +__LINE__, -0x2a49ea4, "-44342948", "%1d", +__LINE__, -0x0000055, "-85", "%0d", +__LINE__, -0x0000a05, "-2565", "%3.3ld", +__LINE__, -0x000000b, "-11 ", "%-4d", +__LINE__, 0xfff30444, "FFF30444", "%7.X", +__LINE__, 0x0000003f, "63", "%-0d", +__LINE__, 0x00046779, "46779", "%X", +__LINE__, 0x000028d7, " 0X28D7", "%#7.X", +__LINE__, 0x00000019, " 19", "%5x", +__LINE__, 0x0032291d, "3287325", "%2.ld", +__LINE__, 0x00057afa, "57AFA", "%X", +__LINE__, 0xfffe8c64, "fffe8c64", "%3.4x", +__LINE__, -0x624110d6, "-1648431318", "%+6d", +__LINE__, 0x0000001a, " 26", "% 5.d", +__LINE__, 0xfffffffd, "FFFFFFFD", "%6.X", +__LINE__, 0x00199490, "1676432", "%-1d", +__LINE__, -0xfff8265, "-268403301", "%-0ld", +__LINE__, 0x0000000e, "e", "%-x", +__LINE__, 0x00c38aec, "c38aec", "%x", +__LINE__, -0x00658f4, "-415988", "%#ld", +__LINE__, 0x0066ac4e, "6728782", "%0d", +__LINE__, 0xc4a808d5, "c4a808d5", "%x", +__LINE__, 0x00000000, " 0", "%6.1x", +__LINE__, 0x00066d24, "66d24", "%x", +__LINE__, 0x00002117, "2117", "%X", +__LINE__, 0xfe06fdf4, "FE06FDF4", "%0X", +__LINE__, 0xfffffff9, "fffffff9", "%x", +__LINE__, 0x1c6bb795, "+476821397", "%+d", +__LINE__, 0xfffffba4, "FFFFFBA4", "%X", +__LINE__, 0xfffd7d44, "fffd7d44", "%0x", +__LINE__, 0x0019dd17, "1694999", "%d", +__LINE__, 0x6475851e, "0x6475851e", "% #7.x", +__LINE__, -0x00330d5, "-209109", "%0ld", +__LINE__, 0x009f53f7, "09F53F7", "%+6.7X", +__LINE__, -0x00172f9, " -94969", "%7.5ld", +__LINE__, 0xffffffdc, "FFFFFFDC", "%X", +__LINE__, -0x013bdec, "-1293804", "%+#2ld", +__LINE__, 0xfff845c0, "fff845c0", "%+7.x", +__LINE__, -0x0fbe712, "-16508690", "%.7d", +__LINE__, 0xffffe13f, "ffffe13f", "%x", +__LINE__, 0xbbc19951, "BBC19951", "%-4X", +__LINE__, -0x28d6d1b, "-42822939", "%#d", +__LINE__, -0x93cda6b, "-154983019", "%-d", +__LINE__, 0xffc93342, "FFC93342", "%7.X", +__LINE__, 0x072ac8b3, " 120244403", "% ld", +__LINE__, 0xfff8d17b, "FFF8D17B", "% X", +__LINE__, 0x00000da5, "DA5", "%0.X", +__LINE__, 0x055ad3ac, "0x55ad3ac", "%#1x", +__LINE__, 0x00000e5a, " 3674", "% .4ld", +__LINE__, 0xffffff79, "FFFFFF79", "%+X", +__LINE__, 0xffffe167, "ffffe167", "%+5x", +__LINE__, 0x0000fa50, "0064080", "%.7ld", +__LINE__, 0x00000001, "1", "%-d", +__LINE__, 0xfffffffe, "fffffffe", "%x", +__LINE__, 0x000009ac, " 2476", "% #2.ld", +__LINE__, 0x00000e78, "0003704", "%.7ld", +__LINE__, -0x000dfc3, "-57283", "%6.d", +__LINE__, 0x00000ee0, "EE0", "%0X", +__LINE__, -0x293703b3, "-691471283", "%ld", +__LINE__, 0x000073e8, " 73e8", "%6x", +__LINE__, 0xffffdffd, "ffffdffd", "%5.5x", +__LINE__, 0x00000004, "4", "%+00.x", +__LINE__, 0x00000008, "0X8", "%#X", +__LINE__, 0x0003044c, "3044c", "%0x", +__LINE__, 0xffc2095e, "FFC2095E", "%0X", +__LINE__, 0x00000aac, "0002732", "%-.7ld", +__LINE__, 0xffffff79, "FFFFFF79", "%+1.X", +__LINE__, 0x53a0f94a, " 1403058506", "% 2.4ld", +__LINE__, 0x000e928d, "e928d", "%x", +__LINE__, 0x0024127a, "2364026", "%5.d", +__LINE__, 0x000f7c1c, " 1014812", "% 2.d", +__LINE__, -0x000003d, "-61 ", "%-#4ld", +__LINE__, -0x0000122, "-290", "%+ld", +__LINE__, 0x00000006, "+6", "%+0d", +__LINE__, 0x00000129, " 000129", "%7.6X", +__LINE__, 0x15d873e5, " 366506981", "% 5.7d", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0x038d6110, "+59597072", "%+d", +__LINE__, 0x0f46ccc3, "256298179", "%-1.4d", +__LINE__, 0xfe434d21, "fe434d21", "%x", +__LINE__, -0x179797d7, "-395810775", "%d", +__LINE__, 0xe35807bf, "e35807bf", "%x", +__LINE__, 0x00000003, " +3", "%+7d", +__LINE__, 0x017e699e, "25061790", "%#ld", +__LINE__, -0x0000029, "-41", "%d", +__LINE__, 0xffffff11, "ffffff11", "%1.x", +__LINE__, -0x0001bf6, "-7158", "%+0ld", +__LINE__, 0xffffff4b, "FFFFFF4B", "%4X", +__LINE__, -0x0000040, "-64", "%ld", +__LINE__, 0x000034d6, "+13526", "%+ld", +__LINE__, 0xffffffa7, "ffffffa7", "%x", +__LINE__, 0xfffffe8e, "fffffe8e", "%+.3x", +__LINE__, 0x00000000, "0", "%0.1d", +__LINE__, -0x007cdf1, "-511473", "%ld", +__LINE__, 0xfffffeef, "FFFFFEEF", "%-X", +__LINE__, 0x00002d91, "2d91", "%x", +__LINE__, -0x000025b, "-603", "%#ld", +__LINE__, -0x000001b, "-27", "%-ld", +__LINE__, 0x042b6752, "42B6752", "%+X", +__LINE__, -0x75afb0a6, "-1974448294", "% ld", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x00000542, " 1346", "%6d", +__LINE__, -0x0000010, "-16", "%+0d", +__LINE__, 0xfffed8f7, "FFFED8F7", "%5.X", +__LINE__, 0x0541852e, "541852e", "% 2.x", +__LINE__, 0xff22aec3, "ff22aec3", "% .1x", +__LINE__, 0x5e34b745, "1580513093", "%ld", +__LINE__, 0xfffffff3, "fffffff3", "%x", +__LINE__, 0x0eda7b86, "+249199494", "%+.3d", +__LINE__, 0xffffe40f, "ffffe40f", "%+x", +__LINE__, -0x0003484, "-13444", "%-1.5ld", +__LINE__, 0x0000334b, " 13131", "%6.ld", +__LINE__, -0x0000149, "-329", "%ld", +__LINE__, 0x00000001, " 001", "% 5.3x", +__LINE__, 0xffeaa035, "ffeaa035", "%+3.5x", +__LINE__, 0x00211dff, "2170367", "%ld", +__LINE__, 0x007e91f4, "7e91f4", "%x", +__LINE__, 0xfffffffc, "0xfffffffc", "%+#5x", +__LINE__, 0xfffffffc, "FFFFFFFC", "%6.X", +__LINE__, 0x0156a9b5, "156a9b5", "%x", +__LINE__, 0xfffffe58, "fffffe58", "%+x", +__LINE__, 0xffff8c66, "FFFF8C66", "%.0X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x00000005, " 5", "%7.d", +__LINE__, -0x0000002, "-2", "%ld", +__LINE__, 0x000076b9, " 30393", "% ld", +__LINE__, 0x00003824, "3824", "%4X", +__LINE__, 0x00000cdf, " CDF", "% 7X", +__LINE__, 0x017c9e8f, "17C9E8F", "%-X", +__LINE__, -0x20f582d, "-34560045", "%-.5d", +__LINE__, 0x0000732e, " 29486", "% 7.ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%+0X", +__LINE__, 0xf379a4a2, "F379A4A2", "% .7X", +__LINE__, -0x0000028, "-40", "%-d", +__LINE__, 0xe73cf79e, "e73cf79e", "%x", +__LINE__, 0x00000002, " 2", "%7ld", +__LINE__, -0x00029b1, "-10673", "%-#1.ld", +__LINE__, -0x0002a58, "-10840", "%3.d", +__LINE__, 0x00000002, "2", "%-X", +__LINE__, 0xfffffffc, "FFFFFFFC", "%X", +__LINE__, -0x000003a, " -58", "%5ld", +__LINE__, 0x0245ef3b, "245ef3b", "%.3x", +__LINE__, 0x00026cca, "158922", "%-06.3ld", +__LINE__, 0x01016fd3, "16871379", "%-d", +__LINE__, 0x000016fc, "5884", "%0ld", +__LINE__, -0x00007fb, " -2043", "%7.3d", +__LINE__, 0xfff73d3c, "fff73d3c", "%0x", +__LINE__, -0x0000110, "-272", "% 04.3d", +__LINE__, 0x0000000e, " 014", "% 04ld", +__LINE__, -0x0000039, "-57", "%.0ld", +__LINE__, 0x00000c95, "c95", "%0x", +__LINE__, 0xffff3b2e, "ffff3b2e", "%x", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, 0x00000015, "21", "%.1d", +__LINE__, 0x0000000c, "+12", "%+ld", +__LINE__, 0x00000000, "0", "%+X", +__LINE__, 0xfffc9a14, "fffc9a14", "%-.5x", +__LINE__, 0x0000003c, "60", "%.2ld", +__LINE__, -0x0000023, " -35", "%6.d", +__LINE__, 0x00000740, "1856", "%ld", +__LINE__, 0x00000160, "160", "% 3.X", +__LINE__, 0x00000006, " 6", "%5.X", +__LINE__, -0x0000677, "-1655", "%.3ld", +__LINE__, 0x12709c7e, "12709C7E", "%.7X", +__LINE__, 0x0000090f, "+2319", "%+#d", +__LINE__, 0xffffffe0, "0xffffffe0", "%#4.1x", +__LINE__, 0x00132ce0, "1256672", "%ld", +__LINE__, 0x00000059, "59", "%+X", +__LINE__, -0x0000017, "-23", "%0d", +__LINE__, -0x01fade6, "-2076134", "%-4.3ld", +__LINE__, 0x000df3fa, "914426", "%.5ld", +__LINE__, 0xfffffd0f, "fffffd0f", "%7x", +__LINE__, -0x000c212, "-49682", "%0.1ld", +__LINE__, 0xffff8bcb, "FFFF8BCB", "%.3X", +__LINE__, 0x0000000a, "a", "% x", +__LINE__, 0x00000021, "21", "%x", +__LINE__, -0x0000040, "-64", "% 1ld", +__LINE__, 0x00000009, " 9", "%6.ld", +__LINE__, -0x0000d67, "-3431", "% 5.3d", +__LINE__, 0x03a85f1b, "61366043", "%ld", +__LINE__, 0x00000035, "000053", "%0.6d", +__LINE__, 0xfffda5cb, "fffda5cb", "%+x", +__LINE__, 0xffffff78, "FFFFFF78", "%-7.0X", +__LINE__, 0xfffffd6d, "fffffd6d", "%7.x", +__LINE__, 0xfffffc08, "fffffc08", "%7.3x", +__LINE__, 0x00003335, " 13109", "% #d", +__LINE__, -0x0000002, " -2", "%5.d", +__LINE__, -0x13767a48, "-326531656", "%+ld", +__LINE__, 0x00000be5, "3045", "%4.0ld", +__LINE__, 0xfffdb28c, "FFFDB28C", "%X", +__LINE__, 0x00127118, "1208600", "%ld", +__LINE__, 0x00000086, " 134", "% ld", +__LINE__, 0x0002214c, "2214c", "%+x", +__LINE__, 0x0000a0c2, " a0c2", "%5.0x", +__LINE__, -0x000007c, "-124", "%ld", +__LINE__, 0x0000012a, "00298", "%3.5d", +__LINE__, 0xfd4f1257, "FD4F1257", "%+2.X", +__LINE__, 0xffffd8aa, "ffffd8aa", "%5x", +__LINE__, -0x00000a7, "-167", "%+ld", +__LINE__, -0x0009c69, "-40041", "%0.0ld", +__LINE__, 0x02230418, "35849240", "%-0.6ld", +__LINE__, 0x00000000, " 0", "%6x", +__LINE__, 0xfffff184, "fffff184", "%02.5x", +__LINE__, -0x0ae967b, "-11441787", "%d", +__LINE__, 0x0015de3a, "1433146", "%-5.3d", +__LINE__, -0x0071e93, "-466579", "%1.ld", +__LINE__, 0xfffff8bd, "fffff8bd", "%+x", +__LINE__, -0x00000e4, "-228", "%+ld", +__LINE__, 0x000001d8, " 472", "% .3ld", +__LINE__, 0x00315faa, "315faa", "%-0x", +__LINE__, 0x00000e59, "e59", "%0x", +__LINE__, -0x0000005, "-5", "%ld", +__LINE__, 0x000018ec, "6380", "%ld", +__LINE__, 0xfffffff9, "fffffff9", "%5.2x", +__LINE__, -0xe7cfd39, "-243072313", "%-d", +__LINE__, 0x0002c30b, "2C30B", "%1.2X", +__LINE__, 0x0000007a, "7A", "%X", +__LINE__, 0xf604ecb2, "F604ECB2", "%2X", +__LINE__, -0x05f602c, "-6250540", "%d", +__LINE__, 0xffff9c86, "ffff9c86", "%2.x", +__LINE__, -0x00d7f55, "-884565", "%#d", +__LINE__, 0xd2a37824, "D2A37824", "%4X", +__LINE__, 0x00000000, "", "%-.0x", +__LINE__, 0x000d4b51, "0d4b51", "%3.6x", +__LINE__, 0x000ecd97, "ecd97", "% x", +__LINE__, -0x0000018, "-024", "%+04ld", +__LINE__, -0x009f292, "-651922", "%ld", +__LINE__, -0x0002da9, "-11689", "%-0ld", +__LINE__, -0x000a218, "-41496", "%4.5d", +__LINE__, 0xffff85ac, "FFFF85AC", "% 04.X", +__LINE__, -0x0d9ffbe, "-14286782", "%0d", +__LINE__, 0xfb18cc8e, "fb18cc8e", "%x", +__LINE__, 0xffffe5d3, "FFFFE5D3", "%-X", +__LINE__, 0x00000000, "0", "%x", +__LINE__, -0x0000006, "-6", "% d", +__LINE__, 0x0002fc62, "2fc62", "% 03.x", +__LINE__, 0x00000000, "00", "%.2d", +__LINE__, -0x00000fd, " -253", "%6ld", +__LINE__, -0x000000b, "-11", "%d", +__LINE__, -0x00042a3, "-17059", "% 6d", +__LINE__, 0x00000002, "2", "% X", +__LINE__, -0x61ead93e, "-1642780990", "%-0d", +__LINE__, 0xf2e61f6d, "f2e61f6d", "%-.4x", +__LINE__, 0xffd31b93, "ffd31b93", "%x", +__LINE__, -0x0000008, "-8", "%ld", +__LINE__, 0xffffffff, "ffffffff", "%00x", +__LINE__, 0x000000fb, "+000251", "%+2.6d", +__LINE__, 0x00000015, " 15", "%4.X", +__LINE__, 0x06ec6d96, "6EC6D96", "%+2.X", +__LINE__, 0xffff1df7, "0xffff1df7", "% #1x", +__LINE__, -0x000004b, "-75", "%-ld", +__LINE__, 0x00000008, "8", "%#.0d", +__LINE__, 0x00001355, "4949", "%3.4ld", +__LINE__, -0x00000f7, "-247", "%d", +__LINE__, 0x0000001f, "31", "%.2ld", +__LINE__, 0x0000d556, "D556", "%-X", +__LINE__, 0xffffd5a5, "ffffd5a5", "% x", +__LINE__, -0x0000e34, "-3636", "%#d", +__LINE__, -0x0000007, "-7", "%d", +__LINE__, 0x01ba10a4, "1ba10a4", "%x", +__LINE__, 0xfffff759, "FFFFF759", "% X", +__LINE__, -0x80d0adb, "-135072475", "%d", +__LINE__, 0x0002bf61, "2bf61", "%x", +__LINE__, 0xffff008b, "FFFF008B", "%-7X", +__LINE__, 0x00000e72, "E72", "%X", +__LINE__, -0x00000ea, "-234", "%0ld", +__LINE__, -0x0007b9d, "-0031645", "%0.7ld", +__LINE__, 0x0001baaa, "0X1BAAA", "%#4X", +__LINE__, 0x0000a57f, " a57f", "%6.x", +__LINE__, -0x21a73726, "-564606758", "%ld", +__LINE__, 0x06f45c9f, "0x6f45c9f", "%#.3x", +__LINE__, 0x00018e5d, "101981", "%-d", +__LINE__, 0x0001e69a, "124570", "%-d", +__LINE__, -0x0000d26, " -3366", "% 07.d", +__LINE__, 0x00000000, "+", "%+0.ld", +__LINE__, 0x00003916, "14614", "%ld", +__LINE__, 0xfffffd8f, "fffffd8f", "%-3.x", +__LINE__, 0x00000011, "11", "%x", +__LINE__, 0x000000e7, "E7", "%X", +__LINE__, 0xfdf9d89b, "FDF9D89B", "%X", +__LINE__, 0x00000a7c, "a7c", "%x", +__LINE__, 0x0000003f, "00003F", "%.6X", +__LINE__, 0xffffe729, "FFFFE729", "%X", +__LINE__, 0xfffffffe, "fffffffe", "% .6x", +__LINE__, -0x0000a4b, "-2635", "%+d", +__LINE__, 0xffffff50, "ffffff50", "%0.7x", +__LINE__, 0xfaf57e8b, "faf57e8b", "% 4.x", +__LINE__, -0x0000056, "-86", "%ld", +__LINE__, 0x08ed2a4d, "8ed2a4d", "%4x", +__LINE__, 0xff8d9081, "FF8D9081", "%+0.X", +__LINE__, 0x002730a1, "2568353", "%4d", +__LINE__, 0xffff9564, "ffff9564", "%x", +__LINE__, -0x0000006, " -6", "%4ld", +__LINE__, -0x19890310, "-428409616", "%0ld", +__LINE__, 0xd2ce636c, "d2ce636c", "%+x", +__LINE__, -0x00001fe, "-510", "%d", +__LINE__, 0x00000006, "0000006", "%+0.7x", +__LINE__, 0xffffffc2, "0XFFFFFFC2", "%-#.5X", +__LINE__, -0x00000fd, "-253", "%+d", +__LINE__, 0x000216aa, "0x216aa", "%#x", +__LINE__, 0xffe36c66, "ffe36c66", "%x", +__LINE__, 0x00000002, "2", "%x", +__LINE__, -0x0000025, "-37", "% d", +__LINE__, 0x0000007e, "126", "%d", +__LINE__, 0x0003c1f9, "+246265", "%+ld", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, -0x00539e7, "-342503", "%06.ld", +__LINE__, 0x00000d42, " 3394", "%#6.ld", +__LINE__, 0xf73b7c4e, "F73B7C4E", "%X", +__LINE__, 0x00000022, "22", "%.1x", +__LINE__, 0xffffa883, "FFFFA883", "%X", +__LINE__, 0x016ec247, "16ec247", "%x", +__LINE__, 0x00000019, "19", "%+X", +__LINE__, 0x0000665a, "665A", "% 2.X", +__LINE__, 0xfffffffc, "FFFFFFFC", "%-5.X", +__LINE__, 0x008e3fbc, "8E3FBC", "%X", +__LINE__, 0xfffffffa, "FFFFFFFA", "%X", +__LINE__, 0x1b806597, "461399447", "%.2d", +__LINE__, 0x00000366, "0000870", "%#1.7ld", +__LINE__, 0x0001d92e, "1d92e", "%x", +__LINE__, 0x000104ce, "104CE", "%-X", +__LINE__, 0xfffffe4c, "fffffe4c", "%x", +__LINE__, 0x000000e9, "E9", "%X", +__LINE__, 0x000a855c, " 689500", "% d", +__LINE__, 0x00000075, "75", "% X", +__LINE__, -0x0000026, "-38", "%ld", +__LINE__, 0xfffff169, "fffff169", "%-04.2x", +__LINE__, 0xffffff6f, "ffffff6f", "%x", +__LINE__, 0x00000003, "0x3", "%#x", +__LINE__, 0x00623bab, "6437803", "%.0d", +__LINE__, -0x2260224c, "-576725580", "%ld", +__LINE__, 0xe7e7a998, "E7E7A998", "%.1X", +__LINE__, 0x00000005, "5", "%X", +__LINE__, 0x0000b560, "0xb560", "%#x", +__LINE__, 0xfe11854d, "fe11854d", "%-.5x", +__LINE__, 0x00190014, "1638420", "%ld", +__LINE__, 0x0001d22a, "0X1D22A", "%-#X", +__LINE__, 0x00000c16, "c16", "%2x", +__LINE__, 0x00000d1a, "3354", "%#d", +__LINE__, 0x000165f6, "91638", "%d", +__LINE__, 0xfffff557, "0XFFFFF557", "%#X", +__LINE__, 0x00000588, " 588", "%07.X", +__LINE__, 0xf4a72708, "f4a72708", "%x", +__LINE__, 0xfff1cba9, "0xfff1cba9", "% #2.5x", +__LINE__, 0x000333a4, "209828", "%d", +__LINE__, 0x0000179b, "179B", "% 2.X", +__LINE__, 0x00000460, "1120", "%0ld", +__LINE__, 0xffffff89, "FFFFFF89", "%X", +__LINE__, -0x0000012, "-18", "%ld", +__LINE__, 0x00004fe0, "20448", "%0.d", +__LINE__, 0x00532e77, "532e77", "%00.x", +__LINE__, 0xf7b92efe, "f7b92efe", "%0x", +__LINE__, -0x0000243, "-579", "%+1.d", +__LINE__, 0x34894bb7, "+881413047", "%+d", +__LINE__, 0xfffaa189, "FFFAA189", "% 6X", +__LINE__, -0x0000579, "-1401", "%+ld", +__LINE__, 0x005acb12, "5acb12", "%5.0x", +__LINE__, 0xffff890a, "FFFF890A", "%X", +__LINE__, 0x010dff2f, "10DFF2F", "%.7X", +__LINE__, 0x00005a7f, "23167", "%#ld", +__LINE__, 0x000005e3, "1507", "%#3d", +__LINE__, -0xa815bcb, "-176249803", "%d", +__LINE__, 0xffffffff, "ffffffff", "%+x", +__LINE__, 0xfffe0ff7, "fffe0ff7", "%3x", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#2.1X", +__LINE__, -0x1cc5ea52, "-482732626", "%6.d", +__LINE__, 0x000425ed, "+0271853", "%+.7d", +__LINE__, 0x00000001, "1", "%+x", +__LINE__, -0x48f2a72, "-76491378", "%7.0d", +__LINE__, 0xfffffff7, "FFFFFFF7", "% 0X", +__LINE__, 0xfd8ffc0a, "fd8ffc0a", "%.1x", +__LINE__, 0x0001f56d, " 1F56D", "%+7.2X", +__LINE__, 0x000000db, " DB", "%6.X", +__LINE__, 0xffffffc2, "ffffffc2", "%x", +__LINE__, 0x00000001, "001", "%03ld", +__LINE__, 0xffd89f58, "ffd89f58", "% 0.x", +__LINE__, 0xfe1a72fc, "fe1a72fc", "%x", +__LINE__, 0xfffff9b6, "FFFFF9B6", "%X", +__LINE__, 0x00243633, "243633", "%X", +__LINE__, 0x00821bc7, "+8526791", "%+#0ld", +__LINE__, 0xfe63f348, "0XFE63F348", "%#3X", +__LINE__, 0xff729f19, "ff729f19", "%4x", +__LINE__, 0xffff570f, "FFFF570F", "%+X", +__LINE__, 0x00a57a42, "10844738", "%6.3d", +__LINE__, 0xfe4a3ed0, "FE4A3ED0", "%6.X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x000001bb, "01bb", "% .4x", +__LINE__, 0x02b4a1e9, "2b4a1e9", "%-7.x", +__LINE__, 0x31750683, "31750683", "%x", +__LINE__, 0x00001cd7, "7383", "%#ld", +__LINE__, 0x0000079d, "1949", "%d", +__LINE__, 0xffb8ff3b, "FFB8FF3B", "%X", +__LINE__, 0x00a768b6, "0A768B6", "%-6.7X", +__LINE__, 0x1c665b48, "0X1C665B48", "% #X", +__LINE__, -0x000037d, "-000893", "%3.6d", +__LINE__, 0x29890443, "29890443", "%+0x", +__LINE__, 0x000000e5, "e5 ", "%-4x", +__LINE__, 0xfff2b5fa, "FFF2B5FA", "%X", +__LINE__, -0x5d32c2b, "-97725483", "%05ld", +__LINE__, -0x00016c5, " -05829", "%+#7.5ld", +__LINE__, 0x00000644, "644", "%X", +__LINE__, -0x018c027, "-1622055", "%+.1d", +__LINE__, 0x0000013c, "0x13c", "%#x", +__LINE__, 0x00000009, "+9", "%+#ld", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, -0x018eb19, "-1633049", "%4.3ld", +__LINE__, 0xfffff429, "FFFFF429", "% X", +__LINE__, 0x0032de67, "32DE67", "%X", +__LINE__, 0x0016bdfa, " 1490426", "% .2ld", +__LINE__, 0x00000065, "65", "%+.0X", +__LINE__, 0x00000072, " 72", "%+4.2X", +__LINE__, 0x00075119, "75119", "%2x", +__LINE__, 0x000000b8, "b8", "%x", +__LINE__, 0x000000d0, "d0", "%x", +__LINE__, 0x000000b9, "b9", "%x", +__LINE__, 0x003fda9d, " 4184733", "% #3.d", +__LINE__, 0x00029a24, "170532", "%4.d", +__LINE__, -0x132a337d, "-321532797", "% ld", +__LINE__, 0x0000047a, "0X47A", "%-#X", +__LINE__, 0x00000000, "0", "%-ld", +__LINE__, -0x0d9750b, "-14251275", "% ld", +__LINE__, 0x00029d6c, "29d6c", "%x", +__LINE__, 0xfb060cc0, "fb060cc0", "%x", +__LINE__, 0xffffd524, "0XFFFFD524", "%#X", +__LINE__, 0xffffff30, "ffffff30", "%-5x", +__LINE__, 0x00001650, "0005712", "%#0.7d", +__LINE__, 0x0000b702, "0B702", "%03.5X", +__LINE__, 0x000003c1, "3c1", "% .1x", +__LINE__, -0x0290412, "-2688018", "%d", +__LINE__, -0x00008bf, "-2239", "%#d", +__LINE__, -0x0000001, "-1", "%d", +__LINE__, 0x0001d750, "1D750", "%-X", +__LINE__, 0x006eee92, "6EEE92", "%-X", +__LINE__, 0xff812b02, "ff812b02", "%0x", +__LINE__, 0xfffffeac, "FFFFFEAC", "%+0X", +__LINE__, 0x000003a5, "3a5", "%x", +__LINE__, -0x15270cee, "-354880750", "%2.ld", +__LINE__, 0x06b686d2, "6b686d2", "%0x", +__LINE__, 0xffe9cdcc, "ffe9cdcc", "%x", +__LINE__, 0x0ecb168e, "ecb168e", "%x", +__LINE__, 0x00000051, "51", "%-X", +__LINE__, -0x0018860, "-100448", "%-0d", +__LINE__, 0x8f08b82b, "0x8f08b82b", "%-#.5x", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, 0x0000000e, "e", "%+01x", +__LINE__, 0x04cf15bc, " 80680380", "% #ld", +__LINE__, 0x50006e8a, "50006e8a", "%x", +__LINE__, 0x0002f669, "194153", "%0d", +__LINE__, 0x000000a6, " 166", "% 5.ld", +__LINE__, -0x04036bb, "-4208315", "%7.5d", +__LINE__, 0x00070dea, "70DEA", "%+X", +__LINE__, 0x00000964, "0x964", "%#x", +__LINE__, 0x0000004d, "0x4d", "% #3.x", +__LINE__, -0x0000001, "-1", "%-0d", +__LINE__, 0x0000043e, "1086", "%ld", +__LINE__, -0x0000001, "-1", "%-d", +__LINE__, 0x00000000, "+0", "%+d", +__LINE__, 0xfffe68d9, "FFFE68D9", "%7.X", +__LINE__, -0x0169199, "-1479065", "%#.5ld", +__LINE__, -0x000003d, "-61", "%ld", +__LINE__, 0x00000001, "+1", "%+.1d", +__LINE__, 0x0001a65d, "1a65d", "%.5x", +__LINE__, 0x00000141, "+000321", "%+#5.6ld", +__LINE__, 0x00000000, " 0", "%4x", +__LINE__, 0x00000408, "1032", "%-2.3ld", +__LINE__, 0xffffffed, "FFFFFFED", "%-X", +__LINE__, 0xfe832351, "FE832351", "% .4X", +__LINE__, 0x003a421b, "3A421B", "%-X", +__LINE__, -0x53ed7f25, "-1408073509", "%ld", +__LINE__, -0x0000003, "-0003", "%-5.4ld", +__LINE__, 0x00000ad0, " 2768", "%7d", +__LINE__, 0xfffaf30b, "FFFAF30B", "%X", +__LINE__, 0x006349d3, " 6506963", "% 6.2ld", +__LINE__, 0x07f0146a, "7f0146a", "%+3.4x", +__LINE__, -0x0000002, " -2", "% 3.ld", +__LINE__, -0x26e94f3, "-40801523", "%-#ld", +__LINE__, -0x0000004, " -004", "%7.3d", +__LINE__, 0xfffe8cc9, "FFFE8CC9", "%0X", +__LINE__, 0x00000018, " 18", "%5.x", +__LINE__, -0x4941de83, "-1229053571", "% 0.5ld", +__LINE__, 0x00000000, " 0", "%6ld", +__LINE__, 0xfffffffe, "0XFFFFFFFE", "%-#X", +__LINE__, -0x0142ae1, "-1321697", "%4.ld", +__LINE__, -0x0319e7f, "-3251839", "%0ld", +__LINE__, 0x000004ff, " 4FF", "%7.2X", +__LINE__, -0x0001c3e, "-7230", "%#.2ld", +__LINE__, 0xffffe522, "ffffe522", "%x", +__LINE__, 0x0001d1cb, "+119243", "%+.3ld", +__LINE__, 0xfad19d52, "FAD19D52", "%+X", +__LINE__, 0x00002a7c, " 10876", "% 0.ld", +__LINE__, 0x00001449, "1449", "%X", +__LINE__, 0x000732b8, "471736", "%d", +__LINE__, -0x211a496e, "-555370862", "%ld", +__LINE__, -0x0000004, "-4", "%1.d", +__LINE__, 0x0295c03d, "43368509", "%5.ld", +__LINE__, 0x01fa5722, "33183522", "%0ld", +__LINE__, 0xfffbff62, "0xfffbff62", "%#x", +__LINE__, 0x000000f5, " 245", "% 2.d", +__LINE__, 0x000000a0, "160", "%-d", +__LINE__, 0x0000000f, "15", "%.2ld", +__LINE__, 0x0bf5f077, "+200667255", "%+ld", +__LINE__, -0x14d3e5a, "-21839450", "%#2.3d", +__LINE__, -0x21cbe656, "-567010902", "%ld", +__LINE__, 0x000002b9, "697", "%ld", +__LINE__, 0xfffff9b0, "FFFFF9B0", "%X", +__LINE__, 0x007fd9c7, "8378823", "%3.4d", +__LINE__, 0x00036d06, "36d06", "%x", +__LINE__, 0xffde8052, "FFDE8052", "%4.6X", +__LINE__, 0x0000000d, "13", "%#d", +__LINE__, 0x68157d93, "68157d93", "%x", +__LINE__, 0x00000005, "5", "%1x", +__LINE__, 0xfffffff4, "FFFFFFF4", "%X", +__LINE__, 0xf5bbf7e9, "f5bbf7e9", "%+.1x", +__LINE__, 0x0be98f98, "BE98F98", "%X", +__LINE__, 0x00000122, "00122", "%.5X", +__LINE__, -0x0000936, "-2358", "%+#3.0ld", +__LINE__, 0xfd230f09, "FD230F09", "%-7X", +__LINE__, 0x00000089, "137", "%ld", +__LINE__, 0x00000078, " 120", "%7d", +__LINE__, -0x68ef2b6b, "-1760504683", "%-ld", +__LINE__, 0xc24480bb, "C24480BB", "%+4X", +__LINE__, 0xfefe36a2, "FEFE36A2", "%0X", +__LINE__, -0x35344ba, "-55788730", "%7.d", +__LINE__, 0xffffffff, "FFFFFFFF", "%+.6X", +__LINE__, -0x0000f40, "-3904", "% ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "%X", +__LINE__, 0x58b37c4b, "58b37c4b", "%2.2x", +__LINE__, 0x000000e2, "226", "%#ld", +__LINE__, 0xfff5ebde, "fff5ebde", "%-7.1x", +__LINE__, 0x0c6ea9be, "208579006", "%-ld", +__LINE__, 0xff708c74, "FF708C74", "% 4.X", +__LINE__, 0x00000000, " 0", "% 3X", +__LINE__, 0x00000004, " 4", "%03.d", +__LINE__, 0x0919be7c, "+152682108", "%+6.d", +__LINE__, 0x00d4fd1e, "13958430", "%0d", +__LINE__, 0xfe77a69e, "fe77a69e", "%-7.x", +__LINE__, 0x284ded44, "676195652", "%-#2ld", +__LINE__, -0x00006e6, "-1766", "% ld", +__LINE__, -0x7dac7ea, "-131778538", "%.0ld", +__LINE__, 0x0003c50f, "247055", "%#d", +__LINE__, 0xfffffffc, "fffffffc", "%-x", +__LINE__, 0xfe0f0d1f, "fe0f0d1f", "% 5.1x", +__LINE__, 0x00000009, "9", "%0ld", +__LINE__, -0x0175cc1, "-1531073", "%-04.d", +__LINE__, 0x000e4da2, " 937378", "% 4.ld", +__LINE__, 0x00000762, "762", "%-0.X", +__LINE__, 0x005211bf, "5211bf", "%-x", +__LINE__, 0xfffffffb, "fffffffb", "%+2.6x", +__LINE__, 0x00008862, "34914", "%ld", +__LINE__, 0xfffc9754, "fffc9754", "%+x", +__LINE__, 0x0000716e, "716E", "%X", +__LINE__, 0x000000a8, "a8", "%x", +__LINE__, 0xffff84f5, "ffff84f5", "%0x", +__LINE__, 0x00005032, "5032", "%x", +__LINE__, 0xffe242b4, "ffe242b4", "%6x", +__LINE__, 0x002df9bd, "3013053", "%ld", +__LINE__, 0xffffe267, "FFFFE267", "%.5X", +__LINE__, 0xffffffc7, "0xffffffc7", "%#x", +__LINE__, -0x1727c38, "-24280120", "%d", +__LINE__, 0x01308072, "1308072", "%x", +__LINE__, -0x5883c7c, "-92814460", "%+ld", +__LINE__, 0x000030ad, "30ad", "%x", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, -0x2090a708, "-546350856", "% d", +__LINE__, 0x0024e6b4, "2418356", "%#ld", +__LINE__, 0x02db71ac, "2DB71AC", "% 6.3X", +__LINE__, 0xfffffffc, "FFFFFFFC", "%2.7X", +__LINE__, -0x000074e, " -1870", "%7.ld", +__LINE__, -0x0011d84, "-73092", "%d", +__LINE__, 0x00160723, "160723", "%1.3x", +__LINE__, 0x00412929, "4270377", "%-d", +__LINE__, -0x0008fc6, "-36806", "% d", +__LINE__, 0x00000002, "2", "%d", +__LINE__, 0x0eb67ffa, "eb67ffa", "%.4x", +__LINE__, 0x05b86c3c, "95972412", "%4.4d", +__LINE__, 0xffffca9c, "FFFFCA9C", "% 4.X", +__LINE__, 0x0007d571, "7d571", "%-0x", +__LINE__, -0x000239b, "-09115", "%5.5d", +__LINE__, -0x0000155, " -341", "%5.3ld", +__LINE__, 0x00000034, "34", "%x", +__LINE__, -0x0000051, "-81", "%.1ld", +__LINE__, 0x309bbbe0, "309bbbe0", "%x", +__LINE__, 0x0075be1e, " 7716382", "% #ld", +__LINE__, 0x000002d5, "2d5", "%x", +__LINE__, 0x006b466d, "6B466D", "%-0X", +__LINE__, 0x01d6c30f, "1D6C30F", "%4.X", +__LINE__, 0x00000003, " 3", "%07.x", +__LINE__, 0xfffcc102, "FFFCC102", "%6.X", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#X", +__LINE__, 0xfffffffe, "fffffffe", "%+x", +__LINE__, 0x00000005, "5", "%ld", +__LINE__, 0xff060284, "ff060284", "%x", +__LINE__, 0x007a3325, "7A3325", "%-X", +__LINE__, 0xf5f595bd, "F5F595BD", "%0X", +__LINE__, 0xfffa3a10, "FFFA3A10", "%0X", +__LINE__, 0x00000000, "0", "%x", +__LINE__, -0x15078f9, "-22051065", "%7d", +__LINE__, -0x0000002, "-000002", "%.6d", +__LINE__, 0x00000036, "54", "%1.1ld", +__LINE__, -0xbbecf6a, "-197054314", "%ld", +__LINE__, 0x0000043d, "43D", "%X", +__LINE__, 0xfffffffa, "0xfffffffa", "% #6.x", +__LINE__, 0x016759f8, "23550456", "%0.ld", +__LINE__, 0x000052d2, "+21202", "%+6.2d", +__LINE__, -0x007d232, "-512562", "%ld", +__LINE__, 0x00240be0, "2362336", "%.1d", +__LINE__, -0x0000001, "-1", "%0d", +__LINE__, 0xfffffffa, "FFFFFFFA", "%X", +__LINE__, -0x0000e88, "-3720", "%ld", +__LINE__, 0xfffffa9b, "FFFFFA9B", "%.5X", +__LINE__, 0x09296eeb, "153710315", "%-1.0d", +__LINE__, 0x001f46fc, "0X1F46FC", "%#X", +__LINE__, 0x00000006, "6", "%X", +__LINE__, 0xffffff87, "0XFFFFFF87", "%+#X", +__LINE__, 0x00000469, "0469", "%04X", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x00000000, "", "%.0ld", +__LINE__, -0x52bc137, "-86753591", "%-#3ld", +__LINE__, -0x2bddb08, "-45996808", "%-3.d", +__LINE__, 0x041367f7, "41367F7", "%+X", +__LINE__, -0x0018eb5, "-102069", "%+ld", +__LINE__, -0x0000537, "-1335", "%#ld", +__LINE__, -0x6f159ff4, "-1863688180", "%+1.d", +__LINE__, 0x00112ac8, "0X112AC8", "%#6.3X", +__LINE__, 0x00000000, " ", "%3.d", +__LINE__, 0x0008afe8, "08afe8", "%+3.6x", +__LINE__, 0x00000015, "21", "%ld", +__LINE__, -0x02b7130, "-2847024", "% #2.4d", +__LINE__, 0xffffffd0, "FFFFFFD0", "%X", +__LINE__, -0x6970fa1, "-110563233", "%+#.4ld", +__LINE__, 0x06387dcc, "0X6387DCC", "%-#X", +__LINE__, 0xffffd506, "ffffd506", "%+6x", +__LINE__, -0x00fe5cd, "-1041869", "%-#7d", +__LINE__, -0x0c35bf6, "-12803062", "%-03d", +__LINE__, -0x0020d89, "-134537", "%#d", +__LINE__, -0x0c7aed3, "-13086419", "%-ld", +__LINE__, -0x000362a, "-13866", "%#.4ld", +__LINE__, -0x02d05f0, "-2950640", "%#ld", +__LINE__, 0x02de1321, "0x2de1321", "%#7.x", +__LINE__, 0xffb56428, "0xffb56428", "%#x", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, 0xf072292d, "F072292D", "%.5X", +__LINE__, -0x0f4b0f2, "-16036082", "%.5ld", +__LINE__, 0x01b81885, "28842117", "%5d", +__LINE__, -0x009cfa6, "-642982", "%d", +__LINE__, 0xfffffffd, "0XFFFFFFFD", "%-#.5X", +__LINE__, 0x0dc97a66, "DC97A66", "%2.X", +__LINE__, 0x000000be, "190", "%.0d", +__LINE__, 0xffffe1c7, "FFFFE1C7", "% X", +__LINE__, 0x01883b9a, "1883b9a", "%3x", +__LINE__, 0xffffdde1, "ffffdde1", "%+x", +__LINE__, 0x2f1b4e32, "+790318642", "%+ld", +__LINE__, 0x000129aa, "129aa", "%x", +__LINE__, -0x00092c2, "-37570", "%d", +__LINE__, 0x00070fbd, "70fbd", "%x", +__LINE__, -0x00000ea, "-234", "%+4ld", +__LINE__, 0xfffffffe, "fffffffe", "%x", +__LINE__, 0x0091c7f7, "91C7F7", "% .3X", +__LINE__, -0x0c14fe2, "-12668898", "%d", +__LINE__, -0x0017c15, "-97301", "%d", +__LINE__, -0x00005d0, "-0001488", "%5.7d", +__LINE__, 0x0114c36e, "18137966", "%0d", +__LINE__, 0xffffffff, "ffffffff", "%+x", +__LINE__, 0x0ac76e78, "180842104", "%d", +__LINE__, 0x001976cd, " 1668813", "% 4.ld", +__LINE__, -0x0642319, "-6562585", "% d", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, -0x035019d, "-3473821", "%.7d", +__LINE__, -0x0000061, "-97", "%#3.d", +__LINE__, 0x0000001f, " 31", "% 6.1ld", +__LINE__, -0x0000024, "-36", "%d", +__LINE__, 0x000b3785, "735109", "%ld", +__LINE__, 0xfffffda9, "fffffda9", "%-x", +__LINE__, 0x00254832, "2443314", "%-ld", +__LINE__, 0xfffffd40, "FFFFFD40", "%0X", +__LINE__, -0x0006105, "-24837", "%+#d", +__LINE__, 0x00000006, "+6", "%+d", +__LINE__, 0xffd40fd8, "ffd40fd8", "%3.x", +__LINE__, -0x000988e, "-39054", "%03d", +__LINE__, 0x0005ad8b, "5AD8B", "%0.0X", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0xfe1f59b7, "fe1f59b7", "%4.x", +__LINE__, -0x0000022, "-34", "%#d", +__LINE__, 0x0018e3e9, "18E3E9", "% X", +__LINE__, 0xffffff25, "FFFFFF25", "%2.X", +__LINE__, -0x00002c6, "-710", "%1.ld", +__LINE__, 0x00009765, "38757", "%5ld", +__LINE__, 0xfe197646, "FE197646", "%-X", +__LINE__, 0x00000001, " 1", "%+5.x", +__LINE__, -0x0000002, "-2", "%#ld", +__LINE__, 0x0072f6be, "72F6BE", "%1X", +__LINE__, -0x000f06d, "-61549", "%-d", +__LINE__, 0x00000001, " 1", "%5X", +__LINE__, 0x328cba28, " 848083496", "% 2.ld", +__LINE__, 0x0000cddc, "cddc", "%.1x", +__LINE__, 0xfffffff9, "fffffff9", "%7x", +__LINE__, 0x00baf511, "BAF511", "%-5.6X", +__LINE__, 0x00000001, " 1", "%4.ld", +__LINE__, 0x0001e4b0, "+124080", "%+ld", +__LINE__, -0x07548f3, "-7686387", "% 6.d", +__LINE__, -0x01b14ea, "-1774826", "% #0d", +__LINE__, -0x000005c, "-92 ", "%-04ld", +__LINE__, -0x00000ae, "-174", "%+.3ld", +__LINE__, 0x0000008c, "0X8C", "%+#X", +__LINE__, 0x14c02360, "14C02360", "%.6X", +__LINE__, 0xfffffff6, "FFFFFFF6", "%X", +__LINE__, 0x009f4ee5, "9f4ee5", "%x", +__LINE__, 0x00000035, "35", "%X", +__LINE__, -0x00000eb, "-235", "%ld", +__LINE__, 0x1552ced8, "1552CED8", "%04X", +__LINE__, 0x0000002a, " 2A", "%5X", +__LINE__, 0xffffffff, "ffffffff", "% x", +__LINE__, -0xdec0db2, "-233573810", "%d", +__LINE__, 0x001e2ef0, "1978096", "%2.d", +__LINE__, 0xffffef24, "ffffef24", "%.5x", +__LINE__, 0xfffe6a6c, "fffe6a6c", "%+x", +__LINE__, -0x0000004, "-4", "% ld", +__LINE__, 0xfe3c6743, "fe3c6743", "%.1x", +__LINE__, 0x0000033d, "829", "%0ld", +__LINE__, -0x00006a0, " -1696", "% 7.ld", +__LINE__, 0xffffffdb, "ffffffdb", "%0.0x", +__LINE__, 0xfffffffc, "FFFFFFFC", "%3.3X", +__LINE__, -0x0000004, "-4", "%#ld", +__LINE__, 0x00b32b56, "B32B56", "%X", +__LINE__, 0xffffffff, "0xffffffff", "%+#x", +__LINE__, 0x01cd1a48, "1cd1a48", "%+7x", +__LINE__, 0xffffffda, "ffffffda", "%x", +__LINE__, 0x1886509e, "1886509E", "% X", +__LINE__, 0x000000eb, "235", "%0d", +__LINE__, 0xfffffff4, "fffffff4", "%0x", +__LINE__, 0x00000547, "547", "% X", +__LINE__, 0x000017e6, "17e6", "%-2.x", +__LINE__, 0x00001dc4, "7620", "%d", +__LINE__, 0xffffffff, "FFFFFFFF", "%3.0X", +__LINE__, 0xffff93fa, "0XFFFF93FA", "%#X", +__LINE__, 0xfffffe1c, "FFFFFE1C", "%-X", +__LINE__, 0x00000000, "", "% .0x", +__LINE__, 0x000000a1, "A1", "%X", +__LINE__, 0xffffffff, "0xffffffff", "%#x", +__LINE__, -0x0001460, "-05216", "%+#.5d", +__LINE__, 0x00000001, "1 ", "%-6.x", +__LINE__, 0xfffd5324, "FFFD5324", "%+2.6X", +__LINE__, 0x00000007, " 07", "%06.2d", +__LINE__, 0x00000003, "3", "%-X", +__LINE__, 0xfffffdb7, "0XFFFFFDB7", "%+#X", +__LINE__, 0xfffff4cc, "fffff4cc", "%0x", +__LINE__, 0x00000000, "0 ", "%-5X", +__LINE__, 0x00758c96, "758C96", "%X", +__LINE__, -0x0000001, "-1", "%-ld", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0x03f03caf, "66075823", "%.2ld", +__LINE__, 0x0000a87c, "a87c", "%1.x", +__LINE__, 0x00000034, "34", "%X", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0x00010167, "10167", "%x", +__LINE__, -0x00007ce, "-1998 ", "%-6ld", +__LINE__, 0x00000001, "1", "%.0d", +__LINE__, 0x00d94cee, "14241006", "%ld", +__LINE__, -0x0000008, "-8", "% d", +__LINE__, -0x71520839, "-1901201465", "%+0d", +__LINE__, 0x0000035a, "35a", "%-x", +__LINE__, 0xfffd2f68, "FFFD2F68", "%-X", +__LINE__, 0x0006ea53, "453203", "%1d", +__LINE__, 0x000000df, "DF", "% 1X", +__LINE__, 0xfffffffe, "fffffffe", "% 7x", +__LINE__, 0x00000156, "156", "% X", +__LINE__, 0x00037ac9, " 228041", "% ld", +__LINE__, 0xffffffde, "FFFFFFDE", "%0.5X", +__LINE__, 0x00000025, "37", "%-0.ld", +__LINE__, -0x4133686, "-68368006", "%2ld", +__LINE__, -0x000003b, "-59", "%.2ld", +__LINE__, 0xfffff910, "fffff910", "% 00.0x", +__LINE__, 0xff9ec802, "FF9EC802", "%2.6X", +__LINE__, 0x00000008, "0X8", "%#1X", +__LINE__, 0xfffffff7, "FFFFFFF7", "%-X", +__LINE__, 0x0029a4da, "2729178", "%04.ld", +__LINE__, 0x007d1588, "8197512", "%#d", +__LINE__, 0x0007e86d, "518253", "%0d", +__LINE__, 0xfffffff9, "fffffff9", "%x", +__LINE__, 0x00000002, "002", "%.3d", +__LINE__, 0x00006ec1, "6EC1", "%2X", +__LINE__, 0x0000300c, "12300", "%-d", +__LINE__, -0x0000002, "-2", "%+ld", +__LINE__, -0x0000002, "-2", "%ld", +__LINE__, -0x00015d5, "-005589", "%#.6ld", +__LINE__, 0x00000041, "65", "%d", +__LINE__, 0x00000229, "0000229", "% 0.7x", +__LINE__, 0xfffffffb, "fffffffb", "%03.x", +__LINE__, 0x00093262, "0602722", "%.7d", +__LINE__, -0x00037b4, "-14260", "%-0ld", +__LINE__, 0xfffffffc, "fffffffc", "%-x", +__LINE__, 0xf24cb3e6, "f24cb3e6", "%1x", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xfffffffb, "FFFFFFFB", "%0X", +__LINE__, 0x00000031, "0000049", "%00.7ld", +__LINE__, 0x00000bb3, "BB3", "%.1X", +__LINE__, -0x0000001, "-0001", "%+#4.4ld", +__LINE__, -0x0000001, "-1", "% d", +__LINE__, 0x00022c0c, "22c0c", "%-x", +__LINE__, 0xffffffd4, "ffffffd4", "%x", +__LINE__, 0x000729c6, "469446", "%3.d", +__LINE__, 0xb180feae, "b180feae", "%3.x", +__LINE__, 0x124fac15, "307211285", "%-0ld", +__LINE__, -0x0000004, "-4", "%ld", +__LINE__, 0x0000006a, "106", "%#d", +__LINE__, 0x0000297f, "297F", "%+3X", +__LINE__, 0x0000000e, "14", "%0ld", +__LINE__, 0x00000027, "27", "%0.1X", +__LINE__, 0xffeb98eb, "ffeb98eb", "% 05.2x", +__LINE__, 0xfffff19b, "FFFFF19B", "%+X", +__LINE__, 0x00025992, "154002", "%6.6d", +__LINE__, 0x00000040, " 040", "%6.3X", +__LINE__, 0x00000a9e, " 0a9e", "%5.4x", +__LINE__, 0x00c7f2cc, "c7f2cc", "%x", +__LINE__, 0x000325e6, " 325E6", "%6.X", +__LINE__, -0x69faad3, "-111127251", "%d", +__LINE__, -0x059a307, "-5874439", "% ld", +__LINE__, 0xfffffff6, "0xfffffff6", "%#0.0x", +__LINE__, 0x0030fdf3, "30fdf3", "%x", +__LINE__, 0x00007343, "+29507", "%+#2d", +__LINE__, 0x0003cf4b, "0X3CF4B", "% #.2X", +__LINE__, 0x00000433, "+1075", "%+0ld", +__LINE__, 0xfffffffd, "fffffffd", "%+.3x", +__LINE__, 0x0ae30c4e, "ae30c4e", "%+00x", +__LINE__, 0x0002540f, "02540f", "%-.6x", +__LINE__, -0x0000001, " -01", "% #5.2ld", +__LINE__, 0xffffffe7, "0xffffffe7", "% #5.x", +__LINE__, 0x0000005b, "91", "%d", +__LINE__, 0x00001f9b, "8091", "%.4ld", +__LINE__, 0xfffff315, "fffff315", "%4.x", +__LINE__, -0x130eec41, "-319745089", "% ld", +__LINE__, 0xfff8fe13, "FFF8FE13", "%X", +__LINE__, -0x0000004, "-00004", "%5.5d", +__LINE__, 0x00000669, "669", "%0X", +__LINE__, -0x0000004, "-4", "%d", +__LINE__, 0xf5e81496, "F5E81496", "% 6X", +__LINE__, -0x0000001, "-1", "% 0d", +__LINE__, 0xfffffff7, "fffffff7", "%x", +__LINE__, 0x000001de, "478", "%d", +__LINE__, 0x0000623e, "25150", "%5.0d", +__LINE__, 0xffffffa8, "FFFFFFA8", "%+X", +__LINE__, -0x0000117, "-279", "% ld", +__LINE__, -0x0000517, "-1303", "%d", +__LINE__, 0xfffff9d5, "fffff9d5", "% x", +__LINE__, 0x000001cc, "1CC", "%-X", +__LINE__, 0x0000019a, "0000410", "%.7d", +__LINE__, 0x00000003, "3 ", "%-06X", +__LINE__, 0x00000009, "0x9", "%#0x", +__LINE__, 0xfd544610, "0XFD544610", "% #X", +__LINE__, 0xfffffffc, "fffffffc", "%+x", +__LINE__, 0x00009437, "37943", "%ld", +__LINE__, -0x00b5ea6, "-745126", "%d", +__LINE__, 0xffffffd8, "ffffffd8", "%6x", +__LINE__, 0x00002a2d, "10797", "%.3ld", +__LINE__, 0x00275238, "2576952", "%0ld", +__LINE__, 0xfff90a34, "FFF90A34", "%-7X", +__LINE__, 0xfffffffe, "FFFFFFFE", "% .7X", +__LINE__, -0xb3b673e, "-188442430", "% ld", +__LINE__, 0xfffff67a, "0xfffff67a", "%#0.x", +__LINE__, 0x0000dff6, " dff6", "%+7.x", +__LINE__, 0xffee46e3, "ffee46e3", "%x", +__LINE__, 0x00001a66, " 0006758", "% 7.7d", +__LINE__, 0x0002b475, "2B475", "%.4X", +__LINE__, 0x0002090d, "002090d", "%.7x", +__LINE__, -0x0057838, "-358456", "%#ld", +__LINE__, 0x00000004, "0x4", "%#x", +__LINE__, 0x0574cb62, "91540322", "%#7d", +__LINE__, -0x0054388, "-344968", "% #d", +__LINE__, 0x000421c2, "421C2", "% X", +__LINE__, 0x00000003, "3", "%0d", +__LINE__, 0xffffe2e2, "ffffe2e2", "% 5.x", +__LINE__, 0x00000021, "+33", "%+d", +__LINE__, -0x0020033, "-131123", "%ld", +__LINE__, -0x0000001, " -1", "%4.ld", +__LINE__, 0x000000fd, "000fd", "%3.5x", +__LINE__, 0x023e4337, "37634871", "%1d", +__LINE__, 0x6e823d96, "6E823D96", "% X", +__LINE__, 0xfff0e133, "fff0e133", "%x", +__LINE__, -0x000decc, "-57036", "%3d", +__LINE__, 0x004397b8, "4429752", "%0d", +__LINE__, -0x0000023, " -35", "%6d", +__LINE__, 0xffe701ca, "FFE701CA", "%3X", +__LINE__, 0x000c0319, "+787225", "%+.6d", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xfffffe1d, "FFFFFE1D", "%X", +__LINE__, 0xfffffb33, "fffffb33", "%x", +__LINE__, 0x02b5e30a, "45474570", "%d", +__LINE__, 0x000074eb, "29931", "%03.ld", +__LINE__, -0x4e42e310, "-1313006352", "%-0.d", +__LINE__, -0x000007b, "-123", "%d", +__LINE__, 0x00000160, " 352", "% d", +__LINE__, -0x16af31ec, "-380580332", "%#ld", +__LINE__, -0x000006e, "-000110", "%07ld", +__LINE__, 0x232699a0, "232699a0", "%7.x", +__LINE__, 0x00f9b8e5, "+16365797", "%+0d", +__LINE__, 0x0000000c, "C", "%X", +__LINE__, 0xfffffd4f, "FFFFFD4F", "%X", +__LINE__, 0xffffe7bb, "FFFFE7BB", "%.7X", +__LINE__, -0x0000163, "-355", "%d", +__LINE__, 0x00070315, " 459541", "% #2.d", +__LINE__, -0x7d5c12a, "-131449130", "% 6.ld", +__LINE__, 0xffffffb2, "FFFFFFB2", "%X", +__LINE__, -0x0004aad, "-19117", "%+6.4ld", +__LINE__, 0x00115586, "1136006", "%0d", +__LINE__, -0x0000021, "-33", "%d", +__LINE__, 0x093ce01e, "93ce01e", "% 5x", +__LINE__, 0x00672135, "672135", "% x", +__LINE__, 0x05f4abd5, "0x5f4abd5", "%+#6.x", +__LINE__, -0x0448b03, "-4492035", "%-0.2ld", +__LINE__, 0x00000000, "0", "%#x", +__LINE__, 0x1987217e, "428286334", "%d", +__LINE__, 0x000010f6, "10f6", "%-x", +__LINE__, 0x0000177a, "177a", "%1x", +__LINE__, 0xfffffefd, "FFFFFEFD", "%7X", +__LINE__, -0x095cbf8, "-9817080", "%-5ld", +__LINE__, 0x0000008a, "138", "%2.0ld", +__LINE__, 0xfffe80ad, "fffe80ad", "%0x", +__LINE__, -0x1a4c8f7, "-27576567", "%d", +__LINE__, 0x00000000, "0", "%-x", +__LINE__, 0x0000a82b, "43051", "%-ld", +__LINE__, 0x000000eb, "235", "%2.3ld", +__LINE__, -0x0002747, "-10055", "%d", +__LINE__, 0x00000319, "0X319", "%#X", +__LINE__, 0xfffffcfe, "FFFFFCFE", "% X", +__LINE__, 0x00050f0e, "50f0e", "%-1x", +__LINE__, -0x398e09e, "-60350622", "%0.7ld", +__LINE__, 0x00000000, " ", "%2.ld", +__LINE__, 0x00000049, "00049", "% .5X", +__LINE__, -0x00000dd, " -221", "%+#5ld", +__LINE__, 0xf6db2fac, "f6db2fac", "%-07x", +__LINE__, 0x0000004f, "4F", "% .0X", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xfd07f692, "fd07f692", "%x", +__LINE__, 0xdb98bde0, "db98bde0", "%x", +__LINE__, 0x00000271, "0271", "% 3.4x", +__LINE__, -0x000115a, "-4442", "%#1.ld", +__LINE__, 0x0002f5f2, "194034", "%ld", +__LINE__, -0x0000152, " -338", "%+7ld", +__LINE__, 0x00059336, "365366", "%d", +__LINE__, 0xfffffff6, "fffffff6", "%-7x", +__LINE__, 0xfb916c51, "fb916c51", "%-x", +__LINE__, 0xffff413d, "FFFF413D", "%-X", +__LINE__, 0xf2576910, "F2576910", "%-4.X", +__LINE__, 0xfffc7730, "fffc7730", "%5.x", +__LINE__, 0x000002e6, "+742", "%+1d", +__LINE__, -0x00001bf, "-447", "%3d", +__LINE__, 0x000002e1, "2E1", "%-X", +__LINE__, 0x00000096, "150", "%#0ld", +__LINE__, 0x000002bd, "701", "%d", +__LINE__, -0x0053386, "-340870", "%#d", +__LINE__, 0xfffdb076, "FFFDB076", "%X", +__LINE__, 0x00004dc5, " +19909", "%+07.ld", +__LINE__, 0x00000f7a, " F7A", "%4X", +__LINE__, 0x02405000, " 37769216", "% ld", +__LINE__, 0xfffce68d, "fffce68d", "%0x", +__LINE__, -0x35b3af2, "-56310514", "%-ld", +__LINE__, -0x0238631, "-2328113", "%.4d", +__LINE__, -0x000001e, "-030", "%.3ld", +__LINE__, 0xffffffdd, "FFFFFFDD", "%.4X", +__LINE__, 0x0013f6ac, "13f6ac", "%02.x", +__LINE__, 0xfffffffa, "fffffffa", "%+07.x", +__LINE__, -0x000192b, " -6443", "%6.d", +__LINE__, 0x0000058b, "+1419", "%+d", +__LINE__, 0x00001391, "5009", "%ld", +__LINE__, -0x0041a57, "-268887", "%1ld", +__LINE__, 0xfffff266, "0xfffff266", "%+#6.6x", +__LINE__, 0x0000018b, " 395", "%6.ld", +__LINE__, 0x009ae24d, "+10150477", "%+ld", +__LINE__, 0x0000007e, "7E", "%X", +__LINE__, 0xfffffd53, "FFFFFD53", "% 0X", +__LINE__, 0x000002fa, "2FA", "%-1.3X", +__LINE__, 0x000000a4, "164", "%0d", +__LINE__, 0x00001833, "6195", "%ld", +__LINE__, -0x0000001, "-1", "%d", +__LINE__, 0xf2fcbd9b, "F2FCBD9B", "%+0.2X", +__LINE__, 0x00004a8a, "4A8A", "%X", +__LINE__, -0x10695cda, "-275340506", "%d", +__LINE__, 0x00000037, "37", "%X", +__LINE__, 0x00082d5c, "82D5C", "%+0.5X", +__LINE__, 0xfffffe01, "fffffe01", "% 5.3x", +__LINE__, 0x000005ea, "05EA", "% 1.4X", +__LINE__, 0x0e0b8826, "e0b8826", "%2x", +__LINE__, -0x0000161, "-353", "%+d", +__LINE__, 0x19e3014a, "19E3014A", "%+5X", +__LINE__, 0x00000140, "140", "%x", +__LINE__, 0xffff84b9, "FFFF84B9", "%X", +__LINE__, -0x0005776, "-22390", "%+5ld", +__LINE__, 0x0162ad61, "162AD61", "% X", +__LINE__, 0x00002395, "2395", "%X", +__LINE__, 0x003702ec, "3605228", "%5.2d", +__LINE__, 0xffffffff, "FFFFFFFF", "%7X", +__LINE__, 0x00001778, "0x1778", "%#5.x", +__LINE__, 0xc52bef7f, "C52BEF7F", "%X", +__LINE__, 0xfffffec4, "FFFFFEC4", "%X", +__LINE__, 0x00000006, "6", "%X", +__LINE__, 0x00000000, "000", "%03.3x", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xffff6c46, "FFFF6C46", "% 2.2X", +__LINE__, -0x1506098, "-22044824", "%01.d", +__LINE__, 0x03415caf, "3415caf", "%x", +__LINE__, -0x00007b4, "-1972", "%#4.4d", +__LINE__, -0x00158c9, "-88265", "%03.4d", +__LINE__, 0x6947c336, "1766310710", "%.6d", +__LINE__, 0x0000017c, "17C", "% 0X", +__LINE__, -0x00001b7, "-439", "% 0ld", +__LINE__, 0x06a7575a, "6A7575A", "%-.0X", +__LINE__, 0x000b3459, "734297", "%ld", +__LINE__, -0x395d8dd, "-60152029", "%ld", +__LINE__, 0x00036bb3, "224179", "%-6.d", +__LINE__, 0xffff14ff, "FFFF14FF", "%X", +__LINE__, -0x15910e4f, "-361827919", "%-0d", +__LINE__, -0x0000004, "-4", "%#d", +__LINE__, 0xf7f7adac, "F7F7ADAC", "% 3.X", +__LINE__, 0xffffff74, "FFFFFF74", "%0X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, -0x000007b, "-123 ", "%-7.d", +__LINE__, -0x000002c, "-44", "%d", +__LINE__, -0x000002b, " -43", "%5d", +__LINE__, 0x0000ae5f, "44639", "%d", +__LINE__, 0x003cbc63, "3CBC63", "%X", +__LINE__, 0xfffffffc, "0XFFFFFFFC", "%#5.7X", +__LINE__, 0x0003e044, "3E044", "%X", +__LINE__, -0x0000c46, "-3142", "%.1d", +__LINE__, 0xff18f4bb, "FF18F4BB", "%0X", +__LINE__, 0xfffffffd, "FFFFFFFD", "%.1X", +__LINE__, -0x01c0f27, "-1838887", "%0d", +__LINE__, -0x1242901f, "-306352159", "%.4ld", +__LINE__, 0x1775c10a, "393593098", "%6.ld", +__LINE__, 0x00000001, " 1", "%03.d", +__LINE__, 0xfff1fd30, "0xfff1fd30", "%#x", +__LINE__, 0x00000191, "191", "%0.X", +__LINE__, 0x2e597178, "777613688", "%2.ld", +__LINE__, -0x4ef0cf3, "-82775283", "%+.6ld", +__LINE__, -0x0000085, " -133", "%6.d", +__LINE__, 0x0000014d, "333 ", "%-5ld", +__LINE__, -0xc03bd74, "-201571700", "%07.6ld", +__LINE__, -0x000000a, "-10", "%d", +__LINE__, 0x01f5e86e, "32893038", "%#2.ld", +__LINE__, 0x00000033, "0X33", "% #X", +__LINE__, 0x0087c797, " 8898455", "% 7.d", +__LINE__, -0x0001205, "-4613", "%5d", +__LINE__, 0x00000192, " 192", "%7.X", +__LINE__, 0x000e6c00, "945152", "%6.1ld", +__LINE__, 0x00018629, " 99881", "% d", +__LINE__, -0x04739c6, "-4667846", "%-01.3ld", +__LINE__, 0x00001f42, "8002", "%d", +__LINE__, 0x00000caf, "3247", "%d", +__LINE__, -0x4992e24, "-77147684", "%#.6d", +__LINE__, 0x0000001d, "1d", "%-0x", +__LINE__, 0x14d79f03, "349675267", "%0ld", +__LINE__, 0x00000dd4, " 03540", "%#6.5ld", +__LINE__, 0x0005f30e, "0X5F30E", "%#X", +__LINE__, 0x00000157, "157", "%X", +__LINE__, -0x9281698, "-153622168", "%d", +__LINE__, -0x000004a, "-74", "%d", +__LINE__, -0x0010c9e, "-68766", "%-0d", +__LINE__, 0x00000059, "00089", "%.5ld", +__LINE__, -0x06959e3, "-6904291", "% 4.d", +__LINE__, 0xfbea12b1, "0XFBEA12B1", "%+#X", +__LINE__, 0xffffdfb1, "FFFFDFB1", "%2.6X", +__LINE__, 0x0434faac, "434faac", "%.5x", +__LINE__, 0xffffffff, "ffffffff", "% x", +__LINE__, 0x00000b32, "B32", "%0X", +__LINE__, 0x00000047, "71", "%.1d", +__LINE__, 0x00070bef, " 0461807", "% .7d", +__LINE__, 0x00000038, "38", "% 0x", +__LINE__, 0x00000000, " 0", "%6X", +__LINE__, 0xfff9c011, "FFF9C011", "%2X", +__LINE__, 0xfffffffe, "fffffffe", "%7x", +__LINE__, 0xfffffff9, "FFFFFFF9", "%X", +__LINE__, -0x016a095, "-1482901", "%4.0ld", +__LINE__, -0x000001c, "-28", "% ld", +__LINE__, 0xfffd6133, "0xfffd6133", "%#x", +__LINE__, 0x000004a4, "0x4a4", "%#x", +__LINE__, 0x000003c2, "0962", "%.4d", +__LINE__, -0x000323b, "-12859", "%+#d", +__LINE__, 0x0f620237, "F620237", "%X", +__LINE__, 0x00007863, "007863", "%.6X", +__LINE__, 0x0000002c, " 44", "% #ld", +__LINE__, 0xfffffff0, "fffffff0", "%03.6x", +__LINE__, 0xffff6346, "FFFF6346", "%1.X", +__LINE__, 0x00063188, "63188", "% x", +__LINE__, 0xfffff91c, "fffff91c", "%-.3x", +__LINE__, 0x004cd0b4, "4CD0B4", "%-2.X", +__LINE__, 0x06b4d739, "112514873", "%0.1d", +__LINE__, -0x0009beb, "-39915", "%.2d", +__LINE__, 0x0000831b, "33563", "%d", +__LINE__, 0x00000001, "1", "%X", +__LINE__, -0x942d76b, "-155375467", "% #0ld", +__LINE__, 0xffff2a95, "FFFF2A95", "%2X", +__LINE__, 0x00548d5e, "5541214", "%.3ld", +__LINE__, 0x0b5e1a01, "B5E1A01", "% .7X", +__LINE__, 0xfffffc22, "fffffc22", "%6x", +__LINE__, -0x0000dd7, "-3543", "%-.3ld", +__LINE__, 0xfffff834, "FFFFF834", "%X", +__LINE__, 0x0365f762, "57014114", "%ld", +__LINE__, -0x0000003, "-3", "%d", +__LINE__, 0x3bd998a3, "1004116131", "%d", +__LINE__, 0xfffff6c9, "FFFFF6C9", "%+X", +__LINE__, 0xffffded9, "FFFFDED9", "%-.1X", +__LINE__, -0x00fbb5a, "-1031002", "% 1.0d", +__LINE__, 0xffffffb7, "ffffffb7", "%6.x", +__LINE__, 0xff1b8ac3, "FF1B8AC3", "%-X", +__LINE__, 0xfffffff2, "FFFFFFF2", "%00.X", +__LINE__, -0x000013d, " -317", "%05.d", +__LINE__, 0x0000f5e2, "+62946", "%+0.2ld", +__LINE__, 0x16ac6358, "16ac6358", "%x", +__LINE__, 0xffff8728, "FFFF8728", "%+X", +__LINE__, -0x0014a6d, "-084589", "%0.6ld", +__LINE__, 0xfc904514, "FC904514", "%+0X", +__LINE__, 0x00000004, "4", "%ld", +__LINE__, 0xffffffe0, "ffffffe0", "%+x", +__LINE__, -0x0a0ffdd, "-10551261", "%+02d", +__LINE__, -0x0000bbc, "-3004", "%+d", +__LINE__, 0x00000006, " +6", "%+7ld", +__LINE__, 0x17afa6e5, "397387493", "%ld", +__LINE__, 0xfffff6bf, "fffff6bf", "%+04.4x", +__LINE__, 0x000001dc, "01dc", "% 02.4x", +__LINE__, 0x0000000e, " 14", "% d", +__LINE__, 0xfffffff9, "0XFFFFFFF9", "%#4.X", +__LINE__, 0x0000005d, "93", "%0d", +__LINE__, -0x004fa05, "-0326149", "%.7d", +__LINE__, -0x0000018, "-24", "%ld", +__LINE__, 0xfffff7eb, "FFFFF7EB", "%X", +__LINE__, 0x0072b044, " 7516228", "% .7ld", +__LINE__, 0xffffffed, "0xffffffed", "%#x", +__LINE__, 0x0010364d, "10364D", "%X", +__LINE__, 0xfff90469, "0XFFF90469", "%#X", +__LINE__, 0x000001b4, " 436", "% 0d", +__LINE__, 0x00000000, "0", "% X", +__LINE__, 0xfffffff3, "fffffff3", "%x", +__LINE__, 0x19335d40, "19335d40", "%6x", +__LINE__, 0x00039c24, "236580", "%ld", +__LINE__, 0x000021f7, "8695", "%0.4ld", +__LINE__, -0x057b406, "-5747718", "%d", +__LINE__, -0x017b371, "-1553265", "%#ld", +__LINE__, 0x0003e405, "254981", "%2.d", +__LINE__, 0x00000001, "1", "%-.1x", +__LINE__, 0x000000ae, "AE", "%.1X", +__LINE__, 0xffd85825, "ffd85825", "%-7.x", +__LINE__, 0xfffad763, "fffad763", "%x", +__LINE__, 0x002431d4, "2372052", "%6.ld", +__LINE__, 0x00000003, "000003", "%-05.6d", +__LINE__, 0xffffffeb, "0xffffffeb", "%#x", +__LINE__, 0xff8cf3b0, "ff8cf3b0", "%x", +__LINE__, 0xfe88d2ff, "0xfe88d2ff", "%+#.2x", +__LINE__, 0xffffff6b, "ffffff6b", "%6.3x", +__LINE__, 0xfffffffe, "fffffffe", "%-x", +__LINE__, 0xe998945a, "e998945a", "%2.x", +__LINE__, 0x03b9c50f, "3B9C50F", "%+X", +__LINE__, 0xffffffff, "FFFFFFFF", "%3.7X", +__LINE__, 0x000024ef, "24ef", "%+x", +__LINE__, 0xfffffc04, "FFFFFC04", "%X", +__LINE__, 0x0d4bef7c, " 223080316", "% .1ld", +__LINE__, -0xc33f3bc, "-204731324", "%.5ld", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#2X", +__LINE__, 0x0000e493, "e493", "%x", +__LINE__, 0x000001b4, "1b4", "%x", +__LINE__, 0xffffffd6, "0xffffffd6", "% #1x", +__LINE__, 0x00000001, "1", "%d", +__LINE__, -0x0000f28, "-3880", "%ld", +__LINE__, 0x00000277, "631", "%-1ld", +__LINE__, 0x00000001, " 1", "%2x", +__LINE__, -0x0ff4d2c, "-16731436", "%#ld", +__LINE__, 0x0bb80344, "196608836", "%00ld", +__LINE__, 0xffffffdc, "FFFFFFDC", "%X", +__LINE__, 0x00000484, "1156", "%ld", +__LINE__, 0x00000341, "341", "%-.2x", +__LINE__, 0x0000ee62, "ee62", "%x", +__LINE__, 0xfffffe20, "fffffe20", "%+x", +__LINE__, -0x00076eb, "-30443", "%.2d", +__LINE__, 0x2c4a7407, "2c4a7407", "% x", +__LINE__, 0x00000000, " ", "%3.X", +__LINE__, 0xffffff60, "ffffff60", "% 4.x", +__LINE__, 0x000e4cf2, "+937202", "%+.5ld", +__LINE__, 0x00000008, " 00008", "%06.5X", +__LINE__, 0x0002f612, "194066", "%d", +__LINE__, 0xfffffc96, "fffffc96", "%-3.3x", +__LINE__, -0x0000001, "-1", "% ld", +__LINE__, 0x00000000, " ", "% 6.0X", +__LINE__, 0xfffffff5, "fffffff5", "%3.x", +__LINE__, 0x0bfd63a1, "201155489", "%d", +__LINE__, -0x1547c214, "-357024276", "%ld", +__LINE__, 0x00000004, "4", "%#0.d", +__LINE__, -0x000f2f3, "-62195", "%.2d", +__LINE__, 0xfff843dd, "FFF843DD", "%X", +__LINE__, 0x00966e36, "9858614", "%.0ld", +__LINE__, 0x0000782e, "0X782E", "% #X", +__LINE__, 0x00bd36c0, "12400320", "%ld", +__LINE__, 0x00000000, "00", "% .2X", +__LINE__, 0x00000000, "0", "%1X", +__LINE__, 0x0003f416, "3f416 ", "%-6.x", +__LINE__, -0x00b74bd, "-750781", "% ld", +__LINE__, 0x0000138a, "138a", "% x", +__LINE__, 0x024df7f0, "24DF7F0", "% 0.6X", +__LINE__, 0xfffffffc, "FFFFFFFC", "%X", +__LINE__, -0x0003284, "-12932 ", "%-07.ld", +__LINE__, 0x000094d3, "94d3", "%x", +__LINE__, 0x000000bf, "bf", "%.2x", +__LINE__, 0x00000000, "00000", "%-1.5X", +__LINE__, -0x04899b8, "-4757944", "%d", +__LINE__, 0x2b51bf20, "+726777632", "%+d", +__LINE__, -0x000000d, "-13", "%.2d", +__LINE__, 0x04f78fbd, "4F78FBD", "% 7.X", +__LINE__, 0x00011684, "71300", "%5.d", +__LINE__, 0x0000539d, "21405", "%0d", +__LINE__, 0x00000008, "000008", "%-3.6X", +__LINE__, 0xfc7a2cdc, "fc7a2cdc", "%2.3x", +__LINE__, 0xffc21da1, "ffc21da1", "%x", +__LINE__, 0x00000273, "273", "%x", +__LINE__, 0x00000000, "0", "%#X", +__LINE__, -0x31cd6b9, "-52221625", "% d", +__LINE__, 0xfffffff8, "FFFFFFF8", "%.0X", +__LINE__, 0x00000002, "2", "%#ld", +__LINE__, 0x00e8922c, "15241772", "%d", +__LINE__, 0xfeb19ea7, "FEB19EA7", "%0.1X", +__LINE__, 0x00003931, "014641", "%06ld", +__LINE__, 0x00000015, "0X00015", "%#.5X", +__LINE__, 0xfffffffe, "FFFFFFFE", "%1.X", +__LINE__, 0xfff17103, "0XFFF17103", "% #X", +__LINE__, 0xfffffffc, "FFFFFFFC", "%+X", +__LINE__, 0x00000002, "00002", "%.5x", +__LINE__, 0x00001617, " 5655", "% 7.d", +__LINE__, -0x0000010, "-000016", "%00.6d", +__LINE__, 0x000000b0, "B0", "% X", +__LINE__, 0xfc9362b2, "FC9362B2", "%-X", +__LINE__, 0xfc3d8276, "fc3d8276", "% 1x", +__LINE__, 0x00001405, "5125", "%#d", +__LINE__, 0x02250183, " 35979651", "% ld", +__LINE__, 0xffc9b007, "ffc9b007", "% 4.x", +__LINE__, 0x00000311, "785", "%0d", +__LINE__, 0x0004d273, " 316019", "% d", +__LINE__, 0x00000001, "1", "%1.x", +__LINE__, 0xffff240f, "FFFF240F", "%4.X", +__LINE__, 0x0049cfda, "+4837338", "%+ld", +__LINE__, 0x012f6dd5, "12F6DD5", "% 6.2X", +__LINE__, 0x00000002, "0x2", "%#2.0x", +__LINE__, 0xfffd834a, "FFFD834A", "%.6X", +__LINE__, 0xfe2a40f8, "0XFE2A40F8", "%#X", +__LINE__, 0xffffffeb, "ffffffeb", "%x", +__LINE__, -0x00ac5cb, "-705995", "%d", +__LINE__, -0x3021108c, "-807473292", "% .4d", +__LINE__, -0x0000035, "-53", "%-ld", +__LINE__, -0x1a36475, "-27485301", "% d", +__LINE__, -0x0000011, "-17", "%d", +__LINE__, 0x000001a3, "000419", "%.6ld", +__LINE__, 0x0030a0a8, "3186856", "%.5ld", +__LINE__, 0x00000019, "25", "%d", +__LINE__, 0xf32deac1, "F32DEAC1", "%06.2X", +__LINE__, -0x0000004, " -00004", "%7.5ld", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, 0x0006bf19, "442137", "%#0.d", +__LINE__, 0x566f6c44, "1450142788", "%1.6d", +__LINE__, 0xfffffc10, "fffffc10", "%.2x", +__LINE__, -0x000e04d, "-57421", "%+0d", +__LINE__, 0x00000000, "0000000", "%+.7X", +__LINE__, 0x00b5c74d, " 11913037", "% ld", +__LINE__, -0x028dfe2, "-2678754", "%05.1d", +__LINE__, 0xfffffee0, "fffffee0", "%0x", +__LINE__, -0x030c077, "-3194999", "%-.6d", +__LINE__, 0x00055ca1, "055ca1", "%-.6x", +__LINE__, 0x00000000, " ", "%7.X", +__LINE__, 0xfffffe3b, "FFFFFE3B", "%X", +__LINE__, 0xffffffff, "FFFFFFFF", "% 3X", +__LINE__, 0x00000857, "2135", "%-#1.d", +__LINE__, -0x00546a2, "-345762", "%0.5d", +__LINE__, 0x0000000b, "0xb ", "%-#6x", +__LINE__, 0x00000d2b, "d2b ", "%-4.0x", +__LINE__, 0x0ae02b9e, "AE02B9E", "%X", +__LINE__, 0xfffffa7b, "fffffa7b", "%-2.x", +__LINE__, 0x00000001, "1", "%X", +__LINE__, 0x000006ad, "01709", "%05.5ld", +__LINE__, -0x0000102, "-258", "%-0.ld", +__LINE__, 0x00000000, "0", "%.1X", +__LINE__, -0x01daa95, "-1944213", "%-1ld", +__LINE__, 0x02b99040, "2B99040", "%2.X", +__LINE__, 0x1b3d5621, "1B3D5621", "%X", +__LINE__, 0x0312d16b, "51564907", "%-1.7ld", +__LINE__, 0x000aa76c, " 698220", "% 2d", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, 0xfff8a4ec, "FFF8A4EC", "%-X", +__LINE__, 0xffffe06d, "ffffe06d", "%x", +__LINE__, 0x00000003, "3", "% x", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xd3e244dd, "D3E244DD", "%+5X", +__LINE__, 0x000028b3, " 28b3", "% 5.x", +__LINE__, 0x0001aceb, "109803", "%6d", +__LINE__, 0xfffbc5ca, "0xfffbc5ca", "%-#5x", +__LINE__, 0x00000097, " 151", "% 7ld", +__LINE__, 0x00001fcc, "+8140", "%+d", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, -0x00052a9, "-21161", "%ld", +__LINE__, 0xfffffc76, "FFFFFC76", "%.1X", +__LINE__, -0x2acb012, "-44871698", "%0.1ld", +__LINE__, 0xffffff81, "ffffff81", "%x", +__LINE__, -0x0018394, "-99220", "%-ld", +__LINE__, 0x0000001b, "1B", "%X", +__LINE__, 0x00000033, "51", "%1d", +__LINE__, 0xffec37e5, "FFEC37E5", "%-1X", +__LINE__, -0x000000a, " -10", "%#5.d", +__LINE__, -0x0000412, "-1042", "%ld", +__LINE__, 0x000cd0b1, "cd0b1 ", "%-7.5x", +__LINE__, 0x0b445370, "B445370", "%+2.0X", +__LINE__, 0xfffffff3, "0XFFFFFFF3", "%-#X", +__LINE__, 0xffff9f33, "FFFF9F33", "%5.X", +__LINE__, 0x00010a1e, "10A1E", "%-2X", +__LINE__, -0xede156f, "-249435503", "% 7.1ld", +__LINE__, 0xfc6d63aa, "fc6d63aa", "% .6x", +__LINE__, 0x0000311c, " 12572", "% ld", +__LINE__, 0x00001f8a, "8074", "%00.d", +__LINE__, 0x00000199, "199", "%-X", +__LINE__, 0xfffffc60, "FFFFFC60", "%+3X", +__LINE__, -0x000022c, "-556", "%+0ld", +__LINE__, 0x021d8407, "35488775", "%-#.7ld", +__LINE__, 0x0000020f, "527", "%d", +__LINE__, -0x000064b, "-1611", "%#ld", +__LINE__, -0x0c15aef, "-12671727", "%d", +__LINE__, -0x1f1a6881, "-521824385", "%ld", +__LINE__, 0xffffc115, "ffffc115", "% x", +__LINE__, 0x00000017, " 23", "% #ld", +__LINE__, 0x00000dc1, "DC1 ", "%-4X", +__LINE__, 0x000002ca, "2CA", "%X", +__LINE__, 0x000f052c, " 984364", "%7.d", +__LINE__, 0x0000005a, "0090", "%0.4d", +__LINE__, -0x001e463, "-124003", "% 4.ld", +__LINE__, 0x00000001, "0000001", "%+.7X", +__LINE__, 0x00000bfb, "0000bfb", "%5.7x", +__LINE__, 0x0002484b, "149579", "%#1d", +__LINE__, 0x0043ba18, "4438552", "%-ld", +__LINE__, 0x000078f8, "0X78F8", "%#X", +__LINE__, 0x00000001, " 1", "%4d", +__LINE__, 0x0cedaeed, "CEDAEED", "%X", +__LINE__, 0x00000003, "+3", "%+ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "%7.4X", +__LINE__, 0x00000169, "361", "%ld", +__LINE__, 0x00003c7a, "+15482", "%+ld", +__LINE__, -0x0159d93, "-1416595", "% 0.0d", +__LINE__, 0x0000775c, "+30556", "%+3.d", +__LINE__, 0x10284768, "+271075176", "%+0.0ld", +__LINE__, -0xf8b610e, "-260792590", "%0d", +__LINE__, 0xfdd8d369, "fdd8d369", "%-.3x", +__LINE__, 0x000c9495, "+824469", "%+ld", +__LINE__, -0x000003f, " -063", "%7.3d", +__LINE__, -0x000073b, "-1851", "%+03.ld", +__LINE__, 0xfffe4e23, "0xfffe4e23", "%#.5x", +__LINE__, 0x0081788c, "81788c", "%5x", +__LINE__, -0x015f888, "-1439880", "%+1d", +__LINE__, -0x31d64b4, "-52257972", "%0.2d", +__LINE__, 0xffffffff, "FFFFFFFF", "%6.5X", +__LINE__, -0x0000072, "-114", "%+.1d", +__LINE__, -0x00000e1, "-225", "%ld", +__LINE__, 0x000006a8, "0x6a8", "%+#x", +__LINE__, 0xfffe673a, "fffe673a", "%01.x", +__LINE__, 0xfff2ee0d, "FFF2EE0D", "%-X", +__LINE__, 0x0290320a, "43004426", "%0ld", +__LINE__, -0xeb7a832, "-246917170", "% ld", +__LINE__, 0x02ae9265, "2ae9265", "%1.x", +__LINE__, 0xffffffd2, "ffffffd2", "%+2.x", +__LINE__, 0x00e6e858, "0xe6e858", "%#0.x", +__LINE__, 0x00000c4a, "+3146", "%+3.1d", +__LINE__, -0x6943c1a, "-110378010", "% 0ld", +__LINE__, 0x0167b119, "167b119", "%0x", +__LINE__, 0xfffffffe, "fffffffe", "%+x", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, 0x000b861e, "755230", "%ld", +__LINE__, 0x0000015b, "347", "%-#ld", +__LINE__, 0xfffffffa, "0XFFFFFFFA", "%#X", +__LINE__, 0x000de9e5, "911845", "%d", +__LINE__, 0x00000001, "01", "%.2d", +__LINE__, 0x000007a5, "1957", "%0d", +__LINE__, 0x0000000f, "f", "%x", +__LINE__, 0x00c38cbf, " 12815551", "% .2d", +__LINE__, -0x7bd1b6e, "-129833838", "% d", +__LINE__, -0x000013c, "-316", "%0d", +__LINE__, 0x00001aad, "1AAD", "%-0X", +__LINE__, 0x0034f903, "3471619", "%00d", +__LINE__, 0xff925717, "ff925717", "%4x", +__LINE__, 0x00000002, "02", "%.2d", +__LINE__, 0x00000f34, "F34", "%+X", +__LINE__, 0xffffeefe, "FFFFEEFE", "%X", +__LINE__, 0xfffeecb4, "FFFEECB4", "% 2.X", +__LINE__, 0x00034421, "214049", "%0ld", +__LINE__, 0x00000000, " 0", "%+6X", +__LINE__, -0x0000062, "-98", "%-#2d", +__LINE__, -0x0000557, "-1367", "%-4.4d", +__LINE__, 0xffffe17c, "FFFFE17C", "%X", +__LINE__, 0x00000097, "00097", "%.5X", +__LINE__, 0xfffcb278, "FFFCB278", "%0.7X", +__LINE__, -0x0000001, "-0001 ", "%-7.4d", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x000002c4, "708", "%d", +__LINE__, 0x04946f45, "4946F45", "%-2.X", +__LINE__, 0x000000ff, "00ff", "% 2.4x", +__LINE__, 0x00073307, "471815", "%3ld", +__LINE__, 0x0085b7b6, "+8763318", "%+ld", +__LINE__, -0x0000002, "-2", "%1ld", +__LINE__, -0x0000001, "-1", "%-2d", +__LINE__, -0x00000b5, " -181", "%7ld", +__LINE__, -0x0412486, "-4269190", "%+2.1ld", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, 0x0000006d, "6d", "%x", +__LINE__, 0x000000da, "218", "%-.3ld", +__LINE__, 0xfffffcfe, "fffffcfe", "%x", +__LINE__, 0x652e60c7, "652E60C7", "%7.7X", +__LINE__, 0x00000035, " 53", "% #2d", +__LINE__, 0x000000fc, "FC", "%-X", +__LINE__, 0x00000019, " 25", "% ld", +__LINE__, 0xfffffcf4, "fffffcf4", "%6x", +__LINE__, 0xffffff41, "ffffff41", "%x", +__LINE__, 0x00000034, " 52", "%3.ld", +__LINE__, 0xffffffb2, "ffffffb2", "%-x", +__LINE__, -0x6dc43e7c, "-1841577596", "% .2ld", +__LINE__, 0x00000004, "4", "%d", +__LINE__, -0x000023b, "-571", "%ld", +__LINE__, -0x000004d, "-77", "%ld", +__LINE__, 0x0000e3ba, "58298", "%.0ld", +__LINE__, 0xfffffff2, "fffffff2", "%0.0x", +__LINE__, -0x0000020, "-32", "%ld", +__LINE__, 0xffffb33e, "0XFFFFB33E", "%-#X", +__LINE__, 0x00000000, " ", "% 4.x", +__LINE__, 0xffd96f92, "FFD96F92", "%X", +__LINE__, 0x0000002e, " 46", "% 0ld", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, -0x5008ba3, "-83921827", "%+d", +__LINE__, 0xfdc1df3d, "FDC1DF3D", "%0X", +__LINE__, 0xfc7410e5, "fc7410e5", "%7x", +__LINE__, 0xfffffffa, "FFFFFFFA", "% 6.X", +__LINE__, 0x00000000, "0", "%X", +__LINE__, -0x040fd4e, "-4259150", "% 05.d", +__LINE__, 0x0000003b, " 59", "%3.2d", +__LINE__, 0xff776dd8, "ff776dd8", "%x", +__LINE__, 0x0000055b, "+1371", "%+#2d", +__LINE__, 0x00004841, "4841", "%.1x", +__LINE__, 0x0229d710, "36296464", "%-.2ld", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xfffe8376, "fffe8376", "%0x", +__LINE__, 0x000a7b83, "a7b83", "%x", +__LINE__, 0x0000000d, " 013", "%#7.3d", +__LINE__, 0xffffffff, "FFFFFFFF", "%5.0X", +__LINE__, 0x00000704, " 0x704", "%#7.0x", +__LINE__, 0xfff970b9, "FFF970B9", "%.1X", +__LINE__, -0x000b60a, "-46602", "%+d", +__LINE__, 0x00000000, " 00000", "%6.5x", +__LINE__, 0x00000003, "3", "%X", +__LINE__, 0x0000c14b, "c14b", "%0x", +__LINE__, 0x066d7860, "107837536", "%-d", +__LINE__, 0x00000013, " 13", "%4.x", +__LINE__, 0xfff96f18, "FFF96F18", "%4X", +__LINE__, 0xffffff30, "FFFFFF30", "%X", +__LINE__, 0xffffffff, "FFFFFFFF", "% .7X", +__LINE__, -0x72a9e985, "-1923737989", "%2.d", +__LINE__, 0x00000002, "0x2", "%#x", +__LINE__, 0x0000050e, "50e", "%2.3x", +__LINE__, 0x0000605c, "24668", "%4.1d", +__LINE__, 0xffffff3e, "ffffff3e", "%x", +__LINE__, -0x0000010, "-16", "%-2d", +__LINE__, 0x000061aa, "61AA", "%X", +__LINE__, 0x000c2ec3, "C2EC3", "%0X", +__LINE__, -0x0000001, "-1", "%-0d", +__LINE__, 0x00130e17, "+1248791", "%+.6ld", +__LINE__, 0x000000ef, "EF", "%-X", +__LINE__, -0x0000001, " -1", "%+5ld", +__LINE__, 0x0000989d, "39069", "%d", +__LINE__, 0x00000000, "0", "%-x", +__LINE__, 0x00000417, "417", "%X", +__LINE__, 0x00005e86, "5E86", "%+X", +__LINE__, -0x0007c08, "-31752", "%ld", +__LINE__, 0x00da8e0f, "DA8E0F", "%2.2X", +__LINE__, -0x3ee095ec, "-1054905836", "% 0d", +__LINE__, 0xfffdb5a3, "fffdb5a3", "%x", +__LINE__, 0xffffff83, "FFFFFF83", "%X", +__LINE__, 0xfff8efd7, "0xfff8efd7", "%#x", +__LINE__, 0x00000020, " 32", "% d", +__LINE__, 0xfff7c002, "fff7c002", "%.7x", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x00000000, " 000", "%05.3X", +__LINE__, 0xfff190ee, "FFF190EE", "%X", +__LINE__, 0x00000a6c, " 2668", "%#6.ld", +__LINE__, 0x00037024, "37024", "%x", +__LINE__, 0xfffec37f, "FFFEC37F", "%X", +__LINE__, 0x007ee9bb, "8317371", "%#0.ld", +__LINE__, 0x00000122, "290", "%ld", +__LINE__, -0x0013b5f, "-80735", "%ld", +__LINE__, 0xfffffff6, "FFFFFFF6", "%X", +__LINE__, -0x0000c16, "-0003094", "%-00.7d", +__LINE__, -0x00010ed, "-4333", "%ld", +__LINE__, 0x00000007, " 0X007", "%#6.3X", +__LINE__, 0x0053781e, " 5470238", "% 2d", +__LINE__, 0xffff03e9, "0XFFFF03E9", "%+#7.3X", +__LINE__, 0xfffffdc2, "0xfffffdc2", "% #4.x", +__LINE__, -0x00018e1, "-6369", "%d", +__LINE__, 0xf3a4abc6, "F3A4ABC6", "%-.2X", +__LINE__, 0xfff64a27, "FFF64A27", "%7.7X", +__LINE__, 0x00195ae5, "195AE5", "%+03.X", +__LINE__, 0xfff8849a, "fff8849a", "%.1x", +__LINE__, -0x001b045, "-110661", "%+ld", +__LINE__, 0x01e8a106, "32022790", "%7.ld", +__LINE__, 0x0008ee94, "8EE94", "%X", +__LINE__, 0xfffcdabc, "FFFCDABC", "%X", +__LINE__, 0xfda75cd2, "fda75cd2", "%x", +__LINE__, 0x00fd505a, "fd505a", "%x", +__LINE__, 0x00003748, "3748", "%+x", +__LINE__, 0xffffffe5, "ffffffe5", "% 3.6x", +__LINE__, -0x1d1c4045, "-488390725", "%d", +__LINE__, 0xfffffff9, "0xfffffff9", "%#x", +__LINE__, -0x0000001, "-1", "%-#ld", +__LINE__, 0x00000191, "191", "%X", +__LINE__, 0xfffffffe, "FFFFFFFE", "%-X", +__LINE__, -0x0000006, "-6", "%ld", +__LINE__, 0x00000033, " 33", "% 4x", +__LINE__, -0x0159a14, "-1415700", "% ld", +__LINE__, 0x000001c3, "00001c3", "%07x", +__LINE__, 0xffffe9e2, "ffffe9e2", "%-x", +__LINE__, 0x5b19abd9, "0x5b19abd9", "%-#x", +__LINE__, 0xffff1bae, "0xffff1bae", "%#x", +__LINE__, 0x00000001, "+1", "%+d", +__LINE__, 0x006a23c7, "6A23C7", "%2.X", +__LINE__, 0x000008a4, " 8a4", "% 4.1x", +__LINE__, 0xfffffcd9, "fffffcd9", "%.1x", +__LINE__, 0x0000121b, "121B", "%X", +__LINE__, 0x001231aa, "1192362", "%7.d", +__LINE__, -0x008026d, "-524909", "%4.2d", +__LINE__, 0x192ea594, "422487444", "%ld", +__LINE__, 0x0001a800, "108544", "%0d", +__LINE__, 0x000062f1, "62f1", "%.4x", +__LINE__, 0xff8b39b0, "ff8b39b0", "% x", +__LINE__, 0x00000001, "0x1", "%+#x", +__LINE__, 0x0000144a, "5194", "%ld", +__LINE__, 0x00002599, "9625", "%d", +__LINE__, 0xffa0a2ef, "ffa0a2ef", "%0x", +__LINE__, 0xff6712e1, "FF6712E1", "%0X", +__LINE__, 0x0007ebb3, "519091", "%1ld", +__LINE__, 0x0000000f, "15 ", "%-4.ld", +__LINE__, -0x0000096, "-150", "%2.ld", +__LINE__, 0x0000004f, "4F", "%.2X", +__LINE__, 0xfffffc29, "fffffc29", "%-4.x", +__LINE__, 0x00000019, "19", "%x", +__LINE__, 0x00000c4e, "c4e", "%x", +__LINE__, 0x0000006b, " 0006B", "%6.5X", +__LINE__, 0x00c8d2c6, "c8d2c6", "%.0x", +__LINE__, -0x256fb8de, "-628078814", "%ld", +__LINE__, 0x4f51fcf4, "4F51FCF4", "%+X", +__LINE__, 0x000f000e, "983054", "%1.ld", +__LINE__, 0xfffff03f, "fffff03f", "%x", +__LINE__, 0x0000001d, " 1D", "%05.X", +__LINE__, 0x0072ea14, "72ea14", "%x", +__LINE__, -0xc6098b9, "-207657145", "%-7d", +__LINE__, 0x00000a76, "2678", "%3ld", +__LINE__, 0xfff84db3, "FFF84DB3", "%X", +__LINE__, 0x0fb52870, "fb52870", "%+x", +__LINE__, 0x08bc170a, "0x8bc170a", "%#x", +__LINE__, 0xfffeeb00, "fffeeb00", "%0.5x", +__LINE__, 0x000ece95, "970389", "%d", +__LINE__, 0x00000000, "0", "%0X", +__LINE__, 0x07f98e8a, "7f98e8a", "% x", +__LINE__, 0x000499eb, " 499eb", "% 6.x", +__LINE__, 0xffffffff, "FFFFFFFF", "%-X", +__LINE__, 0x0aa45e86, "178544262", "%#.2d", +__LINE__, 0xff73387d, "FF73387D", "%03.X", +__LINE__, 0xfffffb51, "FFFFFB51", "%.3X", +__LINE__, 0xffffffdc, "ffffffdc", "%6.x", +__LINE__, 0xffffffed, "FFFFFFED", "%-X", +__LINE__, 0x0001c4c2, "1c4c2", "%0.3x", +__LINE__, -0x0000001, "-0000001", "%-#.7d", +__LINE__, 0x00000007, "7", "%0.x", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0xffffd000, "ffffd000", "%4.3x", +__LINE__, 0x00000030, "48", "%2.d", +__LINE__, -0x6c121ce, "-113320398", "%.5ld", +__LINE__, 0x000001ed, "1ED", "% 3.X", +__LINE__, 0xfffff0f3, "FFFFF0F3", "%+.6X", +__LINE__, 0xffffffec, "ffffffec", "%x", +__LINE__, 0x002d5ab8, "0x2d5ab8", "%-#x", +__LINE__, 0x0026acff, "2534655", "%0ld", +__LINE__, 0x01d90cd7, "+31001815", "%+.2ld", +__LINE__, -0x1f7abc0, "-33008576", "%7.6d", +__LINE__, 0xfc5babcc, "fc5babcc", "%x", +__LINE__, -0x9b74892, "-163006610", "% .6d", +__LINE__, 0x03931d84, "59972996", "%0.d", +__LINE__, 0x07d261ce, "131228110", "%#ld", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0x00000002, "2", "%+X", +__LINE__, -0x0000604, "-1540", "%+d", +__LINE__, 0x00000000, " ", "%7.x", +__LINE__, 0x00000001, "1", "%.0X", +__LINE__, -0x0005a8e, "-23182", "% d", +__LINE__, 0x03fb2730, "3fb2730", "%7.x", +__LINE__, 0xffffff03, "ffffff03", "%x", +__LINE__, 0x00000000, " ", "%-#3.d", +__LINE__, 0x04025a4b, "0X4025A4B", "%+#X", +__LINE__, -0x0000001, " -1", "%4.d", +__LINE__, 0xfffe00a3, "FFFE00A3", "%+X", +__LINE__, -0x1b26e3c8, "-455533512", "% ld", +__LINE__, 0x000017e5, "6117", "%d", +__LINE__, -0x0e4f3b6, "-15004598", "%0ld", +__LINE__, 0x00000034, "52", "%ld", +__LINE__, 0x0000024c, " 24C", "%4X", +__LINE__, 0xfffedf65, "FFFEDF65", "%-0X", +__LINE__, -0x000ff1f, "-65311", "%+#d", +__LINE__, 0x00000007, " 7", "%7.x", +__LINE__, 0x018656ae, "18656ae", "%3.7x", +__LINE__, -0x0000004, "-4", "%d", +__LINE__, 0x7081292d, "1887512877", "%d", +__LINE__, 0x87d3e48c, "87d3e48c", "%-x", +__LINE__, 0xf99c516e, "0xf99c516e", "% #7.4x", +__LINE__, 0xfffffffa, "FFFFFFFA", "%-1X", +__LINE__, -0x000001d, "-29", "%#ld", +__LINE__, -0x0000001, "-1", "%+ld", +__LINE__, 0x28ab3350, " 682308432", "% 1d", +__LINE__, -0x0000006, "-6", "%ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "%.5X", +__LINE__, -0x0000007, "-7", "%#d", +__LINE__, -0x0000328, " -808", "%6.ld", +__LINE__, -0x29386f00, "-691564288", "%.3d", +__LINE__, -0x059f38a, "-5895050", "%.4ld", +__LINE__, 0xfffff888, "FFFFF888", "%3X", +__LINE__, 0xffffffdf, "ffffffdf", "%0.0x", +__LINE__, -0xb4fc354, "-189776724", "%2d", +__LINE__, 0x00058c07, "363527", "%1.d", +__LINE__, 0x0a256162, "a256162", "%x", +__LINE__, -0x05c87b0, "-6064048", "%0ld", +__LINE__, 0xfffffda1, "fffffda1", "%x", +__LINE__, 0x000034b7, "13495", "%d", +__LINE__, -0x6d1a8918, "-1830455576", "%.1d", +__LINE__, 0x00022290, "139920", "%05ld", +__LINE__, 0x00000000, "0", "%-x", +__LINE__, -0x1f8eafce, "-529444814", "%4.d", +__LINE__, -0x7bf32808, "-2079533064", "% ld", +__LINE__, 0x0000023c, "23c", "% x", +__LINE__, 0x00000039, "39", "%X", +__LINE__, -0x000556d, "-21869", "%ld", +__LINE__, -0x00000ca, "-202", "%ld", +__LINE__, 0x00002e28, "11816", "%-d", +__LINE__, 0x00000011, "17", "%-ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "%-X", +__LINE__, 0xfffdd67f, "0XFFFDD67F", "%#X", +__LINE__, -0x000003d, "-61", "%d", +__LINE__, 0x0000bfce, "0XBFCE", "%-#5.2X", +__LINE__, 0xfffffffc, "fffffffc", "%x", +__LINE__, -0x00aea17, "-715287", "%.5d", +__LINE__, -0x02fce89, "-3133065", "%0d", +__LINE__, 0x007f6ed1, "7F6ED1", "%6X", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, -0x0002761, "-10081", "%#6.2d", +__LINE__, 0x003be8d8, "3BE8D8", "%-X", +__LINE__, 0x00000901, " 2305", "%6.d", +__LINE__, 0x00049916, "0301334", "%3.7ld", +__LINE__, 0x0678ffea, "0X678FFEA", "%#4X", +__LINE__, 0xffffffff, "ffffffff", "%+.0x", +__LINE__, -0x31d2ec61, "-835906657", "%.0d", +__LINE__, 0xfffffffc, "FFFFFFFC", "%0X", +__LINE__, -0x0015588, "-87432", "%d", +__LINE__, 0xffffff3e, "ffffff3e", "%.4x", +__LINE__, 0x0000000a, "10", "%d", +__LINE__, -0x0000003, "-3", "%2.1ld", +__LINE__, -0x000d29a, "-53914", "%ld", +__LINE__, -0x04ccbe0, "-5032928", "%2.2ld", +__LINE__, 0x0357c2a5, "357c2a5", "% 7.x", +__LINE__, 0x00000009, " 9", "% 1.ld", +__LINE__, -0x005908d, "-364685", "%0d", +__LINE__, -0x0000de6, "-3558", "%0ld", +__LINE__, 0x2d395e6b, "+758734443", "%+6d", +__LINE__, 0x001aba58, "1ABA58", "% X", +__LINE__, 0x0ceba5ab, "0XCEBA5AB", "%#.1X", +__LINE__, -0x01a8575, "-1738101", "% 2ld", +__LINE__, 0x0000000d, "13", "%#ld", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x4b856407, "4b856407", "%5x", +__LINE__, 0x006f333c, "6F333C", "%-X", +__LINE__, 0x000000d0, "d0", "%x", +__LINE__, 0x2ecf0d4e, "2ecf0d4e", "%0x", +__LINE__, -0x0000188, "-0000392", "%#1.7ld", +__LINE__, -0x0000037, "-55", "%d", +__LINE__, 0xfffffff1, "FFFFFFF1", "% .1X", +__LINE__, 0x00000001, "0x1", "%#3x", +__LINE__, 0x000005ed, "5ED", "%3X", +__LINE__, 0x031183a3, "31183A3", "%X", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, -0x0018695, "-99989", "%-0.5ld", +__LINE__, -0x0000001, "-01", "%0.2ld", +__LINE__, 0x00007822, "7822", "%+x", +__LINE__, 0x00000000, "0", "% x", +__LINE__, 0xfda2461a, "FDA2461A", "%X", +__LINE__, 0x065c50ef, "106713327", "%2.ld", +__LINE__, 0x00000a81, "a81", "% 0x", +__LINE__, -0x000022e, "-558", "%.0ld", +__LINE__, 0x00013d2f, "81199", "%.2ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%+X", +__LINE__, 0x000015f9, "5625", "%04.ld", +__LINE__, 0x0ab575a2, "179664290", "%0d", +__LINE__, 0x0024d07f, "0X24D07F", "%#X", +__LINE__, 0x07ee35e1, "7EE35E1", "%+X", +__LINE__, -0x00c114c, "-790860", "%#ld", +__LINE__, 0x00003be3, " 15331", "%07.d", +__LINE__, 0xfff87570, "FFF87570", "%4.0X", +__LINE__, -0x14eab419, "-350925849", "%-ld", +__LINE__, -0x000001b, "-27", "%ld", +__LINE__, 0x167ce2ea, "0x167ce2ea", "%#0.x", +__LINE__, -0x00009bc, "-002492", "% 3.6d", +__LINE__, 0xfffffdb9, "0XFFFFFDB9", "%#7.X", +__LINE__, 0x008b2b9d, "8B2B9D", "% X", +__LINE__, 0x000cfec3, "CFEC3", "% 05X", +__LINE__, 0x05970be6, "5970be6", "%x", +__LINE__, 0x00002780, "010112", "%2.6d", +__LINE__, 0x00000005, "+5", "%+d", +__LINE__, 0xfffffffb, "0xfffffffb", "%#3.x", +__LINE__, 0x00000001, "1 ", "%-#5.ld", +__LINE__, -0x0000017, "-23", "%ld", +__LINE__, -0x023b943, "-2341187", "%d", +__LINE__, 0x0000000d, "13", "%ld", +__LINE__, 0x00025a03, "25a03", "% .5x", +__LINE__, 0x3e1ebe24, "3e1ebe24", "% x", +__LINE__, 0x0000013a, "0x13a", "%#5.0x", +__LINE__, 0xfff6f5b3, "FFF6F5B3", "%4.X", +__LINE__, -0x0000a8a, "-2698", "%.3d", +__LINE__, 0x0009dd5f, "9dd5f", "%x", +__LINE__, 0x000003c7, " 3C7", "%04.2X", +__LINE__, 0x1bcfa2f2, "1bcfa2f2", "%+1.x", +__LINE__, 0x0001b4f4, "1b4f4", "%+1.x", +__LINE__, 0x1bc19a90, "465672848", "%#d", +__LINE__, 0xffffffff, "ffffffff", "%+06x", +__LINE__, -0x0000a88, "-2696", "%3.d", +__LINE__, 0x00084a19, "84A19", "%-X", +__LINE__, 0xffe1fc8f, "FFE1FC8F", "%0.1X", +__LINE__, -0x0000a3a, "-2618", "%5d", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, -0x5c6183d, "-96868413", "%+ld", +__LINE__, -0x0000001, "-1", "%-d", +__LINE__, 0x0000faa8, "64168", "%05.d", +__LINE__, 0x003913ef, "3740655", "%ld", +__LINE__, 0x0dde330a, "232665866", "%#ld", +__LINE__, 0xfcfb1a7b, "FCFB1A7B", "%+X", +__LINE__, 0x07b1a81f, " 129083423", "% 0d", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0x00000070, " 112", "%5ld", +__LINE__, 0xffff74d9, "ffff74d9", "%x", +__LINE__, -0x001ab93, "-109459", "%03.d", +__LINE__, 0x0eb6b497, "EB6B497", "%+X", +__LINE__, 0x07adbac2, "128826050", "%#0.4d", +__LINE__, 0xff747068, "FF747068", "%6.X", +__LINE__, -0x190ce98f, "-420276623", "%06.6ld", +__LINE__, -0x0000007, "-7", "%.0d", +__LINE__, 0x0001240f, "1240f", "% 3x", +__LINE__, 0x267ae4a0, "645588128", "%-#ld", +__LINE__, -0x0000001, "-1", "% ld", +__LINE__, -0x0000066, "-00102", "%.5ld", +__LINE__, 0x868fa035, "868fa035", "%x", +__LINE__, 0x00000000, " ", "%-4.ld", +__LINE__, 0xfffffe72, "FFFFFE72", "%4.4X", +__LINE__, 0x00a6b4f4, "10925300", "%#ld", +__LINE__, -0x0000002, "-2", "%00.1d", +__LINE__, -0x00000a3, "-163", "%ld", +__LINE__, 0xfffffffe, "fffffffe", "% 3.x", +__LINE__, 0xffe25941, "ffe25941", "% x", +__LINE__, 0x0000a20f, "41487", "%ld", +__LINE__, -0x000009b, "-155", "%#.3ld", +__LINE__, 0x000c5dc1, "810433", "%4.ld", +__LINE__, 0x00003ec4, "16068", "%ld", +__LINE__, 0x000002f3, "0755", "%04ld", +__LINE__, 0xffffff28, "FFFFFF28", "%.5X", +__LINE__, -0x08450ff, "-8671487", "%-3.0ld", +__LINE__, 0x00000092, "92", "%x", +__LINE__, -0x0000317, "-791", "%d", +__LINE__, 0x0000000d, "d", "%x", +__LINE__, 0x00000036, "36", "%x", +__LINE__, -0x112693f, "-17983807", "%ld", +__LINE__, 0x00004226, "16934", "%0.d", +__LINE__, 0x000001ba, " 442", "% ld", +__LINE__, 0xfffffffc, "0XFFFFFFFC", "%#4X", +__LINE__, 0xffdb3d23, "0xffdb3d23", "% #x", +__LINE__, 0x039eb84d, "39EB84D", "%+.6X", +__LINE__, 0xffffc7da, "ffffc7da", "%0x", +__LINE__, 0xfffffdb6, "FFFFFDB6", "%6X", +__LINE__, 0x001b75b0, "1799600", "%ld", +__LINE__, 0xfffffca2, "FFFFFCA2", "%-X", +__LINE__, 0xffffffba, "ffffffba", "%7.4x", +__LINE__, -0x000124e, "-4686", "%3.ld", +__LINE__, -0x000bec0, "-48832", "% 0d", +__LINE__, 0xfffffca0, "fffffca0", "%2.x", +__LINE__, 0x00b2a462, "11707490", "%ld", +__LINE__, 0x0745a647, "745a647", "%+4.x", +__LINE__, 0xfffffbac, "0XFFFFFBAC", "%#3.X", +__LINE__, -0x0000002, "-2", "%-0.1d", +__LINE__, 0x0006cfdb, "446427", "%#5.d", +__LINE__, -0x0000001, "-1", "%d", +__LINE__, 0x043b134e, "43B134E", "%X", +__LINE__, -0x0000015, "-21", "%ld", +__LINE__, -0x0000114, "-276", "%0d", +__LINE__, -0x0004d4a, "-19786", "%-d", +__LINE__, -0x000001c, "-28", "%ld", +__LINE__, -0x0cb89fc, "-13339132", "%ld", +__LINE__, 0xffffffcf, "ffffffcf", "%x", +__LINE__, 0xf6d2387a, "f6d2387a", "%-x", +__LINE__, -0x00000cd, "-205", "%#ld", +__LINE__, 0x00000000, "0", "%#x", +__LINE__, 0xfffffc81, "fffffc81", "%x", +__LINE__, 0x00000000, " 0", "% ld", +__LINE__, 0x00024fb5, "24fb5", "%x", +__LINE__, 0x000012fa, "12FA", "%X", +__LINE__, 0x0318ce7c, "51957372", "%0d", +__LINE__, 0x02280a99, "2280a99", "%-x", +__LINE__, 0xffffff5c, "FFFFFF5C", "%2.X", +__LINE__, -0x000002e, " -46", "%7ld", +__LINE__, -0x04a73e8, "-4879336", "%4ld", +__LINE__, 0x000007f3, "7f3", "% 1.3x", +__LINE__, 0x00000114, "0x114", "%#x", +__LINE__, 0x0000030c, "30c", "%-x", +__LINE__, 0x001dd0dd, "0x1dd0dd", "%+#5.5x", +__LINE__, 0xfff23de3, "fff23de3", "%-x", +__LINE__, -0x0178f9c, "-1544092", "%d", +__LINE__, 0x02ded8da, "2DED8DA", "%X", +__LINE__, -0x0991672, "-10032754", "%3.d", +__LINE__, 0x6943c150, "6943c150", "%x", +__LINE__, 0xffffc25d, "FFFFC25D", "%4X", +__LINE__, 0x00000c9c, " 0003228", "% .7d", +__LINE__, 0xffffffdf, "FFFFFFDF", "% 6.X", +__LINE__, 0x0001a145, " 1a145", "%6.0x", +__LINE__, 0xffdc832f, "0xffdc832f", "%#.1x", +__LINE__, 0x00699f7b, "699f7b", "%x", +__LINE__, 0xf9575268, "F9575268", "%+0X", +__LINE__, 0x04eb4783, "82528131", "%-ld", +__LINE__, -0x0000023, "-35", "%0ld", +__LINE__, -0x012b08a, "-1224842", "%0d", +__LINE__, 0xffffb587, "FFFFB587", "%X", +__LINE__, 0xffffffe9, "ffffffe9", "%x", +__LINE__, 0x006b5596, " 7034262", "% 0d", +__LINE__, 0x004d0d2a, "+5049642", "%+ld", +__LINE__, -0x002a099, "-172185", "%d", +__LINE__, 0x00000224, "548", "%ld", +__LINE__, 0x03e0cca8, "65064104", "%d", +__LINE__, -0x7bb389d, "-129710237", "%.3ld", +__LINE__, 0xffc630f5, "ffc630f5", "%-07.0x", +__LINE__, 0xfffffff8, "FFFFFFF8", "%X", +__LINE__, 0x0030225b, "3154523", "%#d", +__LINE__, 0xff7f4e28, "ff7f4e28", "%+4.x", +__LINE__, 0x14ee154d, "+351147341", "%+ld", +__LINE__, 0x00000003, "03", "%.2d", +__LINE__, 0xfe0359d6, "fe0359d6", "%x", +__LINE__, 0x002b71c3, "2847171", "%d", +__LINE__, 0x055c4d4a, "55C4D4A", "%-X", +__LINE__, 0xfffb17d2, "fffb17d2", "% .0x", +__LINE__, 0x00000002, "2", "%x", +__LINE__, 0x000018e1, "18E1", "%1.1X", +__LINE__, 0x00000331, "817", "%0d", +__LINE__, -0x0000982, "-2434 ", "%-06.ld", +__LINE__, -0x0000168, "-0000360", "%.7ld", +__LINE__, 0xffffffe9, "FFFFFFE9", "%-0.4X", +__LINE__, 0xe42084ef, "E42084EF", "%X", +__LINE__, 0x000000aa, "aa", "%x", +__LINE__, -0xe8b98b5, "-244029621", "%+d", +__LINE__, -0x00000d9, "-217", "%+2.d", +__LINE__, 0x0000027b, "27B", "%+.0X", +__LINE__, 0x002e52db, "3035867", "%-ld", +__LINE__, -0x00e2ba8, "-928680", "%0.2ld", +__LINE__, 0x003b74d8, "3B74D8", "%X", +__LINE__, -0x000006f, "-111", "%+ld", +__LINE__, 0xf8507e22, "0XF8507E22", "%-#X", +__LINE__, 0x0629f4c0, "103412928", "%-ld", +__LINE__, -0x000002d, "-45", "%0d", +__LINE__, -0x0001db0, "-7600", "%d", +__LINE__, -0x00001bb, " -443", "%5.ld", +__LINE__, 0xffffd2b9, "ffffd2b9", "%+x", +__LINE__, 0xffffe685, "0XFFFFE685", "%#0.7X", +__LINE__, 0x0000a4ce, "A4CE", "% X", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, 0x0000000c, "C", "% X", +__LINE__, 0xfff59369, "FFF59369", "%7X", +__LINE__, 0x00000156, " 156", "%5.X", +__LINE__, 0x02833aa9, "+42154665", "%+2d", +__LINE__, 0x0004a8f3, "+305395", "%+d", +__LINE__, 0x01a09267, "1A09267", "%0.3X", +__LINE__, 0x000004f1, "4f1", "%x", +__LINE__, 0x00000005, "5", "%x", +__LINE__, 0x00000119, " 0281", "% #2.4ld", +__LINE__, -0x0001a2a, "-6698", "%ld", +__LINE__, 0xa3633a57, "A3633A57", "%7X", +__LINE__, -0x10bd2970, "-280832368", "%-d", +__LINE__, 0xffff9c38, "ffff9c38", "%x", +__LINE__, 0xffdbe81e, "ffdbe81e", "%+6.7x", +__LINE__, 0xffffffe7, "FFFFFFE7", "%-3.0X", +__LINE__, 0x0002f6d6, "2f6d6", "%5.x", +__LINE__, 0xffffffff, "ffffffff", "% x", +__LINE__, 0xffc2c07a, "ffc2c07a", "%0.x", +__LINE__, 0xfcc0e13a, "FCC0E13A", "%X", +__LINE__, 0x0000000d, "d", "% x", +__LINE__, 0x0016cac8, "16CAC8", "%-0.3X", +__LINE__, 0x00945dc1, "9723329", "%2d", +__LINE__, 0xf19a1cd1, "F19A1CD1", "%-X", +__LINE__, 0x00000003, "+3", "%+ld", +__LINE__, 0x00000773, "1907", "%ld", +__LINE__, 0x000263e6, "263e6", "%-x", +__LINE__, -0x0238b55, "-2329429", "%d", +__LINE__, 0x00006c56, "6C56", "%X", +__LINE__, 0x0000f34b, "62283", "%#.0ld", +__LINE__, -0x1620e21, "-23203361", "%0ld", +__LINE__, 0xf9257d6a, "f9257d6a", "%2x", +__LINE__, -0x00ed463, "-971875", "%03.d", +__LINE__, 0x02bb94c6, "45847750", "%d", +__LINE__, 0xffffd20c, "0XFFFFD20C", "%#X", +__LINE__, 0x000087d8, "34776", "%.0d", +__LINE__, 0xfffffffc, "FFFFFFFC", "%+7.X", +__LINE__, -0x0009cd5, "-40149", "%-ld", +__LINE__, 0xfffff85e, "FFFFF85E", "% 0.7X", +__LINE__, -0x0000006, " -6", "%+#6.ld", +__LINE__, 0x007ff453, "0x7ff453", "%-#1.x", +__LINE__, 0xffffffe6, "FFFFFFE6", "%2X", +__LINE__, 0x0000001f, "0X1F", "%#4X", +__LINE__, -0x001c157, "-115031", "%.3ld", +__LINE__, 0x00096e06, "617990", "%3.1ld", +__LINE__, 0x0f77271d, "259467037", "%d", +__LINE__, -0x0001403, "-5123", "%d", +__LINE__, 0xffffff8a, "ffffff8a", "%x", +__LINE__, -0x000010f, "-271", "%1.ld", +__LINE__, 0xe573cc4a, "E573CC4A", "%0X", +__LINE__, -0x0000d88, "-3464", "%-d", +__LINE__, 0x0000000e, "14", "%#ld", +__LINE__, -0x000345b, "-13403", "%#d", +__LINE__, 0x00000602, "602", "%+x", +__LINE__, 0x00000011, "17", "%#d", +__LINE__, -0x0000002, "-2", "%+d", +__LINE__, 0x030fe6e6, "51373798", "%d", +__LINE__, 0x00000007, "007", "%.3X", +__LINE__, 0x0001abe0, "0X1ABE0", "%+#.4X", +__LINE__, 0xfffffdb7, "fffffdb7", "%-6x", +__LINE__, 0xffffff8d, "FFFFFF8D", "% 02.2X", +__LINE__, 0xfff12126, "FFF12126", "%X", +__LINE__, 0x0208e32d, "34136877", "%.2d", +__LINE__, 0x11c04b55, "297814869", "%ld", +__LINE__, 0xff1e5ca3, "0xff1e5ca3", "%#x", +__LINE__, 0xf9643f09, "f9643f09", "%x", +__LINE__, -0x003c6da, "-247514", "%4d", +__LINE__, 0xff69d0e7, "FF69D0E7", "%-X", +__LINE__, 0x00006ae9, "0x6ae9", "%#x", +__LINE__, -0x005aefe, "-372478", "%d", +__LINE__, 0x0000000d, "00013", "%3.5ld", +__LINE__, 0x00cc185c, "CC185C", "%X", +__LINE__, 0x3dd14d9f, "3DD14D9F", "%1.4X", +__LINE__, -0x4cc2ad3, "-80489171", "%1.d", +__LINE__, 0xfffff79e, "fffff79e", "%x", +__LINE__, 0xfffeeb03, "fffeeb03", "%-1x", +__LINE__, -0x0b1b15c, "-11645276", "%0ld", +__LINE__, -0x06b558d, "-7034253", "%ld", +__LINE__, 0xfffffe61, "fffffe61", "%x", +__LINE__, -0x0000002, "-2", "%d", +__LINE__, -0x0000162, "-000354", "%-5.6d", +__LINE__, 0x01a23780, "27408256", "%d", +__LINE__, 0xffff3a9b, "ffff3a9b", "% x", +__LINE__, 0xfffffdc7, "0xfffffdc7", "%#4.5x", +__LINE__, 0x00000000, "00", "%.2X", +__LINE__, -0x0000006, "-6", "%0ld", +__LINE__, -0x16072c6, "-23098054", "%#5ld", +__LINE__, -0x07152b8, "-7426744", "%01ld", +__LINE__, 0x0000d6c6, "0x0d6c6", "%#1.5x", +__LINE__, 0x00000f7c, "000f7c", "%+04.6x", +__LINE__, 0x00000bd0, "3024", "%4ld", +__LINE__, 0x0000295e, "0x295e", "%#x", +__LINE__, 0x00002e38, "11832", "%.5d", +__LINE__, -0xa2f5de4, "-170876388", "%#d", +__LINE__, -0x001aa36, "-109110", "%-#d", +__LINE__, 0x03012091, "3012091", "%+2.5X", +__LINE__, -0x00009ed, "-002541", "%-0.6ld", +__LINE__, 0x0000001d, "1d", "%x", +__LINE__, 0xffffe315, "FFFFE315", "%+4X", +__LINE__, 0x0000716b, "716B", "%X", +__LINE__, 0xfffb8315, "0xfffb8315", "%+#x", +__LINE__, 0x00000132, "132 ", "%-7.3x", +__LINE__, 0x00000000, "+0000000", "%+1.7d", +__LINE__, 0xe16d27ab, "E16D27AB", "%X", +__LINE__, 0xffffffe5, "ffffffe5", "%+x", +__LINE__, -0x000ab9d, "-43933", "%ld", +__LINE__, 0xffd042d6, "ffd042d6", "%2x", +__LINE__, 0xffffff9b, "ffffff9b", "%x", +__LINE__, 0x000000fb, "0xfb", "% #1.x", +__LINE__, 0x0000000f, " 15", "%#3ld", +__LINE__, 0xfffba2d8, "0XFFFBA2D8", "%-#0.X", +__LINE__, 0xfffffff8, "0XFFFFFFF8", "% #X", +__LINE__, 0x00000000, " ", "%4.ld", +__LINE__, 0x00000002, "2", "%+x", +__LINE__, 0xfffff314, "FFFFF314", "%-X", +__LINE__, 0x00000000, " 0", "% ld", +__LINE__, -0x0000007, "-07", "%3.2ld", +__LINE__, 0xffffdd80, "FFFFDD80", "%.6X", +__LINE__, -0x000001b, "-27", "%-ld", +__LINE__, -0x0000258, "-600", "%-0d", +__LINE__, 0x00016377, "16377", "%3X", +__LINE__, 0x00000001, "1", "%X", +__LINE__, -0xac5d314, "-180736788", "%d", +__LINE__, -0x000036e, "-878", "% ld", +__LINE__, 0xfe346af4, "fe346af4", "%.5x", +__LINE__, 0xffffffe1, "ffffffe1", "%-7.6x", +__LINE__, -0x0a1df07, "-10608391", "%#.5d", +__LINE__, 0x000000c9, " 0XC9", "%+#5.X", +__LINE__, 0xfffffffe, "fffffffe", "%x", +__LINE__, 0xfffffff8, "fffffff8", "%+x", +__LINE__, -0x4517255, "-72446549", "%.6ld", +__LINE__, 0xfffa3670, "FFFA3670", "%-6X", +__LINE__, 0xffffffe0, "ffffffe0", "%2.x", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, 0x0000230d, "8973", "%#.1d", +__LINE__, 0x00000238, "238", "%0X", +__LINE__, 0xfffce5ab, "FFFCE5AB", "%-X", +__LINE__, 0x0000002c, "2C", "%X", +__LINE__, 0x00000001, " 1", "%4.ld", +__LINE__, 0xffffff8d, "FFFFFF8D", "%-X", +__LINE__, 0x00069c69, "433257", "%06d", +__LINE__, 0xfffffb8d, "0xfffffb8d", "%#x", +__LINE__, 0x000d6a2d, "879149", "%5.5d", +__LINE__, -0x0001fcb, " -8139", "%7.ld", +__LINE__, 0xfff86937, "fff86937", "%-0x", +__LINE__, 0x00059cf9, "367865", "%#.0ld", +__LINE__, 0x02c5d87a, "46520442", "%3.ld", +__LINE__, 0x00000571, "1393", "%ld", +__LINE__, 0x0003c73f, "+247615", "%+4ld", +__LINE__, 0x0000004f, "4f", "% 0x", +__LINE__, 0x00000000, "0", "%-ld", +__LINE__, -0x0e5850f, "-15041807", "% ld", +__LINE__, -0x0000002, " -0002", "%7.4d", +__LINE__, 0xfffffd1b, "fffffd1b", "%05x", +__LINE__, 0x0000041c, " 1052", "% #0.ld", +__LINE__, -0x0000030, "-48", "%d", +__LINE__, -0x0013593, "-79251", "% #d", +__LINE__, 0x00000001, "1", "%+X", +__LINE__, 0x0000056b, " 56b", "%4.x", +__LINE__, -0x0000004, "-4 ", "%-3d", +__LINE__, -0x0000003, "-3", "% ld", +__LINE__, 0xffff7c14, "0XFFFF7C14", "%#X", +__LINE__, 0x02f63dd8, "49692120", "%.7ld", +__LINE__, -0x03c51c9, "-3953097", "%+d", +__LINE__, 0x00ded685, "14603909", "%5.ld", +__LINE__, 0xffffffba, "ffffffba", "%x", +__LINE__, 0x000370e8, "225512", "%#ld", +__LINE__, 0x00000003, "3", "%X", +__LINE__, -0x0024a64, "-150116", "%7.d", +__LINE__, 0xff486ca1, "ff486ca1", "%x", +__LINE__, 0x000001cf, "1CF", "% X", +__LINE__, -0x0002d7e, "-11646", "%-0d", +__LINE__, 0x0a594c65, "a594c65", "%.4x", +__LINE__, -0x0000002, "-0002", "%-5.4ld", +__LINE__, 0x00000000, "", "%00.ld", +__LINE__, 0x00058bc4, "58BC4", "%3X", +__LINE__, 0x0002cf8e, " 184206", "% 0ld", +__LINE__, 0x000009c7, "+2503", "%+4.ld", +__LINE__, 0xed0c984d, "ED0C984D", "%X", +__LINE__, -0x0000058, "-088", "%#.3ld", +__LINE__, 0x0076083d, "0X76083D", "%#6X", +__LINE__, -0x0000001, "-1", "%#d", +__LINE__, -0x6bf1777, "-113186679", "%#ld", +__LINE__, -0x000011f, "-287", "%ld", +__LINE__, 0x001b0e7d, "1B0E7D", "%-4X", +__LINE__, 0x000007ac, " 1964", "%5.ld", +__LINE__, 0x00000005, "5", "%0.d", +__LINE__, -0x00003ba, "-954", "%4.0ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, 0x00000019, "19", "%x", +__LINE__, 0xffffffe0, "ffffffe0", "%-.6x", +__LINE__, 0x0000012a, " 298", "% d", +__LINE__, 0x00002c74, "2c74", "% 4.3x", +__LINE__, 0x000002d5, "725", "%d", +__LINE__, 0x0001c9a9, "1c9a9", "%-02x", +__LINE__, 0xffc928c8, "ffc928c8", "%x", +__LINE__, -0x03ae51f, "-3859743", "% #ld", +__LINE__, 0x0000526d, "526d", "%x", +__LINE__, -0x00028f0, "-10480", "%5ld", +__LINE__, -0x49b4262, "-77283938", "%+02.0d", +__LINE__, 0x028d37f0, "0x28d37f0", "%+#x", +__LINE__, 0xd66e0af9, "D66E0AF9", "%03.X", +__LINE__, -0x00c7707, "-816903", "%0d", +__LINE__, -0x00000d0, "-208", "%-.1ld", +__LINE__, 0x0000c328, "49960", "%d", +__LINE__, 0x34cb86f1, "34CB86F1", "%X", +__LINE__, 0x000000f6, "F6", "%+X", +__LINE__, 0x0a3407ec, "0xa3407ec", "%-#x", +__LINE__, 0x00007ebc, "32444", "%#3.d", +__LINE__, 0xfffd3d65, "fffd3d65", "%x", +__LINE__, 0x0007bc82, "0507010", "%0.7d", +__LINE__, 0x0005bb93, "375699", "%ld", +__LINE__, 0x0ec11cc8, "0XEC11CC8", "%+#6.2X", +__LINE__, 0xfffff9c6, "fffff9c6", "%.5x", +__LINE__, 0xff05ab70, "0XFF05AB70", "%-#.3X", +__LINE__, 0x2328b716, "589870870", "%d", +__LINE__, 0x00001a79, "6777", "%.1d", +__LINE__, 0xfffee573, "fffee573", "%0.1x", +__LINE__, -0x0000929, " -2345", "%7.d", +__LINE__, 0xffffff9a, "FFFFFF9A", "%2.X", +__LINE__, 0xfffffe60, "fffffe60", "%.5x", +__LINE__, 0xfffffcd2, "fffffcd2", "%.7x", +__LINE__, 0x00000001, " 001", "%6.3X", +__LINE__, 0x00011e9c, "+73372", "%+0ld", +__LINE__, 0x0000002a, "2a", "% x", +__LINE__, 0xffffffff, "ffffffff", "%.7x", +__LINE__, -0x0008ee8, "-36584", "%ld", +__LINE__, 0x0000001c, "28", "%-d", +__LINE__, 0x000abeda, "704218", "%d", +__LINE__, 0x001347f7, "1347f7", "%3.0x", +__LINE__, 0x0000023e, "574", "%3.3ld", +__LINE__, 0x00000000, "0", "%-ld", +__LINE__, -0x0016de0, "-93664", "%0ld", +__LINE__, 0xffffff45, "FFFFFF45", "% X", +__LINE__, 0x02dfb08c, "48214156", "%#ld", +__LINE__, 0x003d73a2, "3d73a2", "%6.x", +__LINE__, 0x00147da7, "1342887", "%#d", +__LINE__, -0x5ff0f1e, "-100601630", "%-01ld", +__LINE__, -0x000000b, "-11", "%ld", +__LINE__, 0x00000168, " 168", "%+6.x", +__LINE__, 0xffffc28e, "ffffc28e", "%0x", +__LINE__, -0x00003a2, "-930", "%ld", +__LINE__, 0x0002e56f, " 189807", "% 1.ld", +__LINE__, 0x51abf44f, "0x51abf44f", "%#.7x", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x9581268f, "9581268F", "%+X", +__LINE__, 0xffffff3b, "FFFFFF3B", "%X", +__LINE__, 0x000083d4, " 33748", "% #d", +__LINE__, 0x00000001, "1", "%x", +__LINE__, -0x000e51f, "-58655", "%.0ld", +__LINE__, 0x0003eacb, "256715", "%6ld", +__LINE__, 0x02be09db, " 46008795", "% 0.ld", +__LINE__, 0xfffffffb, "FFFFFFFB", "% X", +__LINE__, 0x000084f5, " 34037", "%6ld", +__LINE__, -0x1127f99, "-17989529", "%#d", +__LINE__, 0x5f6512de, "5f6512de", "%.7x", +__LINE__, 0x00000001, "1", "%x", +__LINE__, 0xfff74ab5, "fff74ab5", "%x", +__LINE__, 0x0eebeb94, "250342292", "%4.ld", +__LINE__, 0x0001b846, "0x1b846", "%#1x", +__LINE__, 0x001e8c32, "1E8C32", "%2X", +__LINE__, -0x0dae932, "-14346546", "%5.1d", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, -0x0000042, "-66", "%ld", +__LINE__, 0xffffff51, "FFFFFF51", "%0.1X", +__LINE__, 0x00000043, "43", "%x", +__LINE__, 0x04c21f39, " 79830841", "% 0ld", +__LINE__, 0x0000061e, "1566", "%03.3d", +__LINE__, -0x0000003, "-3", "%+d", +__LINE__, 0x015b32db, " 22754011", "% .4d", +__LINE__, 0xfffff181, "FFFFF181", "%-X", +__LINE__, 0x000017ec, "0X17EC", "%#X", +__LINE__, 0x000d703e, "880702", "%#ld", +__LINE__, -0x6d7533a0, "-1836397472", "%ld", +__LINE__, 0x0000008a, " 138", "% d", +__LINE__, -0x7368794b, "-1936226635", "%+#d", +__LINE__, 0x0000000d, "0XD", "%#X", +__LINE__, 0x0000030d, "30D", "% X", +__LINE__, 0xfffff9fe, "FFFFF9FE", "%5X", +__LINE__, 0x00001bb2, "7090", "%d", +__LINE__, 0x041d2a0c, "41D2A0C", "%0X", +__LINE__, 0x00012aee, " 76526", "% d", +__LINE__, 0x0000055f, "55f", "%.1x", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#1X", +__LINE__, 0x07b0a971, "+129018225", "%+.2ld", +__LINE__, 0xfffffff8, "FFFFFFF8", "%4X", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0x00000038, "+56", "%+2ld", +__LINE__, 0xfffffc2f, "fffffc2f", "%+7.x", +__LINE__, 0x00004477, "0x4477", "% #x", +__LINE__, 0x0000000d, "0XD", "%+#3X", +__LINE__, 0xf5bf37b1, "F5BF37B1", "%1.X", +__LINE__, 0x1a96f431, "446100529", "%d", +__LINE__, 0x0037edf3, "+3665395", "%+#4.5ld", +__LINE__, 0x0007f2aa, "520874", "%0ld", +__LINE__, -0x00051a3, "-20899", "%+#1.ld", +__LINE__, 0x0000037f, "37F", "%0X", +__LINE__, 0xffffffb4, "ffffffb4", "%x", +__LINE__, -0xd984c00, "-228084736", "%+06ld", +__LINE__, 0xffffe1be, "FFFFE1BE", "%X", +__LINE__, 0xfff20d48, "FFF20D48", "%+6.0X", +__LINE__, 0x000028b7, "0x028b7", "%-#7.5x", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, 0x03f37945, "66287941", "%d", +__LINE__, 0xffffffed, "0XFFFFFFED", "%+#6.4X", +__LINE__, 0x0000f046, "f046", "%x", +__LINE__, 0xe9772b51, "E9772B51", "%-1.X", +__LINE__, 0xfffffffe, "fffffffe", "% x", +__LINE__, 0xfffffffa, "0xfffffffa", "%#x", +__LINE__, 0x00000015, "15", "%-X", +__LINE__, 0x0000003c, "60", "%#ld", +__LINE__, 0x3103952d, "822318381", "%0.ld", +__LINE__, 0x17ba68bb, "398092475", "%2d", +__LINE__, 0x000006c4, "+1732", "%+.2d", +__LINE__, 0x00000043, "67", "%#d", +__LINE__, 0x0043fb55, "4455253", "%.1ld", +__LINE__, 0x00004b76, "4b76", "% 0x", +__LINE__, 0xfff4c56b, "FFF4C56B", "%7X", +__LINE__, 0x00766055, "766055", "%+5x", +__LINE__, -0x000009f, "-159", "%+d", +__LINE__, 0xffff063f, "ffff063f", "%-2x", +__LINE__, 0x00808fc8, "808fc8", "%x", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, 0x000000f1, "00000f1", "%+02.7x", +__LINE__, 0x00000002, "2", "%X", +__LINE__, 0x00000000, "000", "%03d", +__LINE__, 0xe63f73b2, "E63F73B2", "% 1X", +__LINE__, 0xfffffffe, "FFFFFFFE", "%5.1X", +__LINE__, 0x0d3fa38b, "222274443", "%1d", +__LINE__, 0x00000000, "0", "% X", +__LINE__, 0x00000001, " 1", "%04.ld", +__LINE__, 0x00000046, "46", "%0X", +__LINE__, 0x0000761f, " 30239", "% ld", +__LINE__, -0x0002517, "-9495", "%+d", +__LINE__, 0x00000156, "156", "% 0x", +__LINE__, 0x1c55eba2, "1c55eba2", "%.6x", +__LINE__, 0x005af80d, "5af80d", "%.6x", +__LINE__, 0x0000002e, "46", "%d", +__LINE__, -0x0007c0f, "-31759", "%ld", +__LINE__, 0xffffe924, "FFFFE924", "%7X", +__LINE__, 0x00000174, "372", "%ld", +__LINE__, 0xffffffc9, "0xffffffc9", "%-#x", +__LINE__, 0x00000020, "+000032", "%+07d", +__LINE__, 0xffffe5d9, "FFFFE5D9", "%4.5X", +__LINE__, 0xffffffa3, "FFFFFFA3", "%+.3X", +__LINE__, 0x00000a03, "+2563", "%+2d", +__LINE__, 0x001b58ca, "+1792202", "%+4d", +__LINE__, 0xffffffc9, "0xffffffc9", "%+#5x", +__LINE__, -0x0000003, "-3", "% d", +__LINE__, 0xfffffffc, "fffffffc", "%+0x", +__LINE__, -0x0000002, "-02", "%.2d", +__LINE__, 0x000243fb, "148475", "%-ld", +__LINE__, 0x00000001, "1", "%0d", +__LINE__, -0x0000672, "-1650", "%ld", +__LINE__, -0x0005413, "-0021523", "% 7.7d", +__LINE__, 0x00000017, "0X17", "%#X", +__LINE__, 0x00000e48, "3656", "%0d", +__LINE__, 0xffe79b38, "ffe79b38", "%-x", +__LINE__, 0xffffff15, "FFFFFF15", "%+6.1X", +__LINE__, 0xfff0272c, "fff0272c", "%-.5x", +__LINE__, -0x00b706f, "-749679", "%1.ld", +__LINE__, 0x0176aeec, "176AEEC", "%.1X", +__LINE__, -0x00005a1, "-1441", "% 0ld", +__LINE__, -0x0000002, "-00002", "%.5d", +__LINE__, -0xd2e6f5d, "-221146973", "%1ld", +__LINE__, -0x0000001, " -001", "%5.3ld", +__LINE__, 0x00000001, " 1", "%05.ld", +__LINE__, 0x0000749e, "+29854", "%+#d", +__LINE__, 0x00000005, "5", "%d", +__LINE__, 0xfa7128b0, "fa7128b0", "%1.x", +__LINE__, 0xffffbbb4, "0XFFFFBBB4", "%#.1X", +__LINE__, 0x0006862f, "427567", "%d", +__LINE__, 0x00000002, "2", "%X", +__LINE__, 0x000005d4, "5d4", "% x", +__LINE__, 0x001387e1, "1279969", "%-05.0ld", +__LINE__, -0x0035a56, "-219734", "%ld", +__LINE__, -0x4064ecc6, "-1080356038", "%ld", +__LINE__, 0x0000360d, "13837", "%0ld", +__LINE__, -0xea1a85b, "-245475419", "%-.2ld", +__LINE__, 0xffffff2d, "FFFFFF2D", "%X", +__LINE__, 0x00000004, " 0004", "%7.4x", +__LINE__, 0x00f72ffd, "F72FFD", "%-X", +__LINE__, 0x00000fa2, "fa2 ", "%-5x", +__LINE__, 0x05ae1f9a, "95297434", "%#ld", +__LINE__, 0x0000bf2e, "48942", "%3.d", +__LINE__, 0x00000000, " ", "%1.X", +__LINE__, 0x01bcb097, "29143191", "%ld", +__LINE__, 0x0000009c, "156 ", "%-4.0d", +__LINE__, 0xfffffffe, "fffffffe", "% x", +__LINE__, 0x00000001, "1 ", "%-6.d", +__LINE__, 0xffffffef, "ffffffef", "%7.x", +__LINE__, 0xfffffec1, "fffffec1", "%.5x", +__LINE__, -0x000000f, "-15", "%-1d", +__LINE__, -0x0008426, "-33830", "%0ld", +__LINE__, 0x005be0ae, "5BE0AE", "% X", +__LINE__, 0x00000009, " 9", "%+7X", +__LINE__, -0x0007e18, "-32280", "%+0.d", +__LINE__, 0x01697ba1, " 23690145", "% 5.ld", +__LINE__, -0x0012042, "-073794", "%7.6d", +__LINE__, 0x04e9bd0d, "4e9bd0d", "%-2x", +__LINE__, 0xffffffd9, "FFFFFFD9", "%.2X", +__LINE__, -0x01b9632, "-1807922", "%.6ld", +__LINE__, 0x000000cd, "205", "%1.ld", +__LINE__, 0x00000000, " ", "% .0d", +__LINE__, 0xff17bbb1, "ff17bbb1", "%x", +__LINE__, -0x00146d7, "-83671", "%+1.ld", +__LINE__, 0xfffff144, "fffff144", "%x", +__LINE__, 0x000f8dbe, "F8DBE", "%3.X", +__LINE__, -0x000381c, "-14364", "%d", +__LINE__, 0x0000001e, " 30", "%4.1d", +__LINE__, 0x00000016, "22", "%-0d", +__LINE__, 0x00000002, "+02", "%+1.2ld", +__LINE__, 0x0000e803, "59395", "%d", +__LINE__, 0xb4c2448d, "b4c2448d", "%-7x", +__LINE__, 0x000e697d, "944509", "%ld", +__LINE__, 0xfffe6e32, "0XFFFE6E32", "%#X", +__LINE__, 0x00000190, " 190", "%+5.X", +__LINE__, -0x03a2219, "-3809817", "%#6.ld", +__LINE__, -0x000003c, "-60 ", "%-#4.ld", +__LINE__, 0x00000000, " ", "% 03.ld", +__LINE__, -0x074f922, "-7665954", "%ld", +__LINE__, -0x00000f0, "-240", "%-ld", +__LINE__, 0xfffe42d2, "0XFFFE42D2", "%#X", +__LINE__, 0x000000dd, "DD", "%X", +__LINE__, 0x00359abe, "359ABE", "%.1X", +__LINE__, 0xffec7bdf, "FFEC7BDF", "%0.1X", +__LINE__, 0x0ecddcba, "248372410", "%-#3.d", +__LINE__, 0x00ad0dbc, "11341244", "%ld", +__LINE__, -0x0000001, "-1", "%-d", +__LINE__, 0x00050841, "50841", "% .5x", +__LINE__, 0x01d359e7, "1d359e7", "%1.x", +__LINE__, 0xff9efaa3, "FF9EFAA3", "%X", +__LINE__, 0x0007ea10, "+518672", "%+ld", +__LINE__, -0x000671c, "-26396", "%1d", +__LINE__, 0xffffff91, "0xffffff91", "%#4.4x", +__LINE__, 0x00000000, "+", "%+0.0ld", +__LINE__, -0x002c53e, "-181566", "%3.d", +__LINE__, 0xffffff56, "ffffff56", "%x", +__LINE__, 0xfffff589, "FFFFF589", "%+X", +__LINE__, 0x00024d13, "24D13", "%-5.2X", +__LINE__, 0x00000000, " 0", "%6.1d", +__LINE__, 0x00a64f33, "A64F33", "%4.4X", +__LINE__, 0xffebb57a, "FFEBB57A", "%5.4X", +__LINE__, 0xfff3b4a0, "fff3b4a0", "%2.x", +__LINE__, 0xffffffd9, "FFFFFFD9", "%.2X", +__LINE__, 0x00d37b84, "13859716", "%d", +__LINE__, 0x00001e85, "0001E85", "%0.7X", +__LINE__, -0x756148f, "-123081871", "% 7.d", +__LINE__, -0x0319339, "-3248953", "%+#.4d", +__LINE__, -0x00798b8, "-497848", "%#5ld", +__LINE__, -0x0000039, "-57", "%0d", +__LINE__, -0x000b1d7, "-45527", "%+0.ld", +__LINE__, 0xff811fba, "FF811FBA", "%+X", +__LINE__, 0x00000042, " 66", "% ld", +__LINE__, 0xfffffe31, "0XFFFFFE31", "%#X", +__LINE__, 0x00000073, "115", "%ld", +__LINE__, 0x45091a39, "0x45091a39", "%+#3.x", +__LINE__, 0x001270f5, "1270f5", "%-5.6x", +__LINE__, 0xfffd91fd, "fffd91fd", "%x", +__LINE__, -0x0817bad, "-8485805", "%#ld", +__LINE__, -0x32ad55f, "-53138783", "%0d", +__LINE__, 0x00003e57, "15959", "%0ld", +__LINE__, -0x0048756, "-296790", "%2.6d", +__LINE__, 0xff90f45f, "FF90F45F", "% X", +__LINE__, 0x0000e454, "0e454", "% .5x", +__LINE__, 0xfffffffc, "fffffffc", "%x", +__LINE__, 0xfffffff7, "FFFFFFF7", "%-2X", +__LINE__, 0xffdabf0e, "FFDABF0E", "%+X", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#1X", +__LINE__, 0x01516650, "1516650", "% x", +__LINE__, 0xffffff51, "FFFFFF51", "%X", +__LINE__, 0x000000ea, "234", "%00.d", +__LINE__, 0x06db60ca, "115040458", "%5.d", +__LINE__, 0x00000f01, " 3841", "% d", +__LINE__, 0x00000009, "9", "%x", +__LINE__, 0x299b3ba0, "299b3ba0", "%6.7x", +__LINE__, 0x0067f298, "67f298", "%-2.6x", +__LINE__, 0xfffffff5, "FFFFFFF5", "% 2X", +__LINE__, 0x00102ff9, "102FF9", "%-.0X", +__LINE__, 0xffc22393, "0xffc22393", "% #6x", +__LINE__, 0x00007db5, "32181", "%-2ld", +__LINE__, 0x0000b0a3, "0xb0a3", "%#0x", +__LINE__, 0x001ceebb, "1CEEBB", "%-3.4X", +__LINE__, 0x00025101, "0x25101", "%#x", +__LINE__, -0x0000001, "-1", "%0ld", +__LINE__, 0xffffd846, "FFFFD846", "%+2.3X", +__LINE__, 0x00001d79, " 7545", "% 0.1ld", +__LINE__, -0x0000002, " -2", "%5d", +__LINE__, 0xf93b9fdc, "f93b9fdc", "%5x", +__LINE__, 0xffff0021, "FFFF0021", "%6X", +__LINE__, 0x00007cf9, "7cf9", "%3.1x", +__LINE__, -0x0000002, "-2", "%d", +__LINE__, 0x00001d84, "1d84", "%0x", +__LINE__, -0x033201e, "-3350558", "%-2.0d", +__LINE__, 0xfff8a6fb, "FFF8A6FB", "%+.7X", +__LINE__, 0x00006fff, " 28671", "% ld", +__LINE__, -0x02a274a, "-2762570", "%d", +__LINE__, -0x0006628, "-26152", "%00ld", +__LINE__, 0x00000011, "11", "%-x", +__LINE__, -0x0000ed9, "-3801", "%0.ld", +__LINE__, 0xfc5b725d, "FC5B725D", "%X", +__LINE__, 0x3530bd4e, "892386638", "%7.d", +__LINE__, 0x03bb4ff7, "62607351", "%#4.7ld", +__LINE__, 0x00009f86, "9f86", "%x", +__LINE__, 0x0000e727, "59175", "%1d", +__LINE__, 0xfffffdf2, "0XFFFFFDF2", "%#X", +__LINE__, 0x00e60dbf, "0XE60DBF", "% #1.X", +__LINE__, 0xffffffff, "FFFFFFFF", "%+X", +__LINE__, 0x0a16f44e, "0XA16F44E", "%#.0X", +__LINE__, 0x0001f97c, "1f97c", "% x", +__LINE__, 0x0000000d, "13", "%#0ld", +__LINE__, 0x0000002a, "42", "%0ld", +__LINE__, 0x00000007, " +7", "%+5ld", +__LINE__, 0xffffff7f, "FFFFFF7F", "%-X", +__LINE__, 0x000006a6, "1702", "%ld", +__LINE__, 0xfaff2fb1, "faff2fb1", "% x", +__LINE__, 0xffff94ab, "ffff94ab", "%x", +__LINE__, 0x011d611b, "0X11D611B", "%#2.3X", +__LINE__, 0x00000000, " +000", "%+#5.3ld", +__LINE__, -0x87fcc37, "-142593079", "%+d", +__LINE__, -0x0417424, "-4289572", "%+d", +__LINE__, 0x03fabc0c, "3fabc0c", "%x", +__LINE__, 0xfffff880, "fffff880", "%-x", +__LINE__, 0x000002d7, "2d7", "%-02.x", +__LINE__, 0x00003e82, "16002", "%#d", +__LINE__, -0x0003713, "-14099", "% 5d", +__LINE__, -0x0000027, "-39", "%ld", +__LINE__, 0x00013098, "0077976", "%01.7d", +__LINE__, -0x000000c, "-12", "%ld", +__LINE__, -0x00000c0, "-192", "% ld", +__LINE__, 0xffbe9285, "FFBE9285", "%3.X", +__LINE__, 0x00000046, "46", "%x", +__LINE__, 0x00000000, " ", "%+4.x", +__LINE__, 0x00011e72, "73330", "%2.3d", +__LINE__, -0x5276dd7, "-86470103", "%d", +__LINE__, 0x00000013, "19", "%-02.ld", +__LINE__, 0x384118a7, "0X384118A7", "%-#X", +__LINE__, 0x00000000, "0", "% #X", +__LINE__, 0x00000009, "9", "%#ld", +__LINE__, 0x00021145, "135493", "%-ld", +__LINE__, 0xff188a0c, "FF188A0C", "%1.X", +__LINE__, 0xffffffd5, "ffffffd5", "%0x", +__LINE__, 0xfffffffe, "FFFFFFFE", "% 0X", +__LINE__, 0xffff74a3, "ffff74a3", "%x", +__LINE__, 0x01d5a2f8, "1d5a2f8", "%-0.x", +__LINE__, 0xfffffef6, "fffffef6", "%+06.x", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0x00000000, "+0", "%+ld", +__LINE__, 0xfffffffc, "fffffffc", "%4.x", +__LINE__, -0x0000344, "-0836", "% .4d", +__LINE__, 0xfffffffd, "FFFFFFFD", "%0X", +__LINE__, 0x000a3121, "667937", "%#4.4ld", +__LINE__, 0x0001e211, "0X1E211", "%#X", +__LINE__, 0x00000c8b, "00C8B", "%05X", +__LINE__, 0xfffffffe, "fffffffe", "%+0x", +__LINE__, 0x001a53ce, "1725390", "%d", +__LINE__, 0x0000057f, "57f ", "%-7.x", +__LINE__, -0x0073e4d, "-474701", "%#ld", +__LINE__, -0x0000002, " -2", "% 3.d", +__LINE__, 0x482dc404, "482DC404", "%X", +__LINE__, 0x0000011c, "11c", "%-.1x", +__LINE__, 0x00000c12, " 3090", "%5.3ld", +__LINE__, 0xfffe1068, "FFFE1068", "%-.4X", +__LINE__, -0x0055e88, "-351880", "%ld", +__LINE__, 0x000c9cef, "+826607", "%+d", +__LINE__, 0xffffffe3, "ffffffe3", "%0x", +__LINE__, -0x0000ee9, "-3817", "%#ld", +__LINE__, 0xff1f6daa, "FF1F6DAA", "%X", +__LINE__, 0xfffffc4e, "FFFFFC4E", "%5.2X", +__LINE__, -0x000040a, "-1034", "%d", +__LINE__, -0x0000085, "-00133", "% 01.5d", +__LINE__, -0x126c797c, "-309098876", "%5.ld", +__LINE__, 0x00000039, " 57", "% d", +__LINE__, 0xfffffff6, "0xfffffff6", "%#5.x", +__LINE__, 0xfffffff4, "fffffff4", "%7.6x", +__LINE__, 0x00000003, "3", "%ld", +__LINE__, 0x0000f8ae, "f8ae", "%.0x", +__LINE__, 0x003ca1cf, "3973583", "%#3.7d", +__LINE__, 0x14687009, "0x14687009", "%+#3x", +__LINE__, 0xfffff1f7, "0xfffff1f7", "%#4.5x", +__LINE__, 0xfffff17a, "fffff17a", "%3.x", +__LINE__, 0x0011ea18, "1174040", "%ld", +__LINE__, -0x0000019, "-25", "%03.d", +__LINE__, 0x00015d72, "0X15D72", "%-#X", +__LINE__, 0xffde4a41, "ffde4a41", "%x", +__LINE__, 0x00006f1f, "28447", "%d", +__LINE__, 0xffffffbd, "0xffffffbd", "%#.1x", +__LINE__, 0x000013b9, "13B9", "%0X", +__LINE__, -0x00001b9, "-00441", "%1.5d", +__LINE__, 0x00000001, "000001", "%-.6d", +__LINE__, 0x7b602d8f, "+2069900687", "%+0ld", +__LINE__, 0x0005e323, "+385827", "%+ld", +__LINE__, 0x00002fce, "2FCE", "%+0X", +__LINE__, 0x0000000e, "0014", "%.4d", +__LINE__, 0xffffffd6, "0XFFFFFFD6", "%#4.X", +__LINE__, 0x037bf361, "58454881", "%5.ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%-7.5X", +__LINE__, -0x016d4dc, "-1496284", "%6ld", +__LINE__, 0x0005be9a, "0x5be9a", "%-#.5x", +__LINE__, 0xffffffff, "ffffffff", "%1x", +__LINE__, 0x00000055, " 85", "% 7.d", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, -0x0135392, "-1266578", "% ld", +__LINE__, 0x00850f26, "8720166", "%d", +__LINE__, 0xffffee39, "ffffee39", "%0x", +__LINE__, 0x000000dd, "221", "%ld", +__LINE__, 0x00000000, " ", "%6.d", +__LINE__, 0x000000d8, "d8", "%x", +__LINE__, 0x000007ec, "002028", "%4.6ld", +__LINE__, 0x0dab4e67, "0XDAB4E67", "%#X", +__LINE__, 0xfffd7c95, "FFFD7C95", "% 4X", +__LINE__, 0x0009302d, "9302D", "%3.1X", +__LINE__, 0x00000003, " 3", "% d", +__LINE__, 0x0000082f, "82f", "%-x", +__LINE__, 0x0652517f, "652517F", "%-.2X", +__LINE__, -0x1fd8f4e3, "-534312163", "%d", +__LINE__, 0x00000176, "176", "%-x", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0x0000001a, "1A", "%X", +__LINE__, -0x0005740, "-22336", "% 0ld", +__LINE__, 0xffffffff, "ffffffff", "%6x", +__LINE__, 0x1b273b80, "0x1b273b80", "%#x", +__LINE__, 0x00000065, "65", "%X", +__LINE__, 0x6a62138a, "1784812426", "%2ld", +__LINE__, 0x000001a2, "1A2", "%X", +__LINE__, -0x002aafd, "-174845", "%02.ld", +__LINE__, 0x00000014, "20", "%d", +__LINE__, -0x00000c7, " -199", "%7.0ld", +__LINE__, 0xff545bfd, "ff545bfd", "%-x", +__LINE__, -0x002beb9, "-179897", "%02.2ld", +__LINE__, -0x00000df, "-223", "% 02.d", +__LINE__, -0x000d569, "-54633", "%1.ld", +__LINE__, 0x0000000e, "14", "%d", +__LINE__, -0x0077407, "-488455", "% ld", +__LINE__, 0x0001be09, "114185", "%ld", +__LINE__, -0x0000514, "-01300", "%+05.5d", +__LINE__, 0xf1fb397f, "f1fb397f", "%+x", +__LINE__, 0xfdb6707c, "FDB6707C", "%X", +__LINE__, 0x03cad111, "3cad111", "%5.x", +__LINE__, -0x022e72f, "-2287407", "%d", +__LINE__, -0xda35f48, "-228810568", "%d", +__LINE__, -0x02d1fd4, "-2957268", "%1.3d", +__LINE__, 0x0000005f, "+95", "%+2d", +__LINE__, 0xfffbf8a1, "FFFBF8A1", "%4.2X", +__LINE__, 0x0000071e, " 71e", "%6.x", +__LINE__, 0x000cc8a5, "+837797", "%+03ld", +__LINE__, 0x000eebe9, " EEBE9", "%6.X", +__LINE__, -0x2896b204, "-680964612", "%d", +__LINE__, -0x09553f8, "-9786360", "%d", +__LINE__, 0x000015d3, "5587", "%0d", +__LINE__, 0x0000056d, " 56d", "%+4.x", +__LINE__, -0x00624ad, "-402605", "% ld", +__LINE__, 0xfea64ba5, "0xfea64ba5", "%#1x", +__LINE__, 0x004f35c6, "5191110", "%-ld", +__LINE__, -0x1441fe4, "-21241828", "%d", +__LINE__, 0xffffff95, "FFFFFF95", "%X", +__LINE__, 0xfffecf81, "FFFECF81", "%-2.X", +__LINE__, -0x00002bb, "-699", "%-d", +__LINE__, -0x0000c29, "-3113", "% 02ld", +__LINE__, 0x000026a3, " 9891", "% .4d", +__LINE__, 0x00000003, "3", "%-x", +__LINE__, 0x000007db, "+02011", "%+.5ld", +__LINE__, 0xfff99558, "FFF99558", "%.1X", +__LINE__, 0x0000fce6, "64742", "%4.0d", +__LINE__, 0x000b7ea2, "753314", "%ld", +__LINE__, 0x13e5df30, "0X13E5DF30", "%#2.X", +__LINE__, 0x006761c4, "06761C4", "%6.7X", +__LINE__, 0xffffff78, "FFFFFF78", "%0.X", +__LINE__, 0xfffff1c0, "0xfffff1c0", "% #x", +__LINE__, -0x034af1c, "-3452700", "% 06.1d", +__LINE__, 0x000000de, "0000222", "%2.7ld", +__LINE__, 0x000003d8, "0x3d8", "%#4.x", +__LINE__, -0x001a1d1, "-106961", "%3.1d", +__LINE__, -0x0000002, "-2", "% d", +__LINE__, 0x00001de6, "+7654", "%+0ld", +__LINE__, 0x00000001, "001", "%#.3d", +__LINE__, -0x53dacf9f, "-1406848927", "%ld", +__LINE__, 0xfffffffc, "fffffffc", "%3.3x", +__LINE__, -0x00950e8, "-610536", "%3.6ld", +__LINE__, 0xff14ade9, "FF14ADE9", "%6X", +__LINE__, 0x012f5284, "0X12F5284", "% #5X", +__LINE__, 0x00005a21, " 5a21", "%5x", +__LINE__, 0x00000638, "1592", "%2.4ld", +__LINE__, -0x063017b, "-6488443", "%ld", +__LINE__, 0x00000000, "0", "% X", +__LINE__, 0xfffe8ef2, "FFFE8EF2", "%+0X", +__LINE__, -0x0001c96, "-7318", "%.3d", +__LINE__, 0x0000ca7d, "51837", "%ld", +__LINE__, 0x00000001, "1", "%+1x", +__LINE__, 0xfffff7bc, "FFFFF7BC", "%X", +__LINE__, -0x03d15e2, "-4003298", "%ld", +__LINE__, 0xfffffffe, "fffffffe", "% x", +__LINE__, 0x00066183, "+418179", "%+7.1ld", +__LINE__, 0xffffef2e, "ffffef2e", "%-2.x", +__LINE__, 0x00000000, " 000", "%04.3x", +__LINE__, -0x000000f, "-15", "% d", +__LINE__, -0x00001f5, "-501", "%d", +__LINE__, 0x0c67f159, "c67f159", "%6.2x", +__LINE__, -0x0000006, "-6", "%.1d", +__LINE__, 0x00000005, "0X5", "%+#1X", +__LINE__, -0x0000002, " -2", "%6.ld", +__LINE__, 0xeb2183ec, "eb2183ec", "% x", +__LINE__, -0x5e12a322, "-1578279714", "%d", +__LINE__, 0x00000001, "0x1", "%#x", +__LINE__, -0x0001ea4, "-7844", "%0d", +__LINE__, -0x19955a3, "-26826147", "%d", +__LINE__, 0x000002a6, "2A6", "%2.X", +__LINE__, 0x00000002, "2", "%X", +__LINE__, 0xfffffeec, "fffffeec", "%0.4x", +__LINE__, 0xfffffffc, "fffffffc", "%0x", +__LINE__, 0xffdfe740, "FFDFE740", "% X", +__LINE__, -0x0b0b3e7, "-11580391", "%.1d", +__LINE__, 0x8e01077c, "8E01077C", "%5.7X", +__LINE__, 0x3b6b6d55, "996896085", "%1.1d", +__LINE__, 0x000016af, "5807", "%ld", +__LINE__, -0x0004900, "-18688", "%d", +__LINE__, 0xfffd77bc, "FFFD77BC", "%X", +__LINE__, 0x004cbd74, "5029236", "%0d", +__LINE__, 0x00000003, " 00003", "%6.5d", +__LINE__, 0x0004720f, "4720f", "% x", +__LINE__, 0x0e44535d, "e44535d", "%4x", +__LINE__, 0xfffffff9, "FFFFFFF9", "%3.3X", +__LINE__, -0x0000005, "-5", "%-d", +__LINE__, 0x000001a6, "00001A6", "%1.7X", +__LINE__, 0x0000004a, "4A", "%-2.X", +__LINE__, 0xfffff249, "FFFFF249", "%X", +__LINE__, 0x00004345, "4345", "%x", +__LINE__, 0x0197041d, "197041d", "%+0x", +__LINE__, 0x0000019a, " 19a", "% 6.x", +__LINE__, 0xfff98376, "FFF98376", "%X", +__LINE__, 0xfc536c41, "FC536C41", "%X", +__LINE__, -0x0008d91, "-36241", "% d", +__LINE__, 0xf058d69d, "f058d69d", "%4.x", +__LINE__, -0x00013ef, "-5103", "%d", +__LINE__, -0x0000003, "-3", "%00ld", +__LINE__, -0x09e80f0, "-10387696", "%+07ld", +__LINE__, -0x0222c15, "-2239509", "%#0.4ld", +__LINE__, 0x00000004, "4", "%0ld", +__LINE__, -0x02c6b0d, "-2910989", "% 0ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%-4X", +__LINE__, 0xffffff3d, "FFFFFF3D", "%-.0X", +__LINE__, -0x0000015, "-21", "%0d", +__LINE__, 0x131dfc90, "+320732304", "%+d", +__LINE__, 0xffffffff, "ffffffff", "%+x", +__LINE__, 0x000035c8, "13768", "%0ld", +__LINE__, 0x00000033, "0x0033", "%#.4x", +__LINE__, 0x0ce7e8c1, "0xce7e8c1", "%#.7x", +__LINE__, 0xfc18b5d2, "FC18B5D2", "%+.3X", +__LINE__, 0x00000015, "21", "%d", +__LINE__, 0x001a5e7c, "1a5e7c", "%05x", +__LINE__, -0x000fbf0, "-64496", "%ld", +__LINE__, -0x000a4f7, "-042231", "%+2.6d", +__LINE__, -0x0000002, "-002", "%3.3ld", +__LINE__, 0x00728878, "728878", "%0X", +__LINE__, -0x0000002, "-2", "%#.1ld", +__LINE__, -0x00002ef, "-751", "%-0ld", +__LINE__, 0xfffffff7, "fffffff7", "%.3x", +__LINE__, 0x00491867, "0491867", "%.7X", +__LINE__, 0x00000d4d, "3405", "%-ld", +__LINE__, 0x00234e86, "234E86", "%0X", +__LINE__, -0x000001b, "-27", "%ld", +__LINE__, 0x00275255, "2576981", "%.5ld", +__LINE__, 0xfeacc214, "0XFEACC214", "%-#3.X", +__LINE__, -0x0001ce5, "-7397", "%+#2.2ld", +__LINE__, 0x089ddb6a, "144563050", "%d", +__LINE__, 0x003d5a95, "3D5A95", "%1X", +__LINE__, 0x002f0b6d, "3083117", "%d", +__LINE__, 0x1e79e228, "511304232", "%ld", +__LINE__, 0xfffffe6b, "FFFFFE6B", "%+0X", +__LINE__, -0x5104ff3, "-84955123", "%.4ld", +__LINE__, 0xfffff1de, "FFFFF1DE", "%X", +__LINE__, 0x000000cf, "+207", "%+.1ld", +__LINE__, -0x16ad0164, "-380436836", "%+5.d", +__LINE__, 0x001fefa6, "2092966", "%ld", +__LINE__, 0x00000000, "00", "%-.2d", +__LINE__, 0x00195f45, "195f45", "%+0x", +__LINE__, 0x00000001, " 1", "%3.ld", +__LINE__, -0x00001c9, "-457", "% ld", +__LINE__, 0x0002479e, "149406", "%#ld", +__LINE__, 0x001ab18b, "1749387", "%04d", +__LINE__, 0x00000045, "69", "%ld", +__LINE__, 0xfbb13f7d, "fbb13f7d", "%.2x", +__LINE__, 0x03ddc208, "3ddc208", "%x", +__LINE__, 0x00000007, "000007", "%#.6d", +__LINE__, 0x00000000, "0", "%01X", +__LINE__, -0x0023110, "-143632", "%+0.3d", +__LINE__, 0x00000006, "06", "%#.2d", +__LINE__, 0xffff9ec9, "ffff9ec9", "%7x", +__LINE__, -0x08afb12, "-9108242", "% #0.ld", +__LINE__, 0x00000004, "4", "%X", +__LINE__, 0x00059684, "59684", "%x", +__LINE__, 0xfff8d8f5, "FFF8D8F5", "%X", +__LINE__, 0x00b7027d, "+11993725", "%+0.7ld", +__LINE__, 0x0000d814, "55316", "%0ld", +__LINE__, 0x03c95a08, "3c95a08", "%3x", +__LINE__, -0x0b65f9a, "-11952026", "%d", +__LINE__, 0xfd956021, "fd956021", "%0x", +__LINE__, 0x000000ed, "ed", "%0x", +__LINE__, -0x006a80c, "-436236", "%.6ld", +__LINE__, 0xfedb109d, "fedb109d", "%x", +__LINE__, 0x00000001, "1", "%X", +__LINE__, 0x00b3eb71, " 11791217", "% d", +__LINE__, 0x00000016, "16", "%0X", +__LINE__, 0x000001db, " 475", "% ld", +__LINE__, 0x00465eaf, "4611759", "%0d", +__LINE__, 0x0001b423, "1B423", "%0X", +__LINE__, 0x05df95ea, "5df95ea", "%+.5x", +__LINE__, 0x0000000e, " 14", "%7ld", +__LINE__, 0xffffb89e, "ffffb89e", "%+x", +__LINE__, 0x01259918, " 19241240", "% d", +__LINE__, -0x0000f8d, "-003981", "%+#.6d", +__LINE__, 0x00054ae0, "54AE0", "%X", +__LINE__, -0x4589ed4, "-72916692", "% ld", +__LINE__, 0x01017516, "1017516", "%6X", +__LINE__, 0xfffb9f15, "FFFB9F15", "%.2X", +__LINE__, 0x005f8394, "5F8394", "%.2X", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, -0x0000001, " -1", "%7.1ld", +__LINE__, 0x004367af, "4417455", "%4.ld", +__LINE__, 0xffffff86, "ffffff86", "%4.5x", +__LINE__, -0x0000d17, "-3351", "%2.0ld", +__LINE__, 0xffffff31, "ffffff31", "%.6x", +__LINE__, -0x0000001, "-1", "%ld", +__LINE__, -0x3d785fab, "-1031298987", "%d", +__LINE__, -0x0000002, "-2", "%-0ld", +__LINE__, 0x0000019c, "412", "%d", +__LINE__, -0x0006f54, "-28500", "%d", +__LINE__, 0xfffe3524, "FFFE3524", "% 6.2X", +__LINE__, -0x128d3c00, "-311245824", "%2d", +__LINE__, -0x3be71293, "-1004999315", "%d", +__LINE__, 0x0000659d, "26013", "%d", +__LINE__, 0x2d947538, "+764704056", "%+5d", +__LINE__, 0xffa2a420, "FFA2A420", "%0X", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0x04477c14, "4477c14", "%.6x", +__LINE__, -0x06e145b, "-7214171", "%d", +__LINE__, 0x00009c01, "39937", "%-.1d", +__LINE__, 0xffde174b, "ffde174b", "% 0x", +__LINE__, 0x0001fbae, "1FBAE", "%01.X", +__LINE__, -0x06b8406, "-7046150", "%d", +__LINE__, 0x000005b8, "005b8", "%05x", +__LINE__, -0x02d780b, "-2979851", "%1d", +__LINE__, 0x00209e26, "2137638", "%2d", +__LINE__, 0x0000041a, "41A", "%0X", +__LINE__, 0x2a77f42c, "2A77F42C", "%02X", +__LINE__, 0x13b6ee14, "+330755604", "%+0d", +__LINE__, -0x0000002, "-2 ", "%-6.d", +__LINE__, -0x0001eee, "-7918", "% #2.ld", +__LINE__, 0xffffffff, "FFFFFFFF", "% .5X", +__LINE__, 0x20d11927, "20d11927", "% 0.x", +__LINE__, -0x0018690, "-99984", "% ld", +__LINE__, 0x000002a0, "2A0", "%-0X", +__LINE__, -0x0000511, "-1297", "%+d", +__LINE__, 0x0e782f31, "242757425", "%-0.ld", +__LINE__, 0x2ce06da0, "752905632", "%#0ld", +__LINE__, 0x00000062, "62 ", "%-07x", +__LINE__, -0x015d9d8, "-1432024", "% 7d", +__LINE__, 0xc9125ea8, "c9125ea8", "%x", +__LINE__, 0x00000006, "6", "%.0ld", +__LINE__, 0x0000019c, "19c", "%x", +__LINE__, 0x00000000, " ", "%6.d", +__LINE__, 0x00043e89, "278153", "%0ld", +__LINE__, 0x3e422abd, "1044523709", "%ld", +__LINE__, 0x0220a75d, "35694429", "%#7.6d", +__LINE__, 0x0000c21c, "C21C", "% X", +__LINE__, 0x000074ab, "29867", "%d", +__LINE__, 0x056b22aa, "56B22AA", "%+0.X", +__LINE__, 0xfffffff9, "FFFFFFF9", "%X", +__LINE__, 0x00000000, "0", "%X", +__LINE__, 0xf094a4f4, "f094a4f4", "%+4.x", +__LINE__, -0x1dad0244, "-497877572", "%d", +__LINE__, 0xffffffff, "FFFFFFFF", "%.1X", +__LINE__, 0xfffffe2d, "fffffe2d", "%7.x", +__LINE__, 0x0000042b, "0x42b", "%#x", +__LINE__, -0x0000001, "-1", "% d", +__LINE__, 0x00e77ef5, " 15171317", "% 7.ld", +__LINE__, 0x00006210, " 25104", "% 06d", +__LINE__, 0x0011187a, "1120378", "%-ld", +__LINE__, -0x000000b, "-11", "% #ld", +__LINE__, 0x14cfaff0, "14cfaff0", "%-2.3x", +__LINE__, 0xffff74ea, "FFFF74EA", "%3.X", +__LINE__, 0x000bfb9d, "bfb9d", "%x", +__LINE__, 0xfffffffe, "FFFFFFFE", "%X", +__LINE__, 0x00014500, "0X14500", "%#4.X", +__LINE__, -0x0000001, "-1", "%#1d", +__LINE__, -0x0000024, "-36", "%-0d", +__LINE__, -0x6528828, "-106072104", "%d", +__LINE__, 0x00000075, " 117", "% #d", +__LINE__, 0xff027d67, "ff027d67", "%0x", +__LINE__, 0x0012b8b3, "12b8b3", "%0.1x", +__LINE__, 0x1070147b, "275780731", "%.6ld", +__LINE__, 0xffffe88e, "FFFFE88E", "%1.3X", +__LINE__, 0xfffffc0d, "fffffc0d", "%00.6x", +__LINE__, 0xffd889f5, "ffd889f5", "%x", +__LINE__, 0x00000470, "1136", "%0ld", +__LINE__, 0x000297f8, "169976", "%ld", +__LINE__, 0xfffffffe, "fffffffe", "%+1x", +__LINE__, 0x0000064a, "64a", "%x", +__LINE__, -0x3d71e43b, "-1030874171", "%1.d", +__LINE__, -0x0000004, "-4 ", "%-3.d", +__LINE__, 0xfffff132, "FFFFF132", "%0.0X", +__LINE__, 0x37b6356f, "37b6356f", "%-x", +__LINE__, 0xffffff7a, "FFFFFF7A", "%.0X", +__LINE__, 0x00023553, "23553", "%x", +__LINE__, 0x39a4c29f, "39a4c29f", "%+5.x", +__LINE__, 0xffffffcc, "ffffffcc", "%x", +__LINE__, 0x0003a83b, "239675", "%#6ld", +__LINE__, 0x00000002, "2", "%0x", +__LINE__, -0x09b4e8c, "-10178188", "%+03.ld", +__LINE__, 0x00000002, "0000002", "%-#.7ld", +__LINE__, 0x00000b5e, "2910", "%-04ld", +__LINE__, -0x0000254, "-596", "%+0d", +__LINE__, 0x00000001, "1", "%+1.x", +__LINE__, 0xf8290d3e, "0XF8290D3E", "% #X", +__LINE__, 0x00000035, "035", "%3.3X", +__LINE__, 0x00131d7d, "131D7D ", "%-7.6X", +__LINE__, 0xffdbb36a, "0xffdbb36a", "%#.6x", +__LINE__, 0xc7275816, "c7275816", "%04.x", +__LINE__, 0x00bae994, "12249492", "%0ld", +__LINE__, 0x00000002, "+2", "%+0.0ld", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, 0xffffffe0, "ffffffe0", "%x", +__LINE__, 0x00000036, "36", "%.0X", +__LINE__, 0xfffffffd, "FFFFFFFD", "%1X", +__LINE__, 0xffffffc8, "ffffffc8", "%+x", +__LINE__, 0xe71c3689, "e71c3689", "%x", +__LINE__, 0x00000007, "7 ", "%-3.ld", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, 0x00030400, "030400", "%-4.6x", +__LINE__, 0xbd8c6fa7, "BD8C6FA7", "%-6X", +__LINE__, 0x00000233, "0000563", "%.7ld", +__LINE__, 0xfef92e35, "fef92e35", "%x", +__LINE__, 0xffff2172, "ffff2172", "%3x", +__LINE__, 0x00001233, "1233", "% X", +__LINE__, -0x000d2e1, "-53985", "%-0d", +__LINE__, -0x3ba8cb5b, "-1000917851", "%0d", +__LINE__, -0x4fefb9a, "-83819418", "%5.ld", +__LINE__, 0xffffe9eb, "FFFFE9EB", "%X", +__LINE__, 0x1e472dc3, "507981251", "%ld", +__LINE__, -0x0077046, "-487494", "%0d", +__LINE__, 0x0002c4c9, "+181449", "%+7.d", +__LINE__, 0xfffffe63, "fffffe63", "%x", +__LINE__, 0xfff5a6db, "FFF5A6DB", "%X", +__LINE__, 0x00174442, "174442", "%-5.0X", +__LINE__, 0x017891d9, "17891D9", "%+5.X", +__LINE__, 0x0261966b, "261966B", "%-X", +__LINE__, -0x3e58614d, "-1045979469", "%ld", +__LINE__, 0x002c4c41, "+2903105", "%+01ld", +__LINE__, 0x0000000c, "012", "%#.3d", +__LINE__, 0x0380f73a, "58783546", "%ld", +__LINE__, 0x000002c7, "0000711", "%2.7ld", +__LINE__, 0x00000002, " 002", "% 04ld", +__LINE__, 0x00687ca0, "687CA0", "%X", +__LINE__, 0x0000058a, "1418", "%0ld", +__LINE__, -0x0000642, "-1602", "% ld", +__LINE__, 0x0001f4f1, "1F4F1", "%X", +__LINE__, 0x0026d6fc, "+2545404", "%+4.ld", +__LINE__, 0x05dd423c, "+98386492", "%+#ld", +__LINE__, 0x0000782c, "0782C", "%3.5X", +__LINE__, 0xf67d91f8, "f67d91f8", "%-x", +__LINE__, 0xffffcf2d, "ffffcf2d", "%+0x", +__LINE__, -0x00af8a6, "-719014", "%0ld", +__LINE__, -0xe606ef9, "-241200889", "%ld", +__LINE__, 0xfe9d87f7, "fe9d87f7", "%+x", +__LINE__, 0x00000d44, "d44", "% 1.x", +__LINE__, 0x008716f5, "8716f5", "%2x", +__LINE__, 0x000027d4, "27D4", "% X", +__LINE__, 0xfdfd92ea, "FDFD92EA", "%-.4X", +__LINE__, 0xfffe764f, "FFFE764F", "%X", +__LINE__, 0xff699032, "ff699032", "%3.x", +__LINE__, 0xffffffff, "FFFFFFFF", "%-3X", +__LINE__, -0x368ba995, "-915122581", "%+#.6ld", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, 0x0000035e, " 862", "% 1d", +__LINE__, 0xfe703e67, "fe703e67", "%07.0x", +__LINE__, 0xfffffffe, "fffffffe", "%4.x", +__LINE__, 0x000e20cf, "e20cf", "%0x", +__LINE__, 0x000063b5, "0X63B5", "%-#X", +__LINE__, 0xfffffffa, "fffffffa", "%+2.x", +__LINE__, 0xffffffff, "FFFFFFFF", "%2.X", +__LINE__, 0xfdfd69da, "FDFD69DA", "%.0X", +__LINE__, 0x00002f61, "0x2f61", "%#3.x", +__LINE__, 0x00000009, "9", "%x", +__LINE__, 0xffffff86, "ffffff86", "%6x", +__LINE__, 0xffffffe4, "ffffffe4", "%0x", +__LINE__, 0x0062e73b, "+6481723", "%+0ld", +__LINE__, -0x2b059130, "-721785136", "%+d", +__LINE__, -0x0000073, "-115", "%d", +__LINE__, 0xf596efcf, "f596efcf", "%x", +__LINE__, 0x0002f1cb, "2F1CB", "%0X", +__LINE__, -0x0000635, "-01589", "%.5ld", +__LINE__, 0xfffa011a, "FFFA011A", "%0X", +__LINE__, 0x00000047, " 47", "%4X", +__LINE__, 0xfffffbc0, "FFFFFBC0", "%5.2X", +__LINE__, 0x00000015, "15", "% X", +__LINE__, 0x002a87a6, "2a87a6", "%.1x", +__LINE__, -0x000069c, "-1692", "%+ld", +__LINE__, 0xfffffffd, "fffffffd", "%+x", +__LINE__, 0xfeda51f5, "FEDA51F5", "%0X", +__LINE__, 0x001781a4, "1781a4", "%-0x", +__LINE__, 0xe77358d4, "e77358d4", "%+0x", +__LINE__, 0x00000084, " 84", "%3.x", +__LINE__, 0xffff0cb2, "FFFF0CB2", "%+5.X", +__LINE__, 0x0009fa17, "653847", "%0.0ld", +__LINE__, -0x0000c92, "-3218", "%d", +__LINE__, 0x0004ebbb, "4ebbb", "%x", +__LINE__, 0x2e72568c, "+779245196", "%+#ld", +__LINE__, 0xffae86a7, "ffae86a7", "%.7x", +__LINE__, 0xffdf3f04, "ffdf3f04", "%x", +__LINE__, 0x000000c7, "199", "%2.d", +__LINE__, -0x0004a55, "-19029", "%ld", +__LINE__, 0x00564ef9, "5656313", "%.6ld", +__LINE__, 0xffffc205, "ffffc205", "%+.0x", +__LINE__, -0x135085d0, "-324044240", "%#.5d", +__LINE__, 0xfffffffe, "fffffffe", "%-7x", +__LINE__, -0x0000003, "-3", "%.1ld", +__LINE__, 0xffda9e0b, "ffda9e0b", "%+0x", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0xffffffda, "ffffffda", "%.6x", +__LINE__, 0x5efdb3d1, "+1593684945", "%+0d", +__LINE__, -0x00000ca, "-202", "% 4.d", +__LINE__, -0x0014433, "-82995", "%.3d", +__LINE__, -0x0000002, "-000002", "% .6ld", +__LINE__, 0x24aac879, "615172217", "%.7d", +__LINE__, -0x1db3c1d, "-31144989", "%+#4ld", +__LINE__, 0x000945ad, "0x945ad", "%#1x", +__LINE__, 0x0000000a, "10", "%#.1ld", +__LINE__, -0x002a2e5, "-172773", "%d", +__LINE__, 0xfffffff3, "FFFFFFF3", "%5X", +__LINE__, 0x0000000e, "e", "%+x", +__LINE__, 0x335333dc, "861090780", "%6.d", +__LINE__, 0xfffa16f4, "FFFA16F4", "%6X", +__LINE__, 0xffffc727, "ffffc727", "%+2.x", +__LINE__, 0x00000273, "273", "%x", +__LINE__, -0x000000f, "-15", "%-0d", +__LINE__, 0x00065fbd, "417725", "%5.1d", +__LINE__, 0x00000ed5, "3797", "%d", +__LINE__, 0x30a40024, "30A40024", "%3.7X", +__LINE__, 0x00000054, "84", "%ld", +__LINE__, 0x00000515, "01301", "%.5ld", +__LINE__, 0x00000897, "+02199", "%+.5d", +__LINE__, -0x0001bcc, "-7116", "% ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%7X", +__LINE__, 0x00000013, "0X13", "%#X", +__LINE__, 0xffffffff, "0xffffffff", "% #x", +__LINE__, 0x00000006, "6", "%ld", +__LINE__, -0x00000c3, "-195", "%1.ld", +__LINE__, -0x005291e, "-338206", "%+d", +__LINE__, 0xffb437a7, "FFB437A7", "%-0X", +__LINE__, 0xff8335cb, "ff8335cb", "%x", +__LINE__, 0x0000006a, "6A", "%2X", +__LINE__, -0x004f629, "-325161", "% .4d", +__LINE__, 0x003698ef, "3578095", "%0ld", +__LINE__, 0x6b5cdf3a, "6b5cdf3a", "%-x", +__LINE__, 0xe9bc5c21, "e9bc5c21", "%+x", +__LINE__, -0x0000001, " -1", "%+6.ld", +__LINE__, 0xfffeffc8, "FFFEFFC8", "%6.X", +__LINE__, 0xff070a73, "ff070a73", "%+.7x", +__LINE__, 0x0023f8ae, "2357422", "%07.4ld", +__LINE__, 0x00000000, "0", "%X", +__LINE__, 0x00000016, "16", "%0X", +__LINE__, -0x000005a, " -90", "%4d", +__LINE__, 0x00000116, "116", "% .3x", +__LINE__, 0xfffed024, "fffed024", "%-x", +__LINE__, 0xfb907950, "fb907950", "%.0x", +__LINE__, 0x0101a1e5, "101a1e5", "%x", +__LINE__, -0x09e7684, "-10385028", "%-#ld", +__LINE__, 0xffffffff, "ffffffff", "%1x", +__LINE__, 0xfffffff6, "fffffff6", "%x", +__LINE__, 0x00000078, "78", "%x", +__LINE__, 0xe6bca9c9, "0XE6BCA9C9", "%#.5X", +__LINE__, -0x0000010, "-16", "%d", +__LINE__, -0x1348f685, "-323548805", "%d", +__LINE__, 0x4dd85797, "1306023831", "%ld", +__LINE__, -0x0000080, "-128", "%.2d", +__LINE__, -0xaed13a7, "-183309223", "%+ld", +__LINE__, -0x000002f, "-47", "% d", +__LINE__, -0x679911f, "-108630303", "%ld", +__LINE__, 0xfffff221, "FFFFF221", "% .7X", +__LINE__, 0x0007476c, "7476c", "%x", +__LINE__, 0xffffe02a, "0xffffe02a", "%#7x", +__LINE__, 0x00000ebb, "0XEBB", "%#X", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%-#X", +__LINE__, 0x00281896, "281896", "%+1.x", +__LINE__, 0x0000085d, " 0X85D", "%#6.3X", +__LINE__, 0x000112bf, "112BF", "%X", +__LINE__, 0xf5518fbf, "F5518FBF", "% X", +__LINE__, -0x00c945b, "-824411", "%ld", +__LINE__, 0x00001b43, "0x1b43", "%-#x", +__LINE__, -0x5872a246, "-1483907654", "%#7.7ld", +__LINE__, 0x00001f96, "8086", "%#d", +__LINE__, 0xfffffff9, "FFFFFFF9", "%X", +__LINE__, -0x006e244, "-451140", "% .3d", +__LINE__, -0x0382188, "-3678600", "%0.2ld", +__LINE__, 0x00000006, "6", "%-x", +__LINE__, 0x00000036, "54 ", "%-5.d", +__LINE__, -0x0000439, " -1081", "%#6.3ld", +__LINE__, 0xfff911c6, "FFF911C6", "%X", +__LINE__, -0x03454dc, "-3429596", "%d", +__LINE__, -0x0363e8d, "-3554957", "%-.2ld", +__LINE__, 0x00000000, "000", "%.3X", +__LINE__, -0x59bb030f, "-1505428239", "%0ld", +__LINE__, 0x073c94d8, "121410776", "%-d", +__LINE__, -0x001ef94, "-126868", "%5.1ld", +__LINE__, 0xfff65fc5, "FFF65FC5", "%0X", +__LINE__, 0xfffffff4, "fffffff4", "%-x", +__LINE__, 0x00001d83, "07555", "%5.5d", +__LINE__, 0x0012b40a, "1225738", "%ld", +__LINE__, -0x0000006, "-6", "%0ld", +__LINE__, 0xfffffffc, "fffffffc", "%06.0x", +__LINE__, -0x0000002, "-00002", "%#.5ld", +__LINE__, 0xf9932c1d, "f9932c1d", "%-x", +__LINE__, -0x46a31d9, "-74068441", "%.3ld", +__LINE__, 0x000987e9, "987E9", "%1X", +__LINE__, 0x0000000f, "15", "%-ld", +__LINE__, -0x0001c4d, "-7245", "%ld", +__LINE__, -0x007deee, "-515822", "%2.6d", +__LINE__, 0xffffffa2, "FFFFFFA2", "%.6X", +__LINE__, 0x00000001, "1", "%-ld", +__LINE__, 0xfc106bde, "fc106bde", "%.4x", +__LINE__, 0x0002f1f8, "0x2f1f8", "%#7.x", +__LINE__, -0x06a290b, "-6957323", "%-ld", +__LINE__, -0x0000037, " -55", "%4ld", +__LINE__, 0x0000152e, "5422", "%2.d", +__LINE__, 0xfffffcb2, "0XFFFFFCB2", "%#3.X", +__LINE__, 0x1b7ca086, "1b7ca086", "%+x", +__LINE__, 0x00000001, "1", "%ld", +__LINE__, 0x006775fc, "6775fc", "%3.2x", +__LINE__, 0x0000000e, "0XE", "%#3.X", +__LINE__, 0xffffffff, "0xffffffff", "%+#4.x", +__LINE__, 0x00001246, "1246", "%X", +__LINE__, 0xffffaed6, "ffffaed6", "%2x", +__LINE__, -0x3a2dec78, "-976088184", "% 0ld", +__LINE__, 0x0001423b, "1423b", "%01x", +__LINE__, 0x00000007, " 0X7", "%#4.X", +__LINE__, 0x01a7ff5a, "27787098", "%.4ld", +__LINE__, -0x0020d05, "-134405", "%-d", +__LINE__, 0xffffff9a, "ffffff9a", "%-.1x", +__LINE__, 0xffff3557, "ffff3557", "%x", +__LINE__, 0x08828e35, "8828e35", "%+.1x", +__LINE__, 0x000006b2, "001714", "%04.6ld", +__LINE__, 0x00000013, "19", "%.0ld", +__LINE__, -0x00341a5, "-213413", "%#d", +__LINE__, -0x0000043, "-67", "%d", +__LINE__, -0x074dce3, "-7658723", "%.1d", +__LINE__, -0x16de2df3, "-383659507", "% ld", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0x00000ce7, "ce7", "% 2.1x", +__LINE__, 0xffecd377, "ffecd377", "% 0x", +__LINE__, 0xa4e8465c, "a4e8465c", "% x", +__LINE__, 0x000005e8, "1512", "%d", +__LINE__, 0x00000513, "1299", "%d", +__LINE__, 0xffffffb8, "FFFFFFB8", "%X", +__LINE__, 0x00000003, "00003", "%3.5x", +__LINE__, -0x0000003, "-3 ", "%-3.ld", +__LINE__, 0xad53f01d, "ad53f01d", "%0x", +__LINE__, 0x0f1c1dae, "253500846", "%-#.0d", +__LINE__, 0xff1753c0, "0xff1753c0", "%#3.x", +__LINE__, -0x00389c5, "-231877", "%d", +__LINE__, 0x0000016e, "00016E", "%.6X", +__LINE__, -0x54d3310f, "-1423126799", "%-d", +__LINE__, 0x00000005, "0X5", "%#.1X", +__LINE__, 0xfffffffd, "0XFFFFFFFD", "%#5.3X", +__LINE__, 0xfffffe0e, "fffffe0e", "%-x", +__LINE__, 0xa3c02157, "a3c02157", "%.5x", +__LINE__, 0x00005765, "22373", "%d", +__LINE__, -0x12668cd, "-19294413", "%+ld", +__LINE__, -0x66544da, "-107300058", "%2d", +__LINE__, 0x8646c605, "0X8646C605", "% #X", +__LINE__, 0x000001f5, "1F5", "%X", +__LINE__, 0x01b33ae4, "28523236", "%5ld", +__LINE__, 0x000007ce, "7ce", "%3.x", +__LINE__, 0x00000355, "355", "%X", +__LINE__, 0x000001ce, "1CE", "% X", +__LINE__, 0xfffffccd, "fffffccd", "%7.0x", +__LINE__, -0x0000001, "-1", "%0ld", +__LINE__, 0x000640b6, "640b6", "%5.x", +__LINE__, 0x0038c4ec, "3720428", "%5.4d", +__LINE__, -0x0f10b5e, "-15797086", "%2ld", +__LINE__, 0x256c815f, "256c815f", "%4.x", +__LINE__, 0x00000682, " 1666", "%6ld", +__LINE__, -0x00000ab, "-171", "%2ld", +__LINE__, 0x00000003, "3", "%0d", +__LINE__, 0x063f5075, "63F5075", "%X", +__LINE__, 0xff83b5d0, "FF83B5D0", "%7.X", +__LINE__, 0xffffffec, "ffffffec", "%x", +__LINE__, 0xffb551c4, "0XFFB551C4", "% #4.X", +__LINE__, -0x071f057, "-7467095", "%3.7d", +__LINE__, 0x00634879, "6506617", "%#ld", +__LINE__, 0x000001d7, "471", "%d", +__LINE__, 0x00a7da92, "A7DA92", "% .4X", +__LINE__, 0x00000003, "3 ", "%-2.ld", +__LINE__, -0x0000004, "-0004", "%.4d", +__LINE__, -0x01dea32, "-1960498", "% #7.d", +__LINE__, 0x53c4159f, "53C4159F", "%1.7X", +__LINE__, -0x1ad7904, "-28145924", "%#d", +__LINE__, -0x0000a85, "-2693", "%ld", +__LINE__, -0x0000c7d, "-3197", "%d", +__LINE__, 0xfffffffc, "FFFFFFFC", "%+0X", +__LINE__, 0x00000004, "00004", "%1.5d", +__LINE__, 0x0000b761, "46945", "%5ld", +__LINE__, -0x0ee3b2c, "-15612716", "%.6d", +__LINE__, 0x0677a73d, "677a73d", "% x", +__LINE__, -0x5f96020, "-100229152", "% d", +__LINE__, 0x00000000, " 0", "%#7X", +__LINE__, -0x5d1cb5b, "-97635163", "% ld", +__LINE__, -0x00a8d8b, "-691595", "%-0ld", +__LINE__, 0xffffffa2, "FFFFFFA2", "%X", +__LINE__, 0xffffffc9, "FFFFFFC9", "%X", +__LINE__, 0x0b180d35, "B180D35", "%X", +__LINE__, 0xfc0b94ce, "fc0b94ce", "%.1x", +__LINE__, 0x0012cd7b, "12CD7B", "% X", +__LINE__, -0x02f1da8, "-3087784", "%ld", +__LINE__, -0x000a6f9, "-42745", "%-ld", +__LINE__, -0x000006d, "-109 ", "%-6d", +__LINE__, 0x00000001, "+1", "%+0d", +__LINE__, 0x00000001, "1", "%1d", +__LINE__, 0xfffffff8, "fffffff8", "%5.x", +__LINE__, -0x00fc4d7, "-1033431", "%+0.5ld", +__LINE__, 0xffff41b4, "0xffff41b4", "%#x", +__LINE__, -0x0000d37, "-3383", "%ld", +__LINE__, 0xffc4e405, "ffc4e405", "%7x", +__LINE__, 0xffffffb0, "FFFFFFB0", "%04X", +__LINE__, -0x0054477, "-345207", "%01.ld", +__LINE__, 0x00512778, "0x512778", "%#3.0x", +__LINE__, 0x00000007, " 7", "%7.d", +__LINE__, 0x00000008, " 00008", "% .5ld", +__LINE__, 0x000053fd, "21501", "%.4ld", +__LINE__, 0x0000370c, "370c", "%2x", +__LINE__, -0x44670a7, "-71725223", "%3d", +__LINE__, 0x00000064, " 64", "%+5x", +__LINE__, 0xfffffffc, "FFFFFFFC", "%X", +__LINE__, 0xf7bbf094, "f7bbf094", "%3x", +__LINE__, 0xfffeb268, "FFFEB268", "%X", +__LINE__, 0x00001ef0, "1ef0", "%4.x", +__LINE__, 0x05ad9aa4, " 95263396", "% 0.ld", +__LINE__, 0xf294dca7, "F294DCA7", "% 4.X", +__LINE__, -0x0000003, "-000003", "%.6d", +__LINE__, 0xfff57471, "fff57471", "% x", +__LINE__, 0x0a848cfd, "176459005", "%d", +__LINE__, -0x000002e, "-46", "%.0d", +__LINE__, 0x00000051, " +81", "%+5d", +__LINE__, -0x000072b, "-0001835", "%06.7d", +__LINE__, -0x0000002, " -2", "%+#6ld", +__LINE__, 0x00000003, "3", "%x", +__LINE__, 0xfffd1799, "FFFD1799", "%6.X", +__LINE__, 0x00000005, "5", "%ld", +__LINE__, 0x0052138b, "5378955", "%#7.7ld", +__LINE__, 0x000000c0, " 192", "% 7ld", +__LINE__, 0x005b26cd, "5B26CD", "%X", +__LINE__, -0x008df17, "-581399", "%.4ld", +__LINE__, 0xfffffad8, "fffffad8", "%-x", +__LINE__, 0x000006a9, "6a9", "%.0x", +__LINE__, -0x003b7f9, "-243705", "%+0ld", +__LINE__, 0x005d7ea4, "6127268", "%ld", +__LINE__, -0x003ccea, "-249066", "%+.0ld", +__LINE__, 0x0000846f, "846F", "%X", +__LINE__, 0x00004f79, "4F79", "%4.X", +__LINE__, 0xe3e1409c, "E3E1409C", "%-X", +__LINE__, 0x07cce2f4, "7CCE2F4", "%2.X", +__LINE__, 0x004bcc8b, "4967563", "%-.5ld", +__LINE__, 0x7d49665e, "2101962334", "%ld", +__LINE__, 0xfffffffc, "FFFFFFFC", "%.5X", +__LINE__, 0x0000019e, "+000414", "%+.6d", +__LINE__, 0x000027ef, "10223", "%d", +__LINE__, -0x0000261, "-609", "%3ld", +__LINE__, -0x000000e, "-14", "% 2.ld", +__LINE__, 0xff3ba3c7, "ff3ba3c7", "%+5.7x", +__LINE__, 0xffffffc4, "FFFFFFC4", "%-1.X", +__LINE__, 0xfffc5a70, "0xfffc5a70", "%#4.4x", +__LINE__, 0x0000d156, " 53590", "% d", +__LINE__, -0x0486258, "-4743768", "%0ld", +__LINE__, 0x00000000, " ", "% 2.d", +__LINE__, 0x04a0ef9f, "77655967", "%0.6ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, 0x00000019, "0000019", "%.7x", +__LINE__, -0x0058d3a, "-363834", "%ld", +__LINE__, 0xfffff6b3, "fffff6b3", "%x", +__LINE__, 0xfffffff5, "FFFFFFF5", "%.0X", +__LINE__, 0x005e1fcb, "5E1FCB", "%+6X", +__LINE__, 0xffc3c866, "0xffc3c866", "%-#.4x", +__LINE__, 0x00000003, "3", "%X", +__LINE__, 0xffa2e961, "FFA2E961", "%7.4X", +__LINE__, 0x00000029, "41", "%d", +__LINE__, -0x0000035, "-53", "%d", +__LINE__, 0x0001b033, "110643", "%ld", +__LINE__, 0x004dd51b, "5100827", "%-2ld", +__LINE__, -0x000252d, "-9517", "% d", +__LINE__, 0xffffdeb2, "ffffdeb2", "%4.x", +__LINE__, 0xffe94eab, "0xffe94eab", "%#x", +__LINE__, 0xf921edf6, "f921edf6", "%4.2x", +__LINE__, 0x0007df97, "515991", "%4.ld", +__LINE__, 0x00709bc5, "709BC5", "%0X", +__LINE__, -0x0000001, "-1", "%d", +__LINE__, 0xfffffffb, "FFFFFFFB", "%7.3X", +__LINE__, -0x0063f74, "-409460", "%+05.0d", +__LINE__, 0xfffffe9a, "FFFFFE9A", "%.2X", +__LINE__, -0x0001ce2, "-7394", "%.4d", +__LINE__, 0x000038c5, "14533", "%ld", +__LINE__, 0x000000ad, "000ad", "% 5.5x", +__LINE__, 0xffffbcc4, "ffffbcc4", "%-5x", +__LINE__, 0x00000000, "0", "% X", +__LINE__, 0x00372877, "372877", "%.6X", +__LINE__, 0xffffffd7, "FFFFFFD7", "%1.X", +__LINE__, 0xfa58b14b, "fa58b14b", "%x", +__LINE__, 0xfffffd9f, "FFFFFD9F", "%0.7X", +__LINE__, 0x00000710, "+1808", "%+#.2ld", +__LINE__, 0x00000006, " 6", "%5.0ld", +__LINE__, 0x0fba9706, "263886598", "%-6.3d", +__LINE__, 0xffff420a, "ffff420a", "%-2x", +__LINE__, 0x14b9a825, "14b9a825", "%x", +__LINE__, 0x0077ffe4, "77FFE4", "%+.2X", +__LINE__, 0x00067108, "422152 ", "%-7.ld", +__LINE__, 0x00000001, " 00001", "%6.5X", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, -0x0000001, " -1", "% 7ld", +__LINE__, 0x01ddc7a3, "31311779", "%d", +__LINE__, -0x2a92f9b, "-44642203", "% 3ld", +__LINE__, 0xfffffff9, "fffffff9", "%4.6x", +__LINE__, 0x0279a274, "279a274", "%x", +__LINE__, 0x2e37ed8e, "775417230", "%d", +__LINE__, 0x5ba59f58, "1537580888", "%-ld", +__LINE__, 0xffffffe0, "ffffffe0", "%x", +__LINE__, 0x3110ae47, "0X3110AE47", "%+#X", +__LINE__, 0x000e00b9, "917689", "%d", +__LINE__, 0x0000002e, " 0046", "% 7.4d", +__LINE__, 0x00000363, " 867", "%7.d", +__LINE__, -0x000000b, "-0011", "% 0.4d", +__LINE__, 0x000349c8, " 349C8", "% 7.X", +__LINE__, -0x01358f1, "-1267953", "%d", +__LINE__, -0x0039d3c, "-236860", "%-.3d", +__LINE__, 0xffd6de19, "ffd6de19", "%04.0x", +__LINE__, -0x0003c54, "-0015444", "%1.7d", +__LINE__, -0x0000e17, "-3607", "%d", +__LINE__, 0xff0fa3a9, "ff0fa3a9", "%+3x", +__LINE__, 0x00000009, "0000009", "%1.7x", +__LINE__, 0xfffffc81, "FFFFFC81", "% X", +__LINE__, -0x4ef2df5, "-82783733", "%ld", +__LINE__, 0x00000013, "19", "%-ld", +__LINE__, 0x00000000, " 0", "%#7x", +__LINE__, -0x3b9485fd, "-999589373", "%1.d", +__LINE__, -0x0000006, "-00006", "%6.5d", +__LINE__, 0x0000003f, "+63", "%+ld", +__LINE__, 0x000004c5, "1221", "%1.d", +__LINE__, 0x003f8a8c, "4164236", "%d", +__LINE__, -0x000001e, "-30", "%-#3d", +__LINE__, 0xfff9d230, "FFF9D230", "%+07.3X", +__LINE__, 0x0147cf17, "147cf17", "% x", +__LINE__, 0xffffffeb, "ffffffeb", "%x", +__LINE__, 0x0000007d, "00125", "%.5ld", +__LINE__, 0x000fff56, "1048406", "%#3d", +__LINE__, 0x064307a0, " 105056160", "% 0.3ld", +__LINE__, 0x007d2860, "8202336", "%-.2d", +__LINE__, 0x00a05711, "a05711", "%x", +__LINE__, 0x179a7f9e, "0x179a7f9e", "%+#.3x", +__LINE__, 0x00000003, "3", "%X", +__LINE__, -0x0001d7d, "-7549", "%#5d", +__LINE__, 0x0025d3f2, "+2479090", "%+2.d", +__LINE__, -0x0000001, "-1", "%#ld", +__LINE__, 0xfffffdd5, "fffffdd5", "%.7x", +__LINE__, 0x003462b9, "3433145", "%d", +__LINE__, 0x00005a81, "23169", "%d", +__LINE__, 0xfffffcdb, "fffffcdb", "%-x", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0xfff22085, "fff22085", "%x", +__LINE__, 0x00016d72, " 93554", "% d", +__LINE__, -0x0000002, "-2", "%0ld", +__LINE__, 0xfffffd21, "fffffd21", "% 0x", +__LINE__, 0x00000931, "2353", "%ld", +__LINE__, 0x00010021, "10021", "%5.1X", +__LINE__, -0x000007e, "-126", "%1.0ld", +__LINE__, 0xfffffff8, "fffffff8", "%01.x", +__LINE__, -0x001d148, "-119112", "%d", +__LINE__, -0x0000008, "-8", "%ld", +__LINE__, -0x000038e, "-910", "% ld", +__LINE__, 0x0039e3e5, "3793893", "%0.1d", +__LINE__, 0x0038fb8e, "38FB8E", "%.2X", +__LINE__, -0x002dafa, "-187130", "%ld", +__LINE__, -0xbec275b, "-200025947", "%ld", +__LINE__, 0x1a32f999, "1A32F999", "%05.4X", +__LINE__, 0x0000002f, "2f", "%x", +__LINE__, -0x0001a5b, "-6747", "%+3.ld", +__LINE__, 0x00000762, " 1890", "%7.ld", +__LINE__, 0x000000c2, "000194", "%0.6ld", +__LINE__, 0xffff002b, "FFFF002B", "%.4X", +__LINE__, -0x0019dae, "-105902", "% .2d", +__LINE__, 0x0000125f, "125f", "%+1x", +__LINE__, -0x000b688, " -46728", "%#7.d", +__LINE__, 0x000401ca, "401ca", "%0x", +__LINE__, 0x00000192, "402", "%#ld", +__LINE__, 0xffffffff, "ffffffff", "%x", +__LINE__, 0x1e505a0c, "0X1E505A0C", "%#1.3X", +__LINE__, 0x000f8f6c, "1019756", "%d", +__LINE__, 0x0004a296, "4a296", "%5.2x", +__LINE__, 0x00000003, "3", "% x", +__LINE__, -0x000d44c, "-54348", "%#ld", +__LINE__, 0x00009ae2, "39650", "%-d", +__LINE__, 0xffffff3a, "FFFFFF3A", "% .7X", +__LINE__, 0x0042350b, "4338955", "%d", +__LINE__, 0x000071af, "71af", "%+.4x", +__LINE__, 0x00000001, "0x1", "%#0x", +__LINE__, 0x00000033, "00051", "%3.5d", +__LINE__, 0x00000001, "1", "%X", +__LINE__, -0xebfb0e7, "-247443687", "%+3ld", +__LINE__, 0x00000027, "27 ", "%-07.X", +__LINE__, -0x0004837, "-18487", "%01d", +__LINE__, 0x1a8c53da, "1A8C53DA", "%X", +__LINE__, -0x0bdb8a9, "-12433577", "%d", +__LINE__, -0x0000098, "-152", "%#ld", +__LINE__, -0x003b554, "-243028", "%d", +__LINE__, 0x000000cb, "00000CB", "%+.7X", +__LINE__, 0xfffffeda, "FFFFFEDA", "%X", +__LINE__, -0x0000010, "-16", "%-#d", +__LINE__, 0x00000006, "+6", "%+d", +__LINE__, 0x003c294a, "+3942730", "%+4.ld", +__LINE__, 0x00000009, "9", "%ld", +__LINE__, 0xfbbdd2bc, "FBBDD2BC", "% X", +__LINE__, 0x71c86678, "+1908958840", "%+0.6ld", +__LINE__, -0x0b49bff, "-11836415", "% 6.ld", +__LINE__, 0xfff416be, "fff416be", "%3.x", +__LINE__, 0x00000077, "+119", "%+d", +__LINE__, 0xfff1cfaa, "FFF1CFAA", "% 0.2X", +__LINE__, 0xfffffffb, "fffffffb", "% x", +__LINE__, 0x0000127e, "4734", "%d", +__LINE__, 0x00107ad2, "107ad2", "%+2.6x", +__LINE__, 0x0006b8e9, "440553", "%-#d", +__LINE__, 0x0000eb6f, "eb6f", "% x", +__LINE__, 0x00001f18, "7960", "%0d", +__LINE__, 0xfffff225, "fffff225", "%1.5x", +__LINE__, 0xfffffff9, "fffffff9", "%+6.x", +__LINE__, 0x000005b9, "01465", "%.5ld", +__LINE__, 0xfffc26b8, "FFFC26B8", "% X", +__LINE__, 0x540d580d, "0X540D580D", "%+#X", +__LINE__, 0x05ad7094, "5AD7094", "% 4.7X", +__LINE__, -0x000019b, "-411", "% d", +__LINE__, 0x00000006, "000006", "%6.6ld", +__LINE__, 0x0000026a, "+618", "%+ld", +__LINE__, 0x0000000b, "11", "%ld", +__LINE__, -0x26985d5, "-40469973", "%#.0ld", +__LINE__, 0x0000007d, "7D", "%+02.0X", +__LINE__, -0x0079ddf, "-0499167", "%+.7ld", +__LINE__, 0x0000375f, "14175", "%0d", +__LINE__, -0x18de7f99, "-417234841", "%ld", +__LINE__, -0x00507cc, "-329676", "%.0d", +__LINE__, 0x000029d5, "29D5", "%-2.1X", +__LINE__, 0x0000328c, "328C", "%-3.X", +__LINE__, 0x016f6234, "24076852", "%3.ld", +__LINE__, 0xfffffffc, "0XFFFFFFFC", "%#.5X", +__LINE__, 0xfe6163ca, "FE6163CA", "%5.X", +__LINE__, 0xffffffc2, "FFFFFFC2", "%X", +__LINE__, 0x00000087, "+135", "%+ld", +__LINE__, 0x00310166, "310166", "% x", +__LINE__, 0x00e8c871, "15255665", "%d", +__LINE__, 0x000005ee, "1518", "%ld", +__LINE__, 0xfcb24306, "FCB24306", "%X", +__LINE__, 0x0000000b, " 11", "%5ld", +__LINE__, 0x006d11d0, "0x6d11d0", "%#.0x", +__LINE__, 0x0010d416, "1102870", "%#6.5d", +__LINE__, -0x0047cb3, "-294067", "%.3d", +__LINE__, 0x000000c0, "c0", "%x", +__LINE__, 0xffffffff, "FFFFFFFF", "%+X", +__LINE__, -0x000000a, "-10", "%d", +__LINE__, -0x0000007, "-7", "% ld", +__LINE__, 0xfffffffe, "FFFFFFFE", "%-X", +__LINE__, 0x00000014, "0x14", "%-#3.1x", +__LINE__, 0x00003319, "3319", "% x", +__LINE__, 0x00000000, "00", "%+#.2X", +__LINE__, -0x0000009, "-9", "% ld", +__LINE__, -0x0000001, "-1 ", "%-3ld", +__LINE__, 0x00262909, "2500873", "%.5ld", +__LINE__, 0x33e76560, "33e76560", "%7.0x", +__LINE__, -0x0000002, "-2", "%ld", +__LINE__, 0x00035ee9, "35EE9", "%-3.X", +__LINE__, -0x0000235, "-565", "%+4.ld", +__LINE__, -0x3ea63c5, "-65692613", "%d", +__LINE__, 0x00000003, "3", "%ld", +__LINE__, -0x003362f, "-210479", "% d", +__LINE__, -0x1a819f8a, "-444702602", "%.7d", +__LINE__, 0x027a4668, "41567848", "%d", +__LINE__, 0x0002b025, "2b025", "%x", +__LINE__, -0x0000001, "-001", "%.3ld", +__LINE__, 0xfffffff0, "fffffff0", "%-0x", +__LINE__, -0x0000d4f, "-3407", "%-ld", +__LINE__, 0x00000146, " 326", "% 1.d", +__LINE__, -0x0000006, "-6", "%d", +__LINE__, 0xffffffff, "FFFFFFFF", "%06.4X", +__LINE__, 0x376fddae, "+930078126", "%+#0ld", +__LINE__, 0x006d9da3, "6d9da3", "%1.x", +__LINE__, -0x0000f28, "-3880", "%3.2ld", +__LINE__, 0x0006962c, " 431660", "% 5d", +__LINE__, 0x000011db, " 4571", "%6.ld", +__LINE__, 0xffffffa8, "ffffffa8", "%+x", +__LINE__, 0x0d886db3, "D886DB3", "%.7X", +__LINE__, 0x00000000, "000000", "%2.6ld", +__LINE__, 0xfffff6b6, "FFFFF6B6", "% X", +__LINE__, -0x0739068, "-7573608", "%+6.ld", +__LINE__, 0xfba62553, "0XFBA62553", "%#X", +__LINE__, -0x4474bc5, "-71781317", "%-2ld", +__LINE__, 0xffffff95, "FFFFFF95", "% 2.X", +__LINE__, -0x1d0e1ca, "-30466506", "%+.0d", +__LINE__, -0x000f3aa, "-62378", "%ld", +__LINE__, 0x00000026, "26", "%1x", +__LINE__, 0x001c5400, "1856512", "%-#d", +__LINE__, 0x03808442, "3808442", "%X", +__LINE__, -0x0000081, "-129", "%+#ld", +__LINE__, 0x000004ae, " 1198", "% 3.4d", +__LINE__, -0x7f4ed54, "-133492052", "%d", +__LINE__, 0x00000000, "+0", "%+ld", +__LINE__, 0x00000000, "0", "%+x", +__LINE__, 0x004c7e46, "5013062", "%.0d", +__LINE__, -0x647d7a65, "-1685944933", "%0.2d", +__LINE__, 0x00003b59, "15193", "%-#1d", +__LINE__, 0xfff3e64d, "FFF3E64D", "%-X", +__LINE__, 0x00007022, "28706", "%-d", +__LINE__, 0xc28d0ad8, "c28d0ad8", "%+x", +__LINE__, -0x005c208, "-377352", "% ld", +__LINE__, 0x00cfbadc, "13613788", "%d", +__LINE__, 0x000016ea, "5866", "%0d", +__LINE__, 0x00000029, "29", "%X", +__LINE__, 0xffe16813, "0XFFE16813", "%+#X", +__LINE__, 0x00000004, "4", "%0X", +__LINE__, -0x0000096, " -150", "%5d", +__LINE__, 0x00027ac7, "162503", "%ld", +__LINE__, -0x0075de0, "-482784", "%d", +__LINE__, 0x005fcff6, "6279158", "%d", +__LINE__, 0xffffffef, "FFFFFFEF", "%3X", +__LINE__, 0x267b05ec, "645596652", "%4ld", +__LINE__, 0xa487b724, "a487b724", "%x", +__LINE__, 0x01da2a11, "31074833", "%-.0ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, 0x0000037a, "37a", "%x", +__LINE__, 0x003d0314, "+3998484", "%+#1d", +__LINE__, 0x0000011b, " 283", "%5.2d", +__LINE__, 0x094f6066, "94f6066", "%x", +__LINE__, 0x00000004, "4", "%X", +__LINE__, -0x102e14bd, "-271455421", "% 7.ld", +__LINE__, 0x000048da, "0018650", "%07ld", +__LINE__, -0x24ae0390, "-615383952", "%0.6d", +__LINE__, 0xffff5159, "0XFFFF5159", "%#0X", +__LINE__, 0xfffd38c3, "fffd38c3", "%x", +__LINE__, 0xfffff9ea, "FFFFF9EA", "%-X", +__LINE__, -0x000fd28, "-64808", "% ld", +__LINE__, 0x002c1bf4, "2890740", "%-.1d", +__LINE__, 0x00d00ee7, "D00EE7", "%0.4X", +__LINE__, 0x00000cf9, "3321", "%0d", +__LINE__, -0x0000001, "-1", "%-#ld", +__LINE__, 0xfffffd75, "FFFFFD75", "%.2X", +__LINE__, 0x00000012, "18", "%-d", +__LINE__, 0xfd44b4b2, "fd44b4b2", "%+5.x", +__LINE__, -0x001c53f, "-116031", "%-#6.d", +__LINE__, 0x000ff6fd, "ff6fd", "%2x", +__LINE__, 0x00000001, "1", "%0d", +__LINE__, 0x0120b478, "120B478", "%.7X", +__LINE__, 0x0145591e, "145591E", "%1.4X", +__LINE__, 0x001f99b9, "1F99B9", "%.1X", +__LINE__, 0xffffd078, "ffffd078", "%-1.5x", +__LINE__, 0xffffff1a, "FFFFFF1A", "%-4.6X", +__LINE__, 0xfffffffa, "fffffffa", "%x", +__LINE__, -0x00000b9, "-185", "%3ld", +__LINE__, 0x00001cf0, "7408", "%-ld", +__LINE__, 0xffffffff, "FFFFFFFF", "%X", +__LINE__, 0x00151f30, "151F30", "%X", +__LINE__, -0x0000103, "-259", "%d", +__LINE__, -0x000303f, "-12351", "%d", +__LINE__, 0x000002ca, "714", "%ld", +__LINE__, -0x0000c55, "-3157", "%1d", +__LINE__, 0x00000691, "01681", "%#.5ld", +__LINE__, 0x00230537, "2295095", "%#d", +__LINE__, 0x032a1faa, "53092266", "%.4d", +__LINE__, 0x000050d7, "20695", "%d", +__LINE__, -0x0c7ad4c, "-13086028", "%#.4ld", +__LINE__, -0x00009d9, "-2521", "%+d", +__LINE__, 0xfffffffe, "fffffffe", "%0x", +__LINE__, 0xffdec2d9, "FFDEC2D9", "%5.1X", +__LINE__, -0x000563c, "-22076", "%-.2ld", +__LINE__, 0x0073b36a, "0x73b36a", "%-#x", +__LINE__, 0xfffffffd, "fffffffd", "%x", +__LINE__, 0x0193ba5a, "193ba5a", "%1.x", +__LINE__, 0x00d147b5, "13715381", "%2.d", +__LINE__, 0xffffff10, "ffffff10", "%4x", +__LINE__, 0x000648d5, "648d5", "%1.3x", +__LINE__, 0x00000011, "11", "%X", +__LINE__, 0xff259f5b, "0xff259f5b", "% #.1x", +__LINE__, 0x00000175, "175", "%x", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, 0x00000015, "21", "%#ld", +__LINE__, 0xfffffffe, "fffffffe", "%-x", +__LINE__, 0x00000013, " 19", "% 0ld", +__LINE__, -0x0000001, "-0000001", "% 5.7ld", +__LINE__, 0x0000139d, "139D", "%X", +__LINE__, 0x0041ad18, "41ad18", "%-.6x", +__LINE__, -0x00000f9, "-249", "% 3.d", +__LINE__, 0x00000076, "118", "%ld", +__LINE__, 0x000006f8, "1784", "%d", +__LINE__, -0x0000005, "-5", "%ld", +__LINE__, -0x00008e7, "-2279", "%+ld", +__LINE__, 0x00003f77, "3F77", "%+0X", +__LINE__, 0x000ca3f8, "0XCA3F8", "%+#X", +__LINE__, -0x00004bf, "-001215", "%#5.6ld", +__LINE__, 0x319129ab, "0x319129ab", "%+#x", +__LINE__, -0x0000002, "-2", "%ld", +__LINE__, -0x0f6686e, "-16148590", "%.6ld", +__LINE__, 0x0329576b, "53041003", "%2.d", +__LINE__, -0x000179e, "-6046", "%d", +__LINE__, 0x000002cc, "+716", "%+1.3ld", +__LINE__, 0xfffffff7, "0xfffffff7", "% #x", +__LINE__, 0x0016eb40, "1502016", "%ld", +__LINE__, 0x00000003, "3", "%-0ld", +__LINE__, 0x0023e0d6, "23E0D6", "%-05.X", +__LINE__, 0xffffa6a4, "0XFFFFA6A4", "%#X", +__LINE__, 0x00087664, "87664", "% .2x", +__LINE__, -0x0000002, " -2", "%3.ld", +__LINE__, 0x003ad85d, "3AD85D", "%X", +__LINE__, 0x00002f20, "12064", "%ld", +__LINE__, 0x02030bfc, "2030BFC", "%02.3X", +__LINE__, 0xfffff36a, "FFFFF36A", "%X", +__LINE__, 0xfe0729ff, "0xfe0729ff", "% #.0x", +__LINE__, 0xfec15164, "FEC15164", "%0.2X", +__LINE__, -0x00169ec, "-92652", "%+d", +__LINE__, 0x006d7990, "0x6d7990", "%#x", +__LINE__, 0xffcc89e6, "ffcc89e6", "%x", +__LINE__, 0x002d7cca, "2981066", "%7.7ld", +__LINE__, -0x1649692b, "-373909803", "%#ld", +__LINE__, 0x00664f47, "664f47", "%+6.x", +__LINE__, 0x00000000, "0", "% X", +__LINE__, 0x00000047, "000047", "%.6X", +__LINE__, 0x00000007, "0000007", "%.7ld", +__LINE__, 0x00000030, "30", "%-x", +__LINE__, -0x25bcbabb, "-633125563", "% ld", +__LINE__, 0xfe11c031, "FE11C031", "%4.6X", +__LINE__, -0x0000001, "-0000001", "%.7d", +__LINE__, 0x00b56d84, "11890052", "%ld", +__LINE__, -0x0000b01, "-0002817", "%+07.7ld", +__LINE__, 0xffffe4ad, "ffffe4ad", "% 0.0x", +__LINE__, 0x007760fc, "7760fc", "%+x", +__LINE__, 0xffef44d8, "FFEF44D8", "%X", +__LINE__, 0xfcb6862e, "fcb6862e", "%+x", +__LINE__, -0x0000001, "-1", "%0d", +__LINE__, 0xffffffe6, "FFFFFFE6", "%3.1X", +__LINE__, 0xff816e27, "FF816E27", "% 6.X", +__LINE__, 0x00006415, "25621", "%ld", +__LINE__, -0xfae5449, "-263083081", "%0ld", +__LINE__, 0x00000001, " 1", "% 0d", +__LINE__, 0x00000009, " 9", "%2.X", +__LINE__, 0x002d7e18, "2981400", "%7d", +__LINE__, -0x00000fc, "-0000252", "%-#.7d", +__LINE__, 0x00000003, "3", "%0x", +__LINE__, 0x0d46e47f, "222749823", "%ld", +__LINE__, 0xfffcbc52, "FFFCBC52", "%+X", +__LINE__, 0x00000000, "0", "%-X", +__LINE__, 0xfffff0e5, "fffff0e5", "%x", +__LINE__, 0xffffffd9, "FFFFFFD9", "%07X", +__LINE__, 0x000004ee, "4ee", "%0x", +__LINE__, 0xffffffff, "ffffffff", "%0x", +__LINE__, -0x0008cb4, "-036020", "%+3.6ld", +__LINE__, 0x0000dada, "0xdada", "%#0.x", +__LINE__, 0x0000001a, "26 ", "%-4d", +__LINE__, -0x000000c, " -12", "%04.d", +__LINE__, 0x0000025c, " 25c", "%7.x", +__LINE__, 0xfe9b091e, "FE9B091E", "%X", +__LINE__, 0x00000002, " 2", "%07.ld", +__LINE__, -0x0004930, "-18736", "% 6.d", +__LINE__, 0xffffffe9, "FFFFFFE9", "%X", +__LINE__, 0x00000003, " 3", "%2.ld", +__LINE__, 0x00000e00, "3584", "%.4d", +__LINE__, 0xffff38c2, "ffff38c2", "%0.x", +__LINE__, 0xffffffff, "FFFFFFFF", "% .3X", +__LINE__, 0xff7c1b2f, "FF7C1B2F", "%-3.2X", +__LINE__, -0x0000005, "-5", "%2d", +__LINE__, 0x00098775, "98775", "%x", +__LINE__, 0x000015ff, " 15FF", "%6.X", +__LINE__, 0xfffbe3ef, "FFFBE3EF", "%0.3X", +__LINE__, -0x0000048, "-72", "%ld", +__LINE__, 0x0001488a, "84106", "%d", +__LINE__, 0x00000001, "1", "%x", +__LINE__, -0x0000002, "-2", "%-0.0ld", +__LINE__, -0x0000001, "-1", "%-d", +__LINE__, 0x0006616f, "6616f", "%x", +__LINE__, 0x3657856d, "911705453", "%6.d", +__LINE__, -0x0007222, "-0029218", "%.7d", +__LINE__, 0x00041606, "267782", "%04.5d", +__LINE__, 0x00000001, " 1", "%2.ld", +__LINE__, 0x00000219, "219", "%0x", +__LINE__, 0x0ae0184c, "ae0184c", "%x", +__LINE__, 0x00003a7d, " 14973", "%7.ld", +__LINE__, 0xffffffff, "0XFFFFFFFF", "%#X", +__LINE__, -0x0000002, "-2", "%0ld", +__LINE__, 0x00002cdf, "11487", "%0ld", +__LINE__, -0x000000c, "-12", "%d", +__LINE__, -0x000000e, "-14", "%-#2d", +__LINE__, 0x00000371, "881", "%#ld", +__LINE__, 0x000015be, " 5566", "%5.ld", +__LINE__, 0x01525b91, "22174609", "%#0.0ld", +__LINE__, 0xff8fc22f, "FF8FC22F", "% X", +__LINE__, -0x0007f7b, "-32635", "%4.ld", +__LINE__, 0x00007bca, "7bca", "%x", +__LINE__, -0x0000582, "-1410", "%ld", +__LINE__, 0x00000047, " +71", "%+04.2d", +__LINE__, 0xf8a8dce2, "f8a8dce2", "%+.6x", +__LINE__, -0x000de2e, "-56878", "%.0d", +__LINE__, 0x019c03c1, "0X19C03C1", "%#X", +__LINE__, -0x0f3a43e, "-15967294", "%ld", +__LINE__, 0x00009e87, "40583", "%#5.1d", +__LINE__, 0x000000b8, "184", "%0ld", +__LINE__, -0x000befe, "-48894", "%2ld", +__LINE__, -0x002ee1a, "-192026", "%.2d", +__LINE__, 0x00004fd8, "4fd8", "%x", +__LINE__, 0x0006d57b, "447867", "%2d", +__LINE__, 0xfffffa9c, "FFFFFA9C", "%-X", +__LINE__, 0x0000000f, "15", "%ld", +__LINE__, 0x0005deb2, "5DEB2", "% X", +__LINE__, 0x00000007, "7", "%X", +__LINE__, 0xffffffc8, "0XFFFFFFC8", "% #.1X", +__LINE__, 0xfffff62f, "FFFFF62F", "%X", +__LINE__, -0x1a935bba, "-445864890", "% 3.5d", +__LINE__, 0x000b34b4, "0x0b34b4", "%-#3.6x", +__LINE__, 0xfffff430, "FFFFF430", "%X", +__LINE__, 0x00000b5f, "+0002911", "%+#.7d", +__LINE__, 0x00000007, " 7", "%3ld", +__LINE__, 0xffffffd8, "FFFFFFD8", "% .7X", +__LINE__, 0xfffff544, "FFFFF544", "%0X", +__LINE__, -0x353667b9, "-892757945", "%d", +__LINE__, 0x00000058, "0x00058", "%+#.5x", +__LINE__, 0x39dbcc4a, "+970705994", "%+0.6ld", +__LINE__, 0xfffffffd, "fffffffd", "% 01x", +__LINE__, 0x00b1c28e, "+11649678", "%+0ld", +__LINE__, 0x000066c2, "0X66C2", "%-#4X", +__LINE__, 0x007171a2, "+7434658", "%+07.ld", +__LINE__, -0x0000001, "-1", "%-d", +__LINE__, 0x00000ae0, "+2784", "%+0d", +__LINE__, 0x13786a57, "326658647", "%#5d", +__LINE__, -0x0000001, "-1", "%2.ld", +__LINE__, -0x0168a16, "-1477142", "%d", +__LINE__, 0x12df7dd6, "316636630", "%ld", +__LINE__, 0x00000000, "000000", "%1.6d", +__LINE__, 0x266da2a9, "644719273", "%ld", +__LINE__, 0x0000004a, "74", "%d", +__LINE__, 0x000102ff, "00102FF", "%+06.7X", +__LINE__, 0x17916237, "0x17916237", "%#5x", +__LINE__, -0x0003cbb, "-0015547", "%-.7d", +__LINE__, 0xe7da2010, "e7da2010", "%2.4x", +__LINE__, 0xfffffff3, "fffffff3", "% .7x", +__LINE__, 0xfc9b64f8, "FC9B64F8", "% 7.X", +__LINE__, 0x000001af, "431", "%0d", +__LINE__, 0xffc81796, "0xffc81796", "%#.5x", +__LINE__, 0x057a1fbc, "+91889596", "%+04d", +__LINE__, 0x00001ae1, "6881", "%ld", +__LINE__, 0xfffffff6, "fffffff6", "%3.0x", +__LINE__, -0x6b7d5db, "-112711131", "%-06.1d", +__LINE__, 0x008e8a5c, " 8e8a5c", "%7.0x", +__LINE__, 0xfe07a9bd, "fe07a9bd", "%.1x", +__LINE__, -0x00278e6, "-162022", "%0ld", +__LINE__, 0xf98709f5, "F98709F5", "%X", +__LINE__, -0x00000c9, "-201", "% 1.d", +__LINE__, -0x000001d, "-00029", "%+2.5ld", +__LINE__, 0x00000030, " 48", "% d", +__LINE__, 0xffd753f4, "FFD753F4", "%0X", +__LINE__, 0xfffffffd, "FFFFFFFD", "%X", +__LINE__, 0x0000a765, "a765", "%x", +__LINE__, 0x0026e2c8, "26E2C8", "%-0X", +__LINE__, -0x00003eb, "-1003", "%3.1ld", +__LINE__, 0x015d53ca, "22893514", "%0ld", +__LINE__, -0x0000020, "-32", "%ld", +__LINE__, -0x03558dd, "-3496157", "%1.0ld", +__LINE__, -0x000007f, "-127", "%1.d", +__LINE__, 0xffffc737, "0xffffc737", "%+#x", +__LINE__, 0x0000a70d, " a70d", "%6.x", +__LINE__, 0x01ea0e31, "0X1EA0E31", "% #1.X", +__LINE__, 0x00b5f406, "0X0B5F406", "%-#.7X", +__LINE__, 0x0e58fa9a, "240712346", "%.2d", +__LINE__, 0xf43ff8a9, "f43ff8a9", "%+0.6x", +__LINE__, -0x5d0d3d3, "-97571795", "%.3ld", +__LINE__, -0x000027a, "-634", "%0d", +__LINE__, 0xffcef248, "FFCEF248", "%07.X", +__LINE__, 0x000002dc, "2dc", "%0x", +__LINE__, -0x31fa6c1, "-52405953", "%.2d", +__LINE__, 0x00000014, "14", "%X", +__LINE__, -0x0282f98, "-2633624", "%ld", +__LINE__, 0x00005f55, "24405", "%#d", +__LINE__, -0x0000004, "-4", "%d", +__LINE__, 0x00000001, "1", "%+x", +__LINE__, 0x013f47ce, "13f47ce", "%0.x", +__LINE__, 0x00143fce, "1327054", "%.3d", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x00001f9a, "1F9A", "% X", +__LINE__, 0x00000cf5, "cf5", "%x", +__LINE__, 0xffea9c24, "ffea9c24", "%x", +__LINE__, 0xf09f85a7, "F09F85A7", "%X", +__LINE__, 0x00001e04, "7684", "%ld", +__LINE__, 0xffffc82a, "ffffc82a", "%7x", +__LINE__, -0x0000a77, "-2679", "% d", +__LINE__, 0x0019a859, "+1681497", "%+2.6ld", +__LINE__, -0x00002d7, "-727", "%ld", +__LINE__, 0x00011b82, "72578", "%-#ld", +__LINE__, 0x00000c32, "3122", "%ld", +__LINE__, -0x0000337, "-823", "%1.d", +__LINE__, 0x00000004, "4", "%1ld", +__LINE__, 0x0000062c, "1580", "%.1ld", +__LINE__, 0xffffffd3, "FFFFFFD3", "% X", +__LINE__, -0x07b1bf8, "-8068088", "%#d", +__LINE__, 0xfffffff9, "fffffff9", "%x", +__LINE__, 0x159e6cfb, "159e6cfb", "%0.x", +__LINE__, 0x0001148d, "1148d", "%-.1x", +__LINE__, 0x003373b7, "3371959", "%#.0d", +__LINE__, 0x00001af2, "1af2", "%.4x", +__LINE__, -0x0000001, "-000001", "%+.6ld", +__LINE__, -0x00001a3, "-419", "%d", +__LINE__, 0xfdb232e7, "fdb232e7", "%5.4x", +__LINE__, -0x000000d, "-13", "%d", +__LINE__, 0x98ec1c74, "98ec1c74", "% 3x", +__LINE__, 0xfffffff8, "fffffff8", "%+1.4x", +__LINE__, -0x0000d58, "-3416", "%+#0ld", +__LINE__, -0x65d1973, "-106764659", "%.6d", +__LINE__, -0x0737641, "-7566913", "%-d", +__LINE__, 0x0000037c, "37c", "%+0x", +__LINE__, 0x0000012c, "0000300", "%#3.7d", +__LINE__, 0x00c12d9b, "12660123", "%1.5ld", +__LINE__, 0xe7e5e77d, "e7e5e77d", "%6x", +__LINE__, 0x1fe0e820, "1FE0E820", "%-4X", +__LINE__, 0xc85a793a, "C85A793A", "%X", +__LINE__, 0x05f9fe2c, "100269612", "%#ld", +__LINE__, 0x00000032, "0X32", "%+#4.1X", +__LINE__, 0xfab4ce81, "fab4ce81", "%3.x", +__LINE__, -0x0000009, "-9", "%2.d", +__LINE__, 0xffff8d2e, "ffff8d2e", "% 6x", +__LINE__, 0xfffffffe, "0xfffffffe", "%#x", +__LINE__, 0x02960f60, "2960f60", "%1.x", +__LINE__, 0x34cf3cbc, " 885996732", "% 5ld", +__LINE__, -0x000006e, "-110", "% d", +__LINE__, -0x0000001, "-1", "%-.0d", +__LINE__, 0x000000b1, " B1", "%+7X", +__LINE__, 0xfffff5b4, "FFFFF5B4", "%01.7X", +__LINE__, 0x00000086, "86", "%0X", +__LINE__, 0x00074367, " 74367", "% 6x", +__LINE__, 0x001000d7, "+1048791", "%+ld", +__LINE__, 0x00000f35, " 3893", "% d", +__LINE__, -0x00000e1, "-225", "%d", +__LINE__, 0xffff6694, "FFFF6694", "%6.X", +__LINE__, 0x00019cf7, "19cf7", "%0.x", +__LINE__, 0x00000046, "0046", "%+.4X", +__LINE__, -0x000001f, "-31", "%ld", +__LINE__, 0xfff25859, "fff25859", "%6x", +__LINE__, 0x21884061, "562577505", "%#ld", +__LINE__, 0x01448b7a, "1448B7A", "%0.1X", +__LINE__, 0xffffffc0, "ffffffc0", "%x", +__LINE__, 0xfffffed5, "fffffed5", "% 1.0x", +__LINE__, 0x0e349767, "E349767", "%.5X", +__LINE__, 0x00000330, "816", "%0d", +__LINE__, -0x0000016, "-22", "%d", +__LINE__, 0xffff9bab, "FFFF9BAB", "%X", +__LINE__, 0xffffee4e, "ffffee4e", "%x", +__LINE__, 0x0026beeb, "2539243", "%6.d", +__LINE__, 0x00002c6c, "11372", "%.2d", +__LINE__, -0x000002c, "-44", "%ld", +__LINE__, -0x001dcfa, "-122106", "% d", +__LINE__, 0x0001683c, "92220", "%#4.ld", +__LINE__, 0x09b51fc9, "9b51fc9", "%+.7x", +__LINE__, 0x0000001d, "29", "%0ld", +__LINE__, -0x83f17e5, "-138352613", "%ld", +__LINE__, 0xfa4e2c1b, "fa4e2c1b", "%x", +__LINE__, 0x000001f3, "499", "%0ld", +__LINE__, 0xffff03e4, "ffff03e4", "%x", +__LINE__, 0x000000ac, "+0172", "%+.4ld", +__LINE__, 0x03c3903b, "63148091", "%00d", +__LINE__, 0x0000000d, "13", "%#d", +__LINE__, 0x0000002e, "0X2E", "%#X", +__LINE__, 0x00006b2d, "6B2D", "%X", +__LINE__, 0x0000010b, " 0010b", "%7.5x", +__LINE__, 0x0000017a, " 17a", "%4x", +__LINE__, 0xfffffffb, "fffffffb", "%+x", +__LINE__, 0xffffac6a, "ffffac6a", "%-.3x", +__LINE__, -0x0005870, "-22640", "%0d", +__LINE__, 0x189c17bc, "189c17bc", "%x", +__LINE__, -0x01bbc38, "-1817656", "%#6.ld", +__LINE__, -0x3382b55, "-54012757", "%d", +__LINE__, -0x0000007, "-7", "%-ld", +__LINE__, -0x000c74b, "-51019", "%ld", +__LINE__, 0x0001a6f2, "+108274", "%+#1.ld", +__LINE__, 0x00077448, "77448", "%x", +__LINE__, 0x00000000, "0", "%x", +__LINE__, 0xfffff056, "FFFFF056", "%.3X", +__LINE__, -0x6f3f9451, "-1866437713", "%-#3.0ld", +__LINE__, 0x000000ac, "AC", "%X", +__LINE__, 0xffc8752f, "ffc8752f", "%-x", +__LINE__, 0xfffffe6d, "FFFFFE6D", "%2.X", +__LINE__, -0x377f1a5, "-58192293", "% .2d", +__LINE__, -0x0000294, "-660", "%d", +__LINE__, 0xfffffffe, "fffffffe", "%-x", +__LINE__, 0xfffcbbe8, "0xfffcbbe8", "%-#4.x", +__LINE__, 0x0022e510, "+2286864", "%+ld", +__LINE__, 0xfffffe2a, "FFFFFE2A", "%0.3X", +__LINE__, 0xfe29f7c0, "fe29f7c0", "%x", +__LINE__, 0xfffe957e, "FFFE957E", "%X", +__LINE__, 0x000080f8, "33016", "%ld", +__LINE__, 0x0003ee2c, " 257580", "%7d", +__LINE__, 0x000003a1, "929", "%d", +__LINE__, 0x0000021f, "21f", "%+x", +__LINE__, 0xffffffff, "ffffffff", "%.5x", +__LINE__, -0x040a988, "-4237704", "%-d", +__LINE__, 0x027c8b69, "41716585", "%ld", +__LINE__, 0x00000003, "3", "%-X", +__LINE__, -0x0000368, " -872", "%7.d", +__LINE__, 0x00000d3c, "3388", "%0.2d", +__LINE__, -0x33734cc, "-53949644", "%2ld", +__LINE__, 0x000003db, "3DB", "%X", +__LINE__, -0x00f154d, "-988493", "%5d", +__LINE__, 0x0000000b, " 11", "%4.ld", +__LINE__, 0x00000067, "103", "%-ld", +__LINE__, -0x0199fce, "-1679310", "%4d", +__LINE__, 0x02b6266b, "2b6266b", "% x", +__LINE__, -0x006b39d, "-439197", "%+d", +__LINE__, 0x00000007, "7", "%ld", +__LINE__, 0x0141fc98, "21101720", "%0ld", +__LINE__, -0x0008420, "-33824", "%d", +__LINE__, 0x0011622b, "1139243", "%6ld", +__LINE__, 0x0000001b, "27", "%-d", +__LINE__, -0x0030935, "-198965", "%3d", +__LINE__, 0x0000001f, " 1f", "%4.x", +__LINE__, -0x10782a19, "-276310553", "%#ld", +__LINE__, -0x007eac4, "-518852", "%06.ld", +__LINE__, 0x0bc4c681, "197445249", "%6ld", +__LINE__, 0x000000f5, "245", "%.3ld", +__LINE__, 0x00000197, "197", "%X", +__LINE__, 0xfffffeab, "FFFFFEAB", "% X", +__LINE__, 0x00000f05, "F05", "%+X", +__LINE__, 0xffe1b785, "0xffe1b785", "%#x", +__LINE__, -0x02d3581, "-2962817", "%05d", +__LINE__, 0xffffb994, "FFFFB994", "%X", +__LINE__, 0x03d139a3, "64043427", "%ld", +__LINE__, -0x0000002, " -2", "%+4.d", +__LINE__, -0x043da83, "-4446851", "%#ld", +__LINE__, -0x6aad891, "-111859857", "%7.ld", +__LINE__, 0x00003e68, "15976", "%-4.5ld", +__LINE__, 0xffe4d3ee, "FFE4D3EE", "%X", +__LINE__, 0x00000002, "000002", "%4.6ld", +__LINE__, 0xffffee32, "ffffee32", "%4x", +__LINE__, 0x0cb7dd25, "cb7dd25", "%3x", +__LINE__, 0xf773d422, "F773D422", "%X", +__LINE__, -0x0b590f7, "-11899127", "%#d", +__LINE__, -0x0002c45, "-11333", "%-#5ld", +__LINE__, -0x1efc9e4, "-32492004", "%ld", +__LINE__, -0x0003b9c, "-15260", "%d", +__LINE__, 0x000001b6, "0X1B6", "%#4X", +__LINE__, 0x3ce93ec3, "1021918915", "%.6d", +__LINE__, 0xffffffff, "ffffffff", "%-x", +__LINE__, 0xfffaf0e4, "fffaf0e4", "%2.x", +__LINE__, 0x00000002, "0x2", "%#x", +__LINE__, 0x0000e806, "e806", "%4x", +__LINE__, 0xfffffff0, "fffffff0", "% 2.x", +__LINE__, 0xfffffc0e, "fffffc0e", "%+.4x", +__LINE__, 0xfd45716e, "FD45716E", "%.4X", +__LINE__, 0xfff96fda, "FFF96FDA", "%-X", +__LINE__, 0xff99d08a, "FF99D08A", "%.5X", +__LINE__, 0x00000002, "2", "%-00.d", +__LINE__, -0x000000f, " -15", "%6.ld", +__LINE__, -0x00d321c, "-864796", "%#1ld", +__LINE__, 0xff19ff8d, "ff19ff8d", "%1.5x", +__LINE__, 0x00000000, "0000000", "%-.7x", +__LINE__, 0x0000f50d, " F50D", "%5X", +__LINE__, 0x00001688, " 5768", "%7.ld", +__LINE__, 0x00000157, "343", "%2ld", +__LINE__, 0xfffffffd, "0xfffffffd", "%+#3x", +__LINE__, 0x00000d52, "3410", "%ld", +__LINE__, 0x00000003, "3", "%d", +__LINE__, 0x0001c6d2, "01c6d2", "%.6x", +__LINE__, 0x242d65d2, "606954962", "%#7.ld", +__LINE__, 0x00000e9f, "0000E9F", "%5.7X", +__LINE__, 0x0002d785, "2D785", "%0X", +__LINE__, 0x00000167, "167", "%0X", +__LINE__, 0xfffff5e5, "fffff5e5", "% x", +__LINE__, 0xffb69a04, "0xffb69a04", "%#0.x", +__LINE__, 0xfffa012e, "FFFA012E", "%X", +__LINE__, 0x0000001a, "0x1a", "% #x", +__LINE__, 0xfffb26d3, "fffb26d3", "%+x", +__LINE__, -0x00003e6, " -998", "%7ld", +__LINE__, 0x00000004, "4", "%-d", +__LINE__, 0xfffffd76, "0XFFFFFD76", "%#7X", +__LINE__, 0x00000035, "53", "%ld", +__LINE__, 0xffc6c190, "0XFFC6C190", "%#X", +__LINE__, 0xffffffe2, "ffffffe2", "%7.0x", +__LINE__, 0x03ff1b87, "67050375", "%2.d", +__LINE__, 0x00020c47, "0X20C47", "%#X", +__LINE__, 0x00000000, "0", "%d", +__LINE__, 0x0000000e, "0X000E", "% #.4X", +__LINE__, -0x00035cd, "-13773", "%+2.d", +__LINE__, 0x00005eec, "5eec", "%1x", +__LINE__, 0x001da0ff, "1941759", "%0d", +__LINE__, 0xf8a9e96a, "f8a9e96a", "%+x", +__LINE__, -0x0000120, "-288 ", "%-#6.d", +__LINE__, 0x00000000, "0", "%-X", +__LINE__, 0x0000152e, "152E", "%+X", +__LINE__, -0x0001077, "-4215", "% 0d", +__LINE__, 0xffffffd7, "FFFFFFD7", "%0X", +__LINE__, 0xfffe097d, "FFFE097D", "%2X", +__LINE__, 0xcb982712, "cb982712", "%x", +__LINE__, 0xfff39f2e, "FFF39F2E", "%.5X", +__LINE__, -0x0058cae, "-363694", "%+.1d", +__LINE__, -0x000002b, "-043", "%#1.3d", +__LINE__, -0x001e989, "-125321", "%1d", +__LINE__, 0x00959ecd, "9805517", "%d", +__LINE__, 0xf49df846, "F49DF846", "%+3X", +__LINE__, 0xfffffffd, "fffffffd", "%+.5x", +__LINE__, -0x000ac76, "-44150", "%3.ld", +__LINE__, 0x00000028, " 0028", "%06.4x", +__LINE__, 0x000003e8, "3E8", "%-02X", +__LINE__, 0x00000012, "012", "%.3X", +__LINE__, 0x00000006, "0X6", "%#X", +__LINE__, 0x00ef8479, "+15697017", "%+0.6d", +__LINE__, 0xffffffe8, "FFFFFFE8", "%-X", +__LINE__, 0x773a90f7, "773a90f7", "%3.5x", +__LINE__, 0x00096d44, "96D44", "%-X", +__LINE__, -0x08a3d96, "-9059734", "%ld", +__LINE__, -0x000001a, "-26", "%00.ld", +__LINE__, 0x32f57585, "32f57585", "% x", +__LINE__, 0x2825f175, "2825F175", "%X", +__LINE__, 0x000054ff, "21759", "%-2d", +__LINE__, -0x0266cdc, "-2518236", "%ld", +__LINE__, 0x0000031d, "0X31D", "%+#4X", +__LINE__, 0x0003fc99, "3fc99", "%x", +__LINE__, -0x0064624, "-411172", "%-#d", +__LINE__, 0x0001b2d9, "111321", "%-ld", +__LINE__, -0x000007c, "-124", "%#d", +__LINE__, 0xfffffffa, "FFFFFFFA", "%+X", +__LINE__, -0x007a5b8, "-501176", "%+ld", +__LINE__, 0x0213b583, "213B583", "%2.X", +__LINE__, 0xfff12e51, "FFF12E51", "%+X", +__LINE__, 0x00052403, "0336899", "%-0.7d", +__LINE__, 0xffffffff, "ffffffff", "%-04.4x", +__LINE__, 0x00000010, "0010", "%0.4X", +__LINE__, 0xffffffb5, "FFFFFFB5", "%-1.3X", +__LINE__, -0x0000001, "-1", "%d", +__LINE__, 0x0003a2d1, "3a2d1", "% x", +__LINE__, 0x00000424, "1060", "%0ld", +__LINE__, -0x0000078, "-120", "%1d", +__LINE__, 0x00000000, "0", "%ld", +__LINE__, 0x00000414, "1044", "%ld", +__LINE__, 0x00000072, "0x072", "%#5.3x", +__LINE__, 0x0000007a, "7A", "% X", +__LINE__, 0x081542a3, "135611043", "%0d", +__LINE__, 0xfffb4ce6, "fffb4ce6", "%4.6x", +__LINE__, 0x00002ab2, "2ab2", "%-1x", +__LINE__, 0x00000000, " 0", "% 2x", +__LINE__, 0xfffffa59, "FFFFFA59", "%2.X", +__LINE__, 0xffffe22b, "ffffe22b", "%-x", +__LINE__, 0xfffffd52, "FFFFFD52", "%+.2X", +__LINE__, 0x0000039f, "927", "%-d", +__LINE__, 0x0002dea6, "2dea6", "%0x", +__LINE__, 0x000216db, "136923", "%ld", +__LINE__, 0x00000013, "19", "%0d", +__LINE__, 0x000047cc, "18380", "%2.2ld", +__LINE__, -0x0007d10, "-32016", "%d", +__LINE__, 0xff9af906, "FF9AF906", "%0X", +__LINE__, 0x02cfa224, "+47161892", "%+0.7d", +__LINE__, -0x0000022, "-34", "%1.d", +__LINE__, 0xfffffff0, "FFFFFFF0", "%-4X", +__LINE__, 0x00000029, " 41", "%6.ld", +__LINE__, 0xffffff76, "ffffff76", "%x", +__LINE__, 0x00000000, "0", "%+X", +__LINE__, 0x00000001, "1", "%d", +__LINE__, 0xfff6de5a, "FFF6DE5A", "%X", +__LINE__, 0x00000002, "2", "%ld", +__LINE__, 0x00000025, "25", "%+x", +__LINE__, 0xfffffffb, "FFFFFFFB", "%5.0X", +__LINE__, 0x0011bbb5, "1162165", "%0.0ld", +__LINE__, 0xfffcdc96, "0XFFFCDC96", "%#X", +__LINE__, 0x00008f5f, "8f5f", "%3.1x", +__LINE__, 0xffa0fa5d, "0XFFA0FA5D", "%#X", +__LINE__, 0x00004534, "4534", "% 0X", +__LINE__, 0xfffffff9, "fffffff9", "%.2x", +__LINE__, 0xffeeae50, "ffeeae50", "%-x", +__LINE__, 0x00002964, " 0010596", "% 0.7d", +__LINE__, 0x000021c9, " 21c9", "%6x", +__LINE__, 0x00000001, " 1", "% d", +__LINE__, 0x0002abd8, "+175064", "%+d", +__LINE__, 0xffffffad, "FFFFFFAD", "%+0X", +__LINE__, 0x00000003, "3", "%ld", +__LINE__, 0x0c036da3, " 201551267", "% .3d", +__LINE__, -0x004343c, "-275516", "%+ld", +__LINE__, 0x00000003, "003", "% .3x", +__LINE__, 0xffffe34e, "ffffe34e", "%x", +__LINE__, 0x0000e118, "e118", "%x", +__LINE__, -0x007d945, "-514373", "%+#0ld", +__LINE__, 0x277f1cc5, "277f1cc5", "% x", +__LINE__, 0x00003bef, "03bef", "% 0.5x", +__LINE__, 0xfffffcb9, "fffffcb9", "%x", +__LINE__, 0x0003311a, "209178", "%ld", +__LINE__, 0x00000000, " ", "%3.ld", +__LINE__, 0x05942225, "5942225", "%x", +__LINE__, 0xfffceb4c, "FFFCEB4C", "%-X", +__LINE__, 0xffd08633, "ffd08633", "%2.x", +__LINE__, -0x0000001, " -1", "%6d", +__LINE__, 0x000fdb12, "1039122", "%d", +__LINE__, 0x00000003, "3", "% 0X", +__LINE__, -0x2fd5bf1, "-50158577", "% 5.ld", +__LINE__, -0x0089a03, "-563715", "%-d", +__LINE__, 0xfffffffe, "FFFFFFFE", "% X", +__LINE__, 0x29fdb2ba, "29fdb2ba", "% 0x", +__LINE__, 0x0000008f, "8F", "% X", +__LINE__, 0x00000003, "3", "%ld", +__LINE__, 0xffc58445, "FFC58445", "%.2X", +__LINE__, -0x00023f6, "-9206", "%+d", +__LINE__, 0x00000011, "11", "%X", +__LINE__, -0x0000003, "-0000003", "%-.7d", +__LINE__, -0x0000003, "-3", "%#ld", +__LINE__, 0x001242d9, "1242D9", "%X", +__LINE__, -0x48d0c81, "-76352641", "%7.d", +__LINE__, -0x001b675, "-112245", "%#ld", +__LINE__, 0x00000003, "3", "%-d", +__LINE__, 0xfff93fdf, "0XFFF93FDF", "% #X", +__LINE__, 0x001a9414, "1741844", "%#ld", +__LINE__, 0x0001fd86, "130438", "%ld", +__LINE__, 0x010f37a8, "17774504", "%4.7d", +__LINE__, 0x00382838, "0382838", "%3.7X", +__LINE__, -0x47fd56c2, "-1207785154", "%ld", +__LINE__, 0x001981dd, "1981dd", "%x", +__LINE__, 0xffffefba, "ffffefba", "% 06.x", +__LINE__, -0x3f402b29, "-1061169961", "%+#ld", +__LINE__, -0x395aae44, "-962244164", "%-1d", +__LINE__, 0x1fa39f42, "530816834", "%#d", +__LINE__, -0x000358d, "-13709", "%d", +__LINE__, -0xdc17b8f, "-230783887", "%ld", +__LINE__, -0x23c41583, "-600053123", "%+3.d", +__LINE__, 0xfffffc16, "fffffc16", "%x", +__LINE__, 0x003f1364, "4133732", "%7.ld", +__LINE__, 0xffffe691, "FFFFE691", "%07X", +__LINE__, 0x07b31d71, "129178993", "%.7d", +__LINE__, -0x0019732, "-104242", "% ld", +__LINE__, 0x02428167, "0x2428167", "%#x", +__LINE__, -0x06c1ecd, "-7085773", "%.7ld", +__LINE__, 0xfb01cb4e, "fb01cb4e", "%x", +__LINE__, 0x00005a41, "+23105", "%+ld", +__LINE__, 0xfffffff4, "FFFFFFF4", "%-5.X", +__LINE__, 0x00000005, " 5", "%4.ld", +__LINE__, 0xf4ab4b2d, "F4AB4B2D", "%0.X", +__LINE__, -0x000fce3, "-64739", "%+#3.ld", +__LINE__, 0x000076ea, " 30442", "%6.2ld", +__LINE__, 0x00000cb9, " cb9", "%4.x", +__LINE__, 0x002f43ef, "3097583", "%1.1ld", +__LINE__, 0xf5bd0105, "F5BD0105", "%+X", +__LINE__, 0x0037954a, "3642698", "%d", +__LINE__, 0xfffffff7, "0XFFFFFFF7", "%-#X", +__LINE__, 0xffffcedf, "0xffffcedf", "%#6.7x", +__LINE__, 0xfffffde4, "FFFFFDE4", "%2.4X", +__LINE__, 0x01a6f103, "1a6f103", "%5.x", +__LINE__, 0x00000191, " 191", "%7.0X", +__LINE__, 0x00000003, "03", "% .2X", +__LINE__, -0xd4e3219, "-223228441", "%6.ld", +__LINE__, 0x00b0efbd, "11595709", "%d", +__LINE__, -0x00000ea, "-234", "%#3d", +__LINE__, 0x00000be8, "BE8 ", "%-5X", +__LINE__, 0xffffffff, "ffffffff", "%5.3x", +__LINE__, -0x267f8c6, "-40368326", "%d", +__LINE__, 0x000006ed, "6ED", "%X", +__LINE__, 0xfdd6c9b6, "FDD6C9B6", "%X", +__LINE__, 0x0007ac29, "7ac29", "%-x", +__LINE__, 0x00000014, "14", "%2x", +__LINE__, 0x123ca563, "+305964387", "%+ld", +__LINE__, 0x00000004, " 4", "%5.d", +__LINE__, 0xffff877a, "ffff877a", "%x", +__LINE__, -0x00003e7, "-999", "%+0.3d", +__LINE__, 0x0a68ba6e, "a68ba6e", "%3.1x", +__LINE__, 0xfe29c810, "FE29C810", "%+X", +#endif + +__LINE__, 0x00000000, "0", "%o", +__LINE__, 0000000123, "123", "%o", +__LINE__, 0000123456, "0123456", "%#o", +__LINE__, 0000123456, "00123456", "%#.8o", +__LINE__, 0000123456, " 00123456", "%#10.8o", +__LINE__, 0x00000123, "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++) { + 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); + } + 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/gnu/lib/libg++/libio/tests/tiomanip.cc b/gnu/lib/libg++/libio/tests/tiomanip.cc new file mode 100644 index 00000000000..b7dd08a4618 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libio/tests/tiomanip.exp b/gnu/lib/libg++/libio/tests/tiomanip.exp new file mode 100644 index 00000000000..7a0a7ea5cb2 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/tiomanip.exp @@ -0,0 +1,4 @@ +1234 4d2 2322 +(**12) +(12) +(-***12) diff --git a/gnu/lib/libg++/libio/tests/tiomisc.cc b/gnu/lib/libg++/libio/tests/tiomisc.cc new file mode 100644 index 00000000000..80964121589 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/tiomisc.cc @@ -0,0 +1,200 @@ +/* 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) +{ + 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 +} + +int main( ) +{ + test1 (); + test2 (); + test3 (); + getline_test1 (); + getline_test2 (); + getline_test3 (); + flush1_test (); + reread_test (); + test_destroy (); + return 0; +} diff --git a/gnu/lib/libg++/libio/tests/tiomisc.exp b/gnu/lib/libg++/libio/tests/tiomisc.exp new file mode 100644 index 00000000000..c62e61fec44 --- /dev/null +++ b/gnu/lib/libg++/libio/tests/tiomisc.exp @@ -0,0 +1,10 @@ +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 diff --git a/gnu/lib/libg++/libio/tests/tstdiomisc.c b/gnu/lib/libg++/libio/tests/tstdiomisc.c new file mode 100644 index 00000000000..1c15b75a709 --- /dev/null +++ b/gnu/lib/libg++/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, 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/gnu/lib/libg++/libio/tests/tstdiomisc.exp b/gnu/lib/libg++/libio/tests/tstdiomisc.exp new file mode 100644 index 00000000000..b8ee02dcd6a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/librx/COPYING.LIB b/gnu/lib/libg++/librx/COPYING.LIB new file mode 100644 index 00000000000..eb685a5ec98 --- /dev/null +++ b/gnu/lib/libg++/librx/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/gnu/lib/libg++/librx/ChangeLog b/gnu/lib/libg++/librx/ChangeLog new file mode 100644 index 00000000000..34b4e9990f7 --- /dev/null +++ b/gnu/lib/libg++/librx/ChangeLog @@ -0,0 +1,284 @@ +Wed Oct 4 12:10:39 1995 Ian Lance Taylor + + * configure.in: If using GCC, assume we always have alloca. This + works around problems with broken cross setups. Use + AC_FUNC_ALLOCA rather than AC_ALLOCA. + * configure: Rebuild. + +Wed Sep 20 13:55:42 1995 Ian Lance Taylor + + * Makefile.in (maintainer-clean): New synonym for realclean. + +Mon Jun 19 00:33:22 1995 Jason Merrill + + * Makefile.in: Massage broken shells that require 'else true'. + +Sun Jun 18 23:24:00 1995 Per Bothner + + * Makefile.in (distclean): Also remove config.cache and config.log. + +Thu Jun 8 22:42:58 1995 Jason Merrill + + * configure.in: Add support for PIC flag configuration. + * configure: Regenerate. + * Makefile.in: Adjust accordingly. + +Mon Jun 5 18:46:06 1995 Jason Merrill + + * Makefile.in (PICFLAG): New macro. + (rx.o): Depend on stamp-picdir. + (.c.o): Also build pic object. + (stamp-picdir): New rule. + (clean): Remove pic and stamp-picdir. + +Tue May 23 12:11:28 1995 Per Bothner + + * rx.c (regcomp and other POSX.2 functions): Leave them out for + now, because they conflict with Motif on HPUX. + + * rx.c (re_syntax_table): Only declare #ifndef RX_WANT_RX_DEFS; + otherwise we duplicate the declaration in rx.h. + * rx.c (re_search_2_fetch_char): Add missing cast. + +Sun Apr 2 23:24:52 1995 Tom Lord + + * rx.h (rx_search): check for and propogate internal + errors correctly (bogus check sometimes mistook ok returns + for internal errors). + +Sun Feb 12 19:28:22 1995 Tom Lord (lord@x1.cygnus.com) + + * rx.h (rx_search): + From: hankedr@duc.auburn.edu (Darrel Hankerson) + 2. I have some problems understanding the code which sets + search_state.free_chunks=0. It appears to me that since this is used + to track alloca'd mem, that it should be done once at the top of + rx_search(). Indeed, this also fixes the problem in the tests I'm + running, but I don't have confidence in this "solution". + [looks right to me. -tl] + + + * rx.c: Two reported by kwzh. + + (re_search_2_get_burst): in the two string case, + when computing `inset', add in pos->offset. + + (re_search_2_fetch_char): watch for the case when + pos is just to the left of the second string, pos refers + to the second string, but the first string is provided. + This can happen at the very beginning of a match when the + first thing after matching the priming character is a side + effect like re_se_wordend. + + * rx.h (rx_search): patches (marked by /*|*/) + from From: hjl@nynexst.com (H.J. Lu). One fixes a clear + bug in a loop termination test. The other i'm not sure about + yet, but it doesn't break the sed tests. + + * rx.c (re_compile_pattern): + Initialize buf.rx.cset_size. + (Fixes problem report from Kayvan Sylvan ) + + * rx.c (#define RX_DECL): cleaned up handling of this macro. + + * rx.c (re_comp): + From hjl@nynexst.com + Define _GNU_SOURCE. + Test for USE_BSD_REGEX around teh BSD entry points. + Under BSD, treat the empty-string pattern like the NULL pattern. + Also under BSD, rx_syntax_options --> re_syntax_options. + Also, rx_exec --> re_exec and rx_registers --> re_registers. + + + * rx.c (rx_compile): + From: kwzh@gnu.ai.mit.edu (Karl Heuer) + The `\sX' handler ends with `goto append_node' but without setting + the `append' variable first. This patch should fix it. + + + * rx.c (regcomp): explicitly zero the field syntax_parens. + Reported/fix suggested by Morten Holmqvist . + + * rx.h (changes under and around ifdef emacs): + From: kwzh@gnu.ai.mit.edu (Karl Heuer) + Here's a patch (for 0.06) to fix most of the other problems I + mentioned. Some of the cpp conditionals in rx.h were ending at + the wrong place and/or were incorrectly commented; fixing these + took care of some of the missing declarations. + + (fastmap_search): unnecessary defaults to switch statements + to shut-up "gcc -Wall". + +Thu Nov 24 18:39:42 1994 Tom Lord (lord@x1.cygnus.com) + These fixes let's rx pass the spencer.tests from grep. + + * rx.h (rx_search): moved slightly out of date debugging + code from RX_DEBUG to RX_DEBUG_0. + + * rx.h (rx_search): in the outer loop, if get_burst returns + that there are no more characters, consider the possibility + of an empty match before failing. + + * rx.h (rx_search): when computing search_end, don't waste + time computing MIN and MAX of values already forced into range. + + * rx.h (rx_search): when making RANGE fit within TOTAL_SIZE, + don't forget to allow the possible empty match at the end of + string. + + * rx.c (is_anchored): the equations solving side-effect + anchoring were wrong for the r_alternate case. The interesting + thing about this bug is that it disguises itself as a precedent + bug between | and ^ because of an optimization in the search + function that checks rxb->begbuf_only (a return value of is_anchored). + + * rx.c: Fix the print-name rx_se_win (missing comma). + Fix the function print_cset to print non-printable characters + as octal. + +Sat Nov 5 20:01:46 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (LIBCFLAGS): New variable. + (.c.o): Use it. + +Thu Sep 1 16:23:21 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.c: applied patches from H J Lu to unrot BSD compatibility + code. + +Mon Aug 29 16:48:57 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * Makefile.in (AR_FLAGS): Define. + (librx.a): Use $(AR) and $(AR_FLAGS). + +Fri Aug 26 11:37:36 1994 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: Call AC_PROG_CPP explicitly. + * configure: Rebuilt. + +Thu Aug 25 18:19:47 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.[ch], configure.in: use __const__ instead of + AC_CONST. Only include stdio once. Don't check + for memory.h. + +Tue Aug 16 12:12:01 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.[ch]: LGPL instead of GPL + +Mon Aug 15 16:24:16 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * rx.h (rx_search): When checking if we've gotten to the end, + handle the case that we're searching backwards. + +Tue Jun 21 12:40:50 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * rx.c (re_rx_search): New function, exports rx_search. + + * Makefile.in (clean): Also remove librx.a. + +Fri Jun 3 12:16:45 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.c(re_search_2_fetch_char): fixed a bug that caused it to + ignore OFFSET. + +Thu May 26 14:05:17 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.[ch]: From: Michael Rendell + + ``The problem seems to lie in the casting between pointers and + integers (pointers on the alpha are 64 bits, ints 32 bits, longs + 64 bits). The core dump happens in rx_compactify_nfa(), in the + first for loop in the while(eclose) loop -- rx_hash_find() returns + 0, which is dereferenced.'' + + The patch changed the type of rx_hash_masks to long and + also a use of `int' to hold a side effect in rx_search. + +Sat May 14 00:45:14 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.c, rx.h: rearranged all the code + so that all the rx functions can be exported + or hidden (define RX_WANT_RX_DEFS when compiling + and when including rx.h). + +Wed May 11 01:15:56 1994 Tom Lord (lord@rtl.cygnus.com) + + * rx.c, rx.h: added rx_search -- searching in + arbitrarily fragmented strings, continuation support. + +Wed May 4 13:56:55 1994 Tom Lord (lord@rtl.cygnus.com) + + * rx.c, rx.h: Started independent maintainence + of these. + +------ version 0.04 ------ + +Fri May 13 02:31:13 1994 Tom Lord (lord@x1.cygnus.com) + + * rx.c: eliminated the weirdo custom allocators. + Fixed some bugs (but lost the ChangeLog entries). + +Wed May 11 06:09:31 1994 Chip Salzenberg (chip@fin.uucp) + + * rx.c (rx_superstate_eclosure_union): Always return a value. + +------ version 0.03 ------ +Fri Aug 6 01:57:28 1993 Tom Lord (lord@unix1.andrew.cmu.edu) + + * rx.c (re_search_2): sped up the fastmap search a little + to as to not be slower than regex.c on simple patterns. + Rx will still lose by a couple instructions in some degenerate + cases but mostly will win. + +Thu Aug 5 11:39:57 1993 Tom Lord (lord@thisbe.weh.andrew.cmu.edu) + + * rx.c (re_search_2 & compilation front-ends): cache the starting + superset of super-nfa's so that it isn't necessary to do an + eclosure union for every call to re_search_2. + + * rx.c (re_search_2): (from Eric Backus) arrange to call + alloca(0) from a shallower stack frame than re_search_2 + if callling it at all. + + This could use a better cpp test. Right now, an extra function + call is added to re_search_2 unles __GNUC__ is defined. If + there were something like _HAVE_LOSER_ALLOCA_.... + + * rx.c (rx_compile, re_search_2, several new fns): + changed the order of side effect lists so that possible + futures that begin with complex effects more to the right + are explored after futures more to the left. Added + a noop complex effect to alts and stars to guarantee + they are explored in the right order. An optimization + after the parse removes some from the alts (and not all + stars get them in the first place). Changed the `best + match' criterea -- now that possible futures are ordered + posixly, we only want to check the length of the match. + For a given length, the best subexpression partitioning + is the first one found. + + A side effect of this is that Rx will always return the + same register assignements for a given regexp/input text. + Bummer :-) / 2. + + +------ version 0.02 ------ + +ed Jul 21 13:10:56 1993 Tom Lord (lord@unix8.andrew.cmu.edu) + + * rx.c (re_search_2): elaborated on the rule for picking the + best match so that the lengths of subexpressions are taken + into account. This is for Posix compatability. + + +------ version 0.01 ------ + +Sun Jun 13 17:20:35 1993 Tom Lord (lord@tsunami.ucc.andrew.cmu.edu) + + * This is the first release of rx.c. Although some of the code + is derived from regex.c, there is not much continuity between + the two implementations. + + + diff --git a/gnu/lib/libg++/librx/DOC b/gnu/lib/libg++/librx/DOC new file mode 100644 index 00000000000..dce6e2e10a4 --- /dev/null +++ b/gnu/lib/libg++/librx/DOC @@ -0,0 +1,179 @@ +Most of the interfaces are covered by the documentation for GNU regex. + +This file will accumulate factoids about other interfaces until +somebody writes a manual. + + +* Don't Pass Registers Gratuitously + +Search and match functions take an optional parameter which is a +pointer to "registers" or "match positions". This parameter points +to a structure which during the match is filled in with the offset locations +of parenthesized subexpressions. + +Unless you specificly need the values that would be stored in that +structure, you should pass NULL for this parameter. Usually Rx will +do less backtracking (and so run much faster) if subexpression +positions are not being measured. + + +* Use syntax_parens + +Sometimes you need to know the positions of *some* parenthesized +subexpressions, but not others. You can still help Rx to avoid +backtracking by telling it specificly which subexpressions you are interested +in. You do this by filling in the rxb.syntax_parens field of +a pattern buffer. + + /* If this is a valid pointer, it tells rx not to store the extents of + * certain subexpressions (those corresponding to non-zero entries). + * Passing 0x1 is the same as passing an array of all ones. Passing 0x0 + * is the same as passing an array of all zeros. + * The array should contain as many entries as their are subexps in the + * regexp. + */ + char * syntax_parens; + + +* RX_SEARCH + +For an example of how to use rx_search, you can look at how +re_search_2 is defined (in rx.c). Basicly you need to define three +functions. These are GET_BURST, FETCH_CHAR, and BACK_REF. They each +operate on `struct rx_string_position' and a closure of your design +passed as void *. + + struct rx_string_position + { + const unsigned char * pos; /* The current pos. */ + const unsigned char * string; /* The current string burst. */ + const unsigned char * end; /* First invalid position >= POS. */ + int offset; /* Integer address of current burst */ + int size; /* Current string's size. */ + int search_direction; /* 1 or -1 */ + int search_end; /* First position to not try. */ + }; + +On entry to GET_BURST, all these fields are set, but POS may be >= +END. In fact, STRING and END might both be 0. + +The function of GET_BURST is to make all the fields valid without +changing the logical position in the string. SEARCH_DIRECTION is a +hint about which way the matcher will move next. It is usually 1, and +is -1 only when fastmapping during a reverse search. SEARCH_END +terminates the burst. + + typedef enum rx_get_burst_return + (*rx_get_burst_fn) (struct rx_string_position * pos, + void * app_closure, + int stop); + + +The closure is whatever you pass to rx_search. STOP is an argument to +rx_search that bounds the search. You should never return a string +position from with SEARCH_END set beyond the position indicated by +STOP. + + + enum rx_get_burst_return + { + rx_get_burst_continuation, + rx_get_burst_error, + rx_get_burst_ok, + rx_get_burst_no_more + }; + +Those are the possible return values of get_burst. Normally, you only +ever care about the last two. An error return indicates something +like trouble reading a file. A continuation return means suspend the +search and resume by retrying GET_BURST if the search is restarted. + +GET_BURST is not quite as trivial as you might hope. If you have a +fragmented string, you really have to keep two adjacent fragments at +all times, even though the GET_BURST interface looks like you only +need one. This is because of operators like `word-boundary' that try +to look at two adjacent characters. Such operators are implemented +with FETCH_CHAR. + + typedef int (*rx_fetch_char_fn) (struct rx_string_position * pos, + int offset, + void * app_closure, + int stop); + +That takes the same closure passed to GET_BURST. It returns the +character at POS or at one past POS according to whether OFFSET is 0 +or 1. + +It is guaranteed that POS + OFFSET is within the string being searched. + + + +The last function compares characters at one position with characters +previously matched by a parenthesized subexpression. + + enum rx_back_check_return + { + rx_back_check_continuation, + rx_back_check_error, + rx_back_check_pass, + rx_back_check_fail + }; + + typedef enum rx_back_check_return + (*rx_back_check_fn) (struct rx_string_position * pos, + int lparen, + int rparen, + unsigned char * translate, + void * app_closure, + int stop); + +LPAREN and RPAREN are the integer indexes of the previously matched +characters. The comparison should translate both characters being +compared by mapping them through TRANSLATE. POS is the point at which +to begin comparing. It should be advanced to the last character +matched during backreferencing. + +* Compilation Stages + +In rx_compile, a string is compiled into a pattern buffer. +Compilation proceeds in these stages: + + 1. Make a syntax tree for the regexp. + 2. Duplicate the syntax tree and make both trees nodes + in a single unifying tree. + 3. In one of the two trees, remove all side effects that + aren't needed to test for the possibility of a match. + Such side effects include the filling in of output registers + for subexpressions that are not backreferenced. + 4. Optimize the unifying tree. + 5. Translate the tree to an NFA. + 6. Analyze and optimize the NFA. + 7. Copy the NFA into a contiguous region of memory. + + +* Cache Size + +During a search or match, the NFA is translated into a "super NFA". +A super NFA can match the patterns of the corresponding NFA in no more +and often fewer steps. + +The catch is that the super NFA may be costly to construct in its entirety; +it may not even fit in memory. So, states of the NFA are constructed +on demand and discarded after a period of non-use. They are kept in a cache +so that time is not wasted constructing existing nodes twice. + +The size of the super state NFA cache is a contributing factor the performance +of Rx. The larger the cache (to a point) the faster Rx can run. The +variable rx_cache_bound is an upper limit on the number of superstates +that can exist in the cache. + +The defaulting setting is 128. GNU sed uses 4096. Neither setting +has much justification although sed's is after a small number of quick +and dirty experiments. The memory consumed by one superstate is +between 4k and 8k. The cache only grows to its bounded size if there +is actual demand for that many states. Sed's setting, for example, +may appear quite high but in practice that much memory is hardly ever +used. The default setting was chosen based on the heuristic that a +megabyte is the upper limit on what a good citizen library can +allocate without special arrangement. + diff --git a/gnu/lib/libg++/librx/INSTALL b/gnu/lib/libg++/librx/INSTALL new file mode 100644 index 00000000000..ce41427b1b7 --- /dev/null +++ b/gnu/lib/libg++/librx/INSTALL @@ -0,0 +1,90 @@ +See also `INSTALL.rx' + +This is a generic INSTALL file for utilities distributions. +If this package does not come with, e.g., installable documentation or +data files, please ignore the references to them below. + +To compile this package: + +1. Configure the package for your system. In the directory that this +file is in, type `./configure'. 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. + +The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation, and +creates the Makefile(s) (one in each subdirectory of the source +directory). In some packages it creates a C header file containing +system-dependent definitions. It also creates a file `config.status' +that you can run in the future to recreate the current configuration. +Running `configure' takes a minute or two. + +To compile the package in a different directory from the one +containing the source code, you must use GNU make. `cd' to the +directory where you want the object files and executables to go and +run `configure' with the option `--srcdir=DIR', where DIR is the +directory that contains the source code. Using this option is +actually unnecessary if the source code is in the parent directory of +the one in which you are compiling; `configure' automatically checks +for the source code in `..' if it does not find it in the current +directory. + +By default, `make install' will install the package's files in +/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify +an installation prefix other than /usr/local by giving `configure' the +option `--prefix=PATH'. Alternately, you can do so by changing the +`prefix' variable in the Makefile that `configure' creates (the +Makefile in the top-level directory, if the package contains +subdirectories). + +You can specify separate installation prefixes for machine-specific +files and machine-independent files. If you give `configure' the +option `--exec_prefix=PATH', the package will use PATH as the prefix +for installing programs and libraries. Normally, all files are +installed using the same prefix. + +`configure' ignores any other arguments that you give it. + +If your system requires unusual options for compilation or linking +that `configure' doesn't know about, you can give `configure' initial +values for some variables by setting them in the environment. In +Bourne-compatible shells, you can do that on the command line like +this: + CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure + +The `make' variables that you might want to override with environment +variables when running `configure' are: + +(For these variables, any value given in the environment overrides the +value that `configure' would choose:) +CC C compiler program. + Default is `cc', or `gcc' if `gcc' is in your PATH. +INSTALL Program to use to install files. + Default is `install' if you have it, `cp' otherwise. +INCLUDEDIR Directory for `configure' to search for include files. + Default is /usr/include. + +(For these variables, any value given in the environment is added to +the value that `configure' chooses:) +DEFS Configuration options, in the form '-Dfoo -Dbar ...' +LIBS Libraries to link with, in the form '-lfoo -lbar ...' + +If you need to do unusual things to compile the package, we encourage +you to teach `configure' how to do them and mail the diffs to the +address given in the README so we can include them in the next +release. + +2. Type `make' to compile the package. + +3. Type `make install' to install programs, data files, and +documentation. + +4. You can remove the program binaries and object files from the +source directory by typing `make clean'. To also remove the +Makefile(s), the header file containing system-dependent definitions +(if the package uses one), and `config.status' (all the files that +`configure' created), type `make distclean'. + +The file `configure.in' is used as a template to create `configure' by +a program called `autoconf'. You will only need it if you want to +regenerate `configure' using a newer version of `autoconf'. diff --git a/gnu/lib/libg++/librx/INSTALL.rx b/gnu/lib/libg++/librx/INSTALL.rx new file mode 100644 index 00000000000..8f003f9e8a2 --- /dev/null +++ b/gnu/lib/libg++/librx/INSTALL.rx @@ -0,0 +1,8 @@ +For general installation instructions, see `INSTALL'. + +* Choice of compiler + +For reasonable performance, it is highly advisable to compile this +code with gcc using at least the `-O' level of optimization. + + diff --git a/gnu/lib/libg++/librx/Makefile.in b/gnu/lib/libg++/librx/Makefile.in new file mode 100644 index 00000000000..f3a314679b9 --- /dev/null +++ b/gnu/lib/libg++/librx/Makefile.in @@ -0,0 +1,114 @@ +# Makefile for librx +# Copyright (C) 1994 Free Software Foundation, Inc. +# +# This file is part of GNU Rx +# +# GNU Rx is free software; you can redistribute 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 Rx is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 SED; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +SHELL = /bin/sh + +srcdir = @srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +includedir = $(prefix)/include +infodir = $(prefix)/info + +#### Start of system configuration section. #### + +CC = @CC@ +INSTALL = @INSTALL@ +DEFS = @DEFS@ +CFLAGS = -g +LIBCFLAGS = $(CFLAGS) +AR = ar +AR_FLAGS = rc +RANLIB = @RANLIB@ +PICFLAG = + +# @target_frag@ + +source=rx.c +headers=rx.h +ancillery=configure.in Makefile.in configure \ + COPYING.LIB INSTALL INSTALL.rx ChangeLog DOC +distfiles=$(source) $(headers) $(ancillery) +libobjs=rx.o + +COMPILE.c = $(CC) -c $(LIBCFLAGS) $(DEFS) -I$(srcdir) +.c.o: + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.c) $(PICFLAG) $< -o pic/$@; \ + else true; fi + $(COMPILE.c) $< + +all: librx.a + +install: all + $(INSTALL) librx.a $(libdir)/librx.a + $(RANLIB) $(libdir)/librx.a + $(INSTALL) $(srcdir)/rx.h $(includedir)/rx.h + + +uninstall: + rm $(libdir)/librx.a + rm $(includedir)/rx.h + +clean: + -rm -rf $(libobjs) librx.a pic stamp-picdir + +distclean: clean + -rm Makefile config.status config.cache config.log + +mostlyclean: clean + +maintainer-clean realclean: distclean + +TAGS: + etags $(source) + +info: + +install-info: + +clean-info: + +dvi: + +check: + +dist: $(distfiles) + echo rx-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q rx.c` > .fname + rm -rf `cat .fname` + mkdir `cat .fname` + ln $(distfiles) `cat .fname` + tar chzf `cat .fname`.tar.gz `cat .fname` + rm -rf `cat .fname` .fname + + +librx.a: $(libobjs) + rm -f librx.a + $(AR) $(AR_FLAGS) librx.a rx.o + $(RANLIB) librx.a + +rx.o: stamp-picdir rx.c rx.h + +stamp-picdir: + if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \ + mkdir pic; \ + else true; fi + touch stamp-picdir diff --git a/gnu/lib/libg++/librx/configure b/gnu/lib/libg++/librx/configure new file mode 100644 index 00000000000..f164e0e51f7 --- /dev/null +++ b/gnu/lib/libg++/librx/configure @@ -0,0 +1,1316 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.4 +# Copyright (C) 1992, 1993, 1994 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 + +# Initialize some other variables. +subdirs= + +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 + + -build | --build | --buil | --bui | --bu | --b) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) + 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" ;; + + -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=PREFIX install architecture-dependent files in PREFIX + [same as prefix] + --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 +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 +--enable and --with options recognized:$ac_help +EOF + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$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 ;; + + -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 ;; + + -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" ;; + + -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.4" + 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=rx.c + +# 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 2>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&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 + + + +# 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 +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" + test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" +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 + + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&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 + if test "${CFLAGS+set}" != set; then + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_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_gcc_g=yes +else + ac_cv_prog_gcc_g=no +fi +rm -f conftest* + +fi + echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6 + if test $ac_cv_prog_gcc_g = yes; then + CFLAGS="-g -O" + else + CFLAGS="-O" + fi + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +# 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 +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&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 + +# 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 +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 + +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 +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" + # As a last resort, use the slow shell script. + test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh" +fi + INSTALL="$ac_cv_path_install" +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' + + +if test "${GCC}" = "yes"; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA 1 +EOF + +else + # If we cannot run a trivial program, we must be cross compiling. +echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_cross=yes +else +cat > conftest.$ac_ext </dev/null; then + ac_cv_c_cross=no +else + ac_cv_c_cross=yes +fi +fi +rm -fr conftest* +fi +cross_compiling=$ac_cv_c_cross +echo "$ac_t""$ac_cv_c_cross" 1>&6 + +# 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 +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() { return 0; } +int t() { +char *p = alloca(2 * sizeof(int)); +; return 0; } +EOF +if eval $ac_link; then + rm -rf conftest* + ac_cv_header_alloca_h=yes +else + 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 +if eval "test \"`echo '$''{'ac_cv_func_alloca'+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() { return 0; } +int t() { +char *p = (char *) alloca(1); +; return 0; } +EOF +if eval $ac_link; then + rm -rf conftest* + ac_cv_func_alloca=yes +else + rm -rf conftest* + ac_cv_func_alloca=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_func_alloca" 1>&6 +if test $ac_cv_func_alloca = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA 1 +EOF + +fi + +if test $ac_cv_func_alloca = 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 +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 +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. */ +char $ac_func(); + +int main() { return 0; } +int t() { + +/* 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 $ac_link; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + 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 +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 +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + ac_cv_c_stack_direction=1 +else + ac_cv_c_stack_direction=-1 +fi +fi +rm -fr conftest* +fi +echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 +cat >> confdefs.h <&6 +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 +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +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 + 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 + ac_cv_header_stdc=no +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 +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + : +else + ac_cv_header_stdc=no +fi +fi +rm -fr conftest* +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 string.h +do +ac_safe=`echo "$ac_hdr" | tr './\055' '___'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +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 +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +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 + 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 | tr '[a-z]./\055' '[A-Z]___'` + cat >> confdefs.h <&6 +fi +done + + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`$ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`$ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`$ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`$ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +echo $ac_n "checking for target makefile fragment... $ac_c" 1>&6 +target_frag= +if test "${enable_shared}" = "yes" ; then + case "${target}" in + hppa*-*-*) target_frag=../config/mh-papic ;; + i34586-*-*) target_frag=../config/mh-x86pic ;; + *-*-*) target_frag=../config/mh-${target_cpu}pic ;; + esac + target_frag=${srcdir}/${target_frag} +fi +if test ! -f "${target_frag}"; then + target_frag=/dev/null + echo "none" 1>&6 +else + echo ${target_frag} 1>&6 +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.4" + 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 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +$ac_vpsub +$extrasub +s%@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%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@RANLIB@%$RANLIB%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@ALLOCA@%$ALLOCA%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +/@target_frag@/r $target_frag +s%@target_frag@%%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 + + 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 + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%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/gnu/lib/libg++/librx/configure.in b/gnu/lib/libg++/librx/configure.in new file mode 100644 index 00000000000..9086d963c09 --- /dev/null +++ b/gnu/lib/libg++/librx/configure.in @@ -0,0 +1,38 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(rx.c) + +AC_PROG_CC +AC_PROG_CPP +AC_PROG_RANLIB +AC_PROG_INSTALL + +dnl Check for gcc explicitly in case the linker does not work when +dnl using a cross compiler. +if test "${GCC}" = "yes"; then + AC_DEFINE(HAVE_ALLOCA) +else + AC_FUNC_ALLOCA +fi +AC_STDC_HEADERS +AC_HAVE_HEADERS(string.h) + +AC_CANONICAL_SYSTEM +echo $ac_n "checking for target makefile fragment... $ac_c" 1>&6 +target_frag= +if test "${enable_shared}" = "yes" ; then + case "${target}" in + hppa*-*-*) target_frag=../config/mh-papic ;; + i[345]86-*-*) target_frag=../config/mh-x86pic ;; + *-*-*) target_frag=../config/mh-${target_cpu}pic ;; + esac + target_frag=${srcdir}/${target_frag} +fi +if test ! -f "${target_frag}"; then + target_frag=/dev/null + echo "none" 1>&6 +else + echo ${target_frag} 1>&6 +fi +AC_SUBST_FILE(target_frag) + +AC_OUTPUT(Makefile) diff --git a/gnu/lib/libg++/librx/rx.c b/gnu/lib/libg++/librx/rx.c new file mode 100644 index 00000000000..c021e0a2c8c --- /dev/null +++ b/gnu/lib/libg++/librx/rx.c @@ -0,0 +1,7192 @@ +/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + +This file is part of the librx library. + +Librx 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. + +Librx is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU Library General Public +License along with this software; see the file COPYING.LIB. If not, +write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA +02139, USA. */ + +/* NOTE!!! AIX is so losing it requires this to be the first thing in the + * file. + * Do not put ANYTHING before it! + */ +#if !defined (__GNUC__) && defined (_AIX) + #pragma alloca +#endif + +/* To make linux happy? */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + + +char rx_version_string[] = "GNU Rx version 0.07.2"; + + /* ``Too hard!'' + * -- anon. + */ + + +#include +#include +#ifndef isgraph +#define isgraph(c) (isprint (c) && !isspace (c)) +#endif +#ifndef isblank +#define isblank(c) ((c) == ' ' || (c) == '\t') +#endif + +#include + +#undef MAX +#undef MIN +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +typedef char boolean; +#define false 0 +#define true 1 + +#ifndef __GCC__ +#undef __inline__ +#define __inline__ +#endif + +/* Emacs already defines alloca, sometimes. */ +#ifndef alloca + +/* Make alloca work the best possible way. */ +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else /* not __GNUC__ */ +#if HAVE_ALLOCA_H +#include +#else /* not __GNUC__ or HAVE_ALLOCA_H */ +#ifndef _AIX /* Already did AIX, up at the top. */ +char *alloca (); +#endif /* not _AIX */ +#endif /* not HAVE_ALLOCA_H */ +#endif /* not __GNUC__ */ + +#endif /* not alloca */ + +/* Memory management and stuff for emacs. */ + +#define CHARBITS 8 +#define remalloc(M, S) (M ? realloc (M, S) : malloc (S)) + + +/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we + * use `alloca' instead of `malloc' for the backtracking stack. + * + * Emacs will die miserably if we don't do this. + */ + +#ifdef REGEX_MALLOC +#define REGEX_ALLOCATE malloc +#else /* not REGEX_MALLOC */ +#define REGEX_ALLOCATE alloca +#endif /* not REGEX_MALLOC */ + + +#ifdef RX_WANT_RX_DEFS +#define RX_DECL extern +#define RX_DEF_QUAL +#else +#define RX_WANT_RX_DEFS +#define RX_DECL static +#define RX_DEF_QUAL static +#endif +#include "rx.h" +#undef RX_DECL +#define RX_DECL RX_DEF_QUAL + + +#ifndef emacs + +#ifdef SYNTAX_TABLE +extern char *re_syntax_table; +#else /* not SYNTAX_TABLE */ + +#ifndef RX_WANT_RX_DEFS +RX_DECL char re_syntax_table[CHAR_SET_SIZE]; +#endif + +#ifdef __STDC__ +static void +init_syntax_once (void) +#else +static void +init_syntax_once () +#endif +{ + register int c; + static int done = 0; + + if (done) + return; + + bzero (re_syntax_table, sizeof re_syntax_table); + + for (c = 'a'; c <= 'z'; c++) + re_syntax_table[c] = Sword; + + for (c = 'A'; c <= 'Z'; c++) + re_syntax_table[c] = Sword; + + for (c = '0'; c <= '9'; c++) + re_syntax_table[c] = Sword; + + re_syntax_table['_'] = Sword; + + done = 1; +} +#endif /* not SYNTAX_TABLE */ +#endif /* not emacs */ + +/* Compile with `-DRX_DEBUG' and use the following flags. + * + * Debugging flags: + * rx_debug - print information as a regexp is compiled + * rx_debug_trace - print information as a regexp is executed + */ + +#ifdef RX_DEBUG + +int rx_debug_compile = 0; +int rx_debug_trace = 0; +static struct re_pattern_buffer * dbug_rxb = 0; + +#ifdef __STDC__ +typedef void (*side_effect_printer) (struct rx *, void *, FILE *); +#else +typedef void (*side_effect_printer) (); +#endif + +#ifdef __STDC__ +static void print_cset (struct rx *rx, rx_Bitset cset, FILE * fp); +#else +static void print_cset (); +#endif + +#ifdef __STDC__ +static void +print_rexp (struct rx *rx, + struct rexp_node *node, int depth, + side_effect_printer seprint, FILE * fp) +#else +static void +print_rexp (rx, node, depth, seprint, fp) + struct rx *rx; + struct rexp_node *node; + int depth; + side_effect_printer seprint; + FILE * fp; +#endif +{ + if (!node) + return; + else + { + switch (node->type) + { + case r_cset: + { + fprintf (fp, "%*s", depth, ""); + print_cset (rx, node->params.cset, fp); + fputc ('\n', fp); + break; + } + + case r_opt: + case r_star: + fprintf (fp, "%*s%s\n", depth, "", + node->type == r_opt ? "opt" : "star"); + print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); + break; + + case r_2phase_star: + fprintf (fp, "%*s2phase star\n", depth, ""); + print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp); + print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); + break; + + + case r_alternate: + case r_concat: + fprintf (fp, "%*s%s\n", depth, "", + node->type == r_alternate ? "alt" : "concat"); + print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); + print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp); + break; + case r_side_effect: + fprintf (fp, "%*sSide effect: ", depth, ""); + seprint (rx, node->params.side_effect, fp); + fputc ('\n', fp); + } + } +} + +#ifdef __STDC__ +static void +print_nfa (struct rx * rx, + struct rx_nfa_state * n, + side_effect_printer seprint, FILE * fp) +#else +static void +print_nfa (rx, n, seprint, fp) + struct rx * rx; + struct rx_nfa_state * n; + side_effect_printer seprint; + FILE * fp; +#endif +{ + while (n) + { + struct rx_nfa_edge *e = n->edges; + struct rx_possible_future *ec = n->futures; + fprintf (fp, "node %d %s\n", n->id, + n->is_final ? "final" : (n->is_start ? "start" : "")); + while (e) + { + fprintf (fp, " edge to %d, ", e->dest->id); + switch (e->type) + { + case ne_epsilon: + fprintf (fp, "epsilon\n"); + break; + case ne_side_effect: + fprintf (fp, "side effect "); + seprint (rx, e->params.side_effect, fp); + fputc ('\n', fp); + break; + case ne_cset: + fprintf (fp, "cset "); + print_cset (rx, e->params.cset, fp); + fputc ('\n', fp); + break; + } + e = e->next; + } + + while (ec) + { + int x; + struct rx_nfa_state_set * s; + struct rx_se_list * l; + fprintf (fp, " eclosure to {"); + for (s = ec->destset; s; s = s->cdr) + fprintf (fp, "%d ", s->car->id); + fprintf (fp, "} ("); + for (l = ec->effects; l; l = l->cdr) + { + seprint (rx, l->car, fp); + fputc (' ', fp); + } + fprintf (fp, ")\n"); + ec = ec->next; + } + n = n->next; + } +} + +static char * efnames [] = +{ + "bogon", + "re_se_try", + "re_se_pushback", + "re_se_push0", + "re_se_pushpos", + "re_se_chkpos", + "re_se_poppos", + "re_se_at_dot", + "re_se_syntax", + "re_se_not_syntax", + "re_se_begbuf", + "re_se_hat", + "re_se_wordbeg", + "re_se_wordbound", + "re_se_notwordbound", + "re_se_wordend", + "re_se_endbuf", + "re_se_dollar", + "re_se_fail", +}; + +static char * efnames2[] = +{ + "re_se_win", + "re_se_lparen", + "re_se_rparen", + "re_se_backref", + "re_se_iter", + "re_se_end_iter", + "re_se_tv" +}; + +static char * inx_names[] = +{ + "rx_backtrack_point", + "rx_do_side_effects", + "rx_cache_miss", + "rx_next_char", + "rx_backtrack", + "rx_error_inx", + "rx_num_instructions" +}; + + +#ifdef __STDC__ +static void +re_seprint (struct rx * rx, void * effect, FILE * fp) +#else +static void +re_seprint (rx, effect, fp) + struct rx * rx; + void * effect; + FILE * fp; +#endif +{ + if ((int)effect < 0) + fputs (efnames[-(int)effect], fp); + else if (dbug_rxb) + { + struct re_se_params * p = &dbug_rxb->se_params[(int)effect]; + fprintf (fp, "%s(%d,%d)", efnames2[p->se], p->op1, p->op2); + } + else + fprintf (fp, "[complex op # %d]", (int)effect); +} + + +/* These are so the regex.c regression tests will compile. */ +void +print_compiled_pattern (rxb) + struct re_pattern_buffer * rxb; +{ +} + +void +print_fastmap (fm) + char * fm; +{ +} + +#endif /* RX_DEBUG */ + + + +/* This page: Bitsets. Completely unintersting. */ + +#ifdef __STDC__ +RX_DECL int +rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL int +rx_bitset_is_equal (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + RX_subset s = b[0]; + b[0] = ~a[0]; + + for (x = rx_bitset_numb_subsets(size) - 1; a[x] == b[x]; --x) + ; + + b[0] = s; + return !x && s == a[0]; +} + +#ifdef __STDC__ +RX_DECL int +rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL int +rx_bitset_is_subset (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x = rx_bitset_numb_subsets(size) - 1; + while (x-- && (a[x] & b[x]) == a[x]); + return x == -1; +} + + +#ifdef __STDC__ +RX_DECL int +rx_bitset_empty (int size, rx_Bitset set) +#else +RX_DECL int +rx_bitset_empty (size, set) + int size; + rx_Bitset set; +#endif +{ + int x; + RX_subset s = set[0]; + set[0] = 1; + for (x = rx_bitset_numb_subsets(size) - 1; !set[x]; --x) + ; + set[0] = s; + return !s; +} + +#ifdef __STDC__ +RX_DECL void +rx_bitset_null (int size, rx_Bitset b) +#else +RX_DECL void +rx_bitset_null (size, b) + int size; + rx_Bitset b; +#endif +{ + bzero (b, rx_sizeof_bitset(size)); +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_universe (int size, rx_Bitset b) +#else +RX_DECL void +rx_bitset_universe (size, b) + int size; + rx_Bitset b; +#endif +{ + int x = rx_bitset_numb_subsets (size); + while (x--) + *b++ = ~(RX_subset)0; +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_complement (int size, rx_Bitset b) +#else +RX_DECL void +rx_bitset_complement (size, b) + int size; + rx_Bitset b; +#endif +{ + int x = rx_bitset_numb_subsets (size); + while (x--) + { + *b = ~*b; + ++b; + } +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_assign (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] = b[x]; +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_union (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_union (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] |= b[x]; +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_intersection (int size, + rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_intersection (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] &= b[x]; +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_difference (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] &= ~ b[x]; +} + + +#ifdef __STDC__ +RX_DECL void +rx_bitset_revdifference (int size, + rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_revdifference (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] = ~a[x] & b[x]; +} + +#ifdef __STDC__ +RX_DECL void +rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b) +#else +RX_DECL void +rx_bitset_xor (size, a, b) + int size; + rx_Bitset a; + rx_Bitset b; +#endif +{ + int x; + for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) + a[x] ^= b[x]; +} + + +#ifdef __STDC__ +RX_DECL unsigned long +rx_bitset_hash (int size, rx_Bitset b) +#else +RX_DECL unsigned long +rx_bitset_hash (size, b) + int size; + rx_Bitset b; +#endif +{ + int x; + unsigned long hash = (unsigned long)rx_bitset_hash; + + for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x) + hash ^= rx_bitset_subset_val(b, x); + + return hash; +} + + +RX_DECL RX_subset rx_subset_singletons [RX_subset_bits] = +{ + 0x1, + 0x2, + 0x4, + 0x8, + 0x10, + 0x20, + 0x40, + 0x80, + 0x100, + 0x200, + 0x400, + 0x800, + 0x1000, + 0x2000, + 0x4000, + 0x8000, + 0x10000, + 0x20000, + 0x40000, + 0x80000, + 0x100000, + 0x200000, + 0x400000, + 0x800000, + 0x1000000, + 0x2000000, + 0x4000000, + 0x8000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000 +}; + +#ifdef RX_DEBUG + +#ifdef __STDC__ +static void +print_cset (struct rx *rx, rx_Bitset cset, FILE * fp) +#else +static void +print_cset (rx, cset, fp) + struct rx *rx; + rx_Bitset cset; + FILE * fp; +#endif +{ + int x; + fputc ('[', fp); + for (x = 0; x < rx->local_cset_size; ++x) + if (RX_bitset_member (cset, x)) + { + if (isprint(x)) + fputc (x, fp); + else + fprintf (fp, "\\0%o ", x); + } + fputc (']', fp); +} + +#endif /* RX_DEBUG */ + + + +static unsigned long rx_hash_masks[4] = +{ + 0x12488421, + 0x96699669, + 0xbe7dd7eb, + 0xffffffff +}; + + +/* Hash tables */ +#ifdef __STDC__ +RX_DECL struct rx_hash_item * +rx_hash_find (struct rx_hash * table, + unsigned long hash, + void * value, + struct rx_hash_rules * rules) +#else +RX_DECL struct rx_hash_item * +rx_hash_find (table, hash, value, rules) + struct rx_hash * table; + unsigned long hash; + void * value; + struct rx_hash_rules * rules; +#endif +{ + rx_hash_eq eq = rules->eq; + int maskc = 0; + long mask = rx_hash_masks [0]; + int bucket = (hash & mask) % 13; + + while (table->children [bucket]) + { + table = table->children [bucket]; + ++maskc; + mask = rx_hash_masks[maskc]; + bucket = (hash & mask) % 13; + } + + { + struct rx_hash_item * it = table->buckets[bucket]; + while (it) + if (eq (it->data, value)) + return it; + else + it = it->next_same_hash; + } + + return 0; +} + + +#ifdef __STDC__ +RX_DECL struct rx_hash_item * +rx_hash_store (struct rx_hash * table, + unsigned long hash, + void * value, + struct rx_hash_rules * rules) +#else +RX_DECL struct rx_hash_item * +rx_hash_store (table, hash, value, rules) + struct rx_hash * table; + unsigned long hash; + void * value; + struct rx_hash_rules * rules; +#endif +{ + rx_hash_eq eq = rules->eq; + int maskc = 0; + long mask = rx_hash_masks[0]; + int bucket = (hash & mask) % 13; + int depth = 0; + + while (table->children [bucket]) + { + table = table->children [bucket]; + ++maskc; + mask = rx_hash_masks[maskc]; + bucket = (hash & mask) % 13; + ++depth; + } + + { + struct rx_hash_item * it = table->buckets[bucket]; + while (it) + if (eq (it->data, value)) + return it; + else + it = it->next_same_hash; + } + + { + if ( (depth < 3) + && (table->bucket_size [bucket] >= 4)) + { + struct rx_hash * newtab = ((struct rx_hash *) + rules->hash_alloc (rules)); + if (!newtab) + goto add_to_bucket; + bzero (newtab, sizeof (*newtab)); + newtab->parent = table; + { + struct rx_hash_item * them = table->buckets[bucket]; + unsigned long newmask = rx_hash_masks[maskc + 1]; + while (them) + { + struct rx_hash_item * save = them->next_same_hash; + int new_buck = (them->hash & newmask) % 13; + them->next_same_hash = newtab->buckets[new_buck]; + newtab->buckets[new_buck] = them; + them->table = newtab; + them = save; + ++newtab->bucket_size[new_buck]; + ++newtab->refs; + } + table->refs = (table->refs - table->bucket_size[bucket] + 1); + table->bucket_size[bucket] = 0; + table->buckets[bucket] = 0; + table->children[bucket] = newtab; + table = newtab; + bucket = (hash & newmask) % 13; + } + } + } + add_to_bucket: + { + struct rx_hash_item * it = ((struct rx_hash_item *) + rules->hash_item_alloc (rules, value)); + if (!it) + return 0; + it->hash = hash; + it->table = table; + /* DATA and BINDING are to be set in hash_item_alloc */ + it->next_same_hash = table->buckets [bucket]; + table->buckets[bucket] = it; + ++table->bucket_size [bucket]; + ++table->refs; + return it; + } +} + + +#ifdef __STDC__ +RX_DECL void +rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules) +#else +RX_DECL void +rx_hash_free (it, rules) + struct rx_hash_item * it; + struct rx_hash_rules * rules; +#endif +{ + if (it) + { + struct rx_hash * table = it->table; + unsigned long hash = it->hash; + int depth = (table->parent + ? (table->parent->parent + ? (table->parent->parent->parent + ? 3 + : 2) + : 1) + : 0); + int bucket = (hash & rx_hash_masks [depth]) % 13; + struct rx_hash_item ** pos = &table->buckets [bucket]; + + while (*pos != it) + pos = &(*pos)->next_same_hash; + *pos = it->next_same_hash; + rules->free_hash_item (it, rules); + --table->bucket_size[bucket]; + --table->refs; + while (!table->refs && depth) + { + struct rx_hash * save = table; + table = table->parent; + --depth; + bucket = (hash & rx_hash_masks [depth]) % 13; + --table->refs; + table->children[bucket] = 0; + rules->free_hash (save, rules); + } + } +} + +#ifdef __STDC__ +RX_DECL void +rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn, + struct rx_hash_rules * rules) +#else +RX_DECL void +rx_free_hash_table (tab, freefn, rules) + struct rx_hash * tab; + rx_hash_freefn freefn; + struct rx_hash_rules * rules; +#endif +{ + int x; + + for (x = 0; x < 13; ++x) + if (tab->children[x]) + { + rx_free_hash_table (tab->children[x], freefn, rules); + rules->free_hash (tab->children[x], rules); + } + else + { + struct rx_hash_item * them = tab->buckets[x]; + while (them) + { + struct rx_hash_item * that = them; + them = that->next_same_hash; + freefn (that); + rules->free_hash_item (that, rules); + } + } +} + + + +/* Utilities for manipulating bitset represntations of characters sets. */ + +#ifdef __STDC__ +RX_DECL rx_Bitset +rx_cset (struct rx *rx) +#else +RX_DECL rx_Bitset +rx_cset (rx) + struct rx *rx; +#endif +{ + rx_Bitset b = (rx_Bitset) malloc (rx_sizeof_bitset (rx->local_cset_size)); + if (b) + rx_bitset_null (rx->local_cset_size, b); + return b; +} + + +#ifdef __STDC__ +RX_DECL rx_Bitset +rx_copy_cset (struct rx *rx, rx_Bitset a) +#else +RX_DECL rx_Bitset +rx_copy_cset (rx, a) + struct rx *rx; + rx_Bitset a; +#endif +{ + rx_Bitset cs = rx_cset (rx); + + if (cs) + rx_bitset_union (rx->local_cset_size, cs, a); + + return cs; +} + + +#ifdef __STDC__ +RX_DECL void +rx_free_cset (struct rx * rx, rx_Bitset c) +#else +RX_DECL void +rx_free_cset (rx, c) + struct rx * rx; + rx_Bitset c; +#endif +{ + if (c) + free ((char *)c); +} + + +/* Hash table memory allocation policy for the regexp compiler */ + +#ifdef __STDC__ +static struct rx_hash * +compiler_hash_alloc (struct rx_hash_rules * rules) +#else +static struct rx_hash * +compiler_hash_alloc (rules) + struct rx_hash_rules * rules; +#endif +{ + return (struct rx_hash *)malloc (sizeof (struct rx_hash)); +} + + +#ifdef __STDC__ +static struct rx_hash_item * +compiler_hash_item_alloc (struct rx_hash_rules * rules, void * value) +#else +static struct rx_hash_item * +compiler_hash_item_alloc (rules, value) + struct rx_hash_rules * rules; + void * value; +#endif +{ + struct rx_hash_item * it; + it = (struct rx_hash_item *)malloc (sizeof (*it)); + if (it) + { + it->data = value; + it->binding = 0; + } + return it; +} + + +#ifdef __STDC__ +static void +compiler_free_hash (struct rx_hash * tab, + struct rx_hash_rules * rules) +#else +static void +compiler_free_hash (tab, rules) + struct rx_hash * tab; + struct rx_hash_rules * rules; +#endif +{ + free ((char *)tab); +} + + +#ifdef __STDC__ +static void +compiler_free_hash_item (struct rx_hash_item * item, + struct rx_hash_rules * rules) +#else +static void +compiler_free_hash_item (item, rules) + struct rx_hash_item * item; + struct rx_hash_rules * rules; +#endif +{ + free ((char *)item); +} + + +/* This page: REXP_NODE (expression tree) structures. */ + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rexp_node (struct rx *rx, + enum rexp_node_type type) +#else +RX_DECL struct rexp_node * +rexp_node (rx, type) + struct rx *rx; + enum rexp_node_type type; +#endif +{ + struct rexp_node *n; + + n = (struct rexp_node *)malloc (sizeof (*n)); + bzero (n, sizeof (*n)); + if (n) + n->type = type; + return n; +} + + +/* free_rexp_node assumes that the bitset passed to rx_mk_r_cset + * can be freed using rx_free_cset. + */ +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_cset (struct rx * rx, + rx_Bitset b) +#else +RX_DECL struct rexp_node * +rx_mk_r_cset (rx, b) + struct rx * rx; + rx_Bitset b; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_cset); + if (n) + n->params.cset = b; + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_concat (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b) +#else +RX_DECL struct rexp_node * +rx_mk_r_concat (rx, a, b) + struct rx * rx; + struct rexp_node * a; + struct rexp_node * b; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_concat); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = b; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_alternate (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b) +#else +RX_DECL struct rexp_node * +rx_mk_r_alternate (rx, a, b) + struct rx * rx; + struct rexp_node * a; + struct rexp_node * b; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_alternate); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = b; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_opt (struct rx * rx, + struct rexp_node * a) +#else +RX_DECL struct rexp_node * +rx_mk_r_opt (rx, a) + struct rx * rx; + struct rexp_node * a; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_opt); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = 0; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_star (struct rx * rx, + struct rexp_node * a) +#else +RX_DECL struct rexp_node * +rx_mk_r_star (rx, a) + struct rx * rx; + struct rexp_node * a; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_star); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = 0; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_2phase_star (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b) +#else +RX_DECL struct rexp_node * +rx_mk_r_2phase_star (rx, a, b) + struct rx * rx; + struct rexp_node * a; + struct rexp_node * b; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_2phase_star); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = b; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_side_effect (struct rx * rx, + rx_side_effect a) +#else +RX_DECL struct rexp_node * +rx_mk_r_side_effect (rx, a) + struct rx * rx; + rx_side_effect a; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_side_effect); + if (n) + { + n->params.side_effect = a; + n->params.pair.right = 0; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_mk_r_data (struct rx * rx, + void * a) +#else +RX_DECL struct rexp_node * +rx_mk_r_data (rx, a) + struct rx * rx; + void * a; +#endif +{ + struct rexp_node * n = rexp_node (rx, r_data); + if (n) + { + n->params.pair.left = a; + n->params.pair.right = 0; + } + return n; +} + + +#ifdef __STDC__ +RX_DECL void +rx_free_rexp (struct rx * rx, struct rexp_node * node) +#else +RX_DECL void +rx_free_rexp (rx, node) + struct rx * rx; + struct rexp_node * node; +#endif +{ + if (node) + { + switch (node->type) + { + case r_cset: + if (node->params.cset) + rx_free_cset (rx, node->params.cset); + + case r_side_effect: + break; + + case r_concat: + case r_alternate: + case r_2phase_star: + case r_opt: + case r_star: + rx_free_rexp (rx, node->params.pair.left); + rx_free_rexp (rx, node->params.pair.right); + break; + + case r_data: + /* This shouldn't occur. */ + break; + } + free ((char *)node); + } +} + + +#ifdef __STDC__ +RX_DECL struct rexp_node * +rx_copy_rexp (struct rx *rx, + struct rexp_node *node) +#else +RX_DECL struct rexp_node * +rx_copy_rexp (rx, node) + struct rx *rx; + struct rexp_node *node; +#endif +{ + if (!node) + return 0; + else + { + struct rexp_node *n = rexp_node (rx, node->type); + if (!n) + return 0; + switch (node->type) + { + case r_cset: + n->params.cset = rx_copy_cset (rx, node->params.cset); + if (!n->params.cset) + { + rx_free_rexp (rx, n); + return 0; + } + break; + + case r_side_effect: + n->params.side_effect = node->params.side_effect; + break; + + case r_concat: + case r_alternate: + case r_opt: + case r_2phase_star: + case r_star: + n->params.pair.left = + rx_copy_rexp (rx, node->params.pair.left); + n->params.pair.right = + rx_copy_rexp (rx, node->params.pair.right); + if ( (node->params.pair.left && !n->params.pair.left) + || (node->params.pair.right && !n->params.pair.right)) + { + rx_free_rexp (rx, n); + return 0; + } + break; + case r_data: + /* shouldn't happen */ + break; + } + return n; + } +} + + + +/* This page: functions to build and destroy graphs that describe nfa's */ + +/* Constructs a new nfa node. */ +#ifdef __STDC__ +RX_DECL struct rx_nfa_state * +rx_nfa_state (struct rx *rx) +#else +RX_DECL struct rx_nfa_state * +rx_nfa_state (rx) + struct rx *rx; +#endif +{ + struct rx_nfa_state * n = (struct rx_nfa_state *)malloc (sizeof (*n)); + if (!n) + return 0; + bzero (n, sizeof (*n)); + n->next = rx->nfa_states; + rx->nfa_states = n; + return n; +} + + +#ifdef __STDC__ +RX_DECL void +rx_free_nfa_state (struct rx_nfa_state * n) +#else +RX_DECL void +rx_free_nfa_state (n) + struct rx_nfa_state * n; +#endif +{ + free ((char *)n); +} + + +/* This looks up an nfa node, given a numeric id. Numeric id's are + * assigned after the nfa has been built. + */ +#ifdef __STDC__ +RX_DECL struct rx_nfa_state * +rx_id_to_nfa_state (struct rx * rx, + int id) +#else +RX_DECL struct rx_nfa_state * +rx_id_to_nfa_state (rx, id) + struct rx * rx; + int id; +#endif +{ + struct rx_nfa_state * n; + for (n = rx->nfa_states; n; n = n->next) + if (n->id == id) + return n; + return 0; +} + + +/* This adds an edge between two nodes, but doesn't initialize the + * edge label. + */ + +#ifdef __STDC__ +RX_DECL struct rx_nfa_edge * +rx_nfa_edge (struct rx *rx, + enum rx_nfa_etype type, + struct rx_nfa_state *start, + struct rx_nfa_state *dest) +#else +RX_DECL struct rx_nfa_edge * +rx_nfa_edge (rx, type, start, dest) + struct rx *rx; + enum rx_nfa_etype type; + struct rx_nfa_state *start; + struct rx_nfa_state *dest; +#endif +{ + struct rx_nfa_edge *e; + e = (struct rx_nfa_edge *)malloc (sizeof (*e)); + if (!e) + return 0; + e->next = start->edges; + start->edges = e; + e->type = type; + e->dest = dest; + return e; +} + + +#ifdef __STDC__ +RX_DECL void +rx_free_nfa_edge (struct rx_nfa_edge * e) +#else +RX_DECL void +rx_free_nfa_edge (e) + struct rx_nfa_edge * e; +#endif +{ + free ((char *)e); +} + + +/* This constructs a POSSIBLE_FUTURE, which is a kind epsilon-closure + * of an NFA. These are added to an nfa automaticly by eclose_nfa. + */ + +#ifdef __STDC__ +static struct rx_possible_future * +rx_possible_future (struct rx * rx, + struct rx_se_list * effects) +#else +static struct rx_possible_future * +rx_possible_future (rx, effects) + struct rx * rx; + struct rx_se_list * effects; +#endif +{ + struct rx_possible_future *ec; + ec = (struct rx_possible_future *) malloc (sizeof (*ec)); + if (!ec) + return 0; + ec->destset = 0; + ec->next = 0; + ec->effects = effects; + return ec; +} + + +#ifdef __STDC__ +static void +rx_free_possible_future (struct rx_possible_future * pf) +#else +static void +rx_free_possible_future (pf) + struct rx_possible_future * pf; +#endif +{ + free ((char *)pf); +} + + +#ifdef __STDC__ +RX_DECL void +rx_free_nfa (struct rx *rx) +#else +RX_DECL void +rx_free_nfa (rx) + struct rx *rx; +#endif +{ + while (rx->nfa_states) + { + while (rx->nfa_states->edges) + { + switch (rx->nfa_states->edges->type) + { + case ne_cset: + rx_free_cset (rx, rx->nfa_states->edges->params.cset); + break; + default: + break; + } + { + struct rx_nfa_edge * e; + e = rx->nfa_states->edges; + rx->nfa_states->edges = rx->nfa_states->edges->next; + rx_free_nfa_edge (e); + } + } /* while (rx->nfa_states->edges) */ + { + /* Iterate over the partial epsilon closures of rx->nfa_states */ + struct rx_possible_future * pf = rx->nfa_states->futures; + while (pf) + { + struct rx_possible_future * pft = pf; + pf = pf->next; + rx_free_possible_future (pft); + } + } + { + struct rx_nfa_state *n; + n = rx->nfa_states; + rx->nfa_states = rx->nfa_states->next; + rx_free_nfa_state (n); + } + } +} + + + +/* This page: translating a pattern expression into an nfa and doing the + * static part of the nfa->super-nfa translation. + */ + +/* This is the thompson regexp->nfa algorithm. + * It is modified to allow for `side-effect epsilons.' Those are + * edges that are taken whenever a similar epsilon edge would be, + * but which imply that some side effect occurs when the edge + * is taken. + * + * Side effects are used to model parts of the pattern langauge + * that are not regular (in the formal sense). + */ + +#ifdef __STDC__ +RX_DECL int +rx_build_nfa (struct rx *rx, + struct rexp_node *rexp, + struct rx_nfa_state **start, + struct rx_nfa_state **end) +#else +RX_DECL int +rx_build_nfa (rx, rexp, start, end) + struct rx *rx; + struct rexp_node *rexp; + struct rx_nfa_state **start; + struct rx_nfa_state **end; +#endif +{ + struct rx_nfa_edge *edge; + + /* Start & end nodes may have been allocated by the caller. */ + *start = *start ? *start : rx_nfa_state (rx); + + if (!*start) + return 0; + + if (!rexp) + { + *end = *start; + return 1; + } + + *end = *end ? *end : rx_nfa_state (rx); + + if (!*end) + { + rx_free_nfa_state (*start); + return 0; + } + + switch (rexp->type) + { + case r_data: + return 0; + + case r_cset: + edge = rx_nfa_edge (rx, ne_cset, *start, *end); + if (!edge) + return 0; + edge->params.cset = rx_copy_cset (rx, rexp->params.cset); + if (!edge->params.cset) + { + rx_free_nfa_edge (edge); + return 0; + } + return 1; + + case r_opt: + return (rx_build_nfa (rx, rexp->params.pair.left, start, end) + && rx_nfa_edge (rx, ne_epsilon, *start, *end)); + + case r_star: + { + struct rx_nfa_state * star_start = 0; + struct rx_nfa_state * star_end = 0; + return (rx_build_nfa (rx, rexp->params.pair.left, + &star_start, &star_end) + && star_start + && star_end + && rx_nfa_edge (rx, ne_epsilon, star_start, star_end) + && rx_nfa_edge (rx, ne_epsilon, *start, star_start) + && rx_nfa_edge (rx, ne_epsilon, star_end, *end) + + && rx_nfa_edge (rx, ne_epsilon, star_end, star_start)); + } + + case r_2phase_star: + { + struct rx_nfa_state * star_start = 0; + struct rx_nfa_state * star_end = 0; + struct rx_nfa_state * loop_exp_start = 0; + struct rx_nfa_state * loop_exp_end = 0; + + return (rx_build_nfa (rx, rexp->params.pair.left, + &star_start, &star_end) + && rx_build_nfa (rx, rexp->params.pair.right, + &loop_exp_start, &loop_exp_end) + && star_start + && star_end + && loop_exp_end + && loop_exp_start + && rx_nfa_edge (rx, ne_epsilon, star_start, *end) + && rx_nfa_edge (rx, ne_epsilon, *start, star_start) + && rx_nfa_edge (rx, ne_epsilon, star_end, *end) + + && rx_nfa_edge (rx, ne_epsilon, star_end, loop_exp_start) + && rx_nfa_edge (rx, ne_epsilon, loop_exp_end, star_start)); + } + + + case r_concat: + { + struct rx_nfa_state *shared = 0; + return + (rx_build_nfa (rx, rexp->params.pair.left, start, &shared) + && rx_build_nfa (rx, rexp->params.pair.right, &shared, end)); + } + + case r_alternate: + { + struct rx_nfa_state *ls = 0; + struct rx_nfa_state *le = 0; + struct rx_nfa_state *rs = 0; + struct rx_nfa_state *re = 0; + return (rx_build_nfa (rx, rexp->params.pair.left, &ls, &le) + && rx_build_nfa (rx, rexp->params.pair.right, &rs, &re) + && rx_nfa_edge (rx, ne_epsilon, *start, ls) + && rx_nfa_edge (rx, ne_epsilon, *start, rs) + && rx_nfa_edge (rx, ne_epsilon, le, *end) + && rx_nfa_edge (rx, ne_epsilon, re, *end)); + } + + case r_side_effect: + edge = rx_nfa_edge (rx, ne_side_effect, *start, *end); + if (!edge) + return 0; + edge->params.side_effect = rexp->params.side_effect; + return 1; + } + + /* this should never happen */ + return 0; +} + + +/* RX_NAME_NFA_STATES identifies all nodes with outgoing non-epsilon + * transitions. Only these nodes can occur in super-states. + * All nodes are given an integer id. + * The id is non-negative if the node has non-epsilon out-transitions, negative + * otherwise (this is because we want the non-negative ids to be used as + * array indexes in a few places). + */ + +#ifdef __STDC__ +RX_DECL void +rx_name_nfa_states (struct rx *rx) +#else +RX_DECL void +rx_name_nfa_states (rx) + struct rx *rx; +#endif +{ + struct rx_nfa_state *n = rx->nfa_states; + + rx->nodec = 0; + rx->epsnodec = -1; + + while (n) + { + struct rx_nfa_edge *e = n->edges; + + if (n->is_start) + n->eclosure_needed = 1; + + while (e) + { + switch (e->type) + { + case ne_epsilon: + case ne_side_effect: + break; + + case ne_cset: + n->id = rx->nodec++; + { + struct rx_nfa_edge *from_n = n->edges; + while (from_n) + { + from_n->dest->eclosure_needed = 1; + from_n = from_n->next; + } + } + goto cont; + } + e = e->next; + } + n->id = rx->epsnodec--; + cont: + n = n->next; + } + rx->epsnodec = -rx->epsnodec; +} + + +/* This page: data structures for the static part of the nfa->supernfa + * translation. + * + * There are side effect lists -- lists of side effects occuring + * along an uninterrupted, acyclic path of side-effect epsilon edges. + * Such paths are collapsed to single edges in the course of computing + * epsilon closures. Such single edges are labled with a list of all + * the side effects entailed in crossing them. Like lists of side + * effects are made == by the constructors below. + * + * There are also nfa state sets. These are used to hold a list of all + * states reachable from a starting state for a given type of transition + * and side effect list. These are also hash-consed. + */ + +/* The next several functions compare, construct, etc. lists of side + * effects. See ECLOSE_NFA (below) for details. + */ + +/* Ordering of rx_se_list + * (-1, 0, 1 return value convention). + */ + +#ifdef __STDC__ +static int +se_list_cmp (void * va, void * vb) +#else +static int +se_list_cmp (va, vb) + void * va; + void * vb; +#endif +{ + struct rx_se_list * a = (struct rx_se_list *)va; + struct rx_se_list * b = (struct rx_se_list *)vb; + + return ((va == vb) + ? 0 + : (!va + ? -1 + : (!vb + ? 1 + : ((long)a->car < (long)b->car + ? 1 + : ((long)a->car > (long)b->car + ? -1 + : se_list_cmp ((void *)a->cdr, (void *)b->cdr)))))); +} + + +#ifdef __STDC__ +static int +se_list_equal (void * va, void * vb) +#else +static int +se_list_equal (va, vb) + void * va; + void * vb; +#endif +{ + return !(se_list_cmp (va, vb)); +} + +static struct rx_hash_rules se_list_hash_rules = +{ + se_list_equal, + compiler_hash_alloc, + compiler_free_hash, + compiler_hash_item_alloc, + compiler_free_hash_item +}; + + +#ifdef __STDC__ +static struct rx_se_list * +side_effect_cons (struct rx * rx, + void * se, struct rx_se_list * list) +#else +static struct rx_se_list * +side_effect_cons (rx, se, list) + struct rx * rx; + void * se; + struct rx_se_list * list; +#endif +{ + struct rx_se_list * l; + l = ((struct rx_se_list *) malloc (sizeof (*l))); + if (!l) + return 0; + l->car = se; + l->cdr = list; + return l; +} + + +#ifdef __STDC__ +static struct rx_se_list * +hash_cons_se_prog (struct rx * rx, + struct rx_hash * memo, + void * car, struct rx_se_list * cdr) +#else +static struct rx_se_list * +hash_cons_se_prog (rx, memo, car, cdr) + struct rx * rx; + struct rx_hash * memo; + void * car; + struct rx_se_list * cdr; +#endif +{ + long hash = (long)car ^ (long)cdr; + struct rx_se_list template; + + template.car = car; + template.cdr = cdr; + { + struct rx_hash_item * it = rx_hash_store (memo, hash, + (void *)&template, + &se_list_hash_rules); + if (!it) + return 0; + if (it->data == (void *)&template) + { + struct rx_se_list * consed; + consed = (struct rx_se_list *) malloc (sizeof (*consed)); + *consed = template; + it->data = (void *)consed; + } + return (struct rx_se_list *)it->data; + } +} + + +#ifdef __STDC__ +static struct rx_se_list * +hash_se_prog (struct rx * rx, struct rx_hash * memo, struct rx_se_list * prog) +#else +static struct rx_se_list * +hash_se_prog (rx, memo, prog) + struct rx * rx; + struct rx_hash * memo; + struct rx_se_list * prog; +#endif +{ + struct rx_se_list * answer = 0; + while (prog) + { + answer = hash_cons_se_prog (rx, memo, prog->car, answer); + if (!answer) + return 0; + prog = prog->cdr; + } + return answer; +} + +#ifdef __STDC__ +static int +nfa_set_cmp (void * va, void * vb) +#else +static int +nfa_set_cmp (va, vb) + void * va; + void * vb; +#endif +{ + struct rx_nfa_state_set * a = (struct rx_nfa_state_set *)va; + struct rx_nfa_state_set * b = (struct rx_nfa_state_set *)vb; + + return ((va == vb) + ? 0 + : (!va + ? -1 + : (!vb + ? 1 + : (a->car->id < b->car->id + ? 1 + : (a->car->id > b->car->id + ? -1 + : nfa_set_cmp ((void *)a->cdr, (void *)b->cdr)))))); +} + +#ifdef __STDC__ +static int +nfa_set_equal (void * va, void * vb) +#else +static int +nfa_set_equal (va, vb) + void * va; + void * vb; +#endif +{ + return !nfa_set_cmp (va, vb); +} + +static struct rx_hash_rules nfa_set_hash_rules = +{ + nfa_set_equal, + compiler_hash_alloc, + compiler_free_hash, + compiler_hash_item_alloc, + compiler_free_hash_item +}; + + +#ifdef __STDC__ +static struct rx_nfa_state_set * +nfa_set_cons (struct rx * rx, + struct rx_hash * memo, struct rx_nfa_state * state, + struct rx_nfa_state_set * set) +#else +static struct rx_nfa_state_set * +nfa_set_cons (rx, memo, state, set) + struct rx * rx; + struct rx_hash * memo; + struct rx_nfa_state * state; + struct rx_nfa_state_set * set; +#endif +{ + struct rx_nfa_state_set template; + struct rx_hash_item * node; + template.car = state; + template.cdr = set; + node = rx_hash_store (memo, + (((long)state) >> 8) ^ (long)set, + &template, &nfa_set_hash_rules); + if (!node) + return 0; + if (node->data == &template) + { + struct rx_nfa_state_set * l; + l = (struct rx_nfa_state_set *) malloc (sizeof (*l)); + node->data = (void *) l; + if (!l) + return 0; + *l = template; + } + return (struct rx_nfa_state_set *)node->data; +} + + +#ifdef __STDC__ +static struct rx_nfa_state_set * +nfa_set_enjoin (struct rx * rx, + struct rx_hash * memo, struct rx_nfa_state * state, + struct rx_nfa_state_set * set) +#else +static struct rx_nfa_state_set * +nfa_set_enjoin (rx, memo, state, set) + struct rx * rx; + struct rx_hash * memo; + struct rx_nfa_state * state; + struct rx_nfa_state_set * set; +#endif +{ + if (!set || state->id < set->car->id) + return nfa_set_cons (rx, memo, state, set); + if (state->id == set->car->id) + return set; + else + { + struct rx_nfa_state_set * newcdr + = nfa_set_enjoin (rx, memo, state, set->cdr); + if (newcdr != set->cdr) + set = nfa_set_cons (rx, memo, set->car, newcdr); + return set; + } +} + + + +/* This page: computing epsilon closures. The closures aren't total. + * Each node's closures are partitioned according to the side effects entailed + * along the epsilon edges. Return true on success. + */ + +struct eclose_frame +{ + struct rx_se_list *prog_backwards; +}; + + +#ifdef __STDC__ +static int +eclose_node (struct rx *rx, struct rx_nfa_state *outnode, + struct rx_nfa_state *node, struct eclose_frame *frame) +#else +static int +eclose_node (rx, outnode, node, frame) + struct rx *rx; + struct rx_nfa_state *outnode; + struct rx_nfa_state *node; + struct eclose_frame *frame; +#endif +{ + struct rx_nfa_edge *e = node->edges; + + /* For each node, we follow all epsilon paths to build the closure. + * The closure omits nodes that have only epsilon edges. + * The closure is split into partial closures -- all the states in + * a partial closure are reached by crossing the same list of + * of side effects (though not necessarily the same path). + */ + if (node->mark) + return 1; + node->mark = 1; + + if (node->id >= 0 || node->is_final) + { + struct rx_possible_future **ec; + struct rx_se_list * prog_in_order + = ((struct rx_se_list *)hash_se_prog (rx, + &rx->se_list_memo, + frame->prog_backwards)); + int cmp; + + ec = &outnode->futures; + + while (*ec) + { + cmp = se_list_cmp ((void *)(*ec)->effects, (void *)prog_in_order); + if (cmp <= 0) + break; + ec = &(*ec)->next; + } + if (!*ec || (cmp < 0)) + { + struct rx_possible_future * saved = *ec; + *ec = rx_possible_future (rx, prog_in_order); + (*ec)->next = saved; + if (!*ec) + return 0; + } + if (node->id >= 0) + { + (*ec)->destset = nfa_set_enjoin (rx, &rx->set_list_memo, + node, (*ec)->destset); + if (!(*ec)->destset) + return 0; + } + } + + while (e) + { + switch (e->type) + { + case ne_epsilon: + if (!eclose_node (rx, outnode, e->dest, frame)) + return 0; + break; + case ne_side_effect: + { + frame->prog_backwards = side_effect_cons (rx, + e->params.side_effect, + frame->prog_backwards); + if (!frame->prog_backwards) + return 0; + if (!eclose_node (rx, outnode, e->dest, frame)) + return 0; + { + struct rx_se_list * dying = frame->prog_backwards; + frame->prog_backwards = frame->prog_backwards->cdr; + free ((char *)dying); + } + break; + } + default: + break; + } + e = e->next; + } + node->mark = 0; + return 1; +} + + +#ifdef __STDC__ +RX_DECL int +rx_eclose_nfa (struct rx *rx) +#else +RX_DECL int +rx_eclose_nfa (rx) + struct rx *rx; +#endif +{ + struct rx_nfa_state *n = rx->nfa_states; + struct eclose_frame frame; + static int rx_id = 0; + + frame.prog_backwards = 0; + rx->rx_id = rx_id++; + bzero (&rx->se_list_memo, sizeof (rx->se_list_memo)); + bzero (&rx->set_list_memo, sizeof (rx->set_list_memo)); + while (n) + { + n->futures = 0; + if (n->eclosure_needed && !eclose_node (rx, n, n, &frame)) + return 0; + /* clear_marks (rx); */ + n = n->next; + } + return 1; +} + + +/* This deletes epsilon edges from an NFA. After running eclose_node, + * we have no more need for these edges. They are removed to simplify + * further operations on the NFA. + */ + +#ifdef __STDC__ +RX_DECL void +rx_delete_epsilon_transitions (struct rx *rx) +#else +RX_DECL void +rx_delete_epsilon_transitions (rx) + struct rx *rx; +#endif +{ + struct rx_nfa_state *n = rx->nfa_states; + struct rx_nfa_edge **e; + + while (n) + { + e = &n->edges; + while (*e) + { + struct rx_nfa_edge *t; + switch ((*e)->type) + { + case ne_epsilon: + case ne_side_effect: + t = *e; + *e = t->next; + rx_free_nfa_edge (t); + break; + + default: + e = &(*e)->next; + break; + } + } + n = n->next; + } +} + + +/* This page: storing the nfa in a contiguous region of memory for + * subsequent conversion to a super-nfa. + */ + +/* This is for qsort on an array of nfa_states. The order + * is based on state ids and goes + * [0...MAX][MIN..-1] where (MAX>=0) and (MIN<0) + * This way, positive ids double as array indices. + */ + +#ifdef __STDC__ +static int +nfacmp (void * va, void * vb) +#else +static int +nfacmp (va, vb) + void * va; + void * vb; +#endif +{ + struct rx_nfa_state **a = (struct rx_nfa_state **)va; + struct rx_nfa_state **b = (struct rx_nfa_state **)vb; + return (*a == *b /* &&&& 3.18 */ + ? 0 + : (((*a)->id < 0) == ((*b)->id < 0) + ? (((*a)->id < (*b)->id) ? -1 : 1) + : (((*a)->id < 0) + ? 1 : -1))); +} + +#ifdef __STDC__ +static int +count_hash_nodes (struct rx_hash * st) +#else +static int +count_hash_nodes (st) + struct rx_hash * st; +#endif +{ + int x; + int count = 0; + for (x = 0; x < 13; ++x) + count += ((st->children[x]) + ? count_hash_nodes (st->children[x]) + : st->bucket_size[x]); + + return count; +} + + +#ifdef __STDC__ +static void +se_memo_freer (struct rx_hash_item * node) +#else +static void +se_memo_freer (node) + struct rx_hash_item * node; +#endif +{ + free ((char *)node->data); +} + + +#ifdef __STDC__ +static void +nfa_set_freer (struct rx_hash_item * node) +#else +static void +nfa_set_freer (node) + struct rx_hash_item * node; +#endif +{ + free ((char *)node->data); +} + + +/* This copies an entire NFA into a single malloced block of memory. + * Mostly this is for compatability with regex.c, though it is convenient + * to have the nfa nodes in an array. + */ + +#ifdef __STDC__ +RX_DECL int +rx_compactify_nfa (struct rx *rx, + void **mem, unsigned long *size) +#else +RX_DECL int +rx_compactify_nfa (rx, mem, size) + struct rx *rx; + void **mem; + unsigned long *size; +#endif +{ + int total_nodec; + struct rx_nfa_state *n; + int edgec = 0; + int eclosec = 0; + int se_list_consc = count_hash_nodes (&rx->se_list_memo); + int nfa_setc = count_hash_nodes (&rx->set_list_memo); + unsigned long total_size; + + /* This takes place in two stages. First, the total size of the + * nfa is computed, then structures are copied. + */ + n = rx->nfa_states; + total_nodec = 0; + while (n) + { + struct rx_nfa_edge *e = n->edges; + struct rx_possible_future *ec = n->futures; + ++total_nodec; + while (e) + { + ++edgec; + e = e->next; + } + while (ec) + { + ++eclosec; + ec = ec->next; + } + n = n->next; + } + + total_size = (total_nodec * sizeof (struct rx_nfa_state) + + edgec * rx_sizeof_bitset (rx->local_cset_size) + + edgec * sizeof (struct rx_nfa_edge) + + nfa_setc * sizeof (struct rx_nfa_state_set) + + eclosec * sizeof (struct rx_possible_future) + + se_list_consc * sizeof (struct rx_se_list) + + rx->reserved); + + if (total_size > *size) + { + *mem = remalloc (*mem, total_size); + if (*mem) + *size = total_size; + else + return 0; + } + /* Now we've allocated the memory; this copies the NFA. */ + { + static struct rx_nfa_state **scratch = 0; + static int scratch_alloc = 0; + struct rx_nfa_state *state_base = (struct rx_nfa_state *) * mem; + struct rx_nfa_state *new_state = state_base; + struct rx_nfa_edge *new_edge = + (struct rx_nfa_edge *) + ((char *) state_base + total_nodec * sizeof (struct rx_nfa_state)); + struct rx_se_list * new_se_list = + (struct rx_se_list *) + ((char *)new_edge + edgec * sizeof (struct rx_nfa_edge)); + struct rx_possible_future *new_close = + ((struct rx_possible_future *) + ((char *) new_se_list + + se_list_consc * sizeof (struct rx_se_list))); + struct rx_nfa_state_set * new_nfa_set = + ((struct rx_nfa_state_set *) + ((char *)new_close + eclosec * sizeof (struct rx_possible_future))); + char *new_bitset = + ((char *) new_nfa_set + nfa_setc * sizeof (struct rx_nfa_state_set)); + int x; + struct rx_nfa_state *n; + + if (scratch_alloc < total_nodec) + { + scratch = ((struct rx_nfa_state **) + remalloc (scratch, total_nodec * sizeof (*scratch))); + if (scratch) + scratch_alloc = total_nodec; + else + { + scratch_alloc = 0; + return 0; + } + } + + for (x = 0, n = rx->nfa_states; n; n = n->next) + scratch[x++] = n; + + qsort (scratch, total_nodec, + sizeof (struct rx_nfa_state *), (int (*)())nfacmp); + + for (x = 0; x < total_nodec; ++x) + { + struct rx_possible_future *eclose = scratch[x]->futures; + struct rx_nfa_edge *edge = scratch[x]->edges; + struct rx_nfa_state *cn = new_state++; + cn->futures = 0; + cn->edges = 0; + cn->next = (x == total_nodec - 1) ? 0 : (cn + 1); + cn->id = scratch[x]->id; + cn->is_final = scratch[x]->is_final; + cn->is_start = scratch[x]->is_start; + cn->mark = 0; + while (edge) + { + int indx = (edge->dest->id < 0 + ? (total_nodec + edge->dest->id) + : edge->dest->id); + struct rx_nfa_edge *e = new_edge++; + rx_Bitset cset = (rx_Bitset) new_bitset; + new_bitset += rx_sizeof_bitset (rx->local_cset_size); + rx_bitset_null (rx->local_cset_size, cset); + rx_bitset_union (rx->local_cset_size, cset, edge->params.cset); + e->next = cn->edges; + cn->edges = e; + e->type = edge->type; + e->dest = state_base + indx; + e->params.cset = cset; + edge = edge->next; + } + while (eclose) + { + struct rx_possible_future *ec = new_close++; + struct rx_hash_item * sp; + struct rx_se_list ** sepos; + struct rx_se_list * sesrc; + struct rx_nfa_state_set * destlst; + struct rx_nfa_state_set ** destpos; + ec->next = cn->futures; + cn->futures = ec; + for (sepos = &ec->effects, sesrc = eclose->effects; + sesrc; + sesrc = sesrc->cdr, sepos = &(*sepos)->cdr) + { + sp = rx_hash_find (&rx->se_list_memo, + (long)sesrc->car ^ (long)sesrc->cdr, + sesrc, &se_list_hash_rules); + if (sp->binding) + { + sesrc = (struct rx_se_list *)sp->binding; + break; + } + *new_se_list = *sesrc; + sp->binding = (void *)new_se_list; + *sepos = new_se_list; + ++new_se_list; + } + *sepos = sesrc; + for (destpos = &ec->destset, destlst = eclose->destset; + destlst; + destpos = &(*destpos)->cdr, destlst = destlst->cdr) + { + sp = rx_hash_find (&rx->set_list_memo, + ((((long)destlst->car) >> 8) + ^ (long)destlst->cdr), + destlst, &nfa_set_hash_rules); + if (sp->binding) + { + destlst = (struct rx_nfa_state_set *)sp->binding; + break; + } + *new_nfa_set = *destlst; + new_nfa_set->car = state_base + destlst->car->id; + sp->binding = (void *)new_nfa_set; + *destpos = new_nfa_set; + ++new_nfa_set; + } + *destpos = destlst; + eclose = eclose->next; + } + } + } + rx_free_hash_table (&rx->se_list_memo, se_memo_freer, &se_list_hash_rules); + bzero (&rx->se_list_memo, sizeof (rx->se_list_memo)); + rx_free_hash_table (&rx->set_list_memo, nfa_set_freer, &nfa_set_hash_rules); + bzero (&rx->set_list_memo, sizeof (rx->set_list_memo)); + + rx_free_nfa (rx); + rx->nfa_states = (struct rx_nfa_state *)*mem; + return 1; +} + + +/* The functions in the next several pages define the lazy-NFA-conversion used + * by matchers. The input to this construction is an NFA such as + * is built by compactify_nfa (rx.c). The output is the superNFA. + */ + +/* Match engines can use arbitrary values for opcodes. So, the parse tree + * is built using instructions names (enum rx_opcode), but the superstate + * nfa is populated with mystery opcodes (void *). + * + * For convenience, here is an id table. The opcodes are == to their inxs + * + * The lables in re_search_2 would make good values for instructions. + */ + +void * rx_id_instruction_table[rx_num_instructions] = +{ + (void *) rx_backtrack_point, + (void *) rx_do_side_effects, + (void *) rx_cache_miss, + (void *) rx_next_char, + (void *) rx_backtrack, + (void *) rx_error_inx +}; + + + +/* Memory mgt. for superstate graphs. */ + +#ifdef __STDC__ +static char * +rx_cache_malloc (struct rx_cache * cache, int bytes) +#else +static char * +rx_cache_malloc (cache, bytes) + struct rx_cache * cache; + int bytes; +#endif +{ + while (cache->bytes_left < bytes) + { + if (cache->memory_pos) + cache->memory_pos = cache->memory_pos->next; + if (!cache->memory_pos) + { + cache->morecore (cache); + if (!cache->memory_pos) + return 0; + } + cache->bytes_left = cache->memory_pos->bytes; + cache->memory_addr = ((char *)cache->memory_pos + + sizeof (struct rx_blocklist)); + } + cache->bytes_left -= bytes; + { + char * addr = cache->memory_addr; + cache->memory_addr += bytes; + return addr; + } +} + +#ifdef __STDC__ +static void +rx_cache_free (struct rx_cache * cache, + struct rx_freelist ** freelist, char * mem) +#else +static void +rx_cache_free (cache, freelist, mem) + struct rx_cache * cache; + struct rx_freelist ** freelist; + char * mem; +#endif +{ + struct rx_freelist * it = (struct rx_freelist *)mem; + it->next = *freelist; + *freelist = it; +} + + +/* The partially instantiated superstate graph has a transition + * table at every node. There is one entry for every character. + * This fills in the transition for a set. + */ +#ifdef __STDC__ +static void +install_transition (struct rx_superstate *super, + struct rx_inx *answer, rx_Bitset trcset) +#else +static void +install_transition (super, answer, trcset) + struct rx_superstate *super; + struct rx_inx *answer; + rx_Bitset trcset; +#endif +{ + struct rx_inx * transitions = super->transitions; + int chr; + for (chr = 0; chr < 256; ) + if (!*trcset) + { + ++trcset; + chr += 32; + } + else + { + RX_subset sub = *trcset; + RX_subset mask = 1; + int bound = chr + 32; + while (chr < bound) + { + if (sub & mask) + transitions [chr] = *answer; + ++chr; + mask <<= 1; + } + ++trcset; + } +} + + +#ifdef __STDC__ +static int +qlen (struct rx_superstate * q) +#else +static int +qlen (q) + struct rx_superstate * q; +#endif +{ + int count = 1; + struct rx_superstate * it; + if (!q) + return 0; + for (it = q->next_recyclable; it != q; it = it->next_recyclable) + ++count; + return count; +} + +#ifdef __STDC__ +static void +check_cache (struct rx_cache * cache) +#else +static void +check_cache (cache) + struct rx_cache * cache; +#endif +{ + struct rx_cache * you_fucked_up = 0; + int total = cache->superstates; + int semi = cache->semifree_superstates; + if (semi != qlen (cache->semifree_superstate)) + check_cache (you_fucked_up); + if ((total - semi) != qlen (cache->lru_superstate)) + check_cache (you_fucked_up); +} + +/* When a superstate is old and neglected, it can enter a + * semi-free state. A semi-free state is slated to die. + * Incoming transitions to a semi-free state are re-written + * to cause an (interpreted) fault when they are taken. + * The fault handler revives the semi-free state, patches + * incoming transitions back to normal, and continues. + * + * The idea is basicly to free in two stages, aborting + * between the two if the state turns out to be useful again. + * When a free is aborted, the rescued superstate is placed + * in the most-favored slot to maximize the time until it + * is next semi-freed. + */ + +#ifdef __STDC__ +static void +semifree_superstate (struct rx_cache * cache) +#else +static void +semifree_superstate (cache) + struct rx_cache * cache; +#endif +{ + int disqualified = cache->semifree_superstates; + if (disqualified == cache->superstates) + return; + while (cache->lru_superstate->locks) + { + cache->lru_superstate = cache->lru_superstate->next_recyclable; + ++disqualified; + if (disqualified == cache->superstates) + return; + } + { + struct rx_superstate * it = cache->lru_superstate; + it->next_recyclable->prev_recyclable = it->prev_recyclable; + it->prev_recyclable->next_recyclable = it->next_recyclable; + cache->lru_superstate = (it == it->next_recyclable + ? 0 + : it->next_recyclable); + if (!cache->semifree_superstate) + { + cache->semifree_superstate = it; + it->next_recyclable = it; + it->prev_recyclable = it; + } + else + { + it->prev_recyclable = cache->semifree_superstate->prev_recyclable; + it->next_recyclable = cache->semifree_superstate; + it->prev_recyclable->next_recyclable = it; + it->next_recyclable->prev_recyclable = it; + } + { + struct rx_distinct_future *df; + it->is_semifree = 1; + ++cache->semifree_superstates; + df = it->transition_refs; + if (df) + { + df->prev_same_dest->next_same_dest = 0; + for (df = it->transition_refs; df; df = df->next_same_dest) + { + df->future_frame.inx = cache->instruction_table[rx_cache_miss]; + df->future_frame.data = 0; + df->future_frame.data_2 = (void *) df; + /* If there are any NEXT-CHAR instruction frames that + * refer to this state, we convert them to CACHE-MISS frames. + */ + if (!df->effects + && (df->edge->options->next_same_super_edge[0] + == df->edge->options)) + install_transition (df->present, &df->future_frame, + df->edge->cset); + } + df = it->transition_refs; + df->prev_same_dest->next_same_dest = df; + } + } + } +} + + +#ifdef __STDC__ +static void +refresh_semifree_superstate (struct rx_cache * cache, + struct rx_superstate * super) +#else +static void +refresh_semifree_superstate (cache, super) + struct rx_cache * cache; + struct rx_superstate * super; +#endif +{ + struct rx_distinct_future *df; + + if (super->transition_refs) + { + super->transition_refs->prev_same_dest->next_same_dest = 0; + for (df = super->transition_refs; df; df = df->next_same_dest) + { + df->future_frame.inx = cache->instruction_table[rx_next_char]; + df->future_frame.data = (void *) super->transitions; + /* CACHE-MISS instruction frames that refer to this state, + * must be converted to NEXT-CHAR frames. + */ + if (!df->effects + && (df->edge->options->next_same_super_edge[0] + == df->edge->options)) + install_transition (df->present, &df->future_frame, + df->edge->cset); + } + super->transition_refs->prev_same_dest->next_same_dest + = super->transition_refs; + } + if (cache->semifree_superstate == super) + cache->semifree_superstate = (super->prev_recyclable == super + ? 0 + : super->prev_recyclable); + super->next_recyclable->prev_recyclable = super->prev_recyclable; + super->prev_recyclable->next_recyclable = super->next_recyclable; + + if (!cache->lru_superstate) + (cache->lru_superstate + = super->next_recyclable + = super->prev_recyclable + = super); + else + { + super->next_recyclable = cache->lru_superstate; + super->prev_recyclable = cache->lru_superstate->prev_recyclable; + super->next_recyclable->prev_recyclable = super; + super->prev_recyclable->next_recyclable = super; + } + super->is_semifree = 0; + --cache->semifree_superstates; +} + +#ifdef __STDC__ +static void +rx_refresh_this_superstate (struct rx_cache * cache, struct rx_superstate * superstate) +#else +static void +rx_refresh_this_superstate (cache, superstate) + struct rx_cache * cache; + struct rx_superstate * superstate; +#endif +{ + if (superstate->is_semifree) + refresh_semifree_superstate (cache, superstate); + else if (cache->lru_superstate == superstate) + cache->lru_superstate = superstate->next_recyclable; + else if (superstate != cache->lru_superstate->prev_recyclable) + { + superstate->next_recyclable->prev_recyclable + = superstate->prev_recyclable; + superstate->prev_recyclable->next_recyclable + = superstate->next_recyclable; + superstate->next_recyclable = cache->lru_superstate; + superstate->prev_recyclable = cache->lru_superstate->prev_recyclable; + superstate->next_recyclable->prev_recyclable = superstate; + superstate->prev_recyclable->next_recyclable = superstate; + } +} + +#ifdef __STDC__ +static void +release_superset_low (struct rx_cache * cache, + struct rx_superset *set) +#else +static void +release_superset_low (cache, set) + struct rx_cache * cache; + struct rx_superset *set; +#endif +{ + if (!--set->refs) + { + if (set->cdr) + release_superset_low (cache, set->cdr); + + set->starts_for = 0; + + rx_hash_free + (rx_hash_find + (&cache->superset_table, + (unsigned long)set->car ^ set->id ^ (unsigned long)set->cdr, + (void *)set, + &cache->superset_hash_rules), + &cache->superset_hash_rules); + rx_cache_free (cache, &cache->free_supersets, (char *)set); + } +} + +#ifdef __STDC__ +RX_DECL void +rx_release_superset (struct rx *rx, + struct rx_superset *set) +#else +RX_DECL void +rx_release_superset (rx, set) + struct rx *rx; + struct rx_superset *set; +#endif +{ + release_superset_low (rx->cache, set); +} + +/* This tries to add a new superstate to the superstate freelist. + * It might, as a result, free some edge pieces or hash tables. + * If nothing can be freed because too many locks are being held, fail. + */ + +#ifdef __STDC__ +static int +rx_really_free_superstate (struct rx_cache * cache) +#else +static int +rx_really_free_superstate (cache) + struct rx_cache * cache; +#endif +{ + int locked_superstates = 0; + struct rx_superstate * it; + + if (!cache->superstates) + return 0; + + { + /* This is a total guess. The idea is that we should expect as + * many misses as we've recently experienced. I.e., cache->misses + * should be the same as cache->semifree_superstates. + */ + while ((cache->hits + cache->misses) > cache->superstates_allowed) + { + cache->hits >>= 1; + cache->misses >>= 1; + } + if ( ((cache->hits + cache->misses) * cache->semifree_superstates) + < (cache->superstates * cache->misses)) + { + semifree_superstate (cache); + semifree_superstate (cache); + } + } + + while (cache->semifree_superstate && cache->semifree_superstate->locks) + { + refresh_semifree_superstate (cache, cache->semifree_superstate); + ++locked_superstates; + if (locked_superstates == cache->superstates) + return 0; + } + + if (cache->semifree_superstate) + { + it = cache->semifree_superstate; + it->next_recyclable->prev_recyclable = it->prev_recyclable; + it->prev_recyclable->next_recyclable = it->next_recyclable; + cache->semifree_superstate = ((it == it->next_recyclable) + ? 0 + : it->next_recyclable); + --cache->semifree_superstates; + } + else + { + while (cache->lru_superstate->locks) + { + cache->lru_superstate = cache->lru_superstate->next_recyclable; + ++locked_superstates; + if (locked_superstates == cache->superstates) + return 0; + } + it = cache->lru_superstate; + it->next_recyclable->prev_recyclable = it->prev_recyclable; + it->prev_recyclable->next_recyclable = it->next_recyclable; + cache->lru_superstate = ((it == it->next_recyclable) + ? 0 + : it->next_recyclable); + } + + if (it->transition_refs) + { + struct rx_distinct_future *df; + for (df = it->transition_refs, + df->prev_same_dest->next_same_dest = 0; + df; + df = df->next_same_dest) + { + df->future_frame.inx = cache->instruction_table[rx_cache_miss]; + df->future_frame.data = 0; + df->future_frame.data_2 = (void *) df; + df->future = 0; + } + it->transition_refs->prev_same_dest->next_same_dest = + it->transition_refs; + } + { + struct rx_super_edge *tc = it->edges; + while (tc) + { + struct rx_distinct_future * df; + struct rx_super_edge *tct = tc->next; + df = tc->options; + df->next_same_super_edge[1]->next_same_super_edge[0] = 0; + while (df) + { + struct rx_distinct_future *dft = df; + df = df->next_same_super_edge[0]; + + + if (dft->future && dft->future->transition_refs == dft) + { + dft->future->transition_refs = dft->next_same_dest; + if (dft->future->transition_refs == dft) + dft->future->transition_refs = 0; + } + dft->next_same_dest->prev_same_dest = dft->prev_same_dest; + dft->prev_same_dest->next_same_dest = dft->next_same_dest; + rx_cache_free (cache, &cache->free_discernable_futures, + (char *)dft); + } + rx_cache_free (cache, &cache->free_transition_classes, (char *)tc); + tc = tct; + } + } + + if (it->contents->superstate == it) + it->contents->superstate = 0; + release_superset_low (cache, it->contents); + rx_cache_free (cache, &cache->free_superstates, (char *)it); + --cache->superstates; + return 1; +} + +#ifdef __STDC__ +static char * +rx_cache_get (struct rx_cache * cache, + struct rx_freelist ** freelist) +#else +static char * +rx_cache_get (cache, freelist) + struct rx_cache * cache; + struct rx_freelist ** freelist; +#endif +{ + while (!*freelist && rx_really_free_superstate (cache)) + ; + if (!*freelist) + return 0; + { + struct rx_freelist * it = *freelist; + *freelist = it->next; + return (char *)it; + } +} + +#ifdef __STDC__ +static char * +rx_cache_malloc_or_get (struct rx_cache * cache, + struct rx_freelist ** freelist, int bytes) +#else +static char * +rx_cache_malloc_or_get (cache, freelist, bytes) + struct rx_cache * cache; + struct rx_freelist ** freelist; + int bytes; +#endif +{ + if (!*freelist) + { + char * answer = rx_cache_malloc (cache, bytes); + if (answer) + return answer; + } + + return rx_cache_get (cache, freelist); +} + +#ifdef __STDC__ +static char * +rx_cache_get_superstate (struct rx_cache * cache) +#else +static char * +rx_cache_get_superstate (cache) + struct rx_cache * cache; +#endif +{ + char * answer; + int bytes = ( sizeof (struct rx_superstate) + + cache->local_cset_size * sizeof (struct rx_inx)); + if (!cache->free_superstates + && (cache->superstates < cache->superstates_allowed)) + { + answer = rx_cache_malloc (cache, bytes); + if (answer) + { + ++cache->superstates; + return answer; + } + } + answer = rx_cache_get (cache, &cache->free_superstates); + if (!answer) + { + answer = rx_cache_malloc (cache, bytes); + if (answer) + ++cache->superstates_allowed; + } + ++cache->superstates; + return answer; +} + + + +#ifdef __STDC__ +static int +supersetcmp (void * va, void * vb) +#else +static int +supersetcmp (va, vb) + void * va; + void * vb; +#endif +{ + struct rx_superset * a = (struct rx_superset *)va; + struct rx_superset * b = (struct rx_superset *)vb; + return ( (a == b) + || (a && b && (a->car == b->car) && (a->cdr == b->cdr))); +} + +#ifdef __STDC__ +static struct rx_hash_item * +superset_allocator (struct rx_hash_rules * rules, void * val) +#else +static struct rx_hash_item * +superset_allocator (rules, val) + struct rx_hash_rules * rules; + void * val; +#endif +{ + struct rx_cache * cache + = ((struct rx_cache *) + ((char *)rules + - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules))); + struct rx_superset * template = (struct rx_superset *)val; + struct rx_superset * newset + = ((struct rx_superset *) + rx_cache_malloc_or_get (cache, + &cache->free_supersets, + sizeof (*template))); + if (!newset) + return 0; + newset->refs = 0; + newset->car = template->car; + newset->id = template->car->id; + newset->cdr = template->cdr; + newset->superstate = 0; + rx_protect_superset (rx, template->cdr); + newset->hash_item.data = (void *)newset; + newset->hash_item.binding = 0; + return &newset->hash_item; +} + +#ifdef __STDC__ +static struct rx_hash * +super_hash_allocator (struct rx_hash_rules * rules) +#else +static struct rx_hash * +super_hash_allocator (rules) + struct rx_hash_rules * rules; +#endif +{ + struct rx_cache * cache + = ((struct rx_cache *) + ((char *)rules + - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules))); + return ((struct rx_hash *) + rx_cache_malloc_or_get (cache, + &cache->free_hash, sizeof (struct rx_hash))); +} + + +#ifdef __STDC__ +static void +super_hash_liberator (struct rx_hash * hash, struct rx_hash_rules * rules) +#else +static void +super_hash_liberator (hash, rules) + struct rx_hash * hash; + struct rx_hash_rules * rules; +#endif +{ + struct rx_cache * cache + = ((struct rx_cache *) + (char *)rules - (long)(&((struct rx_cache *)0)->superset_hash_rules)); + rx_cache_free (cache, &cache->free_hash, (char *)hash); +} + +#ifdef __STDC__ +static void +superset_hash_item_liberator (struct rx_hash_item * it, + struct rx_hash_rules * rules) +#else +static void +superset_hash_item_liberator (it, rules) /* Well, it does ya know. */ + struct rx_hash_item * it; + struct rx_hash_rules * rules; +#endif +{ +} + +int rx_cache_bound = 128; +static int rx_default_cache_got = 0; + +#ifdef __STDC__ +static int +bytes_for_cache_size (int supers, int cset_size) +#else +static int +bytes_for_cache_size (supers, cset_size) + int supers; + int cset_size; +#endif +{ + /* What the hell is this? !!!*/ + return (int) + ((float)supers * + ( (1.03 * (float) ( rx_sizeof_bitset (cset_size) + + sizeof (struct rx_super_edge))) + + (1.80 * (float) sizeof (struct rx_possible_future)) + + (float) ( sizeof (struct rx_superstate) + + cset_size * sizeof (struct rx_inx)))); +} + +#ifdef __STDC__ +static void +rx_morecore (struct rx_cache * cache) +#else +static void +rx_morecore (cache) + struct rx_cache * cache; +#endif +{ + if (rx_default_cache_got >= rx_cache_bound) + return; + + rx_default_cache_got += 16; + cache->superstates_allowed = rx_cache_bound; + { + struct rx_blocklist ** pos = &cache->memory; + int size = bytes_for_cache_size (16, cache->local_cset_size); + while (*pos) + pos = &(*pos)->next; + *pos = ((struct rx_blocklist *) + malloc (size + sizeof (struct rx_blocklist))); + if (!*pos) + return; + + (*pos)->next = 0; + (*pos)->bytes = size; + cache->memory_pos = *pos; + cache->memory_addr = (char *)*pos + sizeof (**pos); + cache->bytes_left = size; + } +} + +static struct rx_cache default_cache = +{ + { + supersetcmp, + super_hash_allocator, + super_hash_liberator, + superset_allocator, + superset_hash_item_liberator, + }, + 0, + 0, + 0, + 0, + rx_morecore, + + 0, + 0, + 0, + 0, + 0, + + 0, + 0, + + 0, + + 0, + 0, + 0, + 0, + 128, + + 256, + rx_id_instruction_table, + + { + 0, + 0, + {0}, + {0}, + {0} + } +}; + +/* This adds an element to a superstate set. These sets are lists, such + * that lists with == elements are ==. The empty set is returned by + * superset_cons (rx, 0, 0) and is NOT equivelent to + * (struct rx_superset)0. + */ + +#ifdef __STDC__ +RX_DECL struct rx_superset * +rx_superset_cons (struct rx * rx, + struct rx_nfa_state *car, struct rx_superset *cdr) +#else +RX_DECL struct rx_superset * +rx_superset_cons (rx, car, cdr) + struct rx * rx; + struct rx_nfa_state *car; + struct rx_superset *cdr; +#endif +{ + struct rx_cache * cache = rx->cache; + if (!car && !cdr) + { + if (!cache->empty_superset) + { + cache->empty_superset + = ((struct rx_superset *) + rx_cache_malloc_or_get (cache, &cache->free_supersets, + sizeof (struct rx_superset))); + if (!cache->empty_superset) + return 0; + bzero (cache->empty_superset, sizeof (struct rx_superset)); + cache->empty_superset->refs = 1000; + } + return cache->empty_superset; + } + { + struct rx_superset template; + struct rx_hash_item * hit; + template.car = car; + template.cdr = cdr; + template.id = car->id; + hit = rx_hash_store (&cache->superset_table, + (unsigned long)car ^ car->id ^ (unsigned long)cdr, + (void *)&template, + &cache->superset_hash_rules); + return (hit + ? (struct rx_superset *)hit->data + : 0); + } +} + +/* This computes a union of two NFA state sets. The sets do not have the + * same representation though. One is a RX_SUPERSET structure (part + * of the superstate NFA) and the other is an NFA_STATE_SET (part of the NFA). + */ + +#ifdef __STDC__ +RX_DECL struct rx_superset * +rx_superstate_eclosure_union + (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl) +#else +RX_DECL struct rx_superset * +rx_superstate_eclosure_union (rx, set, ecl) + struct rx * rx; + struct rx_superset *set; + struct rx_nfa_state_set *ecl; +#endif +{ + if (!ecl) + return set; + + if (!set->car) + return rx_superset_cons (rx, ecl->car, + rx_superstate_eclosure_union (rx, set, ecl->cdr)); + if (set->car == ecl->car) + return rx_superstate_eclosure_union (rx, set, ecl->cdr); + + { + struct rx_superset * tail; + struct rx_nfa_state * first; + + if (set->car > ecl->car) + { + tail = rx_superstate_eclosure_union (rx, set->cdr, ecl); + first = set->car; + } + else + { + tail = rx_superstate_eclosure_union (rx, set, ecl->cdr); + first = ecl->car; + } + if (!tail) + return 0; + else + { + struct rx_superset * answer; + answer = rx_superset_cons (rx, first, tail); + if (!answer) + { + rx_protect_superset (rx, tail); + rx_release_superset (rx, tail); + return 0; + } + else + return answer; + } + } +} + + + + +/* + * This makes sure that a list of rx_distinct_futures contains + * a future for each possible set of side effects in the eclosure + * of a given state. This is some of the work of filling in a + * superstate transition. + */ + +#ifdef __STDC__ +static struct rx_distinct_future * +include_futures (struct rx *rx, + struct rx_distinct_future *df, struct rx_nfa_state + *state, struct rx_superstate *superstate) +#else +static struct rx_distinct_future * +include_futures (rx, df, state, superstate) + struct rx *rx; + struct rx_distinct_future *df; + struct rx_nfa_state *state; + struct rx_superstate *superstate; +#endif +{ + struct rx_possible_future *future; + struct rx_cache * cache = rx->cache; + for (future = state->futures; future; future = future->next) + { + struct rx_distinct_future *dfp; + struct rx_distinct_future *insert_before = 0; + if (df) + df->next_same_super_edge[1]->next_same_super_edge[0] = 0; + for (dfp = df; dfp; dfp = dfp->next_same_super_edge[0]) + if (dfp->effects == future->effects) + break; + else + { + int order = rx->se_list_cmp (rx, dfp->effects, future->effects); + if (order > 0) + { + insert_before = dfp; + dfp = 0; + break; + } + } + if (df) + df->next_same_super_edge[1]->next_same_super_edge[0] = df; + if (!dfp) + { + dfp + = ((struct rx_distinct_future *) + rx_cache_malloc_or_get (cache, &cache->free_discernable_futures, + sizeof (struct rx_distinct_future))); + if (!dfp) + return 0; + if (!df) + { + df = insert_before = dfp; + df->next_same_super_edge[0] = df->next_same_super_edge[1] = df; + } + else if (!insert_before) + insert_before = df; + else if (insert_before == df) + df = dfp; + + dfp->next_same_super_edge[0] = insert_before; + dfp->next_same_super_edge[1] + = insert_before->next_same_super_edge[1]; + dfp->next_same_super_edge[1]->next_same_super_edge[0] = dfp; + dfp->next_same_super_edge[0]->next_same_super_edge[1] = dfp; + dfp->next_same_dest = dfp->prev_same_dest = dfp; + dfp->future = 0; + dfp->present = superstate; + dfp->future_frame.inx = rx->instruction_table[rx_cache_miss]; + dfp->future_frame.data = 0; + dfp->future_frame.data_2 = (void *) dfp; + dfp->side_effects_frame.inx + = rx->instruction_table[rx_do_side_effects]; + dfp->side_effects_frame.data = 0; + dfp->side_effects_frame.data_2 = (void *) dfp; + dfp->effects = future->effects; + } + } + return df; +} + + + +/* This constructs a new superstate from its state set. The only + * complexity here is memory management. + */ +#ifdef __STDC__ +RX_DECL struct rx_superstate * +rx_superstate (struct rx *rx, + struct rx_superset *set) +#else +RX_DECL struct rx_superstate * +rx_superstate (rx, set) + struct rx *rx; + struct rx_superset *set; +#endif +{ + struct rx_cache * cache = rx->cache; + struct rx_superstate * superstate = 0; + + /* Does the superstate already exist in the cache? */ + if (set->superstate) + { + if (set->superstate->rx_id != rx->rx_id) + { + /* Aha. It is in the cache, but belongs to a superstate + * that refers to an NFA that no longer exists. + * (We know it no longer exists because it was evidently + * stored in the same region of memory as the current nfa + * yet it has a different id.) + */ + superstate = set->superstate; + if (!superstate->is_semifree) + { + if (cache->lru_superstate == superstate) + { + cache->lru_superstate = superstate->next_recyclable; + if (cache->lru_superstate == superstate) + cache->lru_superstate = 0; + } + { + superstate->next_recyclable->prev_recyclable + = superstate->prev_recyclable; + superstate->prev_recyclable->next_recyclable + = superstate->next_recyclable; + if (!cache->semifree_superstate) + { + (cache->semifree_superstate + = superstate->next_recyclable + = superstate->prev_recyclable + = superstate); + } + else + { + superstate->next_recyclable = cache->semifree_superstate; + superstate->prev_recyclable + = cache->semifree_superstate->prev_recyclable; + superstate->next_recyclable->prev_recyclable + = superstate; + superstate->prev_recyclable->next_recyclable + = superstate; + cache->semifree_superstate = superstate; + } + ++cache->semifree_superstates; + } + } + set->superstate = 0; + goto handle_cache_miss; + } + ++cache->hits; + superstate = set->superstate; + + rx_refresh_this_superstate (cache, superstate); + return superstate; + } + + handle_cache_miss: + + /* This point reached only for cache misses. */ + ++cache->misses; +#if RX_DEBUG + if (rx_debug_trace > 1) + { + struct rx_superset * setp = set; + fprintf (stderr, "Building a superstet %d(%d): ", rx->rx_id, set); + while (setp) + { + fprintf (stderr, "%d ", setp->id); + setp = setp->cdr; + } + fprintf (stderr, "(%d)\n", set); + } +#endif + superstate = (struct rx_superstate *)rx_cache_get_superstate (cache); + if (!superstate) + return 0; + + if (!cache->lru_superstate) + (cache->lru_superstate + = superstate->next_recyclable + = superstate->prev_recyclable + = superstate); + else + { + superstate->next_recyclable = cache->lru_superstate; + superstate->prev_recyclable = cache->lru_superstate->prev_recyclable; + ( superstate->prev_recyclable->next_recyclable + = superstate->next_recyclable->prev_recyclable + = superstate); + } + superstate->rx_id = rx->rx_id; + superstate->transition_refs = 0; + superstate->locks = 0; + superstate->is_semifree = 0; + set->superstate = superstate; + superstate->contents = set; + rx_protect_superset (rx, set); + superstate->edges = 0; + { + int x; + /* None of the transitions from this superstate are known yet. */ + for (x = 0; x < rx->local_cset_size; ++x) /* &&&&& 3.8 % */ + { + struct rx_inx * ifr = &superstate->transitions[x]; + ifr->inx = rx->instruction_table [rx_cache_miss]; + ifr->data = ifr->data_2 = 0; + } + } + return superstate; +} + + +/* This computes the destination set of one edge of the superstate NFA. + * Note that a RX_DISTINCT_FUTURE is a superstate edge. + * Returns 0 on an allocation failure. + */ + +#ifdef __STDC__ +static int +solve_destination (struct rx *rx, struct rx_distinct_future *df) +#else +static int +solve_destination (rx, df) + struct rx *rx; + struct rx_distinct_future *df; +#endif +{ + struct rx_super_edge *tc = df->edge; + struct rx_superset *nfa_state; + struct rx_superset *nil_set = rx_superset_cons (rx, 0, 0); + struct rx_superset *solution = nil_set; + struct rx_superstate *dest; + + rx_protect_superset (rx, solution); + /* Iterate over all NFA states in the state set of this superstate. */ + for (nfa_state = df->present->contents; + nfa_state->car; + nfa_state = nfa_state->cdr) + { + struct rx_nfa_edge *e; + /* Iterate over all edges of each NFA state. */ + for (e = nfa_state->car->edges; e; e = e->next) + /* If we find an edge that is labeled with + * the characters we are solving for..... + */ + if (rx_bitset_is_subset (rx->local_cset_size, + tc->cset, e->params.cset)) + { + struct rx_nfa_state *n = e->dest; + struct rx_possible_future *pf; + /* ....search the partial epsilon closures of the destination + * of that edge for a path that involves the same set of + * side effects we are solving for. + * If we find such a RX_POSSIBLE_FUTURE, we add members to the + * stateset we are computing. + */ + for (pf = n->futures; pf; pf = pf->next) + if (pf->effects == df->effects) + { + struct rx_superset * old_sol; + old_sol = solution; + solution = rx_superstate_eclosure_union (rx, solution, + pf->destset); + if (!solution) + return 0; + rx_protect_superset (rx, solution); + rx_release_superset (rx, old_sol); + } + } + } + /* It is possible that the RX_DISTINCT_FUTURE we are working on has + * the empty set of NFA states as its definition. In that case, this + * is a failure point. + */ + if (solution == nil_set) + { + df->future_frame.inx = (void *) rx_backtrack; + df->future_frame.data = 0; + df->future_frame.data_2 = 0; + return 1; + } + dest = rx_superstate (rx, solution); + rx_release_superset (rx, solution); + if (!dest) + return 0; + + { + struct rx_distinct_future *dft; + dft = df; + df->prev_same_dest->next_same_dest = 0; + while (dft) + { + dft->future = dest; + dft->future_frame.inx = rx->instruction_table[rx_next_char]; + dft->future_frame.data = (void *) dest->transitions; + dft = dft->next_same_dest; + } + df->prev_same_dest->next_same_dest = df; + } + if (!dest->transition_refs) + dest->transition_refs = df; + else + { + struct rx_distinct_future *dft = dest->transition_refs->next_same_dest; + dest->transition_refs->next_same_dest = df->next_same_dest; + df->next_same_dest->prev_same_dest = dest->transition_refs; + df->next_same_dest = dft; + dft->prev_same_dest = df; + } + return 1; +} + + +/* This takes a superstate and a character, and computes some edges + * from the superstate NFA. In particular, this computes all edges + * that lead from SUPERSTATE given CHR. This function also + * computes the set of characters that share this edge set. + * This returns 0 on allocation error. + * The character set and list of edges are returned through + * the paramters CSETOUT and DFOUT. +} */ + +#ifdef __STDC__ +static int +compute_super_edge (struct rx *rx, struct rx_distinct_future **dfout, + rx_Bitset csetout, struct rx_superstate *superstate, + unsigned char chr) +#else +static int +compute_super_edge (rx, dfout, csetout, superstate, chr) + struct rx *rx; + struct rx_distinct_future **dfout; + rx_Bitset csetout; + struct rx_superstate *superstate; + unsigned char chr; +#endif +{ + struct rx_superset *stateset = superstate->contents; + + /* To compute the set of characters that share edges with CHR, + * we start with the full character set, and subtract. + */ + rx_bitset_universe (rx->local_cset_size, csetout); + *dfout = 0; + + /* Iterate over the NFA states in the superstate state-set. */ + while (stateset->car) + { + struct rx_nfa_edge *e; + for (e = stateset->car->edges; e; e = e->next) + if (RX_bitset_member (e->params.cset, chr)) + { + /* If we find an NFA edge that applies, we make sure there + * are corresponding edges in the superstate NFA. + */ + { + struct rx_distinct_future * saved; + saved = *dfout; + *dfout = include_futures (rx, *dfout, e->dest, superstate); + if (!*dfout) + { + struct rx_distinct_future * df; + df = saved; + if (df) + df->next_same_super_edge[1]->next_same_super_edge[0] = 0; + while (df) + { + struct rx_distinct_future *dft; + dft = df; + df = df->next_same_super_edge[0]; + + if (dft->future && dft->future->transition_refs == dft) + { + dft->future->transition_refs = dft->next_same_dest; + if (dft->future->transition_refs == dft) + dft->future->transition_refs = 0; + } + dft->next_same_dest->prev_same_dest = dft->prev_same_dest; + dft->prev_same_dest->next_same_dest = dft->next_same_dest; + rx_cache_free (rx->cache, + &rx->cache->free_discernable_futures, + (char *)dft); + } + return 0; + } + } + /* We also trim the character set a bit. */ + rx_bitset_intersection (rx->local_cset_size, + csetout, e->params.cset); + } + else + /* An edge that doesn't apply at least tells us some characters + * that don't share the same edge set as CHR. + */ + rx_bitset_difference (rx->local_cset_size, csetout, e->params.cset); + stateset = stateset->cdr; + } + return 1; +} + + +/* This is a constructor for RX_SUPER_EDGE structures. These are + * wrappers for lists of superstate NFA edges that share character sets labels. + * If a transition class contains more than one rx_distinct_future (superstate + * edge), then it represents a non-determinism in the superstate NFA. + */ + +#ifdef __STDC__ +static struct rx_super_edge * +rx_super_edge (struct rx *rx, + struct rx_superstate *super, rx_Bitset cset, + struct rx_distinct_future *df) +#else +static struct rx_super_edge * +rx_super_edge (rx, super, cset, df) + struct rx *rx; + struct rx_superstate *super; + rx_Bitset cset; + struct rx_distinct_future *df; +#endif +{ + struct rx_super_edge *tc = + (struct rx_super_edge *)rx_cache_malloc_or_get + (rx->cache, &rx->cache->free_transition_classes, + sizeof (struct rx_super_edge) + rx_sizeof_bitset (rx->local_cset_size)); + + if (!tc) + return 0; + tc->next = super->edges; + super->edges = tc; + tc->rx_backtrack_frame.inx = rx->instruction_table[rx_backtrack_point]; + tc->rx_backtrack_frame.data = 0; + tc->rx_backtrack_frame.data_2 = (void *) tc; + tc->options = df; + tc->cset = (rx_Bitset) ((char *) tc + sizeof (*tc)); + rx_bitset_assign (rx->local_cset_size, tc->cset, cset); + if (df) + { + struct rx_distinct_future * dfp = df; + df->next_same_super_edge[1]->next_same_super_edge[0] = 0; + while (dfp) + { + dfp->edge = tc; + dfp = dfp->next_same_super_edge[0]; + } + df->next_same_super_edge[1]->next_same_super_edge[0] = df; + } + return tc; +} + + +/* There are three kinds of cache miss. The first occurs when a + * transition is taken that has never been computed during the + * lifetime of the source superstate. That cache miss is handled by + * calling COMPUTE_SUPER_EDGE. The second kind of cache miss + * occurs when the destination superstate of a transition doesn't + * exist. SOLVE_DESTINATION is used to construct the destination superstate. + * Finally, the third kind of cache miss occurs when the destination + * superstate of a transition is in a `semi-free state'. That case is + * handled by UNFREE_SUPERSTATE. + * + * The function of HANDLE_CACHE_MISS is to figure out which of these + * cases applies. + */ + +#ifdef __STDC__ +static void +install_partial_transition (struct rx_superstate *super, + struct rx_inx *answer, + RX_subset set, int offset) +#else +static void +install_partial_transition (super, answer, set, offset) + struct rx_superstate *super; + struct rx_inx *answer; + RX_subset set; + int offset; +#endif +{ + int start = offset; + int end = start + 32; + RX_subset pos = 1; + struct rx_inx * transitions = super->transitions; + + while (start < end) + { + if (set & pos) + transitions[start] = *answer; + pos <<= 1; + ++start; + } +} + + +#ifdef __STDC__ +RX_DECL struct rx_inx * +rx_handle_cache_miss + (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data) +#else +RX_DECL struct rx_inx * +rx_handle_cache_miss (rx, super, chr, data) + struct rx *rx; + struct rx_superstate *super; + unsigned char chr; + void *data; +#endif +{ + int offset = chr / RX_subset_bits; + struct rx_distinct_future *df = data; + + if (!df) /* must be the shared_cache_miss_frame */ + { + /* Perhaps this is just a transition waiting to be filled. */ + struct rx_super_edge *tc; + RX_subset mask = rx_subset_singletons [chr % RX_subset_bits]; + + for (tc = super->edges; tc; tc = tc->next) + if (tc->cset[offset] & mask) + { + struct rx_inx * answer; + df = tc->options; + answer = ((tc->options->next_same_super_edge[0] != tc->options) + ? &tc->rx_backtrack_frame + : (df->effects + ? &df->side_effects_frame + : &df->future_frame)); + install_partial_transition (super, answer, + tc->cset [offset], offset * 32); + return answer; + } + /* Otherwise, it's a flushed or newly encountered edge. */ + { + char cset_space[1024]; /* this limit is far from unreasonable */ + rx_Bitset trcset; + struct rx_inx *answer; + + if (rx_sizeof_bitset (rx->local_cset_size) > sizeof (cset_space)) + return 0; /* If the arbitrary limit is hit, always fail */ + /* cleanly. */ + trcset = (rx_Bitset)cset_space; + rx_lock_superstate (rx, super); + if (!compute_super_edge (rx, &df, trcset, super, chr)) + { + rx_unlock_superstate (rx, super); + return 0; + } + if (!df) /* We just computed the fail transition. */ + { + static struct rx_inx + shared_fail_frame = { 0, 0, (void *)rx_backtrack, 0 }; + answer = &shared_fail_frame; + } + else + { + tc = rx_super_edge (rx, super, trcset, df); + if (!tc) + { + rx_unlock_superstate (rx, super); + return 0; + } + answer = ((tc->options->next_same_super_edge[0] != tc->options) + ? &tc->rx_backtrack_frame + : (df->effects + ? &df->side_effects_frame + : &df->future_frame)); + } + install_partial_transition (super, answer, + trcset[offset], offset * 32); + rx_unlock_superstate (rx, super); + return answer; + } + } + else if (df->future) /* A cache miss on an edge with a future? Must be + * a semi-free destination. */ + { + if (df->future->is_semifree) + refresh_semifree_superstate (rx->cache, df->future); + return &df->future_frame; + } + else + /* no future superstate on an existing edge */ + { + rx_lock_superstate (rx, super); + if (!solve_destination (rx, df)) + { + rx_unlock_superstate (rx, super); + return 0; + } + if (!df->effects + && (df->edge->options->next_same_super_edge[0] == df->edge->options)) + install_partial_transition (super, &df->future_frame, + df->edge->cset[offset], offset * 32); + rx_unlock_superstate (rx, super); + return &df->future_frame; + } +} + + + + +/* The rest of the code provides a regex.c compatable interface. */ + + +__const__ char *re_error_msg[] = +{ + 0, /* REG_NOUT */ + "No match", /* REG_NOMATCH */ + "Invalid regular expression", /* REG_BADPAT */ + "Invalid collation character", /* REG_ECOLLATE */ + "Invalid character class name", /* REG_ECTYPE */ + "Trailing backslash", /* REG_EESCAPE */ + "Invalid back reference", /* REG_ESUBREG */ + "Unmatched [ or [^", /* REG_EBRACK */ + "Unmatched ( or \\(", /* REG_EPAREN */ + "Unmatched \\{", /* REG_EBRACE */ + "Invalid content of \\{\\}", /* REG_BADBR */ + "Invalid range end", /* REG_ERANGE */ + "Memory exhausted", /* REG_ESPACE */ + "Invalid preceding regular expression", /* REG_BADRPT */ + "Premature end of regular expression", /* REG_EEND */ + "Regular expression too big", /* REG_ESIZE */ + "Unmatched ) or \\)", /* REG_ERPAREN */ +}; + + + +/* + * Macros used while compiling patterns. + * + * By convention, PEND points just past the end of the uncompiled pattern, + * P points to the read position in the pattern. `translate' is the name + * of the translation table (`TRANSLATE' is the name of a macro that looks + * things up in `translate'). + */ + + +/* + * Fetch the next character in the uncompiled pattern---translating it + * if necessary. *Also cast from a signed character in the constant + * string passed to us by the user to an unsigned char that we can use + * as an array index (in, e.g., `translate'). + */ +#define PATFETCH(c) \ + do {if (p == pend) return REG_EEND; \ + c = (unsigned char) *p++; \ + c = translate[c]; \ + } while (0) + +/* + * Fetch the next character in the uncompiled pattern, with no + * translation. + */ +#define PATFETCH_RAW(c) \ + do {if (p == pend) return REG_EEND; \ + c = (unsigned char) *p++; \ + } while (0) + +/* Go backwards one character in the pattern. */ +#define PATUNFETCH p-- + + +#define TRANSLATE(d) translate[(unsigned char) (d)] + +typedef unsigned regnum_t; + +/* Since offsets can go either forwards or backwards, this type needs to + * be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. + */ +typedef int pattern_offset_t; + +typedef struct +{ + struct rexp_node ** top_expression; /* was begalt */ + struct rexp_node ** last_expression; /* was laststart */ + pattern_offset_t inner_group_offset; + regnum_t regnum; +} compile_stack_elt_t; + +typedef struct +{ + compile_stack_elt_t *stack; + unsigned size; + unsigned avail; /* Offset of next open position. */ +} compile_stack_type; + + +#define INIT_COMPILE_STACK_SIZE 32 + +#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) +#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) + +/* The next available element. */ +#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) + + +/* Set the bit for character C in a list. */ +#define SET_LIST_BIT(c) \ + (b[((unsigned char) (c)) / CHARBITS] \ + |= 1 << (((unsigned char) c) % CHARBITS)) + +/* Get the next unsigned number in the uncompiled pattern. */ +#define GET_UNSIGNED_NUMBER(num) \ + { if (p != pend) \ + { \ + PATFETCH (c); \ + while (isdigit (c)) \ + { \ + if (num < 0) \ + num = 0; \ + num = num * 10 + c - '0'; \ + if (p == pend) \ + break; \ + PATFETCH (c); \ + } \ + } \ + } + +#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ + +#define IS_CHAR_CLASS(string) \ + (!strcmp (string, "alpha") || !strcmp (string, "upper") \ + || !strcmp (string, "lower") || !strcmp (string, "digit") \ + || !strcmp (string, "alnum") || !strcmp (string, "xdigit") \ + || !strcmp (string, "space") || !strcmp (string, "print") \ + || !strcmp (string, "punct") || !strcmp (string, "graph") \ + || !strcmp (string, "cntrl") || !strcmp (string, "blank")) + + +/* These predicates are used in regex_compile. */ + +/* P points to just after a ^ in PATTERN. Return true if that ^ comes + * after an alternative or a begin-subexpression. We assume there is at + * least one character before the ^. + */ + +#ifdef __STDC__ +static boolean +at_begline_loc_p (__const__ char *pattern, __const__ char * p, reg_syntax_t syntax) +#else +static boolean +at_begline_loc_p (pattern, p, syntax) + __const__ char *pattern; + __const__ char * p; + reg_syntax_t syntax; +#endif +{ + __const__ char *prev = p - 2; + boolean prev_prev_backslash = ((prev > pattern) && (prev[-1] == '\\')); + + return + + (/* After a subexpression? */ + ((*prev == '(') && ((syntax & RE_NO_BK_PARENS) || prev_prev_backslash)) + || + /* After an alternative? */ + ((*prev == '|') && ((syntax & RE_NO_BK_VBAR) || prev_prev_backslash)) + ); +} + +/* The dual of at_begline_loc_p. This one is for $. We assume there is + * at least one character after the $, i.e., `P < PEND'. + */ + +#ifdef __STDC__ +static boolean +at_endline_loc_p (__const__ char *p, __const__ char *pend, int syntax) +#else +static boolean +at_endline_loc_p (p, pend, syntax) + __const__ char *p; + __const__ char *pend; + int syntax; +#endif +{ + __const__ char *next = p; + boolean next_backslash = (*next == '\\'); + __const__ char *next_next = (p + 1 < pend) ? (p + 1) : 0; + + return + ( + /* Before a subexpression? */ + ((syntax & RE_NO_BK_PARENS) + ? (*next == ')') + : (next_backslash && next_next && (*next_next == ')'))) + || + /* Before an alternative? */ + ((syntax & RE_NO_BK_VBAR) + ? (*next == '|') + : (next_backslash && next_next && (*next_next == '|'))) + ); +} + + +unsigned char rx_id_translation[256] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255 +}; + +/* The compiler keeps an inverted translation table. + * This looks up/inititalize elements. + * VALID is an array of booleans that validate CACHE. + */ + +#ifdef __STDC__ +static rx_Bitset +inverse_translation (struct re_pattern_buffer * rxb, + char * valid, rx_Bitset cache, + unsigned char * translate, int c) +#else +static rx_Bitset +inverse_translation (rxb, valid, cache, translate, c) + struct re_pattern_buffer * rxb; + char * valid; + rx_Bitset cache; + unsigned char * translate; + int c; +#endif +{ + rx_Bitset cs + = cache + c * rx_bitset_numb_subsets (rxb->rx.local_cset_size); + + if (!valid[c]) + { + int x; + int c_tr = TRANSLATE(c); + rx_bitset_null (rxb->rx.local_cset_size, cs); + for (x = 0; x < 256; ++x) /* &&&& 13.37 */ + if (TRANSLATE(x) == c_tr) + RX_bitset_enjoin (cs, x); + valid[c] = 1; + } + return cs; +} + + + + +/* More subroutine declarations and macros for regex_compile. */ + +/* Returns true if REGNUM is in one of COMPILE_STACK's elements and + false if it's not. */ + +#ifdef __STDC__ +static boolean +group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) +#else +static boolean +group_in_compile_stack (compile_stack, regnum) + compile_stack_type compile_stack; + regnum_t regnum; +#endif +{ + int this_element; + + for (this_element = compile_stack.avail - 1; + this_element >= 0; + this_element--) + if (compile_stack.stack[this_element].regnum == regnum) + return true; + + return false; +} + + +/* + * Read the ending character of a range (in a bracket expression) from the + * uncompiled pattern *P_PTR (which ends at PEND). We assume the + * starting character is in `P[-2]'. (`P[-1]' is the character `-'.) + * Then we set the translation of all bits between the starting and + * ending characters (inclusive) in the compiled pattern B. + * + * Return an error code. + * + * We use these short variable names so we can use the same macros as + * `regex_compile' itself. + */ + +#ifdef __STDC__ +static reg_errcode_t +compile_range (struct re_pattern_buffer * rxb, rx_Bitset cs, + __const__ char ** p_ptr, __const__ char * pend, + unsigned char * translate, reg_syntax_t syntax, + rx_Bitset inv_tr, char * valid_inv_tr) +#else +static reg_errcode_t +compile_range (rxb, cs, p_ptr, pend, translate, syntax, inv_tr, valid_inv_tr) + struct re_pattern_buffer * rxb; + rx_Bitset cs; + __const__ char ** p_ptr; + __const__ char * pend; + unsigned char * translate; + reg_syntax_t syntax; + rx_Bitset inv_tr; + char * valid_inv_tr; +#endif +{ + unsigned this_char; + + __const__ char *p = *p_ptr; + + unsigned char range_end; + unsigned char range_start = TRANSLATE(p[-2]); + + if (p == pend) + return REG_ERANGE; + + PATFETCH (range_end); + + (*p_ptr)++; + + if (range_start > range_end) + return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; + + for (this_char = range_start; this_char <= range_end; this_char++) + { + rx_Bitset it = + inverse_translation (rxb, valid_inv_tr, inv_tr, translate, this_char); + rx_bitset_union (rxb->rx.local_cset_size, cs, it); + } + + return REG_NOERROR; +} + + +/* This searches a regexp for backreference side effects. + * It fills in the array OUT with 1 at the index of every register pair + * referenced by a backreference. + * + * This is used to help optimize patterns for searching. The information is + * useful because, if the caller doesn't want register values, backreferenced + * registers are the only registers for which we need rx_backtrack. + */ + +#ifdef __STDC__ +static void +find_backrefs (char * out, struct rexp_node * rexp, + struct re_se_params * params) +#else +static void +find_backrefs (out, rexp, params) + char * out; + struct rexp_node * rexp; + struct re_se_params * params; +#endif +{ + if (rexp) + switch (rexp->type) + { + case r_cset: + case r_data: + return; + case r_alternate: + case r_concat: + case r_opt: + case r_star: + case r_2phase_star: + find_backrefs (out, rexp->params.pair.left, params); + find_backrefs (out, rexp->params.pair.right, params); + return; + case r_side_effect: + if ( ((long)rexp->params.side_effect >= 0) + && (params [(long)rexp->params.side_effect].se == re_se_backref)) + out[ params [(long)rexp->params.side_effect].op1] = 1; + return; + } +} + + + +/* Returns 0 unless the pattern can match the empty string. */ + +#ifdef __STDC__ +static int +compute_fastset (struct re_pattern_buffer * rxb, struct rexp_node * rexp) +#else +static int +compute_fastset (rxb, rexp) + struct re_pattern_buffer * rxb; + struct rexp_node * rexp; +#endif +{ + if (!rexp) + return 1; + switch (rexp->type) + { + case r_data: + return 1; + case r_cset: + { + rx_bitset_union (rxb->rx.local_cset_size, + rxb->fastset, rexp->params.cset); + } + return 0; + case r_concat: + return (compute_fastset (rxb, rexp->params.pair.left) + && compute_fastset (rxb, rexp->params.pair.right)); + case r_2phase_star: + compute_fastset (rxb, rexp->params.pair.left); + /* compute_fastset (rxb, rexp->params.pair.right); nope... */ + return 1; + case r_alternate: + return !!(compute_fastset (rxb, rexp->params.pair.left) + + compute_fastset (rxb, rexp->params.pair.right)); + case r_opt: + case r_star: + compute_fastset (rxb, rexp->params.pair.left); + return 1; + case r_side_effect: + return 1; + } + + /* this should never happen */ + return 0; +} + + +/* returns + * 1 -- yes, definately anchored by the given side effect. + * 2 -- maybe anchored, maybe the empty string. + * 0 -- definately not anchored + * There is simply no other possibility. + */ + +#ifdef __STDC__ +static int +is_anchored (struct rexp_node * rexp, rx_side_effect se) +#else +static int +is_anchored (rexp, se) + struct rexp_node * rexp; + rx_side_effect se; +#endif +{ + if (!rexp) + return 2; + switch (rexp->type) + { + case r_cset: + case r_data: + return 0; + case r_concat: + case r_2phase_star: + { + int l = is_anchored (rexp->params.pair.left, se); + return (l == 2 ? is_anchored (rexp->params.pair.right, se) : l); + } + case r_alternate: + { + int l = is_anchored (rexp->params.pair.left, se); + int r = l ? is_anchored (rexp->params.pair.right, se) : 0; + + if (l == r) + return l; + else if ((l == 0) || (r == 0)) + return 0; + else + return 2; + } + case r_opt: + case r_star: + return is_anchored (rexp->params.pair.left, se) ? 2 : 0; + + case r_side_effect: + return ((rexp->params.side_effect == se) + ? 1 : 2); + } + + /* this should never happen */ + return 0; +} + + +/* This removes register assignments that aren't required by backreferencing. + * This can speed up explore_future, especially if it eliminates + * non-determinism in the superstate NFA. + * + * NEEDED is an array of characters, presumably filled in by FIND_BACKREFS. + * The non-zero elements of the array indicate which register assignments + * can NOT be removed from the expression. + */ + +#ifdef __STDC__ +static struct rexp_node * +remove_unecessary_side_effects (struct rx * rx, char * needed, + struct rexp_node * rexp, + struct re_se_params * params) +#else +static struct rexp_node * +remove_unecessary_side_effects (rx, needed, rexp, params) + struct rx * rx; + char * needed; + struct rexp_node * rexp; + struct re_se_params * params; +#endif +{ + struct rexp_node * l; + struct rexp_node * r; + if (!rexp) + return 0; + else + switch (rexp->type) + { + case r_cset: + case r_data: + return rexp; + case r_alternate: + case r_concat: + case r_2phase_star: + l = remove_unecessary_side_effects (rx, needed, + rexp->params.pair.left, params); + r = remove_unecessary_side_effects (rx, needed, + rexp->params.pair.right, params); + if ((l && r) || (rexp->type != r_concat)) + { + rexp->params.pair.left = l; + rexp->params.pair.right = r; + return rexp; + } + else + { + rexp->params.pair.left = rexp->params.pair.right = 0; + rx_free_rexp (rx, rexp); + return l ? l : r; + } + case r_opt: + case r_star: + l = remove_unecessary_side_effects (rx, needed, + rexp->params.pair.left, params); + if (l) + { + rexp->params.pair.left = l; + return rexp; + } + else + { + rexp->params.pair.left = 0; + rx_free_rexp (rx, rexp); + return 0; + } + case r_side_effect: + { + int se = (long)rexp->params.side_effect; + if ( (se >= 0) + && ( ((enum re_side_effects)params[se].se == re_se_lparen) + || ((enum re_side_effects)params[se].se == re_se_rparen)) + && (params [se].op1 > 0) + && (!needed [params [se].op1])) + { + rx_free_rexp (rx, rexp); + return 0; + } + else + return rexp; + } + } + + /* this should never happen */ + return 0; +} + + + +#ifdef __STDC__ +static int +pointless_if_repeated (struct rexp_node * node, struct re_se_params * params) +#else +static int +pointless_if_repeated (node, params) + struct rexp_node * node; + struct re_se_params * params; +#endif +{ + if (!node) + return 1; + switch (node->type) + { + case r_cset: + return 0; + case r_alternate: + case r_concat: + case r_2phase_star: + return (pointless_if_repeated (node->params.pair.left, params) + && pointless_if_repeated (node->params.pair.right, params)); + case r_opt: + case r_star: + return pointless_if_repeated (node->params.pair.left, params); + case r_side_effect: + switch (((long)node->params.side_effect < 0) + ? (enum re_side_effects)node->params.side_effect + : (enum re_side_effects)params[(long)node->params.side_effect].se) + { + case re_se_try: + case re_se_at_dot: + case re_se_begbuf: + case re_se_hat: + case re_se_wordbeg: + case re_se_wordbound: + case re_se_notwordbound: + case re_se_wordend: + case re_se_endbuf: + case re_se_dollar: + case re_se_fail: + case re_se_win: + return 1; + case re_se_lparen: + case re_se_rparen: + case re_se_iter: + case re_se_end_iter: + case re_se_syntax: + case re_se_not_syntax: + case re_se_backref: + return 0; + } + case r_data: + default: + return 0; + } +} + + + +#ifdef __STDC__ +static int +registers_on_stack (struct re_pattern_buffer * rxb, + struct rexp_node * rexp, int in_danger, + struct re_se_params * params) +#else +static int +registers_on_stack (rxb, rexp, in_danger, params) + struct re_pattern_buffer * rxb; + struct rexp_node * rexp; + int in_danger; + struct re_se_params * params; +#endif +{ + if (!rexp) + return 0; + else + switch (rexp->type) + { + case r_cset: + case r_data: + return 0; + case r_alternate: + case r_concat: + return ( registers_on_stack (rxb, rexp->params.pair.left, + in_danger, params) + || (registers_on_stack + (rxb, rexp->params.pair.right, + in_danger, params))); + case r_opt: + return registers_on_stack (rxb, rexp->params.pair.left, 0, params); + case r_star: + return registers_on_stack (rxb, rexp->params.pair.left, 1, params); + case r_2phase_star: + return + ( registers_on_stack (rxb, rexp->params.pair.left, 1, params) + || registers_on_stack (rxb, rexp->params.pair.right, 1, params)); + case r_side_effect: + { + int se = (long)rexp->params.side_effect; + if ( in_danger + && (se >= 0) + && (params [se].op1 > 0) + && ( ((enum re_side_effects)params[se].se == re_se_lparen) + || ((enum re_side_effects)params[se].se == re_se_rparen))) + return 1; + else + return 0; + } + } + + /* this should never happen */ + return 0; +} + + + +static char idempotent_complex_se[] = +{ +#define RX_WANT_SE_DEFS 1 +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#define RX_DEF_SE(IDEM, NAME, VALUE) +#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) IDEM, +#include "rx.h" +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#undef RX_WANT_SE_DEFS + 23 +}; + +static char idempotent_se[] = +{ + 13, +#define RX_WANT_SE_DEFS 1 +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#define RX_DEF_SE(IDEM, NAME, VALUE) IDEM, +#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) +#include "rx.h" +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#undef RX_WANT_SE_DEFS + 42 +}; + + + + +#ifdef __STDC__ +static int +has_any_se (struct rx * rx, + struct rexp_node * rexp) +#else +static int +has_any_se (rx, rexp) + struct rx * rx; + struct rexp_node * rexp; +#endif +{ + if (!rexp) + return 0; + + switch (rexp->type) + { + case r_cset: + case r_data: + return 0; + + case r_side_effect: + return 1; + + case r_2phase_star: + case r_concat: + case r_alternate: + return + ( has_any_se (rx, rexp->params.pair.left) + || has_any_se (rx, rexp->params.pair.right)); + + case r_opt: + case r_star: + return has_any_se (rx, rexp->params.pair.left); + } + + /* this should never happen */ + return 0; +} + + + +/* This must be called AFTER `convert_hard_loops' for a given REXP. */ +#ifdef __STDC__ +static int +has_non_idempotent_epsilon_path (struct rx * rx, + struct rexp_node * rexp, + struct re_se_params * params) +#else +static int +has_non_idempotent_epsilon_path (rx, rexp, params) + struct rx * rx; + struct rexp_node * rexp; + struct re_se_params * params; +#endif +{ + if (!rexp) + return 0; + + switch (rexp->type) + { + case r_cset: + case r_data: + case r_star: + return 0; + + case r_side_effect: + return + !((long)rexp->params.side_effect > 0 + ? idempotent_complex_se [ params [(long)rexp->params.side_effect].se ] + : idempotent_se [-(long)rexp->params.side_effect]); + + case r_alternate: + return + ( has_non_idempotent_epsilon_path (rx, + rexp->params.pair.left, params) + || has_non_idempotent_epsilon_path (rx, + rexp->params.pair.right, params)); + + case r_2phase_star: + case r_concat: + return + ( has_non_idempotent_epsilon_path (rx, + rexp->params.pair.left, params) + && has_non_idempotent_epsilon_path (rx, + rexp->params.pair.right, params)); + + case r_opt: + return has_non_idempotent_epsilon_path (rx, + rexp->params.pair.left, params); + } + + /* this should never happen */ + return 0; +} + + + +/* This computes rougly what it's name suggests. It can (and does) go wrong + * in the direction of returning spurious 0 without causing disasters. + */ +#ifdef __STDC__ +static int +begins_with_complex_se (struct rx * rx, struct rexp_node * rexp) +#else +static int +begins_with_complex_se (rx, rexp) + struct rx * rx; + struct rexp_node * rexp; +#endif +{ + if (!rexp) + return 0; + + switch (rexp->type) + { + case r_cset: + case r_data: + return 0; + + case r_side_effect: + return ((long)rexp->params.side_effect >= 0); + + case r_alternate: + return + ( begins_with_complex_se (rx, rexp->params.pair.left) + && begins_with_complex_se (rx, rexp->params.pair.right)); + + + case r_concat: + return has_any_se (rx, rexp->params.pair.left); + case r_opt: + case r_star: + case r_2phase_star: + return 0; + } + + /* this should never happen */ + return 0; +} + + +/* This destructively removes some of the re_se_tv side effects from + * a rexp tree. In particular, during parsing re_se_tv was inserted on the + * right half of every | to guarantee that posix path preference could be + * honored. This function removes some which it can be determined aren't + * needed. + */ + +#ifdef __STDC__ +static void +speed_up_alt (struct rx * rx, + struct rexp_node * rexp, + int unposix) +#else +static void +speed_up_alt (rx, rexp, unposix) + struct rx * rx; + struct rexp_node * rexp; + int unposix; +#endif +{ + if (!rexp) + return; + + switch (rexp->type) + { + case r_cset: + case r_data: + case r_side_effect: + return; + + case r_opt: + case r_star: + speed_up_alt (rx, rexp->params.pair.left, unposix); + return; + + case r_2phase_star: + case r_concat: + speed_up_alt (rx, rexp->params.pair.left, unposix); + speed_up_alt (rx, rexp->params.pair.right, unposix); + return; + + case r_alternate: + /* the right child is guaranteed to be (concat re_se_tv ) */ + + speed_up_alt (rx, rexp->params.pair.left, unposix); + speed_up_alt (rx, rexp->params.pair.right->params.pair.right, unposix); + + if ( unposix + || (begins_with_complex_se + (rx, rexp->params.pair.right->params.pair.right)) + || !( has_any_se (rx, rexp->params.pair.right->params.pair.right) + || has_any_se (rx, rexp->params.pair.left))) + { + struct rexp_node * conc = rexp->params.pair.right; + rexp->params.pair.right = conc->params.pair.right; + conc->params.pair.right = 0; + rx_free_rexp (rx, conc); + } + } +} + + + + + +/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. + Returns one of error codes defined in `regex.h', or zero for success. + + Assumes the `allocated' (and perhaps `buffer') and `translate' + fields are set in BUFP on entry. + + If it succeeds, results are put in BUFP (if it returns an error, the + contents of BUFP are undefined): + `buffer' is the compiled pattern; + `syntax' is set to SYNTAX; + `used' is set to the length of the compiled pattern; + `fastmap_accurate' is set to zero; + `re_nsub' is set to the number of groups in PATTERN; + `not_bol' and `not_eol' are set to zero. + + The `fastmap' and `newline_anchor' fields are neither + examined nor set. */ + + + +#ifdef __STDC__ +RX_DECL reg_errcode_t +rx_compile (__const__ char *pattern, int size, + reg_syntax_t syntax, + struct re_pattern_buffer * rxb) +#else +RX_DECL reg_errcode_t +rx_compile (pattern, size, syntax, rxb) + __const__ char *pattern; + int size; + reg_syntax_t syntax; + struct re_pattern_buffer * rxb; +#endif +{ + RX_subset + inverse_translate [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)]; + char + validate_inv_tr [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)]; + + /* We fetch characters from PATTERN here. Even though PATTERN is + `char *' (i.e., signed), we declare these variables as unsigned, so + they can be reliably used as array indices. */ + register unsigned char c, c1; + + /* A random tempory spot in PATTERN. */ + __const__ char *p1; + + /* Keeps track of unclosed groups. */ + compile_stack_type compile_stack; + + /* Points to the current (ending) position in the pattern. */ + __const__ char *p = pattern; + __const__ char *pend = pattern + size; + + /* How to translate the characters in the pattern. */ + unsigned char *translate = (rxb->translate + ? rxb->translate + : rx_id_translation); + + /* When parsing is done, this will hold the expression tree. */ + struct rexp_node * rexp = 0; + + /* In the midst of compilation, this holds onto the regexp + * first parst while rexp goes on to aquire additional constructs. + */ + struct rexp_node * orig_rexp = 0; + struct rexp_node * fewer_side_effects = 0; + + /* This and top_expression are saved on the compile stack. */ + struct rexp_node ** top_expression = &rexp; + struct rexp_node ** last_expression = top_expression; + + /* Parameter to `goto append_node' */ + struct rexp_node * append; + + /* Counts open-groups as they are encountered. This is the index of the + * innermost group being compiled. + */ + regnum_t regnum = 0; + + /* Place in the uncompiled pattern (i.e., the {) to + * which to go back if the interval is invalid. + */ + __const__ char *beg_interval; + + struct re_se_params * params = 0; + int paramc = 0; /* How many complex side effects so far? */ + + rx_side_effect side; /* param to `goto add_side_effect' */ + + bzero (validate_inv_tr, sizeof (validate_inv_tr)); + + rxb->rx.instruction_table = rx_id_instruction_table; + + + /* Initialize the compile stack. */ + compile_stack.stack = (( compile_stack_elt_t *) malloc ((INIT_COMPILE_STACK_SIZE) * sizeof ( compile_stack_elt_t))); + if (compile_stack.stack == 0) + return REG_ESPACE; + + compile_stack.size = INIT_COMPILE_STACK_SIZE; + compile_stack.avail = 0; + + /* Initialize the pattern buffer. */ + rxb->rx.cache = &default_cache; + rxb->syntax = syntax; + rxb->fastmap_accurate = 0; + rxb->not_bol = rxb->not_eol = 0; + rxb->least_subs = 0; + + /* Always count groups, whether or not rxb->no_sub is set. + * The whole pattern is implicitly group 0, so counting begins + * with 1. + */ + rxb->re_nsub = 0; + +#if !defined (emacs) && !defined (SYNTAX_TABLE) + /* Initialize the syntax table. */ + init_syntax_once (); +#endif + + /* Loop through the uncompiled pattern until we're at the end. */ + while (p != pend) + { + PATFETCH (c); + + switch (c) + { + case '^': + { + if ( /* If at start of pattern, it's an operator. */ + p == pattern + 1 + /* If context independent, it's an operator. */ + || syntax & RE_CONTEXT_INDEP_ANCHORS + /* Otherwise, depends on what's come before. */ + || at_begline_loc_p (pattern, p, syntax)) + { + struct rexp_node * n + = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_hat); + if (!n) + return REG_ESPACE; + append = n; + goto append_node; + } + else + goto normal_char; + } + break; + + + case '$': + { + if ( /* If at end of pattern, it's an operator. */ + p == pend + /* If context independent, it's an operator. */ + || syntax & RE_CONTEXT_INDEP_ANCHORS + /* Otherwise, depends on what's next. */ + || at_endline_loc_p (p, pend, syntax)) + { + struct rexp_node * n + = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_dollar); + if (!n) + return REG_ESPACE; + append = n; + goto append_node; + } + else + goto normal_char; + } + break; + + + case '+': + case '?': + if ((syntax & RE_BK_PLUS_QM) + || (syntax & RE_LIMITED_OPS)) + goto normal_char; + + handle_plus: + case '*': + /* If there is no previous pattern... */ + if (pointless_if_repeated (*last_expression, params)) + { + if (syntax & RE_CONTEXT_INVALID_OPS) + return REG_BADRPT; + else if (!(syntax & RE_CONTEXT_INDEP_OPS)) + goto normal_char; + } + + { + /* 1 means zero (many) matches is allowed. */ + char zero_times_ok = 0, many_times_ok = 0; + + /* If there is a sequence of repetition chars, collapse it + down to just one (the right one). We can't combine + interval operators with these because of, e.g., `a{2}*', + which should only match an even number of `a's. */ + + for (;;) + { + zero_times_ok |= c != '+'; + many_times_ok |= c != '?'; + + if (p == pend) + break; + + PATFETCH (c); + + if (c == '*' + || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) + ; + + else if (syntax & RE_BK_PLUS_QM && c == '\\') + { + if (p == pend) return REG_EESCAPE; + + PATFETCH (c1); + if (!(c1 == '+' || c1 == '?')) + { + PATUNFETCH; + PATUNFETCH; + break; + } + + c = c1; + } + else + { + PATUNFETCH; + break; + } + + /* If we get here, we found another repeat character. */ + } + + /* Star, etc. applied to an empty pattern is equivalent + to an empty pattern. */ + if (!last_expression) + break; + + /* Now we know whether or not zero matches is allowed + * and also whether or not two or more matches is allowed. + */ + + { + struct rexp_node * inner_exp = *last_expression; + int need_sync = 0; + + if (many_times_ok + && has_non_idempotent_epsilon_path (&rxb->rx, + inner_exp, params)) + { + struct rexp_node * pusher + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_pushpos); + struct rexp_node * checker + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_chkpos); + struct rexp_node * pushback + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_pushback); + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * lit_t = rx_mk_r_cset (&rxb->rx, cs); + struct rexp_node * fake_state + = rx_mk_r_concat (&rxb->rx, pushback, lit_t); + struct rexp_node * phase2 + = rx_mk_r_concat (&rxb->rx, checker, fake_state); + struct rexp_node * popper + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_poppos); + struct rexp_node * star + = rx_mk_r_2phase_star (&rxb->rx, inner_exp, phase2); + struct rexp_node * a + = rx_mk_r_concat (&rxb->rx, pusher, star); + struct rexp_node * whole_thing + = rx_mk_r_concat (&rxb->rx, a, popper); + if (!(pusher && star && pushback && lit_t && fake_state + && lit_t && phase2 && checker && popper + && a && whole_thing)) + return REG_ESPACE; + RX_bitset_enjoin (cs, 't'); + *last_expression = whole_thing; + } + else + { + struct rexp_node * star = + (many_times_ok ? rx_mk_r_star : rx_mk_r_opt) + (&rxb->rx, *last_expression); + if (!star) + return REG_ESPACE; + *last_expression = star; + need_sync = has_any_se (&rxb->rx, *last_expression); + } + if (!zero_times_ok) + { + struct rexp_node * concat + = rx_mk_r_concat (&rxb->rx, inner_exp, + rx_copy_rexp (&rxb->rx, + *last_expression)); + if (!concat) + return REG_ESPACE; + *last_expression = concat; + } + if (need_sync) + { + int sync_se = paramc; + params = (params + ? ((struct re_se_params *) + realloc (params, + sizeof (*params) * (1 + paramc))) + : ((struct re_se_params *) + malloc (sizeof (*params)))); + if (!params) + return REG_ESPACE; + ++paramc; + params [sync_se].se = re_se_tv; + side = (rx_side_effect)sync_se; + goto add_side_effect; + } + } + /* The old regex.c used to optimize `.*\n'. + * Maybe rx should too? + */ + } + break; + + + case '.': + { + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * n = rx_mk_r_cset (&rxb->rx, cs); + if (!(cs && n)) + return REG_ESPACE; + + rx_bitset_universe (rxb->rx.local_cset_size, cs); + if (!(rxb->syntax & RE_DOT_NEWLINE)) + RX_bitset_remove (cs, '\n'); + if (!(rxb->syntax & RE_DOT_NOT_NULL)) + RX_bitset_remove (cs, 0); + + append = n; + goto append_node; + break; + } + + + case '[': + if (p == pend) return REG_EBRACK; + { + boolean had_char_class = false; + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * node = rx_mk_r_cset (&rxb->rx, cs); + int is_inverted = *p == '^'; + + if (!(node && cs)) + return REG_ESPACE; + + /* This branch of the switch is normally exited with + *`goto append_node' + */ + append = node; + + if (is_inverted) + p++; + + /* Remember the first position in the bracket expression. */ + p1 = p; + + /* Read in characters and ranges, setting map bits. */ + for (;;) + { + if (p == pend) return REG_EBRACK; + + PATFETCH (c); + + /* \ might escape characters inside [...] and [^...]. */ + if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') + { + if (p == pend) return REG_EESCAPE; + + PATFETCH (c1); + { + rx_Bitset it = inverse_translation (rxb, + validate_inv_tr, + inverse_translate, + translate, + c1); + rx_bitset_union (rxb->rx.local_cset_size, cs, it); + } + continue; + } + + /* Could be the end of the bracket expression. If it's + not (i.e., when the bracket expression is `[]' so + far), the ']' character bit gets set way below. */ + if (c == ']' && p != p1 + 1) + goto finalize_class_and_append; + + /* Look ahead to see if it's a range when the last thing + was a character class. */ + if (had_char_class && c == '-' && *p != ']') + return REG_ERANGE; + + /* Look ahead to see if it's a range when the last thing + was a character: if this is a hyphen not at the + beginning or the end of a list, then it's the range + operator. */ + if (c == '-' + && !(p - 2 >= pattern && p[-2] == '[') + && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') + && *p != ']') + { + reg_errcode_t ret + = compile_range (rxb, cs, &p, pend, translate, syntax, + inverse_translate, validate_inv_tr); + if (ret != REG_NOERROR) return ret; + } + + else if (p[0] == '-' && p[1] != ']') + { /* This handles ranges made up of characters only. */ + reg_errcode_t ret; + + /* Move past the `-'. */ + PATFETCH (c1); + + ret = compile_range (rxb, cs, &p, pend, translate, syntax, + inverse_translate, validate_inv_tr); + if (ret != REG_NOERROR) return ret; + } + + /* See if we're at the beginning of a possible character + class. */ + + else if ((syntax & RE_CHAR_CLASSES) + && (c == '[') && (*p == ':')) + { + char str[CHAR_CLASS_MAX_LENGTH + 1]; + + PATFETCH (c); + c1 = 0; + + /* If pattern is `[[:'. */ + if (p == pend) return REG_EBRACK; + + for (;;) + { + PATFETCH (c); + if (c == ':' || c == ']' || p == pend + || c1 == CHAR_CLASS_MAX_LENGTH) + break; + str[c1++] = c; + } + str[c1] = '\0'; + + /* If isn't a word bracketed by `[:' and:`]': + undo the ending character, the letters, and leave + the leading `:' and `[' (but set bits for them). */ + if (c == ':' && *p == ']') + { + int ch; + boolean is_alnum = !strcmp (str, "alnum"); + boolean is_alpha = !strcmp (str, "alpha"); + boolean is_blank = !strcmp (str, "blank"); + boolean is_cntrl = !strcmp (str, "cntrl"); + boolean is_digit = !strcmp (str, "digit"); + boolean is_graph = !strcmp (str, "graph"); + boolean is_lower = !strcmp (str, "lower"); + boolean is_print = !strcmp (str, "print"); + boolean is_punct = !strcmp (str, "punct"); + boolean is_space = !strcmp (str, "space"); + boolean is_upper = !strcmp (str, "upper"); + boolean is_xdigit = !strcmp (str, "xdigit"); + + if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; + + /* Throw away the ] at the end of the character + class. */ + PATFETCH (c); + + if (p == pend) return REG_EBRACK; + + for (ch = 0; ch < 1 << CHARBITS; ch++) + { + if ( (is_alnum && isalnum (ch)) + || (is_alpha && isalpha (ch)) + || (is_blank && isblank (ch)) + || (is_cntrl && iscntrl (ch)) + || (is_digit && isdigit (ch)) + || (is_graph && isgraph (ch)) + || (is_lower && islower (ch)) + || (is_print && isprint (ch)) + || (is_punct && ispunct (ch)) + || (is_space && isspace (ch)) + || (is_upper && isupper (ch)) + || (is_xdigit && isxdigit (ch))) + { + rx_Bitset it = + inverse_translation (rxb, + validate_inv_tr, + inverse_translate, + translate, + ch); + rx_bitset_union (rxb->rx.local_cset_size, + cs, it); + } + } + had_char_class = true; + } + else + { + c1++; + while (c1--) + PATUNFETCH; + { + rx_Bitset it = + inverse_translation (rxb, + validate_inv_tr, + inverse_translate, + translate, + '['); + rx_bitset_union (rxb->rx.local_cset_size, + cs, it); + } + { + rx_Bitset it = + inverse_translation (rxb, + validate_inv_tr, + inverse_translate, + translate, + ':'); + rx_bitset_union (rxb->rx.local_cset_size, + cs, it); + } + had_char_class = false; + } + } + else + { + had_char_class = false; + { + rx_Bitset it = inverse_translation (rxb, + validate_inv_tr, + inverse_translate, + translate, + c); + rx_bitset_union (rxb->rx.local_cset_size, cs, it); + } + } + } + + finalize_class_and_append: + if (is_inverted) + { + rx_bitset_complement (rxb->rx.local_cset_size, cs); + if (syntax & RE_HAT_LISTS_NOT_NEWLINE) + RX_bitset_remove (cs, '\n'); + } + goto append_node; + } + break; + + + case '(': + if (syntax & RE_NO_BK_PARENS) + goto handle_open; + else + goto normal_char; + + + case ')': + if (syntax & RE_NO_BK_PARENS) + goto handle_close; + else + goto normal_char; + + + case '\n': + if (syntax & RE_NEWLINE_ALT) + goto handle_alt; + else + goto normal_char; + + + case '|': + if (syntax & RE_NO_BK_VBAR) + goto handle_alt; + else + goto normal_char; + + + case '{': + if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + goto handle_interval; + else + goto normal_char; + + + case '\\': + if (p == pend) return REG_EESCAPE; + + /* Do not translate the character after the \, so that we can + distinguish, e.g., \B from \b, even if we normally would + translate, e.g., B to b. */ + PATFETCH_RAW (c); + + switch (c) + { + case '(': + if (syntax & RE_NO_BK_PARENS) + goto normal_backslash; + + handle_open: + rxb->re_nsub++; + regnum++; + if (COMPILE_STACK_FULL) + { + ((compile_stack.stack) = + (compile_stack_elt_t *) realloc (compile_stack.stack, ( compile_stack.size << 1) * sizeof ( + compile_stack_elt_t))); + if (compile_stack.stack == 0) return REG_ESPACE; + + compile_stack.size <<= 1; + } + + if (*last_expression) + { + struct rexp_node * concat + = rx_mk_r_concat (&rxb->rx, *last_expression, 0); + if (!concat) + return REG_ESPACE; + *last_expression = concat; + last_expression = &concat->params.pair.right; + } + + /* + * These are the values to restore when we hit end of this + * group. + */ + COMPILE_STACK_TOP.top_expression = top_expression; + COMPILE_STACK_TOP.last_expression = last_expression; + COMPILE_STACK_TOP.regnum = regnum; + + compile_stack.avail++; + + top_expression = last_expression; + break; + + + case ')': + if (syntax & RE_NO_BK_PARENS) goto normal_backslash; + + handle_close: + /* See similar code for backslashed left paren above. */ + if (COMPILE_STACK_EMPTY) + if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) + goto normal_char; + else + return REG_ERPAREN; + + /* Since we just checked for an empty stack above, this + ``can't happen''. */ + + { + /* We don't just want to restore into `regnum', because + later groups should continue to be numbered higher, + as in `(ab)c(de)' -- the second group is #2. */ + regnum_t this_group_regnum; + struct rexp_node ** inner = top_expression; + + compile_stack.avail--; + top_expression = COMPILE_STACK_TOP.top_expression; + last_expression = COMPILE_STACK_TOP.last_expression; + this_group_regnum = COMPILE_STACK_TOP.regnum; + { + int left_se = paramc; + int right_se = paramc + 1; + + params = (params + ? ((struct re_se_params *) + realloc (params, + (paramc + 2) * sizeof (params[0]))) + : ((struct re_se_params *) + malloc (2 * sizeof (params[0])))); + if (!params) + return REG_ESPACE; + paramc += 2; + + params[left_se].se = re_se_lparen; + params[left_se].op1 = this_group_regnum; + params[right_se].se = re_se_rparen; + params[right_se].op1 = this_group_regnum; + { + struct rexp_node * left + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)left_se); + struct rexp_node * right + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)right_se); + struct rexp_node * c1 + = (*inner + ? rx_mk_r_concat (&rxb->rx, left, *inner) : left); + struct rexp_node * c2 + = rx_mk_r_concat (&rxb->rx, c1, right); + if (!(left && right && c1 && c2)) + return REG_ESPACE; + *inner = c2; + } + } + break; + } + + case '|': /* `\|'. */ + if ((syntax & RE_LIMITED_OPS) || (syntax & RE_NO_BK_VBAR)) + goto normal_backslash; + handle_alt: + if (syntax & RE_LIMITED_OPS) + goto normal_char; + + { + struct rexp_node * alt + = rx_mk_r_alternate (&rxb->rx, *top_expression, 0); + if (!alt) + return REG_ESPACE; + *top_expression = alt; + last_expression = &alt->params.pair.right; + { + int sync_se = paramc; + + params = (params + ? ((struct re_se_params *) + realloc (params, + (paramc + 1) * sizeof (params[0]))) + : ((struct re_se_params *) + malloc (sizeof (params[0])))); + if (!params) + return REG_ESPACE; + ++paramc; + + params[sync_se].se = re_se_tv; + { + struct rexp_node * sync + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)sync_se); + struct rexp_node * conc + = rx_mk_r_concat (&rxb->rx, sync, 0); + + if (!sync || !conc) + return REG_ESPACE; + + *last_expression = conc; + last_expression = &conc->params.pair.right; + } + } + } + break; + + + case '{': + /* If \{ is a literal. */ + if (!(syntax & RE_INTERVALS) + /* If we're at `\{' and it's not the open-interval + operator. */ + || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + || (p - 2 == pattern && p == pend)) + goto normal_backslash; + + handle_interval: + { + /* If got here, then the syntax allows intervals. */ + + /* At least (most) this many matches must be made. */ + int lower_bound = -1, upper_bound = -1; + + beg_interval = p - 1; + + if (p == pend) + { + if (syntax & RE_NO_BK_BRACES) + goto unfetch_interval; + else + return REG_EBRACE; + } + + GET_UNSIGNED_NUMBER (lower_bound); + + if (c == ',') + { + GET_UNSIGNED_NUMBER (upper_bound); + if (upper_bound < 0) upper_bound = RE_DUP_MAX; + } + else + /* Interval such as `{1}' => match exactly once. */ + upper_bound = lower_bound; + + if (lower_bound < 0 || upper_bound > RE_DUP_MAX + || lower_bound > upper_bound) + { + if (syntax & RE_NO_BK_BRACES) + goto unfetch_interval; + else + return REG_BADBR; + } + + if (!(syntax & RE_NO_BK_BRACES)) + { + if (c != '\\') return REG_EBRACE; + PATFETCH (c); + } + + if (c != '}') + { + if (syntax & RE_NO_BK_BRACES) + goto unfetch_interval; + else + return REG_BADBR; + } + + /* We just parsed a valid interval. */ + + /* If it's invalid to have no preceding re. */ + if (pointless_if_repeated (*last_expression, params)) + { + if (syntax & RE_CONTEXT_INVALID_OPS) + return REG_BADRPT; + else if (!(syntax & RE_CONTEXT_INDEP_OPS)) + goto unfetch_interval; + /* was: else laststart = b; */ + } + + /* If the upper bound is zero, don't want to iterate + * at all. + */ + if (upper_bound == 0) + { + if (*last_expression) + { + rx_free_rexp (&rxb->rx, *last_expression); + *last_expression = 0; + } + } + else + /* Otherwise, we have a nontrivial interval. */ + { + int iter_se = paramc; + int end_se = paramc + 1; + params = (params + ? ((struct re_se_params *) + realloc (params, + sizeof (*params) * (2 + paramc))) + : ((struct re_se_params *) + malloc (2 * sizeof (*params)))); + if (!params) + return REG_ESPACE; + paramc += 2; + params [iter_se].se = re_se_iter; + params [iter_se].op1 = lower_bound; + params[iter_se].op2 = upper_bound; + + params[end_se].se = re_se_end_iter; + params[end_se].op1 = lower_bound; + params[end_se].op2 = upper_bound; + { + struct rexp_node * push0 + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_push0); + struct rexp_node * start_one_iter + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)iter_se); + struct rexp_node * phase1 + = rx_mk_r_concat (&rxb->rx, start_one_iter, + *last_expression); + struct rexp_node * pushback + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)re_se_pushback); + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * lit_t + = rx_mk_r_cset (&rxb->rx, cs); + struct rexp_node * phase2 + = rx_mk_r_concat (&rxb->rx, pushback, lit_t); + struct rexp_node * loop + = rx_mk_r_2phase_star (&rxb->rx, phase1, phase2); + struct rexp_node * push_n_loop + = rx_mk_r_concat (&rxb->rx, push0, loop); + struct rexp_node * final_test + = rx_mk_r_side_effect (&rxb->rx, + (rx_side_effect)end_se); + struct rexp_node * full_exp + = rx_mk_r_concat (&rxb->rx, push_n_loop, final_test); + + if (!(push0 && start_one_iter && phase1 + && pushback && lit_t && phase2 + && loop && push_n_loop && final_test && full_exp)) + return REG_ESPACE; + + RX_bitset_enjoin(cs, 't'); + + *last_expression = full_exp; + } + } + beg_interval = 0; + } + break; + + unfetch_interval: + /* If an invalid interval, match the characters as literals. */ + p = beg_interval; + beg_interval = 0; + + /* normal_char and normal_backslash need `c'. */ + PATFETCH (c); + + if (!(syntax & RE_NO_BK_BRACES)) + { + if (p > pattern && p[-1] == '\\') + goto normal_backslash; + } + goto normal_char; + +#ifdef emacs + /* There is no way to specify the before_dot and after_dot + operators. rms says this is ok. --karl */ + case '=': + side = (rx_side_effect)rx_se_at_dot; + goto add_side_effect; + break; + + case 's': + case 'S': + { + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * set = rx_mk_r_cset (&rxb->rx, cs); + if (!(cs && set)) + return REG_ESPACE; + if (c == 'S') + rx_bitset_universe (rxb->rx.local_cset_size, cs); + + PATFETCH (c); + { + int x; + enum syntaxcode code = syntax_spec_code [c]; + for (x = 0; x < 256; ++x) + { + + if (SYNTAX (x) == code) + { + rx_Bitset it = + inverse_translation (rxb, validate_inv_tr, + inverse_translate, + translate, x); + rx_bitset_xor (rxb->rx.local_cset_size, cs, it); + } + } + } + append = set; + goto append_node; + } + break; +#endif /* emacs */ + + + case 'w': + case 'W': + { + rx_Bitset cs = rx_cset (&rxb->rx); + struct rexp_node * n = (cs ? rx_mk_r_cset (&rxb->rx, cs) : 0); + if (!(cs && n)) + return REG_ESPACE; + if (c == 'W') + rx_bitset_universe (rxb->rx.local_cset_size ,cs); + { + int x; + for (x = rxb->rx.local_cset_size - 1; x > 0; --x) + if (SYNTAX(x) & Sword) + RX_bitset_toggle (cs, x); + } + append = n; + goto append_node; + } + break; + +/* With a little extra work, some of these side effects could be optimized + * away (basicly by looking at what we already know about the surrounding + * chars). + */ + case '<': + side = (rx_side_effect)re_se_wordbeg; + goto add_side_effect; + break; + + case '>': + side = (rx_side_effect)re_se_wordend; + goto add_side_effect; + break; + + case 'b': + side = (rx_side_effect)re_se_wordbound; + goto add_side_effect; + break; + + case 'B': + side = (rx_side_effect)re_se_notwordbound; + goto add_side_effect; + break; + + case '`': + side = (rx_side_effect)re_se_begbuf; + goto add_side_effect; + break; + + case '\'': + side = (rx_side_effect)re_se_endbuf; + goto add_side_effect; + break; + + add_side_effect: + { + struct rexp_node * se + = rx_mk_r_side_effect (&rxb->rx, side); + if (!se) + return REG_ESPACE; + append = se; + goto append_node; + } + break; + + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + if (syntax & RE_NO_BK_REFS) + goto normal_char; + + c1 = c - '0'; + + if (c1 > regnum) + return REG_ESUBREG; + + /* Can't back reference to a subexpression if inside of it. */ + if (group_in_compile_stack (compile_stack, c1)) + return REG_ESUBREG; + + { + int backref_se = paramc; + params = (params + ? ((struct re_se_params *) + realloc (params, + sizeof (*params) * (1 + paramc))) + : ((struct re_se_params *) + malloc (sizeof (*params)))); + if (!params) + return REG_ESPACE; + ++paramc; + params[backref_se].se = re_se_backref; + params[backref_se].op1 = c1; + side = (rx_side_effect)backref_se; + goto add_side_effect; + } + break; + + case '+': + case '?': + if (syntax & RE_BK_PLUS_QM) + goto handle_plus; + else + goto normal_backslash; + + default: + normal_backslash: + /* You might think it would be useful for \ to mean + not to translate; but if we don't translate it + it will never match anything. */ + c = TRANSLATE (c); + goto normal_char; + } + break; + + + default: + /* Expects the character in `c'. */ + normal_char: + { + rx_Bitset cs = rx_cset(&rxb->rx); + struct rexp_node * match = rx_mk_r_cset (&rxb->rx, cs); + rx_Bitset it; + if (!(cs && match)) + return REG_ESPACE; + it = inverse_translation (rxb, validate_inv_tr, + inverse_translate, translate, c); + rx_bitset_union (CHAR_SET_SIZE, cs, it); + append = match; + + append_node: + /* This genericly appends the rexp APPEND to *LAST_EXPRESSION + * and then parses the next character normally. + */ + if (*last_expression) + { + struct rexp_node * concat + = rx_mk_r_concat (&rxb->rx, *last_expression, append); + if (!concat) + return REG_ESPACE; + *last_expression = concat; + last_expression = &concat->params.pair.right; + } + else + *last_expression = append; + } + } /* switch (c) */ + } /* while p != pend */ + + + { + int win_se = paramc; + params = (params + ? ((struct re_se_params *) + realloc (params, + sizeof (*params) * (1 + paramc))) + : ((struct re_se_params *) + malloc (sizeof (*params)))); + if (!params) + return REG_ESPACE; + ++paramc; + params[win_se].se = re_se_win; + { + struct rexp_node * se + = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)win_se); + struct rexp_node * concat + = rx_mk_r_concat (&rxb->rx, rexp, se); + if (!(se && concat)) + return REG_ESPACE; + rexp = concat; + } + } + + + /* Through the pattern now. */ + + if (!COMPILE_STACK_EMPTY) + return REG_EPAREN; + + free (compile_stack.stack); + + orig_rexp = rexp; +#ifdef RX_DEBUG + if (rx_debug_compile) + { + dbug_rxb = rxb; + fputs ("\n\nCompiling ", stdout); + fwrite (pattern, 1, size, stdout); + fputs (":\n", stdout); + rxb->se_params = params; + print_rexp (&rxb->rx, orig_rexp, 2, re_seprint, stdout); + } +#endif + { + rx_Bitset cs = rx_cset(&rxb->rx); + rx_Bitset cs2 = rx_cset(&rxb->rx); + char * se_map = (char *) alloca (paramc); + struct rexp_node * new_rexp = 0; + + + bzero (se_map, paramc); + find_backrefs (se_map, rexp, params); + fewer_side_effects = + remove_unecessary_side_effects (&rxb->rx, se_map, + rx_copy_rexp (&rxb->rx, rexp), params); + + speed_up_alt (&rxb->rx, rexp, 0); + speed_up_alt (&rxb->rx, fewer_side_effects, 1); + + { + char * syntax_parens = rxb->syntax_parens; + if (syntax_parens == (char *)0x1) + rexp = remove_unecessary_side_effects + (&rxb->rx, se_map, rexp, params); + else if (syntax_parens) + { + int x; + for (x = 0; x < paramc; ++x) + if (( (params[x].se == re_se_lparen) + || (params[x].se == re_se_rparen)) + && (!syntax_parens [params[x].op1])) + se_map [x] = 1; + rexp = remove_unecessary_side_effects + (&rxb->rx, se_map, rexp, params); + } + } + + /* At least one more optimization would be nice to have here but i ran out + * of time. The idea would be to delay side effects. + * For examle, `(abc)' is the same thing as `abc()' except that the + * left paren is offset by 3 (which we know at compile time). + * (In this comment, write that second pattern `abc(:3:)' + * where `(:3:' is a syntactic unit.) + * + * Trickier: `(abc|defg)' is the same as `(abc(:3:|defg(:4:))' + * (The paren nesting may be hard to follow -- that's an alternation + * of `abc(:3:' and `defg(:4:' inside (purely syntactic) parens + * followed by the closing paren from the original expression.) + * + * Neither the expression tree representation nor the the nfa make + * this very easy to write. :( + */ + + /* What we compile is different than what the parser returns. + * Suppose the parser returns expression R. + * Let R' be R with unnecessary register assignments removed + * (see REMOVE_UNECESSARY_SIDE_EFFECTS, above). + * + * What we will compile is the expression: + * + * m{try}R{win}\|s{try}R'{win} + * + * {try} and {win} denote side effect epsilons (see EXPLORE_FUTURE). + * + * When trying a match, we insert an `m' at the beginning of the + * string if the user wants registers to be filled, `s' if not. + */ + new_rexp = + rx_mk_r_alternate + (&rxb->rx, + rx_mk_r_concat (&rxb->rx, rx_mk_r_cset (&rxb->rx, cs2), rexp), + rx_mk_r_concat (&rxb->rx, + rx_mk_r_cset (&rxb->rx, cs), fewer_side_effects)); + + if (!(new_rexp && cs && cs2)) + return REG_ESPACE; + RX_bitset_enjoin (cs2, '\0'); /* prefixed to the rexp used for matching. */ + RX_bitset_enjoin (cs, '\1'); /* prefixed to the rexp used for searching. */ + rexp = new_rexp; + } + +#ifdef RX_DEBUG + if (rx_debug_compile) + { + fputs ("\n...which is compiled as:\n", stdout); + print_rexp (&rxb->rx, rexp, 2, re_seprint, stdout); + } +#endif + { + struct rx_nfa_state *start = 0; + struct rx_nfa_state *end = 0; + + if (!rx_build_nfa (&rxb->rx, rexp, &start, &end)) + return REG_ESPACE; /* */ + else + { + void * mem = (void *)rxb->buffer; + unsigned long size = rxb->allocated; + int start_id; + char * perm_mem; + int iterator_size = paramc * sizeof (params[0]); + + end->is_final = 1; + start->is_start = 1; + rx_name_nfa_states (&rxb->rx); + start_id = start->id; +#ifdef RX_DEBUG + if (rx_debug_compile) + { + fputs ("...giving the NFA: \n", stdout); + dbug_rxb = rxb; + print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); + } +#endif + if (!rx_eclose_nfa (&rxb->rx)) + return REG_ESPACE; + else + { + rx_delete_epsilon_transitions (&rxb->rx); + + /* For compatability reasons, we need to shove the + * compiled nfa into one chunk of malloced memory. + */ + rxb->rx.reserved = ( sizeof (params[0]) * paramc + + rx_sizeof_bitset (rxb->rx.local_cset_size)); +#ifdef RX_DEBUG + if (rx_debug_compile) + { + dbug_rxb = rxb; + fputs ("...which cooks down (uncompactified) to: \n", stdout); + print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); + } +#endif + if (!rx_compactify_nfa (&rxb->rx, &mem, &size)) + return REG_ESPACE; + rxb->buffer = mem; + rxb->allocated = size; + rxb->rx.buffer = mem; + rxb->rx.allocated = size; + perm_mem = ((char *)rxb->rx.buffer + + rxb->rx.allocated - rxb->rx.reserved); + rxb->se_params = ((struct re_se_params *)perm_mem); + bcopy (params, rxb->se_params, iterator_size); + perm_mem += iterator_size; + rxb->fastset = (rx_Bitset) perm_mem; + rxb->start = rx_id_to_nfa_state (&rxb->rx, start_id); + } + rx_bitset_null (rxb->rx.local_cset_size, rxb->fastset); + rxb->can_match_empty = compute_fastset (rxb, orig_rexp); + rxb->match_regs_on_stack = + registers_on_stack (rxb, orig_rexp, 0, params); + rxb->search_regs_on_stack = + registers_on_stack (rxb, fewer_side_effects, 0, params); + if (rxb->can_match_empty) + rx_bitset_universe (rxb->rx.local_cset_size, rxb->fastset); + rxb->is_anchored = is_anchored (orig_rexp, (rx_side_effect) re_se_hat); + rxb->begbuf_only = is_anchored (orig_rexp, + (rx_side_effect) re_se_begbuf); + } + rx_free_rexp (&rxb->rx, rexp); + if (params) + free (params); +#ifdef RX_DEBUG + if (rx_debug_compile) + { + dbug_rxb = rxb; + fputs ("...which cooks down to: \n", stdout); + print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); + } +#endif + } + return REG_NOERROR; +} + + + +/* This table gives an error message for each of the error codes listed + in regex.h. Obviously the order here has to be same as there. */ + +__const__ char * rx_error_msg[] = +{ 0, /* REG_NOERROR */ + "No match", /* REG_NOMATCH */ + "Invalid regular expression", /* REG_BADPAT */ + "Invalid collation character", /* REG_ECOLLATE */ + "Invalid character class name", /* REG_ECTYPE */ + "Trailing backslash", /* REG_EESCAPE */ + "Invalid back reference", /* REG_ESUBREG */ + "Unmatched [ or [^", /* REG_EBRACK */ + "Unmatched ( or \\(", /* REG_EPAREN */ + "Unmatched \\{", /* REG_EBRACE */ + "Invalid content of \\{\\}", /* REG_BADBR */ + "Invalid range end", /* REG_ERANGE */ + "Memory exhausted", /* REG_ESPACE */ + "Invalid preceding regular expression", /* REG_BADRPT */ + "Premature end of regular expression", /* REG_EEND */ + "Regular expression too big", /* REG_ESIZE */ + "Unmatched ) or \\)", /* REG_ERPAREN */ +}; + + + + +char rx_slowmap [256] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +#ifdef __STDC__ +RX_DECL void +rx_blow_up_fastmap (struct re_pattern_buffer * rxb) +#else +RX_DECL void +rx_blow_up_fastmap (rxb) + struct re_pattern_buffer * rxb; +#endif +{ + int x; + for (x = 0; x < 256; ++x) /* &&&& 3.6 % */ + rxb->fastmap [x] = !!RX_bitset_member (rxb->fastset, x); + rxb->fastmap_accurate = 1; +} + + + + +#if !defined(REGEX_MALLOC) && !defined(__GNUC__) +#define RE_SEARCH_2_FN inner_re_search_2 +#define RE_S2_QUAL static +#else +#define RE_SEARCH_2_FN re_search_2 +#define RE_S2_QUAL +#endif + +struct re_search_2_closure +{ + __const__ char * string1; + int size1; + __const__ char * string2; + int size2; +}; + + +static __inline__ enum rx_get_burst_return +re_search_2_get_burst (pos, vclosure, stop) + struct rx_string_position * pos; + void * vclosure; + int stop; +{ + struct re_search_2_closure * closure; + closure = (struct re_search_2_closure *)vclosure; + if (!closure->string2) + { + int inset; + + inset = pos->pos - pos->string; + if ((inset < -1) || (inset > closure->size1)) + return rx_get_burst_no_more; + else + { + pos->pos = (__const__ unsigned char *) closure->string1 + inset; + pos->string = (__const__ unsigned char *) closure->string1; + pos->size = closure->size1; + pos->end = ((__const__ unsigned char *) + MIN(closure->string1 + closure->size1, + closure->string1 + stop)); + pos->offset = 0; + return ((pos->pos < pos->end) + ? rx_get_burst_ok + : rx_get_burst_no_more); + } + } + else if (!closure->string1) + { + int inset; + + inset = pos->pos - pos->string; + pos->pos = (__const__ unsigned char *) closure->string2 + inset; + pos->string = (__const__ unsigned char *) closure->string2; + pos->size = closure->size2; + pos->end = ((__const__ unsigned char *) + MIN(closure->string2 + closure->size2, + closure->string2 + stop)); + pos->offset = 0; + return ((pos->pos < pos->end) + ? rx_get_burst_ok + : rx_get_burst_no_more); + } + else + { + int inset; + + inset = pos->pos - pos->string + pos->offset; + if (inset < closure->size1) + { + pos->pos = (__const__ unsigned char *) closure->string1 + inset; + pos->string = (__const__ unsigned char *) closure->string1; + pos->size = closure->size1; + pos->end = ((__const__ unsigned char *) + MIN(closure->string1 + closure->size1, + closure->string1 + stop)); + pos->offset = 0; + return rx_get_burst_ok; + } + else + { + pos->pos = ((__const__ unsigned char *) + closure->string2 + inset - closure->size1); + pos->string = (__const__ unsigned char *) closure->string2; + pos->size = closure->size2; + pos->end = ((__const__ unsigned char *) + MIN(closure->string2 + closure->size2, + closure->string2 + stop - closure->size1)); + pos->offset = closure->size1; + return ((pos->pos < pos->end) + ? rx_get_burst_ok + : rx_get_burst_no_more); + } + } +} + + +static __inline__ enum rx_back_check_return +re_search_2_back_check (pos, lparen, rparen, translate, vclosure, stop) + struct rx_string_position * pos; + int lparen; + int rparen; + unsigned char * translate; + void * vclosure; + int stop; +{ + struct rx_string_position there; + struct rx_string_position past; + + there = *pos; + there.pos = there.string + lparen - there.offset; + re_search_2_get_burst (&there, vclosure, stop); + + past = *pos; + past.pos = past.string + rparen - there.offset; + re_search_2_get_burst (&past, vclosure, stop); + + ++pos->pos; + re_search_2_get_burst (pos, vclosure, stop); + + while ( (there.pos != past.pos) + && (pos->pos != pos->end)) + if (TRANSLATE(*there.pos) != TRANSLATE(*pos->pos)) + return rx_back_check_fail; + else + { + ++there.pos; + ++pos->pos; + if (there.pos == there.end) + re_search_2_get_burst (&there, vclosure, stop); + if (pos->pos == pos->end) + re_search_2_get_burst (pos, vclosure, stop); + } + + if (there.pos != past.pos) + return rx_back_check_fail; + --pos->pos; + re_search_2_get_burst (pos, vclosure, stop); + return rx_back_check_pass; +} + +static __inline__ int +re_search_2_fetch_char (pos, offset, app_closure, stop) + struct rx_string_position * pos; + int offset; + void * app_closure; + int stop; +{ + struct re_search_2_closure * closure; + closure = (struct re_search_2_closure *)app_closure; + if (offset == 0) + { + if (pos->pos >= pos->string) + return *pos->pos; + else + { + if ( (pos->string == (__const__ unsigned char *) closure->string2) + && (closure->string1) + && (closure->size1)) + return closure->string1[closure->size1 - 1]; + else + return 0; /* sure, why not. */ + } + } + if (pos->pos == pos->end) + return *closure->string2; + else + return pos->pos[1]; +} + + +#ifdef __STDC__ +RE_S2_QUAL int +RE_SEARCH_2_FN (struct re_pattern_buffer *rxb, + __const__ char * string1, int size1, + __const__ char * string2, int size2, + int startpos, int range, + struct re_registers *regs, + int stop) +#else +RE_S2_QUAL int +RE_SEARCH_2_FN (rxb, + string1, size1, string2, size2, startpos, range, regs, stop) + struct re_pattern_buffer *rxb; + __const__ char * string1; + int size1; + __const__ char * string2; + int size2; + int startpos; + int range; + struct re_registers *regs; + int stop; +#endif +{ + int answer; + struct re_search_2_closure closure; + closure.string1 = string1; + closure.size1 = size1; + closure.string2 = string2; + closure.size2 = size2; + answer = rx_search (rxb, startpos, range, stop, size1 + size2, + re_search_2_get_burst, + re_search_2_back_check, + re_search_2_fetch_char, + (void *)&closure, + regs, + 0, + 0); + switch (answer) + { + case rx_search_continuation: + abort (); + case rx_search_error: + return -2; + case rx_search_soft_fail: + case rx_search_fail: + return -1; + default: + return answer; + } +} + +/* Export rx_search to callers outside this file. */ + +int +re_rx_search (rxb, startpos, range, stop, total_size, + get_burst, back_check, fetch_char, + app_closure, regs, resume_state, save_state) + struct re_pattern_buffer * rxb; + int startpos; + int range; + int stop; + int total_size; + rx_get_burst_fn get_burst; + rx_back_check_fn back_check; + rx_fetch_char_fn fetch_char; + void * app_closure; + struct re_registers * regs; + struct rx_search_state * resume_state; + struct rx_search_state * save_state; +{ + return rx_search (rxb, startpos, range, stop, total_size, + get_burst, back_check, fetch_char, app_closure, + regs, resume_state, save_state); +} + +#if !defined(REGEX_MALLOC) && !defined(__GNUC__) +#ifdef __STDC__ +int +re_search_2 (struct re_pattern_buffer *rxb, + __const__ char * string1, int size1, + __const__ char * string2, int size2, + int startpos, int range, + struct re_registers *regs, + int stop) +#else +int +re_search_2 (rxb, string1, size1, string2, size2, startpos, range, regs, stop) + struct re_pattern_buffer *rxb; + __const__ char * string1; + int size1; + __const__ char * string2; + int size2; + int startpos; + int range; + struct re_registers *regs; + int stop; +#endif +{ + int ret; + ret = inner_re_search_2 (rxb, string1, size1, string2, size2, startpos, + range, regs, stop); + alloca (0); + return ret; +} +#endif + + +/* Like re_search_2, above, but only one string is specified, and + * doesn't let you say where to stop matching. + */ + +#ifdef __STDC__ +int +re_search (struct re_pattern_buffer * rxb, __const__ char *string, + int size, int startpos, int range, + struct re_registers *regs) +#else +int +re_search (rxb, string, size, startpos, range, regs) + struct re_pattern_buffer * rxb; + __const__ char * string; + int size; + int startpos; + int range; + struct re_registers *regs; +#endif +{ + return re_search_2 (rxb, 0, 0, string, size, startpos, range, regs, size); +} + +#ifdef __STDC__ +int +re_match_2 (struct re_pattern_buffer * rxb, + __const__ char * string1, int size1, + __const__ char * string2, int size2, + int pos, struct re_registers *regs, int stop) +#else +int +re_match_2 (rxb, string1, size1, string2, size2, pos, regs, stop) + struct re_pattern_buffer * rxb; + __const__ char * string1; + int size1; + __const__ char * string2; + int size2; + int pos; + struct re_registers *regs; + int stop; +#endif +{ + struct re_registers some_regs; + regoff_t start; + regoff_t end; + int srch; + int save = rxb->regs_allocated; + struct re_registers * regs_to_pass = regs; + + if (!regs) + { + some_regs.start = &start; + some_regs.end = &end; + some_regs.num_regs = 1; + regs_to_pass = &some_regs; + rxb->regs_allocated = REGS_FIXED; + } + + srch = re_search_2 (rxb, string1, size1, string2, size2, + pos, 1, regs_to_pass, stop); + if (regs_to_pass != regs) + rxb->regs_allocated = save; + if (srch < 0) + return srch; + return regs_to_pass->end[0] - regs_to_pass->start[0]; +} + +/* re_match is like re_match_2 except it takes only a single string. */ + +#ifdef __STDC__ +int +re_match (struct re_pattern_buffer * rxb, + __const__ char * string, + int size, int pos, + struct re_registers *regs) +#else +int +re_match (rxb, string, size, pos, regs) + struct re_pattern_buffer * rxb; + __const__ char *string; + int size; + int pos; + struct re_registers *regs; +#endif +{ + return re_match_2 (rxb, string, size, 0, 0, pos, regs, size); +} + + + +/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can + also be assigned to arbitrarily: each pattern buffer stores its own + syntax, so it can be changed between regex compilations. */ +reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; + + +/* Specify the precise syntax of regexps for compilation. This provides + for compatibility for various utilities which historically have + different, incompatible syntaxes. + + The argument SYNTAX is a bit mask comprised of the various bits + defined in regex.h. We return the old syntax. */ + +#ifdef __STDC__ +reg_syntax_t +re_set_syntax (reg_syntax_t syntax) +#else +reg_syntax_t +re_set_syntax (syntax) + reg_syntax_t syntax; +#endif +{ + reg_syntax_t ret = re_syntax_options; + + re_syntax_options = syntax; + return ret; +} + + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use + this memory for recording register information. STARTS and ENDS + must be allocated using the malloc library routine, and must each + be at least NUM_REGS * sizeof (regoff_t) bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ + +#ifdef __STDC__ +void +re_set_registers (struct re_pattern_buffer *bufp, + struct re_registers *regs, + unsigned num_regs, + regoff_t * starts, regoff_t * ends) +#else +void +re_set_registers (bufp, regs, num_regs, starts, ends) + struct re_pattern_buffer *bufp; + struct re_registers *regs; + unsigned num_regs; + regoff_t * starts; + regoff_t * ends; +#endif +{ + if (num_regs) + { + bufp->regs_allocated = REGS_REALLOCATE; + regs->num_regs = num_regs; + regs->start = starts; + regs->end = ends; + } + else + { + bufp->regs_allocated = REGS_UNALLOCATED; + regs->num_regs = 0; + regs->start = regs->end = (regoff_t) 0; + } +} + + + + +#ifdef __STDC__ +static int +cplx_se_sublist_len (struct rx_se_list * list) +#else +static int +cplx_se_sublist_len (list) + struct rx_se_list * list; +#endif +{ + int x = 0; + while (list) + { + if ((long)list->car >= 0) + ++x; + list = list->cdr; + } + return x; +} + + +/* For rx->se_list_cmp */ + +#ifdef __STDC__ +static int +posix_se_list_order (struct rx * rx, + struct rx_se_list * a, struct rx_se_list * b) +#else +static int +posix_se_list_order (rx, a, b) + struct rx * rx; + struct rx_se_list * a; + struct rx_se_list * b; +#endif +{ + int al = cplx_se_sublist_len (a); + int bl = cplx_se_sublist_len (b); + + if (!al && !bl) + return ((a == b) + ? 0 + : ((a < b) ? -1 : 1)); + + else if (!al) + return -1; + + else if (!bl) + return 1; + + else + { + rx_side_effect * av = ((rx_side_effect *) + alloca (sizeof (rx_side_effect) * (al + 1))); + rx_side_effect * bv = ((rx_side_effect *) + alloca (sizeof (rx_side_effect) * (bl + 1))); + struct rx_se_list * ap = a; + struct rx_se_list * bp = b; + int ai, bi; + + for (ai = al - 1; ai >= 0; --ai) + { + while ((long)ap->car < 0) + ap = ap->cdr; + av[ai] = ap->car; + ap = ap->cdr; + } + av[al] = (rx_side_effect)-2; + for (bi = bl - 1; bi >= 0; --bi) + { + while ((long)bp->car < 0) + bp = bp->cdr; + bv[bi] = bp->car; + bp = bp->cdr; + } + bv[bl] = (rx_side_effect)-1; + + { + int ret; + int x = 0; + while (av[x] == bv[x]) + ++x; + ret = (((unsigned *)(av[x]) < (unsigned *)(bv[x])) ? -1 : 1); + return ret; + } + } +} + + + + +/* re_compile_pattern is the GNU regular expression compiler: it + compiles PATTERN (of length SIZE) and puts the result in RXB. + Returns 0 if the pattern was valid, otherwise an error string. + + Assumes the `allocated' (and perhaps `buffer') and `translate' fields + are set in RXB on entry. + + We call rx_compile to do the actual compilation. */ + +#ifdef __STDC__ +__const__ char * +re_compile_pattern (__const__ char *pattern, + int length, + struct re_pattern_buffer * rxb) +#else +__const__ char * +re_compile_pattern (pattern, length, rxb) + __const__ char *pattern; + int length; + struct re_pattern_buffer * rxb; +#endif +{ + reg_errcode_t ret; + + /* GNU code is written to assume at least RE_NREGS registers will be set + (and at least one extra will be -1). */ + rxb->regs_allocated = REGS_UNALLOCATED; + + /* And GNU code determines whether or not to get register information + by passing null for the REGS argument to re_match, etc., not by + setting no_sub. */ + rxb->no_sub = 0; + + rxb->rx.local_cset_size = 256; + + /* Match anchors at newline. */ + rxb->newline_anchor = 1; + + rxb->re_nsub = 0; + rxb->start = 0; + rxb->se_params = 0; + rxb->rx.nodec = 0; + rxb->rx.epsnodec = 0; + rxb->rx.instruction_table = 0; + rxb->rx.nfa_states = 0; + rxb->rx.se_list_cmp = posix_se_list_order; + rxb->rx.start_set = 0; + + ret = rx_compile (pattern, length, re_syntax_options, rxb); + alloca (0); + return rx_error_msg[(int) ret]; +} + + + +#ifdef __STDC__ +int +re_compile_fastmap (struct re_pattern_buffer * rxb) +#else +int +re_compile_fastmap (rxb) + struct re_pattern_buffer * rxb; +#endif +{ + rx_blow_up_fastmap (rxb); + return 0; +} + + + + +/* Entry points compatible with 4.2 BSD regex library. We don't define + them if this is an Emacs or POSIX compilation. */ + +/* Don't build them for libg++ either. This is a temporary measure + * until the functions are moved to another file and reconditionalized. + */ +#if 0 +/* #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) */ + +/* BSD has one and only one pattern buffer. */ +static struct re_pattern_buffer rx_comp_buf; + +#ifdef __STDC__ +char * +re_comp (__const__ char *s) +#else +char * +re_comp (s) + __const__ char *s; +#endif +{ + reg_errcode_t ret; + + if (!s || (*s == '\0')) + { + if (!rx_comp_buf.buffer) + return "No previous regular expression"; + return 0; + } + + if (!rx_comp_buf.fastmap) + { + rx_comp_buf.fastmap = (char *) malloc (1 << CHARBITS); + if (!rx_comp_buf.fastmap) + return "Memory exhausted"; + } + + /* Since `rx_exec' always passes NULL for the `regs' argument, we + don't need to initialize the pattern buffer fields which affect it. */ + + /* Match anchors at newlines. */ + rx_comp_buf.newline_anchor = 1; + + rx_comp_buf.fastmap_accurate = 0; + rx_comp_buf.re_nsub = 0; + rx_comp_buf.start = 0; + rx_comp_buf.se_params = 0; + rx_comp_buf.rx.nodec = 0; + rx_comp_buf.rx.epsnodec = 0; + rx_comp_buf.rx.instruction_table = 0; + rx_comp_buf.rx.nfa_states = 0; + rx_comp_buf.rx.start = 0; + rx_comp_buf.rx.se_list_cmp = posix_se_list_order; + rx_comp_buf.rx.start_set = 0; + rx_comp_buf.rx.local_cset_size = 256; + + ret = rx_compile (s, strlen (s), re_syntax_options, &rx_comp_buf); + alloca (0); + + /* Yes, we're discarding `__const__' here. */ + return (char *) rx_error_msg[(int) ret]; +} + + +#ifdef __STDC__ +int +re_exec (__const__ char *s) +#else +int +re_exec (s) + __const__ char *s; +#endif +{ + __const__ int len = strlen (s); + return + 0 <= re_search (&rx_comp_buf, s, len, 0, len, (struct re_registers *) 0); +} +#endif /* not emacs and not _POSIX_SOURCE */ + + + +/* POSIX.2 functions. Don't define these for Emacs. */ + +/* For now we leave these out, because regex_t is not binary + compatible with the implementation in other systems. */ +#if 0 /*!defined(emacs)*/ + +/* regcomp takes a regular expression as a string and compiles it. + + PREG is a regex_t *. We do not expect any fields to be initialized, + since POSIX says we shouldn't. Thus, we set + + `buffer' to the compiled pattern; + `used' to the length of the compiled pattern; + `syntax' to RE_SYNTAX_POSIX_EXTENDED if the + REG_EXTENDED bit in CFLAGS is set; otherwise, to + RE_SYNTAX_POSIX_BASIC; + `newline_anchor' to REG_NEWLINE being set in CFLAGS; + `fastmap' and `fastmap_accurate' to zero; + `re_nsub' to the number of subexpressions in PATTERN. + + PATTERN is the address of the pattern string. + + CFLAGS is a series of bits which affect compilation. + + If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we + use POSIX basic syntax. + + If REG_NEWLINE is set, then . and [^...] don't match newline. + Also, regexec will try a match beginning after every newline. + + If REG_ICASE is set, then we considers upper- and lowercase + versions of letters to be equivalent when matching. + + If REG_NOSUB is set, then when PREG is passed to regexec, that + routine will report only success or failure, and nothing about the + registers. + + It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for + the return codes and their meanings.) */ + + +#ifdef __STDC__ +int +regcomp (regex_t * preg, __const__ char * pattern, int cflags) +#else +int +regcomp (preg, pattern, cflags) + regex_t * preg; + __const__ char * pattern; + int cflags; +#endif +{ + reg_errcode_t ret; + unsigned syntax + = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; + + /* regex_compile will allocate the space for the compiled pattern. */ + preg->buffer = 0; + preg->allocated = 0; + preg->fastmap = malloc (256); + if (!preg->fastmap) + return REG_ESPACE; + preg->fastmap_accurate = 0; + + if (cflags & REG_ICASE) + { + unsigned i; + + preg->translate = (unsigned char *) malloc (256); + if (!preg->translate) + return (int) REG_ESPACE; + + /* Map uppercase characters to corresponding lowercase ones. */ + for (i = 0; i < CHAR_SET_SIZE; i++) + preg->translate[i] = isupper (i) ? tolower (i) : i; + } + else + preg->translate = 0; + + /* If REG_NEWLINE is set, newlines are treated differently. */ + if (cflags & REG_NEWLINE) + { /* REG_NEWLINE implies neither . nor [^...] match newline. */ + syntax &= ~RE_DOT_NEWLINE; + syntax |= RE_HAT_LISTS_NOT_NEWLINE; + /* It also changes the matching behavior. */ + preg->newline_anchor = 1; + } + else + preg->newline_anchor = 0; + + preg->no_sub = !!(cflags & REG_NOSUB); + + /* POSIX says a null character in the pattern terminates it, so we + can use strlen here in compiling the pattern. */ + preg->re_nsub = 0; + preg->start = 0; + preg->se_params = 0; + preg->syntax_parens = 0; + preg->rx.nodec = 0; + preg->rx.epsnodec = 0; + preg->rx.instruction_table = 0; + preg->rx.nfa_states = 0; + preg->rx.local_cset_size = 256; + preg->rx.start = 0; + preg->rx.se_list_cmp = posix_se_list_order; + preg->rx.start_set = 0; + ret = rx_compile (pattern, strlen (pattern), syntax, preg); + alloca (0); + + /* POSIX doesn't distinguish between an unmatched open-group and an + unmatched close-group: both are REG_EPAREN. */ + if (ret == REG_ERPAREN) ret = REG_EPAREN; + + return (int) ret; +} + + +/* regexec searches for a given pattern, specified by PREG, in the + string STRING. + + If NMATCH is zero or REG_NOSUB was set in the cflags argument to + `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at + least NMATCH elements, and we set them to the offsets of the + corresponding matched substrings. + + EFLAGS specifies `execution flags' which affect matching: if + REG_NOTBOL is set, then ^ does not match at the beginning of the + string; if REG_NOTEOL is set, then $ does not match at the end. + + We return 0 if we find a match and REG_NOMATCH if not. */ + +#ifdef __STDC__ +int +regexec (__const__ regex_t *preg, __const__ char *string, + size_t nmatch, regmatch_t pmatch[], + int eflags) +#else +int +regexec (preg, string, nmatch, pmatch, eflags) + __const__ regex_t *preg; + __const__ char *string; + size_t nmatch; + regmatch_t pmatch[]; + int eflags; +#endif +{ + int ret; + struct re_registers regs; + regex_t private_preg; + int len = strlen (string); + boolean want_reg_info = !preg->no_sub && nmatch > 0; + + private_preg = *preg; + + private_preg.not_bol = !!(eflags & REG_NOTBOL); + private_preg.not_eol = !!(eflags & REG_NOTEOL); + + /* The user has told us exactly how many registers to return + * information about, via `nmatch'. We have to pass that on to the + * matching routines. + */ + private_preg.regs_allocated = REGS_FIXED; + + if (want_reg_info) + { + regs.num_regs = nmatch; + regs.start = (( regoff_t *) malloc ((nmatch) * sizeof ( regoff_t))); + regs.end = (( regoff_t *) malloc ((nmatch) * sizeof ( regoff_t))); + if (regs.start == 0 || regs.end == 0) + return (int) REG_NOMATCH; + } + + /* Perform the searching operation. */ + ret = re_search (&private_preg, + string, len, + /* start: */ 0, + /* range: */ len, + want_reg_info ? ®s : (struct re_registers *) 0); + + /* Copy the register information to the POSIX structure. */ + if (want_reg_info) + { + if (ret >= 0) + { + unsigned r; + + for (r = 0; r < nmatch; r++) + { + pmatch[r].rm_so = regs.start[r]; + pmatch[r].rm_eo = regs.end[r]; + } + } + + /* If we needed the temporary register info, free the space now. */ + free (regs.start); + free (regs.end); + } + + /* We want zero return to mean success, unlike `re_search'. */ + return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; +} + + +/* Returns a message corresponding to an error code, ERRCODE, returned + from either regcomp or regexec. */ + +#ifdef __STDC__ +size_t +regerror (int errcode, __const__ regex_t *preg, + char *errbuf, size_t errbuf_size) +#else +size_t +regerror (errcode, preg, errbuf, errbuf_size) + int errcode; + __const__ regex_t *preg; + char *errbuf; + size_t errbuf_size; +#endif +{ + __const__ char *msg + = rx_error_msg[errcode] == 0 ? "Success" : rx_error_msg[errcode]; + size_t msg_size = strlen (msg) + 1; /* Includes the 0. */ + + if (errbuf_size != 0) + { + if (msg_size > errbuf_size) + { + strncpy (errbuf, msg, errbuf_size - 1); + errbuf[errbuf_size - 1] = 0; + } + else + strcpy (errbuf, msg); + } + + return msg_size; +} + + +/* Free dynamically allocated space used by PREG. */ + +#ifdef __STDC__ +void +regfree (regex_t *preg) +#else +void +regfree (preg) + regex_t *preg; +#endif +{ + if (preg->buffer != 0) + free (preg->buffer); + preg->buffer = 0; + preg->allocated = 0; + + if (preg->fastmap != 0) + free (preg->fastmap); + preg->fastmap = 0; + preg->fastmap_accurate = 0; + + if (preg->translate != 0) + free (preg->translate); + preg->translate = 0; +} + +#endif /* not emacs */ diff --git a/gnu/lib/libg++/librx/rx.h b/gnu/lib/libg++/librx/rx.h new file mode 100644 index 00000000000..60f99e199e2 --- /dev/null +++ b/gnu/lib/libg++/librx/rx.h @@ -0,0 +1,3732 @@ +#if !defined(RXH) || defined(RX_WANT_SE_DEFS) +#define RXH + +/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. + +This file is part of the librx library. + +Librx 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. + +Librx is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU Library General Public +License along with this software; see the file COPYING.LIB. If not, +write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA +02139, USA. */ +/* t. lord Wed Sep 23 18:20:57 1992 */ + + + + + + + + +#ifndef RX_WANT_SE_DEFS + +/* This page: Bitsets */ + +#ifndef RX_subset +typedef unsigned int RX_subset; +#define RX_subset_bits (32) +#define RX_subset_mask (RX_subset_bits - 1) +#endif + +typedef RX_subset * rx_Bitset; + +#ifdef __STDC__ +typedef void (*rx_bitset_iterator) (void *, int member_index); +#else +typedef void (*rx_bitset_iterator) (); +#endif + +#define rx_bitset_subset(N) ((N) / RX_subset_bits) +#define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)]) +#define RX_bitset_access(B,N,OP) \ + ((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask]) +#define RX_bitset_member(B,N) RX_bitset_access(B, N, &) +#define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=) +#define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~) +#define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= ) +#define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits) +#define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset)) + + + +/* This page: Splay trees. */ + +#ifdef __STDC__ +typedef int (*rx_sp_comparer) (void * a, void * b); +#else +typedef int (*rx_sp_comparer) (); +#endif + +struct rx_sp_node +{ + void * key; + void * data; + struct rx_sp_node * kids[2]; +}; + +#ifdef __STDC__ +typedef void (*rx_sp_key_data_freer) (struct rx_sp_node *); +#else +typedef void (*rx_sp_key_data_freer) (); +#endif + + +/* giant inflatable hash trees */ + +struct rx_hash_item +{ + struct rx_hash_item * next_same_hash; + struct rx_hash * table; + unsigned long hash; + void * data; + void * binding; +}; + +struct rx_hash +{ + struct rx_hash * parent; + int refs; + struct rx_hash * children[13]; + struct rx_hash_item * buckets [13]; + int bucket_size [13]; +}; + +struct rx_hash_rules; + +#ifdef __STDC__ +/* should return like == */ +typedef int (*rx_hash_eq)(void *, void *); +typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *); +typedef void (*rx_free_hash)(struct rx_hash *, + struct rx_hash_rules *); +typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *, + void *); +typedef void (*rx_free_hash_item)(struct rx_hash_item *, + struct rx_hash_rules *); +#else +typedef int (*rx_hash_eq)(); +typedef struct rx_hash * (*rx_alloc_hash)(); +typedef void (*rx_free_hash)(); +typedef struct rx_hash_item * (*rx_alloc_hash_item)(); +typedef void (*rx_free_hash_item)(); +#endif + +struct rx_hash_rules +{ + rx_hash_eq eq; + rx_alloc_hash hash_alloc; + rx_free_hash free_hash; + rx_alloc_hash_item hash_item_alloc; + rx_free_hash_item free_hash_item; +}; + + +/* Forward declarations */ + +struct rx_cache; +struct rx_superset; +struct rx; +struct rx_se_list; + + + +/* + * GLOSSARY + * + * regexp + * regular expression + * expression + * pattern - a `regular' expression. The expression + * need not be formally regular -- it can contain + * constructs that don't correspond to purely regular + * expressions. + * + * buffer + * string - the string (or strings) being searched or matched. + * + * pattern buffer - a structure of type `struct re_pattern_buffer' + * This in turn contains a `struct rx', which holds the + * NFA compiled from a pattern, as well as some of the state + * of a matcher using the pattern. + * + * NFA - nondeterministic finite automata. Some people + * use this term to a member of the class of + * regular automata (those corresponding to a regular + * language). However, in this code, the meaning is + * more general. The automata used by Rx are comperable + * in power to what are usually called `push down automata'. + * + * Two NFA are built by rx for every pattern. One is built + * by the compiler. The other is built from the first, on + * the fly, by the matcher. The latter is called the `superstate + * NFA' because its states correspond to sets of states from + * the first NFA. (Joe Keane gets credit for the name + * `superstate NFA'). + * + * NFA edges + * epsilon edges + * side-effect edges - The NFA compiled from a pattern can have three + * kinds of edges. Epsilon edges can be taken freely anytime + * their source state is reached. Character set edges can be + * taken when their source state is reached and when the next + * character in the buffer is a member of the set. Side effect + * edges imply a transition that can only be taken after the + * indicated side effect has been successfully accomplished. + * Some examples of side effects are: + * + * Storing the current match position to record the + * location of a parentesized subexpression. + * + * Advancing the matcher over N characters if they + * match the N characters previously matched by a + * parentesized subexpression. + * + * Both of those kinds of edges occur in the NFA generated + * by the pattern: \(.\)\1 + * + * Epsilon and side effect edges are similar. Unfortunately, + * some of the code uses the name `epsilon edge' to mean + * both epsilon and side effect edges. For example, the + * function has_non_idempotent_epsilon_path computes the existance + * of a non-trivial path containing only a mix of epsilon and + * side effect edges. In that case `nonidempotent epsilon' is being + * used to mean `side effect'. + */ + + + + + +/* LOW LEVEL PATTERN BUFFERS */ + +/* Suppose that from some NFA state, more than one path through + * side-effect edges is possible. In what order should the paths + * be tried? A function of type rx_se_list_order answers that + * question. It compares two lists of side effects, and says + * which list comes first. + */ + +#ifdef __STDC__ +typedef int (*rx_se_list_order) (struct rx *, + struct rx_se_list *, + struct rx_se_list *); +#else +typedef int (*rx_se_list_order) (); +#endif + + + +/* Struct RX holds a compiled regular expression - that is, an nfa + * ready to be converted on demand to a more efficient superstate nfa. + * This is for the low level interface. The high-level interfaces enclose + * this in a `struct re_pattern_buffer'. + */ +struct rx +{ + /* The compiler assigns a unique id to every pattern. + * Like sequence numbers in X, there is a subtle bug here + * if you use Rx in a system that runs for a long time. + * But, because of the way the caches work out, it is almost + * impossible to trigger the Rx version of this bug. + * + * The id is used to validate superstates found in a cache + * of superstates. It isn't sufficient to let a superstate + * point back to the rx for which it was compiled -- the caller + * may be re-using a `struct rx' in which case the superstate + * is not really valid. So instead, superstates are validated + * by checking the sequence number of the pattern for which + * they were built. + */ + int rx_id; + + /* This is memory mgt. state for superstates. This may be + * shared by more than one struct rx. + */ + struct rx_cache * cache; + + /* Every regex defines the size of its own character set. + * A superstate has an array of this size, with each element + * a `struct rx_inx'. So, don't make this number too large. + * In particular, don't make it 2^16. + */ + int local_cset_size; + + /* After the NFA is built, it is copied into a contiguous region + * of memory (mostly for compatability with GNU regex). + * Here is that region, and it's size: + */ + void * buffer; + unsigned long allocated; + + /* Clients of RX can ask for some extra storage in the space pointed + * to by BUFFER. The field RESERVED is an input parameter to the + * compiler. After compilation, this much space will be available + * at (buffer + allocated - reserved) + */ + unsigned long reserved; + + /* --------- The remaining fields are for internal use only. --------- */ + /* --------- But! they must be initialized to 0. --------- */ + + /* NODEC is the number of nodes in the NFA with non-epsilon + * transitions. + */ + int nodec; + + /* EPSNODEC is the number of nodes with only epsilon transitions. */ + int epsnodec; + + /* The sum (NODEC + EPSNODEC) is the total number of states in the + * compiled NFA. + */ + + /* Lists of side effects as stored in the NFA are `hash consed'..meaning + * that lists with the same elements are ==. During compilation, + * this table facilitates hash-consing. + */ + struct rx_hash se_list_memo; + + /* Lists of NFA states are also hashed. + */ + struct rx_hash set_list_memo; + + + + + /* The compiler and matcher must build a number of instruction frames. + * The format of these frames is fixed (c.f. struct rx_inx). The values + * of the instructions is not fixed. + * + * An enumerated type (enum rx_opcode) defines the set of instructions + * that the compiler or matcher might generate. When filling an instruction + * frame, the INX field is found by indexing this instruction table + * with an opcode: + */ + void ** instruction_table; + + /* The list of all states in an NFA. + * During compilation, the NEXT field of NFA states links this list. + * After compilation, all the states are compacted into an array, + * ordered by state id numbers. At that time, this points to the base + * of that array. + */ + struct rx_nfa_state *nfa_states; + + /* Every nfa begins with one distinguished starting state: + */ + struct rx_nfa_state *start; + + /* This orders the search through super-nfa paths. + * See the comment near the typedef of rx_se_list_order. + */ + rx_se_list_order se_list_cmp; + + struct rx_superset * start_set; +}; + + + + +/* SYNTAX TREES */ + +/* Compilation is in stages. + * + * In the first stage, a pattern specified by a string is + * translated into a syntax tree. Later stages will convert + * the syntax tree into an NFA optimized for conversion to a + * superstate-NFA. + * + * This page is about syntax trees. + */ + +enum rexp_node_type +{ + r_cset, /* Match from a character set. `a' or `[a-z]'*/ + r_concat, /* Concat two subexpressions. `ab' */ + r_alternate, /* Choose one of two subexpressions. `a\|b' */ + r_opt, /* Optional subexpression. `a?' */ + r_star, /* Repeated subexpression. `a*' */ + + + /* A 2phase-star is a variation on a repeated subexpression. + * In this case, there are two subexpressions. The first, if matched, + * begins a repitition (otherwise, the whole expression is matches the + * empth string). + * + * After matching the first subexpression, a 2phase star either finishes, + * or matches the second subexpression. If the second subexpression is + * matched, then the whole construct repeats. + * + * 2phase stars are used in two circumstances. First, they + * are used as part of the implementation of POSIX intervals (counted + * repititions). Second, they are used to implement proper star + * semantics when the repeated subexpression contains paths of + * only side effects. See rx_compile for more information. + */ + r_2phase_star, + + + /* c.f. "typedef void * rx_side_effect" */ + r_side_effect, + + /* This is an extension type: It is for transient use in source->source + * transformations (implemented over syntax trees). + */ + r_data +}; + +/* A side effect is a matcher-specific action associated with + * transitions in the NFA. The details of side effects are up + * to the matcher. To the compiler and superstate constructors + * side effects are opaque: + */ + +typedef void * rx_side_effect; + +/* Nodes in a syntax tree are of this type: + */ +struct rexp_node +{ + enum rexp_node_type type; + union + { + rx_Bitset cset; + rx_side_effect side_effect; + struct + { + struct rexp_node *left; + struct rexp_node *right; + } pair; + void * data; + } params; +}; + + + +/* NFA + * + * A syntax tree is compiled into an NFA. This page defines the structure + * of that NFA. + */ + +struct rx_nfa_state +{ + /* These are kept in a list as the NFA is being built. */ + struct rx_nfa_state *next; + + /* After the NFA is built, states are given integer id's. + * States whose outgoing transitions are all either epsilon or + * side effect edges are given ids less than 0. Other states + * are given successive non-negative ids starting from 0. + */ + int id; + + /* The list of NFA edges that go from this state to some other. */ + struct rx_nfa_edge *edges; + + /* If you land in this state, then you implicitly land + * in all other states reachable by only epsilon translations. + * Call the set of maximal paths to such states the epsilon closure + * of this state. + * + * There may be other states that are reachable by a mixture of + * epsilon and side effect edges. Consider the set of maximal paths + * of that sort from this state. Call it the epsilon-side-effect + * closure of the state. + * + * The epsilon closure of the state is a subset of the epsilon-side- + * effect closure. It consists of all the paths that contain + * no side effects -- only epsilon edges. + * + * The paths in the epsilon-side-effect closure can be partitioned + * into equivalance sets. Two paths are equivalant if they have the + * same set of side effects, in the same order. The epsilon-closure + * is one of these equivalance sets. Let's call these equivalance + * sets: observably equivalant path sets. That name is chosen + * because equivalance of two paths means they cause the same side + * effects -- so they lead to the same subsequent observations other + * than that they may wind up in different target states. + * + * The superstate nfa, which is derived from this nfa, is based on + * the observation that all of the paths in an observably equivalant + * path set can be explored at the same time, provided that the + * matcher keeps track not of a single nfa state, but of a set of + * states. In particular, after following all the paths in an + * observably equivalant set, you wind up at a set of target states. + * That set of target states corresponds to one state in the + * superstate NFA. + * + * Staticly, before matching begins, it is convenient to analyze the + * nfa. Each state is labeled with a list of the observably + * equivalant path sets who's union covers all the + * epsilon-side-effect paths beginning in this state. This list is + * called the possible futures of the state. + * + * A trivial example is this NFA: + * s1 + * A ---> B + * + * s2 + * ---> C + * + * epsilon s1 + * ---------> D ------> E + * + * + * In this example, A has two possible futures. + * One invokes the side effect `s1' and contains two paths, + * one ending in state B, the other in state E. + * The other invokes the side effect `s2' and contains only + * one path, landing in state C. + */ + struct rx_possible_future *futures; + + + /* There are exactly two distinguished states in every NFA: */ + unsigned int is_final:1; + unsigned int is_start:1; + + /* These are used during NFA construction... */ + unsigned int eclosure_needed:1; + unsigned int mark:1; +}; + + +/* An edge in an NFA is typed: */ +enum rx_nfa_etype +{ + /* A cset edge is labled with a set of characters one of which + * must be matched for the edge to be taken. + */ + ne_cset, + + /* An epsilon edge is taken whenever its starting state is + * reached. + */ + ne_epsilon, + + /* A side effect edge is taken whenever its starting state is + * reached. Side effects may cause the match to fail or the + * position of the matcher to advance. + */ + ne_side_effect /* A special kind of epsilon. */ +}; + +struct rx_nfa_edge +{ + struct rx_nfa_edge *next; + enum rx_nfa_etype type; + struct rx_nfa_state *dest; + union + { + rx_Bitset cset; + rx_side_effect side_effect; + } params; +}; + + + +/* A possible future consists of a list of side effects + * and a set of destination states. Below are their + * representations. These structures are hash-consed which + * means that lists with the same elements share a representation + * (their addresses are ==). + */ + +struct rx_nfa_state_set +{ + struct rx_nfa_state * car; + struct rx_nfa_state_set * cdr; +}; + +struct rx_se_list +{ + rx_side_effect car; + struct rx_se_list * cdr; +}; + +struct rx_possible_future +{ + struct rx_possible_future *next; + struct rx_se_list * effects; + struct rx_nfa_state_set * destset; +}; + + + +/* This begins the description of the superstate NFA. + * + * The superstate NFA corresponds to the NFA in these ways: + * + * Every superstate NFA states SUPER correspond to sets of NFA states, + * nfa_states(SUPER). + * + * Superstate edges correspond to NFA paths. + * + * The superstate has no epsilon transitions; + * every edge has a character label, and a (possibly empty) side + * effect label. The side effect label corresponds to a list of + * side effects that occur in the NFA. These parts are referred + * to as: superedge_character(EDGE) and superedge_sides(EDGE). + * + * For a superstate edge EDGE starting in some superstate SUPER, + * the following is true (in pseudo-notation :-): + * + * exists DEST in nfa_states s.t. + * exists nfaEDGE in nfa_edges s.t. + * origin (nfaEDGE) == DEST + * && origin (nfaEDGE) is a member of nfa_states(SUPER) + * && exists PF in possible_futures(dest(nfaEDGE)) s.t. + * sides_of_possible_future (PF) == superedge_sides (EDGE) + * + * also: + * + * let SUPER2 := superedge_destination(EDGE) + * nfa_states(SUPER2) + * == union of all nfa state sets S s.t. + * exists PF in possible_futures(dest(nfaEDGE)) s.t. + * sides_of_possible_future (PF) == superedge_sides (EDGE) + * && S == dests_of_possible_future (PF) } + * + * Or in english, every superstate is a set of nfa states. A given + * character and a superstate implies many transitions in the NFA -- + * those that begin with an edge labeled with that character from a + * state in the set corresponding to the superstate. + * + * The destinations of those transitions each have a set of possible + * futures. A possible future is a list of side effects and a set of + * destination NFA states. Two sets of possible futures can be + * `merged' by combining all pairs of possible futures that have the + * same side effects. A pair is combined by creating a new future + * with the same side effect but the union of the two destination sets. + * In this way, all the possible futures suggested by a superstate + * and a character can be merged into a set of possible futures where + * no two elements of the set have the same set of side effects. + * + * The destination of a possible future, being a set of NFA states, + * corresponds to a supernfa state. So, the merged set of possible + * futures we just created can serve as a set of edges in the + * supernfa. + * + * The representation of the superstate nfa and the nfa is critical. + * The nfa has to be compact, but has to facilitate the rapid + * computation of missing superstates. The superstate nfa has to + * be fast to interpret, lazilly constructed, and bounded in space. + * + * To facilitate interpretation, the superstate data structures are + * peppered with `instruction frames'. There is an instruction set + * defined below which matchers using the supernfa must be able to + * interpret. + * + * We'd like to make it possible but not mandatory to use code + * addresses to represent instructions (c.f. gcc's computed goto). + * Therefore, we define an enumerated type of opcodes, and when + * writing one of these instructions into a data structure, use + * the opcode as an index into a table of instruction values. + * + * Here are the opcodes that occur in the superstate nfa: + */ + + +/* Every superstate contains a table of instruction frames indexed + * by characters. A normal `move' in a matcher is to fetch the next + * character and use it as an index into a superstates transition + * table. + * + * In the fasted case, only one edge follows from that character. + * In other cases there is more work to do. + * + * The descriptions of the opcodes refer to data structures that are + * described further below. + */ + +enum rx_opcode +{ + /* + * BACKTRACK_POINT is invoked when a character transition in + * a superstate leads to more than one edge. In that case, + * the edges have to be explored independently using a backtracking + * strategy. + * + * A BACKTRACK_POINT instruction is stored in a superstate's + * transition table for some character when it is known that that + * character crosses more than one edge. On encountering this + * instruction, the matcher saves enough state to backtrack to this + * point in the match later. + */ + rx_backtrack_point = 0, /* data is (struct transition_class *) */ + + /* + * RX_DO_SIDE_EFFECTS evaluates the side effects of an epsilon path. + * There is one occurence of this instruction per rx_distinct_future. + * This instruction is skipped if a rx_distinct_future has no side effects. + */ + rx_do_side_effects = rx_backtrack_point + 1, + + /* data is (struct rx_distinct_future *) */ + + /* + * RX_CACHE_MISS instructions are stored in rx_distinct_futures whose + * destination superstate has been reclaimed (or was never built). + * It recomputes the destination superstate. + * RX_CACHE_MISS is also stored in a superstate transition table before + * any of its edges have been built. + */ + rx_cache_miss = rx_do_side_effects + 1, + /* data is (struct rx_distinct_future *) */ + + /* + * RX_NEXT_CHAR is called to consume the next character and take the + * corresponding transition. This is the only instruction that uses + * the DATA field of the instruction frame instead of DATA_2. + * (see EXPLORE_FUTURE in regex.c). + */ + rx_next_char = rx_cache_miss + 1, /* data is (struct superstate *) */ + + /* RX_BACKTRACK indicates that a transition fails. + */ + rx_backtrack = rx_next_char + 1, /* no data */ + + /* + * RX_ERROR_INX is stored only in places that should never be executed. + */ + rx_error_inx = rx_backtrack + 1, /* Not supposed to occur. */ + + rx_num_instructions = rx_error_inx + 1 +}; + +/* An id_instruction_table holds the values stored in instruction + * frames. The table is indexed by the enums declared above. + */ +extern void * rx_id_instruction_table[rx_num_instructions]; + +/* The heart of the matcher is a `word-code-interpreter' + * (like a byte-code interpreter, except that instructions + * are a full word wide). + * + * Instructions are not stored in a vector of code, instead, + * they are scattered throughout the data structures built + * by the regexp compiler and the matcher. One word-code instruction, + * together with the arguments to that instruction, constitute + * an instruction frame (struct rx_inx). + * + * This structure type is padded by hand to a power of 2 because + * in one of the dominant cases, we dispatch by indexing a table + * of instruction frames. If that indexing can be accomplished + * by just a shift of the index, we're happy. + * + * Instructions take at most one argument, but there are two + * slots in an instruction frame that might hold that argument. + * These are called data and data_2. The data slot is only + * used for one instruction (RX_NEXT_CHAR). For all other + * instructions, data should be set to 0. + * + * RX_NEXT_CHAR is the most important instruction by far. + * By reserving the data field for its exclusive use, + * instruction dispatch is sped up in that case. There is + * no need to fetch both the instruction and the data, + * only the data is needed. In other words, a `cycle' begins + * by fetching the field data. If that is non-0, then it must + * be the destination state of a next_char transition, so + * make that value the current state, advance the match position + * by one character, and start a new cycle. On the other hand, + * if data is 0, fetch the instruction and do a more complicated + * dispatch on that. + */ + +struct rx_inx +{ + void * data; + void * data_2; + void * inx; + void * fnord; +}; + +#ifndef RX_TAIL_ARRAY +#define RX_TAIL_ARRAY 1 +#endif + +/* A superstate corresponds to a set of nfa states. Those sets are + * represented by STRUCT RX_SUPERSET. The constructors + * guarantee that only one (shared) structure is created for a given set. + */ +struct rx_superset +{ + int refs; /* This is a reference counted structure. */ + + /* We keep these sets in a cache because (in an unpredictable way), + * the same set is often created again and again. But that is also + * problematic -- compatibility with POSIX and GNU regex requires + * that we not be able to tell when a program discards a particular + * NFA (thus invalidating the supersets created from it). + * + * But when a cache hit appears to occur, we will have in hand the + * nfa for which it may have happened. That is why every nfa is given + * its own sequence number. On a cache hit, the cache is validated + * by comparing the nfa sequence number to this field: + */ + int id; + + struct rx_nfa_state * car; /* May or may not be a valid addr. */ + struct rx_superset * cdr; + + /* If the corresponding superstate exists: */ + struct rx_superstate * superstate; + + + /* There is another bookkeeping problem. It is expensive to + * compute the starting nfa state set for an nfa. So, once computed, + * it is cached in the `struct rx'. + * + * But, the state set can be flushed from the superstate cache. + * When that happens, we can't know if the corresponding `struct rx' + * is still alive or if it has been freed or re-used by the program. + * So, the cached pointer to this set in a struct rx might be invalid + * and we need a way to validate it. + * + * Fortunately, even if this set is flushed from the cache, it is + * not freed. It just goes on the free-list of supersets. + * So we can still examine it. + * + * So to validate a starting set memo, check to see if the + * starts_for field still points back to the struct rx in question, + * and if the ID matches the rx sequence number. + */ + struct rx * starts_for; + + /* This is used to link into a hash bucket so these objects can + * be `hash-consed'. + */ + struct rx_hash_item hash_item; +}; + +#define rx_protect_superset(RX,CON) (++(CON)->refs) + +/* The terminology may be confusing (rename this structure?). + * Every character occurs in at most one rx_super_edge per super-state. + * But, that structure might have more than one option, indicating a point + * of non-determinism. + * + * In other words, this structure holds a list of superstate edges + * sharing a common starting state and character label. The edges + * are in the field OPTIONS. All superstate edges sharing the same + * starting state and character are in this list. + */ +struct rx_super_edge +{ + struct rx_super_edge *next; + struct rx_inx rx_backtrack_frame; + int cset_size; + rx_Bitset cset; + struct rx_distinct_future *options; +}; + +/* A superstate is a set of nfa states (RX_SUPERSET) along + * with a transition table. Superstates are built on demand and reclaimed + * without warning. To protect a superstate from this ghastly fate, + * use LOCK_SUPERSTATE. + */ +struct rx_superstate +{ + int rx_id; /* c.f. the id field of rx_superset */ + int locks; /* protection from reclamation */ + + /* Within a superstate cache, all the superstates are kept in a big + * queue. The tail of the queue is the state most likely to be + * reclaimed. The *recyclable fields hold the queue position of + * this state. + */ + struct rx_superstate * next_recyclable; + struct rx_superstate * prev_recyclable; + + /* The supernfa edges that exist in the cache and that have + * this state as their destination are kept in this list: + */ + struct rx_distinct_future * transition_refs; + + /* The list of nfa states corresponding to this superstate: */ + struct rx_superset * contents; + + /* The list of edges in the cache beginning from this state. */ + struct rx_super_edge * edges; + + /* A tail of the recyclable queue is marked as semifree. A semifree + * state has no incoming next_char transitions -- any transition + * into a semifree state causes a complex dispatch with the side + * effect of rescuing the state from its semifree state. + * + * An alternative to this might be to make next_char more expensive, + * and to move a state to the head of the recyclable queue whenever + * it is entered. That way, popular states would never be recycled. + * + * But unilaterally making next_char more expensive actually loses. + * So, incoming transitions are only made expensive for states near + * the tail of the recyclable queue. The more cache contention + * there is, the more frequently a state will have to prove itself + * and be moved back to the front of the queue. If there is less + * contention, then popular states just aggregate in the front of + * the queue and stay there. + */ + int is_semifree; + + + /* This keeps track of the size of the transition table for this + * state. There is a half-hearted attempt to support variable sized + * superstates. + */ + int trans_size; + + /* Indexed by characters... */ + struct rx_inx transitions[RX_TAIL_ARRAY]; +}; + + +/* A list of distinct futures define the edges that leave from a + * given superstate on a given character. c.f. rx_super_edge. + */ + +struct rx_distinct_future +{ + struct rx_distinct_future * next_same_super_edge[2]; + struct rx_distinct_future * next_same_dest; + struct rx_distinct_future * prev_same_dest; + struct rx_superstate * present; /* source state */ + struct rx_superstate * future; /* destination state */ + struct rx_super_edge * edge; + + + /* The future_frame holds the instruction that should be executed + * after all the side effects are done, when it is time to complete + * the transition to the next state. + * + * Normally this is a next_char instruction, but it may be a + * cache_miss instruction as well, depending on whether or not + * the superstate is in the cache and semifree. + * + * If this is the only future for a given superstate/char, and + * if there are no side effects to be performed, this frame is + * not used (directly) at all. Instead, its contents are copied + * into the transition table of the starting state of this dist. future. + */ + struct rx_inx future_frame; + + struct rx_inx side_effects_frame; + struct rx_se_list * effects; +}; + +#define rx_lock_superstate(R,S) ((S)->locks++) +#define rx_unlock_superstate(R,S) (--(S)->locks) + + +/* This page destined for rx.h */ + +struct rx_blocklist +{ + struct rx_blocklist * next; + int bytes; +}; + +struct rx_freelist +{ + struct rx_freelist * next; +}; + +struct rx_cache; + +#ifdef __STDC__ +typedef void (*rx_morecore_fn)(struct rx_cache *); +#else +typedef void (*rx_morecore_fn)(); +#endif + +/* You use this to control the allocation of superstate data + * during matching. Most of it should be initialized to 0. + * + * A MORECORE function is necessary. It should allocate + * a new block of memory or return 0. + * A default that uses malloc is called `rx_morecore'. + * + * The number of SUPERSTATES_ALLOWED indirectly limits how much memory + * the system will try to allocate. The default is 128. Batch style + * applications that are very regexp intensive should use as high a number + * as possible without thrashing. + * + * The LOCAL_CSET_SIZE is the number of characters in a character set. + * It is therefore the number of entries in a superstate transition table. + * Generally, it should be 256. If your character set has 16 bits, + * it is better to translate your regexps into equivalent 8 bit patterns. + */ + +struct rx_cache +{ + struct rx_hash_rules superset_hash_rules; + + /* Objects are allocated by incrementing a pointer that + * scans across rx_blocklists. + */ + struct rx_blocklist * memory; + struct rx_blocklist * memory_pos; + int bytes_left; + char * memory_addr; + rx_morecore_fn morecore; + + /* Freelists. */ + struct rx_freelist * free_superstates; + struct rx_freelist * free_transition_classes; + struct rx_freelist * free_discernable_futures; + struct rx_freelist * free_supersets; + struct rx_freelist * free_hash; + + /* Two sets of superstates -- those that are semifreed, and those + * that are being used. + */ + struct rx_superstate * lru_superstate; + struct rx_superstate * semifree_superstate; + + struct rx_superset * empty_superset; + + int superstates; + int semifree_superstates; + int hits; + int misses; + int superstates_allowed; + + int local_cset_size; + void ** instruction_table; + + struct rx_hash superset_table; +}; + + + +/* The lowest-level search function supports arbitrarily fragmented + * strings and (optionally) suspendable/resumable searches. + * + * Callers have to provide a few hooks. + */ + +#ifndef __GNUC__ +#ifdef __STDC__ +#define __const__ const +#else +#define __const__ +#endif +#endif + +/* This holds a matcher position */ +struct rx_string_position +{ + __const__ unsigned char * pos; /* The current pos. */ + __const__ unsigned char * string; /* The current string burst. */ + __const__ unsigned char * end; /* First invalid position >= POS. */ + int offset; /* Integer address of the current burst. */ + int size; /* Current string's size. */ + int search_direction; /* 1 or -1 */ + int search_end; /* First position to not try. */ +}; + + +enum rx_get_burst_return +{ + rx_get_burst_continuation, + rx_get_burst_error, + rx_get_burst_ok, + rx_get_burst_no_more +}; + + +/* A call to get burst should make POS valid. It might be invalid + * if the STRING field doesn't point to a burst that actually + * contains POS. + * + * GET_BURST should take a clue from SEARCH_DIRECTION (1 or -1) as to + * whether or not to pad to the left. Padding to the right is always + * appropriate, but need not go past the point indicated by STOP. + * + * If a continuation is returned, then the reentering call to + * a search function will retry the get_burst. + */ + +#ifdef __STDC__ +typedef enum rx_get_burst_return + (*rx_get_burst_fn) (struct rx_string_position * pos, + void * app_closure, + int stop); + +#else +typedef enum rx_get_burst_return (*rx_get_burst_fn) (); +#endif + + +enum rx_back_check_return +{ + rx_back_check_continuation, + rx_back_check_error, + rx_back_check_pass, + rx_back_check_fail +}; + +/* Back_check should advance the position it is passed + * over rparen - lparen characters and return pass iff + * the characters starting at POS match those indexed + * by [LPAREN..RPAREN]. + * + * If a continuation is returned, then the reentering call to + * a search function will retry the back_check. + */ + +#ifdef __STDC__ +typedef enum rx_back_check_return + (*rx_back_check_fn) (struct rx_string_position * pos, + int lparen, + int rparen, + unsigned char * translate, + void * app_closure, + int stop); + +#else +typedef enum rx_back_check_return (*rx_back_check_fn) (); +#endif + + + + +/* A call to fetch_char should return the character at POS or POS + 1. + * Returning continuations here isn't supported. OFFSET is either 0 or 1 + * and indicates which characters is desired. + */ + +#ifdef __STDC__ +typedef int (*rx_fetch_char_fn) (struct rx_string_position * pos, + int offset, + void * app_closure, + int stop); +#else +typedef int (*rx_fetch_char_fn) (); +#endif + + +enum rx_search_return +{ + rx_search_continuation = -4, + rx_search_error = -3, + rx_search_soft_fail = -2, /* failed by running out of string */ + rx_search_fail = -1 /* failed only by reaching failure states */ + /* return values >= 0 indicate the position of a successful match */ +}; + + + + + + +/* regex.h + * + * The remaining declarations replace regex.h. + */ + +/* This is an array of error messages corresponding to the error codes. + */ +extern __const__ char *re_error_msg[]; + +/* If any error codes are removed, changed, or added, update the + `re_error_msg' table in regex.c. */ +typedef enum +{ + REG_NOERROR = 0, /* Success. */ + REG_NOMATCH, /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ + REG_BADPAT, /* Invalid pattern. */ + REG_ECOLLATE, /* Not implemented. */ + REG_ECTYPE, /* Invalid character class name. */ + REG_EESCAPE, /* Trailing backslash. */ + REG_ESUBREG, /* Invalid back reference. */ + REG_EBRACK, /* Unmatched left bracket. */ + REG_EPAREN, /* Parenthesis imbalance. */ + REG_EBRACE, /* Unmatched \{. */ + REG_BADBR, /* Invalid contents of \{\}. */ + REG_ERANGE, /* Invalid range end. */ + REG_ESPACE, /* Ran out of memory. */ + REG_BADRPT, /* No preceding re for repetition op. */ + + /* Error codes we've added. */ + REG_EEND, /* Premature end. */ + REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ + REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ +} reg_errcode_t; + +/* The regex.c support, as a client of rx, defines a set of possible + * side effects that can be added to the edge lables of nfa edges. + * Here is the list of sidef effects in use. + */ + +enum re_side_effects +{ +#define RX_WANT_SE_DEFS 1 +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#define RX_DEF_SE(IDEM, NAME, VALUE) NAME VALUE, +#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) NAME VALUE, +#include "rx.h" +#undef RX_DEF_SE +#undef RX_DEF_CPLX_SE +#undef RX_WANT_SE_DEFS + re_floogle_flap = 65533 +}; + +/* These hold paramaters for the kinds of side effects that are possible + * in the supported pattern languages. These include things like the + * numeric bounds of {} operators and the index of paren registers for + * subexpression measurement or backreferencing. + */ +struct re_se_params +{ + enum re_side_effects se; + int op1; + int op2; +}; + +typedef unsigned reg_syntax_t; + +struct re_pattern_buffer +{ + struct rx rx; + reg_syntax_t syntax; /* See below for syntax bit definitions. */ + + unsigned int no_sub:1; /* If set, don't return register offsets. */ + unsigned int not_bol:1; /* If set, the anchors ('^' and '$') don't */ + unsigned int not_eol:1; /* match at the ends of the string. */ + unsigned int newline_anchor:1;/* If true, an anchor at a newline matches.*/ + unsigned int least_subs:1; /* If set, and returning registers, return + * as few values as possible. Only + * backreferenced groups and group 0 (the whole + * match) will be returned. + */ + + /* If true, this says that the matcher should keep registers on its + * backtracking stack. For many patterns, we can easily determine that + * this isn't necessary. + */ + unsigned int match_regs_on_stack:1; + unsigned int search_regs_on_stack:1; + + /* is_anchored and begbuf_only are filled in by rx_compile. */ + unsigned int is_anchored:1; /* Anchorded by ^? */ + unsigned int begbuf_only:1; /* Anchored to char position 0? */ + + + /* If REGS_UNALLOCATED, allocate space in the `regs' structure + * for `max (RE_NREGS, re_nsub + 1)' groups. + * If REGS_REALLOCATE, reallocate space if necessary. + * If REGS_FIXED, use what's there. + */ +#define REGS_UNALLOCATED 0 +#define REGS_REALLOCATE 1 +#define REGS_FIXED 2 + unsigned int regs_allocated:2; + + + /* Either a translate table to apply to all characters before + * comparing them, or zero for no translation. The translation + * is applied to a pattern when it is compiled and to a string + * when it is matched. + */ + unsigned char * translate; + + /* If this is a valid pointer, it tells rx not to store the extents of + * certain subexpressions (those corresponding to non-zero entries). + * Passing 0x1 is the same as passing an array of all ones. Passing 0x0 + * is the same as passing an array of all zeros. + * The array should contain as many entries as their are subexps in the + * regexp. + * + * For POSIX compatability, when using regcomp and regexec this field + * is zeroed and ignored. + */ + char * syntax_parens; + + /* Number of subexpressions found by the compiler. */ + size_t re_nsub; + + void * buffer; /* Malloced memory for the nfa. */ + unsigned long allocated; /* Size of that memory. */ + + /* Pointer to a fastmap, if any, otherwise zero. re_search uses + * the fastmap, if there is one, to skip over impossible + * starting points for matches. */ + char *fastmap; + + unsigned int fastmap_accurate:1; /* These three are internal. */ + unsigned int can_match_empty:1; + struct rx_nfa_state * start; /* The nfa starting state. */ + + /* This is the list of iterator bounds for {lo,hi} constructs. + * The memory pointed to is part of the rx->buffer. + */ + struct re_se_params *se_params; + + /* This is a bitset representation of the fastmap. + * This is a true fastmap that already takes the translate + * table into account. + */ + rx_Bitset fastset; +}; + +/* Type for byte offsets within the string. POSIX mandates this. */ +typedef int regoff_t; + +/* This is the structure we store register match data in. See + regex.texinfo for a full description of what registers match. */ +struct re_registers +{ + unsigned num_regs; + regoff_t *start; + regoff_t *end; +}; + +typedef struct re_pattern_buffer regex_t; + +/* POSIX specification for registers. Aside from the different names than + `re_registers', POSIX uses an array of structures, instead of a + structure of arrays. */ +typedef struct +{ + regoff_t rm_so; /* Byte offset from string's start to substring's start. */ + regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ +} regmatch_t; + + +/* The following bits are used to determine the regexp syntax we + recognize. The set/not-set meanings are chosen so that Emacs syntax + remains the value 0. The bits are given in alphabetical order, and + the definitions shifted by one from the previous bit; thus, when we + add or remove a bit, only one other definition need change. */ + +/* If this bit is not set, then \ inside a bracket expression is literal. + If set, then such a \ quotes the following character. */ +#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) + +/* If this bit is not set, then + and ? are operators, and \+ and \? are + literals. + If set, then \+ and \? are operators and + and ? are literals. */ +#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) + +/* If this bit is set, then character classes are supported. They are: + [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], + [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. + If not set, then character classes are not supported. */ +#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) + +/* If this bit is set, then ^ and $ are always anchors (outside bracket + expressions, of course). + If this bit is not set, then it depends: + ^ is an anchor if it is at the beginning of a regular + expression or after an open-group or an alternation operator; + $ is an anchor if it is at the end of a regular expression, or + before a close-group or an alternation operator. + + This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because + POSIX draft 11.2 says that * etc. in leading positions is undefined. + We already implemented a previous draft which made those constructs + invalid, though, so we haven't changed the code back. */ +#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) + +/* If this bit is set, then special characters are always special + regardless of where they are in the pattern. + If this bit is not set, then special characters are special only in + some contexts; otherwise they are ordinary. Specifically, + * + ? and intervals are only special when not after the beginning, + open-group, or alternation operator. */ +#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) + +/* If this bit is set, then *, +, ?, and { cannot be first in an re or + immediately after an alternation or begin-group operator. */ +#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) + +/* If this bit is set, then . matches newline. + If not set, then it doesn't. */ +#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) + +/* If this bit is set, then . doesn't match NUL. + If not set, then it does. */ +#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) + +/* If this bit is set, nonmatching lists [^...] do not match newline. + If not set, they do. */ +#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) + +/* If this bit is set, either \{...\} or {...} defines an + interval, depending on RE_NO_BK_BRACES. + If not set, \{, \}, {, and } are literals. */ +#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) + +/* If this bit is set, +, ? and | aren't recognized as operators. + If not set, they are. */ +#define RE_LIMITED_OPS (RE_INTERVALS << 1) + +/* If this bit is set, newline is an alternation operator. + If not set, newline is literal. */ +#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) + +/* If this bit is set, then `{...}' defines an interval, and \{ and \} + are literals. + If not set, then `\{...\}' defines an interval. */ +#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) + +/* If this bit is set, (...) defines a group, and \( and \) are literals. + If not set, \(...\) defines a group, and ( and ) are literals. */ +#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) + +/* If this bit is set, then \ matches . + If not set, then \ is a back-reference. */ +#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) + +/* If this bit is set, then | is an alternation operator, and \| is literal. + If not set, then \| is an alternation operator, and | is literal. */ +#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) + +/* If this bit is set, then an ending range point collating higher + than the starting range point, as in [z-a], is invalid. + If not set, then when ending range point collates higher than the + starting range point, the range is ignored. */ +#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) + +/* If this bit is set, then an unmatched ) is ordinary. + If not set, then an unmatched ) is invalid. */ +#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) + +/* This global variable defines the particular regexp syntax to use (for + some interfaces). When a regexp is compiled, the syntax used is + stored in the pattern buffer, so changing this does not affect + already-compiled regexps. */ +extern reg_syntax_t re_syntax_options; + +/* Define combinations of the above bits for the standard possibilities. + (The [[[ comments delimit what gets put into the Texinfo file, so + don't delete them!) */ +/* [[[begin syntaxes]]] */ +#define RE_SYNTAX_EMACS 0 + +#define RE_SYNTAX_AWK \ + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_UNMATCHED_RIGHT_PAREN_ORD) + +#define RE_SYNTAX_POSIX_AWK \ + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) + +#define RE_SYNTAX_GREP \ + (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ + | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ + | RE_NEWLINE_ALT) + +#define RE_SYNTAX_EGREP \ + (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ + | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ + | RE_NO_BK_VBAR) + +#define RE_SYNTAX_POSIX_EGREP \ + (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) + +#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC + +/* Syntax bits common to both basic and extended POSIX regex syntax. */ +#define _RE_SYNTAX_POSIX_COMMON \ + (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ + | RE_INTERVALS | RE_NO_EMPTY_RANGES) + +#define RE_SYNTAX_POSIX_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) + +/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes + RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this + isn't minimal, since other operators, such as \`, aren't disabled. */ +#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) + +#define RE_SYNTAX_POSIX_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_UNMATCHED_RIGHT_PAREN_ORD) + +/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS + replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ +#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) +/* [[[end syntaxes]]] */ + +/* Maximum number of duplicates an interval can allow. Some systems + (erroneously) define this in other header files, but we want our + value, so remove any previous define. */ +#ifdef RE_DUP_MAX +#undef RE_DUP_MAX +#endif +#define RE_DUP_MAX ((1 << 15) - 1) + + + +/* POSIX `cflags' bits (i.e., information for `regcomp'). */ + +/* If this bit is set, then use extended regular expression syntax. + If not set, then use basic regular expression syntax. */ +#define REG_EXTENDED 1 + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +#define REG_ICASE (REG_EXTENDED << 1) + +/* If this bit is set, then anchors do not match at newline + characters in the string. + If not set, then anchors do match at newlines. */ +#define REG_NEWLINE (REG_ICASE << 1) + +/* If this bit is set, then report only success or fail in regexec. + If not set, then returns differ between not matching and errors. */ +#define REG_NOSUB (REG_NEWLINE << 1) + + +/* POSIX `eflags' bits (i.e., information for regexec). */ + +/* If this bit is set, then the beginning-of-line operator doesn't match + the beginning of the string (presumably because it's not the + beginning of a line). + If not set, then the beginning-of-line operator does match the + beginning of the string. */ +#define REG_NOTBOL 1 + +/* Like REG_NOTBOL, except for the end-of-line. */ +#define REG_NOTEOL (1 << 1) + +/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, + * `re_match_2' returns information about at least this many registers + * the first time a `regs' structure is passed. + * + * Also, this is the greatest number of backreferenced subexpressions + * allowed in a pattern being matched without caller-supplied registers. + */ +#ifndef RE_NREGS +#define RE_NREGS 30 +#endif + +extern int rx_cache_bound; +extern char rx_version_string[]; + + + +#ifdef RX_WANT_RX_DEFS + +/* This is decls to the interesting subsystems and lower layers + * of rx. Everything which doesn't have a public counterpart in + * regex.c is declared here. + */ + + +#ifdef __STDC__ +typedef void (*rx_hash_freefn) (struct rx_hash_item * it); +#else /* ndef __STDC__ */ +typedef void (*rx_hash_freefn) (); +#endif /* ndef __STDC__ */ + + + + +#ifdef __STDC__ +RX_DECL int rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b); +RX_DECL int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b); +RX_DECL int rx_bitset_empty (int size, rx_Bitset set); +RX_DECL void rx_bitset_null (int size, rx_Bitset b); +RX_DECL void rx_bitset_universe (int size, rx_Bitset b); +RX_DECL void rx_bitset_complement (int size, rx_Bitset b); +RX_DECL void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b); +RX_DECL void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b); +RX_DECL void rx_bitset_intersection (int size, + rx_Bitset a, rx_Bitset b); +RX_DECL void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b); +RX_DECL void rx_bitset_revdifference (int size, + rx_Bitset a, rx_Bitset b); +RX_DECL void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b); +RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b); +RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table, + unsigned long hash, + void * value, + struct rx_hash_rules * rules); +RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table, + unsigned long hash, + void * value, + struct rx_hash_rules * rules); +RX_DECL void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules); +RX_DECL void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn, + struct rx_hash_rules * rules); +RX_DECL rx_Bitset rx_cset (struct rx *rx); +RX_DECL rx_Bitset rx_copy_cset (struct rx *rx, rx_Bitset a); +RX_DECL void rx_free_cset (struct rx * rx, rx_Bitset c); +RX_DECL struct rexp_node * rexp_node (struct rx *rx, + enum rexp_node_type type); +RX_DECL struct rexp_node * rx_mk_r_cset (struct rx * rx, + rx_Bitset b); +RX_DECL struct rexp_node * rx_mk_r_concat (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b); +RX_DECL struct rexp_node * rx_mk_r_alternate (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b); +RX_DECL struct rexp_node * rx_mk_r_opt (struct rx * rx, + struct rexp_node * a); +RX_DECL struct rexp_node * rx_mk_r_star (struct rx * rx, + struct rexp_node * a); +RX_DECL struct rexp_node * rx_mk_r_2phase_star (struct rx * rx, + struct rexp_node * a, + struct rexp_node * b); +RX_DECL struct rexp_node * rx_mk_r_side_effect (struct rx * rx, + rx_side_effect a); +RX_DECL struct rexp_node * rx_mk_r_data (struct rx * rx, + void * a); +RX_DECL void rx_free_rexp (struct rx * rx, struct rexp_node * node); +RX_DECL struct rexp_node * rx_copy_rexp (struct rx *rx, + struct rexp_node *node); +RX_DECL struct rx_nfa_state * rx_nfa_state (struct rx *rx); +RX_DECL void rx_free_nfa_state (struct rx_nfa_state * n); +RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (struct rx * rx, + int id); +RX_DECL struct rx_nfa_edge * rx_nfa_edge (struct rx *rx, + enum rx_nfa_etype type, + struct rx_nfa_state *start, + struct rx_nfa_state *dest); +RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge * e); +RX_DECL void rx_free_nfa (struct rx *rx); +RX_DECL int rx_build_nfa (struct rx *rx, + struct rexp_node *rexp, + struct rx_nfa_state **start, + struct rx_nfa_state **end); +RX_DECL void rx_name_nfa_states (struct rx *rx); +RX_DECL int rx_eclose_nfa (struct rx *rx); +RX_DECL void rx_delete_epsilon_transitions (struct rx *rx); +RX_DECL int rx_compactify_nfa (struct rx *rx, + void **mem, unsigned long *size); +RX_DECL void rx_release_superset (struct rx *rx, + struct rx_superset *set); +RX_DECL struct rx_superset * rx_superset_cons (struct rx * rx, + struct rx_nfa_state *car, struct rx_superset *cdr); +RX_DECL struct rx_superset * rx_superstate_eclosure_union + (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl); +RX_DECL struct rx_superstate * rx_superstate (struct rx *rx, + struct rx_superset *set); +RX_DECL struct rx_inx * rx_handle_cache_miss + (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data); +RX_DECL reg_errcode_t rx_compile (__const__ char *pattern, int size, + reg_syntax_t syntax, + struct re_pattern_buffer * rxb); +RX_DECL void rx_blow_up_fastmap (struct re_pattern_buffer * rxb); +#else /* STDC */ +RX_DECL int rx_bitset_is_equal (); +RX_DECL int rx_bitset_is_subset (); +RX_DECL int rx_bitset_empty (); +RX_DECL void rx_bitset_null (); +RX_DECL void rx_bitset_universe (); +RX_DECL void rx_bitset_complement (); +RX_DECL void rx_bitset_assign (); +RX_DECL void rx_bitset_union (); +RX_DECL void rx_bitset_intersection (); +RX_DECL void rx_bitset_difference (); +RX_DECL void rx_bitset_revdifference (); +RX_DECL void rx_bitset_xor (); +RX_DECL unsigned long rx_bitset_hash (); +RX_DECL struct rx_hash_item * rx_hash_find (); +RX_DECL struct rx_hash_item * rx_hash_store (); +RX_DECL void rx_hash_free (); +RX_DECL void rx_free_hash_table (); +RX_DECL rx_Bitset rx_cset (); +RX_DECL rx_Bitset rx_copy_cset (); +RX_DECL void rx_free_cset (); +RX_DECL struct rexp_node * rexp_node (); +RX_DECL struct rexp_node * rx_mk_r_cset (); +RX_DECL struct rexp_node * rx_mk_r_concat (); +RX_DECL struct rexp_node * rx_mk_r_alternate (); +RX_DECL struct rexp_node * rx_mk_r_opt (); +RX_DECL struct rexp_node * rx_mk_r_star (); +RX_DECL struct rexp_node * rx_mk_r_2phase_star (); +RX_DECL struct rexp_node * rx_mk_r_side_effect (); +RX_DECL struct rexp_node * rx_mk_r_data (); +RX_DECL void rx_free_rexp (); +RX_DECL struct rexp_node * rx_copy_rexp (); +RX_DECL struct rx_nfa_state * rx_nfa_state (); +RX_DECL void rx_free_nfa_state (); +RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (); +RX_DECL struct rx_nfa_edge * rx_nfa_edge (); +RX_DECL void rx_free_nfa_edge (); +RX_DECL void rx_free_nfa (); +RX_DECL int rx_build_nfa (); +RX_DECL void rx_name_nfa_states (); +RX_DECL int rx_eclose_nfa (); +RX_DECL void rx_delete_epsilon_transitions (); +RX_DECL int rx_compactify_nfa (); +RX_DECL void rx_release_superset (); +RX_DECL struct rx_superset * rx_superset_cons (); +RX_DECL struct rx_superset * rx_superstate_eclosure_union (); +RX_DECL struct rx_superstate * rx_superstate (); +RX_DECL struct rx_inx * rx_handle_cache_miss (); +RX_DECL reg_errcode_t rx_compile (); +RX_DECL void rx_blow_up_fastmap (); +#endif /* STDC */ + + +#endif /* RX_WANT_RX_DEFS */ + + + +#ifdef __STDC__ +extern int re_search_2 (struct re_pattern_buffer *rxb, + __const__ char * string1, int size1, + __const__ char * string2, int size2, + int startpos, int range, + struct re_registers *regs, + int stop); +extern int re_search (struct re_pattern_buffer * rxb, __const__ char *string, + int size, int startpos, int range, + struct re_registers *regs); +extern int re_match_2 (struct re_pattern_buffer * rxb, + __const__ char * string1, int size1, + __const__ char * string2, int size2, + int pos, struct re_registers *regs, int stop); +extern int re_match (struct re_pattern_buffer * rxb, + __const__ char * string, + int size, int pos, + struct re_registers *regs); +extern reg_syntax_t re_set_syntax (reg_syntax_t syntax); +extern void re_set_registers (struct re_pattern_buffer *bufp, + struct re_registers *regs, + unsigned num_regs, + regoff_t * starts, regoff_t * ends); +extern __const__ char * re_compile_pattern (__const__ char *pattern, + int length, + struct re_pattern_buffer * rxb); +extern int re_compile_fastmap (struct re_pattern_buffer * rxb); +extern char * re_comp (__const__ char *s); +extern int re_exec (__const__ char *s); +extern int regcomp (regex_t * preg, __const__ char * pattern, int cflags); +extern int regexec (__const__ regex_t *preg, __const__ char *string, + size_t nmatch, regmatch_t pmatch[], + int eflags); +extern size_t regerror (int errcode, __const__ regex_t *preg, + char *errbuf, size_t errbuf_size); +extern void regfree (regex_t *preg); + +#else /* STDC */ +extern int re_search_2 (); +extern int re_search (); +extern int re_match_2 (); +extern int re_match (); +extern reg_syntax_t re_set_syntax (); +extern void re_set_registers (); +extern __const__ char * re_compile_pattern (); +extern int re_compile_fastmap (); +extern char * re_comp (); +extern int re_exec (); +extern int regcomp (); +extern int regexec (); +extern size_t regerror (); +extern void regfree (); + +#endif /* STDC */ + + + +#ifdef RX_WANT_RX_DEFS + +struct rx_counter_frame +{ + int tag; + int val; + struct rx_counter_frame * inherited_from; /* If this is a copy. */ + struct rx_counter_frame * cdr; +}; + +struct rx_backtrack_frame +{ + char * counter_stack_sp; + + /* A frame is used to save the matchers state when it crosses a + * backtracking point. The `stk_' fields correspond to variables + * in re_search_2 (just strip off thes `stk_'). They are documented + * tere. + */ + struct rx_superstate * stk_super; + unsigned int stk_c; + struct rx_string_position stk_test_pos; + int stk_last_l; + int stk_last_r; + int stk_test_ret; + + /* This is the list of options left to explore at the backtrack + * point for which this frame was created. + */ + struct rx_distinct_future * df; + struct rx_distinct_future * first_df; + +#ifdef RX_DEBUG + int stk_line_no; +#endif +}; + +struct rx_stack_chunk +{ + struct rx_stack_chunk * next_chunk; + int bytes_left; + char * sp; +}; + +enum rx_outer_entry +{ + rx_outer_start, + rx_outer_fastmap, + rx_outer_test, + rx_outer_restore_pos +}; + +enum rx_fastmap_return +{ + rx_fastmap_continuation, + rx_fastmap_error, + rx_fastmap_ok, + rx_fastmap_fail +}; + +enum rx_fastmap_entry +{ + rx_fastmap_start, + rx_fastmap_string_break +}; + +enum rx_test_return +{ + rx_test_continuation, + rx_test_error, + rx_test_fail, + rx_test_ok +}; + +enum rx_test_internal_return +{ + rx_test_internal_error, + rx_test_found_first, + rx_test_line_finished +}; + +enum rx_test_match_entry +{ + rx_test_start, + rx_test_cache_hit_loop, + rx_test_backreference_check, + rx_test_backtrack_return +}; + +struct rx_search_state +{ + /* Two groups of registers are kept. The group with the register state + * of the current test match, and the group that holds the state at the end + * of the best known match, if any. + * + * For some patterns, there may also be registers saved on the stack. + */ + unsigned num_regs; /* Includes an element for register zero. */ + regoff_t * lparen; /* scratch space for register returns */ + regoff_t * rparen; + regoff_t * best_lpspace; /* in case the user doesn't want these */ + regoff_t * best_rpspace; /* values, we still need space to store + * them. Normally, this memoryis unused + * and the space pointed to by REGS is + * used instead. + */ + + int last_l; /* Highest index of a valid lparen. */ + int last_r; /* It's dual. */ + + int * best_lparen; /* This contains the best known register */ + int * best_rparen; /* assignments. + * This may point to the same mem as + * best_lpspace, or it might point to memory + * passed by the caller. + */ + int best_last_l; /* best_last_l:best_lparen::last_l:lparen */ + int best_last_r; + + + unsigned char * translate; + + struct rx_string_position outer_pos; + + struct rx_superstate * start_super; + int nfa_choice; + int first_found; /* If true, return after finding any match. */ + int ret_val; + + /* For continuations... */ + enum rx_outer_entry outer_search_resume_pt; + struct re_pattern_buffer * saved_rxb; + int saved_startpos; + int saved_range; + int saved_stop; + int saved_total_size; + rx_get_burst_fn saved_get_burst; + rx_back_check_fn saved_back_check; + struct re_registers * saved_regs; + + /** + ** state for fastmap + **/ + char * fastmap; + int fastmap_chr; + int fastmap_val; + + /* for continuations in the fastmap procedure: */ + enum rx_fastmap_entry fastmap_resume_pt; + + /** + ** state for test_match + **/ + + /* The current superNFA position of the matcher. */ + struct rx_superstate * super; + + /* The matcher interprets a series of instruction frames. + * This is the `instruction counter' for the interpretation. + */ + struct rx_inx * ifr; + + /* We insert a ghost character in the string to prime + * the nfa. test_pos.pos, test_pos.str_half, and test_pos.end_half + * keep track of the test-match position and string-half. + */ + unsigned char c; + + /* Position within the string. */ + struct rx_string_position test_pos; + + struct rx_stack_chunk * counter_stack; + struct rx_stack_chunk * backtrack_stack; + int backtrack_frame_bytes; + int chunk_bytes; + struct rx_stack_chunk * free_chunks; + + /* To return from this function, set test_ret and + * `goto test_do_return'. + * + * Possible return values are: + * 1 --- end of string while the superNFA is still going + * 0 --- internal error (out of memory) + * -1 --- search completed by reaching the superNFA fail state + * -2 --- a match was found, maybe not the longest. + * + * When the search is complete (-1), best_last_r indicates whether + * a match was found. + * + * -2 is return only if search_state.first_found is non-zero. + * + * if search_state.first_found is non-zero, a return of -1 indicates no match, + * otherwise, best_last_r has to be checked. + */ + int test_ret; + + int could_have_continued; + +#ifdef RX_DEBUG + int backtrack_depth; + /* There is a search tree with every node as set of deterministic + * transitions in the super nfa. For every branch of a + * backtrack point is an edge in the tree. + * This counts up a pre-order of nodes in that tree. + * It's saved on the search stack and printed when debugging. + */ + int line_no; + int lines_found; +#endif + + + /* For continuations within the match tester */ + enum rx_test_match_entry test_match_resume_pt; + struct rx_inx * saved_next_tr_table; + struct rx_inx * saved_this_tr_table; + int saved_reg; + struct rx_backtrack_frame * saved_bf; + +}; + + +extern char rx_slowmap[]; +extern unsigned char rx_id_translation[]; + +static __inline__ void +init_fastmap (rxb, search_state) + struct re_pattern_buffer * rxb; + struct rx_search_state * search_state; +{ + search_state->fastmap = (rxb->fastmap + ? (char *)rxb->fastmap + : (char *)rx_slowmap); + /* Update the fastmap now if not correct already. + * When the regexp was compiled, the fastmap was computed + * and stored in a bitset. This expands the bitset into a + * character array containing 1s and 0s. + */ + if ((search_state->fastmap == rxb->fastmap) && !rxb->fastmap_accurate) + rx_blow_up_fastmap (rxb); + search_state->fastmap_chr = -1; + search_state->fastmap_val = 0; + search_state->fastmap_resume_pt = rx_fastmap_start; +} + +static __inline__ void +uninit_fastmap (rxb, search_state) + struct re_pattern_buffer * rxb; + struct rx_search_state * search_state; +{ + /* Unset the fastmap sentinel */ + if (search_state->fastmap_chr >= 0) + search_state->fastmap[search_state->fastmap_chr] + = search_state->fastmap_val; +} + +static __inline__ int +fastmap_search (rxb, stop, get_burst, app_closure, search_state) + struct re_pattern_buffer * rxb; + int stop; + rx_get_burst_fn get_burst; + void * app_closure; + struct rx_search_state * search_state; +{ + enum rx_fastmap_entry pc; + + if (0) + { + return_continuation: + search_state->fastmap_resume_pt = pc; + return rx_fastmap_continuation; + } + + pc = search_state->fastmap_resume_pt; + + switch (pc) + { + default: + return rx_fastmap_error; + case rx_fastmap_start: + init_fastmap_sentinal: + /* For the sake of fast fastmapping, set a sentinal in the fastmap. + * This sentinal will trap the fastmap loop when it reaches the last + * valid character in a string half. + * + * This must be reset when the fastmap/search loop crosses a string + * boundry, and before returning to the caller. So sometimes, + * the fastmap loop is restarted with `continue', othertimes by + * `goto init_fastmap_sentinal'. + */ + if (search_state->outer_pos.size) + { + search_state->fastmap_chr = ((search_state->outer_pos.search_direction == 1) + ? *(search_state->outer_pos.end - 1) + : *search_state->outer_pos.string); + search_state->fastmap_val + = search_state->fastmap[search_state->fastmap_chr]; + search_state->fastmap[search_state->fastmap_chr] = 1; + } + else + { + search_state->fastmap_chr = -1; + search_state->fastmap_val = 0; + } + + if (search_state->outer_pos.pos >= search_state->outer_pos.end) + goto fastmap_hit_bound; + else + { + if (search_state->outer_pos.search_direction == 1) + { + if (search_state->fastmap_val) + { + for (;;) + { + while (!search_state->fastmap[*search_state->outer_pos.pos]) + ++search_state->outer_pos.pos; + return rx_fastmap_ok; + } + } + else + { + for (;;) + { + while (!search_state->fastmap[*search_state->outer_pos.pos]) + ++search_state->outer_pos.pos; + if (*search_state->outer_pos.pos != search_state->fastmap_chr) + return rx_fastmap_ok; + else + { + ++search_state->outer_pos.pos; + if (search_state->outer_pos.pos == search_state->outer_pos.end) + goto fastmap_hit_bound; + } + } + } + } + else + { + __const__ unsigned char * bound; + bound = search_state->outer_pos.string - 1; + if (search_state->fastmap_val) + { + for (;;) + { + while (!search_state->fastmap[*search_state->outer_pos.pos]) + --search_state->outer_pos.pos; + return rx_fastmap_ok; + } + } + else + { + for (;;) + { + while (!search_state->fastmap[*search_state->outer_pos.pos]) + --search_state->outer_pos.pos; + if ((*search_state->outer_pos.pos != search_state->fastmap_chr) || search_state->fastmap_val) + return rx_fastmap_ok; + else + { + --search_state->outer_pos.pos; + if (search_state->outer_pos.pos == bound) + goto fastmap_hit_bound; + } + } + } + } + } + + case rx_fastmap_string_break: + fastmap_hit_bound: + { + /* If we hit a bound, it may be time to fetch another burst + * of string, or it may be time to return a continuation to + * the caller, or it might be time to fail. + */ + + int burst_state; + burst_state = get_burst (&search_state->outer_pos, app_closure, stop); + switch (burst_state) + { + default: + case rx_get_burst_error: + return rx_fastmap_error; + case rx_get_burst_continuation: + { + pc = rx_fastmap_string_break; + goto return_continuation; + } + case rx_get_burst_ok: + goto init_fastmap_sentinal; + case rx_get_burst_no_more: + /* ...not a string split, simply no more string. + * + * When searching backward, running out of string + * is reason to quit. + * + * When searching forward, we allow the possibility + * of an (empty) match after the last character in the + * virtual string. So, fall through to the matcher + */ + return ( (search_state->outer_pos.search_direction == 1) + ? rx_fastmap_ok + : rx_fastmap_fail); + } + } + } + +} + + + +#ifdef emacs +/* The `emacs' switch turns on certain matching commands + * that make sense only in Emacs. + */ +#include "config.h" +#include "lisp.h" +#include "buffer.h" +#include "syntax.h" +#endif /* emacs */ + +/* Setting RX_MEMDBUG is useful if you have dbmalloc. Maybe with similar + * packages too. + */ +#ifdef RX_MEMDBUG +#include +#endif /* RX_RX_MEMDBUG */ + +/* We used to test for `BSTRING' here, but only GCC and Emacs define + * `BSTRING', as far as I know, and neither of them use this code. + */ +#if HAVE_STRING_H || STDC_HEADERS +#include + +#ifndef bcmp +#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) +#endif + +#ifndef bcopy +#define bcopy(s, d, n) memcpy ((d), (s), (n)) +#endif + +#ifndef bzero +#define bzero(s, n) memset ((s), 0, (n)) +#endif + +#else /* HAVE_STRING_H || STDC_HEADERS */ +#include +#endif /* not (HAVE_STRING_H || STDC_HEADERS) */ + +#ifdef STDC_HEADERS +#include +#else /* not STDC_HEADERS */ +char *malloc (); +char *realloc (); +#endif /* not STDC_HEADERS */ + + + + +/* How many characters in the character set. */ +#define CHAR_SET_SIZE (1 << CHARBITS) + +#ifndef emacs +/* Define the syntax basics for \<, \>, etc. + * This must be nonzero for the wordchar and notwordchar pattern + * commands in re_match_2. + */ +#ifndef Sword +#define Sword 1 +#endif +#define SYNTAX(c) re_syntax_table[c] +RX_DECL char re_syntax_table[CHAR_SET_SIZE]; +#endif /* not emacs */ + + +/* Test if at very beginning or at very end of the virtual concatenation + * of `string1' and `string2'. If only one string, it's `string2'. + */ + +#define AT_STRINGS_BEG() \ + ( -1 \ + == ((search_state.test_pos.pos - search_state.test_pos.string) \ + + search_state.test_pos.offset)) + +#define AT_STRINGS_END() \ + ( (total_size - 1) \ + == ((search_state.test_pos.pos - search_state.test_pos.string) \ + + search_state.test_pos.offset)) + + +/* Test if POS + 1 points to a character which is word-constituent. We have + * two special cases to check for: if past the end of string1, look at + * the first character in string2; and if before the beginning of + * string2, look at the last character in string1. + * + * Assumes `string1' exists, so use in conjunction with AT_STRINGS_BEG (). + */ +#define LETTER_P(POS,OFF) \ + ( SYNTAX (fetch_char(POS, OFF, app_closure, stop)) \ + == Sword) + +/* Test if the character at D and the one after D differ with respect + * to being word-constituent. + */ +#define AT_WORD_BOUNDARY(d) \ + (AT_STRINGS_BEG () || AT_STRINGS_END () || LETTER_P (d,0) != LETTER_P (d, 1)) + + +#ifdef RX_SUPPORT_CONTINUATIONS +#define RX_STACK_ALLOC(BYTES) malloc(BYTES) +#define RX_STACK_FREE(MEM) free(MEM) +#else +#define RX_STACK_ALLOC(BYTES) alloca(BYTES) +#define RX_STACK_FREE(MEM) \ + ((struct rx_stack_chunk *)MEM)->next_chunk = search_state.free_chunks; \ + search_state.free_chunks = ((struct rx_stack_chunk *)MEM); + +#endif + +#define PUSH(CHUNK_VAR,BYTES) \ + if (!CHUNK_VAR || (CHUNK_VAR->bytes_left < (BYTES))) \ + { \ + struct rx_stack_chunk * new_chunk; \ + if (search_state.free_chunks) \ + { \ + new_chunk = search_state.free_chunks; \ + search_state.free_chunks = search_state.free_chunks->next_chunk; \ + } \ + else \ + { \ + new_chunk = (struct rx_stack_chunk *)RX_STACK_ALLOC(search_state.chunk_bytes); \ + if (!new_chunk) \ + { \ + search_state.ret_val = 0; \ + goto test_do_return; \ + } \ + } \ + new_chunk->sp = (char *)new_chunk + sizeof (struct rx_stack_chunk); \ + new_chunk->bytes_left = (search_state.chunk_bytes \ + - (BYTES) \ + - sizeof (struct rx_stack_chunk)); \ + new_chunk->next_chunk = CHUNK_VAR; \ + CHUNK_VAR = new_chunk; \ + } \ + else \ + (CHUNK_VAR->sp += (BYTES)), (CHUNK_VAR->bytes_left -= (BYTES)) + +#define POP(CHUNK_VAR,BYTES) \ + if (CHUNK_VAR->sp == ((char *)CHUNK_VAR + sizeof(*CHUNK_VAR))) \ + { \ + struct rx_stack_chunk * new_chunk = CHUNK_VAR->next_chunk; \ + RX_STACK_FREE(CHUNK_VAR); \ + CHUNK_VAR = new_chunk; \ + } \ + else \ + (CHUNK_VAR->sp -= BYTES), (CHUNK_VAR->bytes_left += BYTES) + + + +#define SRCH_TRANSLATE(C) search_state.translate[(unsigned char) (C)] + + + + +#ifdef __STDC__ +RX_DECL __inline__ int +rx_search (struct re_pattern_buffer * rxb, + int startpos, + int range, + int stop, + int total_size, + rx_get_burst_fn get_burst, + rx_back_check_fn back_check, + rx_fetch_char_fn fetch_char, + void * app_closure, + struct re_registers * regs, + struct rx_search_state * resume_state, + struct rx_search_state * save_state) +#else +RX_DECL __inline__ int +rx_search (rxb, startpos, range, stop, total_size, + get_burst, back_check, fetch_char, + app_closure, regs, resume_state, save_state) + struct re_pattern_buffer * rxb; + int startpos; + int range; + int stop; + int total_size; + rx_get_burst_fn get_burst; + rx_back_check_fn back_check; + rx_fetch_char_fn fetch_char; + void * app_closure; + struct re_registers * regs; + struct rx_search_state * resume_state; + struct rx_search_state * save_state; +#endif +{ + int pc; + int test_state; + struct rx_search_state search_state; + + search_state.free_chunks = 0; + if (!resume_state) + pc = rx_outer_start; + else + { + search_state = *resume_state; + regs = search_state.saved_regs; + rxb = search_state.saved_rxb; + startpos = search_state.saved_startpos; + range = search_state.saved_range; + stop = search_state.saved_stop; + total_size = search_state.saved_total_size; + get_burst = search_state.saved_get_burst; + back_check = search_state.saved_back_check; + pc = search_state.outer_search_resume_pt; + if (0) + { + return_continuation: + if (save_state) + { + *save_state = search_state; + save_state->saved_regs = regs; + save_state->saved_rxb = rxb; + save_state->saved_startpos = startpos; + save_state->saved_range = range; + save_state->saved_stop = stop; + save_state->saved_total_size = total_size; + save_state->saved_get_burst = get_burst; + save_state->saved_back_check = back_check; + save_state->outer_search_resume_pt = pc; + } + return rx_search_continuation; + } + } + + switch (pc) + { + case rx_outer_start: + search_state.ret_val = rx_search_fail; + ( search_state.lparen + = search_state.rparen + = search_state.best_lpspace + = search_state.best_rpspace + = 0); + + /* figure the number of registers we may need for use in backreferences. + * the number here includes an element for register zero. + */ + search_state.num_regs = rxb->re_nsub + 1; + + + /* check for out-of-range startpos. */ + if ((startpos < 0) || (startpos > total_size)) + return rx_search_fail; + + /* fix up range if it might eventually take us outside the string. */ + { + int endpos; + endpos = startpos + range; + if (endpos < -1) + range = (-1 - startpos); + else if (endpos > (total_size + 1)) + range = total_size - startpos; + } + + /* if the search isn't to be a backwards one, don't waste time in a + * long search for a pattern that says it is anchored. + */ + if (rxb->begbuf_only && (range > 0)) + { + if (startpos > 0) + return rx_search_fail; + else + range = 1; + } + + /* decide whether to use internal or user-provided reg buffers. */ + if (!regs || rxb->no_sub) + { + search_state.best_lpspace = + (regoff_t *)REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t)); + search_state.best_rpspace = + (regoff_t *)REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t)); + search_state.best_lparen = search_state.best_lpspace; + search_state.best_rparen = search_state.best_rpspace; + } + else + { + /* have the register data arrays been allocated? */ + if (rxb->regs_allocated == REGS_UNALLOCATED) + { /* no. so allocate them with malloc. we need one + extra element beyond `search_state.num_regs' for the `-1' marker + gnu code uses. */ + regs->num_regs = MAX (RE_NREGS, rxb->re_nsub + 1); + regs->start = ((regoff_t *) + malloc (regs->num_regs * sizeof ( regoff_t))); + regs->end = ((regoff_t *) + malloc (regs->num_regs * sizeof ( regoff_t))); + if (regs->start == 0 || regs->end == 0) + return rx_search_error; + rxb->regs_allocated = REGS_REALLOCATE; + } + else if (rxb->regs_allocated == REGS_REALLOCATE) + { /* yes. if we need more elements than were already + allocated, reallocate them. if we need fewer, just + leave it alone. */ + if (regs->num_regs < search_state.num_regs + 1) + { + regs->num_regs = search_state.num_regs + 1; + regs->start = ((regoff_t *) + realloc (regs->start, + regs->num_regs * sizeof (regoff_t))); + regs->end = ((regoff_t *) + realloc (regs->end, + regs->num_regs * sizeof ( regoff_t))); + if (regs->start == 0 || regs->end == 0) + return rx_search_error; + } + } + else if (rxb->regs_allocated != REGS_FIXED) + return rx_search_error; + + if (regs->num_regs < search_state.num_regs + 1) + { + search_state.best_lpspace = + ((regoff_t *) + REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t))); + search_state.best_rpspace = + ((regoff_t *) + REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t))); + search_state.best_lparen = search_state.best_lpspace; + search_state.best_rparen = search_state.best_rpspace; + } + else + { + search_state.best_lparen = regs->start; + search_state.best_rparen = regs->end; + } + } + + search_state.lparen = + (regoff_t *) REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t)); + search_state.rparen = + (regoff_t *) REGEX_ALLOCATE (search_state.num_regs * sizeof(regoff_t)); + + if (! ( search_state.best_rparen + && search_state.best_lparen + && search_state.lparen && search_state.rparen)) + return rx_search_error; + + search_state.best_last_l = search_state.best_last_r = -1; + + search_state.translate = (rxb->translate + ? rxb->translate + : rx_id_translation); + + + + /* + * two nfa's were compiled. + * `0' is complete. + * `1' faster but gets registers wrong and ends too soon. + */ + search_state.nfa_choice = (regs && !rxb->least_subs) ? '\0' : '\1'; + + /* we have the option to look for the best match or the first + * one we can find. if the user isn't asking for register information, + * we don't need to find the best match. + */ + search_state.first_found = !regs; + + if (range >= 0) + { + search_state.outer_pos.search_end = startpos + range; + search_state.outer_pos.search_direction = 1; + } + else + { + search_state.outer_pos.search_end = startpos + range; + search_state.outer_pos.search_direction = -1; + } + + /* the vacuous search always turns up nothing. */ + if ((search_state.outer_pos.search_direction == 1) + ? (startpos > search_state.outer_pos.search_end) + : (startpos < search_state.outer_pos.search_end)) + return rx_search_fail; + + /* now we build the starting state of the supernfa. */ + { + struct rx_superset * start_contents; + struct rx_nfa_state_set * start_nfa_set; + + /* we presume here that the nfa start state has only one + * possible future with no side effects. + */ + start_nfa_set = rxb->start->futures->destset; + if ( rxb->rx.start_set + && (rxb->rx.start_set->starts_for == &rxb->rx)) + start_contents = rxb->rx.start_set; + else + { + start_contents = + rx_superstate_eclosure_union (&rxb->rx, + rx_superset_cons (&rxb->rx, 0, 0), + start_nfa_set); + + if (!start_contents) + return rx_search_fail; + + start_contents->starts_for = &rxb->rx; + rxb->rx.start_set = start_contents; + } + if ( start_contents->superstate + && (start_contents->superstate->rx_id == rxb->rx.rx_id)) + { + search_state.start_super = start_contents->superstate; + rx_lock_superstate (&rxb->rx, search_state.start_super); + } + else + { + rx_protect_superset (&rxb->rx, start_contents); + + search_state.start_super = rx_superstate (&rxb->rx, start_contents); + if (!search_state.start_super) + return rx_search_fail; + rx_lock_superstate (&rxb->rx, search_state.start_super); + rx_release_superset (&rxb->rx, start_contents); + } + } + + + /* The outer_pos tracks the position within the strings + * as seen by loop that calls fastmap_search. + * + * The caller supplied get_burst function actually + * gives us pointers to chars. + * + * Communication with the get_burst function is through an + * rx_string_position structure. Here, the structure for + * outer_pos is initialized. It is set to point to the + * NULL string, at an offset of STARTPOS. STARTPOS is out + * of range of the NULL string, so the first call to + * getburst will patch up the rx_string_position to point + * to valid characters. + */ + + ( search_state.outer_pos.string + = search_state.outer_pos.end + = 0); + + search_state.outer_pos.offset = 0; + search_state.outer_pos.size = 0; + search_state.outer_pos.pos = (unsigned char *)startpos; + init_fastmap (rxb, &search_state); + + search_state.fastmap_resume_pt = rx_fastmap_start; + case rx_outer_fastmap: + /* do { */ + pseudo_do: + { + { + int fastmap_state; + fastmap_state = fastmap_search (rxb, stop, get_burst, app_closure, + &search_state); + switch (fastmap_state) + { + case rx_fastmap_continuation: + pc = rx_outer_fastmap; + goto return_continuation; + case rx_fastmap_fail: + goto finish; + case rx_fastmap_ok: + break; + } + } + + /* now the fastmap loop has brought us to a plausible + * starting point for a match. so, it's time to run the + * nfa and see if a match occured. + */ + startpos = ( search_state.outer_pos.pos + - search_state.outer_pos.string + + search_state.outer_pos.offset); +#if 0 +/*|*/ if ((range > 0) && (startpos == search_state.outer_pos.search_end)) +/*|*/ goto finish; +#endif + } + + search_state.test_match_resume_pt = rx_test_start; + /* do interrupted for entry point... */ + case rx_outer_test: + /* ...do continued */ + { + goto test_match; + test_returns_to_search: + switch (test_state) + { + case rx_test_continuation: + pc = rx_outer_test; + goto return_continuation; + case rx_test_error: + search_state.ret_val = rx_search_error; + goto finish; + case rx_test_fail: + break; + case rx_test_ok: + goto finish; + } + search_state.outer_pos.pos += search_state.outer_pos.search_direction; + startpos += search_state.outer_pos.search_direction; +#if 0 +/*|*/ if (search_state.test_pos.pos < search_state.test_pos.end) +/*|*/ break; +#endif + } + /* do interrupted for entry point... */ + case rx_outer_restore_pos: + { + int x; + x = get_burst (&search_state.outer_pos, app_closure, stop); + switch (x) + { + case rx_get_burst_continuation: + pc = rx_outer_restore_pos; + goto return_continuation; + case rx_get_burst_error: + search_state.ret_val = rx_search_error; + goto finish; + case rx_get_burst_no_more: + if (rxb->can_match_empty) + break; + goto finish; + case rx_get_burst_ok: + break; + } + } /* } while (...see below...) */ + + if ((search_state.outer_pos.search_direction == 1) + ? (startpos <= search_state.outer_pos.search_end) + : (startpos > search_state.outer_pos.search_end)) + goto pseudo_do; + + + finish: + uninit_fastmap (rxb, &search_state); + if (search_state.start_super) + rx_unlock_superstate (&rxb->rx, search_state.start_super); + +#ifdef regex_malloc + if (search_state.lparen) free (search_state.lparen); + if (search_state.rparen) free (search_state.rparen); + if (search_state.best_lpspace) free (search_state.best_lpspace); + if (search_state.best_rpspace) free (search_state.best_rpspace); +#endif + return search_state.ret_val; + } + + + test_match: + { + enum rx_test_match_entry test_pc; + int inx; + test_pc = search_state.test_match_resume_pt; + if (test_pc == rx_test_start) + { +#ifdef RX_DEBUG + search_state.backtrack_depth = 0; +#endif + search_state.last_l = search_state.last_r = 0; + search_state.lparen[0] = startpos; + search_state.super = search_state.start_super; + search_state.c = search_state.nfa_choice; + search_state.test_pos.pos = search_state.outer_pos.pos - 1; + search_state.test_pos.string = search_state.outer_pos.string; + search_state.test_pos.end = search_state.outer_pos.end; + search_state.test_pos.offset = search_state.outer_pos.offset; + search_state.test_pos.size = search_state.outer_pos.size; + search_state.test_pos.search_direction = 1; + search_state.counter_stack = 0; + search_state.backtrack_stack = 0; + search_state.backtrack_frame_bytes = + (sizeof (struct rx_backtrack_frame) + + (rxb->match_regs_on_stack + ? sizeof (regoff_t) * (search_state.num_regs + 1) * 2 + : 0)); + search_state.chunk_bytes = search_state.backtrack_frame_bytes * 64; + search_state.test_ret = rx_test_line_finished; + search_state.could_have_continued = 0; + } + /* This is while (1)...except that the body of the loop is interrupted + * by some alternative entry points. + */ + pseudo_while_1: + switch (test_pc) + { + case rx_test_cache_hit_loop: + goto resume_continuation_1; + case rx_test_backreference_check: + goto resume_continuation_2; + case rx_test_backtrack_return: + goto resume_continuation_3; + case rx_test_start: +#ifdef RX_DEBUG + /* There is a search tree with every node as set of deterministic + * transitions in the super nfa. For every branch of a + * backtrack point is an edge in the tree. + * This counts up a pre-order of nodes in that tree. + * It's saved on the search stack and printed when debugging. + */ + search_state.line_no = 0; + search_state.lines_found = 0; +#endif + + top_of_cycle: + /* A superstate is basicly a transition table, indexed by + * characters from the string being tested, and containing + * RX_INX (`instruction frame') structures. + */ + search_state.ifr = &search_state.super->transitions [search_state.c]; + + recurse_test_match: + /* This is the point to which control is sent when the + * test matcher `recurses'. Before jumping here, some variables + * need to be saved on the stack and the next instruction frame + * has to be computed. + */ + + restart: + /* Some instructions don't advance the matcher, but just + * carry out some side effects and fetch a new instruction. + * To dispatch that new instruction, `goto restart'. + */ + + { + struct rx_inx * next_tr_table; + struct rx_inx * this_tr_table; + /* The fastest route through the loop is when the instruction + * is RX_NEXT_CHAR. This case is detected when SEARCH_STATE.IFR->DATA + * is non-zero. In that case, it points to the next + * superstate. + * + * This allows us to not bother fetching the bytecode. + */ + next_tr_table = (struct rx_inx *)search_state.ifr->data; + this_tr_table = search_state.super->transitions; + while (next_tr_table) + { +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + { + struct rx_superset * setp; + + fprintf (stderr, "%d %d>> re_next_char @ %d (%d)", + search_state.line_no, + search_state.backtrack_depth, + (search_state.test_pos.pos - search_state.test_pos.string + + search_state.test_pos.offset), search_state.c); + + search_state.super = + ((struct rx_superstate *) + ((char *)this_tr_table + - ((unsigned long) + ((struct rx_superstate *)0)->transitions))); + + setp = search_state.super->contents; + fprintf (stderr, " superstet (rx=%d, &=%x: ", + rxb->rx.rx_id, setp); + while (setp) + { + fprintf (stderr, "%d ", setp->id); + setp = setp->cdr; + } + fprintf (stderr, "\n"); + } +#endif + this_tr_table = next_tr_table; + ++search_state.test_pos.pos; + if (search_state.test_pos.pos == search_state.test_pos.end) + { + int burst_state; + try_burst_1: + burst_state = get_burst (&search_state.test_pos, + app_closure, stop); + switch (burst_state) + { + case rx_get_burst_continuation: + search_state.saved_this_tr_table = this_tr_table; + search_state.saved_next_tr_table = next_tr_table; + test_pc = rx_test_cache_hit_loop; + goto test_return_continuation; + + resume_continuation_1: + /* Continuation one jumps here to do its work: */ + search_state.saved_this_tr_table = this_tr_table; + search_state.saved_next_tr_table = next_tr_table; + goto try_burst_1; + + case rx_get_burst_ok: + /* get_burst succeeded...keep going */ + break; + + case rx_get_burst_no_more: + search_state.test_ret = rx_test_line_finished; + search_state.could_have_continued = 1; + goto test_do_return; + + case rx_get_burst_error: + /* An error... */ + search_state.test_ret = rx_test_internal_error; + goto test_do_return; + } + } + search_state.c = *search_state.test_pos.pos; + search_state.ifr = this_tr_table + search_state.c; + next_tr_table = (struct rx_inx *)search_state.ifr->data; + } /* Fast loop through cached transition tables */ + + /* Here when we ran out of cached next-char transitions. + * So, it will be necessary to do a more expensive + * dispatch on the current instruction. The superstate + * pointer is allowed to become invalid during next-char + * transitions -- now we must bring it up to date. + */ + search_state.super = + ((struct rx_superstate *) + ((char *)this_tr_table + - ((unsigned long) + ((struct rx_superstate *)0)->transitions))); + } + + /* We've encountered an instruction other than next-char. + * Dispatch that instruction: + */ + inx = (int)search_state.ifr->inx; +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + { + struct rx_superset * setp = search_state.super->contents; + + fprintf (stderr, "%d %d>> %s @ %d (%d)", search_state.line_no, + search_state.backtrack_depth, + inx_names[inx], + (search_state.test_pos.pos - search_state.test_pos.string + + (test_pos.half == 0 ? 0 : size1)), search_state.c); + + fprintf (stderr, " superstet (rx=%d, &=%x: ", + rxb->rx.rx_id, setp); + while (setp) + { + fprintf (stderr, "%d ", setp->id); + setp = setp->cdr; + } + fprintf (stderr, "\n"); + } +#endif + switch ((enum rx_opcode)inx) + { + case rx_do_side_effects: + + /* RX_DO_SIDE_EFFECTS occurs when we cross epsilon + * edges associated with parentheses, backreferencing, etc. + */ + { + struct rx_distinct_future * df = + (struct rx_distinct_future *)search_state.ifr->data_2; + struct rx_se_list * el = df->effects; + /* Side effects come in lists. This walks down + * a list, dispatching. + */ + while (el) + { + long effect; + effect = (long)el->car; + if (effect < 0) + { +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + { + struct rx_superset * setp = search_state.super->contents; + + fprintf (stderr, "....%d %d>> %s\n", search_state.line_no, + search_state.backtrack_depth, + efnames[-effect]); + } +#endif + switch ((enum re_side_effects) effect) + + { + case re_se_pushback: + search_state.ifr = &df->future_frame; + if (!search_state.ifr->data) + { + struct rx_superstate * sup; + sup = search_state.super; + rx_lock_superstate (rx, sup); + if (!rx_handle_cache_miss (&rxb->rx, + search_state.super, + search_state.c, + (search_state.ifr + ->data_2))) + { + rx_unlock_superstate (rx, sup); + search_state.test_ret = rx_test_internal_error; + goto test_do_return; + } + rx_unlock_superstate (rx, sup); + } + /* --search_state.test_pos.pos; */ + search_state.c = 't'; + search_state.super + = ((struct rx_superstate *) + ((char *)search_state.ifr->data + - (long)(((struct rx_superstate *)0) + ->transitions))); + goto top_of_cycle; + break; + case re_se_push0: + { + struct rx_counter_frame * old_cf + = (search_state.counter_stack + ? ((struct rx_counter_frame *) + search_state.counter_stack->sp) + : 0); + struct rx_counter_frame * cf; + PUSH (search_state.counter_stack, + sizeof (struct rx_counter_frame)); + cf = ((struct rx_counter_frame *) + search_state.counter_stack->sp); + cf->tag = re_se_iter; + cf->val = 0; + cf->inherited_from = 0; + cf->cdr = old_cf; + break; + } + case re_se_fail: + goto test_do_return; + case re_se_begbuf: + if (!AT_STRINGS_BEG ()) + goto test_do_return; + break; + case re_se_endbuf: + if (!AT_STRINGS_END ()) + goto test_do_return; + break; + case re_se_wordbeg: + if ( LETTER_P (&search_state.test_pos, 1) + && ( AT_STRINGS_BEG() + || !LETTER_P (&search_state.test_pos, 0))) + break; + else + goto test_do_return; + case re_se_wordend: + if ( !AT_STRINGS_BEG () + && LETTER_P (&search_state.test_pos, 0) + && (AT_STRINGS_END () + || !LETTER_P (&search_state.test_pos, 1))) + break; + else + goto test_do_return; + case re_se_wordbound: + if (AT_WORD_BOUNDARY (&search_state.test_pos)) + break; + else + goto test_do_return; + case re_se_notwordbound: + if (!AT_WORD_BOUNDARY (&search_state.test_pos)) + break; + else + goto test_do_return; + case re_se_hat: + if (AT_STRINGS_BEG ()) + { + if (rxb->not_bol) + goto test_do_return; + else + break; + } + else + { + char pos_c = *search_state.test_pos.pos; + if ( (SRCH_TRANSLATE (pos_c) + == SRCH_TRANSLATE('\n')) + && rxb->newline_anchor) + break; + else + goto test_do_return; + } + case re_se_dollar: + if (AT_STRINGS_END ()) + { + if (rxb->not_eol) + goto test_do_return; + else + break; + } + else + { + if ( ( SRCH_TRANSLATE (fetch_char + (&search_state.test_pos, 1, + app_closure, stop)) + == SRCH_TRANSLATE ('\n')) + && rxb->newline_anchor) + break; + else + goto test_do_return; + } + + case re_se_try: + /* This is the first side effect in every + * expression. + * + * FOR NO GOOD REASON...get rid of it... + */ + break; + + case re_se_pushpos: + { + int urhere = + ((int)(search_state.test_pos.pos + - search_state.test_pos.string) + + search_state.test_pos.offset); + struct rx_counter_frame * old_cf + = (search_state.counter_stack + ? ((struct rx_counter_frame *) + search_state.counter_stack->sp) + : 0); + struct rx_counter_frame * cf; + PUSH(search_state.counter_stack, + sizeof (struct rx_counter_frame)); + cf = ((struct rx_counter_frame *) + search_state.counter_stack->sp); + cf->tag = re_se_pushpos; + cf->val = urhere; + cf->inherited_from = 0; + cf->cdr = old_cf; + break; + } + + case re_se_chkpos: + { + int urhere = + ((int)(search_state.test_pos.pos + - search_state.test_pos.string) + + search_state.test_pos.offset); + struct rx_counter_frame * cf + = ((struct rx_counter_frame *) + search_state.counter_stack->sp); + if (cf->val == urhere) + goto test_do_return; + cf->val = urhere; + break; + } + break; + + case re_se_poppos: + POP(search_state.counter_stack, + sizeof (struct rx_counter_frame)); + break; + + + case re_se_at_dot: + case re_se_syntax: + case re_se_not_syntax: +#ifdef emacs + /* + * this release lacks emacs support + */ +#endif + break; + case re_se_win: + case re_se_lparen: + case re_se_rparen: + case re_se_backref: + case re_se_iter: + case re_se_end_iter: + case re_se_tv: + case re_floogle_flap: + search_state.ret_val = 0; + goto test_do_return; + } + } + else + { +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + fprintf (stderr, "....%d %d>> %s %d %d\n", search_state.line_no, + search_state.backtrack_depth, + efnames2[rxb->se_params [effect].se], + rxb->se_params [effect].op1, + rxb->se_params [effect].op2); +#endif + switch (rxb->se_params [effect].se) + { + case re_se_win: + /* This side effect indicates that we've + * found a match, though not necessarily the + * best match. This is a fancy assignment to + * register 0 unless the caller didn't + * care about registers. In which case, + * this stops the match. + */ + { + int urhere = + ((int)(search_state.test_pos.pos + - search_state.test_pos.string) + + search_state.test_pos.offset); + + if ( (search_state.best_last_r < 0) + || (urhere + 1 > search_state.best_rparen[0])) + { + /* Record the best known and keep + * looking. + */ + int x; + for (x = 0; x <= search_state.last_l; ++x) + search_state.best_lparen[x] = search_state.lparen[x]; + search_state.best_last_l = search_state.last_l; + for (x = 0; x <= search_state.last_r; ++x) + search_state.best_rparen[x] = search_state.rparen[x]; + search_state.best_rparen[0] = urhere + 1; + search_state.best_last_r = search_state.last_r; + } + /* If we're not reporting the match-length + * or other register info, we need look no + * further. + */ + if (search_state.first_found) + { + search_state.test_ret = rx_test_found_first; + goto test_do_return; + } + } + break; + case re_se_lparen: + { + int urhere = + ((int)(search_state.test_pos.pos + - search_state.test_pos.string) + + search_state.test_pos.offset); + + int reg = rxb->se_params [effect].op1; +#if 0 + if (reg > search_state.last_l) +#endif + { + search_state.lparen[reg] = urhere + 1; + /* In addition to making this assignment, + * we now know that lower numbered regs + * that haven't already been assigned, + * won't be. We make sure they're + * filled with -1, so they can be + * recognized as unassigned. + */ + if (search_state.last_l < reg) + while (++search_state.last_l < reg) + search_state.lparen[search_state.last_l] = -1; + } + break; + } + + case re_se_rparen: + { + int urhere = + ((int)(search_state.test_pos.pos + - search_state.test_pos.string) + + search_state.test_pos.offset); + int reg = rxb->se_params [effect].op1; + search_state.rparen[reg] = urhere + 1; + if (search_state.last_r < reg) + { + while (++search_state.last_r < reg) + search_state.rparen[search_state.last_r] + = -1; + } + break; + } + + case re_se_backref: + { + int reg = rxb->se_params [effect].op1; + if ( reg > search_state.last_r + || search_state.rparen[reg] < 0) + goto test_do_return; + + { + int backref_status; + check_backreference: + backref_status + = back_check (&search_state.test_pos, + search_state.lparen[reg], + search_state.rparen[reg], + search_state.translate, + app_closure, + stop); + switch (backref_status) + { + case rx_back_check_continuation: + search_state.saved_reg = reg; + test_pc = rx_test_backreference_check; + goto test_return_continuation; + resume_continuation_2: + reg = search_state.saved_reg; + goto check_backreference; + case rx_back_check_fail: + /* Fail */ + goto test_do_return; + case rx_back_check_pass: + /* pass -- + * test_pos now advanced to last + * char matched by backref + */ + break; + } + } + break; + } + case re_se_iter: + { + struct rx_counter_frame * csp + = ((struct rx_counter_frame *) + search_state.counter_stack->sp); + if (csp->val == rxb->se_params[effect].op2) + goto test_do_return; + else + ++csp->val; + break; + } + case re_se_end_iter: + { + struct rx_counter_frame * csp + = ((struct rx_counter_frame *) + search_state.counter_stack->sp); + if (csp->val < rxb->se_params[effect].op1) + goto test_do_return; + else + { + struct rx_counter_frame * source = csp; + while (source->inherited_from) + source = source->inherited_from; + if (!source || !source->cdr) + { + POP(search_state.counter_stack, + sizeof(struct rx_counter_frame)); + } + else + { + source = source->cdr; + csp->val = source->val; + csp->tag = source->tag; + csp->cdr = 0; + csp->inherited_from = source; + } + } + break; + } + case re_se_tv: + /* is a noop */ + break; + case re_se_try: + case re_se_pushback: + case re_se_push0: + case re_se_pushpos: + case re_se_chkpos: + case re_se_poppos: + case re_se_at_dot: + case re_se_syntax: + case re_se_not_syntax: + case re_se_begbuf: + case re_se_hat: + case re_se_wordbeg: + case re_se_wordbound: + case re_se_notwordbound: + case re_se_wordend: + case re_se_endbuf: + case re_se_dollar: + case re_se_fail: + case re_floogle_flap: + search_state.ret_val = 0; + goto test_do_return; + } + } + el = el->cdr; + } + /* Now the side effects are done, + * so get the next instruction. + * and move on. + */ + search_state.ifr = &df->future_frame; + goto restart; + } + + case rx_backtrack_point: + { + /* A backtrack point indicates that we've reached a + * non-determinism in the superstate NFA. This is a + * loop that exhaustively searches the possibilities. + * + * A backtracking strategy is used. We keep track of what + * registers are valid so we can erase side effects. + * + * First, make sure there is some stack space to hold + * our state. + */ + + struct rx_backtrack_frame * bf; + + PUSH(search_state.backtrack_stack, + search_state.backtrack_frame_bytes); +#ifdef RX_DEBUG_0 + ++search_state.backtrack_depth; +#endif + + bf = ((struct rx_backtrack_frame *) + search_state.backtrack_stack->sp); + { + bf->stk_super = search_state.super; + /* We prevent the current superstate from being + * deleted from the superstate cache. + */ + rx_lock_superstate (&rxb->rx, search_state.super); +#ifdef RX_DEBUG_0 + bf->stk_search_state.line_no = search_state.line_no; +#endif + bf->stk_c = search_state.c; + bf->stk_test_pos = search_state.test_pos; + bf->stk_last_l = search_state.last_l; + bf->stk_last_r = search_state.last_r; + bf->df = ((struct rx_super_edge *) + search_state.ifr->data_2)->options; + bf->first_df = bf->df; + bf->counter_stack_sp = (search_state.counter_stack + ? search_state.counter_stack->sp + : 0); + bf->stk_test_ret = search_state.test_ret; + if (rxb->match_regs_on_stack) + { + int x; + regoff_t * stk = + (regoff_t *)((char *)bf + sizeof (*bf)); + for (x = 0; x <= search_state.last_l; ++x) + stk[x] = search_state.lparen[x]; + stk += x; + for (x = 0; x <= search_state.last_r; ++x) + stk[x] = search_state.rparen[x]; + } + } + + /* Here is a while loop whose body is mainly a function + * call and some code to handle a return from that + * function. + * + * From here on for the rest of `case backtrack_point' it + * is unsafe to assume that the search_state copies of + * variables saved on the backtracking stack are valid + * -- so read their values from the backtracking stack. + * + * This lets us use one generation fewer stack saves in + * the call-graph of a search. + */ + + while_non_det_options: +#ifdef RX_DEBUG_0 + ++search_state.lines_found; + if (rx_debug_trace) + fprintf (stderr, "@@@ %d calls %d @@@\n", + search_state.line_no, search_state.lines_found); + + search_state.line_no = search_state.lines_found; +#endif + + if (bf->df->next_same_super_edge[0] == bf->first_df) + { + /* This is a tail-call optimization -- we don't recurse + * for the last of the possible futures. + */ + search_state.ifr = (bf->df->effects + ? &bf->df->side_effects_frame + : &bf->df->future_frame); + + rx_unlock_superstate (&rxb->rx, search_state.super); + POP(search_state.backtrack_stack, + search_state.backtrack_frame_bytes); +#ifdef RX_DEBUG + --search_state.backtrack_depth; +#endif + goto restart; + } + else + { + if (search_state.counter_stack) + { + struct rx_counter_frame * old_cf + = ((struct rx_counter_frame *)search_state.counter_stack->sp); + struct rx_counter_frame * cf; + PUSH(search_state.counter_stack, sizeof (struct rx_counter_frame)); + cf = ((struct rx_counter_frame *)search_state.counter_stack->sp); + cf->tag = old_cf->tag; + cf->val = old_cf->val; + cf->inherited_from = old_cf; + cf->cdr = 0; + } + /* `Call' this test-match block */ + search_state.ifr = (bf->df->effects + ? &bf->df->side_effects_frame + : &bf->df->future_frame); + goto recurse_test_match; + } + + /* Returns in this block are accomplished by + * goto test_do_return. There are two cases. + * If there is some search-stack left, + * then it is a return from a `recursive' call. + * If there is no search-stack left, then + * we should return to the fastmap/search loop. + */ + + test_do_return: + + if (!search_state.backtrack_stack) + { +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + fprintf (stderr, "!!! %d bails returning %d !!!\n", + search_state.line_no, search_state.test_ret); +#endif + + /* No more search-stack -- this test is done. */ + if (search_state.test_ret != rx_test_internal_error) + goto return_from_test_match; + else + goto error_in_testing_match; + } + + /* Returning from a recursive call to + * the test match block: + */ + + bf = ((struct rx_backtrack_frame *) + search_state.backtrack_stack->sp); +#ifdef RX_DEBUG_0 + if (rx_debug_trace) + fprintf (stderr, "+++ %d returns %d (to %d)+++\n", + search_state.line_no, + search_state.test_ret, + bf->stk_search_state.line_no); +#endif + + while (search_state.counter_stack + && (!bf->counter_stack_sp + || (bf->counter_stack_sp + != search_state.counter_stack->sp))) + { + POP(search_state.counter_stack, + sizeof (struct rx_counter_frame)); + } + + if (search_state.test_ret == rx_test_internal_error) + { + POP (search_state.backtrack_stack, + search_state.backtrack_frame_bytes); + search_state.test_ret = rx_test_internal_error; + goto test_do_return; + } + + /* If a non-longest match was found and that is good + * enough, return immediately. + */ + if ( (search_state.test_ret == rx_test_found_first) + && search_state.first_found) + { + rx_unlock_superstate (&rxb->rx, bf->stk_super); + POP (search_state.backtrack_stack, + search_state.backtrack_frame_bytes); + goto test_do_return; + } + + search_state.test_ret = bf->stk_test_ret; + search_state.last_l = bf->stk_last_l; + search_state.last_r = bf->stk_last_r; + bf->df = bf->df->next_same_super_edge[0]; + search_state.super = bf->stk_super; + search_state.c = bf->stk_c; +#ifdef RX_DEBUG_0 + search_state.line_no = bf->stk_search_state.line_no; +#endif + + if (rxb->match_regs_on_stack) + { + int x; + regoff_t * stk = + (regoff_t *)((char *)bf + sizeof (*bf)); + for (x = 0; x <= search_state.last_l; ++x) + search_state.lparen[x] = stk[x]; + stk += x; + for (x = 0; x <= search_state.last_r; ++x) + search_state.rparen[x] = stk[x]; + } + + { + int x; + try_burst_2: + x = get_burst (&bf->stk_test_pos, app_closure, stop); + switch (x) + { + case rx_get_burst_continuation: + search_state.saved_bf = bf; + test_pc = rx_test_backtrack_return; + goto test_return_continuation; + resume_continuation_3: + bf = search_state.saved_bf; + goto try_burst_2; + case rx_get_burst_no_more: + /* Since we've been here before, it is some kind of + * error that we can't return. + */ + case rx_get_burst_error: + search_state.test_ret = rx_test_internal_error; + goto test_do_return; + case rx_get_burst_ok: + break; + } + } + search_state.test_pos = bf->stk_test_pos; + goto while_non_det_options; + } + + + case rx_cache_miss: + /* Because the superstate NFA is lazily constructed, + * and in fact may erode from underneath us, we sometimes + * have to construct the next instruction from the hard way. + * This invokes one step in the lazy-conversion. + */ + search_state.ifr = rx_handle_cache_miss (&rxb->rx, + search_state.super, + search_state.c, + search_state.ifr->data_2); + if (!search_state.ifr) + { + search_state.test_ret = rx_test_internal_error; + goto test_do_return; + } + goto restart; + + case rx_backtrack: + /* RX_BACKTRACK means that we've reached the empty + * superstate, indicating that match can't succeed + * from this point. + */ + goto test_do_return; + + case rx_next_char: + case rx_error_inx: + case rx_num_instructions: + search_state.ret_val = 0; + goto test_do_return; + } + goto pseudo_while_1; + } + + /* Healthy exits from the test-match loop do a + * `goto return_from_test_match' On the other hand, + * we might end up here. + */ + error_in_testing_match: + test_state = rx_test_error; + goto test_returns_to_search; + + /***** fastmap/search loop body + * considering the results testing for a match + */ + + return_from_test_match: + + if (search_state.best_last_l >= 0) + { + if (regs && (regs->start != search_state.best_lparen)) + { + bcopy (search_state.best_lparen, regs->start, + regs->num_regs * sizeof (int)); + bcopy (search_state.best_rparen, regs->end, + regs->num_regs * sizeof (int)); + } + if (regs && !rxb->no_sub) + { + int q; + int bound = (regs->num_regs > search_state.num_regs + ? regs->num_regs + : search_state.num_regs); + regoff_t * s = regs->start; + regoff_t * e = regs->end; + for (q = search_state.best_last_l + 1; q < bound; ++q) + s[q] = e[q] = -1; + } + search_state.ret_val = search_state.best_lparen[0]; + test_state = rx_test_ok; + goto test_returns_to_search; + } + else + { + test_state = rx_test_fail; + goto test_returns_to_search; + } + + test_return_continuation: + search_state.test_match_resume_pt = test_pc; + test_state = rx_test_continuation; + goto test_returns_to_search; + } +} + + + +#endif /* RX_WANT_RX_DEFS */ + + + +#else /* RX_WANT_SE_DEFS */ + /* Integers are used to represent side effects. + * + * Simple side effects are given negative integer names by these enums. + * + * Non-negative names are reserved for complex effects. + * + * Complex effects are those that take arguments. For example, + * a register assignment associated with a group is complex because + * it requires an argument to tell which group is being matched. + * + * The integer name of a complex effect is an index into rxb->se_params. + */ + + RX_DEF_SE(1, re_se_try, = -1) /* Epsilon from start state */ + + RX_DEF_SE(0, re_se_pushback, = re_se_try - 1) + RX_DEF_SE(0, re_se_push0, = re_se_pushback -1) + RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1) + RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1) + RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1) + + RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1) /* Emacs only */ + RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1) /* Emacs only */ + RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1) /* Emacs only */ + + RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1) /* match beginning of buffer */ + RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1) /* match beginning of line */ + + RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1) + RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1) + RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1) + + RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1) + RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1) + + /* This fails except at the end of a line. + * It deserves to go here since it is typicly one of the last steps + * in a match. + */ + RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1) + + /* Simple effects: */ + RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1) + + /* Complex effects. These are used in the 'se' field of + * a struct re_se_params. Indexes into the se array + * are stored as instructions on nfa edges. + */ + RX_DEF_CPLX_SE(1, re_se_win, = 0) + RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1) + RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1) + RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1) + RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1) + RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1) + RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1) + +#endif + +#endif diff --git a/gnu/lib/libg++/libstdc++/ChangeLog b/gnu/lib/libg++/libstdc++/ChangeLog new file mode 100644 index 00000000000..f99a36653d7 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/ChangeLog @@ -0,0 +1,529 @@ +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 (mrs@cygnus.com) + + * exception{,.cc}: Added to support catching bad_cast's. + +Thu Nov 3 17:42:13 1994 Mike Stump (mrs@cygnus.com) + + * 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/gnu/lib/libg++/libstdc++/Make.pack b/gnu/lib/libg++/libstdc++/Make.pack new file mode 100644 index 00000000000..0c1d275545f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/Make.pack @@ -0,0 +1,225 @@ +# Start of package fragment generated by /kalessin/giga/bothner/dist/devo/libstdc++/config.shared. + +MULTITOP = . +MULTIDIRS = +MULTISUBDIR = +MULTIDO = true +MULTICLEAN = true + +# TOPDIR=$${rootme}$(MULTITOP)/../ invsubdir= subdir= +srcdir = /kalessin/giga/bothner/dist/devo/libstdc++ +SUBDIRS = stl tests +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +datadir = $(prefix)/lib +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 +gxx_includedir = $(libdir)/g++-include +docdir = $(datadir)/doc + +SHELL = /bin/sh + +INSTALL = $(srcdir)/../install.sh -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) + +AR = `if [ -f $${rootme}$(MULTITOP)/../binutils/ar ] ; \ + then echo $${rootme}$(MULTITOP)/../binutils/ar ; \ + else echo ar ; fi` +AR_FLAGS = rc +RANLIB = `if [ -f $${rootme}$(MULTITOP)/../binutils/ranlib ] ; \ + then echo $${rootme}$(MULTITOP)/../binutils/ranlib ; \ + else echo ranlib ; fi` +NM = `if [ -f $${rootme}$(MULTITOP)/../binutils/nm.new ] ; \ + then echo $${rootme}$(MULTITOP)/../binutils/nm.new ; \ + else echo nm ; fi` +NLMCONV = `if [ -f $${rootme}$(MULTITOP)/../binutils/nlmconv ] ; \ + then echo $${rootme}$(MULTITOP)/../binutils/nlmconv ; \ + else echo nlmconv ; fi` +LD = `if [ -f $${rootme}$(MULTITOP)/../ld/ld.new ] ; \ + then echo $${rootme}$(MULTITOP)/../ld/ld.new ; \ + else echo ld ; fi` + +MAKEINFO = `if [ -f $${rootme}$(MULTITOP)/../texinfo/C/makeinfo ] ; \ + then echo $${rootme}$(MULTITOP)/../texinfo/C/makeinfo ; \ + else echo makeinfo ; fi` +TEXIDIR=${srcdir}/..//texinfo +TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi + +CC = cc +CXX = g++ -O + +WRAP_C_INCLUDES = +CFLAGS = -g +CXXFLAGS = -g -O3 +LIBCFLAGS = $(CFLAGS) +LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates +PICFLAG = +PICDIR = stamp-picdir +all: $(PICDIR) libs multi-all + @rootme=`pwd`/; export rootme; \ + $(MAKE) "DODIRS=$(SUBDIRS)" DO=all $(FLAGS_TO_PASS) subdir_do +.PHONY: all + +.PHONY: multi-all +multi-all: + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all + + +.PHONY: subdir_do +subdir_do: force + @rootme=`pwd`/; export rootme; \ + for i in $(DODIRS); do \ + if [ -f ./$$i/Makefile ] ; then \ + echo "cd $$i; make $(DO) ..." ; \ + (cd $$i ; $(MAKE) $(FLAGS_TO_PASS) $(DO)) || exit 1 ; \ + else true ; fi ; \ + done + +# List of variables to pass to sub-makes. This should not be needed +# by GNU make or Sun make (both of which pass command-line variable +# overrides thouh $(MAKE)) but may be needed by older versions. + +FLAGS_TO_PASS= \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "prefix=$(prefix)" \ + "exec_prefix=$(exec_prefix)" \ + "tooldir=$(tooldir)" \ + "AR=$(AR)" \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC=$(CC)" \ + "CXX=$(CXX)" \ + "CFLAGS=$(CFLAGS)" \ + "CXXFLAGS=$(CXXFLAGS)" \ + "RANLIB=$(RANLIB)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCXXFLAGS=$(LIBCXXFLAGS)" \ + "LOADLIBES=$(LOADLIBES)" \ + "LDFLAGS=$(LDFLAGS)" \ + "MAKEINFO=$(MAKEINFO)" \ + "PICFLAG=$(PICFLAG)" +NOSTDINC = -nostdinc++ +CXXINCLUDES = -I/kalessin/giga/bothner/dist/devo/libstdc++ -I$(MULTITOP)/../libio -I/kalessin/giga/bothner/dist/devo/libstdc++/../libio $(NOSTDINC) +XCFLAGS = $(LIBCFLAGS) +XCXXFLAGS = $(LIBCXXFLAGS) +.SUFFIXES: .o .C .cc .c +COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES) +.c.o: + [ -z "$(PICFLAG)" ] ||\ + $(COMPILE.c) $(PICFLAG) $< -o pic/$@ + $(COMPILE.c) $< +COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES) +.C.o: + [ -z "$(PICFLAG)" ] ||\ + $(COMPILE.cc) $(PICFLAG) $< -o pic/$@ + $(COMPILE.cc) $< +.cc.o: + [ -z "$(PICFLAG)" ] || \ + $(COMPILE.cc) $(PICFLAG) $< -o pic/$@ + $(COMPILE.cc) $< + + +stamp-picdir: + if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \ + mkdir pic; \ + else true; fi + touch stamp-picdir + +.PHONY: install +install: +.PHONY: check +check: $(PICDIR) libs + rootme=`pwd`/; export rootme; \ + SAVE_LLPATH="$${SAVE_LLPATH-$$LD_LIBRARY_PATH}"; export SAVE_LLPATH; \ + LD_LIBRARY_PATH="$${rootme}${TOLIBGXX}../libstdc++:$${rootme}${TOLIBGXX}../libg++:$$SAVE_LLPATH"; \ + export LD_LIBRARY_PATH; \ + $(MAKE) "DODIRS=$(SUBDIRS)" DO=check $(FLAGS_TO_PASS) subdir_do +.PHONY: info dvi install-info clean-info +info: +dvi: +install-info: +.PHONY: do-clean-info clean-info do-clean-dvi clean-dvi +do-clean-info: +do-clean-dvi: +clean-info: do-clean-info +clean-dvi: do-clean-dvi + +.PHONY: boltcc +boltcc: + rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS) + + +# clean rules +.PHONY: mostlyclean clean distclean maintainer-clean realclean +.PHONY: do-clean subdir_distclean subdir_maintainer_clean +mostlyclean: do-clean-dvi + rm -rf *.o pic stamp-picdir core so_locations $(MOSTLYCLEAN_JUNK) + @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=mostlyclean subdir_do + @$(MULTICLEAN) multi-clean DO=mostlyclean +do-clean: do-clean-dvi + rm -rf *.o pic stamp-picdir core so_locations $(MOSTLYCLEAN_JUNK) $(CLEAN_JUNK) +clean: do-clean + @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=clean subdir_do + @$(MULTICLEAN) multi-clean DO=clean +subdir_distclean: + @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=distclean subdir_do +distclean: do-clean subdir_distclean + @$(MULTICLEAN) multi-clean DO=distclean + rm -rf config.status Makefile target-mkfrag +subdir_maintainer_clean: + @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=maintainer-clean subdir_do +maintainer-clean realclean: do-clean subdir_maintainer_clean do-clean-info + @$(MULTICLEAN) multi-clean DO=maintainer-clean + rm -rf config.status Makefile target-mkfrag depend *.info* + +.PHONY: force +force: + +# with the gnu make, this is done automatically. + +Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status + +.NOEXPORT: +MAKEOVERRIDES= +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 the removes lines containing only "\\". +# It prepends '$(MULTITOP)/' to relative pathnames to other libg++ dirs. +# 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 + gcc -M $(CXXINCLUDES) $(DEPEND_SOURCES) \ + | sed -e 's|$(srcdir)/|$$(srcdir)/|g' \ + -e 's| /[^ ]*[.]h||g' \ + -e 's| [.]\([^ ]*/libio/[^ ]*[.]h\)| $$(MULTITOP)/.\1|g' \ + -e 's| [.]\([^ ]*/libstdc++/[^ ]*[.]h\)| $$(MULTITOP)/.\1|g' \ + -e '/^[ ]*\\$$/d' -e 's/^[ ]*$$//' \ + | 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 +# End of package fragment generated by /kalessin/giga/bothner/dist/devo/libstdc++/config.shared. diff --git a/gnu/lib/libg++/libstdc++/Makefile.in b/gnu/lib/libg++/libstdc++/Makefile.in new file mode 100644 index 00000000000..3254350b81e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/Makefile.in @@ -0,0 +1,292 @@ +# 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.7.1 + +OBJS = newi.o cstringi.o stddefi.o typeinfoi.o exceptioni.o stdexcepti.o \ + cstdlibi.o cmathi.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 new stddef string exception stdexcept typeinfo \ + 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 = foo +SHFLAGS = +SHDEPS = + +STAMP = bigstmp + +LIBS = $(ARLIB) + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +IO_DIR = $(MULTITOP)/../libio$(MULTISUBDIR) +LIBIBERTY_DIR = $(MULTITOP)/../libiberty$(MULTISUBDIR) + +LIBIBERTY_OBJS = `cat $(LIBIBERTY_DIR)/needed-list` strerror.o + +tooldir = $(exec_prefix)/$(target) +INSTALLDIR = $(libdir)$(MULTISUBDIR) + +MOSTLYCLEAN_JUNK = *stmp-* tlib*.a *.s *.ii stdlist piclist +CLEAN_JUNK = $(LIBS) + +# Remove these for public releases. +CXXFLAGS = -g -O3 -Wall -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -pedantic -ansi -Winline +CFLAGS = -g -O3 -Wall -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 stl/stl.list + -rm -f tlist + cp stdlist tlist + sed 's,\([A-Za-z_]*\.o\),stl/\1,g' stl/stl.list >> 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 stl/stl.list + -rm -f t$(ARLIB) + $(AR) $(AR_FLAGS) t$(ARLIB) `cat stdlist` + cd stl; $(AR) $(AR_FLAGS) ../t$(ARLIB) `cat stl.list` + mv t$(ARLIB) $(ARLIB) + $(RANLIB) $(ARLIB) + +$(SHLIB): piclist + $(CXX) $(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 -sf $(SHLIB) $(SHLINK) + +$(MSHLINK): + ln -sf $(SHLIB) $(MSHLINK) + +$(IO_DIR)/iostream.list: force + cd $(IO_DIR) ; $(MAKE) $(FLAGS_TO_PASS) iostream.list + +stl/stl.list: force + @rootme=`pwd`/ ; export rootme; cd stl ; \ + $(MAKE) $(FLAGS_TO_PASS) stl.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 + +typeinfoi.o: ${srcdir}/typeinfoi.cc ${srcdir}/std/typeinfo.h + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) ${srcdir}/typeinfoi.cc -frtti -o pic/typeinfoi.o; \ + else true ; fi + $(COMPILE.cc) ${srcdir}/typeinfoi.cc -frtti + +stdexcepti.o: ${srcdir}/stdexcepti.cc ${srcdir}/std/stdexcept.h + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) ${srcdir}/stdexcepti.cc -frtti -o pic/stdexcepti.o; \ + else true ; fi + $(COMPILE.cc) ${srcdir}/stdexcepti.cc -frtti + +# 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: + 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 ; \ + rootme=`pwd`/; export rootme; 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 + for FILE in $(LIBS) ; do \ + rm -f $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + if [ $$FILE = $(SHLINK) ] || [ $$FILE = $(MSHLINK) ]; then \ + ln -sf $(INSTALLDIR)$(MULTISUBDIR)/$(SHLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + elif [ $$FILE = $(SHLIB) ]; then \ + $(INSTALL_PROGRAM) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + : On the HP, turning off write access improves performance ; \ + chmod a-w $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + else \ + $(INSTALL_DATA) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + $(RANLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + chmod a-x $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + fi ; \ + done + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +.PHONY: force +force: diff --git a/gnu/lib/libg++/libstdc++/algorithm b/gnu/lib/libg++/libstdc++/algorithm new file mode 100644 index 00000000000..472d2416640 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/cassert b/gnu/lib/libg++/libstdc++/cassert new file mode 100644 index 00000000000..848087f1783 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cassert @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CASSERT__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cctype b/gnu/lib/libg++/libstdc++/cctype new file mode 100644 index 00000000000..12d96d75917 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cctype @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CCTYPE__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cerrno b/gnu/lib/libg++/libstdc++/cerrno new file mode 100644 index 00000000000..bbd93f75067 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cerrno @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CERRNO__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cfloat b/gnu/lib/libg++/libstdc++/cfloat new file mode 100644 index 00000000000..bd7497a9ebd --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cfloat @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CFLOAT__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cinst.cc b/gnu/lib/libg++/libstdc++/cinst.cc new file mode 100644 index 00000000000..92236c4f8c0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cinst.cc @@ -0,0 +1,151 @@ +// 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; +#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/gnu/lib/libg++/libstdc++/ciso646 b/gnu/lib/libg++/libstdc++/ciso646 new file mode 100644 index 00000000000..51209086695 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/ciso646 @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CISO646__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/climits b/gnu/lib/libg++/libstdc++/climits new file mode 100644 index 00000000000..4b7b81d82e3 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/climits @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CLIMITS__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/clocale b/gnu/lib/libg++/libstdc++/clocale new file mode 100644 index 00000000000..9e20a88bfa4 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/clocale @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CLOCALE__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cmath b/gnu/lib/libg++/libstdc++/cmath new file mode 100644 index 00000000000..da5bce9cad3 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cmath @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CMATH__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cmathi.cc b/gnu/lib/libg++/libstdc++/cmathi.cc new file mode 100644 index 00000000000..e9fa0604eb9 --- /dev/null +++ b/gnu/lib/libg++/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 "std/cmath.h" +#endif +#include diff --git a/gnu/lib/libg++/libstdc++/complex b/gnu/lib/libg++/libstdc++/complex new file mode 100644 index 00000000000..17e2fe439bf --- /dev/null +++ b/gnu/lib/libg++/libstdc++/complex @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __COMPLEX__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/complex.h b/gnu/lib/libg++/libstdc++/complex.h new file mode 100644 index 00000000000..554210dcffd --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/aix.ml b/gnu/lib/libg++/libstdc++/config/aix.ml new file mode 100644 index 00000000000..619cbcacfa5 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/config/aix.ml @@ -0,0 +1,7 @@ +# AIX has wierd shared/non-shared libraries. + +ARLIB = libstdc++-ar.a +SHLINK = libstdc++.a +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +DEPLIBS = ../$(SHLIB) +SHDEPS = -lm diff --git a/gnu/lib/libg++/libstdc++/config/dec-osf.ml b/gnu/lib/libg++/libstdc++/config/dec-osf.ml new file mode 100644 index 00000000000..618c6c89fad --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/elf.ml b/gnu/lib/libg++/libstdc++/config/elf.ml new file mode 100644 index 00000000000..2a5f336fe5e --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/elfshlibm.ml b/gnu/lib/libg++/libstdc++/config/elfshlibm.ml new file mode 100644 index 00000000000..fe2bf3f93bd --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/hpux.ml b/gnu/lib/libg++/libstdc++/config/hpux.ml new file mode 100644 index 00000000000..1531fe867f1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/irix5.ml b/gnu/lib/libg++/libstdc++/config/irix5.ml new file mode 100644 index 00000000000..aa0eb413910 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/config/irix5.ml @@ -0,0 +1,5 @@ +# We don't need -fpic on IRIX, so let's install both the shared and +# non-shared versions. We also don't need to specify -lm, yay! + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +DEPLIBS = ../$(SHLIB) diff --git a/gnu/lib/libg++/libstdc++/config/linux.ml b/gnu/lib/libg++/libstdc++/config/linux.ml new file mode 100644 index 00000000000..e2686aa649e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/config/linux.ml @@ -0,0 +1,11 @@ +# Elf with shared libm, so we can link it into the shared libstdc++. + +FULL_VERSION = 27.1.0 +MAJOR_VERSION = 27 + +SHLIB = libstdc++.so.$(FULL_VERSION) +MSHLINK = libstdc++.so.$(MAJOR_VERSION) +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) $(MSHLINK) +SHFLAGS = -Wl,-soname,$(MSHLINK) +SHDEPS = -lm +DEPLIBS = ../$(SHLIB) diff --git a/gnu/lib/libg++/libstdc++/config/sol2shm.ml b/gnu/lib/libg++/libstdc++/config/sol2shm.ml new file mode 100644 index 00000000000..f02650ce0ab --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/config/sunos4.ml b/gnu/lib/libg++/libstdc++/config/sunos4.ml new file mode 100644 index 00000000000..0abc13ce0a1 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/configure.in b/gnu/lib/libg++/libstdc++/configure.in new file mode 100644 index 00000000000..4941993a41f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/configure.in @@ -0,0 +1,74 @@ +# 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="stl tests" +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. +if [ "${enable_shared}" = "yes" ]; then + case "${target}" in + hppa*-*-*) frags=../../config/mh-papic ;; + i[345]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" ;; + *-*-irix5*) 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"'$(MULTITOP)/'"${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" +MOSTLYCLEAN='*.o pic stamp-picdir core so_locations $(MOSTLYCLEAN_JUNK)' +CLEAN='$(CLEAN_JUNK)' +DISTCLEAN='config.status Makefile target-mkfrag' + +(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} + +# post-target: + +# If cross-compiling, we install in $(tooldir). +if [ ${host} != ${target} ] ; then + rm -f Makefile.tem + sed \ + -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ + Makefile >Makefile.tem + mv -f Makefile.tem Makefile +fi + +# We need multilib support. +. ${srcdir}/../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libstdc++/csetjmp b/gnu/lib/libg++/libstdc++/csetjmp new file mode 100644 index 00000000000..b635d738a4f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/csetjmp @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSETJMP__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/csignal b/gnu/lib/libg++/libstdc++/csignal new file mode 100644 index 00000000000..21ed90cda08 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/csignal @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSIGNAL__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstdarg b/gnu/lib/libg++/libstdc++/cstdarg new file mode 100644 index 00000000000..c8ca3eabf13 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cstdarg @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDARG__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstddef b/gnu/lib/libg++/libstdc++/cstddef new file mode 100644 index 00000000000..18134383bb2 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cstddef @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDDEF__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstdio b/gnu/lib/libg++/libstdc++/cstdio new file mode 100644 index 00000000000..ac851787b30 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cstdio @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDIO__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstdlib b/gnu/lib/libg++/libstdc++/cstdlib new file mode 100644 index 00000000000..fa4dac415f5 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cstdlib @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDLIB__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstdlibi.cc b/gnu/lib/libg++/libstdc++/cstdlibi.cc new file mode 100644 index 00000000000..bd94aa5dfa3 --- /dev/null +++ b/gnu/lib/libg++/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 "std/cstdlib.h" +#endif +#include diff --git a/gnu/lib/libg++/libstdc++/cstring b/gnu/lib/libg++/libstdc++/cstring new file mode 100644 index 00000000000..e0d18cfaa5e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cstring @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTRING__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cstringi.cc b/gnu/lib/libg++/libstdc++/cstringi.cc new file mode 100644 index 00000000000..e981ab73c98 --- /dev/null +++ b/gnu/lib/libg++/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 "std/cstring.h" +#endif +#include diff --git a/gnu/lib/libg++/libstdc++/ctime b/gnu/lib/libg++/libstdc++/ctime new file mode 100644 index 00000000000..8b68715ac44 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/ctime @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CTIME__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cwchar b/gnu/lib/libg++/libstdc++/cwchar new file mode 100644 index 00000000000..be96cc81d5b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cwchar @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CWCHAR__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/cwctype b/gnu/lib/libg++/libstdc++/cwctype new file mode 100644 index 00000000000..1eaa0ca8e03 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/cwctype @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CWCTYPE__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/deque b/gnu/lib/libg++/libstdc++/deque new file mode 100644 index 00000000000..bdc14299a04 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/exception b/gnu/lib/libg++/libstdc++/exception new file mode 100644 index 00000000000..a843d4bbc9c --- /dev/null +++ b/gnu/lib/libg++/libstdc++/exception @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __EXCEPTION__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/exceptioni.cc b/gnu/lib/libg++/libstdc++/exceptioni.cc new file mode 100644 index 00000000000..115c6d6b7a4 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/exceptioni.cc @@ -0,0 +1,78 @@ +// Functions for Exception Support for -*- C++ -*- +// 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. + +#include +#include + +/* terminate (), unexpected (), set_terminate (), set_unexpected () as + well as the default terminate func and default unexpected func */ + +#if 0 +extern "C" int printf(const char *, ...); +#endif + +void +__default_terminate () +{ + abort (); +} + +void +__default_unexpected () +{ + __default_terminate (); +} + +static terminate_handler __terminate_func = __default_terminate; +static unexpected_handler __unexpected_func = __default_unexpected; + +terminate_handler +set_terminate (terminate_handler func) +{ + terminate_handler old = __terminate_func; + + __terminate_func = func; + return old; +} + +unexpected_handler +set_unexpected (unexpected_handler func) +{ + unexpected_handler old = __unexpected_func; + + __unexpected_func = func; + return old; +} + +void +terminate () +{ + __terminate_func (); +} + +void +unexpected () +{ + __unexpected_func (); +} diff --git a/gnu/lib/libg++/libstdc++/functional b/gnu/lib/libg++/libstdc++/functional new file mode 100644 index 00000000000..ee8b7f20202 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/iterator b/gnu/lib/libg++/libstdc++/iterator new file mode 100644 index 00000000000..a0fa054c5ec --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/list b/gnu/lib/libg++/libstdc++/list new file mode 100644 index 00000000000..475d8443d16 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/map b/gnu/lib/libg++/libstdc++/map new file mode 100644 index 00000000000..0127b9db250 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/memory b/gnu/lib/libg++/libstdc++/memory new file mode 100644 index 00000000000..8328720db6d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/new b/gnu/lib/libg++/libstdc++/new new file mode 100644 index 00000000000..47944fcff98 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/new @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __NEW__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/new.h b/gnu/lib/libg++/libstdc++/new.h new file mode 100644 index 00000000000..02bba4509b0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/new.h @@ -0,0 +1,7 @@ +// -*- C++ -*- backward compatiblity header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __NEW_H__ +#define __NEW_H__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/newi.cc b/gnu/lib/libg++/libstdc++/newi.cc new file mode 100644 index 00000000000..b4a5b6aeb7e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/newi.cc @@ -0,0 +1,7 @@ +// Implementation file for the -*- C++ -*- dynamic memory management header. +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "std/new.h" +#endif +#include diff --git a/gnu/lib/libg++/libstdc++/numeric b/gnu/lib/libg++/libstdc++/numeric new file mode 100644 index 00000000000..dcb88737f17 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/queue b/gnu/lib/libg++/libstdc++/queue new file mode 100644 index 00000000000..9b2b6d6c156 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/set b/gnu/lib/libg++/libstdc++/set new file mode 100644 index 00000000000..0353285fe50 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/sinst.cc b/gnu/lib/libg++/libstdc++/sinst.cc new file mode 100644 index 00000000000..136a05e532b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/sinst.cc @@ -0,0 +1,147 @@ +// 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 + +#if 0 +#define _G_NO_EXTERN_TEMPLATES +#endif +#include + +#ifdef C +typedef char c; +#endif +#ifdef W +typedef wchar_t c; +#endif + +#ifdef TRAITS +template class string_char_traits ; +#endif + +#define STRING basic_string > +typedef class STRING s; +#define BSREP __bsrep > +typedef class BSREP r; + +#ifdef REP +template class BSREP; +r s::nilRep = { 0, 0, 1 }; +#ifdef _G_ALLOC_CONTROL +bool (*r::excess_slop) (size_t, size_t) = r::default_excess; +size_t (*r::frob_size) (size_t) = r::default_frob; +#endif +#endif + +#ifdef MAIN +template class 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&); +#endif diff --git a/gnu/lib/libg++/libstdc++/stack b/gnu/lib/libg++/libstdc++/stack new file mode 100644 index 00000000000..dfe0c51e181 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/std/bastring.cc b/gnu/lib/libg++/libstdc++/std/bastring.cc new file mode 100644 index 00000000000..d3317c50084 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/bastring.cc @@ -0,0 +1,483 @@ +// 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 * __bsrep :: +operator new (size_t s, size_t extra) +{ + return ::operator new (s + extra * sizeof (charT)); +} + +template +inline size_t __bsrep :: +#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 __bsrep * __bsrep :: +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 * __bsrep :: +clone () +{ + Rep *p = Rep::create (len); + p->copy (0, data (), len); + p->len = len; + return p->data (); +} + +template +inline bool __bsrep :: +#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; + 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 __bsrep :: +copy (size_t pos, const charT *s, size_t n) +{ + if (n) + traits::copy (data () + pos, s, n); +} + +template +inline void __bsrep :: +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 >= npos - 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 __bsrep :: +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 >= npos - 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 == npos); + + 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 +{ + 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 +{ + 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 (); + for (; xpos-- > pos; ) + 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 (); + for (; xpos-- > pos; ) + 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 (); + for (; xpos-- > pos; ) + 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; +} +} // extern "C++" diff --git a/gnu/lib/libg++/libstdc++/std/bastring.h b/gnu/lib/libg++/libstdc++/std/bastring.h new file mode 100644 index 00000000000..6361ef27cca --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/bastring.h @@ -0,0 +1,574 @@ +// 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; + +// Should be a nested class basic_string::Rep, but nested +// classes don't work well with templates in g++. +template > +struct __bsrep { + typedef __bsrep 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 &); +}; + +// #include + +template > +class basic_string +{ +private: + typedef __bsrep 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; } // 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) + { insert (p - begin (), 1, c); return p; } + iterator insert(iterator p, size_type n, charT c) + { insert (p - begin (), n, c); return p; } +#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, 0, (charT)0); } + basic_string& remove (iterator pos) + { return replace (pos - begin (), 1, 0, (charT)0); } + basic_string& remove (iterator first, iterator last) + { return replace (first - begin (), last - first, 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); +} + +// Kludge this until g++ supports the new template overloading semantics. +#if !defined(FUNCTION_H) +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); +} +#endif + +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++" + +#if !defined (_G_NO_EXTERN_TEMPLATES) +#include +#endif + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/cassert.h b/gnu/lib/libg++/libstdc++/std/cassert.h new file mode 100644 index 00000000000..83f9f4042f3 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cassert.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- assertions header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __ASSERT__ +#define __ASSERT__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/cctype.h b/gnu/lib/libg++/libstdc++/std/cctype.h new file mode 100644 index 00000000000..e2765aed50a --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cctype.h @@ -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/gnu/lib/libg++/libstdc++/std/cerrno.h b/gnu/lib/libg++/libstdc++/std/cerrno.h new file mode 100644 index 00000000000..ce493469597 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cerrno.h @@ -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/gnu/lib/libg++/libstdc++/std/cfloat.h b/gnu/lib/libg++/libstdc++/std/cfloat.h new file mode 100644 index 00000000000..05a6338740e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cfloat.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- floating point header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CFLOAT__ +#define __CFLOAT__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/cinst.h b/gnu/lib/libg++/libstdc++/std/cinst.h new file mode 100644 index 00000000000..e41a2bad146 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cinst.h @@ -0,0 +1,112 @@ +// Forward declarations of -*- C++ -*- complex number instantiations. +// 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 __CINST__ +#define __CINST__ + +#ifndef _G_NO_EXTERN_TEMPLATES +extern "C++" { +extern template class complex; +extern template class complex; +extern template class complex; + +#define __B(type) bool +#define __C(type) complex +#define __F(type) type +#define __I(type) int +#define __IS(type) istream& +#define __OS(type) ostream& +#define __CR(type) complex& +#define __CCR(type) const complex& + +#define __D2(name,type,ret,arg1,arg2) ret(type) name (arg1(type), arg2(type)); + +#define __S1(name,type,ret,arg1) \ + extern template ret(type) name (arg1(type)); +#define __S2(name,type,ret,arg1,arg2) \ + extern template __D2 (name,type,ret,arg1,arg2) + +#define __DO1(name,ret,arg1) \ + __S1(name,float,ret,arg1) \ + __S1(name,double,ret,arg1) \ + __S1(name,long double,ret,arg1) +#define __DO2(name,ret,arg1,arg2) \ + __S2(name,float,ret,arg1,arg2) \ + __S2(name,double,ret,arg1,arg2) \ + __S2(name,long double,ret,arg1,arg2) + +#define __DOCCC(name) __DO2(name,__C,__CCR,__CCR) +#define __DOCCF(name) __DO2(name,__C,__CCR,__F) +#define __DOCFC(name) __DO2(name,__C,__F,__CCR) +#define __DOCFF(name) __DO2(name,__C,__F,__F) +#define __DOBCC(name) __DO2(name,__B,__CCR,__CCR) +#define __DOBCF(name) __DO2(name,__B,__CCR,__F) +#define __DOBFC(name) __DO2(name,__B,__F,__CCR) +#define __DOFC(name) __DO1(name,__F,__CCR) +#define __DOCC(name) __DO1(name,__C,__CCR) + +__DO2(operator+,__C,__CCR,__CCR) +__DO2(operator+,__C,__CCR,__F) +__DO2(operator+,__C,__F,__CCR) +__DO2(operator-,__C,__CCR,__CCR) +__DO2(operator-,__C,__CCR,__F) +__DO2(operator-,__C,__F,__CCR) +__DO2(operator*,__C,__CCR,__CCR) +__DO2(operator*,__C,__CCR,__F) +__DO2(operator*,__C,__F,__CCR) +__DO2(operator/,__C,__CCR,__F) +__DO1(operator+,__C,__CCR) +__DO1(operator-,__C,__CCR) +__DO2(operator==,__B,__CCR,__CCR) +__DO2(operator==,__B,__CCR,__F) +__DO2(operator==,__B,__F,__CCR) +__DO2(operator!=,__B,__CCR,__CCR) +__DO2(operator!=,__B,__CCR,__F) +__DO2(operator!=,__B,__F,__CCR) +__DO1(abs,__F,__CCR) +__DO1(arg,__F,__CCR) +__DO2(polar,__C,__F,__F) +__DO1(conj,__C,__CCR) +__DO1(norm,__F,__CCR) + +#undef __DO1 +#undef __DO2 +#undef __S1 +#undef __S2 +#undef __D2 +#undef __B +#undef __C +#undef __F +#undef __I +#undef __IS +#undef __OS +#undef __CR +#undef __CCR +} // extern "C++" +#endif + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/ciso646.h b/gnu/lib/libg++/libstdc++/std/ciso646.h new file mode 100644 index 00000000000..974d15b5742 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/ciso646.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- ISO 646 header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CISO646__ +#define __CISO646__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/climits.h b/gnu/lib/libg++/libstdc++/std/climits.h new file mode 100644 index 00000000000..45e3d62b492 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/climits.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- integral type limits header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CLIMITS__ +#define __CLIMITS__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/clocale.h b/gnu/lib/libg++/libstdc++/std/clocale.h new file mode 100644 index 00000000000..b67cf31c9d2 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/clocale.h @@ -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/gnu/lib/libg++/libstdc++/std/cmath.h b/gnu/lib/libg++/libstdc++/std/cmath.h new file mode 100644 index 00000000000..8c6628ed83c --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cmath.h @@ -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 "std/cmath.h" +#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/gnu/lib/libg++/libstdc++/std/complex.h b/gnu/lib/libg++/libstdc++/std/complex.h new file mode 100644 index 00000000000..bfdd352b462 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/complex.h @@ -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/gnu/lib/libg++/libstdc++/std/complext.cc b/gnu/lib/libg++/libstdc++/std/complext.cc new file mode 100644 index 00000000000..0b63125b2d2 --- /dev/null +++ b/gnu/lib/libg++/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& complex:: +operator /= (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 = (re * t + im) / d; + ni = (im * t - re) / d; + } + else + { + t = y.im / y.re; + d = y.re * (1 + t*t); + nr = (re + im * t) / d; + ni = (im - re * t) / d; + } + re = nr; + im = ni; + return *this; +} + +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/gnu/lib/libg++/libstdc++/std/complext.h b/gnu/lib/libg++/libstdc++/std/complext.h new file mode 100644 index 00000000000..db87dd0988f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/complext.h @@ -0,0 +1,317 @@ +// 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 + +extern "C++" { +template +class complex +{ +public: + complex (FLOAT r = 0, FLOAT i = 0): re (r), im (i) { } + complex& operator += (const complex&); + complex& operator -= (const complex&); + complex& operator *= (const complex&); + complex& operator /= (const complex&); + FLOAT real () const { return re; } + FLOAT imag () const { return im; } +private: + FLOAT re, im; + + // These functions are specified as friends for purposes of name injection; + // they do not actually reference private members. + friend FLOAT real (const complex&) __attribute__ ((const)); + friend FLOAT imag (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 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&); +}; + +// Declare specializations. +class complex; +class complex; +class complex; + +template +inline complex& +complex::operator += (const complex& r) +{ + re += r.re; + im += r.im; + return *this; +} + +template +inline complex& +complex::operator -= (const complex& r) +{ + re -= r.re; + im -= r.im; + return *this; +} + +template +inline complex& +complex::operator *= (const complex& r) +{ + FLOAT f = re * r.re - im * r.im; + im = re * r.im + im * r.re; + re = f; + return *this; +} + +template inline FLOAT +imag (const complex& x) __attribute__ ((const)) +{ + return x.imag (); +} + +template inline FLOAT +real (const complex& x) __attribute__ ((const)) +{ + return x.real (); +} + +template inline complex +operator + (const complex& x, const complex& y) __attribute__ ((const)) +{ + return complex (real (x) + real (y), imag (x) + imag (y)); +} + +template inline complex +operator + (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return complex (real (x) + y, imag (x)); +} + +template inline complex +operator + (FLOAT x, const complex& y) __attribute__ ((const)) +{ + return complex (x + real (y), imag (y)); +} + +template inline complex +operator - (const complex& x, const complex& y) __attribute__ ((const)) +{ + return complex (real (x) - real (y), imag (x) - imag (y)); +} + +template inline complex +operator - (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return complex (real (x) - y, imag (x)); +} + +template inline complex +operator - (FLOAT x, const complex& y) __attribute__ ((const)) +{ + return complex (x - real (y), - imag (y)); +} + +template inline complex +operator * (const complex& x, const complex& y) __attribute__ ((const)) +{ + return complex (real (x) * real (y) - imag (x) * imag (y), + real (x) * imag (y) + imag (x) * real (y)); +} + +template inline complex +operator * (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return complex (real (x) * y, imag (x) * y); +} + +template inline complex +operator * (FLOAT x, const complex& y) __attribute__ ((const)) +{ + return complex (x * real (y), x * imag (y)); +} + +template complex +operator / (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return complex (real (x) / y, imag (x) / y); +} + +template inline complex +operator + (const complex& x) __attribute__ ((const)) +{ + return x; +} + +template inline complex +operator - (const complex& x) __attribute__ ((const)) +{ + return complex (-real (x), -imag (x)); +} + +template inline bool +operator == (const complex& x, const complex& y) __attribute__ ((const)) +{ + return real (x) == real (y) && imag (x) == imag (y); +} + +template inline bool +operator == (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return real (x) == y && imag (x) == 0; +} + +template inline bool +operator == (FLOAT x, const complex& y) __attribute__ ((const)) +{ + return x == real (y) && imag (y) == 0; +} + +template inline bool +operator != (const complex& x, const complex& y) __attribute__ ((const)) +{ + return real (x) != real (y) || imag (x) != imag (y); +} + +template inline bool +operator != (const complex& x, FLOAT y) __attribute__ ((const)) +{ + return real (x) != y || imag (x) != 0; +} + +template inline bool +operator != (FLOAT x, const complex& y) __attribute__ ((const)) +{ + 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 FLOAT +abs (const complex& x) __attribute__ ((const)) +{ + return hypot (real (x), imag (x)); +} + +template inline FLOAT +arg (const complex& x) __attribute__ ((const)) +{ + return atan2 (imag (x), real (x)); +} + +template inline complex +polar (FLOAT r, FLOAT t) __attribute__ ((const)) +{ + return complex (r * cos (t), r * sin (t)); +} + +template inline complex +conj (const complex& x) __attribute__ ((const)) +{ + return complex (real (x), -imag (x)); +} + +template inline FLOAT +norm (const complex& x) __attribute__ ((const)) +{ + return real (x) * real (x) + imag (x) * imag (x); +} + +// Declarations of templates in complext.ccI + +template complex + operator / (const complex&, const complex&) __attribute__ ((const)); +template complex + operator / (FLOAT, const complex&) __attribute__ ((const)); +template complex + cos (const complex&) __attribute__ ((const)); +template complex + cosh (const complex&) __attribute__ ((const)); +template complex + exp (const complex&) __attribute__ ((const)); +template complex + log (const complex&) __attribute__ ((const)); +template complex + pow (const complex&, const complex&) __attribute__ ((const)); +template complex + pow (const complex&, FLOAT) __attribute__ ((const)); +template complex + pow (const complex&, int) __attribute__ ((const)); +template complex + pow (FLOAT, const complex&) __attribute__ ((const)); +template complex + sin (const complex&) __attribute__ ((const)); +template complex + sinh (const complex&) __attribute__ ((const)); +template complex + sqrt (const complex&) __attribute__ ((const)); + +class istream; +class ostream; +template istream& operator >> (istream&, complex&); +template ostream& operator << (ostream&, const complex&); +} // extern "C++" + +// Specializations and such + +#include +#include +#include + +// Declare the instantiations. +#include + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/csetjmp.h b/gnu/lib/libg++/libstdc++/std/csetjmp.h new file mode 100644 index 00000000000..4bba048dcb5 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/csetjmp.h @@ -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/gnu/lib/libg++/libstdc++/std/csignal.h b/gnu/lib/libg++/libstdc++/std/csignal.h new file mode 100644 index 00000000000..6febfb7b2ed --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/csignal.h @@ -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/gnu/lib/libg++/libstdc++/std/cstdarg.h b/gnu/lib/libg++/libstdc++/std/cstdarg.h new file mode 100644 index 00000000000..24c57f06299 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cstdarg.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- variable argument handling header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDARG__ +#define __CSTDARG__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/cstddef.h b/gnu/lib/libg++/libstdc++/std/cstddef.h new file mode 100644 index 00000000000..0e025e3d163 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cstddef.h @@ -0,0 +1,7 @@ +// The -*- C++ -*- wrapper for the C standard definitions header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDDEF__ +#define __CSTDDEF__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/std/cstdio.h b/gnu/lib/libg++/libstdc++/std/cstdio.h new file mode 100644 index 00000000000..1fe1456b5bd --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cstdio.h @@ -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/gnu/lib/libg++/libstdc++/std/cstdlib.h b/gnu/lib/libg++/libstdc++/std/cstdlib.h new file mode 100644 index 00000000000..51dc00a5af0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cstdlib.h @@ -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 "std/cstdlib.h" +#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/gnu/lib/libg++/libstdc++/std/cstring.h b/gnu/lib/libg++/libstdc++/std/cstring.h new file mode 100644 index 00000000000..6d493e7501e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cstring.h @@ -0,0 +1,71 @@ +// The -*- C++ -*- null-terminated string header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTRING__ +#define __CSTRING__ + +#if 0 // Let's not bother with this just yet. +// The ANSI C prototypes for these functions have a const argument type and +// non-const return type, so we can't use them. + +#define strchr __hide_strchr +#define strpbrk __hide_strpbrk +#define strrchr __hide_strrchr +#define strstr __hide_strstr +#define memchr __hide_memchr +#endif // 0 + +#include_next + +#if 0 // Let's not bother with this just yet. +#undef strchr +#undef strpbrk +#undef strrchr +#undef strstr +#undef memchr + +#include + +#ifdef __GNUG__ +#pragma interface "std/cstring.h" +#endif + +extern "C++" { +extern "C" const char *strchr (const char *, int); +inline char * +strchr (char *s, int c) +{ + return const_cast (strchr (static_cast (s), c)); +} + +extern "C" const char *strpbrk (const char *, const char *); +inline char * +strpbrk (char *s1, const char *s2) +{ + return const_cast (strpbrk (static_cast (s1), s2)); +} + +extern "C" const char *strrchr (const char *, int); +inline char * +strrchr (char *s, int c) +{ + return const_cast (strrchr (static_cast (s), c)); +} + +extern "C" const char *strstr (const char *, const char *); +inline char * +strstr (char *s1, const char *s2) +{ + return const_cast (strstr (static_cast (s1), s2)); +} + +extern "C" const void *memchr (const void *, int, size_t); +inline void * +memchr (void *s, int c, size_t n) +{ + return const_cast (memchr (static_cast (s), c, n)); +} +} // extern "C++" + +#endif // 0 +#endif // !defined (__CSTRING__) diff --git a/gnu/lib/libg++/libstdc++/std/ctime.h b/gnu/lib/libg++/libstdc++/std/ctime.h new file mode 100644 index 00000000000..0184da5929f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/ctime.h @@ -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/gnu/lib/libg++/libstdc++/std/cwchar.h b/gnu/lib/libg++/libstdc++/std/cwchar.h new file mode 100644 index 00000000000..1674c12b61f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cwchar.h @@ -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/gnu/lib/libg++/libstdc++/std/cwctype.h b/gnu/lib/libg++/libstdc++/std/cwctype.h new file mode 100644 index 00000000000..81122012bd0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/cwctype.h @@ -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/gnu/lib/libg++/libstdc++/std/dcomplex.h b/gnu/lib/libg++/libstdc++/std/dcomplex.h new file mode 100644 index 00000000000..d3e5d311c63 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/dcomplex.h @@ -0,0 +1,89 @@ +// 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&); + complex& operator-= (const complex&); + complex& operator*= (const complex&); + complex& operator/= (const complex&); + + double real () const { return re; } + double imag () const { return im; } +private: + double re, im; + + // 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/gnu/lib/libg++/libstdc++/std/exception.h b/gnu/lib/libg++/libstdc++/std/exception.h new file mode 100644 index 00000000000..6de65d8fc10 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/exception.h @@ -0,0 +1,39 @@ +// Exception Handling header for -*- C++ -*- +// Copyright (C) 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. + +#ifndef __EXCEPTION__ +#define __EXCEPTION__ + +extern "C++" { +// class XUNEXPECTED { to be specified }; +typedef void (*terminate_handler) (); +typedef void (*unexpected_handler) (); + +terminate_handler set_terminate (terminate_handler); +void terminate (void); +unexpected_handler set_unexpected (unexpected_handler); +void unexpected (void); +} // extern "C++" + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/fcomplex.h b/gnu/lib/libg++/libstdc++/std/fcomplex.h new file mode 100644 index 00000000000..27f3be7a480 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/fcomplex.h @@ -0,0 +1,85 @@ +// 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&); + complex& operator-= (const complex&); + complex& operator*= (const complex&); + complex& operator/= (const complex&); + + float real () const { return re; } + float imag () const { return im; } +private: + float re, im; + + // 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/gnu/lib/libg++/libstdc++/std/ldcomplex.h b/gnu/lib/libg++/libstdc++/std/ldcomplex.h new file mode 100644 index 00000000000..95f90ae7f0e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/ldcomplex.h @@ -0,0 +1,93 @@ +// 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&); + complex& operator-= (const complex&); + complex& operator*= (const complex&); + complex& operator/= (const complex&); + + long double real () const { return re; } + long double imag () const { return im; } +private: + long double re, im; + + // 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/gnu/lib/libg++/libstdc++/std/new.h b/gnu/lib/libg++/libstdc++/std/new.h new file mode 100644 index 00000000000..cfdfbebdd63 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/new.h @@ -0,0 +1,34 @@ +// The -*- C++ -*- dynamic memory management header. +// Copyright (C) 1994 Free Software Foundation + +#ifndef __NEW__ +#define __NEW__ + +#ifdef __GNUG__ +#pragma interface "std/new.h" +#endif + +#include + +extern "C++" { +typedef void (*new_handler)(); +extern "C" new_handler set_new_handler (new_handler); + +#if defined(__GNUG__) && !defined (__STRICT_ANSI__) +// G++ implementation internals +extern new_handler __new_handler; +extern "C" void __default_new_handler (void); +#endif + +// replaceable signatures +void *operator new (size_t); +void *operator new[] (size_t); +void operator delete (void *); +void operator delete[] (void *); + +// default placement versions of operator new +inline void *operator new(size_t, void *place) { return place; } +inline void *operator new[](size_t, void *place) { return place; } +} // extern "C++" + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/sinst.h b/gnu/lib/libg++/libstdc++/std/sinst.h new file mode 100644 index 00000000000..6bd9bfc6d19 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/sinst.h @@ -0,0 +1,73 @@ +// Forward declarations of -*- C++ -*- string instantiations. +// 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 __SINST__ +#define __SINST__ + +extern "C++" { +#define __S basic_string > +//#define __W basic_string > + +extern template class __bsrep >; +extern template class __S; +// extern template class __W; +// extern template class __bsrep >; + +#define __DOPR(op, ret, c, s) \ + extern template ret operator op (const s&, const s&); \ + extern template ret operator op (const c*, const s&); \ + extern template ret operator op (const s&, const c*); \ + +#define __DO(op, ret, c, s) \ + extern template ret operator op (const s&, const s&); \ + extern template ret operator op (const c*, const s&); \ + extern template ret operator op (const s&, const c*); \ + extern template ret operator op (c, const s&); \ + extern template ret operator op (const s&, c); + +__DO (+, __S, char, __S) +// __DO (+, __W, wchar_t, __W) */ + +#define __DOB(op) \ + __DOPR (op, bool, char, __S) +// __DOPR (op, bool, wchar_t, __W) + +__DOB (==) +__DOB (!=) +__DOB (<) +__DOB (>) +__DOB (<=) +__DOB (>=) + +#undef __S +//#undef __W +#undef __DO +#undef __DOB +#undef __DOPR +} // extern "C++" + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/stddef.h b/gnu/lib/libg++/libstdc++/std/stddef.h new file mode 100644 index 00000000000..00cf47e7a02 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/stddef.h @@ -0,0 +1,25 @@ +// The -*- C++ -*- standard definitions header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __STDDEF__ +#define __STDDEF__ + +#ifdef __GNUG__ +#pragma interface "std/stddef.h" +#endif + +#include <_G_config.h> +#include + +extern "C++" { +const size_t NPOS = (size_t)(-1); +typedef void fvoid_t(); + +#ifndef _WINT_T +#define _WINT_T +typedef _G_wint_t wint_t; +#endif + +} // extern "C++" + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/stdexcept.h b/gnu/lib/libg++/libstdc++/std/stdexcept.h new file mode 100644 index 00000000000..785bb6a4223 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/stdexcept.h @@ -0,0 +1,126 @@ +// Methods for Exception Support for -*- C++ -*- +// 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 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 "std/stdexcept.h" +#endif + +#include + +extern "C++" { +#if 0 +#include +typedef string __string; +#else +typedef const char * __string; +#endif + +class exception { +public: + typedef void (*raise_handler)(exception&); + static raise_handler set_raise_handler(raise_handler handler_arg); + exception (const __string& what_arg): desc (what_arg) { } + virtual ~exception() { } + void raise(); + virtual __string what() const { return desc; } +protected: + exception() { } + virtual void do_raise() { } +private: + __string desc; +}; + +class logic_error : public exception { +public: + logic_error(const __string& what_arg): exception (what_arg) { } + virtual ~logic_error() { } +}; + +class domain_error : public logic_error { +public: + domain_error (const __string& what_arg): logic_error (what_arg) { } + virtual ~domain_error () { } +}; + +class invalid_argument : public logic_error { +public: + invalid_argument (const __string& what_arg): logic_error (what_arg) { } + virtual ~invalid_argument () { } +}; + +class length_error : public logic_error { +public: + length_error (const __string& what_arg): logic_error (what_arg) { } + virtual ~length_error () { } +}; + +class out_of_range : public logic_error { +public: + out_of_range (const __string& what_arg): logic_error (what_arg) { } + virtual ~out_of_range () { } +}; + +class runtime_error : public exception { +public: + runtime_error(const __string& what_arg): exception (what_arg) { } + virtual ~runtime_error() { } +protected: + runtime_error(): exception () { } +}; + +class range_error : public runtime_error { +public: + range_error (const __string& what_arg): runtime_error (what_arg) { } + virtual ~range_error () { } +}; + +class overflow_error : public runtime_error { +public: + overflow_error (const __string& what_arg): runtime_error (what_arg) { } + virtual ~overflow_error () { } +}; + +// These are moved here from typeinfo so that we can compile with -frtti +class bad_cast : public logic_error { +public: + bad_cast(const __string& what_arg): logic_error (what_arg) { } + virtual ~bad_cast() { } +}; + +extern bad_cast __bad_cast_object; + +class bad_typeid : public logic_error { + public: + bad_typeid (): logic_error ("bad_typeid") { } + virtual ~bad_typeid () { } +}; +} // extern "C++" + +#endif diff --git a/gnu/lib/libg++/libstdc++/std/straits.h b/gnu/lib/libg++/libstdc++/std/straits.h new file mode 100644 index 00000000000..42fbad37fe9 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/std/string.h b/gnu/lib/libg++/libstdc++/std/string.h new file mode 100644 index 00000000000..77cc801be16 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/string.h @@ -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/gnu/lib/libg++/libstdc++/std/typeinfo.h b/gnu/lib/libg++/libstdc++/std/typeinfo.h new file mode 100644 index 00000000000..44f833cd685 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/std/typeinfo.h @@ -0,0 +1,245 @@ +// RTTI support for -*- C++ -*- +// 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 Kung Hsu based upon the specification in the 20 September 1994 +// C++ working paper, ANSI document X3J16/94-0158. + +#ifndef __TYPEINFO__ +#define __TYPEINFO__ + +#ifdef __GNUG__ +#pragma interface "std/typeinfo.h" +#endif + +extern "C" void* __throw_type_match_rtti (void *, void *, void *); + +extern "C++" { +class type_info { +private: + // assigning type_info is not supported. made private. + type_info& operator=(const type_info&); + type_info(const type_info&); + +public: + enum node_type { + _RTTI_BUILTIN_TYPE, // builtin type + _RTTI_USER_TYPE, // user defined type + _RTTI_CLASS_TYPE, // class type + _RTTI_POINTER_TYPE, // pointer type + _RTTI_ATTR_TYPE, // attribute type for const and volatile + _RTTI_FUNC_TYPE, // function type + _RTTI_PTMF_TYPE, // pointer to member function type + _RTTI_PTMD_TYPE // pointer to member data type + }; + + // return node type of the object + virtual node_type __rtti_get_node_type() const { return _RTTI_BUILTIN_TYPE; } + + // get_name will return the name of the type, NULL if no name (like builtin) + virtual const char * __rtti_get_name() const { return 0; } + + // compare if type represented by the type_info are the same type + virtual int __rtti_compare(const type_info&) const { return 0; } + + // argument passed is the desired type, + // for class type, if the type can be converted to the desired type, + // it will be, and returned, else 0 is returned. If the match + // succeeds, the return value will be adjusted to point to the sub-object. + virtual void* __rtti_match(const type_info&, int, void *) const { + // This should never be called. + return 0; + }; + + // destructor + virtual ~type_info() {} + type_info() {} + + bool before(const type_info& arg); + const char* name() const + { return __rtti_get_name(); } + bool operator==(const type_info& arg) const + { return __rtti_compare(arg) == 0; } + bool operator!=(const type_info& arg) const + { return __rtti_compare(arg) != 0; } +}; + +// type_info for builtin type + +class __builtin_type_info : public type_info { +public: + enum builtin_type_val { + _RTTI_BI_BOOL = 1, _RTTI_BI_CHAR, _RTTI_BI_SHORT, _RTTI_BI_INT, + _RTTI_BI_LONG, _RTTI_BI_LONGLONG, _RTTI_BI_FLOAT, + _RTTI_BI_DOUBLE, _RTTI_BI_LDOUBLE, _RTTI_BI_UCHAR, + _RTTI_BI_USHORT, _RTTI_BI_UINT, _RTTI_BI_ULONG, + _RTTI_BI_ULONGLONG, _RTTI_BI_SCHAR, _RTTI_BI_WCHAR, _RTTI_BI_VOID + }; + + builtin_type_val b_type; + + __builtin_type_info (builtin_type_val bt) : b_type (bt) {} + node_type __rtti_get_node_type () const + { return _RTTI_BUILTIN_TYPE; } + const char *__rtti_get_name () const + { return (const char *)0; } + int __rtti_compare (const type_info& arg) const + { return (arg.__rtti_get_node_type () == _RTTI_BUILTIN_TYPE && + ((__builtin_type_info&)arg).b_type == b_type) ? 0 : -1; } +}; + +// serice function for comparing types by name. + +inline int __fast_compare (const char *n1, const char *n2) { + int c; + if (n1 == n2) return 0; + if (n1 == 0) return *n2; + else if (n2 == 0) return *n1; + + c = (int)*n1++ - (int)*n2++; + return c == 0 ? strcmp (n1, n2) : c; +}; + +// type_info for user type. + +class __user_type_info : public type_info { + private: + const char *_name; + +public: + __user_type_info (const char *nm) : _name (nm) {} + node_type __rtti_get_node_type () const + { return _RTTI_USER_TYPE; } + const char *__rtti_get_name () const + { return _name; } + int __rtti_compare (const type_info& arg) const + { return (arg.__rtti_get_node_type () == __rtti_get_node_type() && + __fast_compare (_name, arg.__rtti_get_name ()) == 0) ? 0 : -1; } +}; + +// type_info for a class. + +class __class_type_info : public __user_type_info { +private: + enum access_mode { + _RTTI_ACCESS_PUBLIC, _RTTI_ACCESS_PROTECTED, _RTTI_ACCESS_PRIVATE + }; + type_info **base_list; + int *offset_list; + int *is_virtual_list; + access_mode *access_list; + int n_bases; + +public: + __class_type_info (const char *name, type_info **bl, int *off, + int *is_vir, access_mode *acc, int bn) + : __user_type_info (name), base_list (bl), offset_list(off), + is_virtual_list(is_vir), access_list(acc), n_bases (bn) {} + node_type __rtti_get_node_type () const + { return _RTTI_CLASS_TYPE; } + + // inherit __rtti_compare from __user_type_info + + // This is a little complex defined in typeinfo.cc + void* __rtti_match(const type_info&, int, void *) const; +}; + +// type info for pointer type. + +class __pointer_type_info : public type_info { +private: + type_info& type; + +public: + __pointer_type_info (type_info& ti) : type (ti) {} + node_type __rtti_get_node_type () const + { return _RTTI_POINTER_TYPE; } + const char *__rtti_get_name () const + { return (const char *)0; } + int __rtti_compare (const type_info& arg) const + { return (arg.__rtti_get_node_type () == __rtti_get_node_type() && + type.__rtti_compare ( ((__pointer_type_info&)arg).type) == 0) ? 0 : -1; } + void* __rtti_match(const type_info& catch_type, int, void *objptr) const; +}; + +// type info for attributes + +class __attr_type_info : public type_info { +public: + enum attr_val { + _RTTI_ATTR_CONST = 1, _RTTI_ATTR_VOLATILE, _RTTI_ATTR_CONSTVOL + }; + + attr_val attr; + type_info& type; + + __attr_type_info (attr_val a, type_info& t) : attr (a), type(t) {} + node_type __rtti_get_node_type () const + { return _RTTI_ATTR_TYPE; } + const char *__rtti_get_name () const + { return (const char *)0; } + int __rtti_compare (const type_info& arg) const + { return (arg.__rtti_get_node_type () == _RTTI_ATTR_TYPE && + attr == ((__attr_type_info&)arg).attr && + type.__rtti_compare ( ((__attr_type_info&)arg).type ) == 0) + ? 0 : -1; } +}; + +// type info for function. + +class __func_type_info : public __user_type_info { +public: + __func_type_info (const char *name) : __user_type_info (name) {} + node_type __rtti_get_node_type () const + { return _RTTI_FUNC_TYPE; } +}; + +// type info for pointer to member function. + +class __ptmf_type_info : public __user_type_info { +public: + __ptmf_type_info (const char *name) : __user_type_info (name) {} + node_type __rtti_get_node_type () const + { return _RTTI_PTMF_TYPE; } +}; + +// type info for pointer to data member. + +class __ptmd_type_info : public type_info { + type_info& classtype; + type_info& type; +public: + __ptmd_type_info (type_info& tc, type_info& t) : classtype (tc), type (t) {} + node_type __rtti_get_node_type () const + { return _RTTI_PTMD_TYPE; } + int __rtti_compare (const type_info& arg) const + { return (arg.__rtti_get_node_type () == _RTTI_PTMD_TYPE && + classtype.__rtti_compare ( ((__ptmd_type_info&)arg).classtype ) == 0 && + type.__rtti_compare ( ((__ptmd_type_info&)arg).type ) == 0) + ? 0 : -1; } +}; +} // extern "C++" + +#include + +#endif diff --git a/gnu/lib/libg++/libstdc++/stddef b/gnu/lib/libg++/libstdc++/stddef new file mode 100644 index 00000000000..9bfd4a91782 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stddef @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __STDDEF__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/stddefi.cc b/gnu/lib/libg++/libstdc++/stddefi.cc new file mode 100644 index 00000000000..b49c42c945c --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stddefi.cc @@ -0,0 +1,7 @@ +// Implementation file for the -*- C++ -*- standard definitions header. +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "std/stddef.h" +#endif +#include diff --git a/gnu/lib/libg++/libstdc++/stdexcept b/gnu/lib/libg++/libstdc++/stdexcept new file mode 100644 index 00000000000..560c53dd888 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stdexcept @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __STDEXCEPT__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/stdexcepti.cc b/gnu/lib/libg++/libstdc++/stdexcepti.cc new file mode 100644 index 00000000000..4025f5ba187 --- /dev/null +++ b/gnu/lib/libg++/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 "std/stdexcept.h" +#endif + +#include diff --git a/gnu/lib/libg++/libstdc++/stl.h b/gnu/lib/libg++/libstdc++/stl.h new file mode 100644 index 00000000000..4b270742c9c --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/stl/ChangeLog b/gnu/lib/libg++/libstdc++/stl/ChangeLog new file mode 100644 index 00000000000..6f1b4df9ce9 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/ChangeLog @@ -0,0 +1,73 @@ +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/gnu/lib/libg++/libstdc++/stl/Makefile.in b/gnu/lib/libg++/libstdc++/stl/Makefile.in new file mode 100644 index 00000000000..f672da05fc4 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/Makefile.in @@ -0,0 +1,8 @@ +#### package, host, target, and site dependent Makefile fragments come in here. +## + +STL_OBJECTS = tempbuf.o tree.o random.o + +stl.list: stamp-picdir $(STL_OBJECTS) + @echo "$(STL_OBJECTS)" >stl.list + diff --git a/gnu/lib/libg++/libstdc++/stl/README b/gnu/lib/libg++/libstdc++/stl/README new file mode 100644 index 00000000000..34d9a13bd78 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/README @@ -0,0 +1,92 @@ +This directory contains Hewlett-Packard's implementation of +the C++ Standard Template Library. +It is the February 7, 1995 version. +It has been extensively modified so it can be compiled by g++. +(Version 2.6.1 or newer is recommended.) +Some of these hacks are pretty ugly, but are needed to work around +bugs in g++ (which we are working on). +Thanks to Carsten Bormann for +coming up with many of these work-arounds. However, I have +come up with alternate (possibly inferior!) work-arounds in some cases. + +It is easy to crash g++ by using STL. (I found the function-object +templates in function.h to be especially fruitful in that respect!) +***SO DON'T BOTHER SENDING BUG REPORTS THAT STL CAUSES G++ TO CRASH***, +or otherwise fails to compile it. unless you also have a fix or +improved work-around!!! WE KNOW! + +Also note that this is based on a pre-Draft Standard for C++. +Thinks 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.cs.rpi.edu/~musser/stl.html on the World-Wide Web, +or anonymous ftp to butler.hpl.hp.com, directory stl, file sharfile.Z. + + --Per Bothner +Cygnus Support bothner@cygnus.com + +----------- +Here is Carsten Bormann's notes on his changes: + +This is a set of seriously bletcherous hacks to HP's wonderful STL +library. The objective is to hammer STL through GCC 2.6.1 (2.6.0 +seems to work, too, until you run into one of its bugs) so that us +academic types can play with STL, not to make STL better in any way. + +Many of these changes make the library much less efficient. All +changes (except vector -- see below) are due to bugs (or +non-features) in GCC, not due to any problems in STL. Do not judge +the performance of STL (code space, data space, compile time +complexity, run time complexity) from these hacks -- they will be much +better when GCC implements more of Standard C++. May the authors of +STL forgive me. + +The class templates generally have been hacked in the following ways: + +1) Static data members have been eliminated, generally by making them +non-static members or member functions (both of which generally +seriously impairs performance -- e.g., each rb_tree iterator now +carries a copy of NIL since there is no other place to put it). The +template list<> has suffered most. + +Allocators are still static members, since I changed defalloc.h to +have static members only. (This makes allocators less useful, but +still useable.) (Note that a static member without data need not be +initialized.) + +2) For member functions defined outside the class template, parameters +of type tmpl::something have been changed. In some cases, a class +derived from the type has been used; in some cases the function simply +has been made inline (again causing code bloat). + +3) A number of function templates in iterator.h have been declared +again for derived classes defined by templates, usually by making them +friend functions and using the name injection feature of GCC. I don't +understand the relevant sections of the WP, so I don't know if this +hack will cease to work in more conforming versions of GCC or become +unneccessary or simply STL won't work with standard C++. Some of +the necessary friends may still be missing... + +defalloc.h has lost much of its functionality: see above. + +bool.h has been made ineffective, since GCC supports bool. + +Finally, bit_vector has been changed into a proper specialization of +vector. +[Not in this libstdc++ release. -PB] + +demo.cc and Makefile build a small demo program for a number of +features of STL. This is not a test suite, so I certainly have not +found all my mistakes (could anyone in possession of such a test suite +please run it over these hacks?). Send bug reports (that follow GNU +bug reporting conventions) to + + cabo@informatik.uni-bremen.de + +Note that I generally do not have time to answer questions about STL. + +Carsten Bormann diff --git a/gnu/lib/libg++/libstdc++/stl/algo.h b/gnu/lib/libg++/libstdc++/stl/algo.h new file mode 100644 index 00000000000..e038d715a25 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/algo.h @@ -0,0 +1,2386 @@ +/* + * + * 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 ALGO_H +#define ALGO_H + +#include +#ifndef __GNUG__ +#include +#endif +#include +#include +#include +#include +#include + +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) { + while (first != last) 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) { + while (first != last) + if (*first++ == value) ++n; +} + +template +void count_if(InputIterator first, InputIterator last, Predicate pred, + Size& n) { + while (first != last) + if (pred(*first++)) ++n; +} + +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++) + if (d1-- == d2) + return last1; + else { + current1 = ++first1; + current2 = first2; + } + return (current2 == last2) ? first1 : last1; +} + +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++)) + if (d1-- == d2) + return last1; + else { + current1 = ++first1; + current2 = first2; + } + return (current2 == last2) ? first1 : last1; +} + +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) { + while (first1 != last1) iter_swap(first1++, first2++); + return first2; +} + +template +OutputIterator transform(InputIterator first, InputIterator last, + OutputIterator result, UnaryOperation op) { + while (first != last) *result++ = op(*first++); + return result; +} + +template +OutputIterator transform(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, OutputIterator result, + BinaryOperation binary_op) { + while (first1 != last1) *result++ = binary_op(*first1++, *first2++); + return result; +} + +template +void replace(ForwardIterator first, ForwardIterator last, const T& old_value, + const T& new_value) { + while (first != last) { + if (*first == old_value) *first = new_value; + ++first; + } +} + +template +void replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, + const T& new_value) { + while (first != last) { + if (pred(*first)) *first = new_value; + ++first; + } +} + +template +OutputIterator replace_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& old_value, + const T& new_value) { + while (first != last) { + *result++ = *first == old_value ? new_value : *first; + ++first; + } + return result; +} + +template +OutputIterator replace_copy_if(Iterator first, Iterator last, + OutputIterator result, Predicate pred, + const T& new_value) { + while (first != last) { + *result++ = pred(*first) ? new_value : *first; + ++first; + } + return result; +} + +template +void generate(ForwardIterator first, ForwardIterator last, Generator gen) { + while (first != last) *first++ = gen(); +} + +template +OutputIterator generate_n(OutputIterator first, Size n, Generator gen) { + while (n-- > 0) *first++ = gen(); + return first; +} + +template +OutputIterator remove_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& value) { + while (first != last) { + if (*first != value) *result++ = *first; + ++first; + } + return result; +} + +template +OutputIterator remove_copy_if(InputIterator first, InputIterator last, + OutputIterator result, Predicate pred) { + while (first != last) { + if (!pred(*first)) *result++ = *first; + ++first; + } + 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) *result++ = *--last; + return result; +} + +template +void __rotate(ForwardIterator first, ForwardIterator middle, + ForwardIterator last, Distance*, forward_iterator_tag) { + for (ForwardIterator i = middle; ;) { + iter_swap(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)); +} + +unsigned long __long_random(unsigned long); + +template +void __random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + Distance*) { + if (first == last) return; + for (RandomAccessIterator i = first + 1; i != last; ++i) + iter_swap(i, first + Distance(__long_random((i - first) + 1))); +} + +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 +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, + Distance& fill_pointer, T*) { + if (len <= buffer_size) { + len = 0; + ForwardIterator result1 = first; + Pointer result2 = buffer; + while (first != last && len < fill_pointer) + if (pred(*first)) + *result1++ = *first++; + else { + *result2++ = *first++; + ++len; + } + if (first != last) { + raw_storage_iterator result3 = result2; + while (first != last) + if (pred(*first)) + *result1++ = *first++; + else { + *result3++ = *first++; + ++len; + } + fill_pointer = len; + } + copy(buffer, buffer + len, result1); + return result1; + } + ForwardIterator middle = first; + advance(middle, len / 2); + ForwardIterator first_cut = __stable_partition_adaptive + (first, middle, pred, len / 2, buffer, buffer_size, fill_pointer, + (T*)0); + ForwardIterator second_cut = __stable_partition_adaptive + (middle, last, pred, len - len / 2, buffer, buffer_size, + fill_pointer, (T*)0); + rotate(first_cut, middle, second_cut); + len = 0; + distance(middle, second_cut, len); + advance(first_cut, len); + return first_cut; +} + +template +ForwardIterator __stable_partition(ForwardIterator first, ForwardIterator last, + Predicate pred, Distance len, + pair p) { + if (p.first == 0) + return __inplace_stable_partition(first, last, pred, len); + Distance fill_pointer = 0; + ForwardIterator result = + __stable_partition_adaptive(first, last, pred, len, p.first, p.second, + fill_pointer, value_type(first)); + destroy(p.first, p.first + fill_pointer); + return_temporary_buffer(p.first); + return result; +} + +template +inline ForwardIterator __stable_partition_aux(ForwardIterator first, + ForwardIterator last, + Predicate pred, Distance*) { + Distance len = 0; + distance(first, last, len); + return __stable_partition(first, last, pred, len, + get_temporary_buffer(len, value_type(first))); +} + +template +inline ForwardIterator stable_partition(ForwardIterator first, + ForwardIterator last, + Predicate pred) { + return __stable_partition_aux(first, last, pred, 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 __quick_sort_loop_aux(RandomAccessIterator first, + RandomAccessIterator last, T*) { + while (last - first > __stl_threshold) { + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1)))); + if (cut - first >= last - cut) { + __quick_sort_loop(cut, last); + last = cut; + } else { + __quick_sort_loop(first, cut); + first = cut; + } + } +} + +template +inline void __quick_sort_loop(RandomAccessIterator first, + RandomAccessIterator last) { + __quick_sort_loop_aux(first, last, value_type(first)); +} + +template +void __quick_sort_loop_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Compare comp) { + while (last - first > __stl_threshold) { + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1), comp)), comp); + if (cut - first >= last - cut) { + __quick_sort_loop(cut, last, comp); + last = cut; + } else { + __quick_sort_loop(first, cut, comp); + first = cut; + } + } +} + +template +inline void __quick_sort_loop(RandomAccessIterator first, + RandomAccessIterator last, Compare comp) { + __quick_sort_loop_aux(first, last, value_type(first), comp); +} + +template +void __unguarded_linear_insert(RandomAccessIterator last, T value) { + RandomAccessIterator next = last; + --next; + while (value < *next) { + *last = *next; + last = 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--; + } + *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 +void sort(RandomAccessIterator first, RandomAccessIterator last) { + __quick_sort_loop(first, last); + __final_insertion_sort(first, last); +} + +template +void sort(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + __quick_sort_loop(first, last, 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*, T*) { + 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*, T*, 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, T*) { + Distance len = (last - first + 1) / 2; + RandomAccessIterator middle = first + len; + if (len > buffer_size) { + __stable_sort_adaptive(first, middle, buffer, buffer_size, (T*)0); + __stable_sort_adaptive(middle, last, buffer, buffer_size, (T*)0); + } else { + __merge_sort_with_buffer(first, middle, buffer, (Distance*)0, (T*)0); + __merge_sort_with_buffer(middle, last, buffer, (Distance*)0, (T*)0); + } + __merge_adaptive(first, middle, last, Distance(middle - first), + Distance(last - middle), buffer, buffer_size, (T*)0); +} + +template +void __stable_sort_adaptive(RandomAccessIterator first, + RandomAccessIterator last, Pointer buffer, + Distance buffer_size, T*, Compare comp) { + Distance len = (last - first + 1) / 2; + RandomAccessIterator middle = first + len; + if (len > buffer_size) { + __stable_sort_adaptive(first, middle, buffer, buffer_size, (T*)0, comp); + __stable_sort_adaptive(middle, last, buffer, buffer_size, (T*)0, comp); + } else { + __merge_sort_with_buffer(first, middle, buffer, (Distance*)0, (T*)0, + comp); + __merge_sort_with_buffer(middle, last, buffer, (Distance*)0, (T*)0, + comp); + } + __merge_adaptive(first, middle, last, Distance(middle - first), + Distance(last - middle), buffer, buffer_size, (T*)0, comp); +} + +template +inline void __stable_sort(RandomAccessIterator first, + RandomAccessIterator last, + pair p, T*) { + if (p.first == 0) { + __inplace_stable_sort(first, last); + return; + } + Distance len = min(p.second, last - first); + copy(first, first + len, raw_storage_iterator(p.first)); + __stable_sort_adaptive(first, last, p.first, p.second, (T*)0); + destroy(p.first, p.first + len); + return_temporary_buffer(p.first); +} + +template +inline void __stable_sort(RandomAccessIterator first, + RandomAccessIterator last, + pair p, T*, Compare comp) { + if (p.first == 0) { + __inplace_stable_sort(first, last, comp); + return; + } + Distance len = min(p.second, last - first); + copy(first, first + len, raw_storage_iterator(p.first)); + __stable_sort_adaptive(first, last, p.first, p.second, (T*)0, comp); + destroy(p.first, p.first + len); + return_temporary_buffer(p.first); +} + +template +inline void __stable_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Distance*) { + __stable_sort(first, last, get_temporary_buffer(Distance(last - first), + (T*)0), (T*)0); +} + +template +inline void __stable_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Distance*, + Compare comp) { + __stable_sort(first, last, get_temporary_buffer(Distance(last - first), + (T*)0), (T*)0, 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++; + 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++; + 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++; + else + *result++ = *first1++; + 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++; + else + *result++ = *first1++; + 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 +OutputIterator __borland_bugfix_copy(InputIterator first, InputIterator last, + OutputIterator result) { +// this is used in __rotate_adaptive to work around some obscure Borland +// bug. It is the same as copy, but with a different (and appropriate) name. + while (first != last) *result++ = *first++; + return result; +} + +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 = __borland_bugfix_copy(middle, last, buffer); + copy_backward(first, middle, last); + return copy(buffer, buffer_end, first); + } else if (len1 <= buffer_size) { + buffer_end = __borland_bugfix_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, T*) { + 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, (T*)0); + __merge_adaptive(new_middle, second_cut, last, len1 - len11, + len2 - len22, buffer, buffer_size, (T*)0); + } +} + +template +void __merge_adaptive(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Distance len1, Distance len2, + Pointer buffer, Distance buffer_size, T*, 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, (T*)0, comp); + __merge_adaptive(new_middle, second_cut, last, len1 - len11, + len2 - len22, buffer, buffer_size, (T*)0, comp); + } +} + +template +void __inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Distance len1, Distance len2, + pair p, T*) { + if (p.first == 0) { + __merge_without_buffer(first, middle, last, len1, len2); + return; + } + Distance len = min(p.second, len1 + len2); + fill_n(raw_storage_iterator(p.first), len, *first); + __merge_adaptive(first, middle, last, len1, len2, p.first, p.second, (T*)0); + destroy(p.first, p.first + len); + return_temporary_buffer(p.first); +} + +template +void __inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Distance len1, Distance len2, + pair p, T*, Compare comp) { + if (p.first == 0) { + __merge_without_buffer(first, middle, last, len1, len2, comp); + return; + } + Distance len = min(p.second, len1 + len2); + fill_n(raw_storage_iterator(p.first), len, *first); + __merge_adaptive(first, middle, last, len1, len2, p.first, p.second, (T*)0, + comp); + destroy(p.first, p.first + len); + return_temporary_buffer(p.first); +} + +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); + __inplace_merge(first, middle, last, len1, len2, + get_temporary_buffer(len1 + len2, (T*)0), (T*)0); +} + +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); + __inplace_merge(first, middle, last, len1, len2, + get_temporary_buffer(len1 + len2, (T*)0), (T*)0, + 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++; + else if (*first2 < *first1) + *result++ = *first2++; + else { + *result++ = *first1++; + first2++; + } + 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++; + else if (comp(*first2, *first1)) + *result++ = *first2++; + else { + *result++ = *first1++; + ++first2; + } + 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++; + ++first2; + } + 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++; + ++first2; + } + 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++; + 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++; + 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++; + else if (*first2 < *first1) + *result++ = *first2++; + 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++; + else if (comp(*first2, *first1)) + *result++ = *first2++; + 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--; + 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--; + 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--; + 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--; + 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) { + while (first != last) + init = init + *first++; + return init; +} + +template +T accumulate(InputIterator first, InputIterator last, T init, + BinaryOperation binary_op) { + while (first != last) + init = binary_op(init, *first++); + return init; +} + +template +T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) { + while (first1 != last1) + init = init + (*first1++ * *first2++); + return init; +} + +template +T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2) { + while (first1 != last1) + 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); +} + +template +void iota(ForwardIterator first, ForwardIterator last, T value) { + while (first != last) *first++ = value++; +} + +#endif + diff --git a/gnu/lib/libg++/libstdc++/stl/algobase.h b/gnu/lib/libg++/libstdc++/stl/algobase.h new file mode 100644 index 00000000000..21cea93b5f8 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/algobase.h @@ -0,0 +1,232 @@ +/* + * + * 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 ALGOBASE_H +#define ALGOBASE_H + +#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; +} + +template +inline const T& min(const T& a, const T& b) { + return b < a ? b : a; +} + +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) { + return a < b ? b : a; +} + +template +inline const T& max(const T& a, const T& b, Compare comp) { + return comp(a, b) ? b : a; +} + +template +void __distance(InputIterator first, InputIterator last, Distance& n, + input_iterator_tag) { + while (first != last) { ++first; ++n; } +} + +template +void __distance(ForwardIterator first, ForwardIterator last, Distance& n, + forward_iterator_tag) { + while (first != last) { ++first; ++n; } +} + +template +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)); +} + +template +void __advance(InputIterator& i, Distance n, input_iterator_tag) { + while (n--) ++i; +} + +template +void __advance(ForwardIterator& i, Distance n, forward_iterator_tag) { + while (n--) ++i; +} + +template +void __advance(BidirectionalIterator& i, Distance n, + bidirectional_iterator_tag) { + if (n >= 0) + while (n--) ++i; + else + while (n++) --i; +} + +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 +void destroy(ForwardIterator first, ForwardIterator last) { + while (first != last) { + /* Borland bug */ + destroy(&*first); + ++first; + //destroy(&*first++); + } +} + +template +ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result) { + while (first != last) construct(&*result++, *first++); + return result; +} + +template +void uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x) { + while (first != last) construct(&*first++, x); +} + +template +ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, + const T& x) { + while (n--) construct(&*first++, x); + return first; +} + +template +OutputIterator copy(InputIterator first, InputIterator last, + OutputIterator result) { + while (first != last) *result++ = *first++; + return result; +} + +template +BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, + BidirectionalIterator1 last, + BidirectionalIterator2 result) { + while (first != last) *--result = *--last; + return result; +} + +template +void fill(ForwardIterator first, ForwardIterator last, const T& value) { + while (first != last) *first++ = value; +} + +template +OutputIterator fill_n(OutputIterator first, Size n, const T& value) { + while (n-- > 0) *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) { + return mismatch(first1, last1, first2).first == last1; +} + +template +inline bool equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate binary_pred) { + return mismatch(first1, last1, first2, binary_pred).first == last1; +} + +template +bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + 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) { + while (first1 != last1 && first2 != last2) { + if (comp(*first1, *first2)) return true; + if (comp(*first2++, *first1++)) return false; + } + return first1 == last1 && first2 != last2; +} + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/bool.h b/gnu/lib/libg++/libstdc++/stl/bool.h new file mode 100644 index 00000000000..9d86aac99c6 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/bool.h @@ -0,0 +1,20 @@ +#ifndef __GNUC__ +/* + * + * 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. + * + */ + +#define bool int +#define true 1 +#define false 0 +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/bvector.h b/gnu/lib/libg++/libstdc++/stl/bvector.h new file mode 100644 index 00000000000..f9fe10655cb --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/bvector.h @@ -0,0 +1,421 @@ +/* + * + * 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. + * + */ + +// vector is replaced by bit_vector at present because bool is not +// implemented. + +#ifndef BVECTOR_H +#define BVECTOR_H + +#include +#include +#include +#ifndef __GNUG__ +#include +#endif + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int))) + +class bit_vector { +public: + typedef Allocator vector_allocator; + typedef bool value_type; + typedef vector_allocator::size_type size_type; + typedef vector_allocator::difference_type 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; + class iterator : public random_access_iterator { + friend class bit_vector; + friend class const_iterator; + 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<(iterator x) const { + return p < x.p || (p == x.p && offset < x.offset); + } + }; + + class const_iterator + : public random_access_iterator { + friend class bit_vector; + 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 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_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: + static Allocator static_allocator; + iterator start; + iterator finish; + unsigned int* end_of_storage; + unsigned int* bit_alloc(size_type n) { + return static_allocator.allocate((n + __WORD_BIT - 1)/__WORD_BIT); + } + 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); + 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 static_allocator.max_size(); } + 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 = bool()) { + initialize(n); + fill(start.p, end_of_storage, value ? ~0 : 0); + } + bit_vector(const self& x) { + initialize(x.size()); + copy(x.begin(), x.end(), start); + } + bit_vector(const_iterator first, const_iterator last) { + size_type n = 0; + distance(first, last, n); + initialize(n); + copy(first, last, start); + } + ~bit_vector() { static_allocator.deallocate(start.p); } + self& operator=(const self& x) { + if (&x == this) return *this; + if (x.size() > capacity()) { + static_allocator.deallocate(start.p); + 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)); + static_allocator.deallocate(start.p); + 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) { + size_type n = position - begin(); + if (finish.p != end_of_storage && position == end()) + *finish++ = x; + else + insert_aux(position, x); + return begin() + n; + } + void insert(iterator position, const_iterator first, + const_iterator last); + void insert(iterator position, size_type n, bool 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); + } +}; + +Allocator bit_vector::static_allocator; + +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()); +} + +void swap(bit_vector::reference x, bit_vector::reference y) { + bool tmp = x; + x = y; + y = tmp; +} + +void bit_vector::insert_aux(iterator position, bool x) { + if (finish.p != end_of_storage) { + copy_backward(position, finish - 1, finish); + *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); + static_allocator.deallocate(start.p); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } +} + +void bit_vector::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); + static_allocator.deallocate(start.p); + end_of_storage = q + (n + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } +} + +void bit_vector::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); + static_allocator.deallocate(start.p); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } +} + +#undef Allocator +#undef __WORD_BIT + +#endif + + diff --git a/gnu/lib/libg++/libstdc++/stl/configure.in b/gnu/lib/libg++/libstdc++/stl/configure.in new file mode 100644 index 00000000000..d164e2fb219 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/configure.in @@ -0,0 +1,25 @@ +# 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=iterator.h +srcname="Standard Template Library" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +target_makefile_frag=../target-mkfrag + +LIBDIR=yes +TO_TOPDIR=../../ +ALL='stl.list' +XCXXINCLUDES="-I${srcdir} -I${srcdir}/.. -I"'$(MULTITOP)/'"${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" +(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} + +# post-target: + +# We need multilib support. +. ${srcdir}/../../cfg-ml-pos.in diff --git a/gnu/lib/libg++/libstdc++/stl/defalloc.h b/gnu/lib/libg++/libstdc++/stl/defalloc.h new file mode 100644 index 00000000000..388e58fd744 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/defalloc.h @@ -0,0 +1,176 @@ +/* + * + * 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 DEFALLOC_H +#define DEFALLOC_H + +#include +#include +#include +#include +#include +#include + +#ifndef __GNUG__ +inline void* operator new(size_t, void* p) {return p;} +#endif + +/* + * the following template function is replaced by the following two functions + * due to the fact that the Borland compiler doesn't change prediff_t type + * to type long when compile with -ml or -mh. + +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 T* allocate(int size, T*) { + set_new_handler(0); + T* tmp = (T*)(::operator new((unsigned int)(size * sizeof(T)))); + if (tmp == 0) { + cerr << "out of memory" << endl; + exit(1); + } + return tmp; +} + +template +inline T* allocate(long size, T*) { + set_new_handler(0); + T* tmp = (T*)(::operator new((unsigned long)(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 +inline void destroy(T* pointer) { + pointer->~T(); +} + +inline void destroy(char*) {} +inline void destroy(unsigned char*) {} +inline void destroy(short*) {} +inline void destroy(unsigned short*) {} +inline void destroy(int*) {} +inline void destroy(unsigned int*) {} +inline void destroy(long*) {} +inline void destroy(unsigned long*) {} +inline void destroy(float*) {} +inline void destroy(double*) {} +inline void destroy(char**) {} +inline void destroy(unsigned char**) {} +inline void destroy(short**) {} +inline void destroy(unsigned short**) {} +inline void destroy(int**) {} +inline void destroy(unsigned int**) {} +inline void destroy(long**) {} +inline void destroy(unsigned long**) {} +inline void destroy(float**) {} +inline void destroy(double**) {} + +inline void destroy(char*, char*) {} +inline void destroy(unsigned char*, unsigned char*) {} +inline void destroy(short*, short*) {} +inline void destroy(unsigned short*, unsigned short*) {} +inline void destroy(int*, int*) {} +inline void destroy(unsigned int*, unsigned int*) {} +inline void destroy(long*, long*) {} +inline void destroy(unsigned long*, unsigned long*) {} +inline void destroy(float*, float*) {} +inline void destroy(double*, double*) {} +inline void destroy(char**, char**) {} +inline void destroy(unsigned char**, unsigned char**) {} +inline void destroy(short**, short**) {} +inline void destroy(unsigned short**, unsigned short**) {} +inline void destroy(int**, int**) {} +inline void destroy(unsigned int**, unsigned int**) {} +inline void destroy(long**, long**) {} +inline void destroy(unsigned long**, unsigned long**) {} +inline void destroy(float**, float**) {} +inline void destroy(double**, double**) {} + +template +inline void construct(T1* p, const T2& value) { + new (p) T1(value); +} + +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; +#ifdef __GNUG__ + static pointer allocate(size_type n) { + return ::allocate((difference_type)n, (pointer)0); + } + static void deallocate(pointer p) { ::deallocate(p); } + static pointer address(reference x) { return (pointer)&x; } + static const_pointer const_address(const_reference x) { + return (const_pointer)&x; + } + static size_type init_page_size() { + return max(size_type(1), size_type(4096/sizeof(T))); + } + static size_type max_size() { + return max(size_type(1), size_type(UINT_MAX/sizeof(T))); + } +#else + 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))); + } +#endif +}; + +class allocator { +public: + typedef void* pointer; +}; + + + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/deque.h b/gnu/lib/libg++/libstdc++/stl/deque.h new file mode 100644 index 00000000000..f05de7b09f0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/deque.h @@ -0,0 +1,681 @@ +/* + * + * 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 DEQUE_H +#define DEQUE_H + +#include +#include +#include +#ifndef __GNUG__ +#include +#endif + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#ifndef deque +#define deque deque +#endif + +template +class deque { +public: + class iterator; + class const_iterator; + friend class iterator; + friend class const_iterator; +public: + typedef T value_type; + typedef Allocator data_allocator_type; + typedef Allocator::pointer pointer; + typedef Allocator::reference reference; + typedef Allocator::const_reference const_reference; + typedef Allocator::size_type size_type; + typedef Allocator::difference_type difference_type; + typedef Allocator map_allocator_type; +protected: + static data_allocator_type data_allocator; +#ifdef __GNUG__ + // static // Too bad -- I don't like this hack very much... + static size_type buffer_size() { + return data_allocator.init_page_size(); + } +#define __dq_buffer_size buffer_size() +#else + static size_type buffer_size; +#define __dq_buffer_size buffer_size +#endif + static map_allocator_type map_allocator; + typedef Allocator::pointer map_pointer; +public: + class iterator : public random_access_iterator { + friend class deque; + friend class const_iterator; + protected: + pointer current; + pointer first; + pointer last; + map_pointer node; + iterator(pointer x, map_pointer y) + : current(x), first(*y), last(*y + __dq_buffer_size), node(y) {} + public: + iterator() : current(0), first(0), last(0), node(0) {} + reference operator*() const { return *current; } + difference_type operator-(const iterator& x) const { + return node == x.node + ? current - x.current + : difference_type(__dq_buffer_size * (node - x.node - 1) + + (current - first) + (x.last - x.current)); + } + iterator& operator++() { + if (++current == last) { + first = *(++node); + current = first; + last = first + __dq_buffer_size; + } + return *this; + } + iterator operator++(int) { + iterator tmp = *this; + ++*this; + return tmp; + } + iterator& operator--() { + if (current == first) { + first = *(--node); + last = first + __dq_buffer_size; + current = last; + } + --current; + return *this; + } + iterator operator--(int) { + iterator tmp = *this; + --*this; + return tmp; + } + iterator& operator+=(difference_type n) { + difference_type offset = n + (current - first); + difference_type num_node_to_jump = offset >= 0 + ? offset / __dq_buffer_size + : -((-offset + __dq_buffer_size - 1) / __dq_buffer_size); + if (num_node_to_jump == 0) + current += n; + else { + node = node + num_node_to_jump; + first = *node; + last = first + __dq_buffer_size; + current = first + (offset - num_node_to_jump * __dq_buffer_size); + } + return *this; + } + iterator& operator-=(difference_type n) { return *this += -n; } + iterator operator+(difference_type n) const { + iterator tmp = *this; + return tmp += n; + } + iterator operator-(difference_type n) const { + iterator tmp = *this; + return tmp -= n; + } + reference operator[](difference_type n) { return *(*this + n); } + bool operator==(const iterator& x) const { + return current == x.current || + ((current == first || x.current == x.first) && + *this - x == 0); + } + bool operator<(const iterator& x) const { + return (node == x.node) ? (current < x.current) : (node < x.node); + } + }; + class const_iterator : public random_access_iterator { + friend class deque; + protected: + pointer current; + pointer first; + pointer last; + map_pointer node; + const_iterator(pointer x, map_pointer y) + : current(x), first(*y), last(*y + __dq_buffer_size), node(y) {} + public: + const_iterator() : current(0), first(0), last(0), node(0) {} + const_iterator(const iterator& x) + : current(x.current), first(x.first), last(x.last), node(x.node) {} + const_reference operator*() const { return *current; } + difference_type operator-(const const_iterator& x) const { + return node == x.node + ? current - x.current + : difference_type(__dq_buffer_size * (node - x.node - 1) + + (current - first) + (x.last - x.current)); + } + const_iterator& operator++() { + if (++current == last) { + first = *(++node); + current = first; + last = first + __dq_buffer_size; + } + return *this; + } + const_iterator operator++(int) { + const_iterator tmp = *this; + ++*this; + return tmp; + } + const_iterator& operator--() { + if (current == first) { + first = *(--node); + last = first + __dq_buffer_size; + current = last; + } + --current; + return *this; + } + const_iterator operator--(int) { + const_iterator tmp = *this; + --*this; + return tmp; + } + const_iterator& operator+=(difference_type n) { + difference_type offset = n + (current - first); + difference_type num_node_to_jump = offset >= 0 + ? offset / __dq_buffer_size + : -((-offset + __dq_buffer_size - 1) / __dq_buffer_size); + if (num_node_to_jump == 0) + current += n; + else { + node = node + num_node_to_jump; + first = *node; + last = first + __dq_buffer_size; + current = first + (offset - num_node_to_jump * __dq_buffer_size); + } + return *this; + } + const_iterator& operator-=(difference_type n) { return *this += -n; } + const_iterator operator+(difference_type n) const { + const_iterator tmp = *this; + return tmp += n; + } + const_iterator operator-(difference_type n) const { + const_iterator tmp = *this; + return tmp -= n; + } + const_reference operator[](difference_type n) { + return *(*this + n); + } + bool operator==(const const_iterator& x) const { + return current == x.current || + ((current == first || x.current == x.first) && + *this - x == 0); + } + bool operator<(const const_iterator& x) const { + return (node == x.node) ? (current < x.current) : (node < x.node); + } + }; + typedef reverse_iterator const_reverse_iterator; + typedef reverse_iterator + reverse_iterator; +protected: + iterator start; + iterator finish; + size_type length; + map_pointer map; + size_type map_size; + + void allocate_at_begin(); + void allocate_at_end(); + void deallocate_at_begin(); + void deallocate_at_end(); + +public: + deque() : start(), finish(), length(0), map(0), map_size(0) { +#ifndef __GNUG__ + __dq_buffer_size = data_allocator.init_page_size(); +#endif + } + 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()); + } + bool empty() const { return length == 0; } + size_type size() const { return length; } + size_type max_size() const { return data_allocator.max_size(); } + reference operator[](size_type n) { return *(begin() + n); } + const_reference operator[](size_type n) const { return *(begin() + 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_front(const T& x) { + if (empty() || begin().current == begin().first) + allocate_at_begin(); + --start.current; + construct(start.current, x); + ++length; + if (end().current == end().last) allocate_at_end(); + } + void push_back(const T& x) { + if (empty()) allocate_at_end(); + construct(finish.current, x); + ++finish.current; + ++length; + if (end().current == end().last) allocate_at_end(); + } + void pop_front() { + destroy(start.current); + ++start.current; + --length; + if (empty() || begin().current == begin().last) + deallocate_at_begin(); + } + void pop_back() { + if (end().current == end().first) deallocate_at_end(); + --finish.current; + destroy(finish.current); + --length; + if (empty()) deallocate_at_end(); + } + void swap(deque& x) { + ::swap(start, x.start); + ::swap(finish, x.finish); + ::swap(length, x.length); + ::swap(map, x.map); + ::swap(map_size, x.map_size); + } +#ifdef __GNUG__ + iterator insert(iterator position, const T& x) { + return insert(deque_iterator(position), x); + } + deque_iterator insert(deque_iterator position, const T& x); + void insert(iterator position, size_type n, const T& x) { + insert(deque_iterator(position), n, x); + } + void insert(deque_iterator(position), size_type n, const T& x); +// template void insert(iterator position, +// Iterator first, Iterator last); + void insert(iterator position, const T* first, const T* last) { + insert(deque_iterator(position), first, last); + } + void insert(deque_iterator position, const T* first, const T* last); + void erase(iterator position) { + erase(deque_iterator(position)); + } + void erase(deque_iterator position); + void erase(iterator first, iterator last) { + erase(deque_iterator(first), deque_iterator(last)); + } + void erase(deque_iterator first, deque_iterator last); +#else + iterator insert(iterator position, const T& x); + void insert(iterator position, size_type n, const T& x); +// template void insert(iterator position, +// Iterator first, Iterator last); + void insert(iterator position, const T* first, const T* last); + void erase(iterator position); + void erase(iterator first, iterator last); +#endif + deque(size_type n, const T& value = T()) + : start(), finish(), length(0), map(0), map_size(0) { +#ifndef __GNUG__ + __dq_buffer_size = data_allocator.init_page_size(); +#endif + insert(begin(), n, value); + } +// template deque(Iterator first, Iterator last); + deque(const T* first, const T* last) + : start(), finish(), length(0), map(0), map_size(0) { +#ifndef __GNUG__ + __dq_buffer_size = data_allocator.init_page_size(); +#endif + copy(first, last, back_inserter(*this)); + } + deque(const deque& x) + : start(), finish(), length(0), map(0), map_size(0) { +#ifndef __GNUG__ + __dq_buffer_size = data_allocator.init_page_size(); +#endif + copy(x.begin(), x.end(), back_inserter(*this)); + } + deque& operator=(const deque& x) { + if (this != &x) + if (size() >= x.size()) + erase(copy(x.begin(), x.end(), begin()), end()); + else + copy(x.begin() + size(), x.end(), + inserter(*this, copy(x.begin(), x.begin() + size(), + begin()))); + return *this; + } + ~deque(); +#ifdef __GNUG__ + friend T* value_type(const iterator&) { + return (T*)(0); + } +#endif +}; + +#ifdef __GNUG__ +template +struct deque_iterator: deque::iterator { + deque_iterator(deque::iterator i) : deque::iterator(i) {} +}; + +template +inline T* value_type(const deque_iterator&) { + return (T*)(0); +} +#else +template +deque::data_allocator_type deque::data_allocator; + +template +deque::map_allocator_type deque::map_allocator; + +template +deque::size_type deque::__dq_buffer_size = 0; +// should be data_allocator.init_page_size(); // Borland bug +#endif + +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()); +} + +template +deque::~deque() { while (!empty()) pop_front(); } + +template +void deque::allocate_at_begin() { + pointer p = data_allocator.allocate(__dq_buffer_size); + if (!empty()) { + if (start.node == map) { + difference_type i = finish.node - start.node; + map_size = (i + 1) * 2; +#ifdef __GNU_G__ + map_pointer tmp = map_allocator_type::allocate(map_size); + copy(start.node, finish.node + 1, tmp + map_size / 4 + 1); + map_allocator_type::deallocate(map); +#else + map_pointer tmp = map_allocator.allocate(map_size); + copy(start.node, finish.node + 1, tmp + map_size / 4 + 1); + map_allocator.deallocate(map); +#endif + map = tmp; + map[map_size / 4] = p; + start = iterator(p + __dq_buffer_size, map + map_size / 4); + finish = iterator(finish.current, map + map_size / 4 + i + 1); + } else { +#ifdef __GNUG__ + map_size = map_allocator_type::init_page_size(); + map = map_allocator_type::allocate(map_size); +#else + *--start.node = p; + start = iterator(p + __dq_buffer_size, start.node); +#endif + } + } else { +#ifdef __GNUG__ + map_size = map_allocator_type::init_page_size(); + map = map_allocator_type::allocate(map_size); +#else + map_size = map_allocator.init_page_size(); + map = map_allocator.allocate(map_size); +#endif + map[map_size / 2] = p; + start = iterator(p + __dq_buffer_size / 2 + 1, map + map_size / 2); + finish = start; + } +} + +template +void deque::allocate_at_end() { + pointer p = data_allocator.allocate(__dq_buffer_size); + if (!empty()) { + if (finish.node == map + map_size - 1) { + difference_type i = finish.node - start.node; + map_size = (i + 1) * 2; +#ifdef __GNUG__ + map_pointer tmp = map_allocator_type::allocate(map_size); + copy(start.node, finish.node + 1, tmp + map_size / 4); + map_allocator_type::deallocate(map); +#else + map_pointer tmp = map_allocator.allocate(map_size); + copy(start.node, finish.node + 1, tmp + map_size / 4); + map_allocator.deallocate(map); +#endif + map = tmp; + map[map_size / 4 + i + 1] = p; + start = iterator(start.current, map + map_size / 4); + finish = iterator(p, map + map_size / 4 + i + 1); + } else { + *++finish.node = p; + finish = iterator(p, finish.node); + } + } else { +#ifdef __GNUG__ + map_size = map_allocator_type::init_page_size(); + map = map_allocator_type::allocate(map_size); +#else + map_size = map_allocator.init_page_size(); + map = map_allocator.allocate(map_size); +#endif + map[map_size / 2] = p; + start = iterator(p + __dq_buffer_size / 2, map + map_size / 2); + finish = start; + } +} + +template +void deque::deallocate_at_begin() { + data_allocator.deallocate(*start.node++); + if (empty()) { + if (finish.current == finish.first) + data_allocator.deallocate(*start.node); + start = iterator(); + finish = start; +#ifdef __GNUG__ + map_allocator.deallocate(map); +#else + map_allocator.deallocate(map); +#endif + } else + start = iterator(*start.node, start.node); +} + +template +void deque::deallocate_at_end() { + data_allocator.deallocate(*finish.node--); + if (empty()) { + start = iterator(); + finish = start; +#ifdef __GNUG__ + map_allocator.deallocate(map); +#else + map_allocator.deallocate(map); +#endif + } else + finish = iterator(*finish.node + __dq_buffer_size, finish.node); +} + +template +#ifdef __GNUG__ +deque_iterator +deque::insert(deque_iterator posn, const T& x) { + iterator position = posn; +#else +deque::iterator deque::insert(iterator position, const T& x) { +#endif + if (position == begin()) { + push_front(x); + return begin(); + } else if (position == end()) { + push_back(x); + return end() - 1; + } else { + difference_type index = position - begin(); + if (index < length) { + push_front(*begin()); + copy(begin() + 2, begin() + index + 1, begin() + 1); + } else { + push_back(*(end() - 1)); + copy_backward(begin() + index, end() - 2, end() - 1); + } + *(begin() + index) = x; + return begin() + index; + } +} + +template +#ifdef __GNUG__ +void deque::insert(deque_iterator posn, + size_t n, // BAD HACK + const T& x) { + iterator position = posn; +#else +void deque::insert(iterator position, size_type n, const T& x) { +#endif + difference_type index = position - begin(); + difference_type remainder = length - index; + if (remainder > index) { + if (n > index) { + difference_type m = n - index; + while (m-- > 0) push_front(x); + difference_type i = index; + while (i--) push_front(*(begin() + n - 1)); + fill(begin() + n, begin() + n + index, x); + } else { + difference_type i = n; + while (i--) push_front(*(begin() + n - 1)); + copy(begin() + n + n, begin() + n + index, begin() + n); + fill(begin() + index, begin() + n + index, x); + } + } else { + difference_type orig_len = index + remainder; + if (n > remainder) { + difference_type m = n - remainder; + while (m-- > 0) push_back(x); + difference_type i = 0; + while (i < remainder) push_back(*(begin() + index + i++)); + fill(begin() + index, begin() + orig_len, x); + } else { + difference_type i = 0; + while (i < n) push_back(*(begin() + orig_len - n + i++)); + copy_backward(begin() + index, begin() + orig_len - n, + begin() + orig_len); + fill(begin() + index, begin() + index + n, x); + } + } +} + +template +void deque::insert +#ifdef __GNUG__ +(deque_iterator posn, const T* first, const T* last) +{ + iterator position = posn; +#else +(iterator position, const T* first, const T* last) +{ +#endif + difference_type index = position - begin(); + difference_type remainder = length - index; + size_type n = 0; + distance(first, last, n); + if (remainder > index) { + if (n > index) { + const T* m = last - index; + while (m != first) push_front(*--m); + difference_type i = index; + while (i--) push_front(*(begin() + n - 1)); + copy(last - index, last, begin() + n); + } else { + difference_type i = n; + while (i--) push_front(*(begin() + n - 1)); + copy(begin() + n + n, begin() + n + index, begin() + n); + copy(first, last, begin() + index); + } + } else { + difference_type orig_len = index + remainder; + if (n > remainder) { + const T* m = first + remainder; + while (m != last) push_back(*m++); + difference_type i = 0; + while (i < remainder) push_back(*(begin() + index + i++)); + copy(first, first + remainder, begin() + index); + } else { + difference_type i = 0; + while (i < n) push_back(*(begin() + orig_len - n + i++)); + copy_backward(begin() + index, begin() + orig_len - n, + begin() + orig_len); + copy(first, last, begin() + index); + } + } +} + +template +#ifdef __GNUG__ +void deque::erase(deque_iterator posn) { + iterator position = posn; +#else +void deque::erase(iterator position) { +#endif + if (end() - position > position - begin()) { + copy_backward(begin(), position, position + 1); + pop_front(); + } else { + copy(position + 1, end(), position); + pop_back(); + } +} + +template +#ifdef __GNUG__ +void deque::erase(deque_iterator fi, deque_iterator la) { + iterator first = fi; + iterator last = la; + difference_type n = last - first; +#else +void deque::erase(iterator first, iterator last) { + difference_type n = last - first; +#endif + if (end() - last > first - begin()) { + copy_backward(begin(), first, last); + while(n-- > 0) pop_front(); + } else { + copy(last, end(), first); + while(n-- > 0) pop_back(); + } +} + +#undef Allocator +#undef deque + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/faralloc.h b/gnu/lib/libg++/libstdc++/stl/faralloc.h new file mode 100644 index 00000000000..b29602cc632 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/faralloc.h @@ -0,0 +1,120 @@ +/* + * + * 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 FARALLOC_H +#define FARALLOC_H + +#include +#include +#include +#include +#include +#include + +template +inline random_access_iterator_tag iterator_category(const T __far *) { + return random_access_iterator_tag(); +} + +template +inline T* value_type(const T __far *) { return (T*)(0); } + +template +inline long* distance_type(const T __far*) { return (long*)(0); } + +inline void destroy(char __far *) {} +inline void destroy(unsigned char __far *) {} +inline void destroy(short __far *) {} +inline void destroy(unsigned short __far *) {} +inline void destroy(int __far *) {} +inline void destroy(unsigned int __far *) {} +inline void destroy(long __far *) {} +inline void destroy(unsigned long __far *) {} +inline void destroy(float __far *) {} +inline void destroy(double __far *) {} + +inline void destroy(char __far *, char __far *) {} +inline void destroy(unsigned char __far *, unsigned char __far *) {} +inline void destroy(short __far *, short __far *) {} +inline void destroy(unsigned short __far *, unsigned short __far *) {} +inline void destroy(int __far *, int __far *) {} +inline void destroy(unsigned int __far *, unsigned int __far *) {} +inline void destroy(long __far *, long __far *) {} +inline void destroy(unsigned long __far *, unsigned long __far *) {} +inline void destroy(float __far *, float __far *) {} +inline void destroy(double __far *, double __far *) {} + +inline void __far * operator new(size_t, void __far *p) { return p; } + +template +inline T __far * allocate(long size, T __far * p) { + set_new_handler(0); + T __far * tmp = + (T __far *)(::operator new((unsigned long)(size * sizeof(T)))); + if (tmp == 0) { + cerr << "out of memory" << endl; + exit(1); + } + return tmp; +} + +template +inline void deallocate(T __far * buffer) { + ::operator delete(buffer); +} + +template +inline void construct( T1 __far *p, const T2& value ) +{ + new(p)T1(value); +} + +template +inline void destroy( T __far * pointer ) { + pointer->~T(); +} + +template +class far_allocator { +public: + typedef T value_type; + typedef T __far * pointer; + typedef const T __far * const_pointer; + typedef T __far & reference; + typedef const T __far & const_reference; + typedef unsigned long size_type; + typedef long 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(ULONG_MAX/sizeof(T))); + } +}; + +class far_allocator { +public: + typedef void __far * pointer; +}; + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/fdeque.h b/gnu/lib/libg++/libstdc++/stl/fdeque.h new file mode 100644 index 00000000000..7b512b62dc2 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/fdeque.h @@ -0,0 +1,39 @@ +/* + * + * 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 FDEQUE_H +#define FDEQUE_H + +#ifdef DEQUE_H +#undef DEQUE_H +#define __DEQUE_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define deque far_deque +#include +#include + +#undef DEQUE_H + +#ifdef __DEQUE_WAS_DEFINED +#define DEQUE_H +#undef __DEQUE_WAS_DEFINED +#endif + +#undef Allocator +#undef deque + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/flist.h b/gnu/lib/libg++/libstdc++/stl/flist.h new file mode 100644 index 00000000000..35fe9bf6288 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/flist.h @@ -0,0 +1,39 @@ +/* + * + * 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 FLIST_H +#define FLIST_H + +#ifdef LIST_H +#undef LIST_H +#define __LIST_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define list far_list +#include +#include + +#undef LIST_H + +#ifdef __LIST_WAS_DEFINED +#define LIST_H +#undef __LIST_WAS_DEFINED +#endif + +#undef Allocator +#undef list + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/fmap.h b/gnu/lib/libg++/libstdc++/stl/fmap.h new file mode 100644 index 00000000000..65aa2091fc2 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/fmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 FMAP_H +#define FMAP_H + +#ifdef MAP_H +#undef MAP_H +#undef TREE_H +#define __MAP_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define map far_map +#define rb_tree far_rb_tree +#include +#include + +#undef MAP_H +#undef TREE_H + +#ifdef __MAP_WAS_DEFINED +#define MAP_H +#define TREE_H +#undef __MAP_WAS_DEFINED +#endif + +#undef Allocator +#undef map +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/fmultmap.h b/gnu/lib/libg++/libstdc++/stl/fmultmap.h new file mode 100644 index 00000000000..ecb5cd4fdef --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/fmultmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 FMULTIMAP_H +#define FMULTIMAP_H + +#ifdef MULTIMAP_H +#undef MULTIMAP_H +#undef TREE_H +#define __MULTIMAP_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define multimap far_multimap +#define rb_tree far_rb_tree +#include +#include + +#undef MULTIMAP_H +#undef TREE_H + +#ifdef __MULTIMAP_WAS_DEFINED +#define MULTIMAP_H +#define TREE_H +#undef __MULTIMAP_WAS_DEFINED +#endif + +#undef Allocator +#undef multimap +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/fmultset.h b/gnu/lib/libg++/libstdc++/stl/fmultset.h new file mode 100644 index 00000000000..ca9887646ce --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/fmultset.h @@ -0,0 +1,44 @@ +/* + * + * 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 FMULTISET_H +#define FMULTISET_H + +#ifdef MULTISET_H +#undef MULTISET_H +#undef TREE_H +#define __MULTISET_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define multiset far_multiset +#define rb_tree far_rb_tree +#include +#include + +#undef MULTISET_H +#undef TREE_H + +#ifdef __MULTISET_WAS_DEFINED +#define MULTISET_H +#define TREE_H +#undef __MULTISET_WAS_DEFINED +#endif + +#undef Allocator +#undef multiset +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/fset.h b/gnu/lib/libg++/libstdc++/stl/fset.h new file mode 100644 index 00000000000..b374bc435a6 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/fset.h @@ -0,0 +1,44 @@ +/* + * + * 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 FSET_H +#define FSET_H + +#ifdef SET_H +#undef SET_H +#undef TREE_H +#define __SET_WAS_DEFINED +#endif + +#define Allocator far_allocator +#define set far_set +#define rb_tree far_rb_tree +#include +#include + +#undef SET_H +#undef TREE_H + +#ifdef __SET_WAS_DEFINED +#define SET_H +#define TREE_H +#undef __SET_WAS_DEFINED +#endif + +#undef Allocator +#undef set +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/function.h b/gnu/lib/libg++/libstdc++/stl/function.h new file mode 100644 index 00000000000..46fe55569bb --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/function.h @@ -0,0 +1,282 @@ +/* + * + * 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 FUNCTION_H +#define FUNCTION_H + +#ifndef __GNUG__ +#include +#endif + +template +inline bool operator!=(const T1& x, const T2& y) { + return !(x == y); +} + +template +inline bool operator>(const T1& x, const T2& y) { + return y < x; +} + +template +inline bool operator<=(const T1& x, const T2& y) { + return !(y < x); +} + +template +inline bool operator>=(const T1& x, const T2& 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 : binary_function { + T operator()(const T& x, const T& y) const { return x + y; } +}; + +template +struct minus : binary_function { + T operator()(const T& x, const T& y) const { return x - y; } +}; + +template +struct times : binary_function { + T operator()(const T& x, const T& y) const { return x * y; } +}; + +template +struct divides : binary_function { + T operator()(const T& x, const T& y) const { return x / y; } +}; + +template +#ifdef __GNU__ +struct modulus { + typedef T first_argument_type; + typedef T second_argument_type; + typedef T result_type; + T operator()(const T& x, const T& y) const { return x % y; } +}; +#else +struct modulus : binary_function { + T operator()(const T& x, const T& y) const { return x % y; } +}; +#endif + +template +struct negate : unary_function { + T operator()(const T& x) const { return -x; } +}; + +template +struct equal_to : binary_function { + bool operator()(const T& x, const T& y) const { return x == y; } +}; + +template +struct not_equal_to : binary_function { + bool operator()(const T& x, const T& y) const { return x != y; } +}; + +template +struct greater : binary_function { + bool operator()(const T& x, const T& y) const { return x > y; } +}; + +template +struct less : binary_function { + bool operator()(const T& x, const T& y) const { return x < y; } +}; + +template +struct greater_equal : binary_function { + bool operator()(const T& x, const T& y) const { return x >= y; } +}; + +template +struct less_equal : binary_function { + bool operator()(const T& x, const T& y) const { return x <= y; } +}; + +template +struct logical_and : binary_function { + bool operator()(const T& x, const T& y) const { return x && y; } +}; + +template +struct logical_or : binary_function { + bool operator()(const T& x, const T& y) const { return x || y; } +}; + +template +struct logical_not : unary_function { + bool operator()(const T& x) const { return !x; } +}; + +template +class unary_negate : public unary_function { +protected: + Predicate pred; +public: + unary_negate(const Predicate& x) : pred(x) {} + bool operator()(const argument_type& x) const { return !pred(x); } +}; + +template +unary_negate not1(const Predicate& pred) { + return unary_negate(pred); +} + +template +class binary_negate + : public binary_function { +protected: + Predicate pred; +public: + 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 +binary_negate not2(const Predicate& pred) { + return binary_negate(pred); +} + +template +class binder1st : public unary_function { +protected: + Operation op; + Operation::first_argument_type value; +public: + binder1st(const Operation& x, const Operation::first_argument_type& y) + : op(x), value(y) {} + result_type operator()(const argument_type& x) const { + return op(value, x); + } +}; + +template +binder1st bind1st(const Operation& op, const T& x) { + return binder1st(op, Operation::first_argument_type(x)); +} + +template +class binder2nd : public unary_function { +protected: + Operation op; + Operation::second_argument_type value; +public: + binder2nd(const Operation& x, const Operation::second_argument_type& y) + : op(x), value(y) {} + result_type operator()(const argument_type& x) const { + return op(x, value); + } +}; + +template +binder2nd bind2nd(const Operation& op, const T& x) { + return binder2nd(op, Operation::second_argument_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 +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 +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() {} + pointer_to_unary_function(Result (*x)(Arg)) : ptr(x) {} + Result operator()(Arg x) const { return ptr(x); } +}; + +template +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() {} + pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr(x) {} + Result operator()(Arg1 x, Arg2 y) const { return ptr(x, y); } +}; + +template +pointer_to_binary_function +ptr_fun(Result (*x)(Arg1, Arg2)) { + return pointer_to_binary_function(x); +} + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hdeque.h b/gnu/lib/libg++/libstdc++/stl/hdeque.h new file mode 100644 index 00000000000..0d47098a06c --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hdeque.h @@ -0,0 +1,39 @@ +/* + * + * 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 HDEQUE_H +#define HDEQUE_H + +#ifdef DEQUE_H +#undef DEQUE_H +#define __DEQUE_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define deque huge_deque +#include +#include + +#undef DEQUE_H + +#ifdef __DEQUE_WAS_DEFINED +#define DEQUE_H +#undef __DEQUE_WAS_DEFINED +#endif + +#undef Allocator +#undef deque + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/heap.h b/gnu/lib/libg++/libstdc++/stl/heap.h new file mode 100644 index 00000000000..7f2747fc5b9 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/heap.h @@ -0,0 +1,193 @@ +/* + * + * 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 HEAP_H +#define HEAP_H + +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, T*) { + __push_heap(first, (last - first) - 1, 0, T(*(last - 1))); +} + +template +inline void push_heap(RandomAccessIterator first, RandomAccessIterator last) { + __push_heap_aux(first, last, 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, T*) { + __push_heap(first, (last - first) - 1, 0, T(*(last - 1)), comp); +} + +template +inline void push_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + __push_heap_aux(first, last, comp, 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); +} + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hlist.h b/gnu/lib/libg++/libstdc++/stl/hlist.h new file mode 100644 index 00000000000..543ffa7a77e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hlist.h @@ -0,0 +1,39 @@ +/* + * + * 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 HLIST_H +#define HLIST_H + +#ifdef LIST_H +#undef LIST_H +#define __LIST_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define list huge_list +#include +#include + +#undef LIST_H + +#ifdef __LIST_WAS_DEFINED +#define LIST_H +#undef __LIST_WAS_DEFINED +#endif + +#undef Allocator +#undef list + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hmap.h b/gnu/lib/libg++/libstdc++/stl/hmap.h new file mode 100644 index 00000000000..f40abc042ad --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 HMAP_H +#define HMAP_H + +#ifdef MAP_H +#undef MAP_H +#undef TREE_H +#define __MAP_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define map huge_map +#define rb_tree huge_rb_tree +#include +#include + +#undef MAP_H +#undef TREE_H + +#ifdef __MAP_WAS_DEFINED +#define MAP_H +#define TREE_H +#undef __MAP_WAS_DEFINED +#endif + +#undef Allocator +#undef map +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hmultmap.h b/gnu/lib/libg++/libstdc++/stl/hmultmap.h new file mode 100644 index 00000000000..0a8551e9ec5 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hmultmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 HMULTIMAP_H +#define HMULTIMAP_H + +#ifdef MULTIMAP_H +#undef MULTIMAP_H +#undef TREE_H +#define __MULTIMAP_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define multimap huge_multimap +#define rb_tree huge_rb_tree +#include +#include + +#undef MULTIMAP_H +#undef TREE_H + +#ifdef __MULTIMAP_WAS_DEFINED +#define MULTIMAP_H +#define TREE_H +#undef __MULTIMAP_WAS_DEFINED +#endif + +#undef Allocator +#undef multimap +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hmultset.h b/gnu/lib/libg++/libstdc++/stl/hmultset.h new file mode 100644 index 00000000000..e207299603f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hmultset.h @@ -0,0 +1,44 @@ +/* + * + * 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 HMULTISET_H +#define HMULTISET_H + +#ifdef MULTISET_H +#undef MULTISET_H +#undef TREE_H +#define __MULTISET_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define multiset huge_multiset +#define rb_tree huge_rb_tree +#include +#include + +#undef MULTISET_H +#undef TREE_H + +#ifdef __MULTISET_WAS_DEFINED +#define MULTISET_H +#define TREE_H +#undef __MULTISET_WAS_DEFINED +#endif + +#undef Allocator +#undef multiset +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hset.h b/gnu/lib/libg++/libstdc++/stl/hset.h new file mode 100644 index 00000000000..11a15763216 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hset.h @@ -0,0 +1,44 @@ +/* + * + * 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 HSET_H +#define HSET_H + +#ifdef SET_H +#undef SET_H +#undef TREE_H +#define __SET_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define set huge_set +#define rb_tree huge_rb_tree +#include +#include + +#undef SET_H +#undef TREE_H + +#ifdef __SET_WAS_DEFINED +#define SET_H +#define TREE_H +#undef __SET_WAS_DEFINED +#endif + +#undef Allocator +#undef set +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/hugalloc.h b/gnu/lib/libg++/libstdc++/stl/hugalloc.h new file mode 100644 index 00000000000..a793ab27fd7 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hugalloc.h @@ -0,0 +1,38 @@ +/* + * + * 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 HUGALLOC_H +#define HUGALLOC_H + +#ifdef FARALLOC_H +#undef FARALLOC_H +#define __FARALLOC_WAS_DEFINED +#endif + +#define __far __huge +#define far_allocator huge_allocator +#include +#undef __far +#undef far_allocator + +#undef FARALLOC_H + +#ifdef __FARALLOC_WAS_DEFINED +#define FARALLOC_H +#undef __FARALLOC_WAS_DEFINED +#endif + +#endif + diff --git a/gnu/lib/libg++/libstdc++/stl/hvector.h b/gnu/lib/libg++/libstdc++/stl/hvector.h new file mode 100644 index 00000000000..e7fb41530db --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/hvector.h @@ -0,0 +1,39 @@ +/* + * + * 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 HVECTOR_H +#define HVECTOR_H + +#ifdef VECTOR_H +#undef VECTOR_H +#define __VECTOR_WAS_DEFINED +#endif + +#define Allocator huge_allocator +#define vector huge_vector +#include +#include + +#undef VECTOR_H + +#ifdef __VECTOR_WAS_DEFINED +#define VECTOR_H +#undef __VECTOR_WAS_DEFINED +#endif + +#undef Allocator +#undef vector + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/iterator.h b/gnu/lib/libg++/libstdc++/stl/iterator.h new file mode 100644 index 00000000000..5e51598f200 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/iterator.h @@ -0,0 +1,395 @@ +/* + * + * 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 ITERATOR_H +#define ITERATOR_H + +#include +#include +#ifndef __GNUG__ +#include +#endif +#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 {}; +struct output_iterator {}; +template struct forward_iterator {}; +template struct bidirectional_iterator {}; +template struct random_access_iterator {}; + +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 : public output_iterator { +protected: + Container& container; +public: + back_insert_iterator(Container& x) : container(x) {} + back_insert_iterator& + operator=(const 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 +back_insert_iterator back_inserter(Container& x) { + return back_insert_iterator(x); +} + +template +class front_insert_iterator : public output_iterator { +protected: + Container& container; +public: + front_insert_iterator(Container& x) : container(x) {} + front_insert_iterator& + operator=(const 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 +front_insert_iterator front_inserter(Container& x) { + return front_insert_iterator(x); +} + +template +class insert_iterator : public output_iterator { +protected: + Container& container; + Container::iterator iter; +public: + insert_iterator(Container& x, Container::iterator i) + : container(x), iter(i) {} + insert_iterator& + operator=(const 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 +insert_iterator inserter(Container& x, Iterator i) { + return insert_iterator(x, Container::iterator(i)); +} + +template +// Reference = T& +class reverse_bidirectional_iterator + : public bidirectional_iterator { + typedef reverse_bidirectional_iterator self; + friend bool operator==(const self& x, const self& y); +protected: + BidirectionalIterator current; +public: + reverse_bidirectional_iterator() {} + 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 bool operator==( + const reverse_bidirectional_iterator& x, + const reverse_bidirectional_iterator& y) { + return x.current == y.current; +} + +template +// Reference = T& +class reverse_iterator : public random_access_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: + reverse_iterator() {} + 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 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 : public output_iterator { +protected: + OutputIterator iter; +public: + raw_storage_iterator(OutputIterator 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 +class istream_iterator : public input_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: + 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 +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 : public output_iterator { +protected: + ostream* stream; + char* string; +public: + ostream_iterator(ostream& s) : stream(&s), string(0) {} + ostream_iterator(ostream& s, 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; } +}; + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lbvector.h b/gnu/lib/libg++/libstdc++/stl/lbvector.h new file mode 100644 index 00000000000..763666c3d39 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lbvector.h @@ -0,0 +1,39 @@ +/* + * + * 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 LBVECTOR_H +#define LBVECTOR_H + +#ifdef BVECTOR_H +#undef BVECTOR_H +#define __BVECTOR_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define bit_vector long_bit_vector +#include +#include + +#undef BVECTOR_H + +#ifdef __BVECTOR_WAS_DEFINED +#define BVECTOR_H +#undef __BVECTOR_WAS_DEFINED +#endif + +#undef Allocator +#undef bit_vector + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/ldeque.h b/gnu/lib/libg++/libstdc++/stl/ldeque.h new file mode 100644 index 00000000000..4c8761c9f8b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/ldeque.h @@ -0,0 +1,39 @@ +/* + * + * 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 LDEQUE_H +#define LDEQUE_H + +#ifdef DEQUE_H +#undef DEQUE_H +#define __DEQUE_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define deque long_deque +#include +#include + +#undef DEQUE_H + +#ifdef __DEQUE_WAS_DEFINED +#define DEQUE_H +#undef __DEQUE_WAS_DEFINED +#endif + +#undef Allocator +#undef deque + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/list.h b/gnu/lib/libg++/libstdc++/stl/list.h new file mode 100644 index 00000000000..42b5d0f5f67 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/list.h @@ -0,0 +1,531 @@ +/* + * + * 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 LIST_H +#define LIST_H + +#include +#include +#include +#ifndef __GNUG__ +#include +#endif + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#ifndef list +#define list list +#endif + +template +class list { +protected: + typedef Allocator::pointer void_pointer; + struct list_node; + friend list_node; + struct list_node { + void_pointer next; + void_pointer prev; + T data; + }; +#ifndef __GNUG__ + static Allocator list_node_allocator; + static Allocator value_allocator; +#endif +public: + typedef T value_type; + typedef Allocator value_allocator_type; + typedef Allocator::pointer pointer; + typedef Allocator::reference reference; + typedef Allocator::const_reference const_reference; + typedef Allocator list_node_allocator_type; + typedef Allocator::pointer link_type; + typedef Allocator::size_type size_type; + typedef Allocator::difference_type difference_type; +protected: +#ifdef __GNUG__ + link_type get_node() { return (link_type)(::operator new(sizeof(list_node))); } + void put_node(link_type p) { ::operator delete(p); } +#else + size_type buffer_size() { + return list_node_allocator.init_page_size(); + } + struct list_node_buffer; + friend list_node_buffer; + struct list_node_buffer { + void_pointer next_buffer; + link_type buffer; + }; +public: + typedef Allocator buffer_allocator_type; + typedef Allocator::pointer buffer_pointer; +protected: + static Allocator buffer_allocator; + static buffer_pointer buffer_list; + static link_type free_list; + static link_type next_avail; + static link_type last; + void add_new_buffer() { + buffer_pointer tmp = buffer_allocator.allocate((size_type)1); + tmp->buffer = list_node_allocator.allocate(buffer_size()); + tmp->next_buffer = buffer_list; + buffer_list = tmp; + next_avail = buffer_list->buffer; + last = next_avail + buffer_size(); + } + static size_type number_of_lists; + void deallocate_buffers(); + link_type get_node() { + link_type tmp = free_list; + return free_list ? (free_list = (link_type)(free_list->next), tmp) + : (next_avail == last ? (add_new_buffer(), next_avail++) + : next_avail++); + // ugly code for inlining - avoids multiple returns + } + void put_node(link_type p) { + p->next = free_list; + free_list = p; + } +#endif + + link_type node; + size_type length; +public: + class iterator; + class const_iterator; + class iterator : public bidirectional_iterator { + friend class list; + friend class const_iterator; +// friend bool operator==(const iterator& x, const iterator& y); + protected: + link_type node; + iterator(link_type x) : node(x) {} + public: + iterator() {} + bool operator==(const iterator& x) const { return node == x.node; } + reference operator*() const { return (*node).data; } + iterator& operator++() { + node = (link_type)((*node).next); + return *this; + } + iterator operator++(int) { + iterator tmp = *this; + ++*this; + return tmp; + } + iterator& operator--() { + node = (link_type)((*node).prev); + return *this; + } + iterator operator--(int) { + iterator tmp = *this; + --*this; + return tmp; + } + }; + class const_iterator : public bidirectional_iterator { + friend class list; + protected: + link_type node; + const_iterator(link_type x) : node(x) {} + public: + const_iterator() {} + const_iterator(const iterator& x) : node(x.node) {} + bool operator==(const const_iterator& x) const { return node == x.node; } + const_reference operator*() const { return (*node).data; } + const_iterator& operator++() { + node = (link_type)((*node).next); + return *this; + } + const_iterator operator++(int) { + const_iterator tmp = *this; + ++*this; + return tmp; + } + const_iterator& operator--() { + node = (link_type)((*node).prev); + return *this; + } + const_iterator operator--(int) { + const_iterator tmp = *this; + --*this; + return tmp; + } + }; + typedef reverse_bidirectional_iterator + const_reverse_iterator; + typedef reverse_bidirectional_iterator + reverse_iterator; + list() : length(0) { +#ifndef __GNUG__ + ++number_of_lists; +#endif + node = get_node(); + (*node).next = node; + (*node).prev = node; + } + 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 length == 0; } + size_type size() const { return length; } +#ifndef __GNUG__ + size_type max_size() const { return list_node_allocator.max_size(); } +#endif + 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); + ::swap(length, x.length); + } + iterator insert(iterator position, const T& x) { + link_type tmp = get_node(); +#ifdef __GNUG__ + construct(&(*tmp).data, x); +#else + construct(value_allocator.address((*tmp).data), x); +#endif + (*tmp).next = position.node; + (*tmp).prev = (*position.node).prev; + (*(link_type((*position.node).prev))).next = tmp; + (*position.node).prev = tmp; + ++length; + return tmp; + } +#ifdef __GNUG__ + void insert(iterator position, const T* first, const T* last) { + while (first != last) insert(position, *first++); + } + void insert(iterator position, const_iterator first, + const_iterator last) { + while (first != last) insert(position, *first++); + } + void insert(iterator position, size_type n, const T& x) { + while (n--) insert(position, x); + } +#else + void insert(iterator position, const T* first, const T* last); + void insert(iterator position, const_iterator first, + const_iterator last); + void insert(iterator position, size_type n, const T& x); +#endif + 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; +#ifdef __GNUG__ + destroy(&(*position.node).data); +#else + destroy(value_allocator.address((*position.node).data)); +#endif + put_node(position.node); + --length; + } +#ifdef __GNUG__ + void erase(iterator first, iterator last) { + while (first != last) erase(first++); + } +#else + void erase(iterator first, iterator last); +#endif + void pop_front() { erase(begin()); } + void pop_back() { + iterator tmp = end(); + erase(--tmp); + } + list(size_type n, const T& value = T()) : length(0) { +#ifndef __GNUG__ + ++number_of_lists; +#endif + node = get_node(); + (*node).next = node; + (*node).prev = node; + insert(begin(), n, value); + } + list(const T* first, const T* last) : length(0) { +#ifndef __GNUG__ + ++number_of_lists; +#endif + node = get_node(); + (*node).next = node; + (*node).prev = node; + insert(begin(), first, last); + } + list(const list& x) : length(0) { +#ifndef __GNUG__ + ++number_of_lists; +#endif + node = get_node(); + (*node).next = node; + (*node).prev = node; + insert(begin(), x.begin(), x.end()); + } + ~list() { + erase(begin(), end()); + put_node(node); +#ifndef __GNUG__ + if (--number_of_lists == 0) deallocate_buffers(); +#endif + } + list& operator=(const list& x); +protected: + void transfer(iterator position, iterator first, iterator 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()); + length += x.length; + x.length = 0; + } + } + void splice(iterator position, list& x, iterator i) { + iterator j = i; + if (position == i || position == ++j) return; + transfer(position, i, j); + ++length; + --x.length; + } + void splice(iterator position, list& x, iterator first, iterator last) { + if (first != last) { + if (&x != this) { + difference_type n = 0; + distance(first, last, n); + x.length -= n; + length += n; + } + transfer(position, first, last); + } + } + void remove(const T& value); + void unique(); + void merge(list& x); + void reverse(); + void sort(); +#ifdef __GNUG__ + friend difference_type* distance_type(const iterator&) { + return (difference_type*)(0); + } + friend T* value_type(const iterator&) { + return (T*)(0); + } + friend bidirectional_iterator_tag iterator_category(iterator) { + return bidirectional_iterator_tag(); + } +#endif +}; + +#ifndef __GNUG__ +template +list::buffer_pointer list::buffer_list = 0; + +template +list::link_type list::free_list = 0; + +template +list::link_type list::next_avail = 0; + +template +list::link_type list::last = 0; + +template +list::size_type list::number_of_lists = 0; + +template +list::list_node_allocator_type list::list_node_allocator; + +template +list::value_allocator_type list::value_allocator; + +template +list::buffer_allocator_type list::buffer_allocator; +#endif + +/* + * currently the following does not work - made into a member function + +template +inline bool operator==(const list::iterator& x, const list::iterator& y) { + return x.node == y.node; +} +*/ + +template +inline bool operator==(const list& x, const list& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const list& x, const list& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#ifndef __GNUG__ +template +void list::deallocate_buffers() { + while (buffer_list) { + buffer_pointer tmp = buffer_list; + buffer_list = (buffer_pointer)(buffer_list->next_buffer); + list_node_allocator.deallocate(tmp->buffer); + buffer_allocator.deallocate(tmp); + } + free_list = 0; + next_avail = 0; + last = 0; +} +#endif + +#ifndef __GNUG__ +template +void list::insert(iterator position, const T* first, const T* last) { + while (first != last) insert(position, *first++); +} + +template +void list::insert(iterator position, const_iterator first, + const_iterator last) { + while (first != last) insert(position, *first++); +} + +template +void list::insert(iterator position, size_type n, const T& x) { + while (n--) insert(position, x); +} + +template +void list::erase(iterator first, iterator last) { + while (first != last) erase(first++); +} +#endif + +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); + length += x.length; + x.length= 0; +} + +template +void list::reverse() { + if (size() < 2) return; + for (iterator first = ++begin(); first != end();) { + iterator old = first++; + transfer(begin(), old, first); + } +} + +template +void list::sort() { + if (size() < 2) 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]); +} + +#undef Allocator +#undef list + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/llist.h b/gnu/lib/libg++/libstdc++/stl/llist.h new file mode 100644 index 00000000000..07ee6113a09 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/llist.h @@ -0,0 +1,39 @@ +/* + * + * 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 LLIST_H +#define LLIST_H + +#ifdef LIST_H +#undef LIST_H +#define __LIST_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define list long_list +#include +#include + +#undef LIST_H + +#ifdef __LIST_WAS_DEFINED +#define LIST_H +#undef __LIST_WAS_DEFINED +#endif + +#undef Allocator +#undef list + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lmap.h b/gnu/lib/libg++/libstdc++/stl/lmap.h new file mode 100644 index 00000000000..da1eeba6c8c --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 LMAP_H +#define LMAP_H + +#ifdef MAP_H +#undef MAP_H +#undef TREE_H +#define __MAP_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define map long_map +#define rb_tree long_rb_tree +#include +#include + +#undef MAP_H +#undef TREE_H + +#ifdef __MAP_WAS_DEFINED +#define MAP_H +#define TREE_H +#undef __MAP_WAS_DEFINED +#endif + +#undef Allocator +#undef map +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lmultmap.h b/gnu/lib/libg++/libstdc++/stl/lmultmap.h new file mode 100644 index 00000000000..1a87e3372d8 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lmultmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 LMULTIMAP_H +#define LMULTIMAP_H + +#ifdef MULTIMAP_H +#undef MULTIMAP_H +#undef TREE_H +#define __MULTIMAP_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define multimap long_multimap +#define rb_tree long_rb_tree +#include +#include + +#undef MULTIMAP_H +#undef TREE_H + +#ifdef __MULTIMAP_WAS_DEFINED +#define MULTIMAP_H +#define TREE_H +#undef __MULTIMAP_WAS_DEFINED +#endif + +#undef Allocator +#undef multimap +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lmultset.h b/gnu/lib/libg++/libstdc++/stl/lmultset.h new file mode 100644 index 00000000000..bb1571f6c90 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lmultset.h @@ -0,0 +1,44 @@ +/* + * + * 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 LMULTISET_H +#define LMULTISET_H + +#ifdef MULTISET_H +#undef MULTISET_H +#undef TREE_H +#define __MULTISET_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define multiset long_multiset +#define rb_tree long_rb_tree +#include +#include + +#undef MULTISET_H +#undef TREE_H + +#ifdef __MULTISET_WAS_DEFINED +#define MULTISET_H +#define TREE_H +#undef __MULTISET_WAS_DEFINED +#endif + +#undef Allocator +#undef multiset +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lngalloc.h b/gnu/lib/libg++/libstdc++/stl/lngalloc.h new file mode 100644 index 00000000000..6685ea54511 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lngalloc.h @@ -0,0 +1,54 @@ +/* + * + * 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 LNGALLOC_H +#define LNGALLOC_H + +#include +#include +#include + +template +class long_allocator { +public: + typedef T value_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef unsigned long size_type; + typedef long 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(ULONG_MAX/sizeof(T))); + } +}; + +class long_allocator { +public: + typedef void* pointer; +}; + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/lset.h b/gnu/lib/libg++/libstdc++/stl/lset.h new file mode 100644 index 00000000000..e4d52f7c39e --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/lset.h @@ -0,0 +1,44 @@ +/* + * + * 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 LSET_H +#define LSET_H + +#ifdef SET_H +#undef SET_H +#undef TREE_H +#define __SET_WAS_DEFINED +#endif + +#define Allocator long_allocator +#define set long_set +#define rb_tree long_rb_tree +#include +#include + +#undef SET_H +#undef TREE_H + +#ifdef __SET_WAS_DEFINED +#define SET_H +#define TREE_H +#undef __SET_WAS_DEFINED +#endif + +#undef Allocator +#undef set +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/map.h b/gnu/lib/libg++/libstdc++/stl/map.h new file mode 100644 index 00000000000..5c1c30d49e6 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/map.h @@ -0,0 +1,150 @@ +/* + * + * 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 MAP_H +#define MAP_H + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#include + +template +class map { +public: + +// typedefs: + + typedef Key key_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> 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(const Compare& comp = Compare()) : t(comp, false) {} + map(const value_type* first, const value_type* last, + const Compare& comp = Compare()) : t(first, last, comp, false) {} + map(const map& x) : t(x.t, false) {} + 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(); } +#ifndef __GNUG__ + size_type max_size() const { return t.max_size(); } +#endif + Allocator::reference operator[](const key_type& k) { + return (*((insert(value_type(k, T()))).first)).second; + } + void swap(map& x) { t.swap(x.t); } + +// insert/erase + + typedef pair pair_iterator_bool; + // typedef done to get around compiler bug + pair_iterator_bool insert(const value_type& x) { return t.insert(x); } + iterator insert(iterator position, const value_type& x) { + return t.insert(position, x); + } + void insert(const value_type* first, const value_type* last) { + t.insert(first, last); + } + 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); } + +// 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); + } + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x) { + return t.equal_range(x); + } + typedef pair pair_citerator_citerator; + // typedef done to get around compiler bug + pair_citerator_citerator equal_range(const key_type& x) const { + return t.equal_range(x); + } +}; + +template +inline bool operator==(const map& x, + const map& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const map& x, + const map& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#undef Allocator + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/multimap.h b/gnu/lib/libg++/libstdc++/stl/multimap.h new file mode 100644 index 00000000000..2478e2419fa --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/multimap.h @@ -0,0 +1,142 @@ +/* + * + * 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 MULTIMAP_H +#define MULTIMAP_H + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#include + +template +class multimap { +public: + +// typedefs: + + typedef Key key_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> rep_type; + rep_type t; // red-black tree representing multimap +public: + 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(const Compare& comp = Compare()) : t(comp, true) { } + multimap(const value_type* first, const value_type* last, + const Compare& comp = Compare()) : t(first, last, comp, true) { } + multimap(const multimap& x) : t(x.t, true) { } + 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(x).first; } + iterator insert(iterator position, const value_type& x) { + return t.insert(position, x); + } + void insert(const value_type* first, const value_type* last) { + t.insert(first, last); + } + 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); } + +// 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); + } + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x) { + return t.equal_range(x); + } + typedef pair pair_citerator_citerator; + // typedef done to get around compiler bug + pair_citerator_citerator equal_range(const key_type& x) const { + return t.equal_range(x); + } +}; + +template +inline bool operator==(const multimap& x, + const multimap& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const multimap& x, + const multimap& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#undef Allocator + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/multiset.h b/gnu/lib/libg++/libstdc++/stl/multiset.h new file mode 100644 index 00000000000..1ee6d93e352 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/multiset.h @@ -0,0 +1,129 @@ +/* + * + * 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 MULTISET_H +#define MULTISET_H + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#include + +template +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> rep_type; + rep_type t; // red-black tree representing multiset +public: + 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(const Compare& comp = Compare()) : t(comp, true) {} + multiset(const value_type* first, const value_type* last, + const Compare& comp = Compare()) : t(comp, true) { + for (const value_type* i = first; i != last; ++i) + t.insert(*i); + } + multiset(const multiset& x) : t(x.t, true) {} + 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(x).first; + } + iterator insert(iterator position, const value_type& x) { + return t.insert((rep_type::iterator&)position, x); + } + void insert(const value_type* first, const value_type* last) { + for (const value_type* i = first; i != last; ++i) + t.insert(*i); + } + 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); + } + +// 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); + } + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x) const { + return t.equal_range(x); + } +}; + +template +inline bool operator==(const multiset& x, + const multiset& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const multiset& x, + const multiset& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#undef Allocator + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/neralloc.h b/gnu/lib/libg++/libstdc++/stl/neralloc.h new file mode 100644 index 00000000000..c66e9b366a0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/neralloc.h @@ -0,0 +1,38 @@ +/* + * + * 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 NEARALLOC_H +#define NEARALLOC_H + +#ifdef FARALLOC_H +#undef FARALLOC_H +#define __FARALLOC_WAS_DEFINED +#endif + +#define __far __near +#define far_allocator near_allocator +#include +#undef __far +#undef far_allocator + +#undef FARALLOC_H + +#ifdef __FARALLOC_WAS_DEFINED +#define FARALLOC_H +#undef __FARALLOC_WAS_DEFINED +#endif + +#endif + diff --git a/gnu/lib/libg++/libstdc++/stl/nmap.h b/gnu/lib/libg++/libstdc++/stl/nmap.h new file mode 100644 index 00000000000..99754c78169 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/nmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 NMAP_H +#define NMAP_H + +#ifdef MAP_H +#undef MAP_H +#undef TREE_H +#define __MAP_WAS_DEFINED +#endif + +#define Allocator near_allocator +#define map near_map +#define rb_tree near_rb_tree +#include +#include + +#undef MAP_H +#undef TREE_H + +#ifdef __MAP_WAS_DEFINED +#define MAP_H +#define TREE_H +#undef __MAP_WAS_DEFINED +#endif + +#undef Allocator +#undef map +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/nmultmap.h b/gnu/lib/libg++/libstdc++/stl/nmultmap.h new file mode 100644 index 00000000000..a6ad67c4fbb --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/nmultmap.h @@ -0,0 +1,44 @@ +/* + * + * 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 NMULTIMAP_H +#define NMULTIMAP_H + +#ifdef MULTIMAP_H +#undef MULTIMAP_H +#undef TREE_H +#define __MULTIMAP_WAS_DEFINED +#endif + +#define Allocator near_allocator +#define multimap near_multimap +#define rb_tree near_rb_tree +#include +#include + +#undef MULTIMAP_H +#undef TREE_H + +#ifdef __MULTIMAP_WAS_DEFINED +#define MULTIMAP_H +#define TREE_H +#undef __MULTIMAP_WAS_DEFINED +#endif + +#undef Allocator +#undef multimap +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/nmultset.h b/gnu/lib/libg++/libstdc++/stl/nmultset.h new file mode 100644 index 00000000000..3a0ad30db0d --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/nmultset.h @@ -0,0 +1,44 @@ +/* + * + * 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 NMULTISET_H +#define NMULTISET_H + +#ifdef MULTISET_H +#undef MULTISET_H +#undef TREE_H +#define __MULTISET_WAS_DEFINED +#endif + +#define Allocator near_allocator +#define multiset near_multiset +#define rb_tree near_rb_tree +#include +#include + +#undef MULTISET_H +#undef TREE_H + +#ifdef __MULTISET_WAS_DEFINED +#define MULTISET_H +#define TREE_H +#undef __MULTISET_WAS_DEFINED +#endif + +#undef Allocator +#undef multiset +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/nset.h b/gnu/lib/libg++/libstdc++/stl/nset.h new file mode 100644 index 00000000000..325d6b94aac --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/nset.h @@ -0,0 +1,44 @@ +/* + * + * 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 NSET_H +#define NSET_H + +#ifdef SET_H +#undef SET_H +#undef TREE_H +#define __SET_WAS_DEFINED +#endif + +#define Allocator near_allocator +#define set near_set +#define rb_tree near_rb_tree +#include +#include + +#undef SET_H +#undef TREE_H + +#ifdef __SET_WAS_DEFINED +#define SET_H +#define TREE_H +#undef __SET_WAS_DEFINED +#endif + +#undef Allocator +#undef set +#undef rb_tree + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/pair.h b/gnu/lib/libg++/libstdc++/stl/pair.h new file mode 100644 index 00000000000..817d9a43969 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/pair.h @@ -0,0 +1,46 @@ +/* + * + * 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 PAIR_H +#define PAIR_H + +#ifndef __GNUG__ +#include +#endif + +template +struct pair { + T1 first; + T2 second; + pair() {} + pair(const T1& a, const T2& b) : first(a), second(b) {} +}; + +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/gnu/lib/libg++/libstdc++/stl/projectn.h b/gnu/lib/libg++/libstdc++/stl/projectn.h new file mode 100644 index 00000000000..766796e9f21 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/projectn.h @@ -0,0 +1,33 @@ +/* + * + * 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 PROJECTN_H +#define PROJECTN_H + +#include + +template +struct select1st : public unary_function { + const U& operator()(const T& x) const { return x.first; } +}; + +template +struct ident : public unary_function { + const U& operator()(const T& x) const { return x; } +}; + +#endif + + diff --git a/gnu/lib/libg++/libstdc++/stl/random.cc b/gnu/lib/libg++/libstdc++/stl/random.cc new file mode 100644 index 00000000000..e79872ca49b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/random.cc @@ -0,0 +1,60 @@ +/* + * + * 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. + * + */ + +#include + +#define __SEED 161803398 + +class __random_generator { +protected: + unsigned long table[55]; + size_t index1; + size_t index2; +public: + unsigned long operator()(unsigned long limit) { + index1 = (index1 + 1) % 55; + index2 = (index2 + 1) % 55; + table[index1] = table[index1] - table[index2]; + return table[index1] % limit; + } + void seed(unsigned long j); + __random_generator(unsigned long j) { seed(j); } +}; + +void __random_generator::seed(unsigned long j) { + unsigned long k = 1; + table[54] = j; + for (size_t i = 0; i < 54; i++) { + size_t ii = 21 * i % 55; + table[ii] = k; + k = j - k; + j = table[ii]; + } + for (int loop = 0; loop < 4; loop++) { + for (size_t i = 0; i < 55; i++) + table[i] = table[i] - table[(1 + i + 30) % 55]; + } + index1 = 0; + index2 = 31; +} + +static __random_generator rd(__SEED); + +unsigned long __long_random(unsigned long limit) { + return rd(limit); +} + + + diff --git a/gnu/lib/libg++/libstdc++/stl/set.h b/gnu/lib/libg++/libstdc++/stl/set.h new file mode 100644 index 00000000000..d108e42371a --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/set.h @@ -0,0 +1,132 @@ +/* + * + * 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 SET_H +#define SET_H + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#include + +template +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> rep_type; + rep_type t; // red-black tree representing set +public: + 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(const Compare& comp = Compare()) : t(comp, false) {} + set(const value_type* first, const value_type* last, + const Compare& comp = Compare()) : t(comp, false) { + for (const value_type* i = first; i != last; ++i) + t.insert(*i); + } + set(const set& x) : t(x.t, false) {} + 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; + // typedef done to get around compiler bug + pair_iterator_bool insert(const value_type& x) { + pair p = t.insert(x); + return pair(p.first, p.second); + } + iterator insert(iterator position, const value_type& x) { + return t.insert((rep_type::iterator&)position, x); + } + void insert(const value_type* first, const value_type* last) { + for (const value_type* i = first; i != last; ++i) + t.insert(*i); + } + 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); + } + +// 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); + } + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x) const { + return t.equal_range(x); + } +}; + +template +inline bool operator==(const set& x, + const set& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const set& x, + const set& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#undef Allocator + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/stack.h b/gnu/lib/libg++/libstdc++/stl/stack.h new file mode 100644 index 00000000000..83a59a4c2af --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/stack.h @@ -0,0 +1,120 @@ +/* + * + * 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 STACK_H +#define STACK_H + +#ifndef __GNUG__ +#include +#endif +#include + +template +class stack { +friend bool operator==(const stack& x, const stack& y); +friend bool operator<(const stack& x, const stack& y); +public: + typedef Container::value_type value_type; + typedef Container::size_type size_type; +protected: + Container 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; +} + +template +class queue { +friend bool operator==(const queue& x, const queue& y); +friend bool operator<(const queue& x, const queue& y); +public: + typedef Container::value_type value_type; + typedef Container::size_type size_type; +protected: + Container 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; +} + +template +// Compare = less > +class priority_queue { +public: + typedef Container::value_type value_type; + typedef Container::size_type size_type; +protected: + Container c; + Compare comp; +public: + priority_queue(const Compare& x = Compare()) : c(), comp(x) {} + priority_queue(const value_type* first, const value_type* last, + const Compare& x = Compare()) : c(first, last), comp(x) { + make_heap(c.begin(), c.end(), comp); + } +/* + template + priority_queue(InputIterator first, InputIterator last, + const Compare& x = Compare()) : c(first, last), comp(x) { + make_heap(c.begin(), c.end(), comp); + } +*/ + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& top() { return c.front(); } + const value_type& top() const { return c.front(); } + void push(const value_type& x) { + c.push_back(x); + push_heap(c.begin(), c.end(), comp); + } + void pop() { + pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } +}; + +// no equality is provided + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/tempbuf.cc b/gnu/lib/libg++/libstdc++/stl/tempbuf.cc new file mode 100644 index 00000000000..2e7408eadd3 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/tempbuf.cc @@ -0,0 +1,18 @@ +/* + * + * 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. + * + */ + +#include + +char __stl_temp_buffer[__stl_buffer_size]; diff --git a/gnu/lib/libg++/libstdc++/stl/tempbuf.h b/gnu/lib/libg++/libstdc++/stl/tempbuf.h new file mode 100644 index 00000000000..238b6acc31b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/tempbuf.h @@ -0,0 +1,55 @@ +/* + * + * 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 TEMPBUF_H +#define TEMPBUF_H + +#include +#include + +#ifndef __stl_buffer_size +#define __stl_buffer_size 16384 // 16k +#endif + +extern char __stl_temp_buffer[__stl_buffer_size]; + +//not reentrant code + +template +pair get_temporary_buffer(int len, T*) { + while (len > __stl_buffer_size / sizeof(T)) { + set_new_handler(0); + T* tmp = (T*)(::operator new((unsigned int)len * sizeof(T))); + if (tmp) return pair(tmp, len); + len = len / 2; + } + return pair((T*)__stl_temp_buffer, + (int)(__stl_buffer_size / sizeof(T))); +} + +template +void return_temporary_buffer(T* p) { + if ((char*)(p) != __stl_temp_buffer) deallocate(p); +} + +template +pair get_temporary_buffer(long len, T* p) { + if (len > INT_MAX/sizeof(T)) + len = INT_MAX/sizeof(T); + pair tmp = get_temporary_buffer((int)len, p); + return pair(tmp.first, (long)(tmp.second)); +} + +#endif diff --git a/gnu/lib/libg++/libstdc++/stl/tree.cc b/gnu/lib/libg++/libstdc++/stl/tree.cc new file mode 100644 index 00000000000..e4a9cfe10fa --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/tree.cc @@ -0,0 +1,3 @@ +#include "tree.h" + +__rb_tree_node_base __rb_NIL = { black, 0, 0, 0 }; diff --git a/gnu/lib/libg++/libstdc++/stl/tree.h b/gnu/lib/libg++/libstdc++/stl/tree.h new file mode 100644 index 00000000000..3ae5da02b08 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/tree.h @@ -0,0 +1,1246 @@ +/* + * + * 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 TREE_H +#define 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 +#ifndef __GNUG__ +#include +#endif +#include + +#ifndef rb_tree +#define rb_tree rb_tree +#endif + +enum __rb_color_type {red, black}; + +struct __rb_tree_node_base { + enum __rb_color_type color_field; + void* parent_link; + void* left_link; + void* right_link; +}; + +extern __rb_tree_node_base __rb_NIL; + +template +class rb_tree { +protected: + typedef enum __rb_color_type color_type; + typedef Allocator::pointer void_pointer; + struct rb_tree_node; + friend rb_tree_node; + struct rb_tree_node : public __rb_tree_node_base { + Value value_field; + }; +#ifndef __GNUG__ + static Allocator rb_tree_node_allocator; + static Allocator value_allocator; +#endif +public: + typedef Key key_type; + typedef Value value_type; + typedef Allocator::pointer pointer; + typedef Allocator::reference reference; + typedef Allocator::const_reference const_reference; + typedef Allocator rb_tree_node_allocator_type; + typedef Allocator::pointer link_type; + typedef Allocator::size_type size_type; + typedef Allocator::difference_type difference_type; +protected: +#ifndef __GNUG__ + size_type buffer_size() { + return rb_tree_node_allocator.init_page_size(); + } +#endif + struct rb_tree_node_buffer; + friend rb_tree_node_buffer; + struct rb_tree_node_buffer { + void_pointer next_buffer; + link_type buffer; + }; +public: + typedef Allocator buffer_allocator_type; + typedef Allocator::pointer buffer_pointer; +protected: +#ifdef __GNUG__ + static Allocator buffer_allocator; + static buffer_pointer buffer_list; + static link_type free_list; + static link_type next_avail; + static link_type last; + link_type get_node() { return (link_type) operator new (sizeof (rb_tree_node)); } + void put_node(link_type p) { operator delete (p); } +#else + void add_new_buffer() { + buffer_pointer tmp = buffer_allocator.allocate((size_type)1); + tmp->buffer = rb_tree_node_allocator.allocate(buffer_size()); + tmp->next_buffer = buffer_list; + buffer_list = tmp; + next_avail = buffer_list->buffer; + last = next_avail + buffer_size(); + } + static size_type number_of_trees; + void deallocate_buffers(); + link_type get_node() { + link_type tmp = free_list; + return free_list ? + (free_list = (link_type)(free_list->right_link), tmp) + : (next_avail == last ? (add_new_buffer(), next_avail++) + : next_avail++); + // ugly code for inlining - avoids multiple returns + } + void put_node(link_type p) { + p->right_link = free_list; + free_list = p; + } +#endif +protected: + link_type header; + link_type& root() { return parent(header); } + link_type& root() const { return parent(header); } + link_type& leftmost() { return left(header); } + link_type& leftmost() const { return left(header); } + link_type& rightmost() { return right(header); } + link_type& rightmost() const { return right(header); } + size_type node_count; // keeps track of size of tree + bool insert_always; // controls whether an element already in the + // tree is inserted again +//public: + Compare key_compare; + static link_type& left(link_type x) { + return (link_type&)((*x).left_link); + } + static link_type& right(link_type x) { + return (link_type&)((*x).right_link); + } + static link_type& parent(link_type x) { + return (link_type&)((*x).parent_link); + } + static reference value(link_type x) { return (*x).value_field; } + static Allocator::const_reference key(link_type x) { + return KeyOfValue()(value(x)); + } + static color_type& color(link_type x) { + return (color_type&)(*x).color_field; } + static link_type minimum(link_type x) { + while (left(x) != &__rb_NIL) + x = left(x); + return x; + } + static link_type maximum(link_type x) { + while (right(x) != &__rb_NIL) + x = right(x); + return x; + } +public: + class iterator; + friend iterator; + class const_iterator; + friend const_iterator; + class iterator : public bidirectional_iterator { + friend class rb_tree; + friend class const_iterator; +/* + friend bool operator==(const iterator& x, const iterator& y) { + return x.node == y.node; + } +*/ + protected: + link_type node; + iterator(link_type x) : node(x) {} + public: + iterator() {} + bool operator==(const iterator& y) const { return node == y.node; } + reference operator*() const { return value(node); } + iterator& operator++() { + if (right(node) != &__rb_NIL) { + node = right(node); + while (left(node) != &__rb_NIL) + node = left(node); + } else { + link_type y = parent(node); + while (node == right(y)) { + node = y; + y = parent(y); + } + if (right(node) != y) // necessary because of rightmost + node = y; + } + return *this; + } + iterator operator++(int) { + iterator tmp = *this; + ++*this; + return tmp; + } + iterator& operator--() { + if (color(node) == red && parent(parent(node)) == node) + // check for header + node = right(node); // return rightmost + else if (left(node) != &__rb_NIL) { + link_type y = left(node); + while (right(y) != &__rb_NIL) + y = right(y); + node = y; + } else { + link_type y = parent(node); + while (node == left(y)) { + node = y; + y = parent(y); + } + node = y; + } + return *this; + } + iterator operator--(int) { + iterator tmp = *this; + --*this; + return tmp; + } + }; + class const_iterator + : public bidirectional_iterator { + friend class rb_tree; + friend class iterator; +/* + friend bool operator==(const const_iterator& x, const const_iterator& y) { + return x.node == y.node; + } +*/ + protected: + link_type node; + const_iterator(link_type x) : node(x) {} + public: + const_iterator() {} + const_iterator(const iterator& x) : node(x.node) {} + bool operator==(const const_iterator& y) const { + return node == y.node; + } + bool operator!=(const const_iterator& y) const { + return node != y.node; + } + const_reference operator*() const { return value(node); } + const_iterator& operator++() { + if (right(node) != &__rb_NIL) { + node = right(node); + while (left(node) != &__rb_NIL) + node = left(node); + } else { + link_type y = parent(node); + while (node == right(y)) { + node = y; + y = parent(y); + } + if (right(node) != y) // necessary because of rightmost + node = y; + } + return *this; + } + const_iterator operator++(int) { + const_iterator tmp = *this; + ++*this; + return tmp; + } + const_iterator& operator--() { + if (color(node) == red && parent(parent(node)) == node) + // check for header + node = right(node); // return rightmost + else if (left(node) != &__rb_NIL) { + link_type y = left(node); + while (right(y) != &__rb_NIL) + y = right(y); + node = y; + } else { + link_type y = parent(node); + while (node == left(y)) { + node = y; + y = parent(y); + } + node = y; + } + return *this; + } + const_iterator operator--(int) { + const_iterator tmp = *this; + --*this; + return tmp; + } + }; + typedef reverse_bidirectional_iterator + reverse_iterator; + typedef reverse_bidirectional_iterator + const_reverse_iterator; +private: +#ifdef __GNUC__ + rb_tree_iterator __insert(void* x, void* y, const value_type& v); + link_type __copy(link_type x, link_type p) { + return (link_type) __copy_hack (x, p); + } +private: + void * __copy_hack (void *, void *); +public: + void __erase(void* x); +#else + iterator __insert(link_type x, link_type y, const value_type& v); + link_type __copy(link_type x, link_type p); + void __erase(link_type x); +#endif + void init() { +#ifndef __GNUG__ + ++number_of_trees; +#endif + header = get_node(); + color(header) = red; // used to distinguish header from root, + // in iterator.operator++ + header->parent_link = &__rb_NIL; + leftmost() = header; + rightmost() = header; + } +public: + +// allocation/deallocation + + rb_tree(const Compare& comp = Compare(), bool always = true) + : node_count(0), insert_always(always), key_compare(comp) { + init(); + } + rb_tree(const value_type* first, const value_type* last, + const Compare& comp = Compare(), bool always = true) + : node_count(0), insert_always(always), key_compare(comp) { + init(); + insert(first, last); + } + rb_tree(const rb_tree& x, + bool always = true) : node_count(x.node_count), + insert_always(always), key_compare(x.key_compare) { +#ifndef __GNUG__ + ++number_of_trees; +#endif + header = get_node(); + color(header) = red; + root() = __copy(x.root(), header); + if (root() == &__rb_NIL) { + leftmost() = header; + rightmost() = header; + } else { + leftmost() = minimum(root()); + rightmost() = maximum(root()); + } + } + ~rb_tree() { + erase(begin(), end()); + put_node(header); +#ifndef __GNUG__ + if (--number_of_trees == 0) { + deallocate_buffers(); + free_list = 0; + next_avail = 0; + last = 0; + } +#endif + } + rb_tree& + operator=(const rb_tree& x); + +// 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; } +#ifndef __GNUG__ + size_type max_size() const { + return rb_tree_node_allocator.max_size(); + } +#else + size_type max_size() const { + return rb_tree_node_allocator_type::max_size(); + } +#endif + void swap(rb_tree& t) { + ::swap(header, t.header); + ::swap(node_count, t.node_count); + ::swap(insert_always, t.insert_always); + ::swap(key_compare, t.key_compare); + } + +// insert/erase + + typedef pair pair_iterator_bool; + // typedef done to get around compiler bug +#ifdef __GNUG__ + pair_iterator_bool insert(const value_type& x) { + return insert_hack(x); + } +private: + rb_tree_pair_iterator_bool + insert_hack(const Value& v); +public: + iterator insert(iterator position, const value_type& x) { + return insert_hack(position, x); + } +private: + rb_tree_iterator + insert_hack(rb_tree_iterator posn, + const Value& v); +public: + void insert(iterator first, iterator last) { + while (first != last) insert(*first++); + } + void insert(const value_type* first, const value_type* last){ + while (first != last) insert(*first++); + } + void erase(iterator position) { + erase_hack(position); + } +private: + void erase_hack(rb_tree_iterator position); +public: + size_type erase(const key_type& x); + void erase(iterator first, iterator last) { + while (first != last) erase(first++); + } +#else + pair_iterator_bool insert(const value_type& x); + iterator insert(iterator position, const value_type& x); + void insert(iterator first, iterator last); + void insert(const value_type* first, const value_type* last); + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); +#endif + void erase(const key_type* first, const key_type* last); + +// set operations: + +#ifdef __GNUG__ + iterator find(const key_type& x) { + return find_hack(x); + } + const_iterator find(const key_type& x) const { + return find_hack(x); + } +private: + rb_tree_iterator + find_hack(const key_type& x); + rb_tree_const_iterator + find_hack(const Key& k) const; +public: + + size_type count(const key_type& x) const; + iterator lower_bound(const key_type& x) { + return lower_bound_hack(x); + } + const_iterator lower_bound(const key_type& x) const { + return lower_bound_hack(x); + } + iterator upper_bound(const key_type& x) { + return upper_bound_hack(x); + } + const_iterator upper_bound(const key_type& x) const { + return upper_bound_hack(x); + } +private: + rb_tree_iterator + lower_bound_hack(const key_type& x); + rb_tree_const_iterator + lower_bound_hack(const Key& k) const; + rb_tree_iterator + upper_bound_hack(const key_type& x); + rb_tree_const_iterator + upper_bound_hack(const Key& k) const; +public: + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x) { + return pair_iterator_iterator(lower_bound(x), upper_bound(x)); + } + typedef pair pair_citerator_citerator; + + // typedef done to get around compiler bug + pair_citerator_citerator equal_range(const key_type& x) const { + return pair_citerator_citerator(lower_bound(x), upper_bound(x)); + } + inline void rotate_left(link_type x) { + link_type y = right(x); + right(x) = left(y); + if (left(y) != &__rb_NIL) + parent(left(y)) = x; + parent(y) = parent(x); + if (x == root()) + root() = y; + else if (x == left(parent(x))) + left(parent(x)) = y; + else + right(parent(x)) = y; + left(y) = x; + parent(x) = y; + } + + inline void rotate_right(link_type x) { + link_type y = left(x); + left(x) = right(y); + if (right(y) != &__rb_NIL) + parent(right(y)) = x; + parent(y) = parent(x); + if (x == root()) + root() = y; + else if (x == right(parent(x))) + right(parent(x)) = y; + else + left(parent(x)) = y; + right(y) = x; + parent(x) = y; + } + friend bidirectional_iterator_tag iterator_category(iterator) { + return bidirectional_iterator_tag(); + } + friend bidirectional_iterator_tag iterator_category(const_iterator) { + return bidirectional_iterator_tag(); + } +#else + 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; + typedef pair pair_iterator_iterator; + // typedef done to get around compiler bug + pair_iterator_iterator equal_range(const key_type& x); + typedef pair pair_citerator_citerator; + // typedef done to get around compiler bug + pair_citerator_citerator equal_range(const key_type& x) const; + inline void rotate_left(link_type x); + inline void rotate_right(link_type x); +#endif +}; + +#ifndef __GNUG__ +template +rb_tree::buffer_pointer + rb_tree::buffer_list = 0; + +template +rb_tree::link_type + rb_tree::free_list = 0; + +template +rb_tree::link_type + rb_tree::next_avail = 0; + +template +rb_tree::link_type + rb_tree::last = 0; + +template +rb_tree::size_type + rb_tree::number_of_trees = 0; + +template +rb_tree::rb_tree_node_allocator_type + rb_tree::rb_tree_node_allocator; + +template +Allocator rb_tree::value_allocator; + +template +rb_tree::buffer_allocator_type + rb_tree::buffer_allocator; + +template +void rb_tree::deallocate_buffers() { + while (buffer_list) { + buffer_pointer tmp = buffer_list; + buffer_list = (buffer_pointer)(buffer_list->next_buffer); + rb_tree_node_allocator.deallocate(tmp->buffer); + buffer_allocator.deallocate(tmp); + } +} +#endif + +#ifdef __GNUC__ +template +struct rb_tree_iterator { + rb_tree::iterator it; + rb_tree_iterator(rb_tree::iterator i) : it(i) {} + operator rb_tree::iterator() { + return it; + } +}; + +template +inline Value* value_type(const rb_tree_iterator&) { + return (Value*)(0); +} + +template +struct rb_tree_const_iterator { + rb_tree::const_iterator it; + rb_tree_const_iterator(rb_tree::const_iterator i) : it(i) {} + operator rb_tree::const_iterator() { + return it; + } +}; + +template +inline Value* value_type(const rb_tree_const_iterator&) { + return (Value*)(0); +} + +template +struct rb_tree_pair_iterator_bool { + rb_tree::pair_iterator_bool it; + rb_tree_pair_iterator_bool(rb_tree::pair_iterator_bool i) : it(i) {} + operator rb_tree::pair_iterator_bool() { + return it; + } +}; + +template +inline Value* value_type(rb_tree_pair_iterator_bool&) { + return (Value*)(0); +} +#endif + +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) { + // can't be done as in list because Key may be a constant type + erase(begin(), end()); + root() = __copy(x.root(), header); + if (root() == &__rb_NIL) { + leftmost() = header; + rightmost() = header; + } else { + leftmost() = minimum(root()); + rightmost() = maximum(root()); + } + node_count = x.node_count; + } + return *this; +} + +template +#ifdef __GNUC__ +rb_tree_iterator +rb_tree::__insert +(void* xa, void* ya, const Value& v) { + link_type x = (link_type)xa; + link_type y = (link_type)ya; +#else +rb_tree::iterator +rb_tree:: +__insert(link_type x, link_type y, const Value& v) { +#endif + ++node_count; + link_type z = get_node(); +#ifdef __GNUG__ + construct(&(value(z)), v); +#else + construct(value_allocator.address(value(z)), v); +#endif + if (y == header || x != &__rb_NIL || key_compare(KeyOfValue()(v), key(y))) { + 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 minimum node + } else { + right(y) = z; + if (y == rightmost()) + rightmost() = z; // maintain rightmost() pointing to maximum node + } + parent(z) = y; + z->left_link = &__rb_NIL; + z->right_link = &__rb_NIL; + x = z; // recolor and rebalance the tree + color(x) = red; + while (x != root() && color(parent(x)) == red) + if (parent(x) == left(parent(parent(x)))) { + y = right(parent(parent(x))); + if (color(y) == red) { + color(parent(x)) = black; + color(y) = black; + color(parent(parent(x))) = red; + x = parent(parent(x)); + } else { + if (x == right(parent(x))) { + x = parent(x); + rotate_left(x); + } + color(parent(x)) = black; + color(parent(parent(x))) = red; + rotate_right(parent(parent(x))); + } + } else { + y = left(parent(parent(x))); + if (color(y) == red) { + color(parent(x)) = black; + color(y) = black; + color(parent(parent(x))) = red; + x = parent(parent(x)); + } else { + if (x == left(parent(x))) { + x = parent(x); + rotate_right(x); + } + color(parent(x)) = black; + color(parent(parent(x))) = red; + rotate_left(parent(parent(x))); + } + } + color(root()) = black; + return iterator(z); +} + +template +#ifdef __GNUC__ +rb_tree_pair_iterator_bool +rb_tree::insert_hack(const Value& v) { +#else +rb_tree::pair_iterator_bool +rb_tree::insert(const Value& v) { +#endif + link_type y = header; + link_type x = root(); + bool comp = true; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(KeyOfValue()(v), key(x)); + x = comp ? left(x) : right(x); + } + if (insert_always) + return pair_iterator_bool(__insert(x, y, v), true); + iterator j = iterator(y); + if (comp) + if (j == begin()) + return pair_iterator_bool(__insert(x, y, v), true); + else + --j; + if (key_compare(key(j.node), KeyOfValue()(v))) + return pair_iterator_bool(__insert(x, y, v), true); + return pair_iterator_bool(j, false); +} + +template +#ifdef __GNUC__ +rb_tree_iterator +rb_tree::insert_hack(rb_tree_iterator posn, + const Value& v) { + iterator position = posn; +#else +rb_tree::iterator +rb_tree::insert(iterator position, + const Value& v) { +#endif + if (position == iterator(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-&__rb_NIL + else + return insert(v).first; + else if (position == iterator(end())) + if (key_compare(key(rightmost()), KeyOfValue()(v))) + return __insert(&__rb_NIL, rightmost(), v); + else + return insert(v).first; + else { + iterator before = --position; + if (key_compare(key(before.node), KeyOfValue()(v)) + && key_compare(KeyOfValue()(v), key(position.node))) + if (right(before.node) == &__rb_NIL) + return __insert(&__rb_NIL, before.node, v); + else + return __insert(position.node, position.node, v); + // first argument just needs to be non-&__rb_NIL + else + return insert(v).first; + } +} + +#ifndef __GNUC__ +template +void rb_tree::insert(iterator first, + iterator last) { + while (first != last) insert(*first++); +} + +template +void rb_tree::insert(const Value* first, + const Value* last) { + while (first != last) insert(*first++); +} +#endif + +template +#ifdef __GNUC__ +void rb_tree::erase_hack( + rb_tree_iterator posn) { + iterator position = posn; +#else +void rb_tree::erase(iterator position) { +#endif + link_type z = position.node; + link_type y = z; + link_type x; + if (left(y) == &__rb_NIL) + x = right(y); + else + if (right(y) == &__rb_NIL) + x = left(y); + else { + y = right(y); + while (left(y) != &__rb_NIL) + y = left(y); + x = right(y); + } + if (y != z) { // relink y in place of z + parent(left(z)) = y; + left(y) = left(z); + if (y != right(z)) { + parent(x) = parent(y); // possibly x == &__rb_NIL + left(parent(y)) = x; // y must be a left child + right(y) = right(z); + parent(right(z)) = y; + } else + parent(x) = y; // needed in case x == &__rb_NIL + if (root() == z) + root() = y; + else if (left(parent(z)) == z) + left(parent(z)) = y; + else + right(parent(z)) = y; + parent(y) = parent(z); + ::swap(color(y), color(z)); + ::swap(y, z); + // y points to node to be actually deleted, + // z points to old z's former successor + } else { // y == z + parent(x) = parent(y); // possibly x == &__rb_NIL + if (root() == z) + root() = x; + else + if (left(parent(z)) == z) + left(parent(z)) = x; + else + right(parent(z)) = x; + if (leftmost() == z) + if (right(z) == &__rb_NIL) // left(z) must be &__rb_NIL also + leftmost() = parent(z); + // makes leftmost() == header if z == root() + else + leftmost() = minimum(x); + if (rightmost() == z) + if (left(z) == &__rb_NIL) // right(z) must be &__rb_NIL also + rightmost() = parent(z); + // makes rightmost() == header if z == root() + else // x == left(z) + rightmost() = maximum(x); + } + if (color(y) != red) { + while (x != root() && color(x) == black) + if (x == left(parent(x))) { + link_type w = right(parent(x)); + if (color(w) == red) { + color(w) = black; + color(parent(x)) = red; + rotate_left(parent(x)); + w = right(parent(x)); + } + if (color(left(w)) == black && color(right(w)) == black) { + color(w) = red; + x = parent(x); + } else { + if (color(right(w)) == black) { + color(left(w)) = black; + color(w) = red; + rotate_right(w); + w = right(parent(x)); + } + color(w) = color(parent(x)); + color(parent(x)) = black; + color(right(w)) = black; + rotate_left(parent(x)); + break; + } + } else { // same as then clause with "right" and "left" exchanged + link_type w = left(parent(x)); + if (color(w) == red) { + color(w) = black; + color(parent(x)) = red; + rotate_right(parent(x)); + w = left(parent(x)); + } + if (color(right(w)) == black && color(left(w)) == black) { + color(w) = red; + x = parent(x); + } else { + if (color(left(w)) == black) { + color(right(w)) = black; + color(w) = red; + rotate_left(w); + w = left(parent(x)); + } + color(w) = color(parent(x)); + color(parent(x)) = black; + color(left(w)) = black; + rotate_right(parent(x)); + break; + } + } + color(x) = black; + } +#ifdef __GNUG__ + delete y; +#else + destroy(value_allocator.address(value(y))); + put_node(y); +#endif + --node_count; +} + +template +#ifdef __GNUC__ +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ long unsigned int +#endif +__SIZE_TYPE__ +#else +rb_tree::size_type +#endif +rb_tree::erase(const Key& x) { + pair_iterator_iterator p = equal_range(x); + size_type n = 0; + distance(p.first, p.second, n); + erase(p.first, p.second); + return n; +} + +template +#ifdef __GNUG__ +void * +rb_tree::__copy_hack(void* xa, void* pa) { + link_type x = (link_type)xa; + link_type p = (link_type)pa; +#else +rb_tree::link_type +rb_tree::__copy(link_type x, link_type p) { +#endif + // structural copy + link_type r = x; + while (x != &__rb_NIL) { + link_type y = get_node(); + if (r == x) r = y; // save for return value +#ifdef __GNUG__ + construct(&(value(y)), value(x)); +#else + construct(value_allocator.address(value(y)), value(x)); +#endif + left(p) = y; + parent(y) = p; + color(y) = color(x); + right(y) = __copy(right(x), y); + p = y; + x = left(x); + } + left(p) = (link_type)&__rb_NIL; + return r; +} + +template +#ifdef __GNUG__ +void rb_tree::__erase(void* xa) { + link_type x = (link_type)xa; +#else +void rb_tree::__erase(link_type x) { +#endif + // erase without rebalancing + while (x != &__rb_NIL) { + __erase(right(x)); + link_type y = left(x); +#ifdef __GNUG__ + delete x; +#else + destroy(value_allocator.address(value(x))); + put_node(x); +#endif + x = y; + } +} + +#ifndef __GNUC__ +template +void rb_tree::erase(iterator first, + iterator last) { + if (first == begin() && last == end() && node_count != 0) { + __erase(root()); + leftmost() = header; + root() = NIL; + rightmost() = header; + node_count = 0; + } else + while (first != last) erase(first++); +} +#endif + +template +void rb_tree::erase(const Key* first, + const Key* last) { + while (first != last) erase(*first++); +} + +template +#ifdef __GNUC__ +rb_tree_iterator +rb_tree::find_hack(const Key& k) { +#else +rb_tree::iterator +rb_tree::find(const Key& k) { +#endif + link_type y = header; + link_type x = root(); + bool comp = false; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(key(x), k); + x = comp ? right(x) : left(x); + } + iterator j = iterator(y); + if (comp) ++j; + return (j == end() || key_compare(k, key(j.node))) ? end() : j; +} + +template +#ifdef __GNUC__ +rb_tree_const_iterator +rb_tree::find_hack(const Key& k) const { +#else +rb_tree::const_iterator +rb_tree::find(const Key& k) const { +#endif + link_type y = header; + link_type x = root(); + bool comp = false; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(key(x), k); + x = comp ? right(x) : left(x); + } + const_iterator j = const_iterator(y); + if (comp) ++j; + return (j == end() || key_compare(k, key(j.node))) ? end() : j; +} + +template +#ifdef __GNUG__ +__SIZE_TYPE__ +#else +rb_tree::size_type +#endif +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 +#ifdef __GNUC__ +rb_tree_iterator +rb_tree::lower_bound_hack(const Key& k) { +#else +rb_tree::iterator +rb_tree::lower_bound(const Key& k) { +#endif + link_type y = header; + link_type x = root(); + bool comp = false; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(key(x), k); + x = comp ? right(x) : left(x); + } + iterator j = iterator(y); + return comp ? ++j : j; +} + +template +#ifdef __GNUC__ +rb_tree_const_iterator +rb_tree::lower_bound_hack(const Key& k) const { +#else +rb_tree::const_iterator +rb_tree::lower_bound(const Key& k) const { +#endif + link_type y = header; + link_type x = root(); + bool comp = false; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(key(x), k); + x = comp ? right(x) : left(x); + } + const_iterator j = const_iterator(y); + return comp ? ++j : j; +} + +template +#ifdef __GNUC__ +rb_tree_iterator +rb_tree::upper_bound_hack(const Key& k) { +#else +rb_tree::iterator +rb_tree::upper_bound(const Key& k) { +#endif + link_type y = header; + link_type x = root(); + bool comp = true; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(k, key(x)); + x = comp ? left(x) : right(x); + } + iterator j = iterator(y); + return comp ? j : ++j; +} + +template +#ifdef __GNUC__ +rb_tree_const_iterator +rb_tree::upper_bound_hack(const Key& k) const { +#else +rb_tree::const_iterator +rb_tree::upper_bound(const Key& k) const { +#endif + link_type y = header; + link_type x = root(); + bool comp = true; + while (x != &__rb_NIL) { + y = x; + comp = key_compare(k, key(x)); + x = comp ? left(x) : right(x); + } + const_iterator j = const_iterator(y); + return comp ? j : ++j; +} + + +#ifndef __GNUC__ +template +rb_tree::pair_iterator_iterator +rb_tree::equal_range(const Key& k) { + return pair_iterator_iterator(lower_bound(k), upper_bound(k)); +} + +template +rb_tree::pair_citerator_citerator +rb_tree::equal_range(const Key& k) const { + return pair_citerator_citerator(lower_bound(k), upper_bound(k)); +} + +template +inline void +rb_tree::rotate_left(link_type x) { + link_type y = right(x); + right(x) = left(y); + if (left(y) != &__rb_NIL) + parent(left(y)) = x; + parent(y) = parent(x); + if (x == root()) + root() = y; + else if (x == left(parent(x))) + left(parent(x)) = y; + else + right(parent(x)) = y; + left(y) = x; + parent(x) = y; +} + +template +inline void +rb_tree::rotate_right(link_type x) { + link_type y = left(x); + left(x) = right(y); + if (right(y) != &__rb_NIL) + parent(right(y)) = x; + parent(y) = parent(x); + if (x == root()) + root() = y; + else if (x == right(parent(x))) + right(parent(x)) = y; + else + left(parent(x)) = y; + right(y) = x; + parent(x) = y; +} +#endif + +#endif + diff --git a/gnu/lib/libg++/libstdc++/stl/vector.h b/gnu/lib/libg++/libstdc++/stl/vector.h new file mode 100644 index 00000000000..e609aa109a0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/stl/vector.h @@ -0,0 +1,355 @@ +/* + * + * 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 VECTOR_H +#define VECTOR_H + +#include +#include +#ifndef __GNUG__ +#include +#endif + +#ifndef Allocator +#define Allocator allocator +#include +#endif + +#ifndef vector +#define vector vector +#endif + +template +class vector { +public: + + typedef Allocator vector_allocator; + typedef T value_type; + typedef vector_allocator::pointer pointer; + typedef vector_allocator::pointer iterator; + typedef vector_allocator::const_pointer const_iterator; + typedef vector_allocator::reference reference; + typedef vector_allocator::const_reference const_reference; + typedef vector_allocator::size_type size_type; + typedef vector_allocator::difference_type difference_type; + typedef reverse_iterator const_reverse_iterator; + typedef reverse_iterator + reverse_iterator; +protected: + static Allocator static_allocator; + iterator start; + iterator finish; + iterator end_of_storage; +#ifdef __GNUG__ + void insert_aux(iterator position, const T& x) { + insert_aux(vector_iterator(position), x); + } + void insert_aux(vector_iterator position, const T& x); +#else + void insert_aux(iterator position, const T& x); +#endif +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 static_allocator.max_size(); } + 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 = T()) { + start = static_allocator.allocate(n); + uninitialized_fill_n(start, n, value); + finish = start + n; + end_of_storage = finish; + } + vector(const vector& x) { + start = static_allocator.allocate(x.end() - x.begin()); + finish = uninitialized_copy(x.begin(), x.end(), start); + end_of_storage = finish; + } + vector(const_iterator first, const_iterator last) { + size_type n = 0; + distance(first, last, n); + start = static_allocator.allocate(n); + finish = uninitialized_copy(first, last, start); + end_of_storage = finish; + } + ~vector() { + destroy(start, finish); + static_allocator.deallocate(start); + } + vector& operator=(const vector& x); + void reserve(size_type n) { + if (capacity() < n) { + iterator tmp = static_allocator.allocate(n); + uninitialized_copy(begin(), end(), tmp); + destroy(start, finish); + static_allocator.deallocate(start); + finish = tmp + size(); + start = tmp; + end_of_storage = begin() + 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) { + /* Borland bug */ + 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()) { + /* Borland bug */ + construct(finish, x); + finish++; + } else + insert_aux(position, x); + return begin() + n; + } +#ifdef __GNUG__ + void insert (iterator position, const_iterator first, + const_iterator last) { + insert(vector_iterator(position), + vector_const_iterator(first), + vector_const_iterator(last)); + } + void insert (vector_iterator position, vector_const_iterator first, + vector_const_iterator last); + void insert (iterator position, size_type n, const T& x) { + insert(vector_iterator(position), n, x); + } + void insert (vector_iterator position, size_type n, const T& x); +#else + void insert (iterator position, const_iterator first, + const_iterator last); + void insert (iterator position, size_type n, const T& x); +#endif + void pop_back() { + /* Borland bug */ + --finish; + destroy(finish); + } + void erase(iterator position) { + if (position + 1 != end()) + copy(position + 1, end(), position); + /* Borland bug */ + --finish; + destroy(finish); + } + void erase(iterator first, iterator last) { + vector::iterator i = copy(last, end(), first); + destroy(i, finish); + // work around for destroy(copy(last, end(), first), finish); + finish = finish - (last - first); + } +}; + +#ifdef __GNUG__ +template +struct vector_iterator { + vector::iterator it; + vector_iterator(vector::iterator i) : it(i) {} + operator vector::iterator() { + return it; + } +}; + +template +inline T* value_type(const vector_iterator&) { + return (T*)(0); +} + + +template +struct vector_const_iterator { + vector::const_iterator it; + vector_const_iterator(vector::const_iterator i) : it(i) {} + operator vector::const_iterator() { + return it; + } +}; +#endif + +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()); +} + +#ifndef __GNUG__ +template +vector::vector_allocator vector::static_allocator; +#endif + +template +vector& vector::operator=(const vector& x) { + if (&x == this) return *this; + if (x.size() > capacity()) { + destroy(start, finish); + static_allocator.deallocate(start); + start = static_allocator.allocate(x.end() - x.begin()); + end_of_storage = uninitialized_copy(x.begin(), x.end(), start); + } else if (size() >= x.size()) { + vector::iterator i = copy(x.begin(), x.end(), begin()); + destroy(i, finish); + // work around for destroy(copy(x.begin(), x.end(), begin()), finish); + } else { + copy(x.begin(), x.begin() + size(), begin()); + uninitialized_copy(x.begin() + size(), x.end(), begin() + size()); + } + finish = begin() + x.size(); + return *this; +} + +template +#ifdef __GNUG__ +void vector::insert_aux(vector_iterator posn, const T& x) { + iterator position = posn; +#else +void vector::insert_aux(iterator position, const T& x) { +#endif + if (finish != end_of_storage) { + construct(finish, *(finish - 1)); + copy_backward(position, finish - 1, finish); + *position = x; + ++finish; + } else { + size_type len = size() ? 2 * size() + : static_allocator.init_page_size(); + iterator tmp = static_allocator.allocate(len); + uninitialized_copy(begin(), position, tmp); + construct(tmp + (position - begin()), x); + uninitialized_copy(position, end(), tmp + (position - begin()) + 1); + destroy(begin(), end()); + static_allocator.deallocate(begin()); + end_of_storage = tmp + len; + finish = tmp + size() + 1; + start = tmp; + } +} + +template +#ifdef __GNUG__ +void vector::insert(vector_iterator posn, + size_t n, + const T& x) { + iterator position = posn; +#else +void vector::insert(iterator position, size_type n, const T& x) { +#endif + if (n == 0) return; + if ((size_type) (end_of_storage - finish) >= n) { + if ((size_type) (end() - position) > n) { + uninitialized_copy(end() - n, end(), end()); + copy_backward(position, end() - n, end()); + fill(position, position + n, x); + } else { + uninitialized_copy(position, end(), position + n); + fill(position, end(), x); + uninitialized_fill_n(end(), n - (end() - position), x); + } + finish += n; + } else { + size_type len = size() + max(size(), n); + iterator tmp = static_allocator.allocate(len); + uninitialized_copy(begin(), position, tmp); + uninitialized_fill_n(tmp + (position - begin()), n, x); + uninitialized_copy(position, end(), tmp + (position - begin() + n)); + destroy(begin(), end()); + static_allocator.deallocate(begin()); + end_of_storage = tmp + len; + finish = tmp + size() + n; + start = tmp; + } +} + +template +#ifdef __GNUG__ +void vector::insert(vector_iterator posn, + vector_const_iterator fi, + vector_const_iterator la) { + iterator position = posn; + const_iterator first = fi; + const_iterator last = la; +#else +void vector::insert(iterator position, + const_iterator first, + const_iterator last) { +#endif + if (first == last) return; + size_type n = 0; + distance(first, last, n); + if ((size_type) (end_of_storage - finish) >= n) { + if ((size_type) (end() - position) > n) { + uninitialized_copy(end() - n, end(), end()); + copy_backward(position, end() - n, end()); + copy(first, last, position); + } else { + uninitialized_copy(position, end(), position + n); + copy(first, first + (end() - position), position); + uninitialized_copy(first + (end() - position), last, end()); + } + finish += n; + } else { + size_type len = size() + max(size(), n); + iterator tmp = static_allocator.allocate(len); + uninitialized_copy(begin(), position, tmp); + uninitialized_copy(first, last, tmp + (position - begin())); + uninitialized_copy(position, end(), tmp + (position - begin() + n)); + destroy(begin(), end()); + static_allocator.deallocate(begin()); + end_of_storage = tmp + len; + finish = tmp + size() + n; + start = tmp; + } +} + +#undef Allocator +#undef vector + +#endif + + + + + diff --git a/gnu/lib/libg++/libstdc++/string b/gnu/lib/libg++/libstdc++/string new file mode 100644 index 00000000000..467a2fd0a69 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/string @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __STRING__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/tests/ChangeLog b/gnu/lib/libg++/libstdc++/tests/ChangeLog new file mode 100644 index 00000000000..22d1e3061b0 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/ChangeLog @@ -0,0 +1,44 @@ +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/gnu/lib/libg++/libstdc++/tests/Makefile.in b/gnu/lib/libg++/libstdc++/tests/Makefile.in new file mode 100644 index 00000000000..57ef81369f2 --- /dev/null +++ b/gnu/lib/libg++/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.7.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) -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/gnu/lib/libg++/libstdc++/tests/configure.in b/gnu/lib/libg++/libstdc++/tests/configure.in new file mode 100644 index 00000000000..a32d0495f45 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/configure.in @@ -0,0 +1,49 @@ +# 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) -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}" >>Makefile + + diff --git a/gnu/lib/libg++/libstdc++/tests/tcomplex.cc b/gnu/lib/libg++/libstdc++/tests/tcomplex.cc new file mode 100644 index 00000000000..c9d27360b1b --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tcomplex.cc @@ -0,0 +1,143 @@ +// 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"; + cout << "pow(a, b) = " << pow(a, b) << "\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/gnu/lib/libg++/libstdc++/tests/tcomplex.exp b/gnu/lib/libg++/libstdc++/tests/tcomplex.exp new file mode 100644 index 00000000000..5bef15cd376 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/tests/tcomplex.inp b/gnu/lib/libg++/libstdc++/tests/tcomplex.inp new file mode 100644 index 00000000000..c4e1d84660f --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tcomplex.inp @@ -0,0 +1 @@ +(1.2, -34) diff --git a/gnu/lib/libg++/libstdc++/tests/tlist.cc b/gnu/lib/libg++/libstdc++/tests/tlist.cc new file mode 100644 index 00000000000..313b28b05fc --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tlist.cc @@ -0,0 +1,146 @@ +/* + 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; +} + +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"; + + cout << "\ndone\n"; +} + diff --git a/gnu/lib/libg++/libstdc++/tests/tlist.exp b/gnu/lib/libg++/libstdc++/tests/tlist.exp new file mode 100644 index 00000000000..a888a7152ed --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tlist.exp @@ -0,0 +1,39 @@ + +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, + +done diff --git a/gnu/lib/libg++/libstdc++/tests/tmap.cc b/gnu/lib/libg++/libstdc++/tests/tmap.cc new file mode 100644 index 00000000000..7169f9d20d1 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tmap.cc @@ -0,0 +1,66 @@ +#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; +} diff --git a/gnu/lib/libg++/libstdc++/tests/tmap.exp b/gnu/lib/libg++/libstdc++/tests/tmap.exp new file mode 100644 index 00000000000..b7b5df249fb --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/tests/tstring.cc b/gnu/lib/libg++/libstdc++/tests/tstring.cc new file mode 100644 index 00000000000..490f2c843e7 --- /dev/null +++ b/gnu/lib/libg++/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; +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/gnu/lib/libg++/libstdc++/tests/tstring.exp b/gnu/lib/libg++/libstdc++/tests/tstring.exp new file mode 100644 index 00000000000..3333ab1231d --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/tests/tstring.inp b/gnu/lib/libg++/libstdc++/tests/tstring.inp new file mode 100644 index 00000000000..b0883f382e1 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tstring.inp @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/gnu/lib/libg++/libstdc++/tests/tvector.cc b/gnu/lib/libg++/libstdc++/tests/tvector.cc new file mode 100644 index 00000000000..ef238ef52da --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tvector.cc @@ -0,0 +1,20 @@ +#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; +} diff --git a/gnu/lib/libg++/libstdc++/tests/tvector.exp b/gnu/lib/libg++/libstdc++/tests/tvector.exp new file mode 100644 index 00000000000..84a9d1bf3a4 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/tests/tvector.exp @@ -0,0 +1,4 @@ +Fill of C array: +/************************************************/ +Fill of vector: +/------------------------------------------------/ diff --git a/gnu/lib/libg++/libstdc++/typeinfo b/gnu/lib/libg++/libstdc++/typeinfo new file mode 100644 index 00000000000..93524ed1862 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/typeinfo @@ -0,0 +1,6 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __TYPEINFO__ +#include +#endif diff --git a/gnu/lib/libg++/libstdc++/typeinfoi.cc b/gnu/lib/libg++/libstdc++/typeinfoi.cc new file mode 100644 index 00000000000..01274e009f4 --- /dev/null +++ b/gnu/lib/libg++/libstdc++/typeinfoi.cc @@ -0,0 +1,129 @@ +// Methods for type_info for the -*- C++ -*- Run Time Type Identification. +// 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 Kung Hsu based upon the specification in the 20 September 1994 +// C++ working paper, ANSI document X3J16/94-0158. + +#ifdef __GNUG__ +#pragma implementation "std/typeinfo.h" +#endif + +#include +#include + +// Offset functions for the class type. + +// 0 is returned if the cast is invalid, otherwise the converted +// object pointer that points to the sub-object that is matched is +// returned. + +void* __class_type_info::__rtti_match(const type_info& desired, int is_public, + void *objptr) const +{ + if (__rtti_compare(desired) == 0) + return objptr; + + void *match_found = 0; + for (int i = 0; i < n_bases; i++) { + if (is_public && access_list[i] != _RTTI_ACCESS_PUBLIC) + continue; + void *p = (char *)objptr + offset_list[i]; + if (is_virtual_list[i]) + p = *(void **)p; + + if ((p=base_list[i]->__rtti_match(desired, is_public, p)) + != 0) + if (match_found == 0) + match_found = p; + else if (match_found != p) { + // base found at two different pointers, + // conversion is not unique + return 0; + } + } + + return match_found; +} + +void* __pointer_type_info::__rtti_match(const type_info& catch_type, int, + void *objptr) const +{ + if (catch_type.__rtti_get_node_type () == __rtti_get_node_type()) + { + type_info &sub_catch_type = ((__pointer_type_info&)catch_type).type; + type_info &sub_throw_type = ((__pointer_type_info*)this)->type; + if (sub_catch_type.__rtti_get_node_type () == _RTTI_BUILTIN_TYPE + && ((__builtin_type_info&)sub_catch_type).b_type == __builtin_type_info::_RTTI_BI_VOID) + { + return objptr; + } + if (sub_catch_type.__rtti_get_node_type () == _RTTI_ATTR_TYPE + && ((__attr_type_info&)sub_catch_type).attr == __attr_type_info::_RTTI_ATTR_CONST) + { + /* We have to allow a catch of const int* on a int * throw. */ + type_info &sub_sub_catch_type = ((__attr_type_info&)sub_catch_type).type; + return __throw_type_match_rtti (&sub_sub_catch_type, &sub_throw_type, objptr); + } + return __throw_type_match_rtti (&sub_catch_type, &sub_throw_type, objptr); + } + return 0; +} + +/* Low level match routine used by compiler to match types of catch variables and thrown + objects. */ +extern "C" +void* +__throw_type_match_rtti (void *catch_type_r, void *throw_type_r, void *objptr) +{ + type_info &catch_type = *(type_info*)catch_type_r; + type_info &throw_type = *(type_info*)throw_type_r; + void *new_objptr; + + if (catch_type == throw_type) + return objptr; + + /* Ensure we can call __rtti_match. */ + if ((throw_type.__rtti_get_node_type () != type_info::_RTTI_CLASS_TYPE + && throw_type.__rtti_get_node_type () != type_info::_RTTI_USER_TYPE + && throw_type.__rtti_get_node_type () != type_info::_RTTI_POINTER_TYPE) + || ((catch_type.__rtti_get_node_type () != type_info::_RTTI_CLASS_TYPE + && catch_type.__rtti_get_node_type () != type_info::_RTTI_USER_TYPE + && catch_type.__rtti_get_node_type () != type_info::_RTTI_POINTER_TYPE))) + return 0; + +#if 0 + printf("We want to match a %s against a %s!\n", + throw_type.name(), catch_type.name()); +#endif + + /* The 1 skips conversions to private bases. */ + new_objptr = throw_type.__rtti_match (catch_type, 1, objptr); +#if 0 + if (new_objptr) + printf("It converts, delta is %d\n", new_objptr-objptr); +#endif + return new_objptr; +} + +bad_cast __bad_cast_object ("bad_cast"); diff --git a/gnu/lib/libg++/libstdc++/utility b/gnu/lib/libg++/libstdc++/utility new file mode 100644 index 00000000000..fb79aa78274 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/libstdc++/vector b/gnu/lib/libg++/libstdc++/vector new file mode 100644 index 00000000000..79f73593751 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/move-if-change b/gnu/lib/libg++/move-if-change new file mode 100644 index 00000000000..ee9e355e3e6 --- /dev/null +++ b/gnu/lib/libg++/move-if-change @@ -0,0 +1,15 @@ +#!/bin/sh +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/gnu/lib/libg++/mpw-README b/gnu/lib/libg++/mpw-README new file mode 100644 index 00000000000..30af1d2450e --- /dev/null +++ b/gnu/lib/libg++/mpw-README @@ -0,0 +1,207 @@ +This is preliminary information about the Macintosh(tm) MPW(tm) port +of the Cygnus GNU tools. + + +INSTALLING CYGNUS GNU TOOLS + +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 MPW C unless you want to rebuild from sources, nor even any +include files, unless you are building actual Mac applications. + +The Cygnus GNU tools can go in any directory that is in your +{Commands} list. We generally put all the tools in something like +{Boot}Cygnus:latest:bin, and something like this in the 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:mips-idt-ecoff:cygnus-2.6.4-950305: + +If you built and installed everything yourself according to the build +instructions, 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 + + +USING CYGNUS GNU TOOLS + +To compile and link a file "foo.c", say + + gC foo.c + +This port of GCC exactly the same option syntax as its Unix +counterpart. It also has similar compilation rules, so it will run +the assembler on .s files and so forth. For the example above, the +output file will be an MPW binary file named "a.out". + +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 MPW C, GCC directs assembly +and linking in addition to compilation. + +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 actually called +"c++filt" under Unix.) + +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 +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. + +Currently, both flavors of GDB can only do cross-debugging, via the +serial port. + + +BUILDING CYGNUS GNU TOOLS + +This port of the Cygnus 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". + +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 + forward-include script + MoveIfChange script + open-brace script + sed (1.13) tool + tr-7to8 script + +The scripts are in the sources, under utils:mpw:, while you must +arrange to get the other tools yourself (they are readily available +from the "usual" net sites, and are also on many CDROMS). + + set Commands "{Boot}Cygnus:buildtools:,{Commands}" + + Set FLEX_SKELETON "{Boot}"Cygnus:buildtools:Flex.skel + Export FLEX_SKELETON + +To build everything, setdirectory to the object directory and do: + + {Boot}Cygnus:src:mpw-configure --target --cc --srcdir {Boot}Cygnus:src: --prefix + +If the 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. + +Then the command + + mpw-build + +will build everything, and + + mpw-build install + +will install it. Building will take over an hour on a Quadra 800. + +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 CW 7. +KNOWN BUGS + +'/' 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 + +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. diff --git a/gnu/lib/libg++/mpw-build.in b/gnu/lib/libg++/mpw-build.in new file mode 100644 index 00000000000..8e5c07111cc --- /dev/null +++ b/gnu/lib/libg++/mpw-build.in @@ -0,0 +1,191 @@ +# 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-ld + "{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}" all-byacc + "{ThisScript}" do-flex +Else If "{BuildTarget}" =~ /all-binutils/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" all-byacc + "{ThisScript}" all-flex + "{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-byacc + "{ThisScript}" all-gas + "{ThisScript}" all-binutils + "{ThisScript}" do-gcc +Else If "{BuildTarget}" =~ /all-gdb/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" all-byacc + "{ThisScript}" do-gdb +Else If "{BuildTarget}" =~ /all-ld/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" all-byacc + "{ThisScript}" all-flex + "{ThisScript}" do-ld +Else If "{BuildTarget}" =~ /do-byacc/ + SetDirectory :byacc: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-flex/ + SetDirectory :flex: + ::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 all +Else If "{BuildTarget}" =~ /do-gas/ + SetDirectory :gas: + ::mpw-build stamps + ::mpw-build all +Else If "{BuildTarget}" =~ /do-gcc/ + SetDirectory :gcc: + # Need separate step to build all the insn-... etc files. + ::mpw-build stamps-h + ::mpw-build stamps-c + ::mpw-build all +Else If "{BuildTarget}" =~ /do-gdb/ + SetDirectory :gdb: + ::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-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-ld/ + SetDirectory :ld: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-only/ + "{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-ld/ + SetDirectory :ld: + ::mpw-build install-only +Else + Echo {BuildTarget} not understood, ignoring +End If + +SetDirectory "{savedir}" diff --git a/gnu/lib/libg++/mpw-config.in b/gnu/lib/libg++/mpw-config.in new file mode 100644 index 00000000000..ab7e0ec2167 --- /dev/null +++ b/gnu/lib/libg++/mpw-config.in @@ -0,0 +1,98 @@ +# 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 open-brace is `Which open-brace` +Echo sed is `Which sed` +Echo mpw-touch is `Which mpw-touch` +Echo 'tr-7to8' is `Which tr-7to8` +Set Exit 1 + +Set host_libs "libiberty opcodes bfd readline" + +Set host_tools "byacc flex binutils ld gas gcc gdb" + +Set target_libs "newlib" + +Set target_tools "examples" + +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: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' + +# Make the README more visible. + +Catenate "{srcdir}"mpw-README > "{objdir}Read Me for MPW" diff --git a/gnu/lib/libg++/mpw-configure b/gnu/lib/libg++/mpw-configure new file mode 100644 index 00000000000..ecbd1b9068a --- /dev/null +++ b/gnu/lib/libg++/mpw-configure @@ -0,0 +1,342 @@ +# Configuration script +# Copyright (C) 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 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 (and mpw-config.in fragments) 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 ":" + +Set host_alias "m68k-apple-mpw" + +Set target_alias {host_alias} + +Set host_cc "mpwc" + +Set prefix "{MPW}":Cygnus:latest: + +Set verify 0 +Set verifystr "" + +# Parse arguments. + +Loop + Break If {#} == 0 + If "{1}" =~ /--cc/ + Set host_cc "{2}" + Shift 1 + Else If "{1}" =~ /--host/ + Set host_alias "{2}" + Shift 1 + 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" + Shift 1 + Else + Echo "{1}" is not a valid argument + Exit 1 + End If + Shift 1 +End Loop + +Set Exit 0 + +# 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 {Default}' + 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 {Default}' + 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 {Default}' + 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_C}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_PPC}' +Else If "{host_cc}" =~ /gcc68k/ + Set host_alias "m68k-apple-mpw" + Set cc_name '{CC_68K_GCC}' + Set segment_flag '-s {Default}' + 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 '' + 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 '' + 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 '' + 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 '' + 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 '' + Set ar_name '{AR_PPCLINK}' + Set ranlib_name '{RANLIB_RANLIB}' + 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 + Echo "{host_cc}" is not a known MPW C compiler type +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}" >>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 "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 + +# 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 + If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != "" + sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 + Else + Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1 + End If + sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 + sed -e "s/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem2 >"{objdir}"mpw-make.in + tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem + 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/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 + tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem + 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 + +For subdir In {configdirs} + Set savedir "`Directory`" + If "`Exists "{srcdir}{subdir}:"`" == "" + Echo Strange, no {subdir} in {srcdir} + 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} + SetDirectory "{savedir}" +End For + +SetDirectory "{savedir}" diff --git a/gnu/lib/libg++/texinfo/gpl.texinfo b/gnu/lib/libg++/texinfo/gpl.texinfo new file mode 100644 index 00000000000..ce7d62ec8f8 --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/texinfo/lgpl.texinfo b/gnu/lib/libg++/texinfo/lgpl.texinfo new file mode 100644 index 00000000000..5a57ff9620a --- /dev/null +++ b/gnu/lib/libg++/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/gnu/lib/libg++/texinfo/tex3patch b/gnu/lib/libg++/texinfo/tex3patch new file mode 100644 index 00000000000..e3586224c6a --- /dev/null +++ b/gnu/lib/libg++/texinfo/tex3patch @@ -0,0 +1,68 @@ +#!/bin/sh +# Auxiliary script to work around TeX 3.0 bug. +# 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 diff --git a/gnu/lib/libg++/texinfo/texinfo.tex b/gnu/lib/libg++/texinfo/texinfo.tex new file mode 100644 index 00000000000..50db717ac71 --- /dev/null +++ b/gnu/lib/libg++/texinfo/texinfo.tex @@ -0,0 +1,4119 @@ +%% TeX macros to handle texinfo files + +% Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 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, 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! + +\def\texinfoversion{2.122} +\message{Loading texinfo package [Version \texinfoversion]:} + +% Print the version number if in a .fmt file. +\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} + +% Save some parts of plain tex whose names we will redefine. + +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexdots=\dots +\let\ptexdot=\. +\let\ptexstar=\* +\let\ptexend=\end +\let\ptexbullet=\bullet +\let\ptexb=\b +\let\ptexc=\c +\let\ptexi=\i +\let\ptext=\t +\let\ptexl=\l +\let\ptexL=\L + +\def\tie{\penalty 10000\ } % Save plain tex definition of ~. + +\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 \bindingoffset=0pt +\newdimen \normaloffset \normaloffset=\hoffset +\newdimen\pagewidth \newdimen\pageheight +\pagewidth=\hsize \pageheight=\vsize + +% 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 +}% + +%---------------------Begin change----------------------- +% +%%%% For @cropmarks command. +% 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 +% +%---------------------End change----------------------- + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions itself, but you have to call it yourself. +\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} +\def\onepageout#1{\hoffset=\normaloffset +\ifodd\pageno \advance\hoffset by \bindingoffset +\else \advance\hoffset by -\bindingoffset\fi +{\escapechar=`\\\relax % makes sure backslash is used in output files. +\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% +{\let\hsize=\pagewidth \makefootline}}}% +\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} + +%%%% For @cropmarks command %%%% + +% Here is a modification of the main output routine for Near East Publications +% This provides right-angle cropmarks at all four corners. +% The contents of the page are centerlined into the cropmarks, +% and any desired binding offset is added as an \hskip on either +% site of the centerlined box. (P. A. MacKay, 12 November, 1986) +% +\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up +{\escapechar=`\\\relax % makes sure backslash is used in output files. + \shipout + \vbox to \outervsize{\hsize=\outerhsize + \vbox{\line{\ewtop\hfill\ewtop}} + \nointerlineskip + \line{\vbox{\moveleft\cornerthick\nstop} + \hfill + \vbox{\moveright\cornerthick\nstop}} + \vskip \topandbottommargin + \centerline{\ifodd\pageno\hskip\bindingoffset\fi + \vbox{ + {\let\hsize=\pagewidth \makeheadline} + \pagebody{#1} + {\let\hsize=\pagewidth \makefootline}} + \ifodd\pageno\else\hskip\bindingoffset\fi} + \vskip \topandbottommargin plus1fill minus1fill + \boxmaxdepth\cornerthick + \line{\vbox{\moveleft\cornerthick\nsbot} + \hfill + \vbox{\moveright\cornerthick\nsbot}} + \nointerlineskip + \vbox{\line{\ewbot\hfill\ewbot}} + }} + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi} +% +% Do @cropmarks to get crop marks +\def\cropmarks{\let\onepageout=\croppageout } + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\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 = \baselineskip +\def\singlespace{% +% Why was this kern here? It messes up equalizing space above and below +% environments. --karl, 6may93 +%{\advance \baselineskip by -\singlespaceskip +%\kern \baselineskip}% +\baselineskip=\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 + +% @: 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 } + +% @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 + % + % We do @comment here in case 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{.$\,$.$\,$.\:} + +% @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}}}} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. + +\def\include{\parsearg\includezzz} +%Use \input\thisfile to avoid blank after \input, which may be an active +%char (in which case the blank would become the \input argument). +%The grouping keeps the value of \thisfile correct even when @include +%is nested. +\def\includezzz #1{\begingroup +\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{\par \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 + +% 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\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\include = \relax + \let\lowersections = \relax + \let\down = \relax + \let\raisesections = \relax + \let\up = \relax + \let\set = \relax + \let\clear = \relax + \let\item = \relax + \let\message = \relax +} + +% Ignore @ignore ... @end ignore. +% +\def\ignore{\doignore{ignore}} + +% Also ignore @ifinfo, @menu, and @direntry text. +% +\def\ifinfo{\doignore{ifinfo}} +\def\menu{\doignore{menu}} +\def\direntry{\doignore{direntry}} + +% 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{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{} + \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. +% +\def\set{\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 +} +\def\setzzz#1#2 \endsetzzz{\expandafter\xdef\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#1{\expandafter + \ifx\csname SET#1\endcsname\relax + {\{No value for ``#1''\}} + \else \csname SET#1\endcsname \fi} + +% @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 +\let\lastnode=\relax} + +\def\unnumbnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi +\let\lastnode=\relax} + +\def\appendixnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi +\let\lastnode=\relax} + +\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. +} + +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#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. + +%% Try out Computer Modern fonts at \magstephalf +\let\mainmagstep=\magstephalf + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\font\textrm=cmr12 +\font\texttt=cmtt12 +\else +\font\textrm=cmr10 scaled \mainmagstep +\font\texttt=cmtt10 scaled \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. +\font\textbf=cmb10 scaled \mainmagstep +\font\textit=cmti10 scaled \mainmagstep +\font\textsl=cmsl10 scaled \mainmagstep +\font\textsf=cmss10 scaled \mainmagstep +\font\textsc=cmcsc10 scaled \mainmagstep +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\font\defbf=cmbx10 scaled \magstep1 %was 1314 +\font\deftt=cmtt10 scaled \magstep1 +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples. +% 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. +\font\ninett=cmtt9 +\font\indrm=cmr9 +\font\indit=cmsl9 +\let\indsl=\indit +\let\indtt=\ninett +\let\indsf=\indrm +\let\indbf=\indrm +\let\indsc=\indrm +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Fonts for headings +\font\chaprm=cmbx12 scaled \magstep2 +\font\chapit=cmti12 scaled \magstep2 +\font\chapsl=cmsl12 scaled \magstep2 +\font\chaptt=cmtt12 scaled \magstep2 +\font\chapsf=cmss12 scaled \magstep2 +\let\chapbf=\chaprm +\font\chapsc=cmcsc10 scaled\magstep3 +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +\font\secrm=cmbx12 scaled \magstep1 +\font\secit=cmti12 scaled \magstep1 +\font\secsl=cmsl12 scaled \magstep1 +\font\sectt=cmtt12 scaled \magstep1 +\font\secsf=cmss12 scaled \magstep1 +\font\secbf=cmbx12 scaled \magstep1 +\font\secsc=cmcsc10 scaled\magstep2 +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. +% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. +% \font\ssecsl=cmsl10 scaled \magstep1 +% \font\ssectt=cmtt10 scaled \magstep1 +% \font\ssecsf=cmss10 scaled \magstep1 + +%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. +%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than +%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. +%\font\ssectt=cmtt10 scaled 1315 +%\font\ssecsf=cmss10 scaled 1315 + +%\let\ssecbf=\ssecrm + +\font\ssecrm=cmbx12 scaled \magstephalf +\font\ssecit=cmti12 scaled \magstephalf +\font\ssecsl=cmsl12 scaled \magstephalf +\font\ssectt=cmtt12 scaled \magstephalf +\font\ssecsf=cmss12 scaled \magstephalf +\font\ssecbf=cmbx12 scaled \magstephalf +\font\ssecsc=cmcsc10 scaled \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: +\font\titlerm = cmbx12 scaled \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. Plain TeX does, for example, +% \def\bf{\fam=\bffam \tenbf} 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 + \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 + \resetmathfonts} +\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 + \resetmathfonts} +\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 + \resetmathfonts} +\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 + \resetmathfonts} + +% 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. +\font\shortcontrm=cmr12 +\font\shortcontbf=cmbx12 +\font\shortcontsl=cmsl12 + +%% 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 \nohyphenation \rawbackslash \frenchspacing #1}% + \null +} +\let\ttfont = \t +%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} +\def\samp #1{`\tclose{#1}'\null} +\def\key #1{{\tt \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 overful 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 an a dash. +% -- rms. +{ +\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 +\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder} +} +\def\realdash{-} +\def\realunder{_} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{\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{\look}\fi +\else\tclose{\look}\fi} + +% 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} + +\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 + +\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. + +\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{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +\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}} +} + +\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}} +} + +% 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\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}% Neccessary 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} + +\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. +\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\samp##1{\realbackslash samp {##1}}% +\def\t##1{\realbackslash r {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##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}}% +} + +% \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\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\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 +} + +% 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. + +\def\doind #1#2{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% 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 in the indx. +% +% 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}% +}% +% 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}}}% +\temp }% +}\penalty\count10}} + +\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. + +% This is what you call to cause a particular index to get printed. +% Write +% @unnumbered Function Index +% @printindex fn + +\def\printindex{\parsearg\doprintindex} + +\def\doprintindex#1{% + \tex + \dobreak \chapheadingskip {10000} + \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other + \catcode`\$=\other + \catcode`\~=\other + \indexbreaks + % + % The following don't help, since the chars were translated + % when the raw index was written, and their fonts were discarded + % due to \indexnofonts. + %\catcode`\"=\active + %\catcode`\^=\active + %\catcode`\_=\active + %\catcode`\|=\active + %\catcode`\<=\active + %\catcode`\>=\active + % % + \def\indexbackslash{\rawbackslashxx} + \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt + \begindoublecolumns + % + % 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 + \input \jobname.#1s + \fi + \fi + \closein 1 + \enddoublecolumns + \Etex +} + +% 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 kluged 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 is used in indexes. +%% Adapted from the TeXbook, page 416. +\catcode `\@=11 + +\newbox\partialpage + +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup + % Grab any single-column material above us. + \output = {\global\setbox\partialpage + =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% + \eject + % + % Now switch to the double-column output routine. + \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 once. + % + % 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 + \doublecolumnpagegoal +} + +\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} + +\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth + \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage + \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} + \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} + \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi + \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi +} +\def\doublecolumnpagegoal{% + \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ +} +\def\pagesofar{\unvbox\partialpage % + \hsize=\doublecolumnhsize % have to restore this since output routine + \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} +\def\doublecolumnout{% + \setbox5=\copy255 + {\vbadness=10000 \doublecolumnsplit} + \ifvbox255 + \setbox0=\vtop to\dimen@{\unvbox0} + \setbox2=\vtop to\dimen@{\unvbox2} + \onepageout\pagesofar \unvbox255 \penalty\outputpenalty + \else + \setbox0=\vbox{\unvbox5} + \ifvbox0 + \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip + \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth + {\vbadness=10000 + \loop \global\setbox5=\copy0 + \setbox1=\vsplit5 to\dimen@ + \setbox3=\vsplit5 to\dimen@ + \ifvbox5 \global\advance\dimen@ by1pt \repeat + \setbox0=\vbox to\dimen@{\unvbox1} + \setbox2=\vbox to\dimen@{\unvbox3} + \global\setbox\partialpage=\vbox{\pagesofar} + \doublecolumnpagegoal + } + \fi + \fi +} + +\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{\if \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{Chapter \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% +\edef\temp{{\realbackslash chapentry {#1}{\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% +\edef\temp{{\realbackslash chapentry + {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +}} + +\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% +\edef\temp{{\realbackslash unnumbchapentry {#1}{\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% +\edef\temp{{\realbackslash secentry % +{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appenixsection{\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% +\edef\temp{{\realbackslash secentry % +{#1}{\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% +\edef\temp{{\realbackslash unnumbsecentry{#1}{\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% +\edef\temp{{\realbackslash subsecentry % +{#1}{\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% +\edef\temp{{\realbackslash subsecentry % +{#1}{\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}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\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% +\edef\temp{{\realbackslash subsubsecentry % + {#1} + {\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% +\edef\temp{{\realbackslash subsubsecentry{#1}% + {\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}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\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} + +\def\heading{\parsearg\secheadingi} + +\def\subheading{\parsearg\subsecheadingi} + +\def\subsubheading{\parsearg\subsubsecheadingi} + +% 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 \chapheadingskip = 30pt plus 8pt minus 4pt + +\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\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{ +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain} + +\def\chfplain #1#2{% + \pchapsepmacro + {% + \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #2\enspace #1}% + }% + \bigskip + \penalty5000 +} + +\def\unnchfplain #1{% +\pchapsepmacro % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} +\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\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen} + +% Parameter controlling skip before section headings. + +\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} + +\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} + +% @paragraphindent is defined for the Info formatting commands only. +\let\paragraphindent=\comment + +% Section fonts are the base font at magstep2, which produces +% a size a bit more than 14 points in the default situation. + +\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} +\def\plainsecheading #1{\secheadingi {#1}} +\def\secheadingi #1{{\advance \secheadingskip by \parskip % +\secheadingbreak}% +{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + + +% Subsection fonts are the base font at magstep1, +% which produces a size of 12 points. + +\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} +\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + +\def\subsubsecfonts{\subsecfonts} % Maybe this should change: + % Perhaps make sssec fonts scaled + % magstep half +\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} +\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} + + +\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{% + \pagealignmacro + \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 + \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 + \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 in \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 would want to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno{#2}}% + \endgroup + \nobreak\vskip .25\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.) +% +\def\tocentry#1#2{\begingroup + \hyphenpenalty = 10000 + \entry{#1}{#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 + +\let\ptexequiv = \equiv + +%{\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} +%} + +\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 +\catcode`\"=12 +\catcode`\==12 +\catcode`\|=12 +\catcode`\<=12 +\catcode`\>=12 +\escapechar=`\\ +% +\let\{=\ptexlbrace +\let\}=\ptexrbrace +\let\.=\ptexdot +\let\*=\ptexstar +\let\dots=\ptexdots +\def\@{@}% +\let\bullet=\ptexbullet +\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl +\let\L=\ptexL +% +\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 interline space and fonts for small examples. + \baselineskip 10pt + \indexfonts \tt + \rawbackslash % output the \ character from the current font + \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 and narrows the margins. +% +\def\quotation{% +\begingroup\inENV %This group ends at the end of the @quotation body +{\parskip=0pt % because we will skip by \parskip too, later +\aboveenvbreak}% +\singlespace +\parindent=0pt +\let\Equotation = \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} + +% 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`\(}} \def\clnr{{\sf\char`\)}} \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, putting the result in \tptemp. +% +\def\removeemptybraces\empty#1\relax{\def\tptemp{#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{% + \removeemptybraces#2\relax + #1{\tptemp}{#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 parens in @def arguments}\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. +\functionparens +\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 {\code{#1} #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} + +% #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 {\code{#2} #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\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 % +} + +% @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. +\def\deftypevarheader #1#2{% +\doind {vr}{\code{#2}}% Make entry in variables index +\begingroup\defname {\code{#1} #2}{Variable}% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% +\begingroup\defname {\code{#2} #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. + +% \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. +\ifx SETxref-automatic-section-title % +% This line should make the actual chapter or 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% +% We know the real title if we have the xref values. +\ifhavexrefs \def\printednodename{\refx{#1-title}}% +% Otherwise just copy the Info node name. +\else \def\printednodename{\ignorespaces #1} \fi% +\fi\def\printednodename{#1-title}% +\else% This line just uses the node name. +\def\printednodename{\ignorespaces #1}% +\fi% ends \ifx SETxref-automatic-section-title +\fi% ends \ifdim \wd0 +% +% +% 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 simply 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% +\turnoffactive% +\refx{#1-snt}{} [\printednodename], \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. +} + +% Read the last existing aux file, if any. No error if none exists. + +% This is the macro invoked by entries in the aux file. +\def\xrdef #1#2{ +{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} + +\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 +\catcode 26=\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 +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode `\$=\other +\catcode `\#=\other +\catcode `\&=\other +% `\+ does not work, so use 43. +\catcode 43=\other +% the aux file uses ' as the escape. +% 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. +\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. +% +\long\gdef\footnotezzz#1{\insert\footins{% + % 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 + #1\strut}% +} + +}%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 = 6.5in +\newdimen\defaultparindent \defaultparindent = 15pt +\parindent = \defaultparindent +\parskip 18pt plus 1pt +\setleading{15pt} +\advance\topskip by 1.2cm + +% 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{ + +% These values for secheadingskip and subsecheadingskip are +% experiments. RJC 7 Aug 1992 +\global\secheadingskip = 17pt plus 6pt minus 3pt +\global\subsecheadingskip = 14pt plus 6pt minus 3pt + +\global\lispnarrowing = 0.3in +\setleading{12pt} +\advance\topskip by -1cm +\global\parskip 3pt plus 1pt +\global\hsize = 5in +\global\vsize=7.5in +\global\tolerance=700 +\global\hfuzz=1pt +\global\contentsrightmargin=0pt + +\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 +} + +% 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\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +% \lvvmode is equivalent in function to \leavevmode. +% Using \leavevmode runs into trouble when written out to +% an index file due to the expansion of \leavevmode into ``\unhbox +% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our +% magic tricks with @. +\def\lvvmode{\vbox to 0pt{}} + +\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$} + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +\def\turnoffactive{\let"=\normaldoublequote +\let~=\normaltilde +\let^=\normalcaret +\let_=\normalunderscore +\let|=\normalverticalbar +\let<=\normalless +\let>=\normalgreater +\let+=\normalplus} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\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 + +% 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. +% +@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} + +%% 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: -- 2.20.1