home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GCC258_2.LHA / gcc / src-patches / libg++-2.5.3.diff
Encoding:
Text File  |  1993-12-27  |  136.8 KB  |  4,789 lines

  1. diff -rc2N /free/libg++-2.5.3/Makefile /sources/libg++-2.5.3-amiga/Makefile
  2. *** /free/libg++-2.5.3/Makefile    Thu Jan  1 00:00:00 1970
  3. --- /sources/libg++-2.5.3-amiga/Makefile    Sun Dec  5 16:47:57 1993
  4. ***************
  5. *** 0 ****
  6. --- 1,1133 ----
  7. + # This file was generated automatically by configure.  Do not edit.
  8. + VPATH = .
  9. + links = 
  10. + host_alias = amigados
  11. + host_cpu = m68k
  12. + host_vendor = cbm
  13. + host_os = amigados
  14. + host_canonical = m68k-cbm-amigados
  15. + target_alias = amigados
  16. + target_cpu = m68k
  17. + target_vendor = cbm
  18. + target_os = amigados
  19. + target_canonical = m68k-cbm-amigados
  20. + #
  21. + # Makefile for directory with subdirs to build.
  22. + #   Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation
  23. + #
  24. + # This file is free software; you can redistribute it and/or modify
  25. + # it under the terms of the GNU General Public License as published by
  26. + # the Free Software Foundation; either version 2 of the License, or
  27. + # (at your option) any later version.
  28. + # 
  29. + # This program is distributed in the hope that it will be useful,
  30. + # but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  32. + # GNU General Public License for more details.
  33. + # 
  34. + # You should have received a copy of the GNU General Public License
  35. + # along with this program; if not, write to the Free Software
  36. + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  37. + #
  38. + srcdir = .
  39. + prefix = /usr/local
  40. + exec_prefix = $(prefix)
  41. + bindir = $(exec_prefix)/bin
  42. + libdir = $(exec_prefix)/lib
  43. + tooldir = $(exec_prefix)/amigados
  44. + program_transform_name = 
  45. + datadir = $(prefix)/lib
  46. + mandir = $(prefix)/man
  47. + man1dir = $(mandir)/man1
  48. + man2dir = $(mandir)/man2
  49. + man3dir = $(mandir)/man3
  50. + man4dir = $(mandir)/man4
  51. + man5dir = $(mandir)/man5
  52. + man6dir = $(mandir)/man6
  53. + man7dir = $(mandir)/man7
  54. + man8dir = $(mandir)/man8
  55. + man9dir = $(mandir)/man9
  56. + infodir = $(prefix)/info
  57. + includedir = $(prefix)/include
  58. + docdir = $(datadir)/doc
  59. + SHELL = /bin/sh
  60. + INSTALL = $${srcroot}/install.sh -c
  61. + INSTALL_PROGRAM = $(INSTALL)
  62. + INSTALL_DATA = $(INSTALL)
  63. + INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
  64. + AS = as
  65. + AR = ar
  66. + AR_FLAGS = rc
  67. + CC = gcc
  68. + # We don't specify -g -O because many compilers don't support -g -O,
  69. + # and/or -O is broken in and of itself.
  70. + CFLAGS = -O2
  71. + CXX = gcc
  72. + # Use -O to stress test the compiler.
  73. + CXXFLAGS = -O2
  74. + RANLIB = ranlib
  75. + NM = nm
  76. + MUNCH_NM = $(NM)
  77. + GZIP = gzip
  78. + BISON = bison -y
  79. + LEX = `if [ -f $${rootme}/flex/flex ] ; \
  80. +     then echo $${rootme}/flex/flex ; \
  81. +     else echo flex ; fi`
  82. + M4 = `if [ -f $${rootme}/m4/m4 ] ; \
  83. +     then echo $${rootme}/m4/m4 ; \
  84. +     else echo m4 ; fi`
  85. + MAKEINFO = `if [ -f $${rootme}/texinfo/makeinfo/makeinfo ] ; \
  86. +     then echo $${rootme}/texinfo/makeinfo/makeinfo ; \
  87. +     else echo makeinfo ; fi`
  88. + # This just becomes part of the MAKEINFO definition passed down to
  89. + # sub-makes.  It lets flags be given on the command line while still
  90. + # using the makeinfo from the object tree.
  91. + MAKEINFOFLAGS =
  92. + EXPECT = `if [ -f $${rootme}/expect/expect ] ; \
  93. +     then echo $${rootme}/expect/expect ; \
  94. +     else echo expect ; fi`
  95. + RUNTEST = `if [ -f $${srcroot}/dejagnu/runtest ] ; \
  96. +     then echo $${srcroot}/dejagnu/runtest ; \
  97. +     else echo runtest ; fi`
  98. + # libraries that may need to be augmented on a system-by-system basis
  99. + X11_LIB = -lX11
  100. + # compilers to use to create programs which must be run in the build
  101. + # environment.
  102. + CC_FOR_BUILD = $(CC)
  103. + CXX_FOR_BUILD = $(CXX)
  104. + SUBDIRS = mmalloc libiberty opcodes bfd readline gash tcl tk tclX 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 uudecode hello tar gzip indent recode release sed utils libm  libio libg++ groff
  105. + OTHERS = 
  106. + ALL = all.normal
  107. + INSTALL_TARGET = install-dirs \
  108. +     $(INSTALL_MODULES) \
  109. +     $(INSTALL_TARGET_MODULES) \
  110. +     $(INSTALL_X11_MODULES) \
  111. +     install-gcc
  112. + CC_FOR_TARGET = ` \
  113. +   if [ -f $${rootme}/gcc/Makefile ] ; then \
  114. +     echo $${rootme}/gcc/xgcc -B$${rootme}/gcc/; \
  115. +   else \
  116. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  117. +       echo $(CC); \
  118. +     else \
  119. +       t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \
  120. +     fi; \
  121. +   fi`
  122. + CXX_FOR_TARGET = ` \
  123. +   if [ -f $${rootme}/gcc/Makefile ] ; then \
  124. +     echo $${rootme}/gcc/xgcc -B$${rootme}/gcc/; \
  125. +   else \
  126. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  127. +       echo $(CXX); \
  128. +     else \
  129. +       t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \
  130. +     fi; \
  131. +   fi`
  132. + AS_FOR_TARGET = ` \
  133. +   if [ -f $${rootme}/gas/Makefile ] ; then \
  134. +     echo $${rootme}/gas/as.new ; \
  135. +   else \
  136. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  137. +       echo $(AS); \
  138. +     else \
  139. +        t='$(program_transform_name)'; echo as | sed -e '' $$t ; \
  140. +     fi; \
  141. +   fi`
  142. + AR_FOR_TARGET = ` \
  143. +   if [ -f $${rootme}/binutils/ar ] ; then \
  144. +     echo $${rootme}/binutils/ar ; \
  145. +   else \
  146. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  147. +       echo $(AR); \
  148. +     else \
  149. +        t='$(program_transform_name)'; echo ar | sed -e '' $$t ; \
  150. +     fi; \
  151. +   fi`
  152. + RANLIB_FOR_TARGET = ` \
  153. +   if [ -f $${rootme}/binutils/ranlib ] ; then \
  154. +     echo $${rootme}/binutils/ranlib ; \
  155. +   else \
  156. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  157. +       echo $(RANLIB); \
  158. +     else \
  159. +        t='$(program_transform_name)'; echo ranlib | sed -e '' $$t ; \
  160. +     fi; \
  161. +   fi`
  162. + NM_FOR_TARGET = ` \
  163. +   if [ -f $${rootme}/binutils/Makefile ] ; then \
  164. +     echo $${rootme}/binutils/nm ; \
  165. +   else \
  166. +     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
  167. +       echo $(NM); \
  168. +     else \
  169. +        t='$(program_transform_name)'; echo nm | sed -e '' $$t ; \
  170. +     fi; \
  171. +   fi`
  172. + # FIXME: This is badly named.
  173. + XTRAFLAGS = ` \
  174. +   if [ -f $${rootme}/gcc/Makefile ] ; then \
  175. +     if [ -f $${rootme}/newlib/Makefile ] ; then \
  176. +       echo -I$${rootme}/newlib/targ-include -I$${srcroot}/newlib/libc/include -I$${rootme}/gcc/include -nostdinc ; \
  177. +     else \
  178. +       echo -I$${rootme}/gcc/include ; \
  179. +     fi ; \
  180. +   else \
  181. +      echo ; \
  182. +   fi`
  183. + #### host and target specific makefile fragments come in here.
  184. + ###
  185. + # Flags to pass down to all sub-makes.
  186. + # Please keep these in alphabetical order.
  187. + BASE_FLAGS_TO_PASS = \
  188. +     "AR_FLAGS=$(AR_FLAGS)" \
  189. +     "AR_FOR_TARGET=$(AR_FOR_TARGET)" \
  190. +     "AS_FOR_TARGET=$(AS_FOR_TARGET)" \
  191. +     "BISON=$(BISON)" \
  192. +     "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
  193. +     "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
  194. +     "CFLAGS=$(CFLAGS)" \
  195. +     "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
  196. +     "CXXFLAGS=$(CXXFLAGS)" \
  197. +     "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
  198. +     "GCC_FOR_TARGET=$(CC_FOR_TARGET)" \
  199. +     "INSTALL=$(INSTALL)" \
  200. +     "INSTALL_DATA=$(INSTALL_DATA)" \
  201. +     "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
  202. +     "INSTALL_XFORM=$(INSTALL_XFORM)" \
  203. +     "LDFLAGS=$(LDFLAGS)" \
  204. +     "LEX=$(LEX)" \
  205. +     "M4=$(M4)" \
  206. +     "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
  207. +     "MUNCH_NM=$(MUNCH_NM)" \
  208. +     "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
  209. +     "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
  210. +     "EXPECT=$(EXPECT)" \
  211. +     "RUNTEST=$(RUNTEST)" \
  212. +     "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
  213. +     "XTRAFLAGS_FOR_TARGET=$(XTRAFLAGS)" \
  214. +     "exec_prefix=$(exec_prefix)" \
  215. +     "prefix=$(prefix)" \
  216. +     "tooldir=$(tooldir)" 
  217. + # Flags to pass down to most sub-makes, in which we're building with
  218. + # the host environment.
  219. + # If any variables are added here, they must be added to do-*, below.
  220. + EXTRA_HOST_FLAGS = \
  221. +     'AR=$(AR)' \
  222. +     'AS=$(AS)' \
  223. +     'CC=$(CC)' \
  224. +     'CXX=$(CXX)' \
  225. +     'NM=$(NM)' \
  226. +     'RANLIB=$(RANLIB)' \
  227. +     'XTRAFLAGS='
  228. + FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
  229. + # Flags that are concerned with the location of the X11 include files
  230. + # and library files
  231. + X11_FLAGS_TO_PASS = \
  232. +     "X11_INCLUDE_FLAGS=$(X11_INCLUDE_FLAGS)" \
  233. +     "X11_LIB_FLAGS=$(X11_LIB_FLAGS)" \
  234. +     "X11_LIB=$(X11_LIB)"
  235. + # Flags to pass down to makes which are built with the target environment.
  236. + # The double $ decreases the length of the command line; the variables
  237. + # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.
  238. + # If any variables are added here, they must be added to do-*, below.
  239. + EXTRA_TARGET_FLAGS = \
  240. +     'AR=$$(AR_FOR_TARGET)' \
  241. +     'AS=$$(AS_FOR_TARGET)' \
  242. +     'CC=$$(CC_FOR_TARGET)' \
  243. +     'CXX=$$(CXX_FOR_TARGET)' \
  244. +     'NM=$$(NM_FOR_TARGET)' \
  245. +     'RANLIB=$$(RANLIB_FOR_TARGET)' \
  246. +     'XTRAFLAGS=$$(XTRAFLAGS_FOR_TARGET)'
  247. + TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
  248. + # Flags to pass down to gcc.  gcc builds a library, libgcc.a, so it
  249. + # unfortunately needs the native compiler and the target ar and
  250. + # ranlib.
  251. + # If any variables are added here, they must be added to do-*, below.
  252. + # The HOST_* variables are a special case, which are used for the gcc
  253. + # cross-building scheme.
  254. + HOST_CC = $(CC_FOR_BUILD)
  255. + HOST_PREFIX = 
  256. + HOST_PREFIX_1 = loser-
  257. + EXTRA_GCC_FLAGS = \
  258. +     'AR=$$(AR_FOR_TARGET)' \
  259. +     'AS=$(AS)' \
  260. +     'CC=$(CC)' \
  261. +     'CXX=$(CXX)' \
  262. +     'HOST_CC=$(CC_FOR_BUILD)' \
  263. +     'HOST_PREFIX=$(HOST_PREFIX)' \
  264. +     'HOST_PREFIX_1=$(HOST_PREFIX_1)' \
  265. +     'NM=$(NM)' \
  266. +     'RANLIB=$$(RANLIB_FOR_TARGET)' \
  267. +     'XTRAFLAGS='
  268. + GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS)
  269. + # This is a list of the targets for all of the modules which are compiled
  270. + # using $(FLAGS_TO_PASS).
  271. + ALL_MODULES = \
  272. +     all-autoconf \
  273. +     all-bfd \
  274. +     all-binutils \
  275. +     all-byacc \
  276. +     all-cvs \
  277. +     all-dejagnu \
  278. +     all-diff \
  279. +     all-dosutils \
  280. +     all-etc \
  281. +     all-fileutils \
  282. +     all-find \
  283. +     all-flex \
  284. +     all-gas \
  285. +     all-gawk \
  286. +     all-gdb \
  287. +     all-gprof \
  288. +     all-grep \
  289. +     all-gzip \
  290. +     all-hello \
  291. +     all-indent \
  292. +     all-ispell \
  293. +     all-ld \
  294. +     all-libiberty \
  295. +     all-m4 \
  296. +     all-make \
  297. +     all-mmalloc \
  298. +     all-opcodes \
  299. +     all-pagas \
  300. +     all-patch \
  301. +     all-prms \
  302. +     all-rcs \
  303. +     all-readline \
  304. +     all-release \
  305. +     all-recode \
  306. +     all-sed \
  307. +     all-send-pr \
  308. +     all-shellutils \
  309. +     all-sim \
  310. +     all-tar \
  311. +     all-tcl \
  312. +     all-texinfo \
  313. +     all-textutils \
  314. +     all-tgas \
  315. +     all-time \
  316. +     all-uudecode \
  317. +     all-wdiff
  318. + # This is a list of the check targets for all of the modules which are
  319. + # compiled using $(FLAGS_TO_PASS).
  320. + CHECK_MODULES = \
  321. +     check-autoconf \
  322. +     check-bfd \
  323. +     check-binutils \
  324. +     check-byacc \
  325. +     check-cvs \
  326. +     check-dejagnu \
  327. +     check-diff \
  328. +     check-etc \
  329. +     check-fileutils \
  330. +     check-find \
  331. +     check-flex \
  332. +     check-gas \
  333. +     check-gawk \
  334. +     check-gdb \
  335. +     check-gprof \
  336. +     check-grep \
  337. +     check-gzip \
  338. +     check-hello \
  339. +     check-indent \
  340. +     check-ispell \
  341. +     check-ld \
  342. +     check-libiberty \
  343. +     check-m4 \
  344. +     check-make \
  345. +     check-mmcheckoc \
  346. +     check-opcodes \
  347. +     check-pagas \
  348. +     check-patch \
  349. +     check-prms \
  350. +     check-rcs \
  351. +     check-readline \
  352. +     check-recode \
  353. +     check-sed \
  354. +     check-send-pr \
  355. +     check-shellutils \
  356. +     check-sim \
  357. +     check-tar \
  358. +     check-tcl \
  359. +     check-texinfo \
  360. +     check-textutils \
  361. +     check-tgas \
  362. +     check-time \
  363. +     check-uudecode \
  364. +     check-wdiff
  365. + # This is a list of the install targets for all of the modules which are
  366. + # compiled using $(FLAGS_TO_PASS).
  367. + INSTALL_MODULES = \
  368. +     install-autoconf \
  369. +     install-bfd \
  370. +     install-binutils \
  371. +     install-byacc \
  372. +     install-cvs \
  373. +     install-dejagnu \
  374. +     install-diff \
  375. +     install-etc \
  376. +     install-fileutils \
  377. +     install-find \
  378. +     install-flex \
  379. +     install-gas \
  380. +     install-gawk \
  381. +     install-gdb \
  382. +     install-glob \
  383. +     install-gprof \
  384. +     install-grep \
  385. +     install-gzip \
  386. +     install-hello \
  387. +     install-indent \
  388. +     install-ispell \
  389. +     install-ld \
  390. +     install-libiberty \
  391. +     install-m4 \
  392. +     install-make \
  393. +     install-mmalloc \
  394. +     install-opcodes \
  395. +     install-pagas \
  396. +     install-patch \
  397. +     install-prms \
  398. +     install-rcs \
  399. +     install-readline \
  400. +     install-recode \
  401. +     install-sed \
  402. +     install-send-pr \
  403. +     install-shellutils \
  404. +     install-sim \
  405. +     install-tar \
  406. +     install-tcl \
  407. +     install-textutils \
  408. +     install-tgas \
  409. +     install-time \
  410. +     install-uudecode \
  411. +     install-wdiff
  412. + # This is a list of the targets for all of the modules which are compiled
  413. + # using $(X11_FLAGS_TO_PASS).
  414. + ALL_X11_MODULES = \
  415. +     all-emacs \
  416. +     all-expect \
  417. +     all-gash \
  418. +     all-tclX \
  419. +     all-tk
  420. + # This is a list of the check targets for all of the modules which are
  421. + # compiled using $(X11_FLAGS_TO_PASS).
  422. + CHECK_X11_MODULES = \
  423. +     check-emacs \
  424. +     check-expect \
  425. +     check-gash \
  426. +     check-tclX \
  427. +     check-tk
  428. + # This is a list of the install targets for all the modules which are
  429. + # compiled using $(X11_FLAGS_TO_PASS).
  430. + INSTALL_X11_MODULES = \
  431. +     install-emacs \
  432. +     install-expect \
  433. +     install-gash \
  434. +     install-tclX \
  435. +     install-tk
  436. + # This is a list of the targets for all of the modules which are compiled
  437. + # using $(TARGET_FLAGS_TO_PASS).
  438. + ALL_TARGET_MODULES = \
  439. +     all-libio \
  440. +     all-libg++ \
  441. +     all-newlib \
  442. +     all-xiberty
  443. + # This is a list of the check targets for all of the modules which are
  444. + # compiled using $(TARGET_FLAGS_TO_PASS).
  445. + CHECK_TARGET_MODULES = \
  446. +     check-libio \
  447. +     check-libg++ \
  448. +     check-newlib \
  449. +     check-xiberty
  450. + # This is a list of the install targets for all of the modules which are
  451. + # compiled using $(TARGET_FLAGS_TO_PASS).
  452. + INSTALL_TARGET_MODULES = \
  453. +     install-libio \
  454. +     install-libg++ \
  455. +     install-newlib \
  456. +     install-xiberty
  457. + # This is a shell case of all modules which are compiled using
  458. + # $(TARGET_FLAGS_TO_PASS), used in the do-X rule.
  459. + TARGET_LIBS = libio | libg++ | newlib | xiberty
  460. + # The first rule in the file had better be this one.  Don't put any above it.
  461. + all: all.normal
  462. + .PHONY: all
  463. + # The target built for a native build.
  464. + .PHONY: all.normal
  465. + all.normal: \
  466. +     $(ALL_MODULES) \
  467. +     $(ALL_TARGET_MODULES) \
  468. +     $(ALL_X11_MODULES) \
  469. +     all-gcc
  470. + # Do a target for all the subdirectories.  A ``make do-X'' will do a
  471. + # ``make X'' in all subdirectories (because, in general, there is a
  472. + # dependency (below) of X upon do-X, a ``make X'' will also do this,
  473. + # but it may do additional work as well).
  474. + # This target ensures that $(BASE_FLAGS_TO_PASS) appears only once,
  475. + # because it is so large that it can easily overflow the command line
  476. + # length limit on some systems.
  477. + DO_X = \
  478. +     do-clean \
  479. +     do-distclean \
  480. +     do-dvi \
  481. +     do-info \
  482. +     do-install-info \
  483. +     do-installcheck \
  484. +     do-mostlyclean \
  485. +     do-realclean
  486. + .PHONY: $(DO_X)
  487. + $(DO_X):
  488. +     @target=`echo $@ | sed -e 's/^do-//'`; \
  489. +     rootme=`pwd`; export rootme; \
  490. +     srcroot=`cd $(srcdir); pwd`; export srcroot; \
  491. +     for i in $(SUBDIRS); do \
  492. +       if [ -f ./$$i/Makefile ]; then \
  493. +         case $$i in \
  494. +         $(TARGET_LIBS) ) \
  495. +           for flag in $(EXTRA_TARGET_FLAGS); do \
  496. +         eval `echo "$$flag" | sed -e "s|^\(.*\)=\(.*\)|\1='\2'|"`; \
  497. +           done; \
  498. +           ;; \
  499. +         gcc) \
  500. +           for flag in $(EXTRA_GCC_FLAGS); do \
  501. +         eval `echo "$$flag" | sed -e "s|^\(.*\)=\(.*\)|\1='\2'|"`; \
  502. +           done; \
  503. +           ;; \
  504. +         *) \
  505. +           for flag in $(EXTRA_HOST_FLAGS); do \
  506. +         eval `echo "$$flag" | sed -e "s|^\(.*\)=\(.*\)|\1='\2'|"`; \
  507. +           done; \
  508. +           ;; \
  509. +         esac ; \
  510. +         export AR AS CC CXX NM RANLIB XTRAFLAGS; \
  511. +         if (cd ./$$i; \
  512. +             $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
  513. +             "CC=$${CC}" "CXX=$${CXX}" "NM=$${NM}" \
  514. +             "RANLIB=$${RANLIB}" "XTRAFLAGS=$${XTRAFLAGS}" \
  515. +             $${target}); \
  516. +         then true; else exit 1; fi; \
  517. +       else true; fi; \
  518. +     done
  519. + # Here are the targets which correspond to the do-X targets.
  520. + .PHONY: info installcheck dvi install-info
  521. + .PHONY: clean distclean mostlyclean realclean local-clean local-distclean
  522. + info: do-info
  523. + installcheck: do-installcheck
  524. + dvi: do-dvi
  525. + install-info: do-install-info dir.info
  526. +     srcroot=`cd $(srcdir); pwd`; export srcroot; \
  527. +     if [ -f dir.info ] ; then \
  528. +       $(INSTALL_DATA) dir.info $(infodir)/dir.info ; \
  529. +     else true ; fi
  530. + local-clean:
  531. +     -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E
  532. + local-distclean:
  533. +     -rm -f Makefile config.status
  534. + clean: do-clean local-clean
  535. + mostlyclean: do-mostlyclean local-clean
  536. + distclean: do-distclean local-clean local-distclean
  537. + realclean: do-realclean local-clean local-distclean
  538. + # Check target.
  539. + .PHONY: check
  540. + check: $(CHECK_MODULES) \
  541. +     $(CHECK_TARGET_MODULES) \
  542. +     $(CHECK_X11_MODULES) \
  543. +     check-gcc
  544. + # Installation targets.
  545. + .PHONY: install uninstall vault-install
  546. + install: $(INSTALL_TARGET) 
  547. + uninstall:
  548. +     @echo "the uninstall target is not supported in this tree"
  549. + vault-install:
  550. +     @if [ -f ./release/vault-install ] ; then \
  551. +       ./release/vault-install $(host_alias) $(target_alias) ; \
  552. +     else \
  553. +       true ; \
  554. +     fi
  555. + .PHONY: install.all
  556. + install.all: install-no-fixedincludes
  557. +     @if [ -f ./gcc/Makefile ] ; then \
  558. +         rootme=`pwd` ; export rootme ; \
  559. +         (cd ./gcc; \
  560. +         $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \
  561. +     else \
  562. +         true ; \
  563. +     fi
  564. + # install-no-fixedincludes is used because Cygnus can not distribute
  565. + # the fixed header files.
  566. + .PHONY: install-no-fixedincludes
  567. + install-no-fixedincludes: \
  568. +     install-dirs \
  569. +     $(INSTALL_MODULES) \
  570. +     $(INSTALL_TARGET_MODULES) \
  571. +     $(INSTALL_X11_MODULES) \
  572. +     gcc-no-fixedincludes 
  573. + # Install the gcc headers files, but not the fixed include files,
  574. + # which Cygnus is not allowed to distribute.  This rule is very
  575. + # dependent on the workings of the gcc Makefile.in.
  576. + .PHONY: gcc-no-fixedincludes
  577. + gcc-no-fixedincludes:
  578. +     @if [ -f ./gcc/Makefile ]; then \
  579. +       rm -rf gcc/tmp-include; \
  580. +       mv gcc/include gcc/tmp-include 2>/dev/null; \
  581. +       mkdir gcc/include; \
  582. +       cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
  583. +       touch gcc/stmp-fixinc gcc/stmp-fixproto; \
  584. +       rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
  585. +       rootme=`pwd`; export rootme; \
  586. +       srcroot=`cd $(srcdir); pwd` ; export srcroot; \
  587. +       (cd ./gcc; \
  588. +        $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
  589. +       rm -rf gcc/include; \
  590. +       mv gcc/tmp-include gcc/include 2>/dev/null; \
  591. +     else true; fi
  592. + # This rule is used to build the modules which use FLAGS_TO_PASS.  To
  593. + # build a target all-X means to cd to X and make all.
  594. + # all-glob is handled specially because it doesn't actually build.
  595. + .PHONY: $(ALL_MODULES) all-glob
  596. + $(ALL_MODULES) all-glob:
  597. +     @dir=`echo $@ | sed -e 's/all-//'`; \
  598. +     if [ -f ./$${dir}/Makefile ] ; then \
  599. +       rootme=`pwd`; export rootme; \
  600. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  601. +       (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) all); \
  602. +     else \
  603. +       true; \
  604. +     fi
  605. + # This rule is used to check the modules which use FLAGS_TO_PASS.  To
  606. + # build a target check-X means to cd to X and make all.
  607. + .PHONY: $(CHECK_MODULES) 
  608. + $(CHECK_MODULES):
  609. +     @dir=`echo $@ | sed -e 's/check-//'`; \
  610. +     if [ -f ./$${dir}/Makefile ] ; then \
  611. +       rootme=`pwd`; export rootme; \
  612. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  613. +       (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \
  614. +     else \
  615. +       true; \
  616. +     fi
  617. + # This rule is used to install the modules which use FLAGS_TO_PASS.
  618. + # To build a target install-X means to cd to X and make install.
  619. + .PHONY: $(INSTALL_MODULES)
  620. + $(INSTALL_MODULES): install-dirs
  621. +     @dir=`echo $@ | sed -e 's/install-//'`; \
  622. +     if [ -f ./$${dir}/Makefile ] ; then \
  623. +       rootme=`pwd`; export rootme; \
  624. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  625. +       (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \
  626. +     else \
  627. +       true; \
  628. +     fi
  629. + # This rule is used to build the modules which use TARGET_FLAGS_TO_PASS.
  630. + # To build a target all-X means to cd to X and make all.
  631. + .PHONY: $(ALL_TARGET_MODULES)
  632. + $(ALL_TARGET_MODULES):
  633. +     @dir=`echo $@ | sed -e 's/all-//'`; \
  634. +     if [ -f ./$${dir}/Makefile ] ; then \
  635. +       rootme=`pwd`; export rootme; \
  636. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  637. +       (cd $${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \
  638. +     else \
  639. +       true; \
  640. +     fi
  641. + # This rule is used to check the modules which use TARGET_FLAGS_TO_PASS.
  642. + # To build a target install-X means to cd to X and make install.
  643. + .PHONY: $(CHECK_TARGET_MODULES)
  644. + $(CHECK_TARGET_MODULES):
  645. +     @dir=`echo $@ | sed -e 's/check-//'`; \
  646. +     if [ -f ./$${dir}/Makefile ] ; then \
  647. +       rootme=`pwd`; export rootme; \
  648. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  649. +       (cd $${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) check); \
  650. +     else \
  651. +       true; \
  652. +     fi
  653. + # This rule is used to install the modules which use
  654. + # TARGET_FLAGS_TO_PASS.  To build a target install-X means to cd to X
  655. + # and make install.
  656. + .PHONY: $(INSTALL_TARGET_MODULES)
  657. + $(INSTALL_TARGET_MODULES): install-dirs
  658. +     @dir=`echo $@ | sed -e 's/install-//'`; \
  659. +     if [ -f ./$${dir}/Makefile ] ; then \
  660. +       rootme=`pwd`; export rootme; \
  661. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  662. +       (cd $${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) install); \
  663. +     else \
  664. +       true; \
  665. +     fi
  666. + # This rule is used to build the modules which use X11_FLAGS_TO_PASS.
  667. + # To build a target all-X means to cd to X and make all.
  668. + .PHONY: $(ALL_X11_MODULES)
  669. + $(ALL_X11_MODULES):
  670. +     @dir=`echo $@ | sed -e 's/all-//'`; \
  671. +     if [ -f ./$${dir}/Makefile ] ; then \
  672. +       rootme=`pwd`; export rootme; \
  673. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  674. +       (cd $${dir}; \
  675. +        $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) all); \
  676. +     else \
  677. +       true; \
  678. +     fi
  679. + # This rule is used to check the modules which use X11_FLAGS_TO_PASS.
  680. + # To build a target check-X means to cd to X and make all.
  681. + .PHONY: $(CHECK_X11_MODULES)
  682. + $(CHECK_X11_MODULES):
  683. +     @dir=`echo $@ | sed -e 's/check-//'`; \
  684. +     if [ -f ./$${dir}/Makefile ] ; then \
  685. +       rootme=`pwd`; export rootme; \
  686. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  687. +       (cd $${dir}; \
  688. +        $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check); \
  689. +     else \
  690. +       true; \
  691. +     fi
  692. + # This rule is used to install the modules which use X11_FLAGS_TO_PASS.
  693. + # To build a target install-X means to cd to X and make install.
  694. + .PHONY: $(INSTALL_X11_MODULES)
  695. + $(INSTALL_X11_MODULES):
  696. +     @dir=`echo $@ | sed -e 's/install-//'`; \
  697. +     if [ -f ./$${dir}/Makefile ] ; then \
  698. +       rootme=`pwd`; export rootme; \
  699. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  700. +       (cd $${dir}; \
  701. +        $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install); \
  702. +     else \
  703. +       true; \
  704. +     fi
  705. + # gcc is the only module which uses GCC_FLAGS_TO_PASS.
  706. + .PHONY: all-gcc
  707. + all-gcc:
  708. +     @if [ -f ./gcc/Makefile ] ; then \
  709. +       rootme=`pwd`; export rootme; \
  710. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  711. +       (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) all); \
  712. +     else \
  713. +       true; \
  714. +     fi
  715. + .PHONY: check-gcc
  716. + check-gcc:
  717. +     @if [ -f ./gcc/Makefile ] ; then \
  718. +       rootme=`pwd`; export rootme; \
  719. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  720. +       (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) check); \
  721. +     else \
  722. +       true; \
  723. +     fi
  724. + .PHONY: install-gcc
  725. + install-gcc:
  726. +     @if [ -f ./gcc/Makefile ] ; then \
  727. +       rootme=`pwd`; export rootme; \
  728. +       srcroot=`cd $(srcdir); pwd`; export srcroot; \
  729. +       (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
  730. +     else \
  731. +       true; \
  732. +     fi
  733. + # This is a list of inter-dependencies among modules.
  734. + all-autoconf: all-m4
  735. + all-bfd:
  736. + all-binutils: all-libiberty all-opcodes all-bfd all-flex
  737. + all-byacc:
  738. + all-cvs:
  739. + all-dejagnu:
  740. + all-diff: all-libiberty
  741. + all-emacs:
  742. + all-etc:
  743. + all-expect: all-tcl all-tk
  744. + all-fileutils: all-libiberty
  745. + all-find:
  746. + all-flex: all-libiberty all-byacc
  747. + all-gas: all-libiberty all-opcodes all-bfd
  748. + all-gash: all-tcl
  749. + all-gawk:
  750. + all-gcc: all-libiberty all-byacc all-binutils all-gas all-pagas
  751. + all-gdb: all-libiberty all-opcodes all-bfd all-mmalloc all-readline all-glob all-byacc all-sim
  752. + all-glob:
  753. + all-gprof: all-libiberty all-bfd
  754. + all-grep: all-libiberty
  755. + all-gzip: all-libiberty
  756. + all-hello: all-libiberty
  757. + all-indent:
  758. + all-ispell: all-emacs
  759. + all-ld: all-libiberty all-bfd all-byacc all-flex
  760. + all-libg++: all-gas all-pagas all-ld all-gcc all-xiberty all-newlib all-libio
  761. + all-libio: all-gas all-pagas all-ld all-gcc all-xiberty all-newlib 
  762. + all-libiberty:
  763. + all-m4: all-libiberty
  764. + all-make: all-libiberty
  765. + all-mmalloc:
  766. + all-newlib: all-binutils all-gas all-pagas all-gcc
  767. + all-opcodes: all-bfd
  768. + all-patch:
  769. + all-prms: all-libiberty
  770. + all-rcs:
  771. + all-readline:
  772. + all-recode: all-libiberty
  773. + all-sed: all-libiberty
  774. + all-send-pr: all-prms
  775. + all-shellutils:
  776. + all-sim: all-libiberty all-bfd
  777. + all-tar: all-libiberty
  778. + all-tcl:
  779. + all-tclX: all-tcl all-tk
  780. + all-tk: all-tcl
  781. + all-texinfo: all-libiberty
  782. + all-textutils:
  783. + all-tgas: all-libiberty all-bfd
  784. + all-time:
  785. + all-wdiff:
  786. + all-uudecode: all-libiberty
  787. + all-xiberty: all-gcc all-newlib
  788. + ### other supporting targets
  789. + MAKEDIRS= \
  790. +     $(prefix) \
  791. +     $(exec_prefix) \
  792. +     $(tooldir)
  793. + .PHONY: install-dirs
  794. + install-dirs:
  795. +     @for i in $(MAKEDIRS) ; do \
  796. +         echo Making $$i... ; \
  797. +         parent=`echo $$i | sed -e 's@/[^/]*$$@@' | sed -e 's@^$$@/@'`; \
  798. +         if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi ; \
  799. +         if [ ! -d $$i ] ; then \
  800. +             if mkdir $$i ; then \
  801. +                 true ; \
  802. +             else \
  803. +                 exit 1 ; \
  804. +             fi ; \
  805. +         else \
  806. +             true ; \
  807. +         fi ; \
  808. +     done
  809. + dir.info: do-install-info
  810. +     if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \
  811. +       $(srcdir)/texinfo/gen-info-dir $(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \
  812. +       mv -f dir.info.new dir.info ; \
  813. +     else true ; \
  814. +     fi
  815. + dist:
  816. +     @echo "Building a full distribution of this tree isn't done"
  817. +     @echo "via 'make dist'.  Check out the etc/ subdirectory" 
  818. + etags tags: TAGS
  819. + TAGS:
  820. +     etags `$(MAKE) ls`
  821. + ls:
  822. +     @echo Makefile
  823. +     @for i in $(SUBDIRS); \
  824. +     do \
  825. +         (cd $$i; \
  826. +             pwd=`pwd`; \
  827. +             wd=`basename $$pwd`; \
  828. +             for j in `$(MAKE) ls`; \
  829. +             do \
  830. +                 echo $$wd/$$j; \
  831. +             done) \
  832. +     done
  833. + # with the gnu make, this is done automatically.
  834. + Makefile: Makefile.in configure.in $(host_makefile_frag) $(target_makefile_frag)
  835. +     $(SHELL) ./config.status
  836. + #
  837. + # Support for building net releases
  838. + # Files in devo used in any net release.
  839. + # ChangeLog omitted because it may refer to files which are not in this
  840. + # distribution (perhaps it would be better to include it anyway).
  841. + DEVO_SUPPORT= README Makefile.in configure configure.in \
  842. +     config.guess config.sub config move-if-change \
  843. +     COPYING COPYING.LIB install.sh
  844. + # Files in devo/etc used in any net release.
  845. + # ChangeLog omitted because it may refer to files which are not in this
  846. + # distribution (perhaps it would be better to include it anyway).
  847. + ETC_SUPPORT= Makefile.in cfg-paper.texi configure.in configure.man \
  848. +     configure.texi standards.texi make-stds.texi
  849. + GDB_SUPPORT_DIRS= bfd include libiberty mmalloc opcodes readline glob sim
  850. + GDB_SUPPORT_FILES= $(GDB_SUPPORT_DIRS)
  851. + .PHONY: setup-dirs-gdb gdb.tar.gz make-gdb.tar.gz
  852. + setup-dirs-gdb:
  853. +     ./configure sun4
  854. +     $(MAKE) clean
  855. +     ./configure -rm sun4
  856. +     chmod og=u `find etc $(DEVO_SUPPORT) $(GDB_SUPPORT_FILES) -print`
  857. + gdb.tar.gz: setup-dirs-gdb
  858. +     (cd gdb; $(MAKE) -f Makefile.in make-proto-gdb.dir BISON="byacc")
  859. +     (cd gdb; $(MAKE) -f Makefile.in make-proto-testsuite.dir)
  860. +     $(MAKE) $(MFLAGS) -f Makefile.in make-gdb.tar.gz
  861. + make-gdb.tar.gz: $(DEVO_SUPPORT) $(GDB_SUPPORT_DIRS) gdb texinfo/texinfo.tex
  862. +     rm -rf proto-toplev; mkdir proto-toplev
  863. +     ln -s ../gdb/proto-gdb.dir proto-toplev/gdb
  864. +     (cd proto-toplev; for i in $(DEVO_SUPPORT) $(GDB_SUPPORT_DIRS); do \
  865. +         ln -s ../$$i . ; \
  866. +     done)
  867. +     mkdir proto-toplev/etc
  868. +     (cd proto-toplev/etc; for i in $(ETC_SUPPORT); do \
  869. +         ln -s ../../etc/$$i . ; \
  870. +     done)
  871. +     # Put only one copy (four hard links) of COPYING in the tar file.
  872. +     rm                          proto-toplev/bfd/COPYING
  873. +     ln proto-toplev/gdb/COPYING proto-toplev/bfd/COPYING
  874. +     rm                          proto-toplev/include/COPYING
  875. +     ln proto-toplev/gdb/COPYING proto-toplev/include/COPYING
  876. +     rm                          proto-toplev/readline/COPYING
  877. +     ln proto-toplev/gdb/COPYING proto-toplev/readline/COPYING
  878. +     # Change the bug reporting address in configure to bug-gdb
  879. +     rm proto-toplev/configure
  880. +     sed -e 's/configure@cygnus.com/bug-gdb@prep.ai.mit.edu/' \
  881. +         <configure >proto-toplev/configure
  882. +     chmod a+x proto-toplev/configure
  883. +     # Take out texinfo and glob from configurable dirs
  884. +     rm proto-toplev/configure.in
  885. +     sed -e '/^host_tools=/s/texinfo //' \
  886. +         -e '/^host_libs=/s/glob //' \
  887. +         <configure.in >proto-toplev/configure.in
  888. +     # Take out texinfo from a few places; make simple BISON=bison line.
  889. +     rm proto-toplev/Makefile.in
  890. +     sed -e '/^all\.normal: /s/\all-texinfo //' \
  891. +         -e '/^    install-texinfo /d' \
  892. +         -e '/^BISON = /,/^$$/d' \
  893. +         -e '/^# BISON:/s/.*/BISON = bison -y/' \
  894. +     <Makefile.in >proto-toplev/Makefile.in
  895. +     mkdir proto-toplev/texinfo
  896. +     ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
  897. +     ln -s ../../texinfo/gpl.texinfo proto-toplev/texinfo/
  898. +     ln -s ../../texinfo/tex3patch   proto-toplev/texinfo/
  899. +     chmod og=u `find proto-toplev -print`
  900. +     (VER=`sed <gdb/Makefile.in -n 's/VERSION = //p'`; \
  901. +         echo "==> Making gdb-$$VER.tar.gz"; \
  902. +         rm -f gdb-$$VER; ln -s proto-toplev gdb-$$VER; \
  903. +         tar cfh - gdb-$$VER \
  904. +         | $(GZIP) -v -9 >gdb-$$VER.tar.gz)
  905. +     # Make the testsuite archive separately.
  906. +     ln -s ../../gdb/proto-testsuite.dir/testsuite proto-toplev/gdb/testsuite
  907. +     # Blow away the Chill test that requires a Chill compiled executable,
  908. +     # since GNU Chill is not yet publically available.
  909. +     rm -rf proto-toplev/gdb/testsuite/gdb.t31
  910. +     # Put a copy of COPYING in the tar file.
  911. +     ln proto-toplev/gdb/COPYING proto-toplev/gdb/testsuite/COPYING
  912. +     chmod og=u `find proto-toplev/gdb/testsuite -print`
  913. +     (VER=`sed <gdb/Makefile.in -n 's/VERSION = //p'`; \
  914. +         echo "==> Making gdb-$$VER-testsuite.tar.gz"; \
  915. +         tar cfh - gdb-$$VER/configure gdb-$$VER/config.guess \
  916. +             gdb-$$VER/config.sub gdb-$$VER/move-if-change \
  917. +             gdb-$$VER/gdb/testsuite \
  918. +             | $(GZIP) -v -9 >gdb-$$VER-testsuite.tar.gz)
  919. + # When you use `make setup-dirs' or `make taz' you should always redefine
  920. + # this macro.
  921. + SUPPORT_FILES = list-of-support-files-for-tool-in-question
  922. + # Directories that might want `make diststuff' run.
  923. + DISTSTUFFDIRS= ld gprof gdb libg++ binutils
  924. + # Files where "byacc" (Cygnus version) should be changed to "bison -y" (FSF).
  925. + DISTBISONFILES= binutils/Makefile.in gas/Makefile.in gdb/Makefile.in
  926. + # Directories where "info" should be built.
  927. + DISTDOCDIRS= ld gprof binutils gas bfd libg++ libio
  928. + .PHONY: taz
  929. + taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \
  930. +   texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo
  931. +     # Make sure "diststuff" files get built properly.
  932. +     for f in $(DISTBISONFILES) ; do \
  933. +       if [ -r $$f ]; then \
  934. +         sed '/^BISON *=.*$$/s/.*/BISON = bison -y/' <$$f >tmp ; \
  935. +         mv -f tmp $$f ; \
  936. +       else true; fi ; \
  937. +     done
  938. +     # Take out texinfo from a few places; make simple BISON=bison line.
  939. +     sed -e '/^all\.normal: /s/\all-texinfo //' \
  940. +         -e '/^    install-texinfo /d' \
  941. +         -e '/^BISON = /,/^$$/d' \
  942. +         -e '/^# BISON:/s/.*/BISON = bison -y/' \
  943. +     <Makefile.in >tmp
  944. +     mv -f tmp Makefile.in
  945. +     #
  946. +     ./configure sun4
  947. +     # Doc files don't change; include them in distribution.
  948. +     for f in $(DISTDOCDIRS) ; do \
  949. +       if [ -r $$f/Makefile ]; then \
  950. +         (cd $$f ; $(MAKE) info) || exit 1 ; \
  951. +       else true ; fi ; \
  952. +     done
  953. +     # Make links, and run "make diststuff" when needed.
  954. +     # The `echo' for setting `p' is to convert all whitespace to spaces.
  955. +     # Then the `case' further below should tell whether $$d is in
  956. +     # DISTSTUFFDIRS.
  957. +     rm -rf proto-toplev ; mkdir proto-toplev
  958. +     set -e ; dirs="$(TOOL) $(DEVO_SUPPORT) $(SUPPORT_FILES)" ; \
  959. +     p=" `echo $(DISTSTUFFDIRS)` " ; \
  960. +     for d in $$dirs ; do \
  961. +       if [ -d $$d ]; then \
  962. +         case " $$p " in \
  963. +         *" $$d "*)    \
  964. +         echo making diststuff in $$d ; \
  965. +         (cd $$d ; pwd ; $(MAKE) diststuff ) || exit 1  ;; \
  966. +         esac ; \
  967. +         if [ -d $$d/proto-$$d.dir ]; then \
  968. +           ln -s ../$$d/proto-$$d.dir proto-toplev/$$d ; \
  969. +         else \
  970. +           ln -s ../$$d proto-toplev/$$d ; \
  971. +         fi ; \
  972. +       else ln -s ../$$d proto-toplev/$$d ; fi ; \
  973. +     done
  974. +     $(MAKE) distclean
  975. +     #
  976. +     mkdir proto-toplev/etc
  977. +     (cd proto-toplev/etc; for i in $(ETC_SUPPORT); do \
  978. +         ln -s ../../etc/$$i . ; \
  979. +     done)
  980. +     #
  981. +     # Take out texinfo and glob from configurable dirs
  982. +     rm proto-toplev/configure.in
  983. +     sed -e '/^host_tools=/s/texinfo //' \
  984. +         -e '/^host_libs=/s/glob //' \
  985. +         <configure.in >proto-toplev/configure.in
  986. +     #
  987. +     mkdir proto-toplev/texinfo
  988. +     ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
  989. +     ln -s ../../texinfo/gpl.texinfo proto-toplev/texinfo/
  990. +     ln -s ../../texinfo/lgpl.texinfo proto-toplev/texinfo/
  991. +     ln -s ../../texinfo/tex3patch   proto-toplev/texinfo/
  992. +     chmod og=u `find . -print`
  993. +     (VER=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \
  994. +         echo "==> Making $(TOOL)-$$VER.tar.gz"; \
  995. +         rm -f $(TOOL)-$$VER; ln -s proto-toplev $(TOOL)-$$VER; \
  996. +         tar cfh - $(TOOL)-$$VER \
  997. +         | $(GZIP) -v -9 >$(TOOL)-$$VER.tar.gz)
  998. + TEXINFO_SUPPORT= texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo
  999. + DIST_SUPPORT= $(DEVO_SUPPORT) $(TEXINFO_SUPPORT)
  1000. + .PHONY: gas.tar.gz
  1001. + GAS_SUPPORT_DIRS= bfd include libiberty opcodes
  1002. + gas.tar.gz: $(DIST_SUPPORT) $(GAS_SUPPORT_DIRS) gas
  1003. +     $(MAKE) -f Makefile.in taz TOOL=gas \
  1004. +         SUPPORT_FILES="$(GAS_SUPPORT_DIRS)"
  1005. + # The FSF "binutils" release includes gprof and ld.
  1006. + .PHONY: binutils.tar.gz
  1007. + BINUTILS_SUPPORT_DIRS= bfd include libiberty opcodes ld gprof
  1008. + binutils.tar.gz: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils
  1009. +     $(MAKE) -f Makefile.in taz TOOL=binutils \
  1010. +         SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS)"
  1011. + .PHONY: gas+binutils.tar.gz
  1012. + GASB_SUPPORT_DIRS= $(GAS_SUPPORT_DIRS) binutils ld gprof
  1013. + gas+binutils.tar.gz: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas
  1014. +     $(MAKE) -f Makefile.in taz TOOL=gas \
  1015. +         SUPPORT_FILES="$(GASB_SUPPORT_DIRS)"
  1016. + .PHONY: libg++.tar.gz
  1017. + LIBGXX_SUPPORT_DIRS=include libio libiberty xiberty
  1018. + libg++.tar.gz: $(DIST_SUPPORT) libg++
  1019. +     $(MAKE) -f Makefile.in taz TOOL=libg++ \
  1020. +         SUPPORT_FILES="$(LIBGXX_SUPPORT_DIRS)"
  1021. + .NOEXPORT:
  1022. + MAKEOVERRIDES=
  1023. + # end of Makefile.in
  1024. diff -rc2N /free/libg++-2.5.3/config/mh-amigados /sources/libg++-2.5.3-amiga/config/mh-amigados
  1025. *** /free/libg++-2.5.3/config/mh-amigados    Thu Jan  1 00:00:00 1970
  1026. --- /sources/libg++-2.5.3-amiga/config/mh-amigados    Sun Dec  5 16:43:54 1993
  1027. ***************
  1028. *** 0 ****
  1029. --- 1,5 ----
  1030. + # do the best you can ;-)
  1031. + CC = gcc -O2
  1032. + # as long as we don't have a working debugger under AmigaDOS, using
  1033. + # -g just wastes disk space, so don't use it
  1034. + CFLAGS =
  1035. diff -rc2N /free/libg++-2.5.3/configure.in /sources/libg++-2.5.3-amiga/configure.in
  1036. *** /free/libg++-2.5.3/configure.in    Mon Dec 27 21:43:31 1993
  1037. --- /sources/libg++-2.5.3-amiga/configure.in    Mon Dec 27 16:53:12 1993
  1038. ***************
  1039. *** 104,107 ****
  1040. --- 104,108 ----
  1041.     *-sun-*)          host_makefile_frag=config/mh-sun ;;
  1042.     *-hp-hpux*)             host_makefile_frag=config/mh-hpux ;;
  1043. +   amigados)          host_makefile_frag=config/mh-amigados ;;
  1044.     *-*-hiux*)              host_makefile_frag=config/mh-hpux ;;
  1045.     *-*-lynxos*)            host_makefile_frag=config/mh-lynxos
  1046. diff -rc2N /free/libg++-2.5.3/libg++/config/amigados.mt /sources/libg++-2.5.3-amiga/libg++/config/amigados.mt
  1047. *** /free/libg++-2.5.3/libg++/config/amigados.mt    Thu Jan  1 00:00:00 1970
  1048. --- /sources/libg++-2.5.3-amiga/libg++/config/amigados.mt    Sun Dec  5 16:42:38 1993
  1049. ***************
  1050. *** 0 ****
  1051. --- 1,13 ----
  1052. + # do the best you can ;-)
  1053. + CC = gcc -O2
  1054. + # as long as we don't have a working debugger under AmigaDOS, using
  1055. + # -g just wastes disk space, so don't use it
  1056. + CFLAGS =
  1057. + # Use -nostdinc++ flag if your version of gcc understands it.
  1058. + NOSTDINC = -nostdinc++
  1059. + # If the C include files are C++-ready (with extern "C"),
  1060. + # define: HAVE_CPLUS_EXTERN = 1 and: WRAP_C_INCLUDES =
  1061. + # If not, define HAVE_CPLUS_EXTERN = 0, and do not define WRAP_C_INCLUDES here
  1062. + HAVE_CPLUS_EXTERN = 1
  1063. + WRAP_C_INCLUDES =
  1064. + XTRAFLAGS = -DNO_LIBGXX_MALLOC
  1065. diff -rc2N /free/libg++-2.5.3/libg++/etc/ADT-examples/Patmain.cc /sources/libg++-2.5.3-amiga/libg++/etc/ADT-examples/Patmain.cc
  1066. *** /free/libg++-2.5.3/libg++/etc/ADT-examples/Patmain.cc    Mon Dec 27 21:37:12 1993
  1067. --- /sources/libg++-2.5.3-amiga/libg++/etc/ADT-examples/Patmain.cc    Sun Dec  5 16:42:42 1993
  1068. ***************
  1069. *** 3,7 ****
  1070. --- 3,12 ----
  1071.   #include <stream.h>
  1072.   #include <stdio.h>
  1073. + #ifdef amigados
  1074. + /* amigados is not case sensitive ! */
  1075. + #include "gcc:include/string.h"
  1076. + #else
  1077.   #include <string.h>
  1078. + #endif
  1079.   #include "Patricia.h"
  1080.   #include <builtin.h>
  1081. diff -rc2N /free/libg++-2.5.3/libg++/etc/benchmarks/dhrystone.cc /sources/libg++-2.5.3-amiga/libg++/etc/benchmarks/dhrystone.cc
  1082. *** /free/libg++-2.5.3/libg++/etc/benchmarks/dhrystone.cc    Mon Dec 27 21:40:24 1993
  1083. --- /sources/libg++-2.5.3-amiga/libg++/etc/benchmarks/dhrystone.cc    Mon Dec 13 22:54:59 1993
  1084. ***************
  1085. *** 332,336 ****
  1086. --- 332,341 ----
  1087.   
  1088.   #ifdef    NOSTRUCTASSIGN
  1089. + #ifdef amigados
  1090. + /* amigados is not case sensitive ! */
  1091. + #include "gcc:include/string.h"
  1092. + #else
  1093.   #include <string.h>
  1094. + #endif
  1095.   #define    structassign(d, s)    memcpy(&(d), &(s), sizeof(d))
  1096.   #else
  1097. diff -rc2N /free/libg++-2.5.3/libg++/etc/lf/Dirent.cc /sources/libg++-2.5.3-amiga/libg++/etc/lf/Dirent.cc
  1098. *** /free/libg++-2.5.3/libg++/etc/lf/Dirent.cc    Mon Dec 27 21:37:18 1993
  1099. --- /sources/libg++-2.5.3-amiga/libg++/etc/lf/Dirent.cc    Sun Dec  5 16:42:48 1993
  1100. ***************
  1101. *** 6,10 ****
  1102.   
  1103.   #include <std.h>
  1104. ! #include "Dirent.h"
  1105.   
  1106.   // error handlers
  1107. --- 6,10 ----
  1108.   
  1109.   #include <std.h>
  1110. ! #include "_Dirent.h"
  1111.   
  1112.   // error handlers
  1113. diff -rc2N /free/libg++-2.5.3/libg++/etc/lf/directory.cc /sources/libg++-2.5.3-amiga/libg++/etc/lf/directory.cc
  1114. *** /free/libg++-2.5.3/libg++/etc/lf/directory.cc    Mon Dec 27 21:37:19 1993
  1115. --- /sources/libg++-2.5.3-amiga/libg++/etc/lf/directory.cc    Sun Dec  5 16:42:48 1993
  1116. ***************
  1117. *** 1,5 ****
  1118.   #include <stdio.h>
  1119.   #include <std.h>
  1120. ! #include "Dirent.h"
  1121.   #include "option.h"
  1122.   #include "entry.h"
  1123. --- 1,5 ----
  1124.   #include <stdio.h>
  1125.   #include <std.h>
  1126. ! #include "_Dirent.h"
  1127.   #include "option.h"
  1128.   #include "entry.h"
  1129. diff -rc2N /free/libg++-2.5.3/libg++/etc/trie-gen/test.cc /sources/libg++-2.5.3-amiga/libg++/etc/trie-gen/test.cc
  1130. *** /free/libg++-2.5.3/libg++/etc/trie-gen/test.cc    Mon Dec 27 21:37:21 1993
  1131. --- /sources/libg++-2.5.3-amiga/libg++/etc/trie-gen/test.cc    Sun Dec  5 16:42:50 1993
  1132. ***************
  1133. *** 6,10 ****
  1134. --- 6,15 ----
  1135.     
  1136.   #include <stdio.h>
  1137. + #ifdef amigados
  1138. + /* amigados is not case sensitive ! */
  1139. + #include "gcc:include/string.h"
  1140. + #else
  1141.   #include <string.h>
  1142. + #endif
  1143.   
  1144.   #define MAX_LEN 200
  1145. diff -rc2N /free/libg++-2.5.3/libg++/old-stream/Makefile.in /sources/libg++-2.5.3-amiga/libg++/old-stream/Makefile.in
  1146. *** /free/libg++-2.5.3/libg++/old-stream/Makefile.in    Mon Dec 27 21:37:34 1993
  1147. --- /sources/libg++-2.5.3-amiga/libg++/old-stream/Makefile.in    Sun Dec  5 16:43:02 1993
  1148. ***************
  1149. *** 11,15 ****
  1150.   
  1151.   USER_INCLUDES = File.h Filebuf.h Fmodes.h PlotFile.h SFile.h \
  1152. !   filebuf.h istream.h ostream.h stream.h streambuf.h
  1153.   
  1154.   # The following include files are private to the implementation.
  1155. --- 11,15 ----
  1156.   
  1157.   USER_INCLUDES = File.h Filebuf.h Fmodes.h PlotFile.h SFile.h \
  1158. !   _filebuf.h istream.h ostream.h stream.h streambuf.h
  1159.   
  1160.   # The following include files are private to the implementation.
  1161. diff -rc2N /free/libg++-2.5.3/libg++/old-stream/istream.h /sources/libg++-2.5.3-amiga/libg++/old-stream/istream.h
  1162. *** /free/libg++-2.5.3/libg++/old-stream/istream.h    Mon Dec 27 21:37:36 1993
  1163. --- /sources/libg++-2.5.3-amiga/libg++/old-stream/istream.h    Sun Dec  5 16:43:03 1993
  1164. ***************
  1165. *** 30,34 ****
  1166.   #include <File.h>
  1167.   #include <streambuf.h>
  1168. ! #include <filebuf.h>
  1169.   #include <Filebuf.h>
  1170.   
  1171. --- 30,34 ----
  1172.   #include <File.h>
  1173.   #include <streambuf.h>
  1174. ! #include <_filebuf.h>
  1175.   #include <Filebuf.h>
  1176.   
  1177. diff -rc2N /free/libg++-2.5.3/libg++/old-stream/ostream.h /sources/libg++-2.5.3-amiga/libg++/old-stream/ostream.h
  1178. *** /free/libg++-2.5.3/libg++/old-stream/ostream.h    Mon Dec 27 21:37:36 1993
  1179. --- /sources/libg++-2.5.3-amiga/libg++/old-stream/ostream.h    Sun Dec  5 16:43:03 1993
  1180. ***************
  1181. *** 33,37 ****
  1182.   #include <File.h>
  1183.   #include <streambuf.h>
  1184. ! #include <filebuf.h>
  1185.   #include <Filebuf.h>
  1186.   
  1187. --- 33,37 ----
  1188.   #include <File.h>
  1189.   #include <streambuf.h>
  1190. ! #include <_filebuf.h>
  1191.   #include <Filebuf.h>
  1192.   
  1193. diff -rc2N /free/libg++-2.5.3/libg++/src/BitSet.cc /sources/libg++-2.5.3-amiga/libg++/src/BitSet.cc
  1194. *** /free/libg++-2.5.3/libg++/src/BitSet.cc    Mon Dec 27 21:37:58 1993
  1195. --- /sources/libg++-2.5.3-amiga/libg++/src/BitSet.cc    Sun Dec  5 16:43:21 1993
  1196. ***************
  1197. *** 30,34 ****
  1198.   #include <new.h>
  1199.   #include <builtin.h>
  1200. ! #include <string.h>
  1201.   #include <strstream.h>
  1202.   
  1203. --- 30,34 ----
  1204.   #include <new.h>
  1205.   #include <builtin.h>
  1206. ! // #include <string.h> included by std.h
  1207.   #include <strstream.h>
  1208.   
  1209. diff -rc2N /free/libg++-2.5.3/libg++/src/Complex.h /sources/libg++-2.5.3-amiga/libg++/src/Complex.h
  1210. *** /free/libg++-2.5.3/libg++/src/Complex.h    Mon Dec 27 21:38:12 1993
  1211. --- /sources/libg++-2.5.3-amiga/libg++/src/Complex.h    Sun Dec  5 19:52:33 1993
  1212. ***************
  1213. *** 1,6 ****
  1214. ! #ifndef _complex_h
  1215. ! #define _complex_h
  1216. ! #define __ATT_complex__
  1217. ! #include <Complex.h>
  1218. ! typedef class Complex complex;
  1219.   #endif
  1220. --- 1,276 ----
  1221. ! // This may look like C code, but it is really -*- C++ -*-
  1222. ! /* 
  1223. ! Copyright (C) 1988 Free Software Foundation
  1224. !     written by Doug Lea (dl@rocky.oswego.edu)
  1225. ! This file is part of the GNU C++ Library.  This library is free
  1226. ! software; you can redistribute it and/or modify it under the terms of
  1227. ! the GNU Library General Public License as published by the Free
  1228. ! Software Foundation; either version 2 of the License, or (at your
  1229. ! option) any later version.  This library is distributed in the hope
  1230. ! that it will be useful, but WITHOUT ANY WARRANTY; without even the
  1231. ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  1232. ! PURPOSE.  See the GNU Library General Public License for more details.
  1233. ! You should have received a copy of the GNU Library General Public
  1234. ! License along with this library; if not, write to the Free Software
  1235. ! Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1236. ! */
  1237. ! #ifndef _Complex_h
  1238. ! #ifdef __GNUG__
  1239. ! #pragma interface
  1240. ! #endif
  1241. ! #define _Complex_h 1
  1242. ! #include <stream.h>
  1243. ! #include <math.h>
  1244. ! class Complex
  1245. ! {
  1246. ! #ifdef __ATT_complex__
  1247. ! public:
  1248. ! #else
  1249. ! protected:
  1250. ! #endif
  1251. !   double           re;
  1252. !   double           im;
  1253. ! public:
  1254. !   double           real() const;
  1255. !   double           imag() const;
  1256. !                    Complex();
  1257. !                    Complex(const Complex& y);
  1258. !                    Complex(double r, double i=0);
  1259. !                   ~Complex();
  1260. !   Complex&         operator =  (const Complex& y);
  1261. !   Complex&         operator += (const Complex& y);
  1262. !   Complex&         operator += (double y);
  1263. !   Complex&         operator -= (const Complex& y);
  1264. !   Complex&         operator -= (double y);
  1265. !   Complex&         operator *= (const Complex& y);
  1266. !   Complex&         operator *= (double y);
  1267. !   Complex&         operator /= (const Complex& y); 
  1268. !   Complex&         operator /= (double y); 
  1269. !   void             error(const char* msg) const;
  1270. ! };
  1271. ! // non-inline functions
  1272. ! Complex   operator /  (const Complex& x, const Complex& y);
  1273. ! Complex   operator /  (const Complex& x, double y);
  1274. ! Complex   operator /  (double   x, const Complex& y);
  1275. ! Complex   cos(const Complex& x);
  1276. ! Complex   sin(const Complex& x);
  1277. ! Complex   cosh(const Complex& x);
  1278. ! Complex   sinh(const Complex& x);
  1279. ! Complex   exp(const Complex& x);
  1280. ! Complex   log(const Complex& x);
  1281. ! Complex   pow(const Complex& x, int p);
  1282. ! Complex   pow(const Complex& x, const Complex& p);
  1283. ! Complex   pow(const Complex& x, double y);
  1284. ! Complex   sqrt(const Complex& x);
  1285. !    
  1286. ! istream&  operator >> (istream& s, Complex& x);
  1287. ! ostream&  operator << (ostream& s, const Complex& x);
  1288. ! // other functions defined as inlines
  1289. ! int  operator == (const Complex& x, const Complex& y);
  1290. ! int  operator == (const Complex& x, double y);
  1291. ! int  operator != (const Complex& x, const Complex& y);
  1292. ! int  operator != (const Complex& x, double y);
  1293. ! Complex  operator - (const Complex& x);
  1294. ! Complex  conj(const Complex& x);
  1295. ! Complex  operator + (const Complex& x, const Complex& y);
  1296. ! Complex  operator + (const Complex& x, double y);
  1297. ! Complex  operator + (double x, const Complex& y);
  1298. ! Complex  operator - (const Complex& x, const Complex& y);
  1299. ! Complex  operator - (const Complex& x, double y);
  1300. ! Complex  operator - (double x, const Complex& y);
  1301. ! Complex  operator * (const Complex& x, const Complex& y);
  1302. ! Complex  operator * (const Complex& x, double y);
  1303. ! Complex  operator * (double x, const Complex& y);
  1304. ! double  real(const Complex& x);
  1305. ! double  imag(const Complex& x);
  1306. ! double  abs(const Complex& x);
  1307. ! double  norm(const Complex& x);
  1308. ! double  arg(const Complex& x);
  1309. ! Complex  polar(double r, double t = 0.0);
  1310. ! // inline members
  1311. ! inline double  Complex::real() const { return re; }
  1312. ! inline double  Complex::imag() const { return im; }
  1313. ! inline Complex::Complex() {}
  1314. ! inline Complex::Complex(const Complex& y) :re(y.real()), im(y.imag()) {}
  1315. ! inline Complex::Complex(double r, double i) :re(r), im(i) {}
  1316. ! inline Complex::~Complex() {}
  1317. ! inline Complex&  Complex::operator =  (const Complex& y) 
  1318. ! { 
  1319. !   re = y.real(); im = y.imag(); return *this; 
  1320. ! } 
  1321. ! inline Complex&  Complex::operator += (const Complex& y)
  1322. ! { 
  1323. !   re += y.real();  im += y.imag(); return *this; 
  1324. ! }
  1325. ! inline Complex&  Complex::operator += (double y)
  1326. ! { 
  1327. !   re += y; return *this; 
  1328. ! }
  1329. ! inline Complex&  Complex::operator -= (const Complex& y)
  1330. ! { 
  1331. !   re -= y.real();  im -= y.imag(); return *this; 
  1332. ! }
  1333. ! inline Complex&  Complex::operator -= (double y)
  1334. ! { 
  1335. !   re -= y; return *this; 
  1336. ! }
  1337. ! inline Complex&  Complex::operator *= (const Complex& y)
  1338. ! {  
  1339. !   double r = re * y.real() - im * y.imag();
  1340. !   im = re * y.imag() + im * y.real(); 
  1341. !   re = r; 
  1342. !   return *this; 
  1343. ! }
  1344. ! inline Complex&  Complex::operator *= (double y)
  1345. ! {  
  1346. !   re *=  y; im *=  y; return *this; 
  1347. ! }
  1348. ! //  functions
  1349. ! inline int  operator == (const Complex& x, const Complex& y)
  1350. ! {
  1351. !   return x.real() == y.real() && x.imag() == y.imag();
  1352. ! }
  1353. ! inline int  operator == (const Complex& x, double y)
  1354. ! {
  1355. !   return x.imag() == 0.0 && x.real() == y;
  1356. ! }
  1357. ! inline int  operator != (const Complex& x, const Complex& y)
  1358. ! {
  1359. !   return x.real() != y.real() || x.imag() != y.imag();
  1360. ! }
  1361. ! inline int  operator != (const Complex& x, double y)
  1362. ! {
  1363. !   return x.imag() != 0.0 || x.real() != y;
  1364. ! }
  1365. ! inline Complex  operator - (const Complex& x)
  1366. ! {
  1367. !   return Complex(-x.real(), -x.imag());
  1368. ! }
  1369. ! inline Complex  conj(const Complex& x)
  1370. ! {
  1371. !   return Complex(x.real(), -x.imag());
  1372. ! }
  1373. ! inline Complex  operator + (const Complex& x, const Complex& y)
  1374. ! {
  1375. !   return Complex(x.real() + y.real(), x.imag() + y.imag());
  1376. ! }
  1377. ! inline Complex  operator + (const Complex& x, double y)
  1378. ! {
  1379. !   return Complex(x.real() + y, x.imag());
  1380. ! }
  1381. ! inline Complex  operator + (double x, const Complex& y)
  1382. ! {
  1383. !   return Complex(x + y.real(), y.imag());
  1384. ! }
  1385. ! inline Complex  operator - (const Complex& x, const Complex& y)
  1386. ! {
  1387. !   return Complex(x.real() - y.real(), x.imag() - y.imag());
  1388. ! }
  1389. ! inline Complex  operator - (const Complex& x, double y)
  1390. ! {
  1391. !   return Complex(x.real() - y, x.imag());
  1392. ! }
  1393. ! inline Complex  operator - (double x, const Complex& y)
  1394. ! {
  1395. !   return Complex(x - y.real(), -y.imag());
  1396. ! }
  1397. ! inline Complex  operator * (const Complex& x, const Complex& y)
  1398. ! {
  1399. !   return Complex(x.real() * y.real() - x.imag() * y.imag(), 
  1400. !                  x.real() * y.imag() + x.imag() * y.real());
  1401. ! }
  1402. ! inline Complex  operator * (const Complex& x, double y)
  1403. ! {
  1404. !   return Complex(x.real() * y, x.imag() * y);
  1405. ! }
  1406. ! inline Complex  operator * (double x, const Complex& y)
  1407. ! {
  1408. !   return Complex(x * y.real(), x * y.imag());
  1409. ! }
  1410. ! inline double  real(const Complex& x)
  1411. ! {
  1412. !   return x.real();
  1413. ! }
  1414. ! inline double  imag(const Complex& x)
  1415. ! {
  1416. !   return x.imag();
  1417. ! }
  1418. ! inline double  abs(const Complex& x)
  1419. ! {
  1420. !   return hypot(x.real(), x.imag());
  1421. ! }
  1422. ! inline double  norm(const Complex& x)
  1423. ! {
  1424. !   return (x.real() * x.real() + x.imag() * x.imag());
  1425. ! }
  1426. ! inline double  arg(const Complex& x)
  1427. ! {
  1428. !   return atan2(x.imag(), x.real());
  1429. ! }
  1430. ! inline Complex  polar(double r, double t)
  1431. ! {
  1432. !   return Complex(r * cos(t), r * sin(t));
  1433. ! }
  1434.   #endif
  1435. diff -rc2N /free/libg++-2.5.3/libg++/src/Regex.cc /sources/libg++-2.5.3-amiga/libg++/src/Regex.cc
  1436. *** /free/libg++-2.5.3/libg++/src/Regex.cc    Mon Dec 27 21:38:17 1993
  1437. --- /sources/libg++-2.5.3-amiga/libg++/src/Regex.cc    Sun Dec  5 19:26:03 1993
  1438. ***************
  1439. *** 55,59 ****
  1440. --- 55,64 ----
  1441.   
  1442.   #include <_G_config.h>
  1443. + #ifdef amigados
  1444. + /* amigados is not case sensitive ! */
  1445. + #include "gcc:include/string.h"
  1446. + #else
  1447.   #include <string.h>
  1448. + #endif
  1449.   #include <stdlib.h>
  1450.   
  1451. ***************
  1452. *** 115,120 ****
  1453.   
  1454.   /* Get the interface, including the syntax bits.  */
  1455.   #include "regex.h"
  1456.   
  1457.   /* These are the command codes that appear in compiled regular
  1458. --- 120,129 ----
  1459.   
  1460.   /* Get the interface, including the syntax bits.  */
  1461. + #ifdef amigados
  1462. + /* amigados is not case sensitive ! */
  1463. + #include "_regex.h"
  1464. + #else
  1465.   #include "regex.h"
  1466. ! #endif
  1467.   
  1468.   /* These are the command codes that appear in compiled regular
  1469. diff -rc2N /free/libg++-2.5.3/libg++/src/Regex.h /sources/libg++-2.5.3-amiga/libg++/src/Regex.h
  1470. *** /free/libg++-2.5.3/libg++/src/Regex.h    Mon Dec 27 21:38:17 1993
  1471. --- /sources/libg++-2.5.3-amiga/libg++/src/Regex.h    Sun Dec  5 19:13:54 1993
  1472. ***************
  1473. *** 1,6 ****
  1474. ! /* Definitions for data structures callers pass the regex library.
  1475.   
  1476. -    Copyright (C) 1985, 1989-92 Free Software Foundation, Inc.
  1477.   This file is part of the GNU C++ Library.  This library is free
  1478.   software; you can redistribute it and/or modify it under the terms of
  1479. --- 1,7 ----
  1480. ! // This may look like C code, but it is really -*- C++ -*-
  1481. ! /* 
  1482. ! Copyright (C) 1988 Free Software Foundation
  1483. !     written by Doug Lea (dl@rocky.oswego.edu)
  1484.   
  1485.   This file is part of the GNU C++ Library.  This library is free
  1486.   software; you can redistribute it and/or modify it under the terms of
  1487. ***************
  1488. *** 16,21 ****
  1489.   */
  1490.   
  1491. ! #ifndef __REGEXP_LIBRARY
  1492. ! #define __REGEXP_LIBRARY
  1493.   
  1494.   #if defined(SHORT_NAMES) || defined(VMS)
  1495. --- 17,26 ----
  1496.   */
  1497.   
  1498. ! #ifndef _Regex_h
  1499. ! #ifdef __GNUG__
  1500. ! #pragma interface
  1501. ! #endif
  1502. ! #define _Regex_h 1
  1503.   
  1504.   #if defined(SHORT_NAMES) || defined(VMS)
  1505. ***************
  1506. *** 25,272 ****
  1507.   #endif
  1508.   
  1509. ! #ifdef __cplusplus
  1510. ! extern "C" {
  1511. ! #endif
  1512. ! /* Define number of parens for which we record the beginnings and ends.
  1513. !    This affects how much space the `struct re_registers' type takes up.  */
  1514. ! #ifndef RE_NREGS
  1515. ! #define RE_NREGS 10
  1516. ! #endif
  1517. ! #define BYTEWIDTH 8
  1518. ! /* Maximum number of duplicates an interval can allow.  */
  1519. ! #ifndef RE_DUP_MAX /* kludge for AIX, which defines it */
  1520. ! #define RE_DUP_MAX  ((1 << 15) - 1) 
  1521. ! #endif
  1522. ! /* This defines the various regexp syntaxes.  */
  1523. ! extern int obscure_syntax;
  1524.   
  1525.   
  1526. - /* The following bits are used in the obscure_syntax variable to choose among
  1527. -    alternative regexp syntaxes.  */
  1528.   
  1529. - /* If this bit is set, plain parentheses serve as grouping, and backslash
  1530. -      parentheses are needed for literal searching.
  1531. -    If not set, backslash-parentheses are grouping, and plain parentheses
  1532. -      are for literal searching.  */
  1533. - #define RE_NO_BK_PARENS    1
  1534. - /* If this bit is set, plain | serves as the `or'-operator, and \| is a 
  1535. -      literal.
  1536. -    If not set, \| serves as the `or'-operator, and | is a literal.  */
  1537. - #define RE_NO_BK_VBAR (1 << 1)
  1538. - /* If this bit is not set, plain + or ? serves as an operator, and \+, \? are 
  1539. -      literals.
  1540. -    If set, \+, \? are operators and plain +, ? are literals.  */
  1541. - #define RE_BK_PLUS_QM (1 << 2)
  1542. - /* If this bit is set, | binds tighter than ^ or $.
  1543. -    If not set, the contrary.  */
  1544. - #define RE_TIGHT_VBAR (1 << 3)
  1545. - /* If this bit is set, then treat newline as an OR operator.
  1546. -    If not set, treat it as a normal character.  */
  1547. - #define RE_NEWLINE_OR (1 << 4)
  1548. - /* If this bit is set, then special characters may act as normal
  1549. -    characters in some contexts. Specifically, this applies to:
  1550. -     ^ -- only special at the beginning, or after ( or |;
  1551. -     $ -- only special at the end, or before ) or |;
  1552. -     *, +, ? -- only special when not after the beginning, (, or |.
  1553. -    If this bit is not set, special characters (such as *, ^, and $)
  1554. -    always have their special meaning regardless of the surrounding
  1555. -    context.  */
  1556. - #define RE_CONTEXT_INDEP_OPS (1 << 5)
  1557. - /* If this bit is not set, then \ before anything inside [ and ] is taken as 
  1558. -      a real \.
  1559. -    If set, then such a \ escapes the following character.  This is a
  1560. -      special case for awk.  */
  1561. - #define RE_AWK_CLASS_HACK (1 << 6)
  1562. - /* If this bit is set, then \{ and \} or { and } serve as interval operators.
  1563. -    If not set, then \{ and \} and { and } are treated as literals.  */
  1564. - #define RE_INTERVALS (1 << 7)
  1565. - /* If this bit is not set, then \{ and \} serve as interval operators and 
  1566. -      { and } are literals.
  1567. -    If set, then { and } serve as interval operators and \{ and \} are 
  1568. -      literals.  */
  1569. - #define RE_NO_BK_CURLY_BRACES (1 << 8)
  1570. - /* If this bit is set, then character classes are supported; they are:
  1571. -      [:alpha:],    [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
  1572. -      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
  1573. -    If not set, then character classes are not supported.  */
  1574. - #define RE_CHAR_CLASSES (1 << 9)
  1575. - /* If this bit is set, then the dot re doesn't match a null byte.
  1576. -    If not set, it does.  */
  1577. - #define RE_DOT_NOT_NULL (1 << 10)
  1578. - /* If this bit is set, then [^...] doesn't match a newline.
  1579. -    If not set, it does.  */
  1580. - #define RE_HAT_NOT_NEWLINE (1 << 11)
  1581. - /* If this bit is set, back references are recognized.
  1582. -    If not set, they aren't.  */
  1583. - #define RE_NO_BK_REFS (1 << 12)
  1584. - /* If this bit is set, back references must refer to a preceding
  1585. -    subexpression.  If not set, a back reference to a nonexistent
  1586. -    subexpression is treated as literal characters.  */
  1587. - #define RE_NO_EMPTY_BK_REF (1 << 13)
  1588. - /* If this bit is set, bracket expressions can't be empty.  
  1589. -    If it is set, they can be empty.  */
  1590. - #define RE_NO_EMPTY_BRACKETS (1 << 14)
  1591. - /* If this bit is set, then *, +, ? and { cannot be first in an re or
  1592. -    immediately after a |, or a (.  Furthermore, a | cannot be first or
  1593. -    last in an re, or immediately follow another | or a (.  Also, a ^
  1594. -    cannot appear in a nonleading position and a $ cannot appear in a
  1595. -    nontrailing position (outside of bracket expressions, that is).  */
  1596. - #define RE_CONTEXTUAL_INVALID_OPS (1 << 15)
  1597. - /* If this bit is set, then +, ? and | aren't recognized as operators.
  1598. -    If it's not, they are.  */
  1599. - #define RE_LIMITED_OPS (1 << 16)
  1600. - /* If this bit is set, then an ending range point has to collate higher
  1601. -      or equal to the starting range point.
  1602. -    If it's not set, then when the ending range point collates higher
  1603. -      than the starting range point, the range is just considered empty.  */
  1604. - #define RE_NO_EMPTY_RANGES (1 << 17)
  1605. - /* If this bit is set, then a hyphen (-) can't be an ending range point.
  1606. -    If it isn't, then it can.  */
  1607. - #define RE_NO_HYPHEN_RANGE_END (1 << 18)
  1608. - /* Define combinations of bits for the standard possibilities.  */
  1609. - #define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1610. -             | RE_CONTEXT_INDEP_OPS)
  1611. - #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1612. -             | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
  1613. - #define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1614. -             | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
  1615. - #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  1616. - #define RE_SYNTAX_EMACS 0
  1617. - #define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM         \
  1618. -             | RE_CHAR_CLASSES | RE_DOT_NOT_NULL         \
  1619. -                         | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF     \
  1620. -                         | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS        \
  1621. -                         | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)    
  1622. -                         
  1623. - #define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES       \
  1624. -             | RE_NO_BK_VBAR | RE_NO_BK_PARENS            \
  1625. -                         | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES            \
  1626. -                         | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
  1627. -                         | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES            \
  1628. -                         | RE_NO_HYPHEN_RANGE_END)
  1629. - /* This data structure is used to represent a compiled pattern.  */
  1630. - struct re_pattern_buffer
  1631. -   {
  1632. -     char *buffer;    /* Space holding the compiled pattern commands.  */
  1633. -     long allocated;    /* Size of space that `buffer' points to. */
  1634. -     long used;        /* Length of portion of buffer actually occupied  */
  1635. -     char *fastmap;    /* Pointer to fastmap, if any, or zero if none.  */
  1636. -             /* re_search uses the fastmap, if there is one,
  1637. -                to skip over totally implausible characters.  */
  1638. -     char *translate;    /* Translate table to apply to all characters before 
  1639. -                    comparing, or zero for no translation.
  1640. -                The translation is applied to a pattern when it is 
  1641. -                            compiled and to data when it is matched.  */
  1642. -     char fastmap_accurate;
  1643. -             /* Set to zero when a new pattern is stored,
  1644. -                set to one when the fastmap is updated from it.  */
  1645. -     char can_be_null;   /* Set to one by compiling fastmap
  1646. -                if this pattern might match the null string.
  1647. -                It does not necessarily match the null string
  1648. -                in that case, but if this is zero, it cannot.
  1649. -                2 as value means can match null string
  1650. -                but at end of range or before a character
  1651. -                listed in the fastmap.  */
  1652. -   };
  1653. - /* search.c (search_buffer) needs this one value.  It is defined both in
  1654. -    regex.c and here.  */
  1655. - #define RE_EXACTN_VALUE 1
  1656. - /* Structure to store register contents data in.
  1657. -    Pass the address of such a structure as an argument to re_match, etc.,
  1658. -    if you want this information back.
  1659. -    For i from 1 to RE_NREGS - 1, start[i] records the starting index in
  1660. -    the string of where the ith subexpression matched, and end[i] records
  1661. -    one after the ending index.  start[0] and end[0] are analogous, for
  1662. -    the entire pattern.  */
  1663. - struct re_registers
  1664. -   {
  1665. -     int start[RE_NREGS];
  1666. -     int end[RE_NREGS];
  1667. -   };
  1668. - #if defined(__STDC__) || defined(__cplusplus)
  1669. - extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
  1670. - /* Is this really advertised?  */
  1671. - extern void re_compile_fastmap (struct re_pattern_buffer *);
  1672. - extern int re_search (struct re_pattern_buffer *, char*, int, int, int,
  1673. -               struct re_registers *);
  1674. - extern int re_search_2 (struct re_pattern_buffer *, char *, int,
  1675. -             char *, int, int, int,
  1676. -             struct re_registers *, int);
  1677. - extern int re_match (struct re_pattern_buffer *, char *, int, int,
  1678. -              struct re_registers *);
  1679. - extern int re_match_2 (struct re_pattern_buffer *, char *, int,
  1680. -                char *, int, int, struct re_registers *, int);
  1681. - #if 0
  1682. - /* 4.2 bsd compatibility.  */
  1683. - extern char *re_comp (char *);
  1684. - extern int re_exec (char *);
  1685.   #endif
  1686. - #else /* !__STDC__ */
  1687. - #define const /* nothing */
  1688. - extern char *re_compile_pattern ();
  1689. - /* Is this really advertised? */
  1690. - extern void re_compile_fastmap ();
  1691. - extern int re_search (), re_search_2 ();
  1692. - extern int re_match (), re_match_2 ();
  1693. - #if 0
  1694. - /* 4.2 bsd compatibility.  */
  1695. - extern char *re_comp ();
  1696. - extern int re_exec ();
  1697. - #endif
  1698. - #endif /* __STDC__ */
  1699. - #ifdef SYNTAX_TABLE
  1700. - extern char *re_syntax_table;
  1701. - #endif
  1702. - #ifdef __cplusplus
  1703. - extern int re_max_failures;
  1704. - }
  1705. - #endif
  1706. - #endif /* !__REGEXP_LIBRARY */
  1707. --- 30,76 ----
  1708.   #endif
  1709.   
  1710. ! struct re_pattern_buffer;       // defined elsewhere
  1711. ! struct re_registers;
  1712.   
  1713. + class Regex
  1714. + {
  1715. + private:
  1716. +                      Regex(const Regex&) {}  // no X(X&)
  1717. +   void               operator = (const Regex&) {} // no assignment
  1718. + protected:
  1719. +   re_pattern_buffer* buf;
  1720. +   re_registers*      reg;
  1721. + public:
  1722. +                      Regex(const char* t, 
  1723. +                            int fast = 0, 
  1724. +                            int bufsize = 40, 
  1725. +                            const char* transtable = 0);
  1726. +                     ~Regex();
  1727. +   int                match(const char* s, int len, int pos = 0) const;
  1728. +   int                search(const char* s, int len, 
  1729. +                             int& matchlen, int startpos = 0) const;
  1730. +   int                match_info(int& start, int& length, int nth = 0) const;
  1731. +   int                OK() const;  // representation invariant
  1732. + };
  1733. + // some built in regular expressions
  1734. + extern const Regex RXwhite;          // = "[ \n\t\r\v\f]+"
  1735. + extern const Regex RXint;            // = "-?[0-9]+"
  1736. + extern const Regex RXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
  1737. +                                      //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
  1738. +                                      //    \\([eE][---+]?[0-9]+\\)?"
  1739. + extern const Regex RXalpha;          // = "[A-Za-z]+"
  1740. + extern const Regex RXlowercase;      // = "[a-z]+"
  1741. + extern const Regex RXuppercase;      // = "[A-Z]+"
  1742. + extern const Regex RXalphanum;       // = "[0-9A-Za-z]+"
  1743. + extern const Regex RXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
  1744.   
  1745.   
  1746.   #endif
  1747. diff -rc2N /free/libg++-2.5.3/libg++/src/String.cc /sources/libg++-2.5.3-amiga/libg++/src/String.cc
  1748. *** /free/libg++-2.5.3/libg++/src/String.cc    Mon Dec 27 21:38:10 1993
  1749. --- /sources/libg++-2.5.3-amiga/libg++/src/String.cc    Sun Dec  5 19:14:24 1993
  1750. ***************
  1751. *** 31,35 ****
  1752. --- 31,40 ----
  1753.   
  1754.   // extern "C" {
  1755. + #ifdef amigados
  1756. + /* amigados is not case sensitive ! */
  1757. + #include <_regex.h>
  1758. + #else
  1759.   #include <regex.h>
  1760. + #endif
  1761.   // }
  1762.   
  1763. diff -rc2N /free/libg++-2.5.3/libg++/src/_complex.h /sources/libg++-2.5.3-amiga/libg++/src/_complex.h
  1764. *** /free/libg++-2.5.3/libg++/src/_complex.h    Thu Jan  1 00:00:00 1970
  1765. --- /sources/libg++-2.5.3-amiga/libg++/src/_complex.h    Sun Dec  5 16:43:30 1993
  1766. ***************
  1767. *** 0 ****
  1768. --- 1,6 ----
  1769. + #ifndef _complex_h
  1770. + #define _complex_h
  1771. + #define __ATT_complex__
  1772. + #include <Complex.h>
  1773. + typedef class Complex complex;
  1774. + #endif
  1775. diff -rc2N /free/libg++-2.5.3/libg++/src/_regex.h /sources/libg++-2.5.3-amiga/libg++/src/_regex.h
  1776. *** /free/libg++-2.5.3/libg++/src/_regex.h    Thu Jan  1 00:00:00 1970
  1777. --- /sources/libg++-2.5.3-amiga/libg++/src/_regex.h    Sun Dec  5 19:26:57 1993
  1778. ***************
  1779. *** 0 ****
  1780. --- 1,272 ----
  1781. + /* Definitions for data structures callers pass the regex library.
  1782. +    Copyright (C) 1985, 1989-92 Free Software Foundation, Inc.
  1783. + This file is part of the GNU C++ Library.  This library is free
  1784. + software; you can redistribute it and/or modify it under the terms of
  1785. + the GNU Library General Public License as published by the Free
  1786. + Software Foundation; either version 2 of the License, or (at your
  1787. + option) any later version.  This library is distributed in the hope
  1788. + that it will be useful, but WITHOUT ANY WARRANTY; without even the
  1789. + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  1790. + PURPOSE.  See the GNU Library General Public License for more details.
  1791. + You should have received a copy of the GNU Library General Public
  1792. + License along with this library; if not, write to the Free Software
  1793. + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1794. + */
  1795. + #ifndef __REGEXP_LIBRARY
  1796. + #define __REGEXP_LIBRARY
  1797. + #if defined(SHORT_NAMES) || defined(VMS)
  1798. + #define re_compile_pattern    recmppat
  1799. + #define re_pattern_buffer    repatbuf
  1800. + #define re_registers        reregs
  1801. + #endif
  1802. + #ifdef __cplusplus
  1803. + extern "C" {
  1804. + #endif
  1805. + /* Define number of parens for which we record the beginnings and ends.
  1806. +    This affects how much space the `struct re_registers' type takes up.  */
  1807. + #ifndef RE_NREGS
  1808. + #define RE_NREGS 10
  1809. + #endif
  1810. + #define BYTEWIDTH 8
  1811. + /* Maximum number of duplicates an interval can allow.  */
  1812. + #ifndef RE_DUP_MAX /* kludge for AIX, which defines it */
  1813. + #define RE_DUP_MAX  ((1 << 15) - 1) 
  1814. + #endif
  1815. + /* This defines the various regexp syntaxes.  */
  1816. + extern int obscure_syntax;
  1817. + /* The following bits are used in the obscure_syntax variable to choose among
  1818. +    alternative regexp syntaxes.  */
  1819. + /* If this bit is set, plain parentheses serve as grouping, and backslash
  1820. +      parentheses are needed for literal searching.
  1821. +    If not set, backslash-parentheses are grouping, and plain parentheses
  1822. +      are for literal searching.  */
  1823. + #define RE_NO_BK_PARENS    1
  1824. + /* If this bit is set, plain | serves as the `or'-operator, and \| is a 
  1825. +      literal.
  1826. +    If not set, \| serves as the `or'-operator, and | is a literal.  */
  1827. + #define RE_NO_BK_VBAR (1 << 1)
  1828. + /* If this bit is not set, plain + or ? serves as an operator, and \+, \? are 
  1829. +      literals.
  1830. +    If set, \+, \? are operators and plain +, ? are literals.  */
  1831. + #define RE_BK_PLUS_QM (1 << 2)
  1832. + /* If this bit is set, | binds tighter than ^ or $.
  1833. +    If not set, the contrary.  */
  1834. + #define RE_TIGHT_VBAR (1 << 3)
  1835. + /* If this bit is set, then treat newline as an OR operator.
  1836. +    If not set, treat it as a normal character.  */
  1837. + #define RE_NEWLINE_OR (1 << 4)
  1838. + /* If this bit is set, then special characters may act as normal
  1839. +    characters in some contexts. Specifically, this applies to:
  1840. +     ^ -- only special at the beginning, or after ( or |;
  1841. +     $ -- only special at the end, or before ) or |;
  1842. +     *, +, ? -- only special when not after the beginning, (, or |.
  1843. +    If this bit is not set, special characters (such as *, ^, and $)
  1844. +    always have their special meaning regardless of the surrounding
  1845. +    context.  */
  1846. + #define RE_CONTEXT_INDEP_OPS (1 << 5)
  1847. + /* If this bit is not set, then \ before anything inside [ and ] is taken as 
  1848. +      a real \.
  1849. +    If set, then such a \ escapes the following character.  This is a
  1850. +      special case for awk.  */
  1851. + #define RE_AWK_CLASS_HACK (1 << 6)
  1852. + /* If this bit is set, then \{ and \} or { and } serve as interval operators.
  1853. +    If not set, then \{ and \} and { and } are treated as literals.  */
  1854. + #define RE_INTERVALS (1 << 7)
  1855. + /* If this bit is not set, then \{ and \} serve as interval operators and 
  1856. +      { and } are literals.
  1857. +    If set, then { and } serve as interval operators and \{ and \} are 
  1858. +      literals.  */
  1859. + #define RE_NO_BK_CURLY_BRACES (1 << 8)
  1860. + /* If this bit is set, then character classes are supported; they are:
  1861. +      [:alpha:],    [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
  1862. +      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
  1863. +    If not set, then character classes are not supported.  */
  1864. + #define RE_CHAR_CLASSES (1 << 9)
  1865. + /* If this bit is set, then the dot re doesn't match a null byte.
  1866. +    If not set, it does.  */
  1867. + #define RE_DOT_NOT_NULL (1 << 10)
  1868. + /* If this bit is set, then [^...] doesn't match a newline.
  1869. +    If not set, it does.  */
  1870. + #define RE_HAT_NOT_NEWLINE (1 << 11)
  1871. + /* If this bit is set, back references are recognized.
  1872. +    If not set, they aren't.  */
  1873. + #define RE_NO_BK_REFS (1 << 12)
  1874. + /* If this bit is set, back references must refer to a preceding
  1875. +    subexpression.  If not set, a back reference to a nonexistent
  1876. +    subexpression is treated as literal characters.  */
  1877. + #define RE_NO_EMPTY_BK_REF (1 << 13)
  1878. + /* If this bit is set, bracket expressions can't be empty.  
  1879. +    If it is set, they can be empty.  */
  1880. + #define RE_NO_EMPTY_BRACKETS (1 << 14)
  1881. + /* If this bit is set, then *, +, ? and { cannot be first in an re or
  1882. +    immediately after a |, or a (.  Furthermore, a | cannot be first or
  1883. +    last in an re, or immediately follow another | or a (.  Also, a ^
  1884. +    cannot appear in a nonleading position and a $ cannot appear in a
  1885. +    nontrailing position (outside of bracket expressions, that is).  */
  1886. + #define RE_CONTEXTUAL_INVALID_OPS (1 << 15)
  1887. + /* If this bit is set, then +, ? and | aren't recognized as operators.
  1888. +    If it's not, they are.  */
  1889. + #define RE_LIMITED_OPS (1 << 16)
  1890. + /* If this bit is set, then an ending range point has to collate higher
  1891. +      or equal to the starting range point.
  1892. +    If it's not set, then when the ending range point collates higher
  1893. +      than the starting range point, the range is just considered empty.  */
  1894. + #define RE_NO_EMPTY_RANGES (1 << 17)
  1895. + /* If this bit is set, then a hyphen (-) can't be an ending range point.
  1896. +    If it isn't, then it can.  */
  1897. + #define RE_NO_HYPHEN_RANGE_END (1 << 18)
  1898. + /* Define combinations of bits for the standard possibilities.  */
  1899. + #define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1900. +             | RE_CONTEXT_INDEP_OPS)
  1901. + #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1902. +             | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
  1903. + #define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  1904. +             | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
  1905. + #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  1906. + #define RE_SYNTAX_EMACS 0
  1907. + #define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM         \
  1908. +             | RE_CHAR_CLASSES | RE_DOT_NOT_NULL         \
  1909. +                         | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF     \
  1910. +                         | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS        \
  1911. +                         | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)    
  1912. +                         
  1913. + #define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES       \
  1914. +             | RE_NO_BK_VBAR | RE_NO_BK_PARENS            \
  1915. +                         | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES            \
  1916. +                         | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
  1917. +                         | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES            \
  1918. +                         | RE_NO_HYPHEN_RANGE_END)
  1919. + /* This data structure is used to represent a compiled pattern.  */
  1920. + struct re_pattern_buffer
  1921. +   {
  1922. +     char *buffer;    /* Space holding the compiled pattern commands.  */
  1923. +     long allocated;    /* Size of space that `buffer' points to. */
  1924. +     long used;        /* Length of portion of buffer actually occupied  */
  1925. +     char *fastmap;    /* Pointer to fastmap, if any, or zero if none.  */
  1926. +             /* re_search uses the fastmap, if there is one,
  1927. +                to skip over totally implausible characters.  */
  1928. +     char *translate;    /* Translate table to apply to all characters before 
  1929. +                    comparing, or zero for no translation.
  1930. +                The translation is applied to a pattern when it is 
  1931. +                            compiled and to data when it is matched.  */
  1932. +     char fastmap_accurate;
  1933. +             /* Set to zero when a new pattern is stored,
  1934. +                set to one when the fastmap is updated from it.  */
  1935. +     char can_be_null;   /* Set to one by compiling fastmap
  1936. +                if this pattern might match the null string.
  1937. +                It does not necessarily match the null string
  1938. +                in that case, but if this is zero, it cannot.
  1939. +                2 as value means can match null string
  1940. +                but at end of range or before a character
  1941. +                listed in the fastmap.  */
  1942. +   };
  1943. + /* search.c (search_buffer) needs this one value.  It is defined both in
  1944. +    regex.c and here.  */
  1945. + #define RE_EXACTN_VALUE 1
  1946. + /* Structure to store register contents data in.
  1947. +    Pass the address of such a structure as an argument to re_match, etc.,
  1948. +    if you want this information back.
  1949. +    For i from 1 to RE_NREGS - 1, start[i] records the starting index in
  1950. +    the string of where the ith subexpression matched, and end[i] records
  1951. +    one after the ending index.  start[0] and end[0] are analogous, for
  1952. +    the entire pattern.  */
  1953. + struct re_registers
  1954. +   {
  1955. +     int start[RE_NREGS];
  1956. +     int end[RE_NREGS];
  1957. +   };
  1958. + #if defined(__STDC__) || defined(__cplusplus)
  1959. + extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
  1960. + /* Is this really advertised?  */
  1961. + extern void re_compile_fastmap (struct re_pattern_buffer *);
  1962. + extern int re_search (struct re_pattern_buffer *, char*, int, int, int,
  1963. +               struct re_registers *);
  1964. + extern int re_search_2 (struct re_pattern_buffer *, char *, int,
  1965. +             char *, int, int, int,
  1966. +             struct re_registers *, int);
  1967. + extern int re_match (struct re_pattern_buffer *, char *, int, int,
  1968. +              struct re_registers *);
  1969. + extern int re_match_2 (struct re_pattern_buffer *, char *, int,
  1970. +                char *, int, int, struct re_registers *, int);
  1971. + #if 0
  1972. + /* 4.2 bsd compatibility.  */
  1973. + extern char *re_comp (char *);
  1974. + extern int re_exec (char *);
  1975. + #endif
  1976. + #else /* !__STDC__ */
  1977. + #define const /* nothing */
  1978. + extern char *re_compile_pattern ();
  1979. + /* Is this really advertised? */
  1980. + extern void re_compile_fastmap ();
  1981. + extern int re_search (), re_search_2 ();
  1982. + extern int re_match (), re_match_2 ();
  1983. + #if 0
  1984. + /* 4.2 bsd compatibility.  */
  1985. + extern char *re_comp ();
  1986. + extern int re_exec ();
  1987. + #endif
  1988. + #endif /* __STDC__ */
  1989. + #ifdef SYNTAX_TABLE
  1990. + extern char *re_syntax_table;
  1991. + #endif
  1992. + #ifdef __cplusplus
  1993. + extern int re_max_failures;
  1994. + }
  1995. + #endif
  1996. + #endif /* !__REGEXP_LIBRARY */
  1997. diff -rc2N /free/libg++-2.5.3/libg++/src/std.h /sources/libg++-2.5.3-amiga/libg++/src/std.h
  1998. *** /free/libg++-2.5.3/libg++/src/std.h    Mon Dec 27 21:38:17 1993
  1999. --- /sources/libg++-2.5.3-amiga/libg++/src/std.h    Sun Dec  5 18:26:13 1993
  2000. ***************
  2001. *** 24,29 ****
  2002. --- 24,39 ----
  2003.   #include <stddef.h>
  2004.   #include <stdlib.h>
  2005. + #ifdef amigados
  2006. + /* amigados is not case sensitive ! */
  2007. + #include "gcc:include/string.h"
  2008. + #else
  2009.   #include <string.h>
  2010. + #endif
  2011. + #include <memory.h>
  2012. + #ifdef amigados
  2013. + /* conflicts w/ ../g++-include */
  2014. + #else
  2015.   #include <unistd.h>
  2016. + #endif
  2017.   #include <stdio.h> 
  2018.   #include <errno.h>
  2019. diff -rc2N /free/libg++-2.5.3/libg++/target-mkfrag /sources/libg++-2.5.3-amiga/libg++/target-mkfrag
  2020. *** /free/libg++-2.5.3/libg++/target-mkfrag    Thu Jan  1 00:00:00 1970
  2021. --- /sources/libg++-2.5.3-amiga/libg++/target-mkfrag    Sun Dec  5 16:43:51 1993
  2022. ***************
  2023. *** 0 ****
  2024. --- 1,11 ----
  2025. + # Warning this fragment is automatically generated
  2026. + # RANLIB = ranlib
  2027. + # Use -nostdinc++ flag if your version of gcc understands it.
  2028. + NOSTDINC = -nostdinc++
  2029. + # If the C include files are C++-ready (with extern "C"), uncomment next line:
  2030. + # WRAP_C_INCLUDES =
  2031. + # Flags to pass to gen-params when building _G_config.h.
  2032. + # For example: G_CONFIG_ARGS = size_t="unsigned long"
  2033. + G_CONFIG_ARGS =
  2034. diff -rc2N /free/libg++-2.5.3/libg++/tests/test_h.cc /sources/libg++-2.5.3-amiga/libg++/tests/test_h.cc
  2035. *** /free/libg++-2.5.3/libg++/tests/test_h.cc    Mon Dec 27 21:43:55 1993
  2036. --- /sources/libg++-2.5.3-amiga/libg++/tests/test_h.cc    Mon Dec 27 16:53:43 1993
  2037. ***************
  2038. *** 89,93 ****
  2039. --- 89,98 ----
  2040.   #include <stdlib.h>
  2041.   #include <strclass.h>
  2042. + #ifdef amigados
  2043. + /* amigados is not case sensitive ! */
  2044. + #include "gcc:include/string.h"
  2045. + #else
  2046.   #include <string.h>
  2047. + #endif
  2048.   #include <swap.h>
  2049.   #include <unistd.h>
  2050. diff -rc2N /free/libg++-2.5.3/libiberty/alloca-conf.h /sources/libg++-2.5.3-amiga/libiberty/alloca-conf.h
  2051. *** /free/libg++-2.5.3/libiberty/alloca-conf.h    Thu Jan  1 00:00:00 1970
  2052. --- /sources/libg++-2.5.3-amiga/libiberty/alloca-conf.h    Mon Dec 13 23:09:38 1993
  2053. ***************
  2054. *** 0 ****
  2055. --- 1,11 ----
  2056. + /* "Normal" configuration for alloca.  */
  2057. + #ifdef __GNUC__
  2058. + #define alloca __builtin_alloca
  2059. + #else /* not __GNUC__ */
  2060. + #ifdef sparc
  2061. + #include <alloca.h>
  2062. + #else
  2063. + char *alloca ();
  2064. + #endif /* sparc */
  2065. + #endif /* not __GNUC__ */
  2066. diff -rc2N /free/libg++-2.5.3/libiberty/config/mh-amigados /sources/libg++-2.5.3-amiga/libiberty/config/mh-amigados
  2067. *** /free/libg++-2.5.3/libiberty/config/mh-amigados    Thu Jan  1 00:00:00 1970
  2068. --- /sources/libg++-2.5.3-amiga/libiberty/config/mh-amigados    Sun Dec  5 16:44:18 1993
  2069. ***************
  2070. *** 0 ****
  2071. --- 1,5 ----
  2072. + # do the best you can ;-)
  2073. + CC = gcc -O2
  2074. + # as long as we don't have a working debugger under AmigaDOS, using
  2075. + # -g just wastes disk space, so don't use it
  2076. + CFLAGS =
  2077. diff -rc2N /free/libg++-2.5.3/libio/Make.pack /sources/libg++-2.5.3-amiga/libio/Make.pack
  2078. *** /free/libg++-2.5.3/libio/Make.pack    Thu Jan  1 00:00:00 1970
  2079. --- /sources/libg++-2.5.3-amiga/libio/Make.pack    Sun Dec  5 16:44:17 1993
  2080. ***************
  2081. *** 0 ****
  2082. --- 1,114 ----
  2083. + # Start of package fragment generated by ./config.shared.
  2084. + # TOPDIR=$${rootme}../../ invsubdir= subdir=
  2085. + srcdir = .
  2086. + SUBDIRS = 
  2087. + prefix = /usr/local
  2088. + exec_prefix = $(prefix)
  2089. + bindir = $(exec_prefix)/bin
  2090. + libdir = $(exec_prefix)/lib
  2091. + datadir = $(prefix)/lib
  2092. + mandir = $(prefix)/man
  2093. + man1dir = $(mandir)/man1
  2094. + man2dir = $(mandir)/man2
  2095. + man3dir = $(mandir)/man3
  2096. + man4dir = $(mandir)/man4
  2097. + man5dir = $(mandir)/man5
  2098. + man6dir = $(mandir)/man6
  2099. + man7dir = $(mandir)/man7
  2100. + man8dir = $(mandir)/man8
  2101. + man9dir = $(mandir)/man9
  2102. + infodir = $(prefix)/info
  2103. + includedir = $(prefix)/include
  2104. + gxx_includedir = $(libdir)/g++-include
  2105. + docdir = $(datadir)/doc
  2106. + SHELL = /bin/sh
  2107. + INSTALL = ${rootme}$(srcdir)/../../install.sh -c
  2108. + INSTALL_PROGRAM = $(INSTALL)
  2109. + INSTALL_DATA = $(INSTALL)
  2110. + AR = `if [ -f $${rootme}../../binutils/ar ] ; \
  2111. +     then echo $${rootme}../../binutils/ar ; \
  2112. +     else echo ar ; fi`
  2113. + AR_FLAGS = rc
  2114. + RANLIB = `if [ -f $${rootme}../../binutils/ranlib ] ; \
  2115. +     then echo $${rootme}../../binutils/ranlib ; \
  2116. +     else echo ranlib ; fi`
  2117. + NM = `if [ -f $${rootme}../../binutils/nm ] ; \
  2118. +     then echo $${rootme}../../binutils/nm ; \
  2119. +     else echo nm ; fi`
  2120. + MAKEINFO = `if [ -f $${rootme}../../texinfo/C/makeinfo ] ; \
  2121. +     then echo $${rootme}../../texinfo/C/makeinfo ; \
  2122. +     else echo makeinfo ; fi`
  2123. + TEXIDIR=${srcdir}/../..//texinfo
  2124. + TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi
  2125. + CC = `if [ -f $${rootme}../../gcc/xgcc ] ; \
  2126. +     then echo $${rootme}../../gcc/xgcc -B$${rootme}../../gcc/ ; \
  2127. +     else echo cc ; fi`
  2128. + CXX = `if [ -f $${rootme}../../gcc/xgcc ] ; \
  2129. +     then echo $${rootme}../../gcc/xgcc -B$${rootme}../../gcc/ ; \
  2130. +     else echo gcc ; fi`
  2131. + XTRAFLAGS = `if [ -f $${rootme}../../gcc/xgcc ] ;\
  2132. +     then echo -I$${rootme}../../gcc/include;\
  2133. +     else echo ; fi`
  2134. + WRAP_C_INCLUDES =
  2135. + CFLAGS = -g
  2136. + CXXFLAGS = -g -O
  2137. + .PHONY: all
  2138. + all: nothing
  2139. + .SUFFIXES: .o .C .cc
  2140. + .c.o:
  2141. +     $(CC) -c $(CFLAGS) $(CINCLUDES) $<
  2142. + .C.o:
  2143. +     $(CXX) -c $(CXXFLAGS) $(CXXINCLUDES) $<
  2144. + .cc.o:
  2145. +     $(CXX) -c $(CXXFLAGS) $(CXXINCLUDES) $<
  2146. + .PHONY: install
  2147. + install:
  2148. + .PHONY: check
  2149. + check: nothing 
  2150. + .PHONY: info dvi install-info clean-info
  2151. + info:
  2152. + dvi:
  2153. + install-info:
  2154. + .PHONY: do-clean-info clean-info do-clean-dvi clean-dvi
  2155. + do-clean-info:
  2156. + do-clean-dvi:
  2157. + clean-info: do-clean-info
  2158. + clean-dvi: do-clean-dvi
  2159. + .PHONY: boltcc
  2160. + boltcc:
  2161. +     rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS)
  2162. + # clean rules
  2163. + .PHONY: mostlyclean clean distclean realclean
  2164. + mostlyclean: clean-dvi
  2165. +     rm -rf *.o core stdio.list 
  2166. + clean: clean-dvi
  2167. +     rm -rf *.o core stdio.list   
  2168. + distclean: clean
  2169. +     rm -rf config.status Makefile *~ Make.pack
  2170. + realclean: clean clean-info
  2171. +     rm -rf config.status Makefile *~ Make.pack depend *.info*
  2172. + .PHONY: force
  2173. + force:
  2174. + # with the gnu make, this is done automatically.
  2175. + Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
  2176. +     $(SHELL) ./config.status
  2177. + .NOEXPORT:
  2178. + MAKEOVERRIDES=
  2179. + # End of package fragment generated by ./config.shared.
  2180. diff -rc2N /free/libg++-2.5.3/libio/dbz/rdbz.c /sources/libg++-2.5.3-amiga/libio/dbz/rdbz.c
  2181. *** /free/libg++-2.5.3/libio/dbz/rdbz.c    Mon Dec 27 21:41:03 1993
  2182. --- /sources/libg++-2.5.3-amiga/libio/dbz/rdbz.c    Mon Dec 13 22:57:12 1993
  2183. ***************
  2184. *** 0 ****
  2185. --- 1,1766 ----
  2186. + /*
  2187. + dbz.c  V3.2
  2188. + Copyright 1988 Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us)
  2189. + You can use this code in any manner, as long as you leave my name on it
  2190. + and don't hold me responsible for any problems with it.
  2191. + Hacked on by gdb@ninja.UUCP (David Butler); Sun Jun  5 00:27:08 CDT 1988
  2192. + Various improvments + INCORE by moraes@ai.toronto.edu (Mark Moraes)
  2193. + Major reworking by Henry Spencer as part of the C News project.
  2194. + These routines replace dbm as used by the usenet news software
  2195. + (it's not a full dbm replacement by any means).  It's fast and
  2196. + simple.  It contains no AT&T code.
  2197. + In general, dbz's files are 1/20 the size of dbm's.  Lookup performance
  2198. + is somewhat better, while file creation is spectacularly faster, especially
  2199. + if the incore facility is used.
  2200. + */
  2201. + #include <stdio.h>
  2202. + #include <sys/types.h>
  2203. + #include <string.h>
  2204. + #include <ctype.h>
  2205. + #include <errno.h>
  2206. + #ifndef __STDC__
  2207. + extern int errno;
  2208. + #endif
  2209. + #include <dbz.h>
  2210. + /*
  2211. +  * #ifdef index.  "LIA" = "leave it alone unless you know what you're doing".
  2212. +  *
  2213. +  * FUNNYSEEKS    SEEK_SET is not 0, get it from <unistd.h>
  2214. +  * INDEX_SIZE    backward compatibility with old dbz; avoid using this
  2215. +  * NMEMORY    number of days of memory for use in sizing new table (LIA)
  2216. +  * INCORE    backward compatibility with old dbz; use dbzincore() instead
  2217. +  * DBZDEBUG    enable debugging
  2218. +  * DEFSIZE    default table size (not as critical as in old dbz)
  2219. +  * OLDBNEWS    default case mapping as in old B News; set NOBUFFER
  2220. +  * BNEWS    default case mapping as in current B News; set NOBUFFER
  2221. +  * DEFCASE    default case-map algorithm selector
  2222. +  * NOTAGS    fseek offsets are strange, do not do tagging (see below)
  2223. +  * NPAGBUF    size of .pag buffer, in longs (LIA)
  2224. +  * SHISTBUF    size of ASCII-file buffer, in bytes (LIA)
  2225. +  * MAXRUN    length of run which shifts to next table (see below) (LIA)
  2226. +  * OVERFLOW    long-int arithmetic overflow must be avoided, will trap
  2227. +  * NOBUFFER    do not buffer hash-table i/o, B News locking is defective
  2228. +  */
  2229. + #ifdef FUNNYSEEKS
  2230. + #include <unistd.h>
  2231. + #else
  2232. + #define    SEEK_SET    0
  2233. + #endif
  2234. + #ifdef OVERFLOW
  2235. + #include <limits.h>
  2236. + #endif
  2237. + static int dbzversion = 3;    /* for validating .dir file format */
  2238. + /*
  2239. +  * The dbz database exploits the fact that when news stores a <key,value>
  2240. +  * tuple, the `value' part is a seek offset into a text file, pointing to
  2241. +  * a copy of the `key' part.  This avoids the need to store a copy of
  2242. +  * the key in the dbz files.  However, the text file *must* exist and be
  2243. +  * consistent with the dbz files, or things will fail.
  2244. +  *
  2245. +  * The basic format of the database is a simple hash table containing the
  2246. +  * values.  A value is stored by indexing into the table using a hash value
  2247. +  * computed from the key; collisions are resolved by linear probing (just
  2248. +  * search forward for an empty slot, wrapping around to the beginning of
  2249. +  * the table if necessary).  Linear probing is a performance disaster when
  2250. +  * the table starts to get full, so a complication is introduced.  The
  2251. +  * database is actually one *or more* tables, stored sequentially in the
  2252. +  * .pag file, and the length of linear-probe sequences is limited.  The
  2253. +  * search (for an existing item or an empty slot) always starts in the
  2254. +  * first table, and whenever MAXRUN probes have been done in table N,
  2255. +  * probing continues in table N+1.  This behaves reasonably well even in
  2256. +  * cases of massive overflow.  There are some other small complications
  2257. +  * added, see comments below.
  2258. +  *
  2259. +  * The table size is fixed for any particular database, but is determined
  2260. +  * dynamically when a database is rebuilt.  The strategy is to try to pick
  2261. +  * the size so the first table will be no more than 2/3 full, that being
  2262. +  * slightly before the point where performance starts to degrade.  (It is
  2263. +  * desirable to be a bit conservative because the overflow strategy tends
  2264. +  * to produce files with holes in them, which is a nuisance.)
  2265. +  */
  2266. + /*
  2267. +  * The following is for backward compatibility.
  2268. +  */
  2269. + #ifdef INDEX_SIZE
  2270. + #define    DEFSIZE    INDEX_SIZE
  2271. + #endif
  2272. + /*
  2273. +  * ANSI C says an offset into a file is a long, not an off_t, for some
  2274. +  * reason.  This actually does simplify life a bit, but it's still nice
  2275. +  * to have a distinctive name for it.  Beware, this is just for readability,
  2276. +  * don't try to change this.
  2277. +  */
  2278. + #define    of_t    long
  2279. + #define    SOF    (sizeof(of_t))
  2280. + /*
  2281. +  * We assume that unused areas of a binary file are zeros, and that the
  2282. +  * bit pattern of `(of_t)0' is all zeros.  The alternative is rather
  2283. +  * painful file initialization.  Note that okayvalue(), if OVERFLOW is
  2284. +  * defined, knows what value of an offset would cause overflow.
  2285. +  */
  2286. + #define    VACANT        ((of_t)0)
  2287. + #define    BIAS(o)        ((o)+1)        /* make any valid of_t non-VACANT */
  2288. + #define    UNBIAS(o)    ((o)-1)        /* reverse BIAS() effect */
  2289. + /*
  2290. +  * In a Unix implementation, or indeed any in which an of_t is a byte
  2291. +  * count, there are a bunch of high bits free in an of_t.  There is a
  2292. +  * use for them.  Checking a possible hit by looking it up in the base
  2293. +  * file is relatively expensive, and the cost can be dramatically reduced
  2294. +  * by using some of those high bits to tag the value with a few more bits
  2295. +  * of the key's hash.  This detects most false hits without the overhead of
  2296. +  * seek+read+strcmp.  We use the top bit to indicate whether the value is
  2297. +  * tagged or not, and don't tag a value which is using the tag bits itself.
  2298. +  * We're in trouble if the of_t representation wants to use the top bit.
  2299. +  * The actual bitmasks and offset come from the configuration stuff,
  2300. +  * which permits fiddling with them as necessary, and also suppressing
  2301. +  * them completely (by defining the masks to 0).  We build pre-shifted
  2302. +  * versions of the masks for efficiency.
  2303. +  */
  2304. + static of_t tagbits;        /* pre-shifted tag mask */
  2305. + static of_t taghere;        /* pre-shifted tag-enable bit */
  2306. + static of_t tagboth;        /* tagbits|taghere */
  2307. + #define    HASTAG(o)    ((o)&taghere)
  2308. + #define    TAG(o)        ((o)&tagbits)
  2309. + #define    NOTAG(o)    ((o)&~tagboth)
  2310. + #define    CANTAG(o)    (((o)&tagboth) == 0)
  2311. + #define    MKTAG(v)    (((v)<<conf.tagshift)&tagbits)
  2312. + /*
  2313. +  * A new, from-scratch database, not built as a rebuild of an old one,
  2314. +  * needs to know table size, casemap algorithm, and tagging.  Normally
  2315. +  * the user supplies this info, but there have to be defaults.
  2316. +  */
  2317. + #ifndef DEFSIZE
  2318. + #define    DEFSIZE    120011        /* 300007 might be better */
  2319. + #endif
  2320. + #ifdef OLDBNEWS
  2321. + #define    DEFCASE    '0'        /* B2.10 -- no mapping */
  2322. + #define    NOBUFFER        /* B News locking is defective */
  2323. + #endif
  2324. + #ifdef BNEWS
  2325. + #define    DEFCASE    '='        /* B2.11 -- all mapped */
  2326. + #define    NOBUFFER        /* B News locking is defective */
  2327. + #endif
  2328. + #ifndef DEFCASE            /* C News compatibility is the default */
  2329. + #define    DEFCASE    'C'        /* C News -- RFC822 mapping */
  2330. + #endif
  2331. + #ifndef NOTAGS
  2332. + #define    TAGENB    0x80        /* tag enable is top bit, tag is next 7 */
  2333. + #define    TAGMASK    0x7f
  2334. + #define    TAGSHIFT    24
  2335. + #else
  2336. + #define    TAGENB    0        /* no tags */
  2337. + #define    TAGMASK    0
  2338. + #define    TAGSHIFT    0
  2339. + #endif
  2340. + /*
  2341. +  * We read configuration info from the .dir file into this structure,
  2342. +  * so we can avoid wired-in assumptions for an existing database.
  2343. +  *
  2344. +  * Among the info is a record of recent peak usages, so that a new table
  2345. +  * size can be chosen intelligently when rebuilding.  10 is a good
  2346. +  * number of usages to keep, since news displays marked fluctuations
  2347. +  * in volume on a 7-day cycle.
  2348. +  */
  2349. + struct dbzconfig {
  2350. +     int olddbz;        /* .dir file empty but .pag not? */
  2351. +     of_t tsize;        /* table size */
  2352. + #    ifndef NMEMORY
  2353. + #    define    NMEMORY    10    /* # days of use info to remember */
  2354. + #    endif
  2355. + #    define    NUSEDS    (1+NMEMORY)
  2356. +     of_t used[NUSEDS];    /* entries used today, yesterday, ... */
  2357. +     int valuesize;        /* size of table values, == SOF */
  2358. +     int bytemap[SOF];    /* byte-order map */
  2359. +     char casemap;        /* case-mapping algorithm (see cipoint()) */
  2360. +     char fieldsep;        /* field separator in base file, if any */
  2361. +     of_t tagenb;        /* unshifted tag-enable bit */
  2362. +     of_t tagmask;        /* unshifted tag mask */
  2363. +     int tagshift;        /* shift count for tagmask and tagenb */
  2364. + };
  2365. + static struct dbzconfig conf;
  2366. + static int getconf();
  2367. + static long getno();
  2368. + static int putconf();
  2369. + static void mybytemap();
  2370. + static of_t bytemap();
  2371. + /* 
  2372. +  * For a program that makes many, many references to the database, it
  2373. +  * is a large performance win to keep the table in core, if it will fit.
  2374. +  * Note that this does hurt robustness in the event of crashes, and
  2375. +  * dbmclose() *must* be called to flush the in-core database to disk.
  2376. +  * The code is prepared to deal with the possibility that there isn't
  2377. +  * enough memory.  There *is* an assumption that a size_t is big enough
  2378. +  * to hold the size (in bytes) of one table, so dbminit() tries to figure
  2379. +  * out whether this is possible first.
  2380. +  *
  2381. +  * The preferred way to ask for an in-core table is to do dbzincore(1)
  2382. +  * before dbminit().  The default is not to do it, although -DINCORE
  2383. +  * overrides this for backward compatibility with old dbz.
  2384. +  *
  2385. +  * We keep only the first table in core.  This greatly simplifies the
  2386. +  * code, and bounds memory demand.  Furthermore, doing this is a large
  2387. +  * performance win even in the event of massive overflow.
  2388. +  */
  2389. + #ifdef INCORE
  2390. + static int incore = 1;
  2391. + #else
  2392. + static int incore = 0;
  2393. + #endif
  2394. + /*
  2395. +  * Stdio buffer for .pag reads.  Buffering more than about 16 does not help
  2396. +  * significantly at the densities we try to maintain, and the much larger
  2397. +  * buffers that most stdios default to are much more expensive to fill.
  2398. +  * With small buffers, stdio is performance-competitive with raw read(),
  2399. +  * and it's much more portable.
  2400. +  */
  2401. + #ifndef NPAGBUF
  2402. + #define    NPAGBUF    16
  2403. + #endif
  2404. + #ifndef NOBUFFER
  2405. + #ifdef _IOFBF
  2406. + static of_t pagbuf[NPAGBUF];    /* only needed if !NOBUFFER && _IOFBF */
  2407. + #endif
  2408. + #endif
  2409. + /*
  2410. +  * Stdio buffer for base-file reads.  Message-IDs (all news ever needs to
  2411. +  * read) are essentially never longer than 64 bytes, and the typical stdio
  2412. +  * buffer is so much larger that it is much more expensive to fill.
  2413. +  */
  2414. + #ifndef SHISTBUF
  2415. + #define    SHISTBUF    64
  2416. + #endif
  2417. + #ifdef _IOFBF
  2418. + static char basebuf[SHISTBUF];        /* only needed if _IOFBF exists */
  2419. + #endif
  2420. + /*
  2421. +  * Data structure for recording info about searches.
  2422. +  */
  2423. + struct searcher {
  2424. +     of_t place;        /* current location in file */
  2425. +     int tabno;        /* which table we're in */
  2426. +     int run;        /* how long we'll stay in this table */
  2427. + #        ifndef MAXRUN
  2428. + #        define    MAXRUN    100
  2429. + #        endif
  2430. +     long hash;        /* the key's hash code (for optimization) */
  2431. +     of_t tag;        /* tag we are looking for */
  2432. +     int seen;        /* have we examined current location? */
  2433. +     int aborted;        /* has i/o error aborted search? */
  2434. + };
  2435. + static void start();
  2436. + #define    FRESH    ((struct searcher *)NULL)
  2437. + static of_t search();
  2438. + #define    NOTFOUND    ((of_t)-1)
  2439. + static int okayvalue();
  2440. + static int set();
  2441. + /*
  2442. +  * Arguably the searcher struct for a given routine ought to be local to
  2443. +  * it, but a fetch() is very often immediately followed by a store(), and
  2444. +  * in some circumstances it is a useful performance win to remember where
  2445. +  * the fetch() completed.  So we use a global struct and remember whether
  2446. +  * it is current.
  2447. +  */
  2448. + static struct searcher srch;
  2449. + static struct searcher *prevp;    /* &srch or FRESH */
  2450. + /* byte-ordering stuff */
  2451. + static int mybmap[SOF];            /* my byte order (see mybytemap()) */
  2452. + static int bytesame;            /* is database order same as mine? */
  2453. + #define    MAPIN(o)    ((bytesame) ? (o) : bytemap((o), conf.bytemap, mybmap))
  2454. + #define    MAPOUT(o)    ((bytesame) ? (o) : bytemap((o), mybmap, conf.bytemap))
  2455. + /*
  2456. +  * The double parentheses needed to make this work are ugly, but the
  2457. +  * alternative (under most compilers) is to pack around 2K of unused
  2458. +  * strings -- there's just no way to get rid of them.
  2459. +  */
  2460. + static int debug;            /* controlled by dbzdebug() */
  2461. + #ifdef DBZDEBUG
  2462. + #define DEBUG(args) if (debug) { (void) printf args ; }
  2463. + #else
  2464. + #define    DEBUG(args)    ;
  2465. + #endif
  2466. + /* externals used */
  2467. + extern char *malloc();
  2468. + extern char *calloc();
  2469. + extern void free();        /* ANSI C; some old implementations say int */
  2470. + extern int atoi();
  2471. + extern long atol();
  2472. + /* misc. forwards */
  2473. + static long hash();
  2474. + static void crcinit();
  2475. + static char *cipoint();
  2476. + static char *mapcase();
  2477. + static int isprime();
  2478. + static FILE *latebase();
  2479. + /* file-naming stuff */
  2480. + static char dir[] = ".dir";
  2481. + static char pag[] = ".pag";
  2482. + static char *enstring();
  2483. + /* central data structures */
  2484. + static FILE *basef;        /* descriptor for base file */
  2485. + static char *basefname;        /* name for not-yet-opened base file */
  2486. + static FILE *dirf;        /* descriptor for .dir file */
  2487. + static int dirronly;        /* dirf open read-only? */
  2488. + static FILE *pagf = NULL;    /* descriptor for .pag file */
  2489. + static of_t pagpos;        /* posn in pagf; only search may set != -1 */
  2490. + static int pagronly;        /* pagf open read-only? */
  2491. + static of_t *corepag;        /* incore version of .pag file, if any */
  2492. + static FILE *bufpagf;        /* well-buffered pagf, for incore rewrite */
  2493. + static of_t *getcore();
  2494. + static int putcore();
  2495. + static int written;        /* has a store() been done? */
  2496. + /*
  2497. +  - dbzfresh - set up a new database, no historical info
  2498. +  */
  2499. + int                /* 0 success, -1 failure */
  2500. + dbzfresh(name, size, fs, cmap, tagmask)
  2501. + char *name;            /* base name; .dir and .pag must exist */
  2502. + long size;            /* table size (0 means default) */
  2503. + int fs;                /* field-separator character in base file */
  2504. + int cmap;            /* case-map algorithm (0 means default) */
  2505. + of_t tagmask;            /* 0 default, 1 no tags */
  2506. + {
  2507. +     register char *fn;
  2508. +     struct dbzconfig c;
  2509. +     register of_t m;
  2510. +     register FILE *f;
  2511. +     if (pagf != NULL) {
  2512. +         DEBUG(("dbzfresh: database already open\n"));
  2513. +         return(-1);
  2514. +     }
  2515. +     if (size != 0 && size < 2) {
  2516. +         DEBUG(("dbzfresh: preposterous size (%ld)\n", size));
  2517. +         return(-1);
  2518. +     }
  2519. +     /* get default configuration */
  2520. +     if (getconf((FILE *)NULL, (FILE *)NULL, &c) < 0)
  2521. +         return(-1);    /* "can't happen" */
  2522. +     /* and mess with it as specified */
  2523. +     if (size != 0)
  2524. +         c.tsize = size;
  2525. +     c.fieldsep = fs;
  2526. +     switch (cmap) {
  2527. +     case 0:
  2528. +     case '0':
  2529. +     case 'B':        /* 2.10 compat */
  2530. +         c.casemap = '0';    /* '\0' nicer, but '0' printable! */
  2531. +         break;
  2532. +     case '=':
  2533. +     case 'b':        /* 2.11 compat */
  2534. +         c.casemap = '=';
  2535. +         break;
  2536. +     case 'C':
  2537. +         c.casemap = 'C';
  2538. +         break;
  2539. +     case '?':
  2540. +         c.casemap = DEFCASE;
  2541. +         break;
  2542. +     default:
  2543. +         DEBUG(("dbzfresh case map `%c' unknown\n", cmap));
  2544. +         return(-1);
  2545. +         break;
  2546. +     }
  2547. +     switch (tagmask) {
  2548. +     case 0:            /* default */
  2549. +         break;
  2550. +     case 1:            /* no tags */
  2551. +         c.tagshift = 0;
  2552. +         c.tagmask = 0;
  2553. +         c.tagenb = 0;
  2554. +         break;
  2555. +     default:
  2556. +         m = tagmask;
  2557. +         c.tagshift = 0;
  2558. +         while (!(m&01)) {
  2559. +             m >>= 1;
  2560. +             c.tagshift++;
  2561. +         }
  2562. +         c.tagmask = m;
  2563. +         c.tagenb = (m << 1) & ~m;
  2564. +         break;
  2565. +     }
  2566. +     /* write it out */
  2567. +     fn = enstring(name, dir);
  2568. +     if (fn == NULL)
  2569. +         return(-1);
  2570. +     f = fopen(fn, "w");
  2571. +     free(fn);
  2572. +     if (f == NULL) {
  2573. +         DEBUG(("dbzfresh: unable to write config\n"));
  2574. +         return(-1);
  2575. +     }
  2576. +     if (putconf(f, &c) < 0) {
  2577. +         (void) fclose(f);
  2578. +         return(-1);
  2579. +     }
  2580. +     if (fclose(f) == EOF) {
  2581. +         DEBUG(("dbzfresh: fclose failure\n"));
  2582. +         return(-1);
  2583. +     }
  2584. +     /* create/truncate .pag */
  2585. +     fn = enstring(name, pag);
  2586. +     if (fn == NULL)
  2587. +         return(-1);
  2588. +     f = fopen(fn, "w");
  2589. +     free(fn);
  2590. +     if (f == NULL) {
  2591. +         DEBUG(("dbzfresh: unable to create/truncate .pag file\n"));
  2592. +         return(-1);
  2593. +     } else
  2594. +         (void) fclose(f);
  2595. +     /* and punt to dbminit for the hard work */
  2596. +     return(dbminit(name));
  2597. + }
  2598. + /*
  2599. +  - dbzsize - what's a good table size to hold this many entries?
  2600. +  */
  2601. + long
  2602. + dbzsize(contents)
  2603. + long contents;            /* 0 means what's the default */
  2604. + {
  2605. +     register long n;
  2606. +     if (contents <= 0) {    /* foulup or default inquiry */
  2607. +         DEBUG(("dbzsize: preposterous input (%ld)\n", contents));
  2608. +         return(DEFSIZE);
  2609. +     }
  2610. +     n = (contents/2)*3;    /* try to keep table at most 2/3 full */
  2611. +     if (!(n&01))        /* make it odd */
  2612. +         n++;
  2613. +     DEBUG(("dbzsize: tentative size %ld\n", n));
  2614. +     while (!isprime(n))    /* and look for a prime */
  2615. +         n += 2;
  2616. +     DEBUG(("dbzsize: final size %ld\n", n));
  2617. +     return(n);
  2618. + }
  2619. + /*
  2620. +  - isprime - is a number prime?
  2621. +  *
  2622. +  * This is not a terribly efficient approach.
  2623. +  */
  2624. + static int            /* predicate */
  2625. + isprime(x)
  2626. + register long x;
  2627. + {
  2628. +     static int quick[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 0 };
  2629. +     register int *ip;
  2630. +     register long div;
  2631. +     register long stop;
  2632. +     /* hit the first few primes quickly to eliminate easy ones */
  2633. +     /* this incidentally prevents ridiculously small tables */
  2634. +     for (ip = quick; (div = *ip) != 0; ip++)
  2635. +         if (x%div == 0) {
  2636. +             DEBUG(("isprime: quick result on %ld\n", (long)x));
  2637. +             return(0);
  2638. +         }
  2639. +     /* approximate square root of x */
  2640. +     for (stop = x; x/stop < stop; stop >>= 1)
  2641. +         continue;
  2642. +     stop <<= 1;
  2643. +     /* try odd numbers up to stop */
  2644. +     for (div = *--ip; div < stop; div += 2)
  2645. +         if (x%div == 0)
  2646. +             return(0);
  2647. +     return(1);
  2648. + }
  2649. + /*
  2650. +  - dbzagain - set up a new database to be a rebuild of an old one
  2651. +  */
  2652. + int                /* 0 success, -1 failure */
  2653. + dbzagain(name, oldname)
  2654. + char *name;            /* base name; .dir and .pag must exist */
  2655. + char *oldname;            /* base name; all must exist */
  2656. + {
  2657. +     register char *fn;
  2658. +     struct dbzconfig c;
  2659. +     register int i;
  2660. +     register long top;
  2661. +     register FILE *f;
  2662. +     register int newtable;
  2663. +     register of_t newsize;
  2664. +     if (pagf != NULL) {
  2665. +         DEBUG(("dbzagain: database already open\n"));
  2666. +         return(-1);
  2667. +     }
  2668. +     /* pick up the old configuration */
  2669. +     fn = enstring(oldname, dir);
  2670. +     if (fn == NULL)
  2671. +         return(-1);
  2672. +     f = fopen(fn, "r");
  2673. +     free(fn);
  2674. +     if (f == NULL) {
  2675. +         DEBUG(("dbzagain: cannot open old .dir file\n"));
  2676. +         return(-1);
  2677. +     }
  2678. +     i = getconf(f, (FILE *)NULL, &c);
  2679. +     (void) fclose(f);
  2680. +     if (i < 0) {
  2681. +         DEBUG(("dbzagain: getconf failed\n"));
  2682. +         return(-1);
  2683. +     }
  2684. +     /* tinker with it */
  2685. +     top = 0;
  2686. +     newtable = 0;
  2687. +     for (i = 0; i < NUSEDS; i++) {
  2688. +         if (top < c.used[i])
  2689. +             top = c.used[i];
  2690. +         if (c.used[i] == 0)
  2691. +             newtable = 1;    /* hasn't got full usage history yet */
  2692. +     }
  2693. +     if (top == 0) {
  2694. +         DEBUG(("dbzagain: old table has no contents!\n"));
  2695. +         newtable = 1;
  2696. +     }
  2697. +     for (i = NUSEDS-1; i > 0; i--)
  2698. +         c.used[i] = c.used[i-1];
  2699. +     c.used[0] = 0;
  2700. +     newsize = dbzsize(top);
  2701. +     if (!newtable || newsize > c.tsize)    /* don't shrink new table */
  2702. +         c.tsize = newsize;
  2703. +     /* write it out */
  2704. +     fn = enstring(name, dir);
  2705. +     if (fn == NULL)
  2706. +         return(-1);
  2707. +     f = fopen(fn, "w");
  2708. +     free(fn);
  2709. +     if (f == NULL) {
  2710. +         DEBUG(("dbzagain: unable to write new .dir\n"));
  2711. +         return(-1);
  2712. +     }
  2713. +     i = putconf(f, &c);
  2714. +     (void) fclose(f);
  2715. +     if (i < 0) {
  2716. +         DEBUG(("dbzagain: putconf failed\n"));
  2717. +         return(-1);
  2718. +     }
  2719. +     /* create/truncate .pag */
  2720. +     fn = enstring(name, pag);
  2721. +     if (fn == NULL)
  2722. +         return(-1);
  2723. +     f = fopen(fn, "w");
  2724. +     free(fn);
  2725. +     if (f == NULL) {
  2726. +         DEBUG(("dbzagain: unable to create/truncate .pag file\n"));
  2727. +         return(-1);
  2728. +     } else
  2729. +         (void) fclose(f);
  2730. +     /* and let dbminit do the work */
  2731. +     return(dbminit(name));
  2732. + }
  2733. + /*
  2734. +  - dbminit - open a database, creating it (using defaults) if necessary
  2735. +  *
  2736. +  * We try to leave errno set plausibly, to the extent that underlying
  2737. +  * functions permit this, since many people consult it if dbminit() fails.
  2738. +  */
  2739. + int                 /* 0 success, -1 failure */
  2740. + dbminit(name)
  2741. + char *name;
  2742. + {
  2743. +     register int i;
  2744. +     register size_t s;
  2745. +     register char *dirfname;
  2746. +     register char *pagfname;
  2747. +     if (pagf != NULL) {
  2748. +         DEBUG(("dbminit: dbminit already called once\n"));
  2749. +         errno = 0;
  2750. +         return(-1);
  2751. +     }
  2752. +     /* open the .dir file */
  2753. +     dirfname = enstring(name, dir);
  2754. +     if (dirfname == NULL)
  2755. +         return(-1);
  2756. +     dirf = fopen(dirfname, "r+");
  2757. +     if (dirf == NULL) {
  2758. +         dirf = fopen(dirfname, "r");
  2759. +         dirronly = 1;
  2760. +     } else
  2761. +         dirronly = 0;
  2762. +     free(dirfname);
  2763. +     if (dirf == NULL) {
  2764. +         DEBUG(("dbminit: can't open .dir file\n"));
  2765. +         return(-1);
  2766. +     }
  2767. +     /* open the .pag file */
  2768. +     pagfname = enstring(name, pag);
  2769. +     if (pagfname == NULL) {
  2770. +         (void) fclose(dirf);
  2771. +         return(-1);
  2772. +     }
  2773. +     pagf = fopen(pagfname, "r+b");
  2774. +     if (pagf == NULL) {
  2775. +         pagf = fopen(pagfname, "rb");
  2776. +         if (pagf == NULL) {
  2777. +             DEBUG(("dbminit: .pag open failed\n"));
  2778. +             (void) fclose(dirf);
  2779. +             free(pagfname);
  2780. +             return(-1);
  2781. +         }
  2782. +         pagronly = 1;
  2783. +     } else if (dirronly)
  2784. +         pagronly = 1;
  2785. +     else
  2786. +         pagronly = 0;
  2787. + #ifdef NOBUFFER
  2788. +     /*
  2789. +      * B News does not do adequate locking on its database accesses.
  2790. +      * Why it doesn't get into trouble using dbm is a mystery.  In any
  2791. +      * case, doing unbuffered i/o does not cure the problem, but does
  2792. +      * enormously reduce its incidence.
  2793. +      */
  2794. +     (void) setbuf(pagf, (char *)NULL);
  2795. + #else
  2796. + #ifdef _IOFBF
  2797. +     (void) setvbuf(pagf, (char *)pagbuf, _IOFBF, sizeof(pagbuf));
  2798. + #endif
  2799. + #endif
  2800. +     pagpos = -1;
  2801. +     /* don't free pagfname, need it below */
  2802. +     /* open the base file */
  2803. +     basef = fopen(name, "r");
  2804. +     if (basef == NULL) {
  2805. +         DEBUG(("dbminit: basefile open failed\n"));
  2806. +         basefname = enstring(name, "");
  2807. +         if (basefname == NULL) {
  2808. +             (void) fclose(pagf);
  2809. +             (void) fclose(dirf);
  2810. +             free(pagfname);
  2811. +             pagf = NULL;
  2812. +             return(-1);
  2813. +         }
  2814. +     } else
  2815. +         basefname = NULL;
  2816. + #ifdef _IOFBF
  2817. +     if (basef != NULL)
  2818. +         (void) setvbuf(basef, basebuf, _IOFBF, sizeof(basebuf));
  2819. + #endif
  2820. +     /* pick up configuration */
  2821. +     if (getconf(dirf, pagf, &conf) < 0) {
  2822. +         DEBUG(("dbminit: getconf failure\n"));
  2823. +         (void) fclose(basef);
  2824. +         (void) fclose(pagf);
  2825. +         (void) fclose(dirf);
  2826. +         free(pagfname);
  2827. +         pagf = NULL;
  2828. +         errno = EDOM;    /* kind of a kludge, but very portable */
  2829. +         return(-1);
  2830. +     }
  2831. +     tagbits = conf.tagmask << conf.tagshift;
  2832. +     taghere = conf.tagenb << conf.tagshift;
  2833. +     tagboth = tagbits | taghere;
  2834. +     mybytemap(mybmap);
  2835. +     bytesame = 1;
  2836. +     for (i = 0; i < SOF; i++)
  2837. +         if (mybmap[i] != conf.bytemap[i])
  2838. +             bytesame = 0;
  2839. +     /* get first table into core, if it looks desirable and feasible */
  2840. +     s = (size_t)conf.tsize * SOF;
  2841. +     if (incore && (of_t)(s/SOF) == conf.tsize) {
  2842. +         bufpagf = fopen(pagfname, (pagronly) ? "rb" : "r+b");
  2843. +         if (bufpagf != NULL)
  2844. +             corepag = getcore(bufpagf);
  2845. +     } else {
  2846. +         bufpagf = NULL;
  2847. +         corepag = NULL;
  2848. +     }
  2849. +     free(pagfname);
  2850. +     /* misc. setup */
  2851. +     crcinit();
  2852. +     written = 0;
  2853. +     prevp = FRESH;
  2854. +     DEBUG(("dbminit: succeeded\n"));
  2855. +     return(0);
  2856. + }
  2857. + /*
  2858. +  - enstring - concatenate two strings into a malloced area
  2859. +  */
  2860. + static char *            /* NULL if malloc fails */
  2861. + enstring(s1, s2)
  2862. + char *s1;
  2863. + char *s2;
  2864. + {
  2865. +     register char *p;
  2866. +     p = malloc((size_t)strlen(s1) + (size_t)strlen(s2) + 1);
  2867. +     if (p != NULL) {
  2868. +         (void) strcpy(p, s1);
  2869. +         (void) strcat(p, s2);
  2870. +     } else {
  2871. +         DEBUG(("enstring(%s, %s) out of memory\n", s1, s2));
  2872. +     }
  2873. +     return(p);
  2874. + }
  2875. + /*
  2876. +  - dbmclose - close a database
  2877. +  */
  2878. + int
  2879. + dbmclose()
  2880. + {
  2881. +     register int ret = 0;
  2882. +     if (pagf == NULL) {
  2883. +         DEBUG(("dbmclose: not opened!\n"));
  2884. +         return(-1);
  2885. +     }
  2886. +     if (fclose(pagf) == EOF) {
  2887. +         DEBUG(("dbmclose: fclose(pagf) failed\n"));
  2888. +         ret = -1;
  2889. +     }
  2890. +     pagf = basef;        /* ensure valid pointer; dbzsync checks it */
  2891. +     if (dbzsync() < 0)
  2892. +         ret = -1;
  2893. +     if (bufpagf != NULL && fclose(bufpagf) == EOF) {
  2894. +         DEBUG(("dbmclose: fclose(bufpagf) failed\n"));
  2895. +         ret = -1;
  2896. +     }
  2897. +     if (corepag != NULL)
  2898. +         free((char *)corepag);
  2899. +     corepag = NULL;
  2900. +     if (fclose(basef) == EOF) {
  2901. +         DEBUG(("dbmclose: fclose(basef) failed\n"));
  2902. +         ret = -1;
  2903. +     }
  2904. +     if (basefname != NULL)
  2905. +         free(basefname);
  2906. +     basef = NULL;
  2907. +     pagf = NULL;
  2908. +     if (fclose(dirf) == EOF) {
  2909. +         DEBUG(("dbmclose: fclose(dirf) failed\n"));
  2910. +         ret = -1;
  2911. +     }
  2912. +     DEBUG(("dbmclose: %s\n", (ret == 0) ? "succeeded" : "failed"));
  2913. +     return(ret);
  2914. + }
  2915. + /*
  2916. +  - dbzsync - push all in-core data out to disk
  2917. +  */
  2918. + int
  2919. + dbzsync()
  2920. + {
  2921. +     register int ret = 0;
  2922. +     if (pagf == NULL) {
  2923. +         DEBUG(("dbzsync: not opened!\n"));
  2924. +         return(-1);
  2925. +     }
  2926. +     if (!written)
  2927. +         return(0);
  2928. +     if (corepag != NULL) {
  2929. +         if (putcore(corepag, bufpagf) < 0) {
  2930. +             DEBUG(("dbzsync: putcore failed\n"));
  2931. +             ret = -1;
  2932. +         }
  2933. +     }
  2934. +     if (!conf.olddbz)
  2935. +         if (putconf(dirf, &conf) < 0)
  2936. +             ret = -1;
  2937. +     DEBUG(("dbzsync: %s\n", (ret == 0) ? "succeeded" : "failed"));
  2938. +     return(ret);
  2939. + }
  2940. + /*
  2941. +  - dbzcancel - cancel writing of in-core data
  2942. +  * Mostly for use from child processes.
  2943. +  * Note that we don't need to futz around with stdio buffers, because we
  2944. +  * always fflush them immediately anyway and so they never have stale data.
  2945. +  */
  2946. + int
  2947. + dbzcancel()
  2948. + {
  2949. +     if (pagf == NULL) {
  2950. +         DEBUG(("dbzcancel: not opened!\n"));
  2951. +         return(-1);
  2952. +     }
  2953. +     written = 0;
  2954. +     return(0);
  2955. + }
  2956. + /*
  2957. +  - dbzfetch - fetch() with case mapping built in
  2958. +  */
  2959. + datum
  2960. + dbzfetch(key)
  2961. + datum key;
  2962. + {
  2963. +     char buffer[DBZMAXKEY + 1];
  2964. +     datum mappedkey;
  2965. +     register size_t keysize;
  2966. +     DEBUG(("dbzfetch: (%s)\n", key.dptr));
  2967. +     /* Key is supposed to be less than DBZMAXKEY */
  2968. +     keysize = key.dsize;
  2969. +     if (keysize >= DBZMAXKEY) {
  2970. +         keysize = DBZMAXKEY;
  2971. +         DEBUG(("keysize is %d - truncated to %d\n", key.dsize, DBZMAXKEY));
  2972. +     }
  2973. +     mappedkey.dptr = mapcase(buffer, key.dptr, keysize);
  2974. +     buffer[keysize] = '\0';    /* just a debug aid */
  2975. +     mappedkey.dsize = keysize;
  2976. +     return(fetch(mappedkey));
  2977. + }
  2978. + /*
  2979. +  - fetch - get an entry from the database
  2980. +  *
  2981. +  * Disgusting fine point, in the name of backward compatibility:  if the
  2982. +  * last character of "key" is a NUL, that character is (effectively) not
  2983. +  * part of the comparison against the stored keys.
  2984. +  */
  2985. + datum                /* dptr NULL, dsize 0 means failure */
  2986. + fetch(key)
  2987. + datum key;
  2988. + {
  2989. +     char buffer[DBZMAXKEY + 1];
  2990. +     static of_t key_ptr;        /* return value points here */
  2991. +     datum output;
  2992. +     register size_t keysize;
  2993. +     register size_t cmplen;
  2994. +     register char *sepp;
  2995. +     DEBUG(("fetch: (%s)\n", key.dptr));
  2996. +     output.dptr = NULL;
  2997. +     output.dsize = 0;
  2998. +     prevp = FRESH;
  2999. +     /* Key is supposed to be less than DBZMAXKEY */
  3000. +     keysize = key.dsize;
  3001. +     if (keysize >= DBZMAXKEY) {
  3002. +         keysize = DBZMAXKEY;
  3003. +         DEBUG(("keysize is %d - truncated to %d\n", key.dsize, DBZMAXKEY));
  3004. +     }
  3005. +     if (pagf == NULL) {
  3006. +         DEBUG(("fetch: database not open!\n"));
  3007. +         return(output);
  3008. +     } else if (basef == NULL) {    /* basef didn't exist yet */
  3009. +         basef = latebase();
  3010. +         if (basef == NULL)
  3011. +             return(output);
  3012. +     }
  3013. +     cmplen = keysize;
  3014. +     sepp = &conf.fieldsep;
  3015. +     if (key.dptr[keysize-1] == '\0') {
  3016. +         cmplen--;
  3017. +         sepp = &buffer[keysize-1];
  3018. +     }
  3019. +     start(&srch, &key, FRESH);
  3020. +     while ((key_ptr = search(&srch)) != NOTFOUND) {
  3021. +         DEBUG(("got 0x%lx\n", key_ptr));
  3022. +         /* fetch the key */
  3023. +         if (fseek(basef, key_ptr, SEEK_SET) != 0) {
  3024. +             DEBUG(("fetch: seek failed\n"));
  3025. +             return(output);
  3026. +         }
  3027. +         if (fread(buffer, 1, keysize, basef) != keysize) {
  3028. +             DEBUG(("fetch: read failed\n"));
  3029. +             return(output);
  3030. +         }
  3031. +         /* try it */
  3032. +         buffer[keysize] = '\0';        /* terminated for DEBUG */
  3033. +         (void) mapcase(buffer, buffer, keysize);
  3034. +         DEBUG(("fetch: buffer (%s) looking for (%s) size = %d\n", 
  3035. +                         buffer, key.dptr, keysize));
  3036. +         if (memcmp(key.dptr, buffer, cmplen) == 0 &&
  3037. +                 (*sepp == conf.fieldsep || *sepp == '\0')) {
  3038. +             /* we found it */
  3039. +             output.dptr = (char *)&key_ptr;
  3040. +             output.dsize = SOF;
  3041. +             DEBUG(("fetch: successful\n"));
  3042. +             return(output);
  3043. +         }
  3044. +     }
  3045. +     /* we didn't find it */
  3046. +     DEBUG(("fetch: failed\n"));
  3047. +     prevp = &srch;            /* remember where we stopped */
  3048. +     return(output);
  3049. + }
  3050. + /*
  3051. +  - latebase - try to open a base file that wasn't there at the start
  3052. +  */
  3053. + static FILE *
  3054. + latebase()
  3055. + {
  3056. +     register FILE *it;
  3057. +     if (basefname == NULL) {
  3058. +         DEBUG(("latebase: name foulup\n"));
  3059. +         return(NULL);
  3060. +     }
  3061. +     it = fopen(basefname, "r");
  3062. +     if (it == NULL) {
  3063. +         DEBUG(("latebase: still can't open base\n"));
  3064. +     } else {
  3065. +         DEBUG(("latebase: late open succeeded\n"));
  3066. +         free(basefname);
  3067. +         basefname = NULL;
  3068. + #ifdef _IOFBF
  3069. +         (void) setvbuf(it, basebuf, _IOFBF, sizeof(basebuf));
  3070. + #endif
  3071. +     }
  3072. +     return(it);
  3073. + }
  3074. + /*
  3075. +  - dbzstore - store() with case mapping built in
  3076. +  */
  3077. + int
  3078. + dbzstore(key, data)
  3079. + datum key;
  3080. + datum data;
  3081. + {
  3082. +     char buffer[DBZMAXKEY + 1];
  3083. +     datum mappedkey;
  3084. +     register size_t keysize;
  3085. +     DEBUG(("dbzstore: (%s)\n", key.dptr));
  3086. +     /* Key is supposed to be less than DBZMAXKEY */
  3087. +     keysize = key.dsize;
  3088. +     if (keysize >= DBZMAXKEY) {
  3089. +         DEBUG(("dbzstore: key size too big (%d)\n", key.dsize));
  3090. +         return(-1);
  3091. +     }
  3092. +     mappedkey.dptr = mapcase(buffer, key.dptr, keysize);
  3093. +     buffer[keysize] = '\0';    /* just a debug aid */
  3094. +     mappedkey.dsize = keysize;
  3095. +     return(store(mappedkey, data));
  3096. + }
  3097. + /*
  3098. +  - store - add an entry to the database
  3099. +  */
  3100. + int                /* 0 success, -1 failure */
  3101. + store(key, data)
  3102. + datum key;
  3103. + datum data;
  3104. + {
  3105. +     of_t value;
  3106. +     if (pagf == NULL) {
  3107. +         DEBUG(("store: database not open!\n"));
  3108. +         return(-1);
  3109. +     } else if (basef == NULL) {    /* basef didn't exist yet */
  3110. +         basef = latebase();
  3111. +         if (basef == NULL)
  3112. +             return(-1);
  3113. +     }
  3114. +     if (pagronly) {
  3115. +         DEBUG(("store: database open read-only\n"));
  3116. +         return(-1);
  3117. +     }
  3118. +     if (data.dsize != SOF) {
  3119. +         DEBUG(("store: value size wrong (%d)\n", data.dsize));
  3120. +         return(-1);
  3121. +     }
  3122. +     if (key.dsize >= DBZMAXKEY) {
  3123. +         DEBUG(("store: key size too big (%d)\n", key.dsize));
  3124. +         return(-1);
  3125. +     }
  3126. +     /* copy the value in to ensure alignment */
  3127. +     (void) memcpy((char *)&value, data.dptr, SOF);
  3128. +     DEBUG(("store: (%s, %ld)\n", key.dptr, (long)value));
  3129. +     if (!okayvalue(value)) {
  3130. +         DEBUG(("store: reserved bit or overflow in 0x%lx\n", value));
  3131. +         return(-1);
  3132. +     }
  3133. +     /* find the place, exploiting previous search if possible */
  3134. +     start(&srch, &key, prevp);
  3135. +     while (search(&srch) != NOTFOUND)
  3136. +         continue;
  3137. +     prevp = FRESH;
  3138. +     conf.used[0]++;
  3139. +     DEBUG(("store: used count %ld\n", conf.used[0]));
  3140. +     written = 1;
  3141. +     return(set(&srch, value));
  3142. + }
  3143. + /*
  3144. +  - dbzincore - control attempts to keep .pag file in core
  3145. +  */
  3146. + int                /* old setting */
  3147. + dbzincore(value)
  3148. + int value;
  3149. + {
  3150. +     register int old = incore;
  3151. +     incore = value;
  3152. +     return(old);
  3153. + }
  3154. + /*
  3155. +  - getconf - get configuration from .dir file
  3156. +  */
  3157. + static int            /* 0 success, -1 failure */
  3158. + getconf(df, pf, cp)
  3159. + register FILE *df;        /* NULL means just give me the default */
  3160. + register FILE *pf;        /* NULL means don't care about .pag */
  3161. + register struct dbzconfig *cp;
  3162. + {
  3163. +     register int c;
  3164. +     register int i;
  3165. +     int err = 0;
  3166. +     c = (df != NULL) ? getc(df) : EOF;
  3167. +     if (c == EOF) {        /* empty file, no configuration known */
  3168. +         cp->olddbz = 0;
  3169. +         if (df != NULL && pf != NULL && getc(pf) != EOF)
  3170. +             cp->olddbz = 1;
  3171. +         cp->tsize = DEFSIZE;
  3172. +         cp->fieldsep = '\t';
  3173. +         for (i = 0; i < NUSEDS; i++)
  3174. +             cp->used[i] = 0;
  3175. +         cp->valuesize = SOF;
  3176. +         mybytemap(cp->bytemap);
  3177. +         cp->casemap = DEFCASE;
  3178. +         cp->tagenb = TAGENB;
  3179. +         cp->tagmask = TAGMASK;
  3180. +         cp->tagshift = TAGSHIFT;
  3181. +         DEBUG(("getconf: defaults (%ld, %c, (0x%lx/0x%lx<<%d))\n",
  3182. +             cp->tsize, cp->casemap, cp->tagenb, 
  3183. +             cp->tagmask, cp->tagshift));
  3184. +         return(0);
  3185. +     }
  3186. +     (void) ungetc(c, df);
  3187. +     /* first line, the vital stuff */
  3188. +     if (getc(df) != 'd' || getc(df) != 'b' || getc(df) != 'z')
  3189. +         err = -1;
  3190. +     if (getno(df, &err) != dbzversion)
  3191. +         err = -1;
  3192. +     cp->tsize = getno(df, &err);
  3193. +     cp->fieldsep = getno(df, &err);
  3194. +     while ((c = getc(df)) == ' ')
  3195. +         continue;
  3196. +     cp->casemap = c;
  3197. +     cp->tagenb = getno(df, &err);
  3198. +     cp->tagmask = getno(df, &err);
  3199. +     cp->tagshift = getno(df, &err);
  3200. +     cp->valuesize = getno(df, &err);
  3201. +     if (cp->valuesize != SOF) {
  3202. +         DEBUG(("getconf: wrong of_t size (%d)\n", cp->valuesize));
  3203. +         err = -1;
  3204. +         cp->valuesize = SOF;    /* to protect the loops below */
  3205. +     }
  3206. +     for (i = 0; i < cp->valuesize; i++)
  3207. +         cp->bytemap[i] = getno(df, &err);
  3208. +     if (getc(df) != '\n')
  3209. +         err = -1;
  3210. +     DEBUG(("size %ld, sep %d, cmap %c, tags 0x%lx/0x%lx<<%d, ", cp->tsize,
  3211. +             cp->fieldsep, cp->casemap, cp->tagenb, cp->tagmask,
  3212. +             cp->tagshift));
  3213. +     DEBUG(("bytemap (%d)", cp->valuesize));
  3214. +     for (i = 0; i < cp->valuesize; i++) {
  3215. +         DEBUG((" %d", cp->bytemap[i]));
  3216. +     }
  3217. +     DEBUG(("\n"));
  3218. +     /* second line, the usages */
  3219. +     for (i = 0; i < NUSEDS; i++)
  3220. +         cp->used[i] = getno(df, &err);
  3221. +     if (getc(df) != '\n')
  3222. +         err = -1;
  3223. +     DEBUG(("used %ld %ld %ld...\n", cp->used[0], cp->used[1], cp->used[2]));
  3224. +     if (err < 0) {
  3225. +         DEBUG(("getconf error\n"));
  3226. +         return(-1);
  3227. +     }
  3228. +     return(0);
  3229. + }
  3230. + /*
  3231. +  - getno - get a long
  3232. +  */
  3233. + static long
  3234. + getno(f, ep)
  3235. + FILE *f;
  3236. + int *ep;
  3237. + {
  3238. +     register char *p;
  3239. + #    define    MAXN    50
  3240. +     char getbuf[MAXN];
  3241. +     register int c;
  3242. +     while ((c = getc(f)) == ' ')
  3243. +         continue;
  3244. +     if (c == EOF || c == '\n') {
  3245. +         DEBUG(("getno: missing number\n"));
  3246. +         *ep = -1;
  3247. +         return(0);
  3248. +     }
  3249. +     p = getbuf;
  3250. +     *p++ = c;
  3251. +     while ((c = getc(f)) != EOF && c != '\n' && c != ' ')
  3252. +         if (p < &getbuf[MAXN-1])
  3253. +             *p++ = c;
  3254. +     if (c == EOF) {
  3255. +         DEBUG(("getno: EOF\n"));
  3256. +         *ep = -1;
  3257. +     } else
  3258. +         (void) ungetc(c, f);
  3259. +     *p = '\0';
  3260. +     if (strspn(getbuf, "-1234567890") != strlen(getbuf)) {
  3261. +         DEBUG(("getno: `%s' non-numeric\n", getbuf));
  3262. +         *ep = -1;
  3263. +     }
  3264. +     return(atol(getbuf));
  3265. + }
  3266. + /*
  3267. +  - putconf - write configuration to .dir file
  3268. +  */
  3269. + static int            /* 0 success, -1 failure */
  3270. + putconf(f, cp)
  3271. + register FILE *f;
  3272. + register struct dbzconfig *cp;
  3273. + {
  3274. +     register int i;
  3275. +     register int ret = 0;
  3276. +     if (fseek(f, (of_t)0, SEEK_SET) != 0) {
  3277. +         DEBUG(("fseek failure in putconf\n"));
  3278. +         ret = -1;
  3279. +     }
  3280. +     fprintf(f, "dbz %d %ld %d %c %ld %ld %d %d", dbzversion, cp->tsize,
  3281. +                 cp->fieldsep, cp->casemap, cp->tagenb,
  3282. +                 cp->tagmask, cp->tagshift, cp->valuesize);
  3283. +     for (i = 0; i < cp->valuesize; i++)
  3284. +         fprintf(f, " %d", cp->bytemap[i]);
  3285. +     fprintf(f, "\n");
  3286. +     for (i = 0; i < NUSEDS; i++)
  3287. +         fprintf(f, "%ld%c", cp->used[i], (i < NUSEDS-1) ? ' ' : '\n');
  3288. +     (void) fflush(f);
  3289. +     if (ferror(f))
  3290. +         ret = -1;
  3291. +     DEBUG(("putconf status %d\n", ret));
  3292. +     return(ret);
  3293. + }
  3294. + /*
  3295. +  - getcore - try to set up an in-core copy of .pag file
  3296. +  */
  3297. + static of_t *            /* pointer to copy, or NULL */
  3298. + getcore(f)
  3299. + FILE *f;
  3300. + {
  3301. +     register of_t *p;
  3302. +     register size_t i;
  3303. +     register size_t nread;
  3304. +     register char *it;
  3305. +     it = malloc((size_t)conf.tsize * SOF);
  3306. +     if (it == NULL) {
  3307. +         DEBUG(("getcore: malloc failed\n"));
  3308. +         return(NULL);
  3309. +     }
  3310. +     nread = fread(it, SOF, (size_t)conf.tsize, f);
  3311. +     if (ferror(f)) {
  3312. +         DEBUG(("getcore: read failed\n"));
  3313. +         free(it);
  3314. +         return(NULL);
  3315. +     }
  3316. +     p = (of_t *)it + nread;
  3317. +     i = (size_t)conf.tsize - nread;
  3318. +     while (i-- > 0)
  3319. +         *p++ = VACANT;
  3320. +     return((of_t *)it);
  3321. + }
  3322. + /*
  3323. +  - putcore - try to rewrite an in-core table
  3324. +  */
  3325. + static int            /* 0 okay, -1 fail */
  3326. + putcore(tab, f)
  3327. + of_t *tab;
  3328. + FILE *f;
  3329. + {
  3330. +     if (fseek(f, (of_t)0, SEEK_SET) != 0) {
  3331. +         DEBUG(("fseek failure in putcore\n"));
  3332. +         return(-1);
  3333. +     }
  3334. +     (void) fwrite((char *)tab, SOF, (size_t)conf.tsize, f);
  3335. +     (void) fflush(f);
  3336. +     return((ferror(f)) ? -1 : 0);
  3337. + }
  3338. + /*
  3339. +  - start - set up to start or restart a search
  3340. +  */
  3341. + static void
  3342. + start(sp, kp, osp)
  3343. + register struct searcher *sp;
  3344. + register datum *kp;
  3345. + register struct searcher *osp;        /* may be FRESH, i.e. NULL */
  3346. + {
  3347. +     register long h;
  3348. +     h = hash(kp->dptr, kp->dsize);
  3349. +     if (osp != FRESH && osp->hash == h) {
  3350. +         if (sp != osp)
  3351. +             *sp = *osp;
  3352. +         DEBUG(("search restarted\n"));
  3353. +     } else {
  3354. +         sp->hash = h;
  3355. +         sp->tag = MKTAG(h / conf.tsize);
  3356. +         DEBUG(("tag 0x%lx\n", sp->tag));
  3357. +         sp->place = h % conf.tsize;
  3358. +         sp->tabno = 0;
  3359. +         sp->run = (conf.olddbz) ? conf.tsize : MAXRUN;
  3360. +         sp->aborted = 0;
  3361. +     }
  3362. +     sp->seen = 0;
  3363. + }
  3364. + /*
  3365. +  - search - conduct part of a search
  3366. +  */
  3367. + static of_t            /* NOTFOUND if we hit VACANT or error */
  3368. + search(sp)
  3369. + register struct searcher *sp;
  3370. + {
  3371. +     register of_t dest;
  3372. +     register of_t value;
  3373. +     of_t val;        /* buffer for value (can't fread register) */
  3374. +     register of_t place;
  3375. +     if (sp->aborted)
  3376. +         return(NOTFOUND);
  3377. +     for (;;) {
  3378. +         /* determine location to be examined */
  3379. +         place = sp->place;
  3380. +         if (sp->seen) {
  3381. +             /* go to next location */
  3382. +             if (--sp->run <= 0) {
  3383. +                 sp->tabno++;
  3384. +                 sp->run = MAXRUN;
  3385. +             }
  3386. +             place = (place+1)%conf.tsize + sp->tabno*conf.tsize;
  3387. +             sp->place = place;
  3388. +         } else
  3389. +             sp->seen = 1;    /* now looking at current location */
  3390. +         DEBUG(("search @ %ld\n", place));
  3391. +         /* get the tagged value */
  3392. +         if (corepag != NULL && place < conf.tsize) {
  3393. +             DEBUG(("search: in core\n"));
  3394. +             value = MAPIN(corepag[place]);
  3395. +         } else {
  3396. +             /* seek, if necessary */
  3397. +             dest = place * SOF;
  3398. +             if (pagpos != dest) {
  3399. +                 if (fseek(pagf, dest, SEEK_SET) != 0) {
  3400. +                     DEBUG(("search: seek failed\n"));
  3401. +                     pagpos = -1;
  3402. +                     sp->aborted = 1;
  3403. +                     return(NOTFOUND);
  3404. +                 }
  3405. +                 pagpos = dest;
  3406. +             }
  3407. +             /* read it */
  3408. +             if (fread((char *)&val, sizeof(val), 1, pagf) == 1)
  3409. +                 value = MAPIN(val);
  3410. +             else if (ferror(pagf)) {
  3411. +                 DEBUG(("search: read failed\n"));
  3412. +                 pagpos = -1;
  3413. +                 sp->aborted = 1;
  3414. +                 return(NOTFOUND);
  3415. +             } else
  3416. +                 value = VACANT;
  3417. +             /* and finish up */
  3418. +             pagpos += sizeof(val);
  3419. +         }
  3420. +         /* vacant slot is always cause to return */
  3421. +         if (value == VACANT) {
  3422. +             DEBUG(("search: empty slot\n"));
  3423. +             return(NOTFOUND);
  3424. +         };
  3425. +         /* check the tag */
  3426. +         value = UNBIAS(value);
  3427. +         DEBUG(("got 0x%lx\n", value));
  3428. +         if (!HASTAG(value)) {
  3429. +             DEBUG(("tagless\n"));
  3430. +             return(value);
  3431. +         } else if (TAG(value) == sp->tag) {
  3432. +             DEBUG(("match\n"));
  3433. +             return(NOTAG(value));
  3434. +         } else {
  3435. +             DEBUG(("mismatch 0x%lx\n", TAG(value)));
  3436. +         }
  3437. +     }
  3438. +     /* NOTREACHED */
  3439. + }
  3440. + /*
  3441. +  - okayvalue - check that a value can be stored
  3442. +  */
  3443. + static int            /* predicate */
  3444. + okayvalue(value)
  3445. + of_t value;
  3446. + {
  3447. +     if (HASTAG(value))
  3448. +         return(0);
  3449. + #ifdef OVERFLOW
  3450. +     if (value == LONG_MAX)    /* BIAS() and UNBIAS() will overflow */
  3451. +         return(0);
  3452. + #endif
  3453. +     return(1);
  3454. + }
  3455. + /*
  3456. +  - set - store a value into a location previously found by search
  3457. +  */
  3458. + static int            /* 0 success, -1 failure */
  3459. + set(sp, value)
  3460. + register struct searcher *sp;
  3461. + of_t value;
  3462. + {
  3463. +     register of_t place = sp->place;
  3464. +     register of_t v = value;
  3465. +     if (sp->aborted)
  3466. +         return(-1);
  3467. +     if (CANTAG(v) && !conf.olddbz) {
  3468. +         v |= sp->tag | taghere;
  3469. +         if (v != UNBIAS(VACANT))    /* BIAS(v) won't look VACANT */
  3470. + #ifdef OVERFLOW
  3471. +             if (v != LONG_MAX)    /* and it won't overflow */
  3472. + #endif
  3473. +             value = v;
  3474. +     }
  3475. +     DEBUG(("tagged value is 0x%lx\n", value));
  3476. +     value = BIAS(value);
  3477. +     value = MAPOUT(value);
  3478. +     /* If we have the index file in memory, use it */
  3479. +     if (corepag != NULL && place < conf.tsize) {
  3480. +         corepag[place] = value;
  3481. +         DEBUG(("set: incore\n"));
  3482. +         return(0);
  3483. +     }
  3484. +     /* seek to spot */
  3485. +     pagpos = -1;        /* invalidate position memory */
  3486. +     if (fseek(pagf, place * SOF, SEEK_SET) != 0) {
  3487. +         DEBUG(("set: seek failed\n"));
  3488. +         sp->aborted = 1;
  3489. +         return(-1);
  3490. +     }
  3491. +     /* write in data */
  3492. +     if (fwrite((char *)&value, SOF, 1, pagf) != 1) {
  3493. +         DEBUG(("set: write failed\n"));
  3494. +         sp->aborted = 1;
  3495. +         return(-1);
  3496. +     }
  3497. +     /* fflush improves robustness, and buffer re-use is rare anyway */
  3498. +     if (fflush(pagf) == EOF) {
  3499. +         DEBUG(("set: fflush failed\n"));
  3500. +         sp->aborted = 1;
  3501. +         return(-1);
  3502. +     }
  3503. +     DEBUG(("set: succeeded\n"));
  3504. +     return(0);
  3505. + }
  3506. + /*
  3507. +  - mybytemap - determine this machine's byte map
  3508. +  *
  3509. +  * A byte map is an array of ints, sizeof(of_t) of them.  The 0th int
  3510. +  * is the byte number of the high-order byte in my of_t, and so forth.
  3511. +  */
  3512. + static void
  3513. + mybytemap(map)
  3514. + int map[];            /* -> int[SOF] */
  3515. + {
  3516. +     union {
  3517. +         of_t o;
  3518. +         char c[SOF];
  3519. +     } u;
  3520. +     register int *mp = &map[SOF];
  3521. +     register int ntodo;
  3522. +     register int i;
  3523. +     u.o = 1;
  3524. +     for (ntodo = (int)SOF; ntodo > 0; ntodo--) {
  3525. +         for (i = 0; i < SOF; i++)
  3526. +             if (u.c[i] != 0)
  3527. +                 break;
  3528. +         if (i == SOF) {
  3529. +             /* trouble -- set it to *something* consistent */
  3530. +             DEBUG(("mybytemap: nonexistent byte %d!!!\n", ntodo));
  3531. +             for (i = 0; i < SOF; i++)
  3532. +                 map[i] = i;
  3533. +             return;
  3534. +         }
  3535. +         DEBUG(("mybytemap: byte %d\n", i));
  3536. +         *--mp = i;
  3537. +         while (u.c[i] != 0)
  3538. +             u.o <<= 1;
  3539. +     }
  3540. + }
  3541. + /*
  3542. +  - bytemap - transform an of_t from byte ordering map1 to map2
  3543. +  */
  3544. + static of_t            /* transformed result */
  3545. + bytemap(ino, map1, map2)
  3546. + of_t ino;
  3547. + int *map1;
  3548. + int *map2;
  3549. + {
  3550. +     union oc {
  3551. +         of_t o;
  3552. +         char c[SOF];
  3553. +     };
  3554. +     union oc in;
  3555. +     union oc out;
  3556. +     register int i;
  3557. +     in.o = ino;
  3558. +     for (i = 0; i < SOF; i++)
  3559. +         out.c[map2[i]] = in.c[map1[i]];
  3560. +     return(out.o);
  3561. + }
  3562. + /*
  3563. +  * This is a simplified version of the pathalias hashing function.
  3564. +  * Thanks to Steve Belovin and Peter Honeyman
  3565. +  *
  3566. +  * hash a string into a long int.  31 bit crc (from andrew appel).
  3567. +  * the crc table is computed at run time by crcinit() -- we could
  3568. +  * precompute, but it takes 1 clock tick on a 750.
  3569. +  *
  3570. +  * This fast table calculation works only if POLY is a prime polynomial
  3571. +  * in the field of integers modulo 2.  Since the coefficients of a
  3572. +  * 32-bit polynomial won't fit in a 32-bit word, the high-order bit is
  3573. +  * implicit.  IT MUST ALSO BE THE CASE that the coefficients of orders
  3574. +  * 31 down to 25 are zero.  Happily, we have candidates, from
  3575. +  * E. J.  Watson, "Primitive Polynomials (Mod 2)", Math. Comp. 16 (1962):
  3576. +  *    x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + x^0
  3577. +  *    x^31 + x^3 + x^0
  3578. +  *
  3579. +  * We reverse the bits to get:
  3580. +  *    111101010000000000000000000000001 but drop the last 1
  3581. +  *         f   5   0   0   0   0   0   0
  3582. +  *    010010000000000000000000000000001 ditto, for 31-bit crc
  3583. +  *       4   8   0   0   0   0   0   0
  3584. +  */
  3585. + #define POLY 0x48000000L    /* 31-bit polynomial (avoids sign problems) */
  3586. + static long CrcTable[128];
  3587. + /*
  3588. +  - crcinit - initialize tables for hash function
  3589. +  */
  3590. + static void
  3591. + crcinit()
  3592. + {
  3593. +     register int i, j;
  3594. +     register long sum;
  3595. +     for (i = 0; i < 128; ++i) {
  3596. +         sum = 0L;
  3597. +         for (j = 7 - 1; j >= 0; --j)
  3598. +             if (i & (1 << j))
  3599. +                 sum ^= POLY >> j;
  3600. +         CrcTable[i] = sum;
  3601. +     }
  3602. +     DEBUG(("crcinit: done\n"));
  3603. + }
  3604. + /*
  3605. +  - hash - Honeyman's nice hashing function
  3606. +  */
  3607. + static long
  3608. + hash(name, size)
  3609. + register char *name;
  3610. + register int size;
  3611. + {
  3612. +     register long sum = 0L;
  3613. +     while (size--) {
  3614. +         sum = (sum >> 7) ^ CrcTable[(sum ^ (*name++)) & 0x7f];
  3615. +     }
  3616. +     DEBUG(("hash: returns (%ld)\n", sum));
  3617. +     return(sum);
  3618. + }
  3619. + /*
  3620. +  * case-mapping stuff
  3621. +  *
  3622. +  * Borrowed from C News, by permission of the authors.  Somewhat modified.
  3623. +  *
  3624. +  * We exploit the fact that we are dealing only with headers here, and
  3625. +  * headers are limited to the ASCII characters by RFC822.  It is barely
  3626. +  * possible that we might be dealing with a translation into another
  3627. +  * character set, but in particular it's very unlikely for a header
  3628. +  * character to be outside -128..255.
  3629. +  *
  3630. +  * Life would be a whole lot simpler if tolower() could safely and portably
  3631. +  * be applied to any char.
  3632. +  */
  3633. + #define    OFFSET    128        /* avoid trouble with negative chars */
  3634. + /* must call casencmp before invoking TOLOW... */
  3635. + #define    TOLOW(c)    (cmap[(c)+OFFSET])
  3636. + /* ...but the use of it in CISTREQN is safe without the preliminary call (!) */
  3637. + /* CISTREQN is an optimised case-insensitive strncmp(a,b,n)==0; n > 0 */
  3638. + #define CISTREQN(a, b, n) \
  3639. +     (TOLOW((a)[0]) == TOLOW((b)[0]) && casencmp(a, b, n) == 0)
  3640. + #define    MAPSIZE    (256+OFFSET)
  3641. + static char cmap[MAPSIZE];    /* relies on init to '\0' */
  3642. + static int mprimed = 0;        /* has cmap been set up? */
  3643. + /*
  3644. +  - mapprime - set up case-mapping stuff
  3645. +  */
  3646. + static void
  3647. + mapprime()
  3648. + {
  3649. +     register char *lp;
  3650. +     register char *up;
  3651. +     register int c;
  3652. +     register int i;
  3653. +     static char lower[] = "abcdefghijklmnopqrstuvwxyz";
  3654. +     static char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  3655. +     for (lp = lower, up = upper; *lp != '\0'; lp++, up++) {
  3656. +         c = *lp;
  3657. +         cmap[c+OFFSET] = c;
  3658. +         cmap[*up+OFFSET] = c;
  3659. +     }
  3660. +     for (i = 0; i < MAPSIZE; i++)
  3661. +         if (cmap[i] == '\0')
  3662. +             cmap[i] = (char)(i-OFFSET);
  3663. +     mprimed = 1;
  3664. + }
  3665. + /*
  3666. +  - casencmp - case-independent strncmp
  3667. +  */
  3668. + static int            /* < == > 0 */
  3669. + casencmp(s1, s2, len)
  3670. + char *s1;
  3671. + char *s2;
  3672. + int len;
  3673. + {
  3674. +     register char *p1;
  3675. +     register char *p2;
  3676. +     register int n;
  3677. +     if (!mprimed)
  3678. +         mapprime();
  3679. +     p1 = s1;
  3680. +     p2 = s2;
  3681. +     n = len;
  3682. +     while (--n >= 0 && *p1 != '\0' && TOLOW(*p1) == TOLOW(*p2)) {
  3683. +         p1++;
  3684. +         p2++;
  3685. +     }
  3686. +     if (n < 0)
  3687. +         return(0);
  3688. +     /*
  3689. +      * The following case analysis is necessary so that characters
  3690. +      * which look negative collate low against normal characters but
  3691. +      * high against the end-of-string NUL.
  3692. +      */
  3693. +     if (*p1 == '\0' && *p2 == '\0')
  3694. +         return(0);
  3695. +     else if (*p1 == '\0')
  3696. +         return(-1);
  3697. +     else if (*p2 == '\0')
  3698. +         return(1);
  3699. +     else
  3700. +         return(TOLOW(*p1) - TOLOW(*p2));
  3701. + }
  3702. + /*
  3703. +  - mapcase - do case-mapped copy
  3704. +  */
  3705. + static char *            /* returns src or dst */
  3706. + mapcase(dst, src, siz)
  3707. + char *dst;            /* destination, used only if mapping needed */
  3708. + char *src;            /* source; src == dst is legal */
  3709. + size_t siz;
  3710. + {
  3711. +     register char *s;
  3712. +     register char *d;
  3713. +     register char *c;    /* case break */
  3714. +     register char *e;    /* end of source */
  3715. +     c = cipoint(src, siz);
  3716. +     if (c == NULL)
  3717. +         return(src);
  3718. +     if (!mprimed)
  3719. +         mapprime();
  3720. +     s = src;
  3721. +     e = s + siz;
  3722. +     d = dst;
  3723. +     while (s < c)
  3724. +         *d++ = *s++;
  3725. +     while (s < e)
  3726. +         *d++ = TOLOW(*s++);
  3727. +     return(dst);
  3728. + }
  3729. + /*
  3730. +  - cipoint - where in this message-ID does it become case-insensitive?
  3731. +  *
  3732. +  * The RFC822 code is not quite complete.  Absolute, total, full RFC822
  3733. +  * compliance requires a horrible parsing job, because of the arcane
  3734. +  * quoting conventions -- abc"def"ghi is not equivalent to abc"DEF"ghi,
  3735. +  * for example.  There are three or four things that might occur in the
  3736. +  * domain part of a message-id that are case-sensitive.  They don't seem
  3737. +  * to ever occur in real news, thank Cthulhu.  (What?  You were expecting
  3738. +  * a merciful and forgiving deity to be invoked in connection with RFC822?
  3739. +  * Forget it; none of them would come near it.)
  3740. +  */
  3741. + static char *            /* pointer into s, or NULL for "nowhere" */
  3742. + cipoint(s, siz)
  3743. + char *s;
  3744. + size_t siz;
  3745. + {
  3746. +     register char *p;
  3747. +     static char post[] = "postmaster";
  3748. +     static int plen = sizeof(post)-1;
  3749. +     switch (conf.casemap) {
  3750. +     case '0':        /* unmapped, sensible */
  3751. +         return(NULL);
  3752. +         break;
  3753. +     case 'C':        /* C News, RFC 822 conformant (approx.) */
  3754. +         p = memchr(s, '@', siz);
  3755. +         if (p == NULL)            /* no local/domain split */
  3756. +             return(NULL);        /* assume all local */
  3757. +         else if    (p - (s+1) == plen && CISTREQN(s+1, post, plen)) {
  3758. +             /* crazy -- "postmaster" is case-insensitive */
  3759. +             return(s);
  3760. +         } else
  3761. +             return(p);
  3762. +         break;
  3763. +     case '=':        /* 2.11, neither sensible nor conformant */
  3764. +         return(s);    /* all case-insensitive */
  3765. +         break;
  3766. +     }
  3767. +     DEBUG(("cipoint: unknown case mapping `%c'\n", conf.casemap));
  3768. +     return(NULL);        /* just leave it alone */
  3769. + }
  3770. + /*
  3771. +  - dbzdebug - control dbz debugging at run time
  3772. +  */
  3773. + int                /* old value */
  3774. + dbzdebug(value)
  3775. + int value;
  3776. + {
  3777. + #ifdef DBZDEBUG
  3778. +     register int old = debug;
  3779. +     debug = value;
  3780. +     return(old);
  3781. + #else
  3782. +     return(-1);
  3783. + #endif
  3784. + }
  3785. diff -rc2N /free/libg++-2.5.3/libio/dbz/rdbzmain.c /sources/libg++-2.5.3-amiga/libio/dbz/rdbzmain.c
  3786. *** /free/libg++-2.5.3/libio/dbz/rdbzmain.c    Mon Dec 27 21:41:04 1993
  3787. --- /sources/libg++-2.5.3-amiga/libio/dbz/rdbzmain.c    Mon Dec 13 22:57:36 1993
  3788. ***************
  3789. *** 0 ****
  3790. --- 1,518 ----
  3791. + /*
  3792. +  * dbz - use and test dbz in various ways
  3793. +  *
  3794. +  * -Log-
  3795. +  */
  3796. + #include <stdio.h>
  3797. + #include <sys/types.h>
  3798. + #include <sys/stat.h>
  3799. + #include <string.h>
  3800. + #include <dbz.h>
  3801. + #ifdef FUNNYSEEKS
  3802. + #include <unistd.h>
  3803. + #else
  3804. + #define    SEEK_SET    0
  3805. + #endif
  3806. + #define    STREQ(a, b)    (*(a) == *(b) && strcmp((a), (b)) == 0)
  3807. + #ifndef lint
  3808. + static char RCSid[] = "$Header: /rel/cvsfiles/devo/libio/dbz/dbzmain.c,v 1.2 1993/10/25 20:02:41 bothner Exp $";
  3809. + #endif
  3810. + char *progname;
  3811. + char *inname = "(no file)";        /* filename for messages etc. */
  3812. + long lineno;                /* line number for messages etc. */
  3813. + char *basename;
  3814. + char *pagname;
  3815. + char *dirname;
  3816. + char *str2dup();
  3817. + FILE *base;
  3818. + int op = 'b';            /* what to do, default build a new table */
  3819. + int baseinput = 1;        /* is the base file also the input? */
  3820. + char *from = NULL;        /* old table to use for dbzagain() */
  3821. + int omitzero = 0;        /* omit lines tagged with 0 */
  3822. + long every = 0;            /* report every n lines */
  3823. + int syncs = 0;            /* dbzsync() on each report */
  3824. + int quick = 0;            /* quick checking, not too thorough */
  3825. + int sweep = 0;            /* sweep file checking all offsets */
  3826. + int useincore = 1;        /* should we use incore facility? */
  3827. + long xxx = 0;            /* debugging variable */
  3828. + int printx = 0;            /* print xxx after all is done */
  3829. + int unique = 1;            /* before store(), check with fetch() */
  3830. + int usefresh = 0;        /* use dbzfresh? */
  3831. + long siz = 0;            /* -p size */
  3832. + char map = 'C';            /* -p map */
  3833. + long tag = 0;            /* -p tag mask */
  3834. + int exact = 0;            /* do not run dbzsize(siz) */
  3835. + int dbzint = 1;            /* use new interface? */
  3836. + char fs = '\t';            /* field separator, default tab */
  3837. + int unopen = 0;            /* make base unopenable during dbminit? */
  3838. + char *change = NULL;        /* chdir here before dbmclose */
  3839. + #define    DEFBUF    1024        /* default line-buffer size */
  3840. + int buflen = DEFBUF;        /* line length limit */
  3841. + char lbuf[DEFBUF];
  3842. + char *line = lbuf;
  3843. + char cbuf[DEFBUF];
  3844. + char *cmp = cbuf;
  3845. + void fail();
  3846. + void dofile();
  3847. + void runs();
  3848. + void dosweep();
  3849. + void mkfiles();
  3850. + void crfile();
  3851. + void doline();
  3852. + void process();
  3853. + #ifdef HAVERFCIZE
  3854. + extern char *rfc822ize();
  3855. + #else
  3856. + #define    rfc822ize(n)    (n)
  3857. + #endif
  3858. + extern char *malloc();
  3859. + /*
  3860. +  - main - parse arguments and handle options
  3861. +  */
  3862. + main(argc, argv)
  3863. + int argc;
  3864. + char *argv[];
  3865. + {
  3866. +     int c;
  3867. +     int errflg = 0;
  3868. +     extern int optind;
  3869. +     extern char *optarg;
  3870. +     int doruns = 0;
  3871. +     extern long atol();
  3872. +     progname = argv[0];
  3873. +     while ((c = getopt(argc, argv, "axcmt:l:R0E:SqOiX:Yuf:p:eMUC:d")) != EOF)
  3874. +         switch (c) {
  3875. +         case 'a':    /* append to existing table */
  3876. +             if (op != 'b')
  3877. +                 fail("only one of -a -x -c -m can be given", "");
  3878. +             op = 'a';
  3879. +             baseinput = 0;
  3880. +             break;
  3881. +         case 'x':    /* extract from existing table */
  3882. +             if (op != 'b')
  3883. +                 fail("only one of -a -x -c -m can be given", "");
  3884. +             op = 'x';
  3885. +             baseinput = 0;
  3886. +             break;
  3887. +         case 'c':    /* check existing table */
  3888. +             if (op != 'b')
  3889. +                 fail("only one of -a -x -c -m can be given", "");
  3890. +             op = 'c';
  3891. +             break;
  3892. +         case 'm':    /* extract missing (complement of -x) */
  3893. +             if (op != 'b')
  3894. +                 fail("only one of -a -x -c -m can be given", "");
  3895. +             op = 'm';
  3896. +             baseinput = 0;
  3897. +             break;
  3898. +         case 't':    /* set field separator */
  3899. +             if (strlen(optarg) > 1)
  3900. +                 fail("only one field separator allowed", "");
  3901. +             fs = *optarg;
  3902. +             break;
  3903. +         case 'l':    /* override line-length limit */
  3904. +             buflen = atoi(optarg) + 1;
  3905. +             if (buflen <= 2)
  3906. +                 fail("bad -l value `%s'", optarg);
  3907. +             line = malloc(buflen);
  3908. +             cmp = malloc(buflen);
  3909. +             if (line == NULL || cmp == NULL)
  3910. +                 fail("cannot allocate %s-byte buffers", optarg);
  3911. +             break;
  3912. +         case 'R':    /* print run statistics */
  3913. +             doruns = 1;
  3914. +             break;
  3915. +         case '0':    /* omit lines tagged (by fake -t) with 0 */
  3916. +             omitzero = 1;
  3917. +             break;
  3918. +         case 'E':    /* report every n items */
  3919. +             every = atol(optarg);
  3920. +             break;
  3921. +         case 'S':    /* dbzsync() on each -E report */
  3922. +             syncs = 1;
  3923. +             break;
  3924. +         case 'q':    /* quick check or extract */
  3925. +             quick = 1;
  3926. +             break;
  3927. +         case 'O':    /* sweep file checking all offsets */
  3928. +             sweep = 1;
  3929. +             break;
  3930. +         case 'i':    /* don't use incore */
  3931. +             useincore = 0;
  3932. +             break;
  3933. +         case 'X':    /* set xxx */
  3934. +             xxx = atoi(optarg);
  3935. +             break;
  3936. +         case 'Y':    /* print xxx afterward */
  3937. +             printx = 1;
  3938. +             break;
  3939. +         case 'u':    /* don't check uniqueness */
  3940. +             unique = 0;
  3941. +             break;
  3942. +         case 'f':    /* init from existing table's parameters */
  3943. +             from = optarg;
  3944. +             break;
  3945. +         case 'p':    /* parameters for dbzfresh */
  3946. +             if (sscanf(optarg, "%ld %1s %lx", &siz, &map, &tag) != 3) {
  3947. +                 map = '?';
  3948. +                 tag = 0;
  3949. +                 if (sscanf(optarg, "%ld", &siz) != 1)
  3950. +                     fail("bad -n value `%s'", optarg);
  3951. +             }
  3952. +             usefresh = 1;
  3953. +             break;
  3954. +         case 'e':    /* -p size is exact, don't dbzsize() it */
  3955. +             exact = 1;
  3956. +             break;
  3957. +         case 'M':    /* use old dbm interface + rfc822ize */
  3958. +             dbzint = 0;
  3959. +             break;
  3960. +         case 'U':    /* make base unopenable during init */
  3961. +             unopen = 1;
  3962. +             break;
  3963. +         case 'C':    /* change directories before dbmclose */
  3964. +             change = optarg;
  3965. +             break;
  3966. +         case 'd':    /* Debugging. */
  3967. +             if (dbzdebug(1) < 0)
  3968. +                 fail("dbz debugging not available", "");
  3969. +             break;
  3970. +         case '?':
  3971. +         default:
  3972. +             errflg++;
  3973. +             break;
  3974. +         }
  3975. +     if (errflg || optind >= argc || (optind+1 < argc && baseinput)) {
  3976. +         fprintf(stderr, "usage: %s ", progname);
  3977. +         fprintf(stderr, "[-a] [-x] [-c] database [file] ...\n");
  3978. +         exit(2);
  3979. +     }
  3980. +     (void) dbzincore(useincore);
  3981. +     basename = argv[optind];
  3982. +     pagname = str2dup(basename, ".pag");
  3983. +     dirname = str2dup(basename, ".dir");
  3984. +     mkfiles();
  3985. +     optind++;
  3986. +     if (baseinput)        /* implies no further arguments */
  3987. +         process(base, basename);
  3988. +     else if (optind >= argc)
  3989. +         process(stdin, "stdin");
  3990. +     else
  3991. +         for (; optind < argc; optind++)
  3992. +             dofile(argv[optind]);
  3993. +     if (change != NULL)
  3994. +         (void) chdir(change);
  3995. +     if (dbmclose() < 0)
  3996. +         fail("dbmclose failed", "");
  3997. +     if (doruns)
  3998. +         runs(pagname);
  3999. +     if (sweep)
  4000. +         dosweep(basename, pagname);
  4001. +     if (printx)
  4002. +         printf("%ld\n", xxx);
  4003. + #ifdef DBZ_FINISH
  4004. +     DBZ_FINISH;
  4005. + #endif
  4006. +     exit(0);
  4007. + }
  4008. + /*
  4009. +  - dofile - open a file and invoke process()
  4010. +  */
  4011. + void
  4012. + dofile(name)
  4013. + char *name;
  4014. + {
  4015. +     register FILE *in;
  4016. +     if (STREQ(name, "-"))
  4017. +         process(stdin, "-");
  4018. +     else {
  4019. +         in = fopen(name, "r");
  4020. +         if (in == NULL)
  4021. +             fail("cannot open `%s'", name);
  4022. +         process(in, name);
  4023. +         (void) fclose(in);
  4024. +     }
  4025. + }
  4026. + /*
  4027. +  - mkfiles - create empty files and open them up
  4028. +  */
  4029. + void
  4030. + mkfiles()
  4031. + {
  4032. +     if (op == 'b' && !dbzint) {
  4033. +         crfile(dirname);
  4034. +         crfile(pagname);
  4035. +     }
  4036. +     base = fopen(basename, (op == 'a') ? "a" : "r");
  4037. +     if (base == NULL)
  4038. +         fail("cannot open `%s'", basename);
  4039. +     if (unopen)
  4040. +         (void) chmod(basename, 0);
  4041. +     if (from != NULL) {
  4042. +         if (dbzagain(basename, from) < 0)
  4043. +             fail("dbzagain(`%s'...) failed", basename);
  4044. +     } else if (op == 'b' && dbzint) {
  4045. +         if (!exact)
  4046. +             siz = dbzsize(siz);
  4047. +         if (dbzfresh(basename, siz, (int)fs, map, tag) < 0)
  4048. +             fail("dbzfresh(`%s'...) failed", basename);
  4049. +     } else if (dbminit(basename) < 0)
  4050. +         fail("dbminit(`%s') failed", basename);
  4051. +     if (unopen)
  4052. +         (void) chmod(basename, 0600);    /* hard to restore original */
  4053. + }
  4054. + /*
  4055. +  - crfile - create a file
  4056. +  */
  4057. + void
  4058. + crfile(name)
  4059. + char *name;
  4060. + {
  4061. +     register int f;
  4062. +     f = creat(name, 0666);
  4063. +     if (f < 0)
  4064. +         fail("cannot create `%s'", name);
  4065. +     (void) close(f);
  4066. + }
  4067. + /*
  4068. +  - process - process input file
  4069. +  */
  4070. + void
  4071. + process(in, name)
  4072. + FILE *in;
  4073. + char *name;
  4074. + {
  4075. +     register off_t place;
  4076. +     inname = name;
  4077. +     lineno = 0;
  4078. +     for (;;) {
  4079. +         place = ftell(in);
  4080. +         if (fgets(line, buflen, in) == NULL)
  4081. +             return;
  4082. +         lineno++;
  4083. +         if (every > 0 && lineno%every == 0) {
  4084. +             fprintf(stderr, "%ld\n", lineno);
  4085. +             if (dbzsync() < 0)
  4086. +                 fail("dbzsync failed", "");
  4087. +         }
  4088. +         doline(line, place);
  4089. +     }
  4090. +     /* NOTREACHED */
  4091. + }
  4092. + /*
  4093. +  - doline - process input line
  4094. +  */
  4095. + void
  4096. + doline(lp, inoffset)
  4097. + char *lp;
  4098. + off_t inoffset;
  4099. + {
  4100. +     register char *p;
  4101. +     register char pc;
  4102. +     datum key, value;
  4103. +     off_t place = inoffset;
  4104. +     register int shouldfind;
  4105. +     register int llen;
  4106. +     char keytext[DBZMAXKEY+1];
  4107. +     p = NULL;
  4108. +     if (fs != '\0')
  4109. +         p = strchr(lp, fs);
  4110. +     if (p == NULL)
  4111. +         p = lp + strlen(lp);
  4112. +     if (p > lp && *(p-1) == '\n')
  4113. +         p--;
  4114. +     if (p - lp > DBZMAXKEY)
  4115. +         fail("key of `%.40s...' too long", lp);
  4116. +     pc = *p;
  4117. +     *p = '\0';
  4118. +     (void) strcpy(keytext, lp);
  4119. +     *p = pc;
  4120. +     key.dptr = (dbzint) ? keytext : rfc822ize(keytext);
  4121. +     key.dsize = strlen(keytext)+1;
  4122. +     switch (op) {
  4123. +     case 'a':
  4124. +         place = ftell(base);
  4125. +         llen = strlen(lp);
  4126. +         if (fwrite(lp, 1, llen, base) != llen)
  4127. +             fail("write error in `%s'", basename);
  4128. +         /* FALLTHROUGH */
  4129. +     case 'b':
  4130. +         if (omitzero && p != NULL && *(p+1) == '0')
  4131. +             return;
  4132. +         if (unique) {
  4133. +             value = (dbzint) ? dbzfetch(key) : fetch(key);
  4134. +             if (value.dptr != NULL)
  4135. +                 fail("`%.40s...' already present", lp);
  4136. +         }
  4137. +         value.dptr = (char *)&place;
  4138. +         value.dsize = (int)sizeof(off_t);
  4139. +         if (((dbzint) ? dbzstore(key, value) : store(key, value)) < 0)
  4140. +             fail("store failed on `%.40s...'", lp);
  4141. +         break;
  4142. +     case 'c':
  4143. +         value = (dbzint) ? dbzfetch(key) : fetch(key);
  4144. +         shouldfind = (omitzero && p != NULL && *(p+1) == '0') ? 0 : 1;
  4145. +         if (!shouldfind && (value.dptr != NULL || value.dsize != 0))
  4146. +             fail("`%.40s...' found, shouldn't be", lp);
  4147. +         if (shouldfind && (value.dptr == NULL ||
  4148. +                     value.dsize != sizeof(off_t)))
  4149. +             fail("can't find `%.40s...'", lp);
  4150. +         if (shouldfind && !quick) {
  4151. +             (void) memcpy((char *)&place, value.dptr, sizeof(off_t));
  4152. +             if (place != inoffset)
  4153. +                 fail("offset mismatch on `%.40s...'", lp);
  4154. +             if (fseek(base, place, SEEK_SET) == -1)
  4155. +                 fail("fseek failed on `%.40s...'", lp);
  4156. +             if (fgets(cmp, buflen, base) == NULL)
  4157. +                 fail("can't read line for `%.40s...'", lp);
  4158. +             if (!STREQ(lp, cmp))
  4159. +                 fail("compare failed on `%.40s...'", lp);
  4160. +         }
  4161. +         break;
  4162. +     case 'x':
  4163. +         value = (dbzint) ? dbzfetch(key) : fetch(key);
  4164. +         if (value.dptr != NULL && !quick) {
  4165. +             (void) memcpy((char *)&place, value.dptr, sizeof(off_t));
  4166. +             if (fseek(base, place, SEEK_SET) == -1)
  4167. +                 fail("fseek failed on `%.40s...'", lp);
  4168. +             if (fgets(cmp, buflen, base) == NULL)
  4169. +                 fail("can't read line for `%.40s...'", lp);
  4170. +             fputs(cmp, stdout);
  4171. +         } else if (value.dptr != NULL)
  4172. +             fputs(lp, stdout);
  4173. +         break;
  4174. +     case 'm':
  4175. +         value = (dbzint) ? dbzfetch(key) : fetch(key);
  4176. +         if (value.dptr == NULL) {
  4177. +             fputs(keytext, stdout);
  4178. +             putchar('\n');
  4179. +         }
  4180. +         break;
  4181. +     default:
  4182. +         fail("unknown operator -- can't happen", "");
  4183. +         break;
  4184. +     }
  4185. + }
  4186. + /*
  4187. +  - runs - print run statistics
  4188. +  */
  4189. + void
  4190. + runs(file)
  4191. + char *file;
  4192. + {
  4193. +     register FILE *fd;
  4194. +     off_t it;
  4195. +     register long run;
  4196. +     fd = fopen(file, "r");
  4197. +     if (fd == NULL)
  4198. +         fail("cannot reopen `%s'", file);
  4199. +     run = 0;
  4200. +     while (fread((char *)&it, sizeof(off_t), 1, fd) == 1) {
  4201. +         if (it != 0)
  4202. +             run++;
  4203. +         else if (run > 0) {
  4204. +             printf("%ld\n", run);
  4205. +             run = 0;
  4206. +         }
  4207. +     }
  4208. +     (void) fclose(fd);
  4209. + }
  4210. + /*
  4211. +  - dosweep - sweep pag file checking for valid offsets
  4212. +  */
  4213. + void
  4214. + dosweep(fn, pn)
  4215. + char *fn;
  4216. + char *pn;
  4217. + {
  4218. +     register FILE *pf;
  4219. +     off_t it;
  4220. +     char nl;
  4221. +     register FILE *hf;
  4222. +     hf = fopen(fn, "r");
  4223. +     if (hf == NULL)
  4224. +         fail("cannot reopen `%s'", fn);
  4225. +     pf = fopen(pn, "r");
  4226. +     if (pf == NULL)
  4227. +         fail("cannot reopen `%s'", pn);
  4228. +     while (fread((char *)&it, sizeof(off_t), 1, pf) == 1) {
  4229. +         it = (it & ((off_t)0x80000000)) ? (it&~((off_t)0xff000000)) : it;
  4230. +         if (it != 0 && it != 1) {    /* 0 empty, 1 known okay */
  4231. +             it--;        /* get rid of bias */
  4232. +             (void) fseek(hf, it-1, SEEK_SET);
  4233. +             nl = getc(hf);
  4234. +             if (nl != '\n')
  4235. +                 fprintf(stderr, "offset 0%lo does not point to line\n",
  4236. +                                 (long)it);
  4237. +         }
  4238. +     }
  4239. +     (void) fclose(hf);
  4240. +     (void) fclose(pf);
  4241. + }
  4242. + /*
  4243. +  - fail - complain and die
  4244. +  */
  4245. + void
  4246. + fail(s1, s2)
  4247. + char *s1;
  4248. + char *s2;
  4249. + {
  4250. +     fprintf(stderr, "%s: (file `%s', line %ld) ", progname, inname, lineno);
  4251. +     fprintf(stderr, s1, s2);
  4252. +     fprintf(stderr, "\n");
  4253. +     exit(1);
  4254. + }
  4255. + /*
  4256. +  - str2dup - concatenate strings and malloc result
  4257. +  */
  4258. + char *
  4259. + str2dup(s1, s2)
  4260. + char *s1;
  4261. + char *s2;
  4262. + {
  4263. +     register char *p;
  4264. +     p = malloc((size_t)strlen(s1) + strlen(s2) + 1);
  4265. +     if (p == NULL)
  4266. +         fail("can't allocate space for strings", "");
  4267. +     (void) strcpy(p, s1);
  4268. +     (void) strcat(p, s2);
  4269. +     return(p);
  4270. + }
  4271.