From fd6dc51d1afd8bbb1e58baabdc169621b5d088c6 Mon Sep 17 00:00:00 2001
From: cvs2git
Date: Fri, 13 Nov 2009 16:28:58 +0000
Subject: This commit was manufactured by cvs2svn to create branch
'rtems-addon- packages-4-10-branch'.
Sprout from ncurses-gnu 2002-12-19 15:34:54 UTC Eric Norum 'Latest ncurses add-on'
Cherrypick from addons 2002-06-28 21:58:41 UTC Eric Norum 'Useful add-on libraries':
README
RTEMS_Makefiles/Makefile.avl
RTEMS_Makefiles/Makefile.common
RTEMS_Makefiles/Makefile.site
avl-1.4.0/AUTHORS
avl-1.4.0/COPYING
avl-1.4.0/ChangeLog
avl-1.4.0/INSTALL
avl-1.4.0/Makefile.am
avl-1.4.0/Makefile.in
avl-1.4.0/NEWS
avl-1.4.0/README
avl-1.4.0/THANKS
avl-1.4.0/TODO
avl-1.4.0/aclocal.m4
avl-1.4.0/avl.c
avl-1.4.0/avl.h
avl-1.4.0/avl.html
avl-1.4.0/avl.info
avl-1.4.0/avl.texinfo
avl-1.4.0/avl.text
avl-1.4.0/avlt.c
avl-1.4.0/avlt.h
avl-1.4.0/avltr.c
avl-1.4.0/avltr.h
avl-1.4.0/configure
avl-1.4.0/configure.in
avl-1.4.0/install-sh
avl-1.4.0/missing
avl-1.4.0/mkinstalldirs
avl-1.4.0/rb.c
avl-1.4.0/rb.h
avl-1.4.0/texinfo.tex
avl-1.4.0/thread-test.c
examples/avl/BuildTests.sh
examples/avl/README
examples/avl/init.c
examples/ncurses/BuildTests.sh
examples/ncurses/README
examples/ncurses/init.c
examples/readline/.gdbinit
examples/readline/init.c
examples/readline/rlgeneric.c
ncurses-5.2/ANNOUNCE
ncurses-5.2/Ada95/Makefile.in
ncurses-5.2/Ada95/README
ncurses-5.2/Ada95/TODO
ncurses-5.2/Ada95/gen/Makefile.in
ncurses-5.2/Ada95/gen/gen.c
ncurses-5.2/Ada95/gen/html.m4
ncurses-5.2/Ada95/gen/normal.m4
ncurses-5.2/Ada95/gen/table.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-aux.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-field_types.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-field_user_data.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-form_user_data.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-forms.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-menus-item_user_data.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-menus-menu_user_data.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-menus.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-mouse.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-panels-user_data.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses-panels.ads.m4
ncurses-5.2/Ada95/gen/terminal_interface-curses.ads.m4
ncurses-5.2/Ada95/samples/Makefile.in
ncurses-5.2/Ada95/samples/README
ncurses-5.2/Ada95/samples/explain.txt
ncurses-5.2/Ada95/samples/rain.adb
ncurses-5.2/Ada95/samples/rain.ads
ncurses-5.2/Ada95/samples/sample-curses_demo-attributes.adb
ncurses-5.2/Ada95/samples/sample-curses_demo-attributes.ads
ncurses-5.2/Ada95/samples/sample-curses_demo-mouse.adb
ncurses-5.2/Ada95/samples/sample-curses_demo-mouse.ads
ncurses-5.2/Ada95/samples/sample-curses_demo.adb
ncurses-5.2/Ada95/samples/sample-curses_demo.ads
ncurses-5.2/Ada95/samples/sample-explanation.adb
ncurses-5.2/Ada95/samples/sample-explanation.ads
ncurses-5.2/Ada95/samples/sample-form_demo-aux.adb
ncurses-5.2/Ada95/samples/sample-form_demo-aux.ads
ncurses-5.2/Ada95/samples/sample-form_demo-handler.adb
ncurses-5.2/Ada95/samples/sample-form_demo-handler.ads
ncurses-5.2/Ada95/samples/sample-form_demo.adb
ncurses-5.2/Ada95/samples/sample-form_demo.ads
ncurses-5.2/Ada95/samples/sample-function_key_setting.adb
ncurses-5.2/Ada95/samples/sample-function_key_setting.ads
ncurses-5.2/Ada95/samples/sample-header_handler.adb
ncurses-5.2/Ada95/samples/sample-header_handler.ads
ncurses-5.2/Ada95/samples/sample-helpers.adb
ncurses-5.2/Ada95/samples/sample-helpers.ads
ncurses-5.2/Ada95/samples/sample-keyboard_handler.adb
ncurses-5.2/Ada95/samples/sample-keyboard_handler.ads
ncurses-5.2/Ada95/samples/sample-manifest.ads
ncurses-5.2/Ada95/samples/sample-menu_demo-aux.adb
ncurses-5.2/Ada95/samples/sample-menu_demo-aux.ads
ncurses-5.2/Ada95/samples/sample-menu_demo-handler.adb
ncurses-5.2/Ada95/samples/sample-menu_demo-handler.ads
ncurses-5.2/Ada95/samples/sample-menu_demo.adb
ncurses-5.2/Ada95/samples/sample-menu_demo.ads
ncurses-5.2/Ada95/samples/sample-my_field_type.adb
ncurses-5.2/Ada95/samples/sample-my_field_type.ads
ncurses-5.2/Ada95/samples/sample-text_io_demo.adb
ncurses-5.2/Ada95/samples/sample-text_io_demo.ads
ncurses-5.2/Ada95/samples/sample.adb
ncurses-5.2/Ada95/samples/sample.ads
ncurses-5.2/Ada95/samples/status.adb
ncurses-5.2/Ada95/samples/status.ads
ncurses-5.2/Ada95/samples/tour.adb
ncurses-5.2/Ada95/samples/tour.ads
ncurses-5.2/Ada95/src/Makefile.in
ncurses-5.2/Ada95/src/terminal_interface-curses-aux.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alpha.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alpha.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-intfield.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-intfield.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-numeric.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-numeric.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-regexp.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-regexp.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_user_data.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms-form_user_data.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-forms.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-menus-item_user_data.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-menus-menu_user_data.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-menus.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-mouse.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-panels-user_data.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-panels.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-aux.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-aux.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-complex_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-complex_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-decimal_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-decimal_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-enumeration_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-enumeration_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-fixed_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-fixed_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-float_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-float_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-integer_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-integer_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-modular_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-modular_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io.adb
ncurses-5.2/Ada95/src/terminal_interface-curses-text_io.ads
ncurses-5.2/Ada95/src/terminal_interface-curses.adb
ncurses-5.2/Ada95/src/terminal_interface.ads
ncurses-5.2/INSTALL
ncurses-5.2/MANIFEST
ncurses-5.2/Makefile.glibc
ncurses-5.2/Makefile.in
ncurses-5.2/Makefile.os2
ncurses-5.2/NEWS
ncurses-5.2/README
ncurses-5.2/README.emx
ncurses-5.2/README.glibc
ncurses-5.2/TO-DO
ncurses-5.2/aclocal.m4
ncurses-5.2/announce.html.in
ncurses-5.2/c++/Makefile.in
ncurses-5.2/c++/NEWS
ncurses-5.2/c++/PROBLEMS
ncurses-5.2/c++/README-first
ncurses-5.2/c++/cursesapp.cc
ncurses-5.2/c++/cursesapp.h
ncurses-5.2/c++/cursesf.cc
ncurses-5.2/c++/cursesf.h
ncurses-5.2/c++/cursesm.cc
ncurses-5.2/c++/cursesm.h
ncurses-5.2/c++/cursesmain.cc
ncurses-5.2/c++/cursesp.cc
ncurses-5.2/c++/cursesp.h
ncurses-5.2/c++/cursespad.cc
ncurses-5.2/c++/cursesw.cc
ncurses-5.2/c++/cursesw.h
ncurses-5.2/c++/cursslk.cc
ncurses-5.2/c++/cursslk.h
ncurses-5.2/c++/demo.cc
ncurses-5.2/c++/edit_cfg.sh
ncurses-5.2/c++/etip.h.in
ncurses-5.2/c++/headers
ncurses-5.2/c++/internal.h
ncurses-5.2/c++/modules
ncurses-5.2/config.guess
ncurses-5.2/config.sub
ncurses-5.2/configure
ncurses-5.2/configure.in
ncurses-5.2/convert_configure.pl
ncurses-5.2/dist.mk
ncurses-5.2/doc/hackguide.doc
ncurses-5.2/doc/html/Ada95.html
ncurses-5.2/doc/html/ada/files.htm
ncurses-5.2/doc/html/ada/files/T.htm
ncurses-5.2/doc/html/ada/funcs.htm
ncurses-5.2/doc/html/ada/funcs/A.htm
ncurses-5.2/doc/html/ada/funcs/B.htm
ncurses-5.2/doc/html/ada/funcs/C.htm
ncurses-5.2/doc/html/ada/funcs/D.htm
ncurses-5.2/doc/html/ada/funcs/E.htm
ncurses-5.2/doc/html/ada/funcs/F.htm
ncurses-5.2/doc/html/ada/funcs/G.htm
ncurses-5.2/doc/html/ada/funcs/H.htm
ncurses-5.2/doc/html/ada/funcs/I.htm
ncurses-5.2/doc/html/ada/funcs/K.htm
ncurses-5.2/doc/html/ada/funcs/L.htm
ncurses-5.2/doc/html/ada/funcs/M.htm
ncurses-5.2/doc/html/ada/funcs/N.htm
ncurses-5.2/doc/html/ada/funcs/O.htm
ncurses-5.2/doc/html/ada/funcs/P.htm
ncurses-5.2/doc/html/ada/funcs/Q.htm
ncurses-5.2/doc/html/ada/funcs/R.htm
ncurses-5.2/doc/html/ada/funcs/S.htm
ncurses-5.2/doc/html/ada/funcs/T.htm
ncurses-5.2/doc/html/ada/funcs/U.htm
ncurses-5.2/doc/html/ada/funcs/V.htm
ncurses-5.2/doc/html/ada/funcs/W.htm
ncurses-5.2/doc/html/ada/index.htm
ncurses-5.2/doc/html/ada/main.htm
ncurses-5.2/doc/html/ada/table.html
ncurses-5.2/doc/html/ada/terminal_interface-curses-aux__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-aux__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alpha__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alpha__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alphanumeric__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration-ada__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-intfield__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-intfield__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-ipv4_address__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-numeric__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-numeric__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-regexp__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-regexp__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user-choice__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_user_data__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_user_data__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-form_user_data__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-form_user_data__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-forms__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-item_user_data__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-item_user_data__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-menu_user_data__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-menu_user_data__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-menus__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-mouse__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-mouse__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-panels-user_data__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-panels-user_data__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-panels__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-panels__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-aux__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-aux__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-complex_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-complex_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-decimal_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-decimal_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-enumeration_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-enumeration_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-fixed_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-fixed_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-float_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-float_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-integer_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-integer_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-modular_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-modular_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses__adb.htm
ncurses-5.2/doc/html/ada/terminal_interface-curses__ads.htm
ncurses-5.2/doc/html/ada/terminal_interface__ads.htm
ncurses-5.2/doc/html/announce.html
ncurses-5.2/doc/html/hackguide.html
ncurses-5.2/doc/html/index.html
ncurses-5.2/doc/html/man/captoinfo.1m.html
ncurses-5.2/doc/html/man/clear.1.html
ncurses-5.2/doc/html/man/curs_addch.3x.html
ncurses-5.2/doc/html/man/curs_addchstr.3x.html
ncurses-5.2/doc/html/man/curs_addstr.3x.html
ncurses-5.2/doc/html/man/curs_attr.3x.html
ncurses-5.2/doc/html/man/curs_beep.3x.html
ncurses-5.2/doc/html/man/curs_bkgd.3x.html
ncurses-5.2/doc/html/man/curs_border.3x.html
ncurses-5.2/doc/html/man/curs_clear.3x.html
ncurses-5.2/doc/html/man/curs_color.3x.html
ncurses-5.2/doc/html/man/curs_delch.3x.html
ncurses-5.2/doc/html/man/curs_deleteln.3x.html
ncurses-5.2/doc/html/man/curs_extend.3x.html
ncurses-5.2/doc/html/man/curs_getch.3x.html
ncurses-5.2/doc/html/man/curs_getstr.3x.html
ncurses-5.2/doc/html/man/curs_getyx.3x.html
ncurses-5.2/doc/html/man/curs_inch.3x.html
ncurses-5.2/doc/html/man/curs_inchstr.3x.html
ncurses-5.2/doc/html/man/curs_initscr.3x.html
ncurses-5.2/doc/html/man/curs_inopts.3x.html
ncurses-5.2/doc/html/man/curs_insch.3x.html
ncurses-5.2/doc/html/man/curs_insstr.3x.html
ncurses-5.2/doc/html/man/curs_instr.3x.html
ncurses-5.2/doc/html/man/curs_kernel.3x.html
ncurses-5.2/doc/html/man/curs_mouse.3x.html
ncurses-5.2/doc/html/man/curs_move.3x.html
ncurses-5.2/doc/html/man/curs_outopts.3x.html
ncurses-5.2/doc/html/man/curs_overlay.3x.html
ncurses-5.2/doc/html/man/curs_pad.3x.html
ncurses-5.2/doc/html/man/curs_print.3x.html
ncurses-5.2/doc/html/man/curs_printw.3x.html
ncurses-5.2/doc/html/man/curs_refresh.3x.html
ncurses-5.2/doc/html/man/curs_scanw.3x.html
ncurses-5.2/doc/html/man/curs_scr_dump.3x.html
ncurses-5.2/doc/html/man/curs_scroll.3x.html
ncurses-5.2/doc/html/man/curs_slk.3x.html
ncurses-5.2/doc/html/man/curs_termattrs.3x.html
ncurses-5.2/doc/html/man/curs_termcap.3x.html
ncurses-5.2/doc/html/man/curs_terminfo.3x.html
ncurses-5.2/doc/html/man/curs_touch.3x.html
ncurses-5.2/doc/html/man/curs_trace.3x.html
ncurses-5.2/doc/html/man/curs_util.3x.html
ncurses-5.2/doc/html/man/curs_window.3x.html
ncurses-5.2/doc/html/man/default_colors.3x.html
ncurses-5.2/doc/html/man/define_key.3x.html
ncurses-5.2/doc/html/man/form.3x.html
ncurses-5.2/doc/html/man/form_cursor.3x.html
ncurses-5.2/doc/html/man/form_data.3x.html
ncurses-5.2/doc/html/man/form_driver.3x.html
ncurses-5.2/doc/html/man/form_field.3x.html
ncurses-5.2/doc/html/man/form_field_attributes.3x.html
ncurses-5.2/doc/html/man/form_field_buffer.3x.html
ncurses-5.2/doc/html/man/form_field_info.3x.html
ncurses-5.2/doc/html/man/form_field_just.3x.html
ncurses-5.2/doc/html/man/form_field_new.3x.html
ncurses-5.2/doc/html/man/form_field_opts.3x.html
ncurses-5.2/doc/html/man/form_field_userptr.3x.html
ncurses-5.2/doc/html/man/form_field_validation.3x.html
ncurses-5.2/doc/html/man/form_fieldtype.3x.html
ncurses-5.2/doc/html/man/form_hook.3x.html
ncurses-5.2/doc/html/man/form_new.3x.html
ncurses-5.2/doc/html/man/form_new_page.3x.html
ncurses-5.2/doc/html/man/form_opts.3x.html
ncurses-5.2/doc/html/man/form_page.3x.html
ncurses-5.2/doc/html/man/form_post.3x.html
ncurses-5.2/doc/html/man/form_requestname.3x.html
ncurses-5.2/doc/html/man/form_userptr.3x.html
ncurses-5.2/doc/html/man/form_win.3x.html
ncurses-5.2/doc/html/man/infocmp.1m.html
ncurses-5.2/doc/html/man/infotocap.1m.html
ncurses-5.2/doc/html/man/keybound.3x.html
ncurses-5.2/doc/html/man/keyok.3x.html
ncurses-5.2/doc/html/man/menu.3x.html
ncurses-5.2/doc/html/man/menu_attributes.3x.html
ncurses-5.2/doc/html/man/menu_cursor.3x.html
ncurses-5.2/doc/html/man/menu_driver.3x.html
ncurses-5.2/doc/html/man/menu_format.3x.html
ncurses-5.2/doc/html/man/menu_hook.3x.html
ncurses-5.2/doc/html/man/menu_items.3x.html
ncurses-5.2/doc/html/man/menu_mark.3x.html
ncurses-5.2/doc/html/man/menu_new.3x.html
ncurses-5.2/doc/html/man/menu_opts.3x.html
ncurses-5.2/doc/html/man/menu_pattern.3x.html
ncurses-5.2/doc/html/man/menu_post.3x.html
ncurses-5.2/doc/html/man/menu_requestname.3x.html
ncurses-5.2/doc/html/man/menu_spacing.3x.html
ncurses-5.2/doc/html/man/menu_userptr.3x.html
ncurses-5.2/doc/html/man/menu_win.3x.html
ncurses-5.2/doc/html/man/mitem_current.3x.html
ncurses-5.2/doc/html/man/mitem_name.3x.html
ncurses-5.2/doc/html/man/mitem_new.3x.html
ncurses-5.2/doc/html/man/mitem_opts.3x.html
ncurses-5.2/doc/html/man/mitem_userptr.3x.html
ncurses-5.2/doc/html/man/mitem_value.3x.html
ncurses-5.2/doc/html/man/mitem_visible.3x.html
ncurses-5.2/doc/html/man/ncurses.3x.html
ncurses-5.2/doc/html/man/panel.3x.html
ncurses-5.2/doc/html/man/resizeterm.3x.html
ncurses-5.2/doc/html/man/term.5.html
ncurses-5.2/doc/html/man/term.7.html
ncurses-5.2/doc/html/man/terminfo.5.html
ncurses-5.2/doc/html/man/tic.1m.html
ncurses-5.2/doc/html/man/toe.1m.html
ncurses-5.2/doc/html/man/tput.1.html
ncurses-5.2/doc/html/man/tset.1.html
ncurses-5.2/doc/html/man/wresize.3x.html
ncurses-5.2/doc/html/ncurses-intro.html
ncurses-5.2/doc/ncurses-intro.doc
ncurses-5.2/form/Makefile.in
ncurses-5.2/form/READ.ME
ncurses-5.2/form/fld_arg.c
ncurses-5.2/form/fld_attr.c
ncurses-5.2/form/fld_current.c
ncurses-5.2/form/fld_def.c
ncurses-5.2/form/fld_dup.c
ncurses-5.2/form/fld_ftchoice.c
ncurses-5.2/form/fld_ftlink.c
ncurses-5.2/form/fld_info.c
ncurses-5.2/form/fld_just.c
ncurses-5.2/form/fld_link.c
ncurses-5.2/form/fld_max.c
ncurses-5.2/form/fld_move.c
ncurses-5.2/form/fld_newftyp.c
ncurses-5.2/form/fld_opts.c
ncurses-5.2/form/fld_pad.c
ncurses-5.2/form/fld_page.c
ncurses-5.2/form/fld_stat.c
ncurses-5.2/form/fld_type.c
ncurses-5.2/form/fld_user.c
ncurses-5.2/form/form.h
ncurses-5.2/form/form.priv.h
ncurses-5.2/form/frm_cursor.c
ncurses-5.2/form/frm_data.c
ncurses-5.2/form/frm_def.c
ncurses-5.2/form/frm_driver.c
ncurses-5.2/form/frm_hook.c
ncurses-5.2/form/frm_opts.c
ncurses-5.2/form/frm_page.c
ncurses-5.2/form/frm_post.c
ncurses-5.2/form/frm_req_name.c
ncurses-5.2/form/frm_scale.c
ncurses-5.2/form/frm_sub.c
ncurses-5.2/form/frm_user.c
ncurses-5.2/form/frm_win.c
ncurses-5.2/form/fty_alnum.c
ncurses-5.2/form/fty_alpha.c
ncurses-5.2/form/fty_enum.c
ncurses-5.2/form/fty_int.c
ncurses-5.2/form/fty_ipv4.c
ncurses-5.2/form/fty_num.c
ncurses-5.2/form/fty_regex.c
ncurses-5.2/form/headers
ncurses-5.2/form/llib-lform
ncurses-5.2/form/modules
ncurses-5.2/include/Caps
ncurses-5.2/include/MKhashsize.sh
ncurses-5.2/include/MKncurses_def.sh
ncurses-5.2/include/MKparametrized.sh
ncurses-5.2/include/MKterm.h.awk.in
ncurses-5.2/include/Makefile.in
ncurses-5.2/include/capdefaults.c
ncurses-5.2/include/curses.h.in
ncurses-5.2/include/edit_cfg.sh
ncurses-5.2/include/headers
ncurses-5.2/include/nc_alloc.h
ncurses-5.2/include/nc_panel.h
ncurses-5.2/include/ncurses_cfg.hin
ncurses-5.2/include/ncurses_defs
ncurses-5.2/include/term_entry.h
ncurses-5.2/include/termcap.h.in
ncurses-5.2/include/tic.h
ncurses-5.2/include/unctrl.h.in
ncurses-5.2/install-sh
ncurses-5.2/man/MKterminfo.sh
ncurses-5.2/man/Makefile.in
ncurses-5.2/man/captoinfo.1m
ncurses-5.2/man/clear.1
ncurses-5.2/man/curs_addch.3x
ncurses-5.2/man/curs_addchstr.3x
ncurses-5.2/man/curs_addstr.3x
ncurses-5.2/man/curs_attr.3x
ncurses-5.2/man/curs_beep.3x
ncurses-5.2/man/curs_bkgd.3x
ncurses-5.2/man/curs_border.3x
ncurses-5.2/man/curs_clear.3x
ncurses-5.2/man/curs_color.3x
ncurses-5.2/man/curs_delch.3x
ncurses-5.2/man/curs_deleteln.3x
ncurses-5.2/man/curs_extend.3x
ncurses-5.2/man/curs_getch.3x
ncurses-5.2/man/curs_getstr.3x
ncurses-5.2/man/curs_getyx.3x
ncurses-5.2/man/curs_inch.3x
ncurses-5.2/man/curs_inchstr.3x
ncurses-5.2/man/curs_initscr.3x
ncurses-5.2/man/curs_inopts.3x
ncurses-5.2/man/curs_insch.3x
ncurses-5.2/man/curs_insstr.3x
ncurses-5.2/man/curs_instr.3x
ncurses-5.2/man/curs_kernel.3x
ncurses-5.2/man/curs_mouse.3x
ncurses-5.2/man/curs_move.3x
ncurses-5.2/man/curs_outopts.3x
ncurses-5.2/man/curs_overlay.3x
ncurses-5.2/man/curs_pad.3x
ncurses-5.2/man/curs_print.3x
ncurses-5.2/man/curs_printw.3x
ncurses-5.2/man/curs_refresh.3x
ncurses-5.2/man/curs_scanw.3x
ncurses-5.2/man/curs_scr_dump.3x
ncurses-5.2/man/curs_scroll.3x
ncurses-5.2/man/curs_slk.3x
ncurses-5.2/man/curs_termattrs.3x
ncurses-5.2/man/curs_termcap.3x
ncurses-5.2/man/curs_terminfo.3x
ncurses-5.2/man/curs_touch.3x
ncurses-5.2/man/curs_trace.3x
ncurses-5.2/man/curs_util.3x
ncurses-5.2/man/curs_window.3x
ncurses-5.2/man/default_colors.3x
ncurses-5.2/man/define_key.3x
ncurses-5.2/man/form.3x
ncurses-5.2/man/form_cursor.3x
ncurses-5.2/man/form_data.3x
ncurses-5.2/man/form_driver.3x
ncurses-5.2/man/form_field.3x
ncurses-5.2/man/form_field_attributes.3x
ncurses-5.2/man/form_field_buffer.3x
ncurses-5.2/man/form_field_info.3x
ncurses-5.2/man/form_field_just.3x
ncurses-5.2/man/form_field_new.3x
ncurses-5.2/man/form_field_opts.3x
ncurses-5.2/man/form_field_userptr.3x
ncurses-5.2/man/form_field_validation.3x
ncurses-5.2/man/form_fieldtype.3x
ncurses-5.2/man/form_hook.3x
ncurses-5.2/man/form_new.3x
ncurses-5.2/man/form_new_page.3x
ncurses-5.2/man/form_opts.3x
ncurses-5.2/man/form_page.3x
ncurses-5.2/man/form_post.3x
ncurses-5.2/man/form_requestname.3x
ncurses-5.2/man/form_userptr.3x
ncurses-5.2/man/form_win.3x
ncurses-5.2/man/infocmp.1m
ncurses-5.2/man/infotocap.1m
ncurses-5.2/man/keybound.3x
ncurses-5.2/man/keyok.3x
ncurses-5.2/man/make_sed.sh
ncurses-5.2/man/man_db.renames
ncurses-5.2/man/manlinks.sed
ncurses-5.2/man/menu.3x
ncurses-5.2/man/menu_attributes.3x
ncurses-5.2/man/menu_cursor.3x
ncurses-5.2/man/menu_driver.3x
ncurses-5.2/man/menu_format.3x
ncurses-5.2/man/menu_hook.3x
ncurses-5.2/man/menu_items.3x
ncurses-5.2/man/menu_mark.3x
ncurses-5.2/man/menu_new.3x
ncurses-5.2/man/menu_opts.3x
ncurses-5.2/man/menu_pattern.3x
ncurses-5.2/man/menu_post.3x
ncurses-5.2/man/menu_requestname.3x
ncurses-5.2/man/menu_spacing.3x
ncurses-5.2/man/menu_userptr.3x
ncurses-5.2/man/menu_win.3x
ncurses-5.2/man/mitem_current.3x
ncurses-5.2/man/mitem_name.3x
ncurses-5.2/man/mitem_new.3x
ncurses-5.2/man/mitem_opts.3x
ncurses-5.2/man/mitem_userptr.3x
ncurses-5.2/man/mitem_value.3x
ncurses-5.2/man/mitem_visible.3x
ncurses-5.2/man/ncurses.3x
ncurses-5.2/man/panel.3x
ncurses-5.2/man/resizeterm.3x
ncurses-5.2/man/term.5
ncurses-5.2/man/term.7
ncurses-5.2/man/terminfo.head
ncurses-5.2/man/terminfo.tail
ncurses-5.2/man/tic.1m
ncurses-5.2/man/toe.1m
ncurses-5.2/man/tput.1
ncurses-5.2/man/tset.1
ncurses-5.2/man/wresize.3x
ncurses-5.2/menu/Makefile.in
ncurses-5.2/menu/READ.ME
ncurses-5.2/menu/eti.h
ncurses-5.2/menu/headers
ncurses-5.2/menu/llib-lmenu
ncurses-5.2/menu/m_attribs.c
ncurses-5.2/menu/m_cursor.c
ncurses-5.2/menu/m_driver.c
ncurses-5.2/menu/m_format.c
ncurses-5.2/menu/m_global.c
ncurses-5.2/menu/m_hook.c
ncurses-5.2/menu/m_item_cur.c
ncurses-5.2/menu/m_item_nam.c
ncurses-5.2/menu/m_item_new.c
ncurses-5.2/menu/m_item_opt.c
ncurses-5.2/menu/m_item_top.c
ncurses-5.2/menu/m_item_use.c
ncurses-5.2/menu/m_item_val.c
ncurses-5.2/menu/m_item_vis.c
ncurses-5.2/menu/m_items.c
ncurses-5.2/menu/m_new.c
ncurses-5.2/menu/m_opts.c
ncurses-5.2/menu/m_pad.c
ncurses-5.2/menu/m_pattern.c
ncurses-5.2/menu/m_post.c
ncurses-5.2/menu/m_req_name.c
ncurses-5.2/menu/m_scale.c
ncurses-5.2/menu/m_spacing.c
ncurses-5.2/menu/m_sub.c
ncurses-5.2/menu/m_userptr.c
ncurses-5.2/menu/m_win.c
ncurses-5.2/menu/menu.h
ncurses-5.2/menu/menu.priv.h
ncurses-5.2/menu/mf_common.h
ncurses-5.2/menu/modules
ncurses-5.2/misc/Makefile.in
ncurses-5.2/misc/chkdef.cmd
ncurses-5.2/misc/cleantic.cmd
ncurses-5.2/misc/cmpdef.cmd
ncurses-5.2/misc/emx.src
ncurses-5.2/misc/form.def
ncurses-5.2/misc/form.ref
ncurses-5.2/misc/indent.pro
ncurses-5.2/misc/makedef.cmd
ncurses-5.2/misc/makellib
ncurses-5.2/misc/menu.def
ncurses-5.2/misc/menu.ref
ncurses-5.2/misc/ncurses.def
ncurses-5.2/misc/ncurses.ref
ncurses-5.2/misc/panel.def
ncurses-5.2/misc/panel.ref
ncurses-5.2/misc/run_tic.in
ncurses-5.2/misc/shlib
ncurses-5.2/misc/tabset/std
ncurses-5.2/misc/tabset/stdcrt
ncurses-5.2/misc/tabset/vt100
ncurses-5.2/misc/tabset/vt300
ncurses-5.2/misc/tdlint
ncurses-5.2/misc/terminfo.src
ncurses-5.2/mk-0th.awk
ncurses-5.2/mk-1st.awk
ncurses-5.2/mk-2nd.awk
ncurses-5.2/mkinstalldirs
ncurses-5.2/ncurses/Makefile.in
ncurses-5.2/ncurses/README
ncurses-5.2/ncurses/SigAction.h
ncurses-5.2/ncurses/base/MKkeyname.awk
ncurses-5.2/ncurses/base/MKlib_gen.sh
ncurses-5.2/ncurses/base/MKunctrl.awk
ncurses-5.2/ncurses/base/README
ncurses-5.2/ncurses/base/define_key.c
ncurses-5.2/ncurses/base/keybound.c
ncurses-5.2/ncurses/base/keyok.c
ncurses-5.2/ncurses/base/lib_addch.c
ncurses-5.2/ncurses/base/lib_addstr.c
ncurses-5.2/ncurses/base/lib_beep.c
ncurses-5.2/ncurses/base/lib_bkgd.c
ncurses-5.2/ncurses/base/lib_box.c
ncurses-5.2/ncurses/base/lib_chgat.c
ncurses-5.2/ncurses/base/lib_clear.c
ncurses-5.2/ncurses/base/lib_clearok.c
ncurses-5.2/ncurses/base/lib_clrbot.c
ncurses-5.2/ncurses/base/lib_clreol.c
ncurses-5.2/ncurses/base/lib_color.c
ncurses-5.2/ncurses/base/lib_colorset.c
ncurses-5.2/ncurses/base/lib_delch.c
ncurses-5.2/ncurses/base/lib_delwin.c
ncurses-5.2/ncurses/base/lib_dft_fgbg.c
ncurses-5.2/ncurses/base/lib_echo.c
ncurses-5.2/ncurses/base/lib_endwin.c
ncurses-5.2/ncurses/base/lib_erase.c
ncurses-5.2/ncurses/base/lib_flash.c
ncurses-5.2/ncurses/base/lib_freeall.c
ncurses-5.2/ncurses/base/lib_getch.c
ncurses-5.2/ncurses/base/lib_getstr.c
ncurses-5.2/ncurses/base/lib_hline.c
ncurses-5.2/ncurses/base/lib_immedok.c
ncurses-5.2/ncurses/base/lib_inchstr.c
ncurses-5.2/ncurses/base/lib_initscr.c
ncurses-5.2/ncurses/base/lib_insch.c
ncurses-5.2/ncurses/base/lib_insdel.c
ncurses-5.2/ncurses/base/lib_insstr.c
ncurses-5.2/ncurses/base/lib_instr.c
ncurses-5.2/ncurses/base/lib_isendwin.c
ncurses-5.2/ncurses/base/lib_leaveok.c
ncurses-5.2/ncurses/base/lib_mouse.c
ncurses-5.2/ncurses/base/lib_move.c
ncurses-5.2/ncurses/base/lib_mvwin.c
ncurses-5.2/ncurses/base/lib_newterm.c
ncurses-5.2/ncurses/base/lib_newwin.c
ncurses-5.2/ncurses/base/lib_nl.c
ncurses-5.2/ncurses/base/lib_overlay.c
ncurses-5.2/ncurses/base/lib_pad.c
ncurses-5.2/ncurses/base/lib_printw.c
ncurses-5.2/ncurses/base/lib_redrawln.c
ncurses-5.2/ncurses/base/lib_refresh.c
ncurses-5.2/ncurses/base/lib_restart.c
ncurses-5.2/ncurses/base/lib_scanw.c
ncurses-5.2/ncurses/base/lib_screen.c
ncurses-5.2/ncurses/base/lib_scroll.c
ncurses-5.2/ncurses/base/lib_scrollok.c
ncurses-5.2/ncurses/base/lib_scrreg.c
ncurses-5.2/ncurses/base/lib_set_term.c
ncurses-5.2/ncurses/base/lib_slk.c
ncurses-5.2/ncurses/base/lib_slkatr_set.c
ncurses-5.2/ncurses/base/lib_slkatrof.c
ncurses-5.2/ncurses/base/lib_slkatron.c
ncurses-5.2/ncurses/base/lib_slkatrset.c
ncurses-5.2/ncurses/base/lib_slkattr.c
ncurses-5.2/ncurses/base/lib_slkclear.c
ncurses-5.2/ncurses/base/lib_slkcolor.c
ncurses-5.2/ncurses/base/lib_slkinit.c
ncurses-5.2/ncurses/base/lib_slklab.c
ncurses-5.2/ncurses/base/lib_slkrefr.c
ncurses-5.2/ncurses/base/lib_slkset.c
ncurses-5.2/ncurses/base/lib_slktouch.c
ncurses-5.2/ncurses/base/lib_touch.c
ncurses-5.2/ncurses/base/lib_ungetch.c
ncurses-5.2/ncurses/base/lib_vline.c
ncurses-5.2/ncurses/base/lib_wattroff.c
ncurses-5.2/ncurses/base/lib_wattron.c
ncurses-5.2/ncurses/base/lib_winch.c
ncurses-5.2/ncurses/base/lib_window.c
ncurses-5.2/ncurses/base/memmove.c
ncurses-5.2/ncurses/base/nc_panel.c
ncurses-5.2/ncurses/base/resizeterm.c
ncurses-5.2/ncurses/base/safe_sprintf.c
ncurses-5.2/ncurses/base/sigaction.c
ncurses-5.2/ncurses/base/tries.c
ncurses-5.2/ncurses/base/version.c
ncurses-5.2/ncurses/base/vsscanf.c
ncurses-5.2/ncurses/base/wresize.c
ncurses-5.2/ncurses/curses.priv.h
ncurses-5.2/ncurses/fifo_defs.h
ncurses-5.2/ncurses/llib-lncurses
ncurses-5.2/ncurses/modules
ncurses-5.2/ncurses/tinfo/MKcaptab.awk
ncurses-5.2/ncurses/tinfo/MKfallback.sh
ncurses-5.2/ncurses/tinfo/MKnames.awk
ncurses-5.2/ncurses/tinfo/README
ncurses-5.2/ncurses/tinfo/access.c
ncurses-5.2/ncurses/tinfo/add_tries.c
ncurses-5.2/ncurses/tinfo/alloc_entry.c
ncurses-5.2/ncurses/tinfo/alloc_ttype.c
ncurses-5.2/ncurses/tinfo/captoinfo.c
ncurses-5.2/ncurses/tinfo/comp_error.c
ncurses-5.2/ncurses/tinfo/comp_expand.c
ncurses-5.2/ncurses/tinfo/comp_hash.c
ncurses-5.2/ncurses/tinfo/comp_parse.c
ncurses-5.2/ncurses/tinfo/comp_scan.c
ncurses-5.2/ncurses/tinfo/doalloc.c
ncurses-5.2/ncurses/tinfo/free_ttype.c
ncurses-5.2/ncurses/tinfo/getenv_num.c
ncurses-5.2/ncurses/tinfo/home_terminfo.c
ncurses-5.2/ncurses/tinfo/init_keytry.c
ncurses-5.2/ncurses/tinfo/keys.list
ncurses-5.2/ncurses/tinfo/lib_acs.c
ncurses-5.2/ncurses/tinfo/lib_baudrate.c
ncurses-5.2/ncurses/tinfo/lib_cur_term.c
ncurses-5.2/ncurses/tinfo/lib_data.c
ncurses-5.2/ncurses/tinfo/lib_has_cap.c
ncurses-5.2/ncurses/tinfo/lib_kernel.c
ncurses-5.2/ncurses/tinfo/lib_longname.c
ncurses-5.2/ncurses/tinfo/lib_napms.c
ncurses-5.2/ncurses/tinfo/lib_options.c
ncurses-5.2/ncurses/tinfo/lib_print.c
ncurses-5.2/ncurses/tinfo/lib_raw.c
ncurses-5.2/ncurses/tinfo/lib_setup.c
ncurses-5.2/ncurses/tinfo/lib_termcap.c
ncurses-5.2/ncurses/tinfo/lib_termname.c
ncurses-5.2/ncurses/tinfo/lib_tgoto.c
ncurses-5.2/ncurses/tinfo/lib_ti.c
ncurses-5.2/ncurses/tinfo/lib_tparm.c
ncurses-5.2/ncurses/tinfo/lib_tputs.c
ncurses-5.2/ncurses/tinfo/lib_ttyflags.c
ncurses-5.2/ncurses/tinfo/make_keys.c
ncurses-5.2/ncurses/tinfo/name_match.c
ncurses-5.2/ncurses/tinfo/parse_entry.c
ncurses-5.2/ncurses/tinfo/read_entry.c
ncurses-5.2/ncurses/tinfo/read_termcap.c
ncurses-5.2/ncurses/tinfo/setbuf.c
ncurses-5.2/ncurses/tinfo/strings.c
ncurses-5.2/ncurses/tinfo/write_entry.c
ncurses-5.2/ncurses/trace/README
ncurses-5.2/ncurses/trace/lib_trace.c
ncurses-5.2/ncurses/trace/lib_traceatr.c
ncurses-5.2/ncurses/trace/lib_tracebits.c
ncurses-5.2/ncurses/trace/lib_tracechr.c
ncurses-5.2/ncurses/trace/lib_tracedmp.c
ncurses-5.2/ncurses/trace/lib_tracemse.c
ncurses-5.2/ncurses/trace/trace_buf.c
ncurses-5.2/ncurses/trace/trace_tries.c
ncurses-5.2/ncurses/trace/trace_xnames.c
ncurses-5.2/ncurses/tty/MKexpanded.sh
ncurses-5.2/ncurses/tty/hardscroll.c
ncurses-5.2/ncurses/tty/hashmap.c
ncurses-5.2/ncurses/tty/lib_mvcur.c
ncurses-5.2/ncurses/tty/lib_tstp.c
ncurses-5.2/ncurses/tty/lib_twait.c
ncurses-5.2/ncurses/tty/lib_vidattr.c
ncurses-5.2/ncurses/tty/tty_display.h
ncurses-5.2/ncurses/tty/tty_input.h
ncurses-5.2/ncurses/tty/tty_update.c
ncurses-5.2/panel/Makefile.in
ncurses-5.2/panel/headers
ncurses-5.2/panel/llib-lpanel
ncurses-5.2/panel/modules
ncurses-5.2/panel/p_above.c
ncurses-5.2/panel/p_below.c
ncurses-5.2/panel/p_bottom.c
ncurses-5.2/panel/p_delete.c
ncurses-5.2/panel/p_hidden.c
ncurses-5.2/panel/p_hide.c
ncurses-5.2/panel/p_move.c
ncurses-5.2/panel/p_new.c
ncurses-5.2/panel/p_replace.c
ncurses-5.2/panel/p_show.c
ncurses-5.2/panel/p_top.c
ncurses-5.2/panel/p_update.c
ncurses-5.2/panel/p_user.c
ncurses-5.2/panel/p_win.c
ncurses-5.2/panel/panel.c
ncurses-5.2/panel/panel.h
ncurses-5.2/panel/panel.priv.h
ncurses-5.2/progs/MKtermsort.sh
ncurses-5.2/progs/Makefile.in
ncurses-5.2/progs/capconvert
ncurses-5.2/progs/clear.c
ncurses-5.2/progs/clear.sh
ncurses-5.2/progs/dump_entry.c
ncurses-5.2/progs/dump_entry.h
ncurses-5.2/progs/infocmp.c
ncurses-5.2/progs/modules
ncurses-5.2/progs/progs.priv.h
ncurses-5.2/progs/tic.c
ncurses-5.2/progs/toe.c
ncurses-5.2/progs/tput.c
ncurses-5.2/progs/tset.c
ncurses-5.2/sysdeps/unix/sysv/linux/Makefile
ncurses-5.2/sysdeps/unix/sysv/linux/alpha/configure
ncurses-5.2/sysdeps/unix/sysv/linux/configure
ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sed
ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sh
ncurses-5.2/sysdeps/unix/sysv/linux/run_tic.sh
ncurses-5.2/tack/COPYING
ncurses-5.2/tack/HISTORY
ncurses-5.2/tack/Makefile.in
ncurses-5.2/tack/README
ncurses-5.2/tack/ansi.c
ncurses-5.2/tack/charset.c
ncurses-5.2/tack/color.c
ncurses-5.2/tack/control.c
ncurses-5.2/tack/crum.c
ncurses-5.2/tack/edit.c
ncurses-5.2/tack/fun.c
ncurses-5.2/tack/init.c
ncurses-5.2/tack/menu.c
ncurses-5.2/tack/modes.c
ncurses-5.2/tack/modules
ncurses-5.2/tack/output.c
ncurses-5.2/tack/pad.c
ncurses-5.2/tack/scan.c
ncurses-5.2/tack/sync.c
ncurses-5.2/tack/sysdep.c
ncurses-5.2/tack/tack.1
ncurses-5.2/tack/tack.c
ncurses-5.2/tack/tack.h
ncurses-5.2/tar-copy.sh
ncurses-5.2/test/Makefile.in
ncurses-5.2/test/README
ncurses-5.2/test/blue.c
ncurses-5.2/test/bs.6
ncurses-5.2/test/bs.c
ncurses-5.2/test/cardfile.c
ncurses-5.2/test/cardfile.dat
ncurses-5.2/test/configure
ncurses-5.2/test/configure.in
ncurses-5.2/test/ditto.c
ncurses-5.2/test/dots.c
ncurses-5.2/test/filter.c
ncurses-5.2/test/firework.c
ncurses-5.2/test/firstlast.c
ncurses-5.2/test/gdc.6
ncurses-5.2/test/gdc.c
ncurses-5.2/test/hanoi.c
ncurses-5.2/test/hashtest.c
ncurses-5.2/test/keynames.c
ncurses-5.2/test/knight.c
ncurses-5.2/test/lrtest.c
ncurses-5.2/test/modules
ncurses-5.2/test/ncurses.c
ncurses-5.2/test/ncurses_tst.hin
ncurses-5.2/test/newdemo.c
ncurses-5.2/test/railroad.c
ncurses-5.2/test/rain.c
ncurses-5.2/test/tclock.c
ncurses-5.2/test/test.priv.h
ncurses-5.2/test/testaddch.c
ncurses-5.2/test/testcurs.c
ncurses-5.2/test/testscanw.c
ncurses-5.2/test/tracemunch
ncurses-5.2/test/view.c
ncurses-5.2/test/worm.c
ncurses-5.2/test/xmas.c
Cherrypick from master 2009-11-13 16:28:56 UTC Joel Sherrill '2009-11-13 Joel Sherrill ':
ChangeLog
RTEMS_Makefiles/Makefile.bfd
RTEMS_Makefiles/Makefile.libtecla
RTEMS_Makefiles/Makefile.ncurses
RTEMS_Makefiles/Makefile.ncurses-5.3
RTEMS_Makefiles/Makefile.readline-4.3
RTEMS_Makefiles/Makefile.zlib
SUPPORT
VERSION
bit
bit_bfd
examples/avl/Makefile
examples/ncurses/Makefile
examples/readline/Makefile
libtecla-1.4.1/CHANGES
libtecla-1.4.1/INSTALL
libtecla-1.4.1/LICENSE.TERMS
libtecla-1.4.1/Makefile
libtecla-1.4.1/Makefile.in
libtecla-1.4.1/Makefile.rules
libtecla-1.4.1/Makefile.stub
libtecla-1.4.1/PORTING
libtecla-1.4.1/README
libtecla-1.4.1/RELEASE.NOTES
libtecla-1.4.1/config.guess
libtecla-1.4.1/config.sub
libtecla-1.4.1/configure
libtecla-1.4.1/configure.in
libtecla-1.4.1/cplfile.c
libtecla-1.4.1/cplfile.h
libtecla-1.4.1/cplmatch.c
libtecla-1.4.1/demo.c
libtecla-1.4.1/demo2.c
libtecla-1.4.1/direader.c
libtecla-1.4.1/direader.h
libtecla-1.4.1/enhance.c
libtecla-1.4.1/expand.c
libtecla-1.4.1/freelist.c
libtecla-1.4.1/freelist.h
libtecla-1.4.1/getline.c
libtecla-1.4.1/getline.h
libtecla-1.4.1/hash.c
libtecla-1.4.1/hash.h
libtecla-1.4.1/history.c
libtecla-1.4.1/history.h
libtecla-1.4.1/homedir.c
libtecla-1.4.1/homedir.h
libtecla-1.4.1/html/changes.html
libtecla-1.4.1/html/cpl_complete_word.html
libtecla-1.4.1/html/ef_expand_file.html
libtecla-1.4.1/html/enhance.html
libtecla-1.4.1/html/gl_get_line.html
libtecla-1.4.1/html/index.html
libtecla-1.4.1/html/libtecla.html
libtecla-1.4.1/html/pca_lookup_file.html
libtecla-1.4.1/html/release.html
libtecla-1.4.1/install-sh
libtecla-1.4.1/keytab.c
libtecla-1.4.1/keytab.h
libtecla-1.4.1/libtecla.h
libtecla-1.4.1/libtecla.map
libtecla-1.4.1/man3/cfc_file_start.3
libtecla-1.4.1/man3/cfc_literal_escapes.3
libtecla-1.4.1/man3/cfc_set_check_fn.3
libtecla-1.4.1/man3/cpl_add_completion.3
libtecla-1.4.1/man3/cpl_complete_word.3
libtecla-1.4.1/man3/cpl_file_completions.3
libtecla-1.4.1/man3/cpl_last_error.3
libtecla-1.4.1/man3/cpl_list_completions.3
libtecla-1.4.1/man3/cpl_record_error.3
libtecla-1.4.1/man3/del_CplFileConf.3
libtecla-1.4.1/man3/del_ExpandFile.3
libtecla-1.4.1/man3/del_GetLine.3
libtecla-1.4.1/man3/del_PathCache.3
libtecla-1.4.1/man3/del_PcaPathConf.3
libtecla-1.4.1/man3/del_WordCompletion.3
libtecla-1.4.1/man3/ef_expand_file.3
libtecla-1.4.1/man3/ef_last_error.3
libtecla-1.4.1/man3/ef_list_expansions.3
libtecla-1.4.1/man3/enhance.3
libtecla-1.4.1/man3/gl_change_terminal.3
libtecla-1.4.1/man3/gl_clear_history.3
libtecla-1.4.1/man3/gl_configure_getline.3
libtecla-1.4.1/man3/gl_customize_completion.3
libtecla-1.4.1/man3/gl_echo_mode.3
libtecla-1.4.1/man3/gl_get_line.3
libtecla-1.4.1/man3/gl_group_history.3
libtecla-1.4.1/man3/gl_ignore_signal.3
libtecla-1.4.1/man3/gl_last_signal.3
libtecla-1.4.1/man3/gl_limit_history.3
libtecla-1.4.1/man3/gl_load_history.3
libtecla-1.4.1/man3/gl_lookup_history.3
libtecla-1.4.1/man3/gl_prompt_style.3
libtecla-1.4.1/man3/gl_range_of_history.3
libtecla-1.4.1/man3/gl_resize_history.3
libtecla-1.4.1/man3/gl_save_history.3
libtecla-1.4.1/man3/gl_show_history.3
libtecla-1.4.1/man3/gl_size_of_history.3
libtecla-1.4.1/man3/gl_state_of_history.3
libtecla-1.4.1/man3/gl_terminal_size.3
libtecla-1.4.1/man3/gl_toggle_history.3
libtecla-1.4.1/man3/gl_trap_signal.3
libtecla-1.4.1/man3/gl_watch_fd.3
libtecla-1.4.1/man3/libtecla.3
libtecla-1.4.1/man3/libtecla_version.3
libtecla-1.4.1/man3/new_CplFileConf.3
libtecla-1.4.1/man3/new_ExpandFile.3
libtecla-1.4.1/man3/new_GetLine.3
libtecla-1.4.1/man3/new_PathCache.3
libtecla-1.4.1/man3/new_PcaPathConf.3
libtecla-1.4.1/man3/new_WordCompletion.3
libtecla-1.4.1/man3/pca_last_error.3
libtecla-1.4.1/man3/pca_lookup_file.3
libtecla-1.4.1/man3/pca_path_completions.3
libtecla-1.4.1/man3/pca_scan_path.3
libtecla-1.4.1/man3/pca_set_check_fn.3
libtecla-1.4.1/man3/ppc_file_start.3
libtecla-1.4.1/man3/ppc_literal_escapes.3
libtecla-1.4.1/pathutil.c
libtecla-1.4.1/pathutil.h
libtecla-1.4.1/pcache.c
libtecla-1.4.1/stringrp.c
libtecla-1.4.1/stringrp.h
libtecla-1.4.1/strngmem.c
libtecla-1.4.1/strngmem.h
libtecla-1.4.1/update_html
libtecla-1.4.1/update_version
libtecla-1.4.1/version.c
ncurses-5.3/config.sub
ncurses-5.3/misc/run_tic.sh
readline-4.3.orig/CHANGELOG
readline-4.3.orig/CHANGES
readline-4.3.orig/COPYING
readline-4.3.orig/INSTALL
readline-4.3.orig/MANIFEST
readline-4.3.orig/Makefile.in
readline-4.3.orig/README
readline-4.3.orig/USAGE
readline-4.3.orig/aclocal.m4
readline-4.3.orig/ansi_stdlib.h
readline-4.3.orig/bind.c
readline-4.3.orig/callback.c
readline-4.3.orig/chardefs.h
readline-4.3.orig/compat.c
readline-4.3.orig/complete.c
readline-4.3.orig/config.h.in
readline-4.3.orig/configure
readline-4.3.orig/configure.in
readline-4.3.orig/display.c
readline-4.3.orig/doc/Makefile.in
readline-4.3.orig/doc/hist.texinfo
readline-4.3.orig/doc/history.0
readline-4.3.orig/doc/history.3
readline-4.3.orig/doc/history.dvi
readline-4.3.orig/doc/history.html
readline-4.3.orig/doc/history.info
readline-4.3.orig/doc/history.ps
readline-4.3.orig/doc/history_3.ps
readline-4.3.orig/doc/hstech.texinfo
readline-4.3.orig/doc/hsuser.texinfo
readline-4.3.orig/doc/manvers.texinfo
readline-4.3.orig/doc/readline.0
readline-4.3.orig/doc/readline.3
readline-4.3.orig/doc/readline.dvi
readline-4.3.orig/doc/readline.html
readline-4.3.orig/doc/readline.info
readline-4.3.orig/doc/readline.ps
readline-4.3.orig/doc/readline_3.ps
readline-4.3.orig/doc/rlman.texinfo
readline-4.3.orig/doc/rltech.texinfo
readline-4.3.orig/doc/rluser.texinfo
readline-4.3.orig/doc/rluserman.dvi
readline-4.3.orig/doc/rluserman.html
readline-4.3.orig/doc/rluserman.info
readline-4.3.orig/doc/rluserman.ps
readline-4.3.orig/doc/rluserman.texinfo
readline-4.3.orig/doc/texi2dvi
readline-4.3.orig/doc/texi2html
readline-4.3.orig/doc/texinfo.tex
readline-4.3.orig/emacs_keymap.c
readline-4.3.orig/examples/Inputrc
readline-4.3.orig/examples/Makefile.in
readline-4.3.orig/examples/excallback.c
readline-4.3.orig/examples/fileman.c
readline-4.3.orig/examples/histexamp.c
readline-4.3.orig/examples/manexamp.c
readline-4.3.orig/examples/readlinebuf.h
readline-4.3.orig/examples/rl.c
readline-4.3.orig/examples/rlcat.c
readline-4.3.orig/examples/rlfe.c
readline-4.3.orig/examples/rltest.c
readline-4.3.orig/examples/rlversion.c
readline-4.3.orig/funmap.c
readline-4.3.orig/histexpand.c
readline-4.3.orig/histfile.c
readline-4.3.orig/histlib.h
readline-4.3.orig/history.c
readline-4.3.orig/history.h
readline-4.3.orig/histsearch.c
readline-4.3.orig/input.c
readline-4.3.orig/isearch.c
readline-4.3.orig/keymaps.c
readline-4.3.orig/keymaps.h
readline-4.3.orig/kill.c
readline-4.3.orig/macro.c
readline-4.3.orig/mbutil.c
readline-4.3.orig/misc.c
readline-4.3.orig/nls.c
readline-4.3.orig/parens.c
readline-4.3.orig/posixdir.h
readline-4.3.orig/posixjmp.h
readline-4.3.orig/posixstat.h
readline-4.3.orig/readline.c
readline-4.3.orig/readline.h
readline-4.3.orig/rlconf.h
readline-4.3.orig/rldefs.h
readline-4.3.orig/rlmbutil.h
readline-4.3.orig/rlprivate.h
readline-4.3.orig/rlshell.h
readline-4.3.orig/rlstdc.h
readline-4.3.orig/rltty.c
readline-4.3.orig/rltty.h
readline-4.3.orig/rltypedefs.h
readline-4.3.orig/rlwinsize.h
readline-4.3.orig/savestring.c
readline-4.3.orig/search.c
readline-4.3.orig/shell.c
readline-4.3.orig/shlib/Makefile.in
readline-4.3.orig/signals.c
readline-4.3.orig/support/config.guess
readline-4.3.orig/support/config.sub
readline-4.3.orig/support/install.sh
readline-4.3.orig/support/mkdirs
readline-4.3.orig/support/mkdist
readline-4.3.orig/support/shlib-install
readline-4.3.orig/support/shobj-conf
readline-4.3.orig/support/wcwidth.c
readline-4.3.orig/tcap.h
readline-4.3.orig/terminal.c
readline-4.3.orig/text.c
readline-4.3.orig/tilde.c
readline-4.3.orig/tilde.h
readline-4.3.orig/undo.c
readline-4.3.orig/util.c
readline-4.3.orig/vi_keymap.c
readline-4.3.orig/vi_mode.c
readline-4.3.orig/xmalloc.c
readline-4.3.orig/xmalloc.h
readline-4.3/CHANGELOG-ReadLine
readline-4.3/CHANGES
readline-4.3/COPYING
readline-4.3/ChangeLog
readline-4.3/INSTALL
readline-4.3/MANIFEST
readline-4.3/Makefile.in
readline-4.3/README
readline-4.3/USAGE
readline-4.3/aclocal.m4
readline-4.3/ansi_stdlib.h
readline-4.3/bind.c
readline-4.3/callback.c
readline-4.3/chardefs.h
readline-4.3/compat.c
readline-4.3/complete.c
readline-4.3/config.h.in
readline-4.3/configure
readline-4.3/configure.in
readline-4.3/display.c
readline-4.3/doc/Makefile.in
readline-4.3/doc/hist.texinfo
readline-4.3/doc/history.3
readline-4.3/doc/hstech.texinfo
readline-4.3/doc/hsuser.texinfo
readline-4.3/doc/manvers.texinfo
readline-4.3/doc/readline.3
readline-4.3/doc/rlman.texinfo
readline-4.3/doc/rltech.texinfo
readline-4.3/doc/rluser.texinfo
readline-4.3/doc/rluserman.texinfo
readline-4.3/doc/texi2dvi
readline-4.3/doc/texi2html
readline-4.3/doc/texinfo.tex
readline-4.3/emacs_keymap.c
readline-4.3/examples/Inputrc
readline-4.3/examples/Makefile.in
readline-4.3/examples/excallback.c
readline-4.3/examples/fileman.c
readline-4.3/examples/histexamp.c
readline-4.3/examples/manexamp.c
readline-4.3/examples/readlinebuf.h
readline-4.3/examples/rl.c
readline-4.3/examples/rlcat.c
readline-4.3/examples/rlfe.c
readline-4.3/examples/rltest.c
readline-4.3/examples/rlversion.c
readline-4.3/funmap.c
readline-4.3/histexpand.c
readline-4.3/histfile.c
readline-4.3/histlib.h
readline-4.3/history.c
readline-4.3/history.h
readline-4.3/histsearch.c
readline-4.3/input.c
readline-4.3/isearch.c
readline-4.3/keymaps.c
readline-4.3/keymaps.h
readline-4.3/kill.c
readline-4.3/macro.c
readline-4.3/mbutil.c
readline-4.3/misc.c
readline-4.3/nls.c
readline-4.3/parens.c
readline-4.3/posixdir.h
readline-4.3/posixjmp.h
readline-4.3/posixstat.h
readline-4.3/readline.c
readline-4.3/readline.h
readline-4.3/rlconf.h
readline-4.3/rldefs.h
readline-4.3/rlmbutil.h
readline-4.3/rlprivate.h
readline-4.3/rlshell.h
readline-4.3/rlstdc.h
readline-4.3/rltty.c
readline-4.3/rltty.h
readline-4.3/rltypedefs.h
readline-4.3/rlwinsize.h
readline-4.3/savestring.c
readline-4.3/search.c
readline-4.3/shell.c
readline-4.3/shlib/Makefile.in
readline-4.3/signals.c
readline-4.3/support/config.guess
readline-4.3/support/config.sub
readline-4.3/support/install.sh
readline-4.3/support/mkdirs
readline-4.3/support/mkdist
readline-4.3/support/shlib-install
readline-4.3/support/shobj-conf
readline-4.3/support/wcwidth.c
readline-4.3/tcap.h
readline-4.3/terminal.c
readline-4.3/text.c
readline-4.3/tilde.c
readline-4.3/tilde.h
readline-4.3/undo.c
readline-4.3/util.c
readline-4.3/vi_keymap.c
readline-4.3/vi_mode.c
readline-4.3/xmalloc.c
readline-4.3/xmalloc.h
readline-doc-4.3/MANIFEST.doc
readline-doc-4.3/doc/history.0
readline-doc-4.3/doc/history.dvi
readline-doc-4.3/doc/history.html
readline-doc-4.3/doc/history.info
readline-doc-4.3/doc/history.ps
readline-doc-4.3/doc/history_3.ps
readline-doc-4.3/doc/readline.0
readline-doc-4.3/doc/readline.dvi
readline-doc-4.3/doc/readline.html
readline-doc-4.3/doc/readline.info
readline-doc-4.3/doc/readline.ps
readline-doc-4.3/doc/readline_3.ps
readline-doc-4.3/doc/rluserman.dvi
readline-doc-4.3/doc/rluserman.html
readline-doc-4.3/doc/rluserman.info
readline-doc-4.3/doc/rluserman.ps
zlib-1.1.4/ChangeLog
zlib-1.1.4/FAQ
zlib-1.1.4/INDEX
zlib-1.1.4/Make_vms.com
zlib-1.1.4/Makefile
zlib-1.1.4/Makefile.in
zlib-1.1.4/Makefile.riscos
zlib-1.1.4/README
zlib-1.1.4/adler32.c
zlib-1.1.4/algorithm.txt
zlib-1.1.4/amiga/Makefile.pup
zlib-1.1.4/amiga/Makefile.sas
zlib-1.1.4/compress.c
zlib-1.1.4/configure
zlib-1.1.4/contrib/README.contrib
zlib-1.1.4/contrib/asm386/gvmat32.asm
zlib-1.1.4/contrib/asm386/gvmat32c.c
zlib-1.1.4/contrib/asm386/mkgvmt32.bat
zlib-1.1.4/contrib/asm386/zlibvc.def
zlib-1.1.4/contrib/asm386/zlibvc.dsp
zlib-1.1.4/contrib/asm386/zlibvc.dsw
zlib-1.1.4/contrib/asm586/README.586
zlib-1.1.4/contrib/asm586/match.S
zlib-1.1.4/contrib/asm686/README.686
zlib-1.1.4/contrib/asm686/match.S
zlib-1.1.4/contrib/delphi/zlib.mak
zlib-1.1.4/contrib/delphi/zlibdef.pas
zlib-1.1.4/contrib/delphi2/d_zlib.bpr
zlib-1.1.4/contrib/delphi2/d_zlib.cpp
zlib-1.1.4/contrib/delphi2/readme.txt
zlib-1.1.4/contrib/delphi2/zlib.bpg
zlib-1.1.4/contrib/delphi2/zlib.bpr
zlib-1.1.4/contrib/delphi2/zlib.cpp
zlib-1.1.4/contrib/delphi2/zlib.pas
zlib-1.1.4/contrib/delphi2/zlib32.bpr
zlib-1.1.4/contrib/delphi2/zlib32.cpp
zlib-1.1.4/contrib/iostream/test.cpp
zlib-1.1.4/contrib/iostream/zfstream.cpp
zlib-1.1.4/contrib/iostream/zfstream.h
zlib-1.1.4/contrib/iostream2/zstream.h
zlib-1.1.4/contrib/iostream2/zstream_test.cpp
zlib-1.1.4/contrib/minizip/ChangeLogUnzip
zlib-1.1.4/contrib/minizip/Makefile
zlib-1.1.4/contrib/minizip/miniunz.c
zlib-1.1.4/contrib/minizip/minizip.c
zlib-1.1.4/contrib/minizip/readme.txt
zlib-1.1.4/contrib/minizip/unzip.c
zlib-1.1.4/contrib/minizip/unzip.def
zlib-1.1.4/contrib/minizip/unzip.h
zlib-1.1.4/contrib/minizip/zip.c
zlib-1.1.4/contrib/minizip/zip.def
zlib-1.1.4/contrib/minizip/zip.h
zlib-1.1.4/contrib/minizip/zlibvc.def
zlib-1.1.4/contrib/minizip/zlibvc.dsp
zlib-1.1.4/contrib/minizip/zlibvc.dsw
zlib-1.1.4/contrib/untgz/Makefile
zlib-1.1.4/contrib/untgz/makefile.w32
zlib-1.1.4/contrib/untgz/untgz.c
zlib-1.1.4/contrib/visual-basic.txt
zlib-1.1.4/crc32.c
zlib-1.1.4/deflate.c
zlib-1.1.4/deflate.h
zlib-1.1.4/descrip.mms
zlib-1.1.4/example.c
zlib-1.1.4/gzio.c
zlib-1.1.4/infblock.c
zlib-1.1.4/infblock.h
zlib-1.1.4/infcodes.c
zlib-1.1.4/infcodes.h
zlib-1.1.4/inffast.c
zlib-1.1.4/inffast.h
zlib-1.1.4/inffixed.h
zlib-1.1.4/inflate.c
zlib-1.1.4/inftrees.c
zlib-1.1.4/inftrees.h
zlib-1.1.4/infutil.c
zlib-1.1.4/infutil.h
zlib-1.1.4/maketree.c
zlib-1.1.4/minigzip.c
zlib-1.1.4/msdos/Makefile.b32
zlib-1.1.4/msdos/Makefile.bor
zlib-1.1.4/msdos/Makefile.dj2
zlib-1.1.4/msdos/Makefile.emx
zlib-1.1.4/msdos/Makefile.msc
zlib-1.1.4/msdos/Makefile.tc
zlib-1.1.4/msdos/Makefile.w32
zlib-1.1.4/msdos/Makefile.wat
zlib-1.1.4/msdos/zlib.def
zlib-1.1.4/msdos/zlib.rc
zlib-1.1.4/nt/Makefile.emx
zlib-1.1.4/nt/Makefile.gcc
zlib-1.1.4/nt/Makefile.nt
zlib-1.1.4/nt/zlib.dnt
zlib-1.1.4/os2/Makefile.os2
zlib-1.1.4/os2/zlib.def
zlib-1.1.4/trees.c
zlib-1.1.4/trees.h
zlib-1.1.4/uncompr.c
zlib-1.1.4/zconf.h
zlib-1.1.4/zlib.3
zlib-1.1.4/zlib.h
zlib-1.1.4/zlib.html
zlib-1.1.4/zutil.c
zlib-1.1.4/zutil.h
---
ChangeLog | 142 +
README | 24 +
RTEMS_Makefiles/Makefile.avl | 12 +
RTEMS_Makefiles/Makefile.bfd | 14 +
RTEMS_Makefiles/Makefile.common | 23 +
RTEMS_Makefiles/Makefile.libtecla | 15 +
RTEMS_Makefiles/Makefile.ncurses | 28 +
RTEMS_Makefiles/Makefile.ncurses-5.3 | 30 +
RTEMS_Makefiles/Makefile.readline-4.3 | 18 +
RTEMS_Makefiles/Makefile.site | 3 +
RTEMS_Makefiles/Makefile.zlib | 13 +
SUPPORT | 22 +
VERSION | 7 +
avl-1.4.0/AUTHORS | 1 +
avl-1.4.0/COPYING | 340 +
avl-1.4.0/ChangeLog | 181 +
avl-1.4.0/INSTALL | 182 +
avl-1.4.0/Makefile.am | 28 +
avl-1.4.0/Makefile.in | 572 +
avl-1.4.0/NEWS | 98 +
avl-1.4.0/README | 37 +
avl-1.4.0/THANKS | 15 +
avl-1.4.0/TODO | 92 +
avl-1.4.0/aclocal.m4 | 104 +
avl-1.4.0/avl.c | 1154 ++
avl-1.4.0/avl.h | 148 +
avl-1.4.0/avl.html | 1046 ++
avl-1.4.0/avl.info | 708 +
avl-1.4.0/avl.texinfo | 679 +
avl-1.4.0/avl.text | 636 +
avl-1.4.0/avlt.c | 1597 ++
avl-1.4.0/avlt.h | 142 +
avl-1.4.0/avltr.c | 1538 ++
avl-1.4.0/avltr.h | 142 +
avl-1.4.0/configure | 1297 ++
avl-1.4.0/configure.in | 5 +
avl-1.4.0/install-sh | 251 +
avl-1.4.0/missing | 190 +
avl-1.4.0/mkinstalldirs | 40 +
avl-1.4.0/rb.c | 1083 ++
avl-1.4.0/rb.h | 155 +
avl-1.4.0/texinfo.tex | 5484 ++++++
avl-1.4.0/thread-test.c | 142 +
bit | 41 +
bit_bfd | 18 +
examples/avl/BuildTests.sh | 13 +
examples/avl/Makefile | 70 +
examples/avl/README | 4 +
examples/avl/init.c | 51 +
examples/ncurses/BuildTests.sh | 36 +
examples/ncurses/Makefile | 70 +
examples/ncurses/README | 4 +
examples/ncurses/init.c | 52 +
examples/readline/.gdbinit | 1 +
examples/readline/Makefile | 70 +
examples/readline/init.c | 51 +
examples/readline/rlgeneric.c | 30 +
libtecla-1.4.1/CHANGES | 1492 ++
libtecla-1.4.1/INSTALL | 168 +
libtecla-1.4.1/LICENSE.TERMS | 28 +
libtecla-1.4.1/Makefile | 3 +
libtecla-1.4.1/Makefile.in | 225 +
libtecla-1.4.1/Makefile.rules | 142 +
libtecla-1.4.1/Makefile.stub | 3 +
libtecla-1.4.1/PORTING | 38 +
libtecla-1.4.1/README | 53 +
libtecla-1.4.1/RELEASE.NOTES | 357 +
libtecla-1.4.1/config.guess | 1183 ++
libtecla-1.4.1/config.sub | 1268 ++
libtecla-1.4.1/configure | 1939 ++
libtecla-1.4.1/configure.in | 412 +
libtecla-1.4.1/cplfile.c | 874 +
libtecla-1.4.1/cplfile.h | 96 +
libtecla-1.4.1/cplmatch.c | 927 +
libtecla-1.4.1/demo.c | 109 +
libtecla-1.4.1/demo2.c | 352 +
libtecla-1.4.1/direader.c | 299 +
libtecla-1.4.1/direader.h | 44 +
libtecla-1.4.1/enhance.c | 689 +
libtecla-1.4.1/expand.c | 1265 ++
libtecla-1.4.1/freelist.c | 393 +
libtecla-1.4.1/freelist.h | 82 +
libtecla-1.4.1/getline.c | 8346 +++++++++
libtecla-1.4.1/getline.h | 88 +
libtecla-1.4.1/hash.c | 748 +
libtecla-1.4.1/hash.h | 157 +
libtecla-1.4.1/history.c | 2003 ++
libtecla-1.4.1/history.h | 159 +
libtecla-1.4.1/homedir.c | 399 +
libtecla-1.4.1/homedir.h | 81 +
libtecla-1.4.1/html/changes.html | 1495 ++
libtecla-1.4.1/html/cpl_complete_word.html | 423 +
libtecla-1.4.1/html/ef_expand_file.html | 267 +
libtecla-1.4.1/html/enhance.html | 111 +
libtecla-1.4.1/html/gl_get_line.html | 2295 +++
libtecla-1.4.1/html/index.html | 116 +
libtecla-1.4.1/html/libtecla.html | 163 +
libtecla-1.4.1/html/pca_lookup_file.html | 371 +
libtecla-1.4.1/html/release.html | 360 +
libtecla-1.4.1/install-sh | 251 +
libtecla-1.4.1/keytab.c | 827 +
libtecla-1.4.1/keytab.h | 146 +
libtecla-1.4.1/libtecla.h | 1194 ++
libtecla-1.4.1/libtecla.map | 124 +
libtecla-1.4.1/man3/cfc_file_start.3 | 1 +
libtecla-1.4.1/man3/cfc_literal_escapes.3 | 1 +
libtecla-1.4.1/man3/cfc_set_check_fn.3 | 1 +
libtecla-1.4.1/man3/cpl_add_completion.3 | 1 +
libtecla-1.4.1/man3/cpl_complete_word.3 | 405 +
libtecla-1.4.1/man3/cpl_file_completions.3 | 1 +
libtecla-1.4.1/man3/cpl_last_error.3 | 1 +
libtecla-1.4.1/man3/cpl_list_completions.3 | 1 +
libtecla-1.4.1/man3/cpl_record_error.3 | 1 +
libtecla-1.4.1/man3/del_CplFileConf.3 | 1 +
libtecla-1.4.1/man3/del_ExpandFile.3 | 1 +
libtecla-1.4.1/man3/del_GetLine.3 | 1 +
libtecla-1.4.1/man3/del_PathCache.3 | 1 +
libtecla-1.4.1/man3/del_PcaPathConf.3 | 1 +
libtecla-1.4.1/man3/del_WordCompletion.3 | 1 +
libtecla-1.4.1/man3/ef_expand_file.3 | 245 +
libtecla-1.4.1/man3/ef_last_error.3 | 1 +
libtecla-1.4.1/man3/ef_list_expansions.3 | 1 +
libtecla-1.4.1/man3/enhance.3 | 86 +
libtecla-1.4.1/man3/gl_change_terminal.3 | 1 +
libtecla-1.4.1/man3/gl_clear_history.3 | 1 +
libtecla-1.4.1/man3/gl_configure_getline.3 | 1 +
libtecla-1.4.1/man3/gl_customize_completion.3 | 1 +
libtecla-1.4.1/man3/gl_echo_mode.3 | 1 +
libtecla-1.4.1/man3/gl_get_line.3 | 2329 +++
libtecla-1.4.1/man3/gl_group_history.3 | 1 +
libtecla-1.4.1/man3/gl_ignore_signal.3 | 1 +
libtecla-1.4.1/man3/gl_last_signal.3 | 1 +
libtecla-1.4.1/man3/gl_limit_history.3 | 1 +
libtecla-1.4.1/man3/gl_load_history.3 | 1 +
libtecla-1.4.1/man3/gl_lookup_history.3 | 1 +
libtecla-1.4.1/man3/gl_prompt_style.3 | 1 +
libtecla-1.4.1/man3/gl_range_of_history.3 | 1 +
libtecla-1.4.1/man3/gl_resize_history.3 | 1 +
libtecla-1.4.1/man3/gl_save_history.3 | 1 +
libtecla-1.4.1/man3/gl_show_history.3 | 1 +
libtecla-1.4.1/man3/gl_size_of_history.3 | 1 +
libtecla-1.4.1/man3/gl_state_of_history.3 | 1 +
libtecla-1.4.1/man3/gl_terminal_size.3 | 1 +
libtecla-1.4.1/man3/gl_toggle_history.3 | 1 +
libtecla-1.4.1/man3/gl_trap_signal.3 | 1 +
libtecla-1.4.1/man3/gl_watch_fd.3 | 1 +
libtecla-1.4.1/man3/libtecla.3 | 160 +
libtecla-1.4.1/man3/libtecla_version.3 | 1 +
libtecla-1.4.1/man3/new_CplFileConf.3 | 1 +
libtecla-1.4.1/man3/new_ExpandFile.3 | 1 +
libtecla-1.4.1/man3/new_GetLine.3 | 1 +
libtecla-1.4.1/man3/new_PathCache.3 | 1 +
libtecla-1.4.1/man3/new_PcaPathConf.3 | 1 +
libtecla-1.4.1/man3/new_WordCompletion.3 | 1 +
libtecla-1.4.1/man3/pca_last_error.3 | 1 +
libtecla-1.4.1/man3/pca_lookup_file.3 | 361 +
libtecla-1.4.1/man3/pca_path_completions.3 | 1 +
libtecla-1.4.1/man3/pca_scan_path.3 | 1 +
libtecla-1.4.1/man3/pca_set_check_fn.3 | 1 +
libtecla-1.4.1/man3/ppc_file_start.3 | 1 +
libtecla-1.4.1/man3/ppc_literal_escapes.3 | 1 +
libtecla-1.4.1/pathutil.c | 532 +
libtecla-1.4.1/pathutil.h | 122 +
libtecla-1.4.1/pcache.c | 1688 ++
libtecla-1.4.1/stringrp.c | 285 +
libtecla-1.4.1/stringrp.h | 84 +
libtecla-1.4.1/strngmem.c | 226 +
libtecla-1.4.1/strngmem.h | 80 +
libtecla-1.4.1/update_html | 35 +
libtecla-1.4.1/update_version | 82 +
libtecla-1.4.1/version.c | 30 +
ncurses-5.2/ANNOUNCE | 486 +
ncurses-5.2/Ada95/Makefile.in | 67 +
ncurses-5.2/Ada95/README | 33 +
ncurses-5.2/Ada95/TODO | 27 +
ncurses-5.2/Ada95/gen/Makefile.in | 429 +
ncurses-5.2/Ada95/gen/gen.c | 1381 ++
ncurses-5.2/Ada95/gen/html.m4 | 11 +
ncurses-5.2/Ada95/gen/normal.m4 | 8 +
ncurses-5.2/Ada95/gen/table.m4 | 6 +
.../Ada95/gen/terminal_interface-curses-aux.ads.m4 | 104 +
...minal_interface-curses-forms-field_types.ads.m4 | 238 +
...l_interface-curses-forms-field_user_data.ads.m4 | 70 +
...al_interface-curses-forms-form_user_data.ads.m4 | 70 +
.../gen/terminal_interface-curses-forms.ads.m4 | 696 +
...al_interface-curses-menus-item_user_data.ads.m4 | 75 +
...al_interface-curses-menus-menu_user_data.ads.m4 | 70 +
.../gen/terminal_interface-curses-menus.ads.m4 | 594 +
.../gen/terminal_interface-curses-mouse.ads.m4 | 173 +
...rminal_interface-curses-panels-user_data.ads.m4 | 70 +
.../gen/terminal_interface-curses-panels.ads.m4 | 146 +
.../Ada95/gen/terminal_interface-curses.ads.m4 | 1388 ++
ncurses-5.2/Ada95/samples/Makefile.in | 137 +
ncurses-5.2/Ada95/samples/README | 6 +
ncurses-5.2/Ada95/samples/explain.txt | 186 +
ncurses-5.2/Ada95/samples/rain.adb | 161 +
ncurses-5.2/Ada95/samples/rain.ads | 42 +
.../samples/sample-curses_demo-attributes.adb | 122 +
.../samples/sample-curses_demo-attributes.ads | 45 +
.../Ada95/samples/sample-curses_demo-mouse.adb | 220 +
.../Ada95/samples/sample-curses_demo-mouse.ads | 45 +
ncurses-5.2/Ada95/samples/sample-curses_demo.adb | 142 +
ncurses-5.2/Ada95/samples/sample-curses_demo.ads | 45 +
ncurses-5.2/Ada95/samples/sample-explanation.adb | 408 +
ncurses-5.2/Ada95/samples/sample-explanation.ads | 59 +
ncurses-5.2/Ada95/samples/sample-form_demo-aux.adb | 259 +
ncurses-5.2/Ada95/samples/sample-form_demo-aux.ads | 92 +
.../Ada95/samples/sample-form_demo-handler.adb | 97 +
.../Ada95/samples/sample-form_demo-handler.ads | 64 +
ncurses-5.2/Ada95/samples/sample-form_demo.adb | 134 +
ncurses-5.2/Ada95/samples/sample-form_demo.ads | 45 +
.../Ada95/samples/sample-function_key_setting.adb | 213 +
.../Ada95/samples/sample-function_key_setting.ads | 82 +
.../Ada95/samples/sample-header_handler.adb | 180 +
.../Ada95/samples/sample-header_handler.ads | 53 +
ncurses-5.2/Ada95/samples/sample-helpers.adb | 69 +
ncurses-5.2/Ada95/samples/sample-helpers.ads | 54 +
.../Ada95/samples/sample-keyboard_handler.adb | 191 +
.../Ada95/samples/sample-keyboard_handler.ads | 55 +
ncurses-5.2/Ada95/samples/sample-manifest.ads | 67 +
ncurses-5.2/Ada95/samples/sample-menu_demo-aux.adb | 204 +
ncurses-5.2/Ada95/samples/sample-menu_demo-aux.ads | 71 +
.../Ada95/samples/sample-menu_demo-handler.adb | 107 +
.../Ada95/samples/sample-menu_demo-handler.ads | 64 +
ncurses-5.2/Ada95/samples/sample-menu_demo.adb | 390 +
ncurses-5.2/Ada95/samples/sample-menu_demo.ads | 45 +
ncurses-5.2/Ada95/samples/sample-my_field_type.adb | 65 +
ncurses-5.2/Ada95/samples/sample-my_field_type.ads | 62 +
ncurses-5.2/Ada95/samples/sample-text_io_demo.adb | 180 +
ncurses-5.2/Ada95/samples/sample-text_io_demo.ads | 45 +
ncurses-5.2/Ada95/samples/sample.adb | 218 +
ncurses-5.2/Ada95/samples/sample.ads | 43 +
ncurses-5.2/Ada95/samples/status.adb | 56 +
ncurses-5.2/Ada95/samples/status.ads | 59 +
ncurses-5.2/Ada95/samples/tour.adb | 46 +
ncurses-5.2/Ada95/samples/tour.ads | 41 +
ncurses-5.2/Ada95/src/Makefile.in | 352 +
.../Ada95/src/terminal_interface-curses-aux.adb | 116 +
...al_interface-curses-forms-field_types-alpha.adb | 68 +
...al_interface-curses-forms-field_types-alpha.ads | 53 +
...rface-curses-forms-field_types-alphanumeric.adb | 68 +
...rface-curses-forms-field_types-alphanumeric.ads | 54 +
...ce-curses-forms-field_types-enumeration-ada.adb | 80 +
...ce-curses-forms-field_types-enumeration-ada.ads | 59 +
...erface-curses-forms-field_types-enumeration.adb | 119 +
...erface-curses-forms-field_types-enumeration.ads | 98 +
...interface-curses-forms-field_types-intfield.adb | 72 +
...interface-curses-forms-field_types-intfield.ads | 55 +
...rface-curses-forms-field_types-ipv4_address.adb | 68 +
...rface-curses-forms-field_types-ipv4_address.ads | 51 +
..._interface-curses-forms-field_types-numeric.adb | 74 +
..._interface-curses-forms-field_types-numeric.ads | 55 +
...l_interface-curses-forms-field_types-regexp.adb | 71 +
...l_interface-curses-forms-field_types-regexp.ads | 55 +
...erface-curses-forms-field_types-user-choice.adb | 110 +
...erface-curses-forms-field_types-user-choice.ads | 96 +
...nal_interface-curses-forms-field_types-user.adb | 132 +
...nal_interface-curses-forms-field_types-user.ads | 97 +
...terminal_interface-curses-forms-field_types.adb | 296 +
...inal_interface-curses-forms-field_user_data.adb | 85 +
...minal_interface-curses-forms-form_user_data.adb | 86 +
.../Ada95/src/terminal_interface-curses-forms.adb | 1160 ++
...minal_interface-curses-menus-item_user_data.adb | 77 +
...minal_interface-curses-menus-menu_user_data.adb | 76 +
.../Ada95/src/terminal_interface-curses-menus.adb | 1021 +
.../Ada95/src/terminal_interface-curses-mouse.adb | 214 +
.../terminal_interface-curses-panels-user_data.adb | 78 +
.../Ada95/src/terminal_interface-curses-panels.adb | 164 +
.../src/terminal_interface-curses-text_io-aux.adb | 128 +
.../src/terminal_interface-curses-text_io-aux.ads | 55 +
...erminal_interface-curses-text_io-complex_io.adb | 73 +
...erminal_interface-curses-text_io-complex_io.ads | 70 +
...erminal_interface-curses-text_io-decimal_io.adb | 75 +
...erminal_interface-curses-text_io-decimal_io.ads | 66 +
...nal_interface-curses-text_io-enumeration_io.adb | 80 +
...nal_interface-curses-text_io-enumeration_io.ads | 63 +
.../terminal_interface-curses-text_io-fixed_io.adb | 75 +
.../terminal_interface-curses-text_io-fixed_io.ads | 66 +
.../terminal_interface-curses-text_io-float_io.adb | 76 +
.../terminal_interface-curses-text_io-float_io.ads | 66 +
...erminal_interface-curses-text_io-integer_io.adb | 70 +
...erminal_interface-curses-text_io-integer_io.ads | 63 +
...erminal_interface-curses-text_io-modular_io.adb | 70 +
...erminal_interface-curses-text_io-modular_io.ads | 63 +
.../src/terminal_interface-curses-text_io.adb | 336 +
.../src/terminal_interface-curses-text_io.ads | 136 +
.../Ada95/src/terminal_interface-curses.adb | 2414 +++
ncurses-5.2/Ada95/src/terminal_interface.ads | 48 +
ncurses-5.2/INSTALL | 1059 ++
ncurses-5.2/MANIFEST | 866 +
ncurses-5.2/Makefile.glibc | 403 +
ncurses-5.2/Makefile.in | 92 +
ncurses-5.2/Makefile.os2 | 234 +
ncurses-5.2/NEWS | 4584 +++++
ncurses-5.2/README | 175 +
ncurses-5.2/README.emx | 45 +
ncurses-5.2/README.glibc | 5 +
ncurses-5.2/TO-DO | 251 +
ncurses-5.2/aclocal.m4 | 2573 +++
ncurses-5.2/announce.html.in | 593 +
ncurses-5.2/c++/Makefile.in | 213 +
ncurses-5.2/c++/NEWS | 42 +
ncurses-5.2/c++/PROBLEMS | 5 +
ncurses-5.2/c++/README-first | 58 +
ncurses-5.2/c++/cursesapp.cc | 146 +
ncurses-5.2/c++/cursesapp.h | 163 +
ncurses-5.2/c++/cursesf.cc | 426 +
ncurses-5.2/c++/cursesf.h | 824 +
ncurses-5.2/c++/cursesm.cc | 383 +
ncurses-5.2/c++/cursesm.h | 592 +
ncurses-5.2/c++/cursesmain.cc | 51 +
ncurses-5.2/c++/cursesp.cc | 124 +
ncurses-5.2/c++/cursesp.h | 218 +
ncurses-5.2/c++/cursespad.cc | 270 +
ncurses-5.2/c++/cursesw.cc | 434 +
ncurses-5.2/c++/cursesw.h | 1375 ++
ncurses-5.2/c++/cursslk.cc | 122 +
ncurses-5.2/c++/cursslk.h | 205 +
ncurses-5.2/c++/demo.cc | 449 +
ncurses-5.2/c++/edit_cfg.sh | 67 +
ncurses-5.2/c++/etip.h.in | 273 +
ncurses-5.2/c++/headers | 39 +
ncurses-5.2/c++/internal.h | 47 +
ncurses-5.2/c++/modules | 43 +
ncurses-5.2/config.guess | 1276 ++
ncurses-5.2/config.sub | 1328 ++
ncurses-5.2/configure | 8083 ++++++++
ncurses-5.2/configure.in | 1171 ++
ncurses-5.2/convert_configure.pl | 90 +
ncurses-5.2/dist.mk | 118 +
ncurses-5.2/doc/hackguide.doc | 687 +
ncurses-5.2/doc/html/Ada95.html | 172 +
ncurses-5.2/doc/html/ada/files.htm | 5 +
ncurses-5.2/doc/html/ada/files/T.htm | 69 +
ncurses-5.2/doc/html/ada/funcs.htm | 27 +
ncurses-5.2/doc/html/ada/funcs/A.htm | 18 +
ncurses-5.2/doc/html/ada/funcs/B.htm | 10 +
ncurses-5.2/doc/html/ada/funcs/C.htm | 33 +
ncurses-5.2/doc/html/ada/funcs/D.htm | 22 +
ncurses-5.2/doc/html/ada/funcs/E.htm | 11 +
ncurses-5.2/doc/html/ada/funcs/F.htm | 46 +
ncurses-5.2/doc/html/ada/funcs/G.htm | 21 +
ncurses-5.2/doc/html/ada/funcs/H.htm | 12 +
ncurses-5.2/doc/html/ada/funcs/I.htm | 31 +
ncurses-5.2/doc/html/ada/funcs/K.htm | 10 +
ncurses-5.2/doc/html/ada/funcs/L.htm | 14 +
ncurses-5.2/doc/html/ada/funcs/M.htm | 44 +
ncurses-5.2/doc/html/ada/funcs/N.htm | 28 +
ncurses-5.2/doc/html/ada/funcs/O.htm | 9 +
ncurses-5.2/doc/html/ada/funcs/P.htm | 39 +
ncurses-5.2/doc/html/ada/funcs/Q.htm | 7 +
ncurses-5.2/doc/html/ada/funcs/R.htm | 20 +
ncurses-5.2/doc/html/ada/funcs/S.htm | 93 +
ncurses-5.2/doc/html/ada/funcs/T.htm | 19 +
ncurses-5.2/doc/html/ada/funcs/U.htm | 11 +
ncurses-5.2/doc/html/ada/funcs/V.htm | 7 +
ncurses-5.2/doc/html/ada/funcs/W.htm | 51 +
ncurses-5.2/doc/html/ada/index.htm | 41 +
ncurses-5.2/doc/html/ada/main.htm | 66 +
ncurses-5.2/doc/html/ada/table.html | 325 +
.../ada/terminal_interface-curses-aux__adb.htm | 121 +
.../ada/terminal_interface-curses-aux__ads.htm | 130 +
...terface-curses-forms-field_types-alpha__adb.htm | 73 +
...terface-curses-forms-field_types-alpha__ads.htm | 58 +
...-curses-forms-field_types-alphanumeric__adb.htm | 73 +
...-curses-forms-field_types-alphanumeric__ads.htm | 59 +
...rses-forms-field_types-enumeration-ada__adb.htm | 85 +
...rses-forms-field_types-enumeration-ada__ads.htm | 64 +
...e-curses-forms-field_types-enumeration__adb.htm | 124 +
...e-curses-forms-field_types-enumeration__ads.htm | 103 +
...face-curses-forms-field_types-intfield__adb.htm | 77 +
...face-curses-forms-field_types-intfield__ads.htm | 60 +
...-curses-forms-field_types-ipv4_address__adb.htm | 73 +
...-curses-forms-field_types-ipv4_address__ads.htm | 56 +
...rface-curses-forms-field_types-numeric__adb.htm | 79 +
...rface-curses-forms-field_types-numeric__ads.htm | 60 +
...erface-curses-forms-field_types-regexp__adb.htm | 76 +
...erface-curses-forms-field_types-regexp__ads.htm | 60 +
...e-curses-forms-field_types-user-choice__adb.htm | 115 +
...e-curses-forms-field_types-user-choice__ads.htm | 101 +
...nterface-curses-forms-field_types-user__adb.htm | 137 +
...nterface-curses-forms-field_types-user__ads.htm | 102 +
...nal_interface-curses-forms-field_types__adb.htm | 301 +
...nal_interface-curses-forms-field_types__ads.htm | 245 +
...interface-curses-forms-field_user_data__adb.htm | 90 +
...interface-curses-forms-field_user_data__ads.htm | 75 +
..._interface-curses-forms-form_user_data__adb.htm | 91 +
..._interface-curses-forms-form_user_data__ads.htm | 75 +
.../ada/terminal_interface-curses-forms__adb.htm | 1165 ++
.../ada/terminal_interface-curses-forms__ads.htm | 783 +
..._interface-curses-menus-item_user_data__adb.htm | 82 +
..._interface-curses-menus-item_user_data__ads.htm | 80 +
..._interface-curses-menus-menu_user_data__adb.htm | 81 +
..._interface-curses-menus-menu_user_data__ads.htm | 75 +
.../ada/terminal_interface-curses-menus__adb.htm | 1026 +
.../ada/terminal_interface-curses-menus__ads.htm | 673 +
.../ada/terminal_interface-curses-mouse__adb.htm | 219 +
.../ada/terminal_interface-curses-mouse__ads.htm | 225 +
...inal_interface-curses-panels-user_data__adb.htm | 83 +
...inal_interface-curses-panels-user_data__ads.htm | 75 +
.../ada/terminal_interface-curses-panels__adb.htm | 169 +
.../ada/terminal_interface-curses-panels__ads.htm | 152 +
.../terminal_interface-curses-text_io-aux__adb.htm | 133 +
.../terminal_interface-curses-text_io-aux__ads.htm | 60 +
...al_interface-curses-text_io-complex_io__adb.htm | 78 +
...al_interface-curses-text_io-complex_io__ads.htm | 75 +
...al_interface-curses-text_io-decimal_io__adb.htm | 80 +
...al_interface-curses-text_io-decimal_io__ads.htm | 71 +
...nterface-curses-text_io-enumeration_io__adb.htm | 85 +
...nterface-curses-text_io-enumeration_io__ads.htm | 68 +
...inal_interface-curses-text_io-fixed_io__adb.htm | 80 +
...inal_interface-curses-text_io-fixed_io__ads.htm | 71 +
...inal_interface-curses-text_io-float_io__adb.htm | 81 +
...inal_interface-curses-text_io-float_io__ads.htm | 71 +
...al_interface-curses-text_io-integer_io__adb.htm | 75 +
...al_interface-curses-text_io-integer_io__ads.htm | 68 +
...al_interface-curses-text_io-modular_io__adb.htm | 75 +
...al_interface-curses-text_io-modular_io__ads.htm | 68 +
.../ada/terminal_interface-curses-text_io__adb.htm | 341 +
.../ada/terminal_interface-curses-text_io__ads.htm | 141 +
.../html/ada/terminal_interface-curses__adb.htm | 2419 +++
.../html/ada/terminal_interface-curses__ads.htm | 1744 ++
.../doc/html/ada/terminal_interface__ads.htm | 53 +
ncurses-5.2/doc/html/announce.html | 593 +
ncurses-5.2/doc/html/hackguide.html | 890 +
ncurses-5.2/doc/html/index.html | 30 +
ncurses-5.2/doc/html/man/captoinfo.1m.html | 190 +
ncurses-5.2/doc/html/man/clear.1.html | 74 +
ncurses-5.2/doc/html/man/curs_addch.3x.html | 189 +
ncurses-5.2/doc/html/man/curs_addchstr.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_addstr.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_attr.3x.html | 186 +
ncurses-5.2/doc/html/man/curs_beep.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_bkgd.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_border.3x.html | 135 +
ncurses-5.2/doc/html/man/curs_clear.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_color.3x.html | 242 +
ncurses-5.2/doc/html/man/curs_delch.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_deleteln.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_extend.3x.html | 78 +
ncurses-5.2/doc/html/man/curs_getch.3x.html | 296 +
ncurses-5.2/doc/html/man/curs_getstr.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_getyx.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_inch.3x.html | 78 +
ncurses-5.2/doc/html/man/curs_inchstr.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_initscr.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_inopts.3x.html | 242 +
ncurses-5.2/doc/html/man/curs_insch.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_insstr.3x.html | 135 +
ncurses-5.2/doc/html/man/curs_instr.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_kernel.3x.html | 188 +
ncurses-5.2/doc/html/man/curs_mouse.3x.html | 242 +
ncurses-5.2/doc/html/man/curs_move.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_outopts.3x.html | 188 +
ncurses-5.2/doc/html/man/curs_overlay.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_pad.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_print.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_printw.3x.html | 78 +
ncurses-5.2/doc/html/man/curs_refresh.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_scanw.3x.html | 78 +
ncurses-5.2/doc/html/man/curs_scr_dump.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_scroll.3x.html | 80 +
ncurses-5.2/doc/html/man/curs_slk.3x.html | 188 +
ncurses-5.2/doc/html/man/curs_termattrs.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_termcap.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_terminfo.3x.html | 296 +
ncurses-5.2/doc/html/man/curs_touch.3x.html | 135 +
ncurses-5.2/doc/html/man/curs_trace.3x.html | 132 +
ncurses-5.2/doc/html/man/curs_util.3x.html | 134 +
ncurses-5.2/doc/html/man/curs_window.3x.html | 190 +
ncurses-5.2/doc/html/man/default_colors.3x.html | 136 +
ncurses-5.2/doc/html/man/define_key.3x.html | 80 +
ncurses-5.2/doc/html/man/form.3x.html | 245 +
ncurses-5.2/doc/html/man/form_cursor.3x.html | 82 +
ncurses-5.2/doc/html/man/form_data.3x.html | 80 +
ncurses-5.2/doc/html/man/form_driver.3x.html | 299 +
ncurses-5.2/doc/html/man/form_field.3x.html | 136 +
.../doc/html/man/form_field_attributes.3x.html | 136 +
ncurses-5.2/doc/html/man/form_field_buffer.3x.html | 137 +
ncurses-5.2/doc/html/man/form_field_info.3x.html | 82 +
ncurses-5.2/doc/html/man/form_field_just.3x.html | 82 +
ncurses-5.2/doc/html/man/form_field_new.3x.html | 136 +
ncurses-5.2/doc/html/man/form_field_opts.3x.html | 134 +
.../doc/html/man/form_field_userptr.3x.html | 82 +
.../doc/html/man/form_field_validation.3x.html | 190 +
ncurses-5.2/doc/html/man/form_fieldtype.3x.html | 136 +
ncurses-5.2/doc/html/man/form_hook.3x.html | 136 +
ncurses-5.2/doc/html/man/form_new.3x.html | 82 +
ncurses-5.2/doc/html/man/form_new_page.3x.html | 82 +
ncurses-5.2/doc/html/man/form_opts.3x.html | 136 +
ncurses-5.2/doc/html/man/form_page.3x.html | 136 +
ncurses-5.2/doc/html/man/form_post.3x.html | 136 +
ncurses-5.2/doc/html/man/form_requestname.3x.html | 82 +
ncurses-5.2/doc/html/man/form_userptr.3x.html | 82 +
ncurses-5.2/doc/html/man/form_win.3x.html | 136 +
ncurses-5.2/doc/html/man/infocmp.1m.html | 406 +
ncurses-5.2/doc/html/man/infotocap.1m.html | 78 +
ncurses-5.2/doc/html/man/keybound.3x.html | 80 +
ncurses-5.2/doc/html/man/keyok.3x.html | 80 +
ncurses-5.2/doc/html/man/menu.3x.html | 244 +
ncurses-5.2/doc/html/man/menu_attributes.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_cursor.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_driver.3x.html | 190 +
ncurses-5.2/doc/html/man/menu_format.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_hook.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_items.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_mark.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_new.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_opts.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_pattern.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_post.3x.html | 136 +
ncurses-5.2/doc/html/man/menu_requestname.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_spacing.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_userptr.3x.html | 82 +
ncurses-5.2/doc/html/man/menu_win.3x.html | 136 +
ncurses-5.2/doc/html/man/mitem_current.3x.html | 137 +
ncurses-5.2/doc/html/man/mitem_name.3x.html | 82 +
ncurses-5.2/doc/html/man/mitem_new.3x.html | 82 +
ncurses-5.2/doc/html/man/mitem_opts.3x.html | 82 +
ncurses-5.2/doc/html/man/mitem_userptr.3x.html | 82 +
ncurses-5.2/doc/html/man/mitem_value.3x.html | 82 +
ncurses-5.2/doc/html/man/mitem_visible.3x.html | 80 +
ncurses-5.2/doc/html/man/ncurses.3x.html | 899 +
ncurses-5.2/doc/html/man/panel.3x.html | 194 +
ncurses-5.2/doc/html/man/resizeterm.3x.html | 80 +
ncurses-5.2/doc/html/man/term.5.html | 184 +
ncurses-5.2/doc/html/man/term.7.html | 239 +
ncurses-5.2/doc/html/man/terminfo.5.html | 2242 +++
ncurses-5.2/doc/html/man/tic.1m.html | 297 +
ncurses-5.2/doc/html/man/toe.1m.html | 76 +
ncurses-5.2/doc/html/man/tput.1.html | 246 +
ncurses-5.2/doc/html/man/tset.1.html | 303 +
ncurses-5.2/doc/html/man/wresize.3x.html | 80 +
ncurses-5.2/doc/html/ncurses-intro.html | 2686 +++
ncurses-5.2/doc/ncurses-intro.doc | 2502 +++
ncurses-5.2/form/Makefile.in | 155 +
ncurses-5.2/form/READ.ME | 15 +
ncurses-5.2/form/fld_arg.c | 91 +
ncurses-5.2/form/fld_attr.c | 111 +
ncurses-5.2/form/fld_current.c | 124 +
ncurses-5.2/form/fld_def.c | 346 +
ncurses-5.2/form/fld_dup.c | 97 +
ncurses-5.2/form/fld_ftchoice.c | 62 +
ncurses-5.2/form/fld_ftlink.c | 83 +
ncurses-5.2/form/fld_info.c | 91 +
ncurses-5.2/form/fld_just.c | 81 +
ncurses-5.2/form/fld_link.c | 90 +
ncurses-5.2/form/fld_max.c | 74 +
ncurses-5.2/form/fld_move.c | 62 +
ncurses-5.2/form/fld_newftyp.c | 125 +
ncurses-5.2/form/fld_opts.c | 124 +
ncurses-5.2/form/fld_pad.c | 78 +
ncurses-5.2/form/fld_page.c | 76 +
ncurses-5.2/form/fld_stat.c | 73 +
ncurses-5.2/form/fld_type.c | 92 +
ncurses-5.2/form/fld_user.c | 67 +
ncurses-5.2/form/form.h | 388 +
ncurses-5.2/form/form.priv.h | 128 +
ncurses-5.2/form/frm_cursor.c | 66 +
ncurses-5.2/form/frm_data.c | 181 +
ncurses-5.2/form/frm_def.c | 376 +
ncurses-5.2/form/frm_driver.c | 3843 ++++
ncurses-5.2/form/frm_hook.c | 140 +
ncurses-5.2/form/frm_opts.c | 116 +
ncurses-5.2/form/frm_page.c | 100 +
ncurses-5.2/form/frm_post.c | 117 +
ncurses-5.2/form/frm_req_name.c | 163 +
ncurses-5.2/form/frm_scale.c | 63 +
ncurses-5.2/form/frm_sub.c | 69 +
ncurses-5.2/form/frm_user.c | 67 +
ncurses-5.2/form/frm_win.c | 70 +
ncurses-5.2/form/fty_alnum.c | 137 +
ncurses-5.2/form/fty_alpha.c | 138 +
ncurses-5.2/form/fty_enum.c | 295 +
ncurses-5.2/form/fty_int.c | 160 +
ncurses-5.2/form/fty_ipv4.c | 81 +
ncurses-5.2/form/fty_num.c | 195 +
ncurses-5.2/form/fty_regex.c | 257 +
ncurses-5.2/form/headers | 31 +
ncurses-5.2/form/llib-lform | 694 +
ncurses-5.2/form/modules | 73 +
ncurses-5.2/include/Caps | 1314 ++
ncurses-5.2/include/MKhashsize.sh | 14 +
ncurses-5.2/include/MKncurses_def.sh | 80 +
ncurses-5.2/include/MKparametrized.sh | 35 +
ncurses-5.2/include/MKterm.h.awk.in | 315 +
ncurses-5.2/include/Makefile.in | 111 +
ncurses-5.2/include/capdefaults.c | 84 +
ncurses-5.2/include/curses.h.in | 1370 ++
ncurses-5.2/include/edit_cfg.sh | 65 +
ncurses-5.2/include/headers | 34 +
ncurses-5.2/include/nc_alloc.h | 83 +
ncurses-5.2/include/nc_panel.h | 66 +
ncurses-5.2/include/ncurses_cfg.hin | 62 +
ncurses-5.2/include/ncurses_defs | 151 +
ncurses-5.2/include/term_entry.h | 161 +
ncurses-5.2/include/termcap.h.in | 70 +
ncurses-5.2/include/tic.h | 299 +
ncurses-5.2/include/unctrl.h.in | 63 +
ncurses-5.2/install-sh | 250 +
ncurses-5.2/man/MKterminfo.sh | 105 +
ncurses-5.2/man/Makefile.in | 75 +
ncurses-5.2/man/captoinfo.1m | 189 +
ncurses-5.2/man/clear.1 | 48 +
ncurses-5.2/man/curs_addch.3x | 163 +
ncurses-5.2/man/curs_addchstr.3x | 83 +
ncurses-5.2/man/curs_addstr.3x | 82 +
ncurses-5.2/man/curs_attr.3x | 221 +
ncurses-5.2/man/curs_beep.3x | 63 +
ncurses-5.2/man/curs_bkgd.3x | 102 +
ncurses-5.2/man/curs_border.3x | 110 +
ncurses-5.2/man/curs_clear.3x | 94 +
ncurses-5.2/man/curs_color.3x | 216 +
ncurses-5.2/man/curs_delch.3x | 70 +
ncurses-5.2/man/curs_deleteln.3x | 87 +
ncurses-5.2/man/curs_extend.3x | 89 +
ncurses-5.2/man/curs_getch.3x | 277 +
ncurses-5.2/man/curs_getstr.3x | 107 +
ncurses-5.2/man/curs_getyx.3x | 72 +
ncurses-5.2/man/curs_inch.3x | 73 +
ncurses-5.2/man/curs_inchstr.3x | 88 +
ncurses-5.2/man/curs_initscr.3x | 124 +
ncurses-5.2/man/curs_inopts.3x | 214 +
ncurses-5.2/man/curs_insch.3x | 70 +
ncurses-5.2/man/curs_insstr.3x | 95 +
ncurses-5.2/man/curs_instr.3x | 89 +
ncurses-5.2/man/curs_kernel.3x | 159 +
ncurses-5.2/man/curs_mouse.3x | 217 +
ncurses-5.2/man/curs_move.3x | 63 +
ncurses-5.2/man/curs_outopts.3x | 169 +
ncurses-5.2/man/curs_overlay.3x | 76 +
ncurses-5.2/man/curs_pad.3x | 110 +
ncurses-5.2/man/curs_print.3x | 74 +
ncurses-5.2/man/curs_printw.3x | 80 +
ncurses-5.2/man/curs_refresh.3x | 115 +
ncurses-5.2/man/curs_scanw.3x | 81 +
ncurses-5.2/man/curs_scr_dump.3x | 94 +
ncurses-5.2/man/curs_scroll.3x | 79 +
ncurses-5.2/man/curs_slk.3x | 149 +
ncurses-5.2/man/curs_termattrs.3x | 107 +
ncurses-5.2/man/curs_termcap.3x | 118 +
ncurses-5.2/man/curs_terminfo.3x | 272 +
ncurses-5.2/man/curs_touch.3x | 96 +
ncurses-5.2/man/curs_trace.3x | 150 +
ncurses-5.2/man/curs_util.3x | 114 +
ncurses-5.2/man/curs_window.3x | 159 +
ncurses-5.2/man/default_colors.3x | 133 +
ncurses-5.2/man/define_key.3x | 70 +
ncurses-5.2/man/form.3x | 200 +
ncurses-5.2/man/form_cursor.3x | 74 +
ncurses-5.2/man/form_data.3x | 63 +
ncurses-5.2/man/form_driver.3x | 272 +
ncurses-5.2/man/form_field.3x | 97 +
ncurses-5.2/man/form_field_attributes.3x | 91 +
ncurses-5.2/man/form_field_buffer.3x | 99 +
ncurses-5.2/man/form_field_info.3x | 84 +
ncurses-5.2/man/form_field_just.3x | 78 +
ncurses-5.2/man/form_field_new.3x | 96 +
ncurses-5.2/man/form_field_opts.3x | 120 +
ncurses-5.2/man/form_field_userptr.3x | 73 +
ncurses-5.2/man/form_field_validation.3x | 127 +
ncurses-5.2/man/form_fieldtype.3x | 126 +
ncurses-5.2/man/form_hook.3x | 100 +
ncurses-5.2/man/form_new.3x | 79 +
ncurses-5.2/man/form_new_page.3x | 77 +
ncurses-5.2/man/form_opts.3x | 90 +
ncurses-5.2/man/form_page.3x | 95 +
ncurses-5.2/man/form_post.3x | 90 +
ncurses-5.2/man/form_requestname.3x | 69 +
ncurses-5.2/man/form_userptr.3x | 73 +
ncurses-5.2/man/form_win.3x | 95 +
ncurses-5.2/man/infocmp.1m | 378 +
ncurses-5.2/man/infotocap.1m | 74 +
ncurses-5.2/man/keybound.3x | 67 +
ncurses-5.2/man/keyok.3x | 69 +
ncurses-5.2/man/make_sed.sh | 83 +
ncurses-5.2/man/man_db.renames | 117 +
ncurses-5.2/man/manlinks.sed | 68 +
ncurses-5.2/man/menu.3x | 190 +
ncurses-5.2/man/menu_attributes.3x | 100 +
ncurses-5.2/man/menu_cursor.3x | 73 +
ncurses-5.2/man/menu_driver.3x | 170 +
ncurses-5.2/man/menu_format.3x | 84 +
ncurses-5.2/man/menu_hook.3x | 101 +
ncurses-5.2/man/menu_items.3x | 91 +
ncurses-5.2/man/menu_mark.3x | 84 +
ncurses-5.2/man/menu_new.3x | 79 +
ncurses-5.2/man/menu_opts.3x | 104 +
ncurses-5.2/man/menu_pattern.3x | 82 +
ncurses-5.2/man/menu_post.3x | 91 +
ncurses-5.2/man/menu_requestname.3x | 69 +
ncurses-5.2/man/menu_spacing.3x | 84 +
ncurses-5.2/man/menu_userptr.3x | 73 +
ncurses-5.2/man/menu_win.3x | 95 +
ncurses-5.2/man/mitem_current.3x | 101 +
ncurses-5.2/man/mitem_name.3x | 64 +
ncurses-5.2/man/mitem_new.3x | 83 +
ncurses-5.2/man/mitem_opts.3x | 84 +
ncurses-5.2/man/mitem_userptr.3x | 72 +
ncurses-5.2/man/mitem_value.3x | 76 +
ncurses-5.2/man/mitem_visible.3x | 59 +
ncurses-5.2/man/ncurses.3x | 927 +
ncurses-5.2/man/panel.3x | 182 +
ncurses-5.2/man/resizeterm.3x | 87 +
ncurses-5.2/man/term.5 | 208 +
ncurses-5.2/man/term.7 | 204 +
ncurses-5.2/man/terminfo.head | 95 +
ncurses-5.2/man/terminfo.tail | 1499 ++
ncurses-5.2/man/tic.1m | 301 +
ncurses-5.2/man/toe.1m | 81 +
ncurses-5.2/man/tput.1 | 256 +
ncurses-5.2/man/tset.1 | 250 +
ncurses-5.2/man/wresize.3x | 70 +
ncurses-5.2/menu/Makefile.in | 157 +
ncurses-5.2/menu/READ.ME | 14 +
ncurses-5.2/menu/eti.h | 52 +
ncurses-5.2/menu/headers | 32 +
ncurses-5.2/menu/llib-lmenu | 508 +
ncurses-5.2/menu/m_attribs.c | 141 +
ncurses-5.2/menu/m_cursor.c | 110 +
ncurses-5.2/menu/m_driver.c | 540 +
ncurses-5.2/menu/m_format.c | 125 +
ncurses-5.2/menu/m_global.c | 483 +
ncurses-5.2/menu/m_hook.c | 149 +
ncurses-5.2/menu/m_item_cur.c | 106 +
ncurses-5.2/menu/m_item_nam.c | 68 +
ncurses-5.2/menu/m_item_new.c | 227 +
ncurses-5.2/menu/m_item_opt.c | 146 +
ncurses-5.2/menu/m_item_top.c | 102 +
ncurses-5.2/menu/m_item_use.c | 72 +
ncurses-5.2/menu/m_item_val.c | 100 +
ncurses-5.2/menu/m_item_vis.c | 66 +
ncurses-5.2/menu/m_items.c | 103 +
ncurses-5.2/menu/m_new.c | 108 +
ncurses-5.2/menu/m_opts.c | 170 +
ncurses-5.2/menu/m_pad.c | 90 +
ncurses-5.2/menu/m_pattern.c | 117 +
ncurses-5.2/menu/m_post.c | 366 +
ncurses-5.2/menu/m_req_name.c | 119 +
ncurses-5.2/menu/m_scale.c | 71 +
ncurses-5.2/menu/m_spacing.c | 98 +
ncurses-5.2/menu/m_sub.c | 80 +
ncurses-5.2/menu/m_userptr.c | 72 +
ncurses-5.2/menu/m_win.c | 80 +
ncurses-5.2/menu/menu.h | 254 +
ncurses-5.2/menu/menu.priv.h | 114 +
ncurses-5.2/menu/mf_common.h | 93 +
ncurses-5.2/menu/modules | 60 +
ncurses-5.2/misc/Makefile.in | 121 +
ncurses-5.2/misc/chkdef.cmd | 86 +
ncurses-5.2/misc/cleantic.cmd | 16 +
ncurses-5.2/misc/cmpdef.cmd | 106 +
ncurses-5.2/misc/emx.src | 825 +
ncurses-5.2/misc/form.def | 101 +
ncurses-5.2/misc/form.ref | 106 +
ncurses-5.2/misc/indent.pro | 35 +
ncurses-5.2/misc/makedef.cmd | 151 +
ncurses-5.2/misc/makellib | 162 +
ncurses-5.2/misc/menu.def | 81 +
ncurses-5.2/misc/menu.ref | 73 +
ncurses-5.2/misc/ncurses.def | 447 +
ncurses-5.2/misc/ncurses.ref | 572 +
ncurses-5.2/misc/panel.def | 20 +
ncurses-5.2/misc/panel.ref | 18 +
ncurses-5.2/misc/run_tic.in | 146 +
ncurses-5.2/misc/shlib | 87 +
ncurses-5.2/misc/tabset/std | 1 +
ncurses-5.2/misc/tabset/stdcrt | 1 +
ncurses-5.2/misc/tabset/vt100 | 3 +
ncurses-5.2/misc/tabset/vt300 | 3 +
ncurses-5.2/misc/tdlint | 111 +
ncurses-5.2/misc/terminfo.src | 18609 +++++++++++++++++++
ncurses-5.2/mk-0th.awk | 91 +
ncurses-5.2/mk-1st.awk | 311 +
ncurses-5.2/mk-2nd.awk | 115 +
ncurses-5.2/mkinstalldirs | 37 +
ncurses-5.2/ncurses/Makefile.in | 253 +
ncurses-5.2/ncurses/README | 2 +
ncurses-5.2/ncurses/SigAction.h | 117 +
ncurses-5.2/ncurses/base/MKkeyname.awk | 74 +
ncurses-5.2/ncurses/base/MKlib_gen.sh | 259 +
ncurses-5.2/ncurses/base/MKunctrl.awk | 69 +
ncurses-5.2/ncurses/base/README | 7 +
ncurses-5.2/ncurses/base/define_key.c | 59 +
ncurses-5.2/ncurses/base/keybound.c | 45 +
ncurses-5.2/ncurses/base/keyok.c | 72 +
ncurses-5.2/ncurses/base/lib_addch.c | 298 +
ncurses-5.2/ncurses/base/lib_addstr.c | 103 +
ncurses-5.2/ncurses/base/lib_beep.c | 73 +
ncurses-5.2/ncurses/base/lib_bkgd.c | 86 +
ncurses-5.2/ncurses/base/lib_box.c | 119 +
ncurses-5.2/ncurses/base/lib_chgat.c | 62 +
ncurses-5.2/ncurses/base/lib_clear.c | 55 +
ncurses-5.2/ncurses/base/lib_clearok.c | 56 +
ncurses-5.2/ncurses/base/lib_clrbot.c | 76 +
ncurses-5.2/ncurses/base/lib_clreol.c | 91 +
ncurses-5.2/ncurses/base/lib_color.c | 482 +
ncurses-5.2/ncurses/base/lib_colorset.c | 58 +
ncurses-5.2/ncurses/base/lib_delch.c | 68 +
ncurses-5.2/ncurses/base/lib_delwin.c | 72 +
ncurses-5.2/ncurses/base/lib_dft_fgbg.c | 71 +
ncurses-5.2/ncurses/base/lib_echo.c | 60 +
ncurses-5.2/ncurses/base/lib_endwin.c | 61 +
ncurses-5.2/ncurses/base/lib_erase.c | 73 +
ncurses-5.2/ncurses/base/lib_flash.c | 73 +
ncurses-5.2/ncurses/base/lib_freeall.c | 139 +
ncurses-5.2/ncurses/base/lib_getch.c | 388 +
ncurses-5.2/ncurses/base/lib_getstr.c | 192 +
ncurses-5.2/ncurses/base/lib_hline.c | 77 +
ncurses-5.2/ncurses/base/lib_immedok.c | 54 +
ncurses-5.2/ncurses/base/lib_inchstr.c | 62 +
ncurses-5.2/ncurses/base/lib_initscr.c | 78 +
ncurses-5.2/ncurses/base/lib_insch.c | 67 +
ncurses-5.2/ncurses/base/lib_insdel.c | 62 +
ncurses-5.2/ncurses/base/lib_insstr.c | 81 +
ncurses-5.2/ncurses/base/lib_instr.c | 73 +
ncurses-5.2/ncurses/base/lib_isendwin.c | 51 +
ncurses-5.2/ncurses/base/lib_leaveok.c | 56 +
ncurses-5.2/ncurses/base/lib_mouse.c | 1004 +
ncurses-5.2/ncurses/base/lib_move.c | 61 +
ncurses-5.2/ncurses/base/lib_mvwin.c | 109 +
ncurses-5.2/ncurses/base/lib_newterm.c | 227 +
ncurses-5.2/ncurses/base/lib_newwin.c | 286 +
ncurses-5.2/ncurses/base/lib_nl.c | 79 +
ncurses-5.2/ncurses/base/lib_overlay.c | 161 +
ncurses-5.2/ncurses/base/lib_pad.c | 292 +
ncurses-5.2/ncurses/base/lib_printw.c | 110 +
ncurses-5.2/ncurses/base/lib_redrawln.c | 69 +
ncurses-5.2/ncurses/base/lib_refresh.c | 183 +
ncurses-5.2/ncurses/base/lib_restart.c | 91 +
ncurses-5.2/ncurses/base/lib_scanw.c | 111 +
ncurses-5.2/ncurses/base/lib_screen.c | 198 +
ncurses-5.2/ncurses/base/lib_scroll.c | 120 +
ncurses-5.2/ncurses/base/lib_scrollok.c | 56 +
ncurses-5.2/ncurses/base/lib_scrreg.c | 60 +
ncurses-5.2/ncurses/base/lib_set_term.c | 419 +
ncurses-5.2/ncurses/base/lib_slk.c | 214 +
ncurses-5.2/ncurses/base/lib_slkatr_set.c | 56 +
ncurses-5.2/ncurses/base/lib_slkatrof.c | 55 +
ncurses-5.2/ncurses/base/lib_slkatron.c | 55 +
ncurses-5.2/ncurses/base/lib_slkatrset.c | 55 +
ncurses-5.2/ncurses/base/lib_slkattr.c | 54 +
ncurses-5.2/ncurses/base/lib_slkclear.c | 62 +
ncurses-5.2/ncurses/base/lib_slkcolor.c | 54 +
ncurses-5.2/ncurses/base/lib_slkinit.c | 51 +
ncurses-5.2/ncurses/base/lib_slklab.c | 51 +
ncurses-5.2/ncurses/base/lib_slkrefr.c | 126 +
ncurses-5.2/ncurses/base/lib_slkset.c | 95 +
ncurses-5.2/ncurses/base/lib_slktouch.c | 53 +
ncurses-5.2/ncurses/base/lib_touch.c | 87 +
ncurses-5.2/ncurses/base/lib_ungetch.c | 74 +
ncurses-5.2/ncurses/base/lib_vline.c | 76 +
ncurses-5.2/ncurses/base/lib_wattroff.c | 55 +
ncurses-5.2/ncurses/base/lib_wattron.c | 55 +
ncurses-5.2/ncurses/base/lib_winch.c | 53 +
ncurses-5.2/ncurses/base/lib_window.c | 221 +
ncurses-5.2/ncurses/base/memmove.c | 63 +
ncurses-5.2/ncurses/base/nc_panel.c | 41 +
ncurses-5.2/ncurses/base/resizeterm.c | 121 +
ncurses-5.2/ncurses/base/safe_sprintf.c | 239 +
ncurses-5.2/ncurses/base/sigaction.c | 106 +
ncurses-5.2/ncurses/base/tries.c | 138 +
ncurses-5.2/ncurses/base/version.c | 47 +
ncurses-5.2/ncurses/base/vsscanf.c | 47 +
ncurses-5.2/ncurses/base/wresize.c | 179 +
ncurses-5.2/ncurses/curses.priv.h | 838 +
ncurses-5.2/ncurses/fifo_defs.h | 59 +
ncurses-5.2/ncurses/llib-lncurses | 3021 +++
ncurses-5.2/ncurses/modules | 189 +
ncurses-5.2/ncurses/tinfo/MKcaptab.awk | 70 +
ncurses-5.2/ncurses/tinfo/MKfallback.sh | 75 +
ncurses-5.2/ncurses/tinfo/MKnames.awk | 98 +
ncurses-5.2/ncurses/tinfo/README | 8 +
ncurses-5.2/ncurses/tinfo/access.c | 94 +
ncurses-5.2/ncurses/tinfo/add_tries.c | 125 +
ncurses-5.2/ncurses/tinfo/alloc_entry.c | 225 +
ncurses-5.2/ncurses/tinfo/alloc_ttype.c | 489 +
ncurses-5.2/ncurses/tinfo/captoinfo.c | 831 +
ncurses-5.2/ncurses/tinfo/comp_error.c | 132 +
ncurses-5.2/ncurses/tinfo/comp_expand.c | 189 +
ncurses-5.2/ncurses/tinfo/comp_hash.c | 325 +
ncurses-5.2/ncurses/tinfo/comp_parse.c | 484 +
ncurses-5.2/ncurses/tinfo/comp_scan.c | 797 +
ncurses-5.2/ncurses/tinfo/doalloc.c | 74 +
ncurses-5.2/ncurses/tinfo/free_ttype.c | 72 +
ncurses-5.2/ncurses/tinfo/getenv_num.c | 56 +
ncurses-5.2/ncurses/tinfo/home_terminfo.c | 65 +
ncurses-5.2/ncurses/tinfo/init_keytry.c | 78 +
ncurses-5.2/ncurses/tinfo/keys.list | 158 +
ncurses-5.2/ncurses/tinfo/lib_acs.c | 139 +
ncurses-5.2/ncurses/tinfo/lib_baudrate.c | 178 +
ncurses-5.2/ncurses/tinfo/lib_cur_term.c | 70 +
ncurses-5.2/ncurses/tinfo/lib_data.c | 84 +
ncurses-5.2/ncurses/tinfo/lib_has_cap.c | 63 +
ncurses-5.2/ncurses/tinfo/lib_kernel.c | 130 +
ncurses-5.2/ncurses/tinfo/lib_longname.c | 58 +
ncurses-5.2/ncurses/tinfo/lib_napms.c | 89 +
ncurses-5.2/ncurses/tinfo/lib_options.c | 255 +
ncurses-5.2/ncurses/tinfo/lib_print.c | 96 +
ncurses-5.2/ncurses/tinfo/lib_raw.c | 236 +
ncurses-5.2/ncurses/tinfo/lib_setup.c | 414 +
ncurses-5.2/ncurses/tinfo/lib_termcap.c | 192 +
ncurses-5.2/ncurses/tinfo/lib_termname.c | 46 +
ncurses-5.2/ncurses/tinfo/lib_tgoto.c | 197 +
ncurses-5.2/ncurses/tinfo/lib_ti.c | 103 +
ncurses-5.2/ncurses/tinfo/lib_tparm.c | 740 +
ncurses-5.2/ncurses/tinfo/lib_tputs.c | 324 +
ncurses-5.2/ncurses/tinfo/lib_ttyflags.c | 163 +
ncurses-5.2/ncurses/tinfo/make_keys.c | 134 +
ncurses-5.2/ncurses/tinfo/name_match.c | 96 +
ncurses-5.2/ncurses/tinfo/parse_entry.c | 952 +
ncurses-5.2/ncurses/tinfo/read_entry.c | 501 +
ncurses-5.2/ncurses/tinfo/read_termcap.c | 1111 ++
ncurses-5.2/ncurses/tinfo/setbuf.c | 144 +
ncurses-5.2/ncurses/tinfo/strings.c | 139 +
ncurses-5.2/ncurses/tinfo/write_entry.c | 581 +
ncurses-5.2/ncurses/trace/README | 5 +
ncurses-5.2/ncurses/trace/lib_trace.c | 216 +
ncurses-5.2/ncurses/trace/lib_traceatr.c | 240 +
ncurses-5.2/ncurses/trace/lib_tracebits.c | 247 +
ncurses-5.2/ncurses/trace/lib_tracechr.c | 51 +
ncurses-5.2/ncurses/trace/lib_tracedmp.c | 128 +
ncurses-5.2/ncurses/trace/lib_tracemse.c | 95 +
ncurses-5.2/ncurses/trace/trace_buf.c | 80 +
ncurses-5.2/ncurses/trace/trace_tries.c | 74 +
ncurses-5.2/ncurses/trace/trace_xnames.c | 74 +
ncurses-5.2/ncurses/tty/MKexpanded.sh | 99 +
ncurses-5.2/ncurses/tty/hardscroll.c | 328 +
ncurses-5.2/ncurses/tty/hashmap.c | 569 +
ncurses-5.2/ncurses/tty/lib_mvcur.c | 1182 ++
ncurses-5.2/ncurses/tty/lib_tstp.c | 366 +
ncurses-5.2/ncurses/tty/lib_twait.c | 265 +
ncurses-5.2/ncurses/tty/lib_vidattr.c | 296 +
ncurses-5.2/ncurses/tty/tty_display.h | 137 +
ncurses-5.2/ncurses/tty/tty_input.h | 61 +
ncurses-5.2/ncurses/tty/tty_update.c | 1801 ++
ncurses-5.2/panel/Makefile.in | 149 +
ncurses-5.2/panel/headers | 31 +
ncurses-5.2/panel/llib-lpanel | 143 +
ncurses-5.2/panel/modules | 49 +
ncurses-5.2/panel/p_above.c | 51 +
ncurses-5.2/panel/p_below.c | 53 +
ncurses-5.2/panel/p_bottom.c | 70 +
ncurses-5.2/panel/p_delete.c | 54 +
ncurses-5.2/panel/p_hidden.c | 47 +
ncurses-5.2/panel/p_hide.c | 57 +
ncurses-5.2/panel/p_move.c | 54 +
ncurses-5.2/panel/p_new.c | 104 +
ncurses-5.2/panel/p_replace.c | 53 +
ncurses-5.2/panel/p_show.c | 67 +
ncurses-5.2/panel/p_top.c | 45 +
ncurses-5.2/panel/p_update.c | 60 +
ncurses-5.2/panel/p_user.c | 55 +
ncurses-5.2/panel/p_win.c | 49 +
ncurses-5.2/panel/panel.c | 136 +
ncurses-5.2/panel/panel.h | 75 +
ncurses-5.2/panel/panel.priv.h | 203 +
ncurses-5.2/progs/MKtermsort.sh | 127 +
ncurses-5.2/progs/Makefile.in | 269 +
ncurses-5.2/progs/capconvert | 229 +
ncurses-5.2/progs/clear.c | 58 +
ncurses-5.2/progs/clear.sh | 1 +
ncurses-5.2/progs/dump_entry.c | 972 +
ncurses-5.2/progs/dump_entry.h | 67 +
ncurses-5.2/progs/infocmp.c | 1441 ++
ncurses-5.2/progs/modules | 41 +
ncurses-5.2/progs/progs.priv.h | 174 +
ncurses-5.2/progs/tic.c | 1068 ++
ncurses-5.2/progs/toe.c | 291 +
ncurses-5.2/progs/tput.c | 391 +
ncurses-5.2/progs/tset.c | 1205 ++
ncurses-5.2/sysdeps/unix/sysv/linux/Makefile | 10 +
.../sysdeps/unix/sysv/linux/alpha/configure | 2 +
ncurses-5.2/sysdeps/unix/sysv/linux/configure | 407 +
ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sed | 100 +
ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sh | 37 +
ncurses-5.2/sysdeps/unix/sysv/linux/run_tic.sh | 143 +
ncurses-5.2/tack/COPYING | 340 +
ncurses-5.2/tack/HISTORY | 44 +
ncurses-5.2/tack/Makefile.in | 170 +
ncurses-5.2/tack/README | 14 +
ncurses-5.2/tack/ansi.c | 853 +
ncurses-5.2/tack/charset.c | 709 +
ncurses-5.2/tack/color.c | 767 +
ncurses-5.2/tack/control.c | 657 +
ncurses-5.2/tack/crum.c | 426 +
ncurses-5.2/tack/edit.c | 977 +
ncurses-5.2/tack/fun.c | 912 +
ncurses-5.2/tack/init.c | 300 +
ncurses-5.2/tack/menu.c | 421 +
ncurses-5.2/tack/modes.c | 913 +
ncurses-5.2/tack/modules | 18 +
ncurses-5.2/tack/output.c | 818 +
ncurses-5.2/tack/pad.c | 1957 ++
ncurses-5.2/tack/scan.c | 261 +
ncurses-5.2/tack/sync.c | 424 +
ncurses-5.2/tack/sysdep.c | 498 +
ncurses-5.2/tack/tack.1 | 311 +
ncurses-5.2/tack/tack.c | 620 +
ncurses-5.2/tack/tack.h | 403 +
ncurses-5.2/tar-copy.sh | 70 +
ncurses-5.2/test/Makefile.in | 221 +
ncurses-5.2/test/README | 22 +
ncurses-5.2/test/blue.c | 440 +
ncurses-5.2/test/bs.6 | 42 +
ncurses-5.2/test/bs.c | 1268 ++
ncurses-5.2/test/cardfile.c | 420 +
ncurses-5.2/test/cardfile.dat | 13 +
ncurses-5.2/test/configure | 1998 ++
ncurses-5.2/test/configure.in | 199 +
ncurses-5.2/test/ditto.c | 148 +
ncurses-5.2/test/dots.c | 143 +
ncurses-5.2/test/filter.c | 109 +
ncurses-5.2/test/firework.c | 174 +
ncurses-5.2/test/firstlast.c | 89 +
ncurses-5.2/test/gdc.6 | 22 +
ncurses-5.2/test/gdc.c | 316 +
ncurses-5.2/test/hanoi.c | 303 +
ncurses-5.2/test/hashtest.c | 220 +
ncurses-5.2/test/keynames.c | 14 +
ncurses-5.2/test/knight.c | 591 +
ncurses-5.2/test/lrtest.c | 132 +
ncurses-5.2/test/modules | 59 +
ncurses-5.2/test/ncurses.c | 3616 ++++
ncurses-5.2/test/ncurses_tst.hin | 56 +
ncurses-5.2/test/newdemo.c | 348 +
ncurses-5.2/test/railroad.c | 241 +
ncurses-5.2/test/rain.c | 133 +
ncurses-5.2/test/tclock.c | 226 +
ncurses-5.2/test/test.priv.h | 116 +
ncurses-5.2/test/testaddch.c | 60 +
ncurses-5.2/test/testcurs.c | 657 +
ncurses-5.2/test/testscanw.c | 38 +
ncurses-5.2/test/tracemunch | 98 +
ncurses-5.2/test/view.c | 447 +
ncurses-5.2/test/worm.c | 428 +
ncurses-5.2/test/xmas.c | 1160 ++
ncurses-5.3/config.sub | 1 +
ncurses-5.3/misc/run_tic.sh | 2 +-
readline-4.3.orig/CHANGELOG | 699 +
readline-4.3.orig/CHANGES | 612 +
readline-4.3.orig/COPYING | 339 +
readline-4.3.orig/INSTALL | 273 +
readline-4.3.orig/MANIFEST | 126 +
readline-4.3.orig/Makefile.in | 520 +
readline-4.3.orig/README | 172 +
readline-4.3.orig/USAGE | 37 +
readline-4.3.orig/aclocal.m4 | 1792 ++
readline-4.3.orig/ansi_stdlib.h | 54 +
readline-4.3.orig/bind.c | 2150 +++
readline-4.3.orig/callback.c | 156 +
readline-4.3.orig/chardefs.h | 159 +
readline-4.3.orig/compat.c | 113 +
readline-4.3.orig/complete.c | 2004 ++
readline-4.3.orig/config.h.in | 200 +
readline-4.3.orig/configure | 5865 ++++++
readline-4.3.orig/configure.in | 206 +
readline-4.3.orig/display.c | 2196 +++
readline-4.3.orig/doc/Makefile.in | 234 +
readline-4.3.orig/doc/hist.texinfo | 110 +
readline-4.3.orig/doc/history.0 | 660 +
readline-4.3.orig/doc/history.3 | 640 +
readline-4.3.orig/doc/history.dvi | Bin 0 -> 48868 bytes
readline-4.3.orig/doc/history.html | 1639 ++
readline-4.3.orig/doc/history.info | 840 +
readline-4.3.orig/doc/history.ps | 1658 ++
readline-4.3.orig/doc/history_3.ps | 800 +
readline-4.3.orig/doc/hstech.texinfo | 550 +
readline-4.3.orig/doc/hsuser.texinfo | 437 +
readline-4.3.orig/doc/manvers.texinfo | 10 +
readline-4.3.orig/doc/readline.0 | 997 +
readline-4.3.orig/doc/readline.3 | 1272 ++
readline-4.3.orig/doc/readline.dvi | Bin 0 -> 235920 bytes
readline-4.3.orig/doc/readline.html | 5908 ++++++
readline-4.3.orig/doc/readline.info | 3638 ++++
readline-4.3.orig/doc/readline.ps | 5200 ++++++
readline-4.3.orig/doc/readline_3.ps | 1294 ++
readline-4.3.orig/doc/rlman.texinfo | 108 +
readline-4.3.orig/doc/rltech.texinfo | 2165 +++
readline-4.3.orig/doc/rluser.texinfo | 1796 ++
readline-4.3.orig/doc/rluserman.dvi | Bin 0 -> 62592 bytes
readline-4.3.orig/doc/rluserman.html | 2184 +++
readline-4.3.orig/doc/rluserman.info | 1260 ++
readline-4.3.orig/doc/rluserman.ps | 2001 ++
readline-4.3.orig/doc/rluserman.texinfo | 94 +
readline-4.3.orig/doc/texi2dvi | 568 +
readline-4.3.orig/doc/texi2html | 5429 ++++++
readline-4.3.orig/doc/texinfo.tex | 5992 ++++++
readline-4.3.orig/emacs_keymap.c | 873 +
readline-4.3.orig/examples/Inputrc | 81 +
readline-4.3.orig/examples/Makefile.in | 104 +
readline-4.3.orig/examples/excallback.c | 188 +
readline-4.3.orig/examples/fileman.c | 485 +
readline-4.3.orig/examples/histexamp.c | 112 +
readline-4.3.orig/examples/manexamp.c | 112 +
readline-4.3.orig/examples/readlinebuf.h | 139 +
readline-4.3.orig/examples/rl.c | 151 +
readline-4.3.orig/examples/rlcat.c | 174 +
readline-4.3.orig/examples/rlfe.c | 1042 ++
readline-4.3.orig/examples/rltest.c | 87 +
readline-4.3.orig/examples/rlversion.c | 43 +
readline-4.3.orig/funmap.c | 253 +
readline-4.3.orig/histexpand.c | 1491 ++
readline-4.3.orig/histfile.c | 479 +
readline-4.3.orig/histlib.h | 82 +
readline-4.3.orig/history.c | 381 +
readline-4.3.orig/history.h | 246 +
readline-4.3.orig/histsearch.c | 195 +
readline-4.3.orig/input.c | 540 +
readline-4.3.orig/isearch.c | 560 +
readline-4.3.orig/keymaps.c | 150 +
readline-4.3.orig/keymaps.h | 103 +
readline-4.3.orig/kill.c | 652 +
readline-4.3.orig/macro.c | 262 +
readline-4.3.orig/mbutil.c | 337 +
readline-4.3.orig/misc.c | 496 +
readline-4.3.orig/nls.c | 225 +
readline-4.3.orig/parens.c | 179 +
readline-4.3.orig/posixdir.h | 57 +
readline-4.3.orig/posixjmp.h | 40 +
readline-4.3.orig/posixstat.h | 142 +
readline-4.3.orig/readline.c | 973 +
readline-4.3.orig/readline.h | 799 +
readline-4.3.orig/rlconf.h | 60 +
readline-4.3.orig/rldefs.h | 156 +
readline-4.3.orig/rlmbutil.h | 108 +
readline-4.3.orig/rlprivate.h | 284 +
readline-4.3.orig/rlshell.h | 34 +
readline-4.3.orig/rlstdc.h | 45 +
readline-4.3.orig/rltty.c | 911 +
readline-4.3.orig/rltty.h | 82 +
readline-4.3.orig/rltypedefs.h | 88 +
readline-4.3.orig/rlwinsize.h | 57 +
readline-4.3.orig/savestring.c | 36 +
readline-4.3.orig/search.c | 465 +
readline-4.3.orig/shell.c | 196 +
readline-4.3.orig/shlib/Makefile.in | 437 +
readline-4.3.orig/signals.c | 398 +
readline-4.3.orig/support/config.guess | 1393 ++
readline-4.3.orig/support/config.sub | 1497 ++
readline-4.3.orig/support/install.sh | 247 +
readline-4.3.orig/support/mkdirs | 48 +
readline-4.3.orig/support/mkdist | 120 +
readline-4.3.orig/support/shlib-install | 156 +
readline-4.3.orig/support/shobj-conf | 458 +
readline-4.3.orig/support/wcwidth.c | 236 +
readline-4.3.orig/tcap.h | 60 +
readline-4.3.orig/terminal.c | 662 +
readline-4.3.orig/text.c | 1540 ++
readline-4.3.orig/tilde.c | 458 +
readline-4.3.orig/tilde.h | 78 +
readline-4.3.orig/undo.c | 263 +
readline-4.3.orig/util.c | 338 +
readline-4.3.orig/vi_keymap.c | 877 +
readline-4.3.orig/vi_mode.c | 1485 ++
readline-4.3.orig/xmalloc.c | 88 +
readline-4.3.orig/xmalloc.h | 46 +
readline-4.3/CHANGELOG-ReadLine | 699 +
readline-4.3/CHANGES | 612 +
readline-4.3/COPYING | 339 +
readline-4.3/ChangeLog | 5 +
readline-4.3/INSTALL | 273 +
readline-4.3/MANIFEST | 126 +
readline-4.3/Makefile.in | 520 +
readline-4.3/README | 172 +
readline-4.3/USAGE | 37 +
readline-4.3/aclocal.m4 | 1792 ++
readline-4.3/ansi_stdlib.h | 54 +
readline-4.3/bind.c | 2150 +++
readline-4.3/callback.c | 156 +
readline-4.3/chardefs.h | 159 +
readline-4.3/compat.c | 113 +
readline-4.3/complete.c | 2004 ++
readline-4.3/config.h.in | 200 +
readline-4.3/configure | 5865 ++++++
readline-4.3/configure.in | 206 +
readline-4.3/display.c | 2196 +++
readline-4.3/doc/Makefile.in | 234 +
readline-4.3/doc/hist.texinfo | 110 +
readline-4.3/doc/history.3 | 640 +
readline-4.3/doc/hstech.texinfo | 550 +
readline-4.3/doc/hsuser.texinfo | 437 +
readline-4.3/doc/manvers.texinfo | 10 +
readline-4.3/doc/readline.3 | 1272 ++
readline-4.3/doc/rlman.texinfo | 108 +
readline-4.3/doc/rltech.texinfo | 2165 +++
readline-4.3/doc/rluser.texinfo | 1796 ++
readline-4.3/doc/rluserman.texinfo | 94 +
readline-4.3/doc/texi2dvi | 568 +
readline-4.3/doc/texi2html | 5429 ++++++
readline-4.3/doc/texinfo.tex | 5992 ++++++
readline-4.3/emacs_keymap.c | 873 +
readline-4.3/examples/Inputrc | 81 +
readline-4.3/examples/Makefile.in | 104 +
readline-4.3/examples/excallback.c | 188 +
readline-4.3/examples/fileman.c | 485 +
readline-4.3/examples/histexamp.c | 112 +
readline-4.3/examples/manexamp.c | 112 +
readline-4.3/examples/readlinebuf.h | 139 +
readline-4.3/examples/rl.c | 151 +
readline-4.3/examples/rlcat.c | 174 +
readline-4.3/examples/rlfe.c | 1042 ++
readline-4.3/examples/rltest.c | 87 +
readline-4.3/examples/rlversion.c | 43 +
readline-4.3/funmap.c | 253 +
readline-4.3/histexpand.c | 1491 ++
readline-4.3/histfile.c | 479 +
readline-4.3/histlib.h | 82 +
readline-4.3/history.c | 381 +
readline-4.3/history.h | 246 +
readline-4.3/histsearch.c | 195 +
readline-4.3/input.c | 540 +
readline-4.3/isearch.c | 560 +
readline-4.3/keymaps.c | 150 +
readline-4.3/keymaps.h | 103 +
readline-4.3/kill.c | 652 +
readline-4.3/macro.c | 262 +
readline-4.3/mbutil.c | 337 +
readline-4.3/misc.c | 496 +
readline-4.3/nls.c | 225 +
readline-4.3/parens.c | 179 +
readline-4.3/posixdir.h | 57 +
readline-4.3/posixjmp.h | 40 +
readline-4.3/posixstat.h | 142 +
readline-4.3/readline.c | 973 +
readline-4.3/readline.h | 799 +
readline-4.3/rlconf.h | 60 +
readline-4.3/rldefs.h | 156 +
readline-4.3/rlmbutil.h | 108 +
readline-4.3/rlprivate.h | 284 +
readline-4.3/rlshell.h | 34 +
readline-4.3/rlstdc.h | 45 +
readline-4.3/rltty.c | 911 +
readline-4.3/rltty.h | 82 +
readline-4.3/rltypedefs.h | 88 +
readline-4.3/rlwinsize.h | 57 +
readline-4.3/savestring.c | 36 +
readline-4.3/search.c | 465 +
readline-4.3/shell.c | 196 +
readline-4.3/shlib/Makefile.in | 437 +
readline-4.3/signals.c | 400 +
readline-4.3/support/config.guess | 1393 ++
readline-4.3/support/config.sub | 1498 ++
readline-4.3/support/install.sh | 247 +
readline-4.3/support/mkdirs | 48 +
readline-4.3/support/mkdist | 120 +
readline-4.3/support/shlib-install | 156 +
readline-4.3/support/shobj-conf | 458 +
readline-4.3/support/wcwidth.c | 236 +
readline-4.3/tcap.h | 60 +
readline-4.3/terminal.c | 662 +
readline-4.3/text.c | 1540 ++
readline-4.3/tilde.c | 458 +
readline-4.3/tilde.h | 78 +
readline-4.3/undo.c | 263 +
readline-4.3/util.c | 338 +
readline-4.3/vi_keymap.c | 877 +
readline-4.3/vi_mode.c | 1485 ++
readline-4.3/xmalloc.c | 88 +
readline-4.3/xmalloc.h | 46 +
readline-doc-4.3/MANIFEST.doc | 21 +
readline-doc-4.3/doc/history.0 | 660 +
readline-doc-4.3/doc/history.dvi | Bin 0 -> 48868 bytes
readline-doc-4.3/doc/history.html | 1639 ++
readline-doc-4.3/doc/history.info | 840 +
readline-doc-4.3/doc/history.ps | 1658 ++
readline-doc-4.3/doc/history_3.ps | 800 +
readline-doc-4.3/doc/readline.0 | 997 +
readline-doc-4.3/doc/readline.dvi | Bin 0 -> 235920 bytes
readline-doc-4.3/doc/readline.html | 5908 ++++++
readline-doc-4.3/doc/readline.info | 3638 ++++
readline-doc-4.3/doc/readline.ps | 5200 ++++++
readline-doc-4.3/doc/readline_3.ps | 1294 ++
readline-doc-4.3/doc/rluserman.dvi | Bin 0 -> 62592 bytes
readline-doc-4.3/doc/rluserman.html | 2184 +++
readline-doc-4.3/doc/rluserman.info | 1260 ++
readline-doc-4.3/doc/rluserman.ps | 2001 ++
zlib-1.1.4/ChangeLog | 486 +
zlib-1.1.4/FAQ | 100 +
zlib-1.1.4/INDEX | 86 +
zlib-1.1.4/Make_vms.com | 115 +
zlib-1.1.4/Makefile | 175 +
zlib-1.1.4/Makefile.in | 175 +
zlib-1.1.4/Makefile.riscos | 151 +
zlib-1.1.4/README | 147 +
zlib-1.1.4/adler32.c | 48 +
zlib-1.1.4/algorithm.txt | 213 +
zlib-1.1.4/amiga/Makefile.pup | 66 +
zlib-1.1.4/amiga/Makefile.sas | 64 +
zlib-1.1.4/compress.c | 68 +
zlib-1.1.4/configure | 212 +
zlib-1.1.4/contrib/README.contrib | 34 +
zlib-1.1.4/contrib/asm386/gvmat32.asm | 559 +
zlib-1.1.4/contrib/asm386/gvmat32c.c | 200 +
zlib-1.1.4/contrib/asm386/mkgvmt32.bat | 1 +
zlib-1.1.4/contrib/asm386/zlibvc.def | 74 +
zlib-1.1.4/contrib/asm386/zlibvc.dsp | 651 +
zlib-1.1.4/contrib/asm386/zlibvc.dsw | 41 +
zlib-1.1.4/contrib/asm586/README.586 | 43 +
zlib-1.1.4/contrib/asm586/match.S | 354 +
zlib-1.1.4/contrib/asm686/README.686 | 34 +
zlib-1.1.4/contrib/asm686/match.S | 327 +
zlib-1.1.4/contrib/delphi/zlib.mak | 36 +
zlib-1.1.4/contrib/delphi/zlibdef.pas | 169 +
zlib-1.1.4/contrib/delphi2/d_zlib.bpr | 224 +
zlib-1.1.4/contrib/delphi2/d_zlib.cpp | 17 +
zlib-1.1.4/contrib/delphi2/readme.txt | 17 +
zlib-1.1.4/contrib/delphi2/zlib.bpg | 26 +
zlib-1.1.4/contrib/delphi2/zlib.bpr | 225 +
zlib-1.1.4/contrib/delphi2/zlib.cpp | 22 +
zlib-1.1.4/contrib/delphi2/zlib.pas | 534 +
zlib-1.1.4/contrib/delphi2/zlib32.bpr | 174 +
zlib-1.1.4/contrib/delphi2/zlib32.cpp | 42 +
zlib-1.1.4/contrib/iostream/test.cpp | 24 +
zlib-1.1.4/contrib/iostream/zfstream.cpp | 329 +
zlib-1.1.4/contrib/iostream/zfstream.h | 142 +
zlib-1.1.4/contrib/iostream2/zstream.h | 307 +
zlib-1.1.4/contrib/iostream2/zstream_test.cpp | 25 +
zlib-1.1.4/contrib/minizip/ChangeLogUnzip | 38 +
zlib-1.1.4/contrib/minizip/Makefile | 25 +
zlib-1.1.4/contrib/minizip/miniunz.c | 508 +
zlib-1.1.4/contrib/minizip/minizip.c | 302 +
zlib-1.1.4/contrib/minizip/readme.txt | 37 +
zlib-1.1.4/contrib/minizip/unzip.c | 1294 ++
zlib-1.1.4/contrib/minizip/unzip.def | 15 +
zlib-1.1.4/contrib/minizip/unzip.h | 275 +
zlib-1.1.4/contrib/minizip/zip.c | 718 +
zlib-1.1.4/contrib/minizip/zip.def | 5 +
zlib-1.1.4/contrib/minizip/zip.h | 150 +
zlib-1.1.4/contrib/minizip/zlibvc.def | 74 +
zlib-1.1.4/contrib/minizip/zlibvc.dsp | 651 +
zlib-1.1.4/contrib/minizip/zlibvc.dsw | 41 +
zlib-1.1.4/contrib/untgz/Makefile | 14 +
zlib-1.1.4/contrib/untgz/makefile.w32 | 63 +
zlib-1.1.4/contrib/untgz/untgz.c | 522 +
zlib-1.1.4/contrib/visual-basic.txt | 69 +
zlib-1.1.4/crc32.c | 162 +
zlib-1.1.4/deflate.c | 1350 ++
zlib-1.1.4/deflate.h | 318 +
zlib-1.1.4/descrip.mms | 48 +
zlib-1.1.4/example.c | 556 +
zlib-1.1.4/gzio.c | 875 +
zlib-1.1.4/infblock.c | 403 +
zlib-1.1.4/infblock.h | 39 +
zlib-1.1.4/infcodes.c | 251 +
zlib-1.1.4/infcodes.h | 27 +
zlib-1.1.4/inffast.c | 183 +
zlib-1.1.4/inffast.h | 17 +
zlib-1.1.4/inffixed.h | 151 +
zlib-1.1.4/inflate.c | 366 +
zlib-1.1.4/inftrees.c | 454 +
zlib-1.1.4/inftrees.h | 58 +
zlib-1.1.4/infutil.c | 87 +
zlib-1.1.4/infutil.h | 98 +
zlib-1.1.4/maketree.c | 85 +
zlib-1.1.4/minigzip.c | 320 +
zlib-1.1.4/msdos/Makefile.b32 | 104 +
zlib-1.1.4/msdos/Makefile.bor | 125 +
zlib-1.1.4/msdos/Makefile.dj2 | 100 +
zlib-1.1.4/msdos/Makefile.emx | 69 +
zlib-1.1.4/msdos/Makefile.msc | 121 +
zlib-1.1.4/msdos/Makefile.tc | 108 +
zlib-1.1.4/msdos/Makefile.w32 | 97 +
zlib-1.1.4/msdos/Makefile.wat | 103 +
zlib-1.1.4/msdos/zlib.def | 60 +
zlib-1.1.4/msdos/zlib.rc | 32 +
zlib-1.1.4/nt/Makefile.emx | 138 +
zlib-1.1.4/nt/Makefile.gcc | 87 +
zlib-1.1.4/nt/Makefile.nt | 88 +
zlib-1.1.4/nt/zlib.dnt | 47 +
zlib-1.1.4/os2/Makefile.os2 | 136 +
zlib-1.1.4/os2/zlib.def | 51 +
zlib-1.1.4/trees.c | 1214 ++
zlib-1.1.4/trees.h | 128 +
zlib-1.1.4/uncompr.c | 58 +
zlib-1.1.4/zconf.h | 279 +
zlib-1.1.4/zlib.3 | 107 +
zlib-1.1.4/zlib.h | 893 +
zlib-1.1.4/zlib.html | 971 +
zlib-1.1.4/zutil.c | 225 +
zlib-1.1.4/zutil.h | 220 +
1381 files changed, 478581 insertions(+), 1 deletion(-)
create mode 100644 ChangeLog
create mode 100644 README
create mode 100644 RTEMS_Makefiles/Makefile.avl
create mode 100644 RTEMS_Makefiles/Makefile.bfd
create mode 100644 RTEMS_Makefiles/Makefile.common
create mode 100644 RTEMS_Makefiles/Makefile.libtecla
create mode 100644 RTEMS_Makefiles/Makefile.ncurses
create mode 100644 RTEMS_Makefiles/Makefile.ncurses-5.3
create mode 100644 RTEMS_Makefiles/Makefile.readline-4.3
create mode 100644 RTEMS_Makefiles/Makefile.site
create mode 100644 RTEMS_Makefiles/Makefile.zlib
create mode 100644 SUPPORT
create mode 100644 VERSION
create mode 100644 avl-1.4.0/AUTHORS
create mode 100644 avl-1.4.0/COPYING
create mode 100644 avl-1.4.0/ChangeLog
create mode 100644 avl-1.4.0/INSTALL
create mode 100644 avl-1.4.0/Makefile.am
create mode 100644 avl-1.4.0/Makefile.in
create mode 100644 avl-1.4.0/NEWS
create mode 100644 avl-1.4.0/README
create mode 100644 avl-1.4.0/THANKS
create mode 100644 avl-1.4.0/TODO
create mode 100644 avl-1.4.0/aclocal.m4
create mode 100644 avl-1.4.0/avl.c
create mode 100644 avl-1.4.0/avl.h
create mode 100644 avl-1.4.0/avl.html
create mode 100644 avl-1.4.0/avl.info
create mode 100644 avl-1.4.0/avl.texinfo
create mode 100644 avl-1.4.0/avl.text
create mode 100644 avl-1.4.0/avlt.c
create mode 100644 avl-1.4.0/avlt.h
create mode 100644 avl-1.4.0/avltr.c
create mode 100644 avl-1.4.0/avltr.h
create mode 100755 avl-1.4.0/configure
create mode 100644 avl-1.4.0/configure.in
create mode 100755 avl-1.4.0/install-sh
create mode 100755 avl-1.4.0/missing
create mode 100755 avl-1.4.0/mkinstalldirs
create mode 100644 avl-1.4.0/rb.c
create mode 100644 avl-1.4.0/rb.h
create mode 100644 avl-1.4.0/texinfo.tex
create mode 100644 avl-1.4.0/thread-test.c
create mode 100755 bit
create mode 100644 bit_bfd
create mode 100644 examples/avl/BuildTests.sh
create mode 100644 examples/avl/Makefile
create mode 100644 examples/avl/README
create mode 100644 examples/avl/init.c
create mode 100644 examples/ncurses/BuildTests.sh
create mode 100644 examples/ncurses/Makefile
create mode 100644 examples/ncurses/README
create mode 100644 examples/ncurses/init.c
create mode 100644 examples/readline/.gdbinit
create mode 100644 examples/readline/Makefile
create mode 100644 examples/readline/init.c
create mode 100644 examples/readline/rlgeneric.c
create mode 100644 libtecla-1.4.1/CHANGES
create mode 100644 libtecla-1.4.1/INSTALL
create mode 100644 libtecla-1.4.1/LICENSE.TERMS
create mode 100644 libtecla-1.4.1/Makefile
create mode 100644 libtecla-1.4.1/Makefile.in
create mode 100644 libtecla-1.4.1/Makefile.rules
create mode 100644 libtecla-1.4.1/Makefile.stub
create mode 100644 libtecla-1.4.1/PORTING
create mode 100644 libtecla-1.4.1/README
create mode 100644 libtecla-1.4.1/RELEASE.NOTES
create mode 100644 libtecla-1.4.1/config.guess
create mode 100644 libtecla-1.4.1/config.sub
create mode 100755 libtecla-1.4.1/configure
create mode 100644 libtecla-1.4.1/configure.in
create mode 100644 libtecla-1.4.1/cplfile.c
create mode 100644 libtecla-1.4.1/cplfile.h
create mode 100644 libtecla-1.4.1/cplmatch.c
create mode 100644 libtecla-1.4.1/demo.c
create mode 100644 libtecla-1.4.1/demo2.c
create mode 100644 libtecla-1.4.1/direader.c
create mode 100644 libtecla-1.4.1/direader.h
create mode 100644 libtecla-1.4.1/enhance.c
create mode 100644 libtecla-1.4.1/expand.c
create mode 100644 libtecla-1.4.1/freelist.c
create mode 100644 libtecla-1.4.1/freelist.h
create mode 100644 libtecla-1.4.1/getline.c
create mode 100644 libtecla-1.4.1/getline.h
create mode 100644 libtecla-1.4.1/hash.c
create mode 100644 libtecla-1.4.1/hash.h
create mode 100644 libtecla-1.4.1/history.c
create mode 100644 libtecla-1.4.1/history.h
create mode 100644 libtecla-1.4.1/homedir.c
create mode 100644 libtecla-1.4.1/homedir.h
create mode 100644 libtecla-1.4.1/html/changes.html
create mode 100644 libtecla-1.4.1/html/cpl_complete_word.html
create mode 100644 libtecla-1.4.1/html/ef_expand_file.html
create mode 100644 libtecla-1.4.1/html/enhance.html
create mode 100644 libtecla-1.4.1/html/gl_get_line.html
create mode 100644 libtecla-1.4.1/html/index.html
create mode 100644 libtecla-1.4.1/html/libtecla.html
create mode 100644 libtecla-1.4.1/html/pca_lookup_file.html
create mode 100644 libtecla-1.4.1/html/release.html
create mode 100755 libtecla-1.4.1/install-sh
create mode 100644 libtecla-1.4.1/keytab.c
create mode 100644 libtecla-1.4.1/keytab.h
create mode 100644 libtecla-1.4.1/libtecla.h
create mode 100644 libtecla-1.4.1/libtecla.map
create mode 100644 libtecla-1.4.1/man3/cfc_file_start.3
create mode 100644 libtecla-1.4.1/man3/cfc_literal_escapes.3
create mode 100644 libtecla-1.4.1/man3/cfc_set_check_fn.3
create mode 100644 libtecla-1.4.1/man3/cpl_add_completion.3
create mode 100644 libtecla-1.4.1/man3/cpl_complete_word.3
create mode 100644 libtecla-1.4.1/man3/cpl_file_completions.3
create mode 100644 libtecla-1.4.1/man3/cpl_last_error.3
create mode 100644 libtecla-1.4.1/man3/cpl_list_completions.3
create mode 100644 libtecla-1.4.1/man3/cpl_record_error.3
create mode 100644 libtecla-1.4.1/man3/del_CplFileConf.3
create mode 100644 libtecla-1.4.1/man3/del_ExpandFile.3
create mode 100644 libtecla-1.4.1/man3/del_GetLine.3
create mode 100644 libtecla-1.4.1/man3/del_PathCache.3
create mode 100644 libtecla-1.4.1/man3/del_PcaPathConf.3
create mode 100644 libtecla-1.4.1/man3/del_WordCompletion.3
create mode 100644 libtecla-1.4.1/man3/ef_expand_file.3
create mode 100644 libtecla-1.4.1/man3/ef_last_error.3
create mode 100644 libtecla-1.4.1/man3/ef_list_expansions.3
create mode 100644 libtecla-1.4.1/man3/enhance.3
create mode 100644 libtecla-1.4.1/man3/gl_change_terminal.3
create mode 100644 libtecla-1.4.1/man3/gl_clear_history.3
create mode 100644 libtecla-1.4.1/man3/gl_configure_getline.3
create mode 100644 libtecla-1.4.1/man3/gl_customize_completion.3
create mode 100644 libtecla-1.4.1/man3/gl_echo_mode.3
create mode 100644 libtecla-1.4.1/man3/gl_get_line.3
create mode 100644 libtecla-1.4.1/man3/gl_group_history.3
create mode 100644 libtecla-1.4.1/man3/gl_ignore_signal.3
create mode 100644 libtecla-1.4.1/man3/gl_last_signal.3
create mode 100644 libtecla-1.4.1/man3/gl_limit_history.3
create mode 100644 libtecla-1.4.1/man3/gl_load_history.3
create mode 100644 libtecla-1.4.1/man3/gl_lookup_history.3
create mode 100644 libtecla-1.4.1/man3/gl_prompt_style.3
create mode 100644 libtecla-1.4.1/man3/gl_range_of_history.3
create mode 100644 libtecla-1.4.1/man3/gl_resize_history.3
create mode 100644 libtecla-1.4.1/man3/gl_save_history.3
create mode 100644 libtecla-1.4.1/man3/gl_show_history.3
create mode 100644 libtecla-1.4.1/man3/gl_size_of_history.3
create mode 100644 libtecla-1.4.1/man3/gl_state_of_history.3
create mode 100644 libtecla-1.4.1/man3/gl_terminal_size.3
create mode 100644 libtecla-1.4.1/man3/gl_toggle_history.3
create mode 100644 libtecla-1.4.1/man3/gl_trap_signal.3
create mode 100644 libtecla-1.4.1/man3/gl_watch_fd.3
create mode 100644 libtecla-1.4.1/man3/libtecla.3
create mode 100644 libtecla-1.4.1/man3/libtecla_version.3
create mode 100644 libtecla-1.4.1/man3/new_CplFileConf.3
create mode 100644 libtecla-1.4.1/man3/new_ExpandFile.3
create mode 100644 libtecla-1.4.1/man3/new_GetLine.3
create mode 100644 libtecla-1.4.1/man3/new_PathCache.3
create mode 100644 libtecla-1.4.1/man3/new_PcaPathConf.3
create mode 100644 libtecla-1.4.1/man3/new_WordCompletion.3
create mode 100644 libtecla-1.4.1/man3/pca_last_error.3
create mode 100644 libtecla-1.4.1/man3/pca_lookup_file.3
create mode 100644 libtecla-1.4.1/man3/pca_path_completions.3
create mode 100644 libtecla-1.4.1/man3/pca_scan_path.3
create mode 100644 libtecla-1.4.1/man3/pca_set_check_fn.3
create mode 100644 libtecla-1.4.1/man3/ppc_file_start.3
create mode 100644 libtecla-1.4.1/man3/ppc_literal_escapes.3
create mode 100644 libtecla-1.4.1/pathutil.c
create mode 100644 libtecla-1.4.1/pathutil.h
create mode 100644 libtecla-1.4.1/pcache.c
create mode 100644 libtecla-1.4.1/stringrp.c
create mode 100644 libtecla-1.4.1/stringrp.h
create mode 100644 libtecla-1.4.1/strngmem.c
create mode 100644 libtecla-1.4.1/strngmem.h
create mode 100755 libtecla-1.4.1/update_html
create mode 100755 libtecla-1.4.1/update_version
create mode 100644 libtecla-1.4.1/version.c
create mode 100644 ncurses-5.2/ANNOUNCE
create mode 100644 ncurses-5.2/Ada95/Makefile.in
create mode 100644 ncurses-5.2/Ada95/README
create mode 100644 ncurses-5.2/Ada95/TODO
create mode 100644 ncurses-5.2/Ada95/gen/Makefile.in
create mode 100644 ncurses-5.2/Ada95/gen/gen.c
create mode 100644 ncurses-5.2/Ada95/gen/html.m4
create mode 100644 ncurses-5.2/Ada95/gen/normal.m4
create mode 100644 ncurses-5.2/Ada95/gen/table.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-aux.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-field_types.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-field_user_data.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-forms-form_user_data.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-forms.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-menus-item_user_data.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-menus-menu_user_data.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-menus.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-mouse.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-panels-user_data.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses-panels.ads.m4
create mode 100644 ncurses-5.2/Ada95/gen/terminal_interface-curses.ads.m4
create mode 100644 ncurses-5.2/Ada95/samples/Makefile.in
create mode 100644 ncurses-5.2/Ada95/samples/README
create mode 100644 ncurses-5.2/Ada95/samples/explain.txt
create mode 100644 ncurses-5.2/Ada95/samples/rain.adb
create mode 100644 ncurses-5.2/Ada95/samples/rain.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo-attributes.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo-attributes.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo-mouse.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo-mouse.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-curses_demo.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-explanation.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-explanation.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo-aux.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo-aux.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo-handler.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo-handler.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-form_demo.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-function_key_setting.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-function_key_setting.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-header_handler.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-header_handler.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-helpers.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-helpers.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-keyboard_handler.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-keyboard_handler.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-manifest.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo-aux.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo-aux.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo-handler.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo-handler.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-menu_demo.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-my_field_type.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-my_field_type.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample-text_io_demo.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample-text_io_demo.ads
create mode 100644 ncurses-5.2/Ada95/samples/sample.adb
create mode 100644 ncurses-5.2/Ada95/samples/sample.ads
create mode 100644 ncurses-5.2/Ada95/samples/status.adb
create mode 100644 ncurses-5.2/Ada95/samples/status.ads
create mode 100644 ncurses-5.2/Ada95/samples/tour.adb
create mode 100644 ncurses-5.2/Ada95/samples/tour.ads
create mode 100644 ncurses-5.2/Ada95/src/Makefile.in
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-aux.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alpha.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alpha.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-enumeration.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-intfield.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-intfield.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-numeric.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-numeric.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-regexp.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-regexp.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types-user.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_types.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-field_user_data.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms-form_user_data.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-forms.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-menus-item_user_data.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-menus-menu_user_data.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-menus.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-mouse.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-panels-user_data.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-panels.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-aux.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-aux.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-complex_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-complex_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-decimal_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-decimal_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-enumeration_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-enumeration_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-fixed_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-fixed_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-float_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-float_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-integer_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-integer_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-modular_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io-modular_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses-text_io.ads
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface-curses.adb
create mode 100644 ncurses-5.2/Ada95/src/terminal_interface.ads
create mode 100644 ncurses-5.2/INSTALL
create mode 100644 ncurses-5.2/MANIFEST
create mode 100644 ncurses-5.2/Makefile.glibc
create mode 100644 ncurses-5.2/Makefile.in
create mode 100644 ncurses-5.2/Makefile.os2
create mode 100644 ncurses-5.2/NEWS
create mode 100644 ncurses-5.2/README
create mode 100644 ncurses-5.2/README.emx
create mode 100644 ncurses-5.2/README.glibc
create mode 100644 ncurses-5.2/TO-DO
create mode 100644 ncurses-5.2/aclocal.m4
create mode 100644 ncurses-5.2/announce.html.in
create mode 100644 ncurses-5.2/c++/Makefile.in
create mode 100644 ncurses-5.2/c++/NEWS
create mode 100644 ncurses-5.2/c++/PROBLEMS
create mode 100644 ncurses-5.2/c++/README-first
create mode 100644 ncurses-5.2/c++/cursesapp.cc
create mode 100644 ncurses-5.2/c++/cursesapp.h
create mode 100644 ncurses-5.2/c++/cursesf.cc
create mode 100644 ncurses-5.2/c++/cursesf.h
create mode 100644 ncurses-5.2/c++/cursesm.cc
create mode 100644 ncurses-5.2/c++/cursesm.h
create mode 100644 ncurses-5.2/c++/cursesmain.cc
create mode 100644 ncurses-5.2/c++/cursesp.cc
create mode 100644 ncurses-5.2/c++/cursesp.h
create mode 100644 ncurses-5.2/c++/cursespad.cc
create mode 100644 ncurses-5.2/c++/cursesw.cc
create mode 100644 ncurses-5.2/c++/cursesw.h
create mode 100644 ncurses-5.2/c++/cursslk.cc
create mode 100644 ncurses-5.2/c++/cursslk.h
create mode 100644 ncurses-5.2/c++/demo.cc
create mode 100755 ncurses-5.2/c++/edit_cfg.sh
create mode 100644 ncurses-5.2/c++/etip.h.in
create mode 100644 ncurses-5.2/c++/headers
create mode 100644 ncurses-5.2/c++/internal.h
create mode 100644 ncurses-5.2/c++/modules
create mode 100755 ncurses-5.2/config.guess
create mode 100755 ncurses-5.2/config.sub
create mode 100755 ncurses-5.2/configure
create mode 100644 ncurses-5.2/configure.in
create mode 100644 ncurses-5.2/convert_configure.pl
create mode 100644 ncurses-5.2/dist.mk
create mode 100644 ncurses-5.2/doc/hackguide.doc
create mode 100644 ncurses-5.2/doc/html/Ada95.html
create mode 100644 ncurses-5.2/doc/html/ada/files.htm
create mode 100644 ncurses-5.2/doc/html/ada/files/T.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/A.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/B.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/C.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/D.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/E.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/F.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/G.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/H.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/I.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/K.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/L.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/M.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/N.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/O.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/P.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/Q.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/R.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/S.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/T.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/U.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/V.htm
create mode 100644 ncurses-5.2/doc/html/ada/funcs/W.htm
create mode 100644 ncurses-5.2/doc/html/ada/index.htm
create mode 100644 ncurses-5.2/doc/html/ada/main.htm
create mode 100644 ncurses-5.2/doc/html/ada/table.html
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-aux__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-aux__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alpha__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alpha__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alphanumeric__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration-ada__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-intfield__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-intfield__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-ipv4_address__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-numeric__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-numeric__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-regexp__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-regexp__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user-choice__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types-user__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_types__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_user_data__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-field_user_data__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-form_user_data__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms-form_user_data__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-forms__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-item_user_data__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-item_user_data__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-menu_user_data__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus-menu_user_data__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-menus__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-mouse__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-mouse__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-panels-user_data__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-panels-user_data__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-panels__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-panels__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-aux__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-aux__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-complex_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-complex_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-decimal_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-decimal_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-enumeration_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-enumeration_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-fixed_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-fixed_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-float_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-float_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-integer_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-integer_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-modular_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io-modular_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses-text_io__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses__adb.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface-curses__ads.htm
create mode 100644 ncurses-5.2/doc/html/ada/terminal_interface__ads.htm
create mode 100644 ncurses-5.2/doc/html/announce.html
create mode 100644 ncurses-5.2/doc/html/hackguide.html
create mode 100644 ncurses-5.2/doc/html/index.html
create mode 100644 ncurses-5.2/doc/html/man/captoinfo.1m.html
create mode 100644 ncurses-5.2/doc/html/man/clear.1.html
create mode 100644 ncurses-5.2/doc/html/man/curs_addch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_addchstr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_addstr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_attr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_beep.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_bkgd.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_border.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_clear.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_color.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_delch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_deleteln.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_extend.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_getch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_getstr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_getyx.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_inch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_inchstr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_initscr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_inopts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_insch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_insstr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_instr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_kernel.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_mouse.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_move.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_outopts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_overlay.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_pad.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_print.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_printw.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_refresh.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_scanw.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_scr_dump.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_scroll.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_slk.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_termattrs.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_termcap.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_terminfo.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_touch.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_trace.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_util.3x.html
create mode 100644 ncurses-5.2/doc/html/man/curs_window.3x.html
create mode 100644 ncurses-5.2/doc/html/man/default_colors.3x.html
create mode 100644 ncurses-5.2/doc/html/man/define_key.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_cursor.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_data.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_driver.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_attributes.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_buffer.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_info.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_just.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_new.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_opts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_userptr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_field_validation.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_fieldtype.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_hook.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_new.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_new_page.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_opts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_page.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_post.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_requestname.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_userptr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/form_win.3x.html
create mode 100644 ncurses-5.2/doc/html/man/infocmp.1m.html
create mode 100644 ncurses-5.2/doc/html/man/infotocap.1m.html
create mode 100644 ncurses-5.2/doc/html/man/keybound.3x.html
create mode 100644 ncurses-5.2/doc/html/man/keyok.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_attributes.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_cursor.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_driver.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_format.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_hook.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_items.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_mark.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_new.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_opts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_pattern.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_post.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_requestname.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_spacing.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_userptr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/menu_win.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_current.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_name.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_new.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_opts.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_userptr.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_value.3x.html
create mode 100644 ncurses-5.2/doc/html/man/mitem_visible.3x.html
create mode 100644 ncurses-5.2/doc/html/man/ncurses.3x.html
create mode 100644 ncurses-5.2/doc/html/man/panel.3x.html
create mode 100644 ncurses-5.2/doc/html/man/resizeterm.3x.html
create mode 100644 ncurses-5.2/doc/html/man/term.5.html
create mode 100644 ncurses-5.2/doc/html/man/term.7.html
create mode 100644 ncurses-5.2/doc/html/man/terminfo.5.html
create mode 100644 ncurses-5.2/doc/html/man/tic.1m.html
create mode 100644 ncurses-5.2/doc/html/man/toe.1m.html
create mode 100644 ncurses-5.2/doc/html/man/tput.1.html
create mode 100644 ncurses-5.2/doc/html/man/tset.1.html
create mode 100644 ncurses-5.2/doc/html/man/wresize.3x.html
create mode 100644 ncurses-5.2/doc/html/ncurses-intro.html
create mode 100644 ncurses-5.2/doc/ncurses-intro.doc
create mode 100644 ncurses-5.2/form/Makefile.in
create mode 100644 ncurses-5.2/form/READ.ME
create mode 100644 ncurses-5.2/form/fld_arg.c
create mode 100644 ncurses-5.2/form/fld_attr.c
create mode 100644 ncurses-5.2/form/fld_current.c
create mode 100644 ncurses-5.2/form/fld_def.c
create mode 100644 ncurses-5.2/form/fld_dup.c
create mode 100644 ncurses-5.2/form/fld_ftchoice.c
create mode 100644 ncurses-5.2/form/fld_ftlink.c
create mode 100644 ncurses-5.2/form/fld_info.c
create mode 100644 ncurses-5.2/form/fld_just.c
create mode 100644 ncurses-5.2/form/fld_link.c
create mode 100644 ncurses-5.2/form/fld_max.c
create mode 100644 ncurses-5.2/form/fld_move.c
create mode 100644 ncurses-5.2/form/fld_newftyp.c
create mode 100644 ncurses-5.2/form/fld_opts.c
create mode 100644 ncurses-5.2/form/fld_pad.c
create mode 100644 ncurses-5.2/form/fld_page.c
create mode 100644 ncurses-5.2/form/fld_stat.c
create mode 100644 ncurses-5.2/form/fld_type.c
create mode 100644 ncurses-5.2/form/fld_user.c
create mode 100644 ncurses-5.2/form/form.h
create mode 100644 ncurses-5.2/form/form.priv.h
create mode 100644 ncurses-5.2/form/frm_cursor.c
create mode 100644 ncurses-5.2/form/frm_data.c
create mode 100644 ncurses-5.2/form/frm_def.c
create mode 100644 ncurses-5.2/form/frm_driver.c
create mode 100644 ncurses-5.2/form/frm_hook.c
create mode 100644 ncurses-5.2/form/frm_opts.c
create mode 100644 ncurses-5.2/form/frm_page.c
create mode 100644 ncurses-5.2/form/frm_post.c
create mode 100644 ncurses-5.2/form/frm_req_name.c
create mode 100644 ncurses-5.2/form/frm_scale.c
create mode 100644 ncurses-5.2/form/frm_sub.c
create mode 100644 ncurses-5.2/form/frm_user.c
create mode 100644 ncurses-5.2/form/frm_win.c
create mode 100644 ncurses-5.2/form/fty_alnum.c
create mode 100644 ncurses-5.2/form/fty_alpha.c
create mode 100644 ncurses-5.2/form/fty_enum.c
create mode 100644 ncurses-5.2/form/fty_int.c
create mode 100644 ncurses-5.2/form/fty_ipv4.c
create mode 100644 ncurses-5.2/form/fty_num.c
create mode 100644 ncurses-5.2/form/fty_regex.c
create mode 100644 ncurses-5.2/form/headers
create mode 100644 ncurses-5.2/form/llib-lform
create mode 100644 ncurses-5.2/form/modules
create mode 100644 ncurses-5.2/include/Caps
create mode 100755 ncurses-5.2/include/MKhashsize.sh
create mode 100755 ncurses-5.2/include/MKncurses_def.sh
create mode 100755 ncurses-5.2/include/MKparametrized.sh
create mode 100644 ncurses-5.2/include/MKterm.h.awk.in
create mode 100644 ncurses-5.2/include/Makefile.in
create mode 100644 ncurses-5.2/include/capdefaults.c
create mode 100644 ncurses-5.2/include/curses.h.in
create mode 100755 ncurses-5.2/include/edit_cfg.sh
create mode 100644 ncurses-5.2/include/headers
create mode 100644 ncurses-5.2/include/nc_alloc.h
create mode 100644 ncurses-5.2/include/nc_panel.h
create mode 100644 ncurses-5.2/include/ncurses_cfg.hin
create mode 100644 ncurses-5.2/include/ncurses_defs
create mode 100644 ncurses-5.2/include/term_entry.h
create mode 100644 ncurses-5.2/include/termcap.h.in
create mode 100644 ncurses-5.2/include/tic.h
create mode 100644 ncurses-5.2/include/unctrl.h.in
create mode 100755 ncurses-5.2/install-sh
create mode 100755 ncurses-5.2/man/MKterminfo.sh
create mode 100644 ncurses-5.2/man/Makefile.in
create mode 100644 ncurses-5.2/man/captoinfo.1m
create mode 100644 ncurses-5.2/man/clear.1
create mode 100644 ncurses-5.2/man/curs_addch.3x
create mode 100644 ncurses-5.2/man/curs_addchstr.3x
create mode 100644 ncurses-5.2/man/curs_addstr.3x
create mode 100644 ncurses-5.2/man/curs_attr.3x
create mode 100644 ncurses-5.2/man/curs_beep.3x
create mode 100644 ncurses-5.2/man/curs_bkgd.3x
create mode 100644 ncurses-5.2/man/curs_border.3x
create mode 100644 ncurses-5.2/man/curs_clear.3x
create mode 100644 ncurses-5.2/man/curs_color.3x
create mode 100644 ncurses-5.2/man/curs_delch.3x
create mode 100644 ncurses-5.2/man/curs_deleteln.3x
create mode 100644 ncurses-5.2/man/curs_extend.3x
create mode 100644 ncurses-5.2/man/curs_getch.3x
create mode 100644 ncurses-5.2/man/curs_getstr.3x
create mode 100644 ncurses-5.2/man/curs_getyx.3x
create mode 100644 ncurses-5.2/man/curs_inch.3x
create mode 100644 ncurses-5.2/man/curs_inchstr.3x
create mode 100644 ncurses-5.2/man/curs_initscr.3x
create mode 100644 ncurses-5.2/man/curs_inopts.3x
create mode 100644 ncurses-5.2/man/curs_insch.3x
create mode 100644 ncurses-5.2/man/curs_insstr.3x
create mode 100644 ncurses-5.2/man/curs_instr.3x
create mode 100644 ncurses-5.2/man/curs_kernel.3x
create mode 100644 ncurses-5.2/man/curs_mouse.3x
create mode 100644 ncurses-5.2/man/curs_move.3x
create mode 100644 ncurses-5.2/man/curs_outopts.3x
create mode 100644 ncurses-5.2/man/curs_overlay.3x
create mode 100644 ncurses-5.2/man/curs_pad.3x
create mode 100644 ncurses-5.2/man/curs_print.3x
create mode 100644 ncurses-5.2/man/curs_printw.3x
create mode 100644 ncurses-5.2/man/curs_refresh.3x
create mode 100644 ncurses-5.2/man/curs_scanw.3x
create mode 100644 ncurses-5.2/man/curs_scr_dump.3x
create mode 100644 ncurses-5.2/man/curs_scroll.3x
create mode 100644 ncurses-5.2/man/curs_slk.3x
create mode 100644 ncurses-5.2/man/curs_termattrs.3x
create mode 100644 ncurses-5.2/man/curs_termcap.3x
create mode 100644 ncurses-5.2/man/curs_terminfo.3x
create mode 100644 ncurses-5.2/man/curs_touch.3x
create mode 100644 ncurses-5.2/man/curs_trace.3x
create mode 100644 ncurses-5.2/man/curs_util.3x
create mode 100644 ncurses-5.2/man/curs_window.3x
create mode 100644 ncurses-5.2/man/default_colors.3x
create mode 100644 ncurses-5.2/man/define_key.3x
create mode 100644 ncurses-5.2/man/form.3x
create mode 100644 ncurses-5.2/man/form_cursor.3x
create mode 100644 ncurses-5.2/man/form_data.3x
create mode 100644 ncurses-5.2/man/form_driver.3x
create mode 100644 ncurses-5.2/man/form_field.3x
create mode 100644 ncurses-5.2/man/form_field_attributes.3x
create mode 100644 ncurses-5.2/man/form_field_buffer.3x
create mode 100644 ncurses-5.2/man/form_field_info.3x
create mode 100644 ncurses-5.2/man/form_field_just.3x
create mode 100644 ncurses-5.2/man/form_field_new.3x
create mode 100644 ncurses-5.2/man/form_field_opts.3x
create mode 100644 ncurses-5.2/man/form_field_userptr.3x
create mode 100644 ncurses-5.2/man/form_field_validation.3x
create mode 100644 ncurses-5.2/man/form_fieldtype.3x
create mode 100644 ncurses-5.2/man/form_hook.3x
create mode 100644 ncurses-5.2/man/form_new.3x
create mode 100644 ncurses-5.2/man/form_new_page.3x
create mode 100644 ncurses-5.2/man/form_opts.3x
create mode 100644 ncurses-5.2/man/form_page.3x
create mode 100644 ncurses-5.2/man/form_post.3x
create mode 100644 ncurses-5.2/man/form_requestname.3x
create mode 100644 ncurses-5.2/man/form_userptr.3x
create mode 100644 ncurses-5.2/man/form_win.3x
create mode 100644 ncurses-5.2/man/infocmp.1m
create mode 100644 ncurses-5.2/man/infotocap.1m
create mode 100644 ncurses-5.2/man/keybound.3x
create mode 100644 ncurses-5.2/man/keyok.3x
create mode 100755 ncurses-5.2/man/make_sed.sh
create mode 100644 ncurses-5.2/man/man_db.renames
create mode 100644 ncurses-5.2/man/manlinks.sed
create mode 100644 ncurses-5.2/man/menu.3x
create mode 100644 ncurses-5.2/man/menu_attributes.3x
create mode 100644 ncurses-5.2/man/menu_cursor.3x
create mode 100644 ncurses-5.2/man/menu_driver.3x
create mode 100644 ncurses-5.2/man/menu_format.3x
create mode 100644 ncurses-5.2/man/menu_hook.3x
create mode 100644 ncurses-5.2/man/menu_items.3x
create mode 100644 ncurses-5.2/man/menu_mark.3x
create mode 100644 ncurses-5.2/man/menu_new.3x
create mode 100644 ncurses-5.2/man/menu_opts.3x
create mode 100644 ncurses-5.2/man/menu_pattern.3x
create mode 100644 ncurses-5.2/man/menu_post.3x
create mode 100644 ncurses-5.2/man/menu_requestname.3x
create mode 100644 ncurses-5.2/man/menu_spacing.3x
create mode 100644 ncurses-5.2/man/menu_userptr.3x
create mode 100644 ncurses-5.2/man/menu_win.3x
create mode 100644 ncurses-5.2/man/mitem_current.3x
create mode 100644 ncurses-5.2/man/mitem_name.3x
create mode 100644 ncurses-5.2/man/mitem_new.3x
create mode 100644 ncurses-5.2/man/mitem_opts.3x
create mode 100644 ncurses-5.2/man/mitem_userptr.3x
create mode 100644 ncurses-5.2/man/mitem_value.3x
create mode 100644 ncurses-5.2/man/mitem_visible.3x
create mode 100644 ncurses-5.2/man/ncurses.3x
create mode 100644 ncurses-5.2/man/panel.3x
create mode 100644 ncurses-5.2/man/resizeterm.3x
create mode 100644 ncurses-5.2/man/term.5
create mode 100644 ncurses-5.2/man/term.7
create mode 100644 ncurses-5.2/man/terminfo.head
create mode 100644 ncurses-5.2/man/terminfo.tail
create mode 100644 ncurses-5.2/man/tic.1m
create mode 100644 ncurses-5.2/man/toe.1m
create mode 100644 ncurses-5.2/man/tput.1
create mode 100644 ncurses-5.2/man/tset.1
create mode 100644 ncurses-5.2/man/wresize.3x
create mode 100644 ncurses-5.2/menu/Makefile.in
create mode 100644 ncurses-5.2/menu/READ.ME
create mode 100644 ncurses-5.2/menu/eti.h
create mode 100644 ncurses-5.2/menu/headers
create mode 100644 ncurses-5.2/menu/llib-lmenu
create mode 100644 ncurses-5.2/menu/m_attribs.c
create mode 100644 ncurses-5.2/menu/m_cursor.c
create mode 100644 ncurses-5.2/menu/m_driver.c
create mode 100644 ncurses-5.2/menu/m_format.c
create mode 100644 ncurses-5.2/menu/m_global.c
create mode 100644 ncurses-5.2/menu/m_hook.c
create mode 100644 ncurses-5.2/menu/m_item_cur.c
create mode 100644 ncurses-5.2/menu/m_item_nam.c
create mode 100644 ncurses-5.2/menu/m_item_new.c
create mode 100644 ncurses-5.2/menu/m_item_opt.c
create mode 100644 ncurses-5.2/menu/m_item_top.c
create mode 100644 ncurses-5.2/menu/m_item_use.c
create mode 100644 ncurses-5.2/menu/m_item_val.c
create mode 100644 ncurses-5.2/menu/m_item_vis.c
create mode 100644 ncurses-5.2/menu/m_items.c
create mode 100644 ncurses-5.2/menu/m_new.c
create mode 100644 ncurses-5.2/menu/m_opts.c
create mode 100644 ncurses-5.2/menu/m_pad.c
create mode 100644 ncurses-5.2/menu/m_pattern.c
create mode 100644 ncurses-5.2/menu/m_post.c
create mode 100644 ncurses-5.2/menu/m_req_name.c
create mode 100644 ncurses-5.2/menu/m_scale.c
create mode 100644 ncurses-5.2/menu/m_spacing.c
create mode 100644 ncurses-5.2/menu/m_sub.c
create mode 100644 ncurses-5.2/menu/m_userptr.c
create mode 100644 ncurses-5.2/menu/m_win.c
create mode 100644 ncurses-5.2/menu/menu.h
create mode 100644 ncurses-5.2/menu/menu.priv.h
create mode 100644 ncurses-5.2/menu/mf_common.h
create mode 100644 ncurses-5.2/menu/modules
create mode 100644 ncurses-5.2/misc/Makefile.in
create mode 100644 ncurses-5.2/misc/chkdef.cmd
create mode 100644 ncurses-5.2/misc/cleantic.cmd
create mode 100644 ncurses-5.2/misc/cmpdef.cmd
create mode 100644 ncurses-5.2/misc/emx.src
create mode 100644 ncurses-5.2/misc/form.def
create mode 100644 ncurses-5.2/misc/form.ref
create mode 100644 ncurses-5.2/misc/indent.pro
create mode 100644 ncurses-5.2/misc/makedef.cmd
create mode 100755 ncurses-5.2/misc/makellib
create mode 100644 ncurses-5.2/misc/menu.def
create mode 100644 ncurses-5.2/misc/menu.ref
create mode 100644 ncurses-5.2/misc/ncurses.def
create mode 100644 ncurses-5.2/misc/ncurses.ref
create mode 100644 ncurses-5.2/misc/panel.def
create mode 100644 ncurses-5.2/misc/panel.ref
create mode 100644 ncurses-5.2/misc/run_tic.in
create mode 100755 ncurses-5.2/misc/shlib
create mode 100644 ncurses-5.2/misc/tabset/std
create mode 100644 ncurses-5.2/misc/tabset/stdcrt
create mode 100644 ncurses-5.2/misc/tabset/vt100
create mode 100644 ncurses-5.2/misc/tabset/vt300
create mode 100755 ncurses-5.2/misc/tdlint
create mode 100644 ncurses-5.2/misc/terminfo.src
create mode 100644 ncurses-5.2/mk-0th.awk
create mode 100644 ncurses-5.2/mk-1st.awk
create mode 100644 ncurses-5.2/mk-2nd.awk
create mode 100755 ncurses-5.2/mkinstalldirs
create mode 100644 ncurses-5.2/ncurses/Makefile.in
create mode 100644 ncurses-5.2/ncurses/README
create mode 100644 ncurses-5.2/ncurses/SigAction.h
create mode 100644 ncurses-5.2/ncurses/base/MKkeyname.awk
create mode 100755 ncurses-5.2/ncurses/base/MKlib_gen.sh
create mode 100644 ncurses-5.2/ncurses/base/MKunctrl.awk
create mode 100644 ncurses-5.2/ncurses/base/README
create mode 100644 ncurses-5.2/ncurses/base/define_key.c
create mode 100644 ncurses-5.2/ncurses/base/keybound.c
create mode 100644 ncurses-5.2/ncurses/base/keyok.c
create mode 100644 ncurses-5.2/ncurses/base/lib_addch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_addstr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_beep.c
create mode 100644 ncurses-5.2/ncurses/base/lib_bkgd.c
create mode 100644 ncurses-5.2/ncurses/base/lib_box.c
create mode 100644 ncurses-5.2/ncurses/base/lib_chgat.c
create mode 100644 ncurses-5.2/ncurses/base/lib_clear.c
create mode 100644 ncurses-5.2/ncurses/base/lib_clearok.c
create mode 100644 ncurses-5.2/ncurses/base/lib_clrbot.c
create mode 100644 ncurses-5.2/ncurses/base/lib_clreol.c
create mode 100644 ncurses-5.2/ncurses/base/lib_color.c
create mode 100644 ncurses-5.2/ncurses/base/lib_colorset.c
create mode 100644 ncurses-5.2/ncurses/base/lib_delch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_delwin.c
create mode 100644 ncurses-5.2/ncurses/base/lib_dft_fgbg.c
create mode 100644 ncurses-5.2/ncurses/base/lib_echo.c
create mode 100644 ncurses-5.2/ncurses/base/lib_endwin.c
create mode 100644 ncurses-5.2/ncurses/base/lib_erase.c
create mode 100644 ncurses-5.2/ncurses/base/lib_flash.c
create mode 100644 ncurses-5.2/ncurses/base/lib_freeall.c
create mode 100644 ncurses-5.2/ncurses/base/lib_getch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_getstr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_hline.c
create mode 100644 ncurses-5.2/ncurses/base/lib_immedok.c
create mode 100644 ncurses-5.2/ncurses/base/lib_inchstr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_initscr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_insch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_insdel.c
create mode 100644 ncurses-5.2/ncurses/base/lib_insstr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_instr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_isendwin.c
create mode 100644 ncurses-5.2/ncurses/base/lib_leaveok.c
create mode 100644 ncurses-5.2/ncurses/base/lib_mouse.c
create mode 100644 ncurses-5.2/ncurses/base/lib_move.c
create mode 100644 ncurses-5.2/ncurses/base/lib_mvwin.c
create mode 100644 ncurses-5.2/ncurses/base/lib_newterm.c
create mode 100644 ncurses-5.2/ncurses/base/lib_newwin.c
create mode 100644 ncurses-5.2/ncurses/base/lib_nl.c
create mode 100644 ncurses-5.2/ncurses/base/lib_overlay.c
create mode 100644 ncurses-5.2/ncurses/base/lib_pad.c
create mode 100644 ncurses-5.2/ncurses/base/lib_printw.c
create mode 100644 ncurses-5.2/ncurses/base/lib_redrawln.c
create mode 100644 ncurses-5.2/ncurses/base/lib_refresh.c
create mode 100644 ncurses-5.2/ncurses/base/lib_restart.c
create mode 100644 ncurses-5.2/ncurses/base/lib_scanw.c
create mode 100644 ncurses-5.2/ncurses/base/lib_screen.c
create mode 100644 ncurses-5.2/ncurses/base/lib_scroll.c
create mode 100644 ncurses-5.2/ncurses/base/lib_scrollok.c
create mode 100644 ncurses-5.2/ncurses/base/lib_scrreg.c
create mode 100644 ncurses-5.2/ncurses/base/lib_set_term.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slk.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkatr_set.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkatrof.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkatron.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkatrset.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkattr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkclear.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkcolor.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkinit.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slklab.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkrefr.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slkset.c
create mode 100644 ncurses-5.2/ncurses/base/lib_slktouch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_touch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_ungetch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_vline.c
create mode 100644 ncurses-5.2/ncurses/base/lib_wattroff.c
create mode 100644 ncurses-5.2/ncurses/base/lib_wattron.c
create mode 100644 ncurses-5.2/ncurses/base/lib_winch.c
create mode 100644 ncurses-5.2/ncurses/base/lib_window.c
create mode 100644 ncurses-5.2/ncurses/base/memmove.c
create mode 100644 ncurses-5.2/ncurses/base/nc_panel.c
create mode 100644 ncurses-5.2/ncurses/base/resizeterm.c
create mode 100644 ncurses-5.2/ncurses/base/safe_sprintf.c
create mode 100644 ncurses-5.2/ncurses/base/sigaction.c
create mode 100644 ncurses-5.2/ncurses/base/tries.c
create mode 100644 ncurses-5.2/ncurses/base/version.c
create mode 100644 ncurses-5.2/ncurses/base/vsscanf.c
create mode 100644 ncurses-5.2/ncurses/base/wresize.c
create mode 100644 ncurses-5.2/ncurses/curses.priv.h
create mode 100644 ncurses-5.2/ncurses/fifo_defs.h
create mode 100644 ncurses-5.2/ncurses/llib-lncurses
create mode 100644 ncurses-5.2/ncurses/modules
create mode 100644 ncurses-5.2/ncurses/tinfo/MKcaptab.awk
create mode 100755 ncurses-5.2/ncurses/tinfo/MKfallback.sh
create mode 100644 ncurses-5.2/ncurses/tinfo/MKnames.awk
create mode 100644 ncurses-5.2/ncurses/tinfo/README
create mode 100644 ncurses-5.2/ncurses/tinfo/access.c
create mode 100644 ncurses-5.2/ncurses/tinfo/add_tries.c
create mode 100644 ncurses-5.2/ncurses/tinfo/alloc_entry.c
create mode 100644 ncurses-5.2/ncurses/tinfo/alloc_ttype.c
create mode 100644 ncurses-5.2/ncurses/tinfo/captoinfo.c
create mode 100644 ncurses-5.2/ncurses/tinfo/comp_error.c
create mode 100644 ncurses-5.2/ncurses/tinfo/comp_expand.c
create mode 100644 ncurses-5.2/ncurses/tinfo/comp_hash.c
create mode 100644 ncurses-5.2/ncurses/tinfo/comp_parse.c
create mode 100644 ncurses-5.2/ncurses/tinfo/comp_scan.c
create mode 100644 ncurses-5.2/ncurses/tinfo/doalloc.c
create mode 100644 ncurses-5.2/ncurses/tinfo/free_ttype.c
create mode 100644 ncurses-5.2/ncurses/tinfo/getenv_num.c
create mode 100644 ncurses-5.2/ncurses/tinfo/home_terminfo.c
create mode 100644 ncurses-5.2/ncurses/tinfo/init_keytry.c
create mode 100644 ncurses-5.2/ncurses/tinfo/keys.list
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_acs.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_baudrate.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_cur_term.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_data.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_has_cap.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_kernel.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_longname.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_napms.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_options.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_print.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_raw.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_setup.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_termcap.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_termname.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_tgoto.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_ti.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_tparm.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_tputs.c
create mode 100644 ncurses-5.2/ncurses/tinfo/lib_ttyflags.c
create mode 100644 ncurses-5.2/ncurses/tinfo/make_keys.c
create mode 100644 ncurses-5.2/ncurses/tinfo/name_match.c
create mode 100644 ncurses-5.2/ncurses/tinfo/parse_entry.c
create mode 100644 ncurses-5.2/ncurses/tinfo/read_entry.c
create mode 100644 ncurses-5.2/ncurses/tinfo/read_termcap.c
create mode 100644 ncurses-5.2/ncurses/tinfo/setbuf.c
create mode 100644 ncurses-5.2/ncurses/tinfo/strings.c
create mode 100644 ncurses-5.2/ncurses/tinfo/write_entry.c
create mode 100644 ncurses-5.2/ncurses/trace/README
create mode 100644 ncurses-5.2/ncurses/trace/lib_trace.c
create mode 100644 ncurses-5.2/ncurses/trace/lib_traceatr.c
create mode 100644 ncurses-5.2/ncurses/trace/lib_tracebits.c
create mode 100644 ncurses-5.2/ncurses/trace/lib_tracechr.c
create mode 100644 ncurses-5.2/ncurses/trace/lib_tracedmp.c
create mode 100644 ncurses-5.2/ncurses/trace/lib_tracemse.c
create mode 100644 ncurses-5.2/ncurses/trace/trace_buf.c
create mode 100644 ncurses-5.2/ncurses/trace/trace_tries.c
create mode 100644 ncurses-5.2/ncurses/trace/trace_xnames.c
create mode 100755 ncurses-5.2/ncurses/tty/MKexpanded.sh
create mode 100644 ncurses-5.2/ncurses/tty/hardscroll.c
create mode 100644 ncurses-5.2/ncurses/tty/hashmap.c
create mode 100644 ncurses-5.2/ncurses/tty/lib_mvcur.c
create mode 100644 ncurses-5.2/ncurses/tty/lib_tstp.c
create mode 100644 ncurses-5.2/ncurses/tty/lib_twait.c
create mode 100644 ncurses-5.2/ncurses/tty/lib_vidattr.c
create mode 100644 ncurses-5.2/ncurses/tty/tty_display.h
create mode 100644 ncurses-5.2/ncurses/tty/tty_input.h
create mode 100644 ncurses-5.2/ncurses/tty/tty_update.c
create mode 100644 ncurses-5.2/panel/Makefile.in
create mode 100644 ncurses-5.2/panel/headers
create mode 100644 ncurses-5.2/panel/llib-lpanel
create mode 100644 ncurses-5.2/panel/modules
create mode 100644 ncurses-5.2/panel/p_above.c
create mode 100644 ncurses-5.2/panel/p_below.c
create mode 100644 ncurses-5.2/panel/p_bottom.c
create mode 100644 ncurses-5.2/panel/p_delete.c
create mode 100644 ncurses-5.2/panel/p_hidden.c
create mode 100644 ncurses-5.2/panel/p_hide.c
create mode 100644 ncurses-5.2/panel/p_move.c
create mode 100644 ncurses-5.2/panel/p_new.c
create mode 100644 ncurses-5.2/panel/p_replace.c
create mode 100644 ncurses-5.2/panel/p_show.c
create mode 100644 ncurses-5.2/panel/p_top.c
create mode 100644 ncurses-5.2/panel/p_update.c
create mode 100644 ncurses-5.2/panel/p_user.c
create mode 100644 ncurses-5.2/panel/p_win.c
create mode 100644 ncurses-5.2/panel/panel.c
create mode 100644 ncurses-5.2/panel/panel.h
create mode 100644 ncurses-5.2/panel/panel.priv.h
create mode 100755 ncurses-5.2/progs/MKtermsort.sh
create mode 100644 ncurses-5.2/progs/Makefile.in
create mode 100755 ncurses-5.2/progs/capconvert
create mode 100644 ncurses-5.2/progs/clear.c
create mode 100755 ncurses-5.2/progs/clear.sh
create mode 100644 ncurses-5.2/progs/dump_entry.c
create mode 100644 ncurses-5.2/progs/dump_entry.h
create mode 100644 ncurses-5.2/progs/infocmp.c
create mode 100644 ncurses-5.2/progs/modules
create mode 100644 ncurses-5.2/progs/progs.priv.h
create mode 100644 ncurses-5.2/progs/tic.c
create mode 100644 ncurses-5.2/progs/toe.c
create mode 100644 ncurses-5.2/progs/tput.c
create mode 100644 ncurses-5.2/progs/tset.c
create mode 100644 ncurses-5.2/sysdeps/unix/sysv/linux/Makefile
create mode 100755 ncurses-5.2/sysdeps/unix/sysv/linux/alpha/configure
create mode 100755 ncurses-5.2/sysdeps/unix/sysv/linux/configure
create mode 100644 ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sed
create mode 100755 ncurses-5.2/sysdeps/unix/sysv/linux/edit_man.sh
create mode 100755 ncurses-5.2/sysdeps/unix/sysv/linux/run_tic.sh
create mode 100644 ncurses-5.2/tack/COPYING
create mode 100644 ncurses-5.2/tack/HISTORY
create mode 100644 ncurses-5.2/tack/Makefile.in
create mode 100644 ncurses-5.2/tack/README
create mode 100644 ncurses-5.2/tack/ansi.c
create mode 100644 ncurses-5.2/tack/charset.c
create mode 100644 ncurses-5.2/tack/color.c
create mode 100644 ncurses-5.2/tack/control.c
create mode 100644 ncurses-5.2/tack/crum.c
create mode 100644 ncurses-5.2/tack/edit.c
create mode 100644 ncurses-5.2/tack/fun.c
create mode 100644 ncurses-5.2/tack/init.c
create mode 100644 ncurses-5.2/tack/menu.c
create mode 100644 ncurses-5.2/tack/modes.c
create mode 100644 ncurses-5.2/tack/modules
create mode 100644 ncurses-5.2/tack/output.c
create mode 100644 ncurses-5.2/tack/pad.c
create mode 100644 ncurses-5.2/tack/scan.c
create mode 100644 ncurses-5.2/tack/sync.c
create mode 100644 ncurses-5.2/tack/sysdep.c
create mode 100644 ncurses-5.2/tack/tack.1
create mode 100644 ncurses-5.2/tack/tack.c
create mode 100644 ncurses-5.2/tack/tack.h
create mode 100755 ncurses-5.2/tar-copy.sh
create mode 100644 ncurses-5.2/test/Makefile.in
create mode 100644 ncurses-5.2/test/README
create mode 100644 ncurses-5.2/test/blue.c
create mode 100644 ncurses-5.2/test/bs.6
create mode 100644 ncurses-5.2/test/bs.c
create mode 100644 ncurses-5.2/test/cardfile.c
create mode 100644 ncurses-5.2/test/cardfile.dat
create mode 100755 ncurses-5.2/test/configure
create mode 100644 ncurses-5.2/test/configure.in
create mode 100644 ncurses-5.2/test/ditto.c
create mode 100644 ncurses-5.2/test/dots.c
create mode 100644 ncurses-5.2/test/filter.c
create mode 100644 ncurses-5.2/test/firework.c
create mode 100644 ncurses-5.2/test/firstlast.c
create mode 100644 ncurses-5.2/test/gdc.6
create mode 100644 ncurses-5.2/test/gdc.c
create mode 100644 ncurses-5.2/test/hanoi.c
create mode 100644 ncurses-5.2/test/hashtest.c
create mode 100644 ncurses-5.2/test/keynames.c
create mode 100644 ncurses-5.2/test/knight.c
create mode 100644 ncurses-5.2/test/lrtest.c
create mode 100644 ncurses-5.2/test/modules
create mode 100644 ncurses-5.2/test/ncurses.c
create mode 100644 ncurses-5.2/test/ncurses_tst.hin
create mode 100644 ncurses-5.2/test/newdemo.c
create mode 100644 ncurses-5.2/test/railroad.c
create mode 100644 ncurses-5.2/test/rain.c
create mode 100644 ncurses-5.2/test/tclock.c
create mode 100644 ncurses-5.2/test/test.priv.h
create mode 100644 ncurses-5.2/test/testaddch.c
create mode 100644 ncurses-5.2/test/testcurs.c
create mode 100644 ncurses-5.2/test/testscanw.c
create mode 100755 ncurses-5.2/test/tracemunch
create mode 100644 ncurses-5.2/test/view.c
create mode 100644 ncurses-5.2/test/worm.c
create mode 100644 ncurses-5.2/test/xmas.c
create mode 100644 readline-4.3.orig/CHANGELOG
create mode 100644 readline-4.3.orig/CHANGES
create mode 100644 readline-4.3.orig/COPYING
create mode 100644 readline-4.3.orig/INSTALL
create mode 100644 readline-4.3.orig/MANIFEST
create mode 100644 readline-4.3.orig/Makefile.in
create mode 100644 readline-4.3.orig/README
create mode 100644 readline-4.3.orig/USAGE
create mode 100644 readline-4.3.orig/aclocal.m4
create mode 100644 readline-4.3.orig/ansi_stdlib.h
create mode 100644 readline-4.3.orig/bind.c
create mode 100644 readline-4.3.orig/callback.c
create mode 100644 readline-4.3.orig/chardefs.h
create mode 100644 readline-4.3.orig/compat.c
create mode 100644 readline-4.3.orig/complete.c
create mode 100644 readline-4.3.orig/config.h.in
create mode 100755 readline-4.3.orig/configure
create mode 100644 readline-4.3.orig/configure.in
create mode 100644 readline-4.3.orig/display.c
create mode 100644 readline-4.3.orig/doc/Makefile.in
create mode 100644 readline-4.3.orig/doc/hist.texinfo
create mode 100644 readline-4.3.orig/doc/history.0
create mode 100644 readline-4.3.orig/doc/history.3
create mode 100644 readline-4.3.orig/doc/history.dvi
create mode 100644 readline-4.3.orig/doc/history.html
create mode 100644 readline-4.3.orig/doc/history.info
create mode 100644 readline-4.3.orig/doc/history.ps
create mode 100644 readline-4.3.orig/doc/history_3.ps
create mode 100644 readline-4.3.orig/doc/hstech.texinfo
create mode 100644 readline-4.3.orig/doc/hsuser.texinfo
create mode 100644 readline-4.3.orig/doc/manvers.texinfo
create mode 100644 readline-4.3.orig/doc/readline.0
create mode 100644 readline-4.3.orig/doc/readline.3
create mode 100644 readline-4.3.orig/doc/readline.dvi
create mode 100644 readline-4.3.orig/doc/readline.html
create mode 100644 readline-4.3.orig/doc/readline.info
create mode 100644 readline-4.3.orig/doc/readline.ps
create mode 100644 readline-4.3.orig/doc/readline_3.ps
create mode 100644 readline-4.3.orig/doc/rlman.texinfo
create mode 100644 readline-4.3.orig/doc/rltech.texinfo
create mode 100644 readline-4.3.orig/doc/rluser.texinfo
create mode 100644 readline-4.3.orig/doc/rluserman.dvi
create mode 100644 readline-4.3.orig/doc/rluserman.html
create mode 100644 readline-4.3.orig/doc/rluserman.info
create mode 100644 readline-4.3.orig/doc/rluserman.ps
create mode 100644 readline-4.3.orig/doc/rluserman.texinfo
create mode 100755 readline-4.3.orig/doc/texi2dvi
create mode 100755 readline-4.3.orig/doc/texi2html
create mode 100644 readline-4.3.orig/doc/texinfo.tex
create mode 100644 readline-4.3.orig/emacs_keymap.c
create mode 100644 readline-4.3.orig/examples/Inputrc
create mode 100644 readline-4.3.orig/examples/Makefile.in
create mode 100644 readline-4.3.orig/examples/excallback.c
create mode 100644 readline-4.3.orig/examples/fileman.c
create mode 100644 readline-4.3.orig/examples/histexamp.c
create mode 100644 readline-4.3.orig/examples/manexamp.c
create mode 100644 readline-4.3.orig/examples/readlinebuf.h
create mode 100644 readline-4.3.orig/examples/rl.c
create mode 100644 readline-4.3.orig/examples/rlcat.c
create mode 100644 readline-4.3.orig/examples/rlfe.c
create mode 100644 readline-4.3.orig/examples/rltest.c
create mode 100644 readline-4.3.orig/examples/rlversion.c
create mode 100644 readline-4.3.orig/funmap.c
create mode 100644 readline-4.3.orig/histexpand.c
create mode 100644 readline-4.3.orig/histfile.c
create mode 100644 readline-4.3.orig/histlib.h
create mode 100644 readline-4.3.orig/history.c
create mode 100644 readline-4.3.orig/history.h
create mode 100644 readline-4.3.orig/histsearch.c
create mode 100644 readline-4.3.orig/input.c
create mode 100644 readline-4.3.orig/isearch.c
create mode 100644 readline-4.3.orig/keymaps.c
create mode 100644 readline-4.3.orig/keymaps.h
create mode 100644 readline-4.3.orig/kill.c
create mode 100644 readline-4.3.orig/macro.c
create mode 100644 readline-4.3.orig/mbutil.c
create mode 100644 readline-4.3.orig/misc.c
create mode 100644 readline-4.3.orig/nls.c
create mode 100644 readline-4.3.orig/parens.c
create mode 100644 readline-4.3.orig/posixdir.h
create mode 100644 readline-4.3.orig/posixjmp.h
create mode 100644 readline-4.3.orig/posixstat.h
create mode 100644 readline-4.3.orig/readline.c
create mode 100644 readline-4.3.orig/readline.h
create mode 100644 readline-4.3.orig/rlconf.h
create mode 100644 readline-4.3.orig/rldefs.h
create mode 100644 readline-4.3.orig/rlmbutil.h
create mode 100644 readline-4.3.orig/rlprivate.h
create mode 100644 readline-4.3.orig/rlshell.h
create mode 100644 readline-4.3.orig/rlstdc.h
create mode 100644 readline-4.3.orig/rltty.c
create mode 100644 readline-4.3.orig/rltty.h
create mode 100644 readline-4.3.orig/rltypedefs.h
create mode 100644 readline-4.3.orig/rlwinsize.h
create mode 100644 readline-4.3.orig/savestring.c
create mode 100644 readline-4.3.orig/search.c
create mode 100644 readline-4.3.orig/shell.c
create mode 100644 readline-4.3.orig/shlib/Makefile.in
create mode 100644 readline-4.3.orig/signals.c
create mode 100755 readline-4.3.orig/support/config.guess
create mode 100644 readline-4.3.orig/support/config.sub
create mode 100755 readline-4.3.orig/support/install.sh
create mode 100755 readline-4.3.orig/support/mkdirs
create mode 100755 readline-4.3.orig/support/mkdist
create mode 100755 readline-4.3.orig/support/shlib-install
create mode 100755 readline-4.3.orig/support/shobj-conf
create mode 100644 readline-4.3.orig/support/wcwidth.c
create mode 100644 readline-4.3.orig/tcap.h
create mode 100644 readline-4.3.orig/terminal.c
create mode 100644 readline-4.3.orig/text.c
create mode 100644 readline-4.3.orig/tilde.c
create mode 100644 readline-4.3.orig/tilde.h
create mode 100644 readline-4.3.orig/undo.c
create mode 100644 readline-4.3.orig/util.c
create mode 100644 readline-4.3.orig/vi_keymap.c
create mode 100644 readline-4.3.orig/vi_mode.c
create mode 100644 readline-4.3.orig/xmalloc.c
create mode 100644 readline-4.3.orig/xmalloc.h
create mode 100644 readline-4.3/CHANGELOG-ReadLine
create mode 100644 readline-4.3/CHANGES
create mode 100644 readline-4.3/COPYING
create mode 100644 readline-4.3/ChangeLog
create mode 100644 readline-4.3/INSTALL
create mode 100644 readline-4.3/MANIFEST
create mode 100644 readline-4.3/Makefile.in
create mode 100644 readline-4.3/README
create mode 100644 readline-4.3/USAGE
create mode 100644 readline-4.3/aclocal.m4
create mode 100644 readline-4.3/ansi_stdlib.h
create mode 100644 readline-4.3/bind.c
create mode 100644 readline-4.3/callback.c
create mode 100644 readline-4.3/chardefs.h
create mode 100644 readline-4.3/compat.c
create mode 100644 readline-4.3/complete.c
create mode 100644 readline-4.3/config.h.in
create mode 100755 readline-4.3/configure
create mode 100644 readline-4.3/configure.in
create mode 100644 readline-4.3/display.c
create mode 100644 readline-4.3/doc/Makefile.in
create mode 100644 readline-4.3/doc/hist.texinfo
create mode 100644 readline-4.3/doc/history.3
create mode 100644 readline-4.3/doc/hstech.texinfo
create mode 100644 readline-4.3/doc/hsuser.texinfo
create mode 100644 readline-4.3/doc/manvers.texinfo
create mode 100644 readline-4.3/doc/readline.3
create mode 100644 readline-4.3/doc/rlman.texinfo
create mode 100644 readline-4.3/doc/rltech.texinfo
create mode 100644 readline-4.3/doc/rluser.texinfo
create mode 100644 readline-4.3/doc/rluserman.texinfo
create mode 100755 readline-4.3/doc/texi2dvi
create mode 100755 readline-4.3/doc/texi2html
create mode 100644 readline-4.3/doc/texinfo.tex
create mode 100644 readline-4.3/emacs_keymap.c
create mode 100644 readline-4.3/examples/Inputrc
create mode 100644 readline-4.3/examples/Makefile.in
create mode 100644 readline-4.3/examples/excallback.c
create mode 100644 readline-4.3/examples/fileman.c
create mode 100644 readline-4.3/examples/histexamp.c
create mode 100644 readline-4.3/examples/manexamp.c
create mode 100644 readline-4.3/examples/readlinebuf.h
create mode 100644 readline-4.3/examples/rl.c
create mode 100644 readline-4.3/examples/rlcat.c
create mode 100644 readline-4.3/examples/rlfe.c
create mode 100644 readline-4.3/examples/rltest.c
create mode 100644 readline-4.3/examples/rlversion.c
create mode 100644 readline-4.3/funmap.c
create mode 100644 readline-4.3/histexpand.c
create mode 100644 readline-4.3/histfile.c
create mode 100644 readline-4.3/histlib.h
create mode 100644 readline-4.3/history.c
create mode 100644 readline-4.3/history.h
create mode 100644 readline-4.3/histsearch.c
create mode 100644 readline-4.3/input.c
create mode 100644 readline-4.3/isearch.c
create mode 100644 readline-4.3/keymaps.c
create mode 100644 readline-4.3/keymaps.h
create mode 100644 readline-4.3/kill.c
create mode 100644 readline-4.3/macro.c
create mode 100644 readline-4.3/mbutil.c
create mode 100644 readline-4.3/misc.c
create mode 100644 readline-4.3/nls.c
create mode 100644 readline-4.3/parens.c
create mode 100644 readline-4.3/posixdir.h
create mode 100644 readline-4.3/posixjmp.h
create mode 100644 readline-4.3/posixstat.h
create mode 100644 readline-4.3/readline.c
create mode 100644 readline-4.3/readline.h
create mode 100644 readline-4.3/rlconf.h
create mode 100644 readline-4.3/rldefs.h
create mode 100644 readline-4.3/rlmbutil.h
create mode 100644 readline-4.3/rlprivate.h
create mode 100644 readline-4.3/rlshell.h
create mode 100644 readline-4.3/rlstdc.h
create mode 100644 readline-4.3/rltty.c
create mode 100644 readline-4.3/rltty.h
create mode 100644 readline-4.3/rltypedefs.h
create mode 100644 readline-4.3/rlwinsize.h
create mode 100644 readline-4.3/savestring.c
create mode 100644 readline-4.3/search.c
create mode 100644 readline-4.3/shell.c
create mode 100644 readline-4.3/shlib/Makefile.in
create mode 100644 readline-4.3/signals.c
create mode 100755 readline-4.3/support/config.guess
create mode 100644 readline-4.3/support/config.sub
create mode 100755 readline-4.3/support/install.sh
create mode 100755 readline-4.3/support/mkdirs
create mode 100755 readline-4.3/support/mkdist
create mode 100755 readline-4.3/support/shlib-install
create mode 100755 readline-4.3/support/shobj-conf
create mode 100644 readline-4.3/support/wcwidth.c
create mode 100644 readline-4.3/tcap.h
create mode 100644 readline-4.3/terminal.c
create mode 100644 readline-4.3/text.c
create mode 100644 readline-4.3/tilde.c
create mode 100644 readline-4.3/tilde.h
create mode 100644 readline-4.3/undo.c
create mode 100644 readline-4.3/util.c
create mode 100644 readline-4.3/vi_keymap.c
create mode 100644 readline-4.3/vi_mode.c
create mode 100644 readline-4.3/xmalloc.c
create mode 100644 readline-4.3/xmalloc.h
create mode 100644 readline-doc-4.3/MANIFEST.doc
create mode 100644 readline-doc-4.3/doc/history.0
create mode 100644 readline-doc-4.3/doc/history.dvi
create mode 100644 readline-doc-4.3/doc/history.html
create mode 100644 readline-doc-4.3/doc/history.info
create mode 100644 readline-doc-4.3/doc/history.ps
create mode 100644 readline-doc-4.3/doc/history_3.ps
create mode 100644 readline-doc-4.3/doc/readline.0
create mode 100644 readline-doc-4.3/doc/readline.dvi
create mode 100644 readline-doc-4.3/doc/readline.html
create mode 100644 readline-doc-4.3/doc/readline.info
create mode 100644 readline-doc-4.3/doc/readline.ps
create mode 100644 readline-doc-4.3/doc/readline_3.ps
create mode 100644 readline-doc-4.3/doc/rluserman.dvi
create mode 100644 readline-doc-4.3/doc/rluserman.html
create mode 100644 readline-doc-4.3/doc/rluserman.info
create mode 100644 readline-doc-4.3/doc/rluserman.ps
create mode 100644 zlib-1.1.4/ChangeLog
create mode 100644 zlib-1.1.4/FAQ
create mode 100644 zlib-1.1.4/INDEX
create mode 100644 zlib-1.1.4/Make_vms.com
create mode 100644 zlib-1.1.4/Makefile
create mode 100644 zlib-1.1.4/Makefile.in
create mode 100644 zlib-1.1.4/Makefile.riscos
create mode 100644 zlib-1.1.4/README
create mode 100644 zlib-1.1.4/adler32.c
create mode 100644 zlib-1.1.4/algorithm.txt
create mode 100644 zlib-1.1.4/amiga/Makefile.pup
create mode 100644 zlib-1.1.4/amiga/Makefile.sas
create mode 100644 zlib-1.1.4/compress.c
create mode 100755 zlib-1.1.4/configure
create mode 100644 zlib-1.1.4/contrib/README.contrib
create mode 100644 zlib-1.1.4/contrib/asm386/gvmat32.asm
create mode 100644 zlib-1.1.4/contrib/asm386/gvmat32c.c
create mode 100644 zlib-1.1.4/contrib/asm386/mkgvmt32.bat
create mode 100644 zlib-1.1.4/contrib/asm386/zlibvc.def
create mode 100644 zlib-1.1.4/contrib/asm386/zlibvc.dsp
create mode 100644 zlib-1.1.4/contrib/asm386/zlibvc.dsw
create mode 100644 zlib-1.1.4/contrib/asm586/README.586
create mode 100644 zlib-1.1.4/contrib/asm586/match.S
create mode 100644 zlib-1.1.4/contrib/asm686/README.686
create mode 100644 zlib-1.1.4/contrib/asm686/match.S
create mode 100644 zlib-1.1.4/contrib/delphi/zlib.mak
create mode 100644 zlib-1.1.4/contrib/delphi/zlibdef.pas
create mode 100644 zlib-1.1.4/contrib/delphi2/d_zlib.bpr
create mode 100644 zlib-1.1.4/contrib/delphi2/d_zlib.cpp
create mode 100644 zlib-1.1.4/contrib/delphi2/readme.txt
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib.bpg
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib.bpr
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib.cpp
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib.pas
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib32.bpr
create mode 100644 zlib-1.1.4/contrib/delphi2/zlib32.cpp
create mode 100644 zlib-1.1.4/contrib/iostream/test.cpp
create mode 100644 zlib-1.1.4/contrib/iostream/zfstream.cpp
create mode 100644 zlib-1.1.4/contrib/iostream/zfstream.h
create mode 100644 zlib-1.1.4/contrib/iostream2/zstream.h
create mode 100644 zlib-1.1.4/contrib/iostream2/zstream_test.cpp
create mode 100644 zlib-1.1.4/contrib/minizip/ChangeLogUnzip
create mode 100644 zlib-1.1.4/contrib/minizip/Makefile
create mode 100644 zlib-1.1.4/contrib/minizip/miniunz.c
create mode 100644 zlib-1.1.4/contrib/minizip/minizip.c
create mode 100644 zlib-1.1.4/contrib/minizip/readme.txt
create mode 100644 zlib-1.1.4/contrib/minizip/unzip.c
create mode 100644 zlib-1.1.4/contrib/minizip/unzip.def
create mode 100644 zlib-1.1.4/contrib/minizip/unzip.h
create mode 100644 zlib-1.1.4/contrib/minizip/zip.c
create mode 100644 zlib-1.1.4/contrib/minizip/zip.def
create mode 100644 zlib-1.1.4/contrib/minizip/zip.h
create mode 100644 zlib-1.1.4/contrib/minizip/zlibvc.def
create mode 100644 zlib-1.1.4/contrib/minizip/zlibvc.dsp
create mode 100644 zlib-1.1.4/contrib/minizip/zlibvc.dsw
create mode 100644 zlib-1.1.4/contrib/untgz/Makefile
create mode 100644 zlib-1.1.4/contrib/untgz/makefile.w32
create mode 100644 zlib-1.1.4/contrib/untgz/untgz.c
create mode 100644 zlib-1.1.4/contrib/visual-basic.txt
create mode 100644 zlib-1.1.4/crc32.c
create mode 100644 zlib-1.1.4/deflate.c
create mode 100644 zlib-1.1.4/deflate.h
create mode 100644 zlib-1.1.4/descrip.mms
create mode 100644 zlib-1.1.4/example.c
create mode 100644 zlib-1.1.4/gzio.c
create mode 100644 zlib-1.1.4/infblock.c
create mode 100644 zlib-1.1.4/infblock.h
create mode 100644 zlib-1.1.4/infcodes.c
create mode 100644 zlib-1.1.4/infcodes.h
create mode 100644 zlib-1.1.4/inffast.c
create mode 100644 zlib-1.1.4/inffast.h
create mode 100644 zlib-1.1.4/inffixed.h
create mode 100644 zlib-1.1.4/inflate.c
create mode 100644 zlib-1.1.4/inftrees.c
create mode 100644 zlib-1.1.4/inftrees.h
create mode 100644 zlib-1.1.4/infutil.c
create mode 100644 zlib-1.1.4/infutil.h
create mode 100644 zlib-1.1.4/maketree.c
create mode 100644 zlib-1.1.4/minigzip.c
create mode 100644 zlib-1.1.4/msdos/Makefile.b32
create mode 100644 zlib-1.1.4/msdos/Makefile.bor
create mode 100644 zlib-1.1.4/msdos/Makefile.dj2
create mode 100644 zlib-1.1.4/msdos/Makefile.emx
create mode 100644 zlib-1.1.4/msdos/Makefile.msc
create mode 100644 zlib-1.1.4/msdos/Makefile.tc
create mode 100644 zlib-1.1.4/msdos/Makefile.w32
create mode 100644 zlib-1.1.4/msdos/Makefile.wat
create mode 100644 zlib-1.1.4/msdos/zlib.def
create mode 100644 zlib-1.1.4/msdos/zlib.rc
create mode 100644 zlib-1.1.4/nt/Makefile.emx
create mode 100644 zlib-1.1.4/nt/Makefile.gcc
create mode 100644 zlib-1.1.4/nt/Makefile.nt
create mode 100644 zlib-1.1.4/nt/zlib.dnt
create mode 100644 zlib-1.1.4/os2/Makefile.os2
create mode 100644 zlib-1.1.4/os2/zlib.def
create mode 100644 zlib-1.1.4/trees.c
create mode 100644 zlib-1.1.4/trees.h
create mode 100644 zlib-1.1.4/uncompr.c
create mode 100644 zlib-1.1.4/zconf.h
create mode 100644 zlib-1.1.4/zlib.3
create mode 100644 zlib-1.1.4/zlib.h
create mode 100644 zlib-1.1.4/zlib.html
create mode 100644 zlib-1.1.4/zutil.c
create mode 100644 zlib-1.1.4/zutil.h
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..887be61
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,142 @@
+2009-11-13 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.9.3.
+
+2008-09-17 Joel Sherrill
+
+ * examples/avl/Makefile, examples/ncurses/Makefile,
+ examples/readline/Makefile, ncurses-5.3/misc/run_tic.sh: Rename
+ STACK_CHECKER_ON to more appropriate CONFIGURE_STACK_CHECKER_ENABLED.
+
+2007-08-07 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.7.99.2.
+
+2007-08-07 Joel Sherrill
+
+ * bit: NFS Client is now merged into main RTEMS source tree.
+ * rtemsNfs/ChangeLog, rtemsNfs/LICENSE, rtemsNfs/Makefile,
+ rtemsNfs/README, rtemsNfs/rfc1094.txt,
+ rtemsNfs/rtems-filesystem-patch, rtemsNfs/proto/Makefile,
+ rtemsNfs/proto/mount_prot.h, rtemsNfs/proto/mount_prot.x,
+ rtemsNfs/proto/mount_prot_xdr.c, rtemsNfs/proto/nfs_prot.h,
+ rtemsNfs/proto/nfs_prot.x, rtemsNfs/proto/nfs_prot_xdr.c,
+ rtemsNfs/src/Makefile, rtemsNfs/src/cexphelp.c,
+ rtemsNfs/src/dirutils.c, rtemsNfs/src/librtemsNfs.h,
+ rtemsNfs/src/nfs.c, rtemsNfs/src/nfs.modini.c, rtemsNfs/src/rpcio.c,
+ rtemsNfs/src/rpcio.h, rtemsNfs/src/rpcio.modini.c,
+ rtemsNfs/src/sock_mbuf.c, rtemsNfs/src/xdr_mbuf.c: Removed.
+
+2007-03-13 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.7.99.1.
+
+2007-03-13 Joel Sherrill
+
+ * bit: Add clean and fix Id.
+
+2007-02-20 Joel Sherrill
+
+ * readline-4.3/support/config.sub: Add bfin.
+
+2007-02-20 Joel Sherrill
+
+ * ncurses-5.3/config.sub: Add bfin.
+
+2006-04-19 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.6.99.3.
+
+2005-09-02 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.6.99.2.
+
+2005-09-02 Joel Sherrill
+
+ * bit, ncurses-5.3/misc/run_tic.sh: Added rtemsNfs 1.2
+ * rtemsNfs/ChangeLog, rtemsNfs/LICENSE, rtemsNfs/Makefile,
+ rtemsNfs/README, rtemsNfs/rtems-filesystem-patch,
+ rtemsNfs/proto/Makefile, rtemsNfs/proto/mount_prot.h,
+ rtemsNfs/proto/mount_prot.x, rtemsNfs/proto/mount_prot_xdr.c,
+ rtemsNfs/proto/nfs_prot.h, rtemsNfs/proto/nfs_prot.x,
+ rtemsNfs/proto/nfs_prot_xdr.c, rtemsNfs/src/Makefile,
+ rtemsNfs/src/cexphelp.c, rtemsNfs/src/dirutils.c,
+ rtemsNfs/src/librtemsNfs.h, rtemsNfs/src/nfs.c,
+ rtemsNfs/src/nfs.modini.c, rtemsNfs/src/rpcio.c,
+ rtemsNfs/src/rpcio.h, rtemsNfs/src/rpcio.modini.c,
+ rtemsNfs/src/sock_mbuf.c, rtemsNfs/src/xdr_mbuf.c: New files.
+ * rtemsNfs-1.1/ChangeLog, rtemsNfs-1.1/LICENSE, rtemsNfs-1.1/Makefile,
+ rtemsNfs-1.1/README, rtemsNfs-1.1/rtems-filesystem-patch,
+ rtemsNfs-1.1/proto/Makefile, rtemsNfs-1.1/proto/mount_prot.x,
+ rtemsNfs-1.1/proto/nfs_prot.x, rtemsNfs-1.1/src/Makefile,
+ rtemsNfs-1.1/src/cexphelp.c, rtemsNfs-1.1/src/dirutils.c,
+ rtemsNfs-1.1/src/librtemsNfs.h, rtemsNfs-1.1/src/nfs.c,
+ rtemsNfs-1.1/src/nfs.modini.c, rtemsNfs-1.1/src/rpcio.c,
+ rtemsNfs-1.1/src/rpcio.h, rtemsNfs-1.1/src/rpcio.modini.c,
+ rtemsNfs-1.1/src/sock_mbuf.c, rtemsNfs-1.1/src/xdr_mbuf.c: Removed.
+
+2004-10-18 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-4.6.2.
+
+2004-10-18 Joel Sherrill
+
+ * aclocal/version.m4: Updated to rtems-addon-packages-4.6.2.
+
+2003-01-28 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-20030128.
+
+2003-01-28 Joel Sherrill
+
+ * aclocal/version.m4: Updated to rtems-addon-packages-20030128.
+
+2003-01-20 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-20030120.
+
+2003-01-20 Joel Sherrill
+
+ * aclocal/version.m4: Updated to rtems-addon-packages-20030120.
+
+2002-12-19 Eric Norum
+
+ * ncurses-5.3 bit: Update ncurses add-on package.
+
+2002-11-28 Eric Norum
+
+ * RTEMS_Makefiles/Makefile.bfd: New file
+
+2002-11-21 Eric Norum
+
+ * bit, bit_bfd: Add support for additional add-ons (libtecla, BFD)
+
+2002-11-19 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-20021119.
+
+2002-11-19 Joel Sherrill
+
+ * aclocal/version.m4: Updated to rtems-addon-packages-20021119.
+
+2002-11-08 Eric Norum
+
+ * RTEMS_Makefiles/Makefile.libtecla, bit, libtecla-1.4.1/:
+ Add TECLA command-line editing library.
+
+2002-09-12 Eric Norum
+
+ * RTEMS_Makefiles/Makefile.ncurses: Added ansi terminal type.
+
+2002-07-30 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-20020730a.
+
+2002-07-30 Joel Sherrill
+
+ * VERSION: Updated to rtems-addon-packages-20020730.
+
+2002-07-30 Joel Sherrill
+
+ * ChangeLog, VERSION, SUPPORT: New files.
+
diff --git a/README b/README
new file mode 100644
index 0000000..504f048
--- /dev/null
+++ b/README
@@ -0,0 +1,24 @@
+Assorted add-on packages for RTEMS.
+
+The bit script builds and installs all the packages.
+
+To build a package:
+ cd <>
+ make -f ../RTEMS_Makefiles/Makefile.<>
+
+Notes
+=====
+1) You must build and install the host version of infocmp before trying to
+build ncurses.
+2) You must build and install ncurses before trying to build readline.
+3) To add ncurses support for other terminals, change the declaration
+ of TERMINALS.
+
+Cautions
+========
+The readline and ncurses `configure' scripts check for the presence of
+select(). Because the RTEMS dummy.rel file does not include network
+configuration information the scripts decide that select() does not
+exist. This is correct since although RTEMS does have a select() call
+it is not supported on tty devices. The fact that one shortcoming is
+covering up another is not really satisfactory, though.
diff --git a/RTEMS_Makefiles/Makefile.avl b/RTEMS_Makefiles/Makefile.avl
new file mode 100644
index 0000000..b801392
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.avl
@@ -0,0 +1,12 @@
+#
+# Configure/build/install the AVL library
+#
+include ../RTEMS_Makefiles/Makefile.common
+
+all:
+ ./configure \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include
+ make
+ make install
diff --git a/RTEMS_Makefiles/Makefile.bfd b/RTEMS_Makefiles/Makefile.bfd
new file mode 100644
index 0000000..b6b9586
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.bfd
@@ -0,0 +1,14 @@
+#
+# Configure/build/install the libtecla library
+#
+include ../RTEMS_Makefiles/Makefile.common
+
+all:
+ $(BINUTILS_SRC_DIR)/bfd/configure \
+ --host=$(RTEMS_CPU)-rtems \
+ --disable-nls \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include
+ make
+ make install
diff --git a/RTEMS_Makefiles/Makefile.common b/RTEMS_Makefiles/Makefile.common
new file mode 100644
index 0000000..7e0ddbe
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.common
@@ -0,0 +1,23 @@
+###########################################################
+# Meta-Makefile for compiling packages to work with RTEMS #
+###########################################################
+
+#
+# Pick up RTEMS configuration
+#
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+CC += $(CPU_CFLAGS)
+
+#
+# For some reason RTEMS Makefiles don't export this
+#
+export RANLIB
+
+.PHONY: all
+
+#
+# Include site-specific options
+#
+include ../RTEMS_Makefiles/Makefile.site
diff --git a/RTEMS_Makefiles/Makefile.libtecla b/RTEMS_Makefiles/Makefile.libtecla
new file mode 100644
index 0000000..2405adb
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.libtecla
@@ -0,0 +1,15 @@
+#
+# Configure/build/install the libtecla library
+#
+include ../RTEMS_Makefiles/Makefile.common
+
+all:
+ ./configure \
+ --host=$(RTEMS_CPU)-rtems \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include
+ make
+ make reentrant
+ make install
+ make distclean
diff --git a/RTEMS_Makefiles/Makefile.ncurses b/RTEMS_Makefiles/Makefile.ncurses
new file mode 100644
index 0000000..3df6d38
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.ncurses
@@ -0,0 +1,28 @@
+#
+# Declare supported terminal types.
+# This value can be augmented/overridden by the site-configuration file
+#
+TERMINALS=xterm,vt100,linux,ansi
+
+include ../RTEMS_Makefiles/Makefile.common
+
+#
+# The following will work only if you have the latest ncurses version
+# of infocmp installed before trying to build for an RTEMS target.
+# The cf_cv_type_of_bool hack works around a bug when configuring
+# for a cross-target.
+#
+all:
+ cf_cv_type_of_bool=char CXX="$(CC)" TERM=xterm ./configure \
+ --host=$(RTEMS_CPU)-rtems \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include \
+ --without-ada \
+ --without-progs \
+ --without-cxx-binding \
+ --disable-sigwinch \
+ --disable-database \
+ --with-fallbacks="$(TERMINALS)"
+ make "TERM=xterm" "HOSTCC=gcc" "HOSTCCFLAGS=-I. -I../include" HOSTLDFLAGS=""
+ make install
diff --git a/RTEMS_Makefiles/Makefile.ncurses-5.3 b/RTEMS_Makefiles/Makefile.ncurses-5.3
new file mode 100644
index 0000000..24c5428
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.ncurses-5.3
@@ -0,0 +1,30 @@
+#
+# Declare supported terminal types.
+# This value can be augmented/overridden by the site-configuration file
+#
+TERMINALS=xterm,vt100,linux,ansi
+
+include ../RTEMS_Makefiles/Makefile.common
+
+#
+# The following will work only if you have the latest ncurses version
+# of infocmp installed before trying to build for an RTEMS target.
+# The cf_cv_type_of_bool hack works around a bug when configuring
+# for a cross-target.
+ #cf_cv_type_of_bool=char CXX="$(CC)" ./configure \
+#
+all:
+ CXX="$(CC)" TERM=xterm ./configure \
+ --host=$(RTEMS_CPU)-rtems \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include \
+ --without-ada \
+ --without-progs \
+ --without-cxx-binding \
+ --with-bool="unsigned char" \
+ --disable-sigwinch \
+ --disable-database \
+ --with-fallbacks="$(TERMINALS)"
+ make "TERM=xterm" "HOSTCC=gcc" "HOSTCCFLAGS=-I. -I../include" HOSTLDFLAGS=""
+ make install
diff --git a/RTEMS_Makefiles/Makefile.readline-4.3 b/RTEMS_Makefiles/Makefile.readline-4.3
new file mode 100644
index 0000000..36644d2
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.readline-4.3
@@ -0,0 +1,18 @@
+include ../RTEMS_Makefiles/Makefile.common
+
+#
+# Running make distclean cleans up documentation files that require
+# special tools to regenerate. Work around this problem by just
+# copying the documentation files from another directory.
+#
+all:
+ bash_cv_have_mbstate_t=yes ./configure \
+ --host=$(RTEMS_CPU)-rtems \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include \
+ --disable-shared
+ cp ../readline-doc-4.3/doc/????* doc
+ make
+ cd doc ; make
+ make install
diff --git a/RTEMS_Makefiles/Makefile.site b/RTEMS_Makefiles/Makefile.site
new file mode 100644
index 0000000..2c9f3a4
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.site
@@ -0,0 +1,3 @@
+#
+# Site-specific options/configuration goes here
+#
diff --git a/RTEMS_Makefiles/Makefile.zlib b/RTEMS_Makefiles/Makefile.zlib
new file mode 100644
index 0000000..a6a54ca
--- /dev/null
+++ b/RTEMS_Makefiles/Makefile.zlib
@@ -0,0 +1,13 @@
+#
+# Configure/build/install the AVL library
+#
+include ../RTEMS_Makefiles/Makefile.common
+
+AR = $(AR_FOR_TARGET) cr
+all:
+ ./configure \
+ --prefix=$(exec_prefix) \
+ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \
+ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include
+ make
+ make install
diff --git a/SUPPORT b/SUPPORT
new file mode 100644
index 0000000..083c1cb
--- /dev/null
+++ b/SUPPORT
@@ -0,0 +1,22 @@
+#
+# $Id$
+#
+
+On-Line Applications Research Corporation (OAR) offers support,
+customization, and training for RTEMS. Custom RTEMS development services
+includes porting RTEMS to new processors and the development of custom board
+support packages and device drivers. In addition, OAR is available
+to assist in the development of your real-time embedded application.
+
+For more information, email Mark Johannes at mark@OARcorp.com
+or contact OAR at:
+
+On-Line Applications Research Corporation
+4910-L Corporate Drive
+Huntsville AL 35805
+Voice: (205) 722-9985
+Fax: (205 722-0985
+
+RTEMS maintenance and development is funded solely by RTEMS users.
+The future of RTEMS depends on its user base.
+
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..3c4c716
--- /dev/null
+++ b/VERSION
@@ -0,0 +1,7 @@
+#
+# This file is automatically generated -- DO NOT EDIT!!!
+#
+# $Id$
+#
+
+Version 4.9.3
diff --git a/avl-1.4.0/AUTHORS b/avl-1.4.0/AUTHORS
new file mode 100644
index 0000000..bcd66cd
--- /dev/null
+++ b/avl-1.4.0/AUTHORS
@@ -0,0 +1 @@
+Ben Pfaff
diff --git a/avl-1.4.0/COPYING b/avl-1.4.0/COPYING
new file mode 100644
index 0000000..60549be
--- /dev/null
+++ b/avl-1.4.0/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C) 19yy
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/avl-1.4.0/ChangeLog b/avl-1.4.0/ChangeLog
new file mode 100644
index 0000000..e31a7c2
--- /dev/null
+++ b/avl-1.4.0/ChangeLog
@@ -0,0 +1,181 @@
+Sat Aug 7 18:32:43 1999 Ben Pfaff
+
+ Implemented red-black tree library.
+ * Makefile.am: Add rb.c, rb.h in appropriate places.
+ * README: Update.
+ * rb.c: New file.
+ * rb.h: Ditto.
+ * avl.texinfo: Revised.
+
+ * THANKS: Update.
+ * TODO: Update.
+
+ * avl.c: In several places, replaced usage of comma operator with
+ a proper statement block.
+ * avlt.c: Ditto.
+ * avltr.c: Ditto.
+
+ * avl.h: (AVL_TRAVERSER_INIT) New macro.
+ (avl_init_traverser) New function-like macro.
+ * avlt.h: (AVLT_TRAVERSER_INIT) New macro.
+ (avlt_init_traverser) New function-like macro.
+ * avltr.h: (AVLTR_TRAVERSER_INIT) New macro.
+ (avltr_init_traverser) New function-like macro.
+ * thread-test.c: (main) Use AVL_TRAVERSER_INIT.
+
+ * Made version 1.4.0.
+
+Sat Jul 31 12:39:54 1999 Ben Pfaff
+
+ * avl.texinfo: Update suggested by Jonathan Roy .
+
+Tue May 25 12:20:43 1999 Ben Pfaff
+
+ * avl.c: (avl_delete) Make work properly for empty tree. Furrfu!
+ I should have noticed this before.
+
+Mon May 17 11:32:56 1999 Ben Pfaff
+
+ * Makefile.am: Don't require texi2html. Use $(MAKEINFO)
+ variable. Thanks to Alexandre Oliva .
+
+Sat May 15 23:47:14 1999 Ben Pfaff
+
+ * Updated copyright dates in several files.
+
+ * Made version 1.3.0.
+
+Sat May 15 21:44:54 1999 Ben Pfaff
+
+ * avl.c, avlt.c, avltr.c: In many places replaced assert (p) by
+ assert (p != NULL). Believe it or not, the former is not valid
+ ANSI C.
+
+ Thanks to "Ficarra, David W, NNAD" for pointing
+ out the following two sets of bugs.
+ * avl.c: (avl_probe) Fix order of assignment and assertion.
+ * avlt.c: (avlt_walk, avlt_probe, avlt_find) Ditto.
+ * avltr.c: (avltr_probe, avltr_find) Ditto.
+
+ * avlt.c: (avlt_find, avlt_delete) Check for empty tree.
+ * avltr.c: (avltr_probe) Ditto.
+
+ * avl.c, avlt.c, avltr.c, thread-test.c: Change test code to only
+ perform a limited number of iterations to facilitate automated
+ testing.
+
+ * avl.c: (avl_find_close) New function contributed by Thomas
+ Binder .
+ * avlt.c: (avlt_find_close) Ditto.
+ * avltr.c: (avltr_find_close) Ditto.
+
+ * avl.texinfo: Update.
+
+ libavl is now automake/autoconfiscated. Contributed by Alexandre
+ Oliva .
+ * AUTHORS: New file.
+ * Makefile: Now automake-generated.
+ * INSTALL: New file.
+ * Makefile.am: New file.
+ * Makefile.in: New file.
+ * THANKS: New file.
+ * config.h.in: New file.
+ * configure.in: New file.
+ * configure: New file.
+ * install-sh: New file.
+ * missing: New file.
+ * mkinstalldirs: New file.
+ * texinfo.tex: New file.
+
+Tue May 11 13:33:20 1999 Ben Pfaff
+
+ * avl.texinfo: Fix typos. Thanks to onTy Toom
+ for pointing these out.
+
+ * Made version 1.2.9.
+
+Sun Mar 14 13:39:16 1999 Ben Pfaff
+
+ * avl.c: Fixed two occurrences of = that should have been == in
+ assertions. Thanks to Girish Zambre for
+ pointing out this problem.
+
+ * avl.c, avlt.c, avltr.c: __attribute__ must follow declarations
+ for gcc 2.7.x.
+
+ * Made version 1.2.8.
+
+Sun Mar 14 13:38:29 1999 Ben Pfaff
+
+ * TODO: Add some comments from David Kastrup
+ .
+
+ * Made version 1.2.7.
+
+Tue Jan 12 10:16:05 1999 Ben Pfaff
+
+ * avl.texinfo: Add skip lists as alternative to AVL trees. Thanks
+ to Ron Pfeifle .
+
+ * Made version 1.2.6.
+
+Sun Jan 10 15:37:57 1999 Ben Pfaff
+
+ * avl.texinfo: Elaborated description of distinction between
+ threaded and unthreaded trees at request of several.
+
+ * Made version 1.2.5.
+
+Sun Nov 22 13:36:58 1998 Ben Pfaff
+
+ * avl.texinfo: Updates suggested by Jason Eisner
+ .
+
+ * Made version 1.2.4.
+
+Sun Oct 18 10:26:08 1998 Ben Pfaff
+
+ * TODO: New file.
+
+ * avl.c: (xmalloc) Don't declare xmalloc if HAVE_XMALLOC is
+ defined. By default on error, print a message to stderr and exit,
+ rather than calling abort() as before.
+ * avlt.c: (xmalloc) Same.
+ * avltr.c: (xmalloc) Same.
+
+ * Made version 1.2.3.
+
+Thu Sep 3 13:58:55 1998 Ben Pfaff
+
+ * README: Update.
+
+ * avl.c: (avl_delete) Minor efficiency fixes; removed redundant
+ comparison.
+
+ * avlt.c: (avl_delete) Minor efficiency fix.
+ * avltr.c: (avl_delete) Same change.
+
+ * avl.texi: Update.
+
+ * Made version 1.2.2.
+
+Thu Jun 11 15:13:02 1998 Ben Pfaff
+
+ * avl.c: Don't #define unused when PSPP is defined.
+ (force_avl_delete) Rename avl_force_delete.
+
+ * avlt.c: (force_avlt_delete) Rename avlt_force_delete.
+
+ * avltr.c: (force_avltr_delete) Rename avltr_force_delete.
+
+ * Made version 1.2.1.
+
+Thu Jun 11 14:43:30 1998 Ben Pfaff
+
+ * Version 1.2.0: First GNU release.
+
+----------------------------------------------------------------------
+Local Variables:
+mode: change-log
+version-control: never
+End:
diff --git a/avl-1.4.0/INSTALL b/avl-1.4.0/INSTALL
new file mode 100644
index 0000000..b42a17a
--- /dev/null
+++ b/avl-1.4.0/INSTALL
@@ -0,0 +1,182 @@
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+ The file `configure.in' is used to create `configure' by a program
+called `autoconf'. You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. You can give `configure'
+initial values for variables by setting them in the environment. Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+ CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+ env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+ CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+ Use and save the results of the tests in FILE instead of
+ `./config.cache'. Set FILE to `/dev/null' to disable caching, for
+ debugging `configure'.
+
+`--help'
+ Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--version'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
diff --git a/avl-1.4.0/Makefile.am b/avl-1.4.0/Makefile.am
new file mode 100644
index 0000000..aa4754d
--- /dev/null
+++ b/avl-1.4.0/Makefile.am
@@ -0,0 +1,28 @@
+AUTOMAKE_OPTIONS = gnits
+
+include_HEADERS = avl.h avlt.h avltr.h rb.h
+
+lib_LIBRARIES = libavl.a
+libavl_a_SOURCES = avl.c avlt.c avltr.c rb.c
+
+info_TEXINFOS = avl.texinfo
+noinst_DATA = avl.html avl.text
+
+avl.text : avl.texinfo
+ $(MAKEINFO) $(srcdir)/avl.texinfo -o avl.text --no-headers
+
+avl.html: avl.texinfo
+ -texi2html -monolithic $(srcdir)/avl.texinfo
+
+EXTRA_PROGRAMS = avl-test avlt-test avltr-test thread-test rb-test
+DISTCLEANFILES = $(EXTRA_PROGRAMS) $(BUILT_SOURCES)
+
+BUILT_SOURCES = avl-test.c avlt-test.c avltr-test.c rb-test.c
+
+TESTS = avl-test avlt-test avltr-test thread-test rb-test
+avl-test.c avlt-test.c avltr-test.c rb-test.c:
+ rm -f $@
+ echo '#define SELF_TEST 1' > $@
+ echo '#include "'`echo $@ | sed s/-test//`'"' >> $@
+
+thread_test_LDADD = libavl.a
diff --git a/avl-1.4.0/Makefile.in b/avl-1.4.0/Makefile.in
new file mode 100644
index 0000000..2d041aa
--- /dev/null
+++ b/avl-1.4.0/Makefile.in
@@ -0,0 +1,572 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+
+AUTOMAKE_OPTIONS = gnits
+
+include_HEADERS = avl.h avlt.h avltr.h rb.h
+
+lib_LIBRARIES = libavl.a
+libavl_a_SOURCES = avl.c avlt.c avltr.c rb.c
+
+info_TEXINFOS = avl.texinfo
+noinst_DATA = avl.html avl.text
+
+EXTRA_PROGRAMS = avl-test avlt-test avltr-test thread-test rb-test
+DISTCLEANFILES = $(EXTRA_PROGRAMS) $(BUILT_SOURCES)
+
+BUILT_SOURCES = avl-test.c avlt-test.c avltr-test.c rb-test.c
+
+TESTS = avl-test avlt-test avltr-test thread-test rb-test
+
+thread_test_LDADD = libavl.a
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(lib_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libavl_a_LIBADD =
+libavl_a_OBJECTS = avl.o avlt.o avltr.o rb.o
+AR = ar
+avl_test_SOURCES = avl-test.c
+avl_test_OBJECTS = avl-test.o
+avl_test_LDADD = $(LDADD)
+avl_test_DEPENDENCIES =
+avl_test_LDFLAGS =
+avlt_test_SOURCES = avlt-test.c
+avlt_test_OBJECTS = avlt-test.o
+avlt_test_LDADD = $(LDADD)
+avlt_test_DEPENDENCIES =
+avlt_test_LDFLAGS =
+avltr_test_SOURCES = avltr-test.c
+avltr_test_OBJECTS = avltr-test.o
+avltr_test_LDADD = $(LDADD)
+avltr_test_DEPENDENCIES =
+avltr_test_LDFLAGS =
+thread_test_SOURCES = thread-test.c
+thread_test_OBJECTS = thread-test.o
+thread_test_DEPENDENCIES = libavl.a
+thread_test_LDFLAGS =
+rb_test_SOURCES = rb-test.c
+rb_test_OBJECTS = rb-test.o
+rb_test_LDADD = $(LDADD)
+rb_test_DEPENDENCIES =
+rb_test_LDFLAGS =
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+TEXI2DVI = texi2dvi
+INFO_DEPS = avl.info
+DVIS = avl.dvi
+TEXINFOS = avl.texinfo
+DATA = $(noinst_DATA)
+
+HEADERS = $(include_HEADERS)
+
+DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
+Makefile.in NEWS THANKS TODO aclocal.m4 configure configure.in \
+install-sh missing mkinstalldirs texinfo.tex
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+SOURCES = $(libavl_a_SOURCES) avl-test.c avlt-test.c avltr-test.c thread-test.c rb-test.c
+OBJECTS = $(libavl_a_OBJECTS) avl-test.o avlt-test.o avltr-test.o thread-test.o rb-test.o
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .dvi .info .o .ps .s .texi .texinfo .txi
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnits --include-deps Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4): configure.in
+ cd $(srcdir) && $(ACLOCAL)
+
+config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+ cd $(srcdir) && $(AUTOCONF)
+
+mostlyclean-libLIBRARIES:
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+
+distclean-libLIBRARIES:
+
+maintainer-clean-libLIBRARIES:
+
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
+ $(RANLIB) $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LIBRARIES)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+libavl.a: $(libavl_a_OBJECTS) $(libavl_a_DEPENDENCIES)
+ -rm -f libavl.a
+ $(AR) cru libavl.a $(libavl_a_OBJECTS) $(libavl_a_LIBADD)
+ $(RANLIB) libavl.a
+
+avl-test: $(avl_test_OBJECTS) $(avl_test_DEPENDENCIES)
+ @rm -f avl-test
+ $(LINK) $(avl_test_LDFLAGS) $(avl_test_OBJECTS) $(avl_test_LDADD) $(LIBS)
+
+avlt-test: $(avlt_test_OBJECTS) $(avlt_test_DEPENDENCIES)
+ @rm -f avlt-test
+ $(LINK) $(avlt_test_LDFLAGS) $(avlt_test_OBJECTS) $(avlt_test_LDADD) $(LIBS)
+
+avltr-test: $(avltr_test_OBJECTS) $(avltr_test_DEPENDENCIES)
+ @rm -f avltr-test
+ $(LINK) $(avltr_test_LDFLAGS) $(avltr_test_OBJECTS) $(avltr_test_LDADD) $(LIBS)
+
+thread-test: $(thread_test_OBJECTS) $(thread_test_DEPENDENCIES)
+ @rm -f thread-test
+ $(LINK) $(thread_test_LDFLAGS) $(thread_test_OBJECTS) $(thread_test_LDADD) $(LIBS)
+
+rb-test: $(rb_test_OBJECTS) $(rb_test_DEPENDENCIES)
+ @rm -f rb-test
+ $(LINK) $(rb_test_LDFLAGS) $(rb_test_OBJECTS) $(rb_test_LDADD) $(LIBS)
+
+avl.info: avl.texinfo
+avl.dvi: avl.texinfo
+
+
+DVIPS = dvips
+
+.texi.info:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+
+.texi.dvi:
+ TEXINPUTS=.:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.texi:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+
+.texinfo.info:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+
+.texinfo:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+
+.texinfo.dvi:
+ TEXINPUTS=.:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.txi.info:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+
+.txi.dvi:
+ TEXINPUTS=.:$$TEXINPUTS \
+ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+
+.txi:
+ @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
+ cd $(srcdir) \
+ && $(MAKEINFO) `echo $< | sed 's,.*/,,'`
+.dvi.ps:
+ $(DVIPS) $< -o $@
+
+install-info-am: $(INFO_DEPS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(infodir)
+ @list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ d=$(srcdir); \
+ for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
+ if test -f $$d/$$ifile; then \
+ echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
+ $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
+ else : ; fi; \
+ done; \
+ done
+ @$(POST_INSTALL)
+ @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
+ install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
+ done; \
+ else : ; fi
+
+uninstall-info:
+ $(PRE_UNINSTALL)
+ @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+ ii=yes; \
+ else ii=; fi; \
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ test -z "$ii" \
+ || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
+ done
+ @$(NORMAL_UNINSTALL)
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ (cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
+ done
+
+dist-info: $(INFO_DEPS)
+ list='$(INFO_DEPS)'; \
+ for base in $$list; do \
+ d=$(srcdir); \
+ for file in `cd $$d && eval echo $$base*`; do \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file; \
+ done; \
+ done
+
+mostlyclean-aminfo:
+ -rm -f avl.aux avl.cp avl.cps avl.dvi avl.fn avl.fns avl.ky avl.kys \
+ avl.ps avl.log avl.pg avl.toc avl.tp avl.tps avl.vr avl.vrs \
+ avl.op avl.tr avl.cv avl.cn
+
+clean-aminfo:
+
+distclean-aminfo:
+
+maintainer-clean-aminfo:
+ cd $(srcdir) && for i in $(INFO_DEPS); do \
+ rm -f $$i; \
+ if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
+ rm -f $$i-[0-9]*; \
+ fi; \
+ done
+
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(includedir)
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ list='$(include_HEADERS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(includedir)/$$p; \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ -rm -rf $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+ mkdir $(distdir)/=build
+ mkdir $(distdir)/=inst
+ dc_install_base=`cd $(distdir)/=inst && pwd`; \
+ cd $(distdir)/=build \
+ && ../configure --srcdir=.. --prefix=$$dc_install_base \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) dist
+ -rm -rf $(distdir)
+ @banner="$(distdir).tar.gz is ready for distribution"; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"
+dist: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+dist-all: distdir
+ -chmod -R a+r $(distdir)
+ GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+ -rm -rf $(distdir)
+distdir: $(DISTFILES)
+ @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \
+ echo "NEWS not updated; not releasing" 1>&2; \
+ exit 1; \
+ fi
+ -rm -rf $(distdir)
+ mkdir $(distdir)
+ -chmod 777 $(distdir)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+ $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; \
+ srcdir=$(srcdir); export srcdir; \
+ for tst in $(TESTS); do \
+ if test -f $$tst; then dir=.; \
+ else dir="$(srcdir)"; fi; \
+ if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
+ all=`expr $$all + 1`; \
+ echo "PASS: $$tst"; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ banner="$$failed of $$all tests failed"; \
+ fi; \
+ dashes=`echo "$$banner" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0
+info-am: $(INFO_DEPS)
+info: info-am
+dvi-am: $(DVIS)
+dvi: dvi-am
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-libLIBRARIES
+install-exec: install-exec-am
+
+install-data-am: install-info-am install-includeHEADERS
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-libLIBRARIES uninstall-info \
+ uninstall-includeHEADERS
+uninstall: uninstall-am
+all-am: Makefile $(INFO_DEPS) $(LIBRARIES) $(DATA) $(HEADERS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \
+ $(DESTDIR)$(includedir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \
+ mostlyclean-aminfo mostlyclean-tags mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-libLIBRARIES clean-compile clean-aminfo clean-tags \
+ clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-libLIBRARIES distclean-compile distclean-aminfo \
+ distclean-tags distclean-generic clean-am
+
+distclean: distclean-am
+ -rm -f config.status
+
+maintainer-clean-am: maintainer-clean-libLIBRARIES \
+ maintainer-clean-compile maintainer-clean-aminfo \
+ maintainer-clean-tags maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+ -rm -f config.status
+
+.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \
+clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
+install-libLIBRARIES mostlyclean-compile distclean-compile \
+clean-compile maintainer-clean-compile install-info-am uninstall-info \
+mostlyclean-aminfo distclean-aminfo clean-aminfo \
+maintainer-clean-aminfo uninstall-includeHEADERS install-includeHEADERS \
+tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
+distdir check-TESTS info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+avl.text : avl.texinfo
+ $(MAKEINFO) $(srcdir)/avl.texinfo -o avl.text --no-headers
+
+avl.html: avl.texinfo
+ -texi2html -monolithic $(srcdir)/avl.texinfo
+avl-test.c avlt-test.c avltr-test.c rb-test.c:
+ rm -f $@
+ echo '#define SELF_TEST 1' > $@
+ echo '#include "'`echo $@ | sed s/-test//`'"' >> $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/avl-1.4.0/NEWS b/avl-1.4.0/NEWS
new file mode 100644
index 0000000..ecdc25d
--- /dev/null
+++ b/avl-1.4.0/NEWS
@@ -0,0 +1,98 @@
+libavl NEWS -- history of user-visible changes.
+Time-stamp: <1999-08-15 21:52:15 blp>
+Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+See the end for copying conditions.
+
+Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
+
+Changes for version 1.4.0:
+
+ Implemented red-black trees.
+
+ New functions, *_init_traverser(), to initialize a *_traverser
+ structure. New macros *_TRAVERSER_INIT for same purpose.
+
+Changes for version 1.3.0:
+
+ Now uses Autoconf and Automake to configure. Thanks to Alexandre
+ Oliva .
+
+ New: automated testing with `make check'.
+
+ Fixes for strict ANSI C compliance.
+
+ Fixed useless assertions. Fixed bug regarding empty trees for some
+ operations with threaded and right-threaded trees. Thanks to
+ "Ficarra, David W, NNAD" .
+
+ New functions, avl*_find_close(), for finding a node in the tree
+ with a value close to a specified value. See documentation and
+ source code for more details. Thanks to Thomas Binder
+ .
+
+Changes for version 1.2.9:
+
+ Fix typos in documentation. Thanks to onTy Toom .
+
+Changes for version 1.2.8:
+
+ Fixed typos in assertions. Thanks to Girish Zambre
+ .
+
+ Better support for gcc 2.7.x.
+
+Changes for versions 1.2.4, 1.2.5, 1.2.6, 1.2.7:
+
+ Documentation updates. Thanks to Ron Pfeifle ,
+ Jason Eisner , and others.
+
+Changes for version 1.2.3:
+
+ The library's allocation function xmalloc() can easily be overridden
+ by the library's user. Thanks to Clayton Weaver
+ for the idea.
+
+Changes for version 1.2.2:
+
+ Documentation fixes. Thanks to Akim Demaille
+ for pointing these out.
+
+Changes for version 1.2.1:
+
+ Bug fixes.
+
+Changes for version 1.2.0:
+
+ Implemented right-threaded trees.
+
+ Added functions to convert among AVL tree types.
+
+ First GNU release.
+
+Changes for version 1.1.0:
+
+ Implemented threaded trees.
+
+Changes for version 1.0:
+
+ First public release.
+
+----------------------------------------------------------------------
+Copyright information:
+
+Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ Permission is granted to anyone to make or distribute verbatim
+ copies of this document as received, in any medium, provided that
+ the copyright notice and this permission notice are preserved, thus
+ giving the recipient permission to redistribute in turn.
+
+ Permission is granted to distribute modified versions of this
+ document, or of portions of it, under the above conditions,
+ provided also that they carry prominent notices stating who last
+ changed them.
+
+Local variables:
+version-control: never
+mode: indented-text
+end:
diff --git a/avl-1.4.0/README b/avl-1.4.0/README
new file mode 100644
index 0000000..46ed6e4
--- /dev/null
+++ b/avl-1.4.0/README
@@ -0,0 +1,37 @@
+This is version 1.4 of libavl, a library in ANSI C for manipulation of
+balanced binary trees. Functions for use with three varieties of AVL
+tree and one type of red-black tree are included. There is full
+documentation, including an explanation of what AVL and red-black
+trees are and why you'd use them, in Texinfo, Info, HTML, and plain
+text formats.
+
+The library is divided into three parts, described in more detail
+below. You need only include the files for the types of trees that
+you are using.
+
+ - avl.h, avl.c: Unthreaded AVL tree library.
+ - avlt.h, avlt.c: Threaded AVL tree library.
+ - avltr.h, avltr.c: Right-threaded AVL tree library.
+ - rb.h, rb.c: Unthreaded red-black tree library.
+
+Each .c file in the library has a self-test routine built in, which
+can be invoked by compiling it with SELF_TEST set to 1. In addition,
+there is a separate program thread-test.c that tests the functions
+that convert among types of AVL trees. To automatically run these
+tests, type `make check' after you have configured the library with
+`configure'. For more information on how to configure and compile
+libavl, see the file INSTALL included in this directory.
+
+libavl is licensed under the GNU General Public License (GPL), which
+should be included in this directory in file COPYING. This is not the
+same as GNU Library General Public License (LGPL). Please read the
+license and become familiar with its terms.
+
+Please send bug reports and enhancement requests for libavl to Ben
+Pfaff .
+
+Share and enjoy!
+
+Local variables:
+mode: text
+End:
diff --git a/avl-1.4.0/THANKS b/avl-1.4.0/THANKS
new file mode 100644
index 0000000..cd9319a
--- /dev/null
+++ b/avl-1.4.0/THANKS
@@ -0,0 +1,15 @@
+Thanks to...
+
+* Donald Knuth for _The Art of Computer Programming_.
+
+* Thomas Cormen, Charles Leiserson, and Ron Rivest for _Introduction
+ to Algorithms_.
+
+* David MacKenzie for writing Autoconf, the automatic configuration
+ tool.
+
+* David MacKenzie and Tom Tromey for writing Automake, the tool for
+ generating `Makefile's.
+
+* All those who have contributed bug reports and enhancements. You
+ can find them listed individually in the NEWS and the ChangeLog.
diff --git a/avl-1.4.0/TODO b/avl-1.4.0/TODO
new file mode 100644
index 0000000..0231395
--- /dev/null
+++ b/avl-1.4.0/TODO
@@ -0,0 +1,92 @@
+TODO
+----
+
+* Write `bare' no-rebalancing version for comparison purposes.
+
+* In avl_delete's D9 it may be faster to move the data instead of
+ moving around all the pointers. Consider the situation carefully.
+
+* avl_traverse_{fwd,rev}; avl_find_traverse
+
+* Generalized testing framework; for instance, could compare with
+ kazlib and avllib implementations.
+
+* Merge algorithm paper into documentation.
+
+----------------------------------------------------------------------
+From: Akim Demaille
+Subject: Re: libavl
+To: pfaffben@pilot.msu.edu
+Date: 25 Sep 1998 16:04:03 +0200
+
+
+Sorry for the delays...
+
+Ben Pfaff writes:
+
+> Akim Demaille writes:
+>
+> And finaly, for the application I want to make of libavl, I have
+> sometimes to merge two avls, say the second into the first, while
+> specifying, when conflict, whether it is always the first or the
+> second that wins.
+>
+> I can easily make this using your api, nevertheless, I wanted to ask
+> you whether you know none brute-force approaches, or even whether
+> this kind of features might appear in the future.
+>
+> Knuth describes an elegant algorithm for merging two avls, but it only
+> works if all the values in one of them is smaller than all the values
+> in the other.
+>
+> If you do think of a clever algorithm for doing this, please let me
+> know and I'll incorporate it into the API.
+
+I know none. but looking on the web, I found one in haskell :)
+I didn't look whether it was smart or not.
+
+http://www.cs.chalmers.se/pub/haskell/library/avl-tree.lgs
+
+There is not much material. I think comp.compiler is a good place to
+ask for an algorithm...
+
+Akim
+----------------------------------------------------------------------
+From: David Kastrup
+Subject: Re: Your AVL tree page
+To: pfaffben@pilot.msu.edu
+Date: Mon, 23 Nov 1998 18:38:55 +0100
+
+ From: Ben Pfaff
+ Date: 23 Nov 1998 12:12:31 -0500
+
+ David Kastrup writes:
+
+ You might want to take a look at the texts at
+ http://www-lsi.upc.es/www/dept/techreps/1998.html
+
+ In particular the paper
+ http://www-lsi.upc.es/dept/techreps/ps/R98-12.ps.gz
+
+ might be interesting, as it gives an AVL-tree mechanism for
+ multi-threaded, distributed access.
+
+ Thanks for the pointers. It seems that connectivity to that machine
+ is really slow from here, at least right now, so I'll try to take a
+ look at them a little later. Currently there is no multithread
+ support in libavl, but it might be nice to add it later.
+
+Well, the reference will probably not be what you think it is. It is
+intended to not properly balance the tree during the access when that
+would mean locking the entire tree. Instead, it does only local
+corrections that eventually probagate to the top. One can also let a
+"garbage collect" thread run that will optimize the data structures
+at idle times, but will let them deteriorate a bit rather than fix
+them up properly under stress. This is, of course, especially
+interesting for internal data structures of an operating system, where
+full balancing at the time of access will slow operations down, but
+there will be idle times when balancing can occur without overhead.
+
+David Kastrup Phone: +49-234-700-5570
+Email: dak@neuroinformatik.ruhr-uni-bochum.de Fax: +49-234-709-4209
+Institut für Neuroinformatik, Universitätsstr. 150, 44780 Bochum, Germany
diff --git a/avl-1.4.0/aclocal.m4 b/avl-1.4.0/aclocal.m4
new file mode 100644
index 0000000..9f8add8
--- /dev/null
+++ b/avl-1.4.0/aclocal.m4
@@ -0,0 +1,104 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+# Do all the work for Automake. This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "[$]*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "[$]*" != "X $srcdir/configure conftestfile" \
+ && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "[$]2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+ $1=$2
+ AC_MSG_RESULT(found)
+else
+ $1="$3/missing $2"
+ AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
diff --git a/avl-1.4.0/avl.c b/avl-1.4.0/avl.c
new file mode 100644
index 0000000..82cdb6e
--- /dev/null
+++ b/avl-1.4.0/avl.c
@@ -0,0 +1,1154 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avl.c in libavl. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#if PSPP
+#include "common.h"
+#include "arena.h"
+#define HAVE_XMALLOC 1
+#endif
+#if SELF_TEST
+#include
+#include
+#endif
+#include
+#include
+#include
+#include "avl.h"
+
+#if !PSPP && !__GCC__
+#define inline
+#endif
+
+#if !PSPP
+#if __GNUC__ >= 2
+#define unused __attribute__ ((unused))
+#else
+#define unused
+#endif
+#endif
+
+#ifdef HAVE_XMALLOC
+void *xmalloc (size_t);
+#else /* !HAVE_XMALLOC */
+/* Allocates SIZE bytes of space using malloc(). Aborts if out of
+ memory. */
+static void *
+xmalloc (size_t size)
+{
+ void *vp;
+
+ if (size == 0)
+ return NULL;
+ vp = malloc (size);
+
+ assert (vp != NULL);
+ if (vp == NULL)
+ {
+ fprintf (stderr, "virtual memory exhausted\n");
+ exit (EXIT_FAILURE);
+ }
+ return vp;
+}
+#endif /* !HAVE_XMALLOC */
+
+/* Creates an AVL tree in arena OWNER (which can be NULL). The arena
+ is owned by the caller, not by the AVL tree. CMP is a order
+ function for the data to be stored in the tree. PARAM is arbitrary
+ data that becomes an argument to the comparison function. */
+avl_tree *
+avl_create (MAYBE_ARENA avl_comparison_func cmp, void *param)
+{
+ avl_tree *tree;
+
+ assert (cmp != NULL);
+#if PSPP
+ if (owner)
+ tree = arena_alloc (owner, sizeof (avl_tree));
+ else
+#endif
+ tree = xmalloc (sizeof (avl_tree));
+
+#if PSPP
+ tree->owner = owner;
+#endif
+ tree->root.link[0] = NULL;
+ tree->root.link[1] = NULL;
+ tree->cmp = cmp;
+ tree->count = 0;
+ tree->param = param;
+
+ return tree;
+}
+
+/* Destroy tree TREE. Function FREE_FUNC is called for every node in
+ the tree as it is destroyed.
+
+ No effect if the tree has an arena owner and free_func is NULL.
+ The caller owns the arena and must destroy it itself.
+
+ Do not attempt to reuse the tree after it has been freed. Create a
+ new one. */
+void
+avl_destroy (avl_tree *tree, avl_node_func free_func)
+{
+ assert (tree != NULL);
+
+#if PSPP
+ if (free_func || tree->owner == NULL)
+#endif
+ {
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal). */
+
+ /* T1. */
+ avl_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ avl_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ while (p != NULL)
+ {
+ /* T3. */
+ ab[ap] = 0;
+ an[ap++] = p;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if (ab[ap] == 0)
+ {
+ ab[ap++] = 1;
+ p = p->link[1];
+ break;
+ }
+
+ if (free_func)
+ free_func (p->data, tree->param);
+#if PSPP
+ if (tree->owner == NULL)
+#endif
+ free (p);
+ }
+ }
+ }
+
+ done:
+#if PSPP
+ if (tree->owner == NULL)
+#endif
+ free (tree);
+}
+
+/* avl_destroy() with FREE_FUNC hardcoded as free(). */
+void
+avl_free (avl_tree *tree)
+{
+ avl_destroy (tree, (avl_node_func) free);
+}
+
+/* Return the number of nodes in TREE. */
+int
+avl_count (const avl_tree *tree)
+{
+ assert (tree != NULL);
+ return tree->count;
+}
+
+/* Allocates room for a new avl_node in arena OWNER, or using
+ xmalloc() if OWNER is NULL. */
+#if PSPP
+static inline avl_node *
+new_node (arena **owner)
+{
+ if (owner != NULL)
+ return arena_alloc (owner, sizeof (avl_node));
+ else
+ return xmalloc (sizeof (avl_node));
+}
+#else
+static inline avl_node *
+new_node (void)
+{
+ return xmalloc (sizeof (avl_node));
+}
+
+#define new_node(owner) \
+ new_node ()
+#endif
+
+/* Copy the contents of TREE to a new tree in arena OWNER. If COPY is
+ non-NULL, then each data item is passed to function COPY, and the
+ return values are inserted into the new tree; otherwise, the items
+ are copied verbatim from the old tree to the new tree. Returns the
+ new tree. */
+avl_tree *
+avl_copy (MAYBE_ARENA const avl_tree *tree, avl_copy_func copy)
+{
+ /* This is a combination of Knuth's Algorithm 2.3.1C (copying a
+ binary tree) and Algorithm 2.3.1T as modified by exercise 12
+ (preorder traversal). */
+
+ avl_tree *new_tree;
+
+ /* PT1. */
+ const avl_node *pa[AVL_MAX_HEIGHT]; /* Stack PA: nodes. */
+ const avl_node **pp = pa; /* Stack PA: stack pointer. */
+ const avl_node *p = &tree->root;
+
+ /* QT1. */
+ avl_node *qa[AVL_MAX_HEIGHT]; /* Stack QA: nodes. */
+ avl_node **qp = qa; /* Stack QA: stack pointer. */
+ avl_node *q;
+
+ assert (tree != NULL);
+#if PSPP
+ new_tree = avl_create (owner, tree->cmp, tree->param);
+#else
+ new_tree = avl_create (tree->cmp, tree->param);
+#endif
+ new_tree->count = tree->count;
+ q = &new_tree->root;
+
+ for (;;)
+ {
+ /* C4. */
+ if (p->link[0] != NULL)
+ {
+ avl_node *r = new_node (owner);
+ r->link[0] = r->link[1] = NULL;
+ q->link[0] = r;
+ }
+
+ /* C5: Find preorder successors of P and Q. */
+ goto start;
+ for (;;)
+ {
+ /* PT2. */
+ while (p != NULL)
+ {
+ goto escape;
+ start:
+ /* PT3. */
+ *pp++ = p;
+ *qp++ = q;
+ p = p->link[0];
+ q = q->link[0];
+ }
+
+ /* PT4. */
+ if (pp == pa)
+ {
+ assert (qp == qa);
+ return new_tree;
+ }
+
+ p = *--pp;
+ q = *--qp;
+
+ /* PT5. */
+ p = p->link[1];
+ q = q->link[1];
+ }
+ escape:
+
+ /* C2. */
+ if (p->link[1])
+ {
+ avl_node *r = new_node (owner);
+ r->link[0] = r->link[1] = NULL;
+ q->link[1] = r;
+ }
+
+ /* C3. */
+ q->bal = p->bal;
+ if (copy == NULL)
+ q->data = p->data;
+ else
+ q->data = copy (p->data, tree->param);
+ }
+}
+
+/* Walk tree TREE in inorder, calling WALK_FUNC at each node. Passes
+ PARAM to WALK_FUNC. */
+void
+avl_walk (const avl_tree *tree, avl_node_func walk_func, void *param)
+{
+ /* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+ assert (tree && walk_func);
+
+ {
+ /* T1. */
+ const avl_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ const avl_node **ap = an; /* Stack A: stack pointer. */
+ const avl_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ while (p != NULL)
+ {
+ /* T3. */
+ *ap++ = p;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ if (ap == an)
+ return;
+ p = *--ap;
+
+ /* T5. */
+ walk_func (p->data, param);
+ p = p->link[1];
+ }
+ }
+}
+
+/* Each call to this function for a given TREE and TRAV return the
+ next item in the tree in inorder. Initialize the first element of
+ TRAV (init) to 0 before calling the first time. Returns NULL when
+ out of elements. */
+void *
+avl_traverse (const avl_tree *tree, avl_traverser *trav)
+{
+ assert (tree && trav);
+
+ /* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+ if (trav->init == 0)
+ {
+ /* T1. */
+ trav->init = 1;
+ trav->nstack = 0;
+ trav->p = tree->root.link[0];
+ }
+ else
+ /* T5. */
+ trav->p = trav->p->link[1];
+
+ for (;;)
+ {
+ /* T2. */
+ while (trav->p != NULL)
+ {
+ /* T3. */
+ trav->stack[trav->nstack++] = trav->p;
+ trav->p = trav->p->link[0];
+ }
+
+ /* T4. */
+ if (trav->nstack == 0)
+ {
+ trav->init = 0;
+ return NULL;
+ }
+ trav->p = trav->stack[--trav->nstack];
+
+ /* T5. */
+ return trav->p->data;
+ }
+}
+
+/* Search TREE for an item matching ITEM. If found, returns a pointer
+ to the address of the item. If none is found, ITEM is inserted
+ into the tree, and a pointer to the address of ITEM is returned.
+ In either case, the pointer returned can be changed by the caller,
+ or the returned data item can be directly edited, but the key data
+ in the item must not be changed. */
+void **
+avl_probe (avl_tree *tree, void *item)
+{
+ /* Uses Knuth's Algorithm 6.2.3A (balanced tree search and
+ insertion), but caches results of comparisons. In empirical
+ tests this eliminates about 25% of the comparisons seen under
+ random insertions. */
+
+ /* A1. */
+ avl_node *t;
+ avl_node *s, *p, *q, *r;
+
+ assert (tree != NULL);
+ t = &tree->root;
+ s = p = t->link[0];
+
+ if (s == NULL)
+ {
+ tree->count++;
+ assert (tree->count == 1);
+ q = t->link[0] = new_node (tree->owner);
+ q->data = item;
+ q->link[0] = q->link[1] = NULL;
+ q->bal = 0;
+ return &q->data;
+ }
+
+ for (;;)
+ {
+ /* A2. */
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ /* A3. */
+ if (diff < 0)
+ {
+ p->cache = 0;
+ q = p->link[0];
+ if (q == NULL)
+ {
+ p->link[0] = q = new_node (tree->owner);
+ break;
+ }
+ }
+ /* A4. */
+ else if (diff > 0)
+ {
+ p->cache = 1;
+ q = p->link[1];
+ if (q == NULL)
+ {
+ p->link[1] = q = new_node (tree->owner);
+ break;
+ }
+ }
+ else
+ /* A2. */
+ return &p->data;
+
+ /* A3, A4. */
+ if (q->bal != 0)
+ t = p, s = q;
+ p = q;
+ }
+
+ /* A5. */
+ tree->count++;
+ q->data = item;
+ q->link[0] = q->link[1] = NULL;
+ q->bal = 0;
+
+ /* A6. */
+ r = p = s->link[(int) s->cache];
+ while (p != q)
+ {
+ p->bal = p->cache * 2 - 1;
+ p = p->link[(int) p->cache];
+ }
+
+ /* A7. */
+ if (s->cache == 0)
+ {
+ /* a = -1. */
+ if (s->bal == 0)
+ {
+ s->bal = -1;
+ return &q->data;
+ }
+ else if (s->bal == +1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == -1);
+ if (r->bal == -1)
+ {
+ /* A8. */
+ p = r;
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == +1);
+ p = r->link[1];
+ r->link[1] = p->link[0];
+ p->link[0] = r;
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ if (p->bal == -1)
+ s->bal = 1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == +1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ }
+ }
+ else
+ {
+ /* a == +1. */
+ if (s->bal == 0)
+ {
+ s->bal = 1;
+ return &q->data;
+ }
+ else if (s->bal == -1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == +1);
+ if (r->bal == +1)
+ {
+ /* A8. */
+ p = r;
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ r->link[0] = p->link[1];
+ p->link[1] = r;
+ s->link[1] = p->link[0];
+ p->link[0] = s;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = 1;
+ }
+ p->bal = 0;
+ }
+ }
+
+ /* A10. */
+ if (t != &tree->root && s == t->link[1])
+ t->link[1] = p;
+ else
+ t->link[0] = p;
+
+ return &q->data;
+}
+
+/* Search TREE for an item matching ITEM, and return it if found. */
+void *
+avl_find (const avl_tree *tree, const void *item)
+{
+ const avl_node *p;
+
+ assert (tree != NULL);
+ for (p = tree->root.link[0]; p; )
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ if (diff < 0)
+ p = p->link[0];
+ else if (diff > 0)
+ p = p->link[1];
+ else
+ return p->data;
+ }
+
+ return NULL;
+}
+
+/* Search TREE for an item close to the value of ITEM, and return it.
+ This function will return a null pointer only if TREE is empty. */
+void *
+avl_find_close (const avl_tree *tree, const void *item)
+{
+ const avl_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p == NULL)
+ return NULL;
+
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+ int t;
+
+ if (diff < 0)
+ t = 0;
+ else if (diff > 0)
+ t = 1;
+ else
+ return p->data;
+
+ if (p->link[t])
+ p = p->link[t];
+ else
+ return p->data;
+ }
+}
+
+/* Searches AVL tree TREE for an item matching ITEM. If found, the
+ item is removed from the tree and the actual item found is returned
+ to the caller. If no item matching ITEM exists in the tree,
+ returns NULL. */
+void *
+avl_delete (avl_tree *tree, const void *item)
+{
+ /* Uses my Algorithm D, which can be found at
+ http://www.msu.edu/user/pfaffben/avl. Algorithm D is based on
+ Knuth's Algorithm 6.2.2D (Tree deletion) and 6.2.3A (Balanced
+ tree search and insertion), as well as the notes on pages 465-466
+ of Vol. 3. */
+
+ /* D1. */
+ avl_node *pa[AVL_MAX_HEIGHT]; /* Stack P: Nodes. */
+ char a[AVL_MAX_HEIGHT]; /* Stack P: Bits. */
+ int k = 1; /* Stack P: Pointer. */
+
+ avl_node **q;
+ avl_node *p;
+
+ assert (tree != NULL);
+
+ a[0] = 0;
+ pa[0] = &tree->root;
+ p = tree->root.link[0];
+ for (;;)
+ {
+ /* D2. */
+ int diff;
+
+ if (p == NULL)
+ return NULL;
+
+ diff = tree->cmp (item, p->data, tree->param);
+ if (diff == 0)
+ break;
+
+ /* D3, D4. */
+ pa[k] = p;
+ if (diff < 0)
+ {
+ p = p->link[0];
+ a[k] = 0;
+ }
+ else if (diff > 0)
+ {
+ p = p->link[1];
+ a[k] = 1;
+ }
+ k++;
+ }
+ tree->count--;
+
+ item = p->data;
+
+ /* D5. */
+ q = &pa[k - 1]->link[(int) a[k - 1]];
+ if (p->link[1] == NULL)
+ {
+ *q = p->link[0];
+ if (*q)
+ (*q)->bal = 0;
+ }
+ else
+ {
+ /* D6. */
+ avl_node *r = p->link[1];
+ if (r->link[0] == NULL)
+ {
+ r->link[0] = p->link[0];
+ *q = r;
+ r->bal = p->bal;
+ a[k] = 1;
+ pa[k++] = r;
+ }
+ else
+ {
+ /* D7. */
+ avl_node *s = r->link[0];
+ int l = k++;
+
+ a[k] = 0;
+ pa[k++] = r;
+
+ /* D8. */
+ while (s->link[0] != NULL)
+ {
+ r = s;
+ s = r->link[0];
+ a[k] = 0;
+ pa[k++] = r;
+ }
+
+ /* D9. */
+ a[l] = 1;
+ pa[l] = s;
+ s->link[0] = p->link[0];
+ r->link[0] = s->link[1];
+ s->link[1] = p->link[1];
+ s->bal = p->bal;
+ *q = s;
+ }
+ }
+
+#if PSPP
+ if (tree->owner == NULL)
+#endif
+ free (p);
+
+ assert (k > 0);
+ /* D10. */
+ while (--k)
+ {
+ avl_node *s = pa[k], *r;
+
+ if (a[k] == 0)
+ {
+ /* D10. */
+ if (s->bal == -1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = 1;
+ break;
+ }
+
+ assert (s->bal == +1);
+ r = s->link[1];
+
+ assert (r != NULL);
+ if (r->bal == 0)
+ {
+ /* D11. */
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ r->bal = -1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == +1)
+ {
+ /* D12. */
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ }
+ else
+ {
+ /* D13. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ r->link[0] = p->link[1];
+ p->link[1] = r;
+ s->link[1] = p->link[0];
+ p->link[0] = s;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = +1;
+ }
+ p->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ }
+ }
+ else
+ {
+ assert (a[k] == 1);
+
+ /* D10. */
+ if (s->bal == +1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = -1;
+ break;
+ }
+
+ assert (s->bal == -1);
+ r = s->link[0];
+
+ if (r == NULL || r->bal == 0)
+ {
+ /* D11. */
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ r->bal = 1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == -1)
+ {
+ /* D12. */
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ }
+ else if (r->bal == +1)
+ {
+ /* D13. */
+ p = r->link[1];
+ r->link[1] = p->link[0];
+ p->link[0] = r;
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ if (p->bal == -1)
+ s->bal = 1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == 1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ }
+ }
+ }
+
+ return (void *) item;
+}
+
+/* Inserts ITEM into TREE. Returns NULL if the item was inserted,
+ otherwise a pointer to the duplicate item. */
+void *
+avl_insert (avl_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avl_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+/* If ITEM does not exist in TREE, inserts it and returns NULL. If a
+ matching item does exist, it is replaced by ITEM and the item
+ replaced is returned. The caller is responsible for freeing the
+ item returned. */
+void *
+avl_replace (avl_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avl_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+
+/* Delete ITEM from TREE when you know that ITEM must be in TREE. For
+ debugging purposes. */
+void *
+(avl_force_delete) (avl_tree *tree, void *item)
+{
+ void *found = avl_delete (tree, item);
+ assert (found != NULL);
+ return found;
+}
+
+#if SELF_TEST
+
+/* Used to flag delayed aborting. */
+int done = 0;
+
+/* Print the structure of node NODE of an avl tree, which is LEVEL
+ levels from the top of the tree. Uses different delimiters to
+ visually distinguish levels. */
+void
+print_structure (avl_node *node, int level)
+{
+ char lc[] = "([{`/";
+ char rc[] = ")]}'\\";
+
+ assert (level <= 10);
+
+ if (node == NULL)
+ {
+ printf (" nil");
+ return;
+ }
+ printf (" %c%d", lc[level % 5], (int) node->data);
+ if (node->link[0] || node->link[1])
+ print_structure (node->link[0], level + 1);
+ if (node->link[1])
+ print_structure (node->link[1], level + 1);
+ printf ("%c", rc[level % 5]);
+}
+
+/* Compare two integers A and B and return a strcmp()-type result. */
+int
+compare_ints (const void *a, const void *b, void *param unused)
+{
+ return ((int) a) - ((int) b);
+}
+
+/* Print the value of integer A. */
+void
+print_int (void *a, void *param unused)
+{
+ printf (" %d", (int) a);
+}
+
+/* Linearly print contents of TREE. */
+void
+print_contents (avl_tree *tree)
+{
+ avl_walk (tree, print_int, NULL);
+ printf ("\n");
+}
+
+/* Examine NODE in a avl tree. *COUNT is increased by the number of
+ nodes in the tree, including the current one. If the node is the
+ root of the tree, PARENT should be INT_MIN, otherwise it should be
+ the parent node value. DIR is the direction that the current node
+ is linked from the parent: -1 for left child, +1 for right child;
+ it is not used if PARENT is INT_MIN. Returns the height of the
+ tree rooted at NODE. */
+int
+recurse_tree (avl_node *node, int *count, int parent, int dir)
+{
+ if (node)
+ {
+ int d = (int) node->data;
+ int nl = node->link[0] ? recurse_tree (node->link[0], count, d, -1) : 0;
+ int nr = node->link[1] ? recurse_tree (node->link[1], count, d, 1) : 0;
+ (*count)++;
+
+ if (nr - nl != node->bal)
+ {
+ printf (" Node %d is unbalanced: right height=%d, left height=%d, "
+ "difference=%d, but balance factor=%d.\n",
+ d, nr, nl, nr - nl, node->bal);
+ done = 1;
+ }
+
+ if (parent != INT_MIN)
+ {
+ assert (dir == -1 || dir == +1);
+ if (dir == -1 && d > parent)
+ {
+ printf (" Node %d is smaller than its left child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ else if (dir == +1 && d < parent)
+ {
+ printf (" Node %d is larger than its right child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ }
+ assert (node->bal >= -1 && node->bal <= 1);
+ return 1 + (nl > nr ? nl : nr);
+ }
+ else return 0;
+}
+
+/* Check that everything about TREE is kosher. */
+void
+verify_tree (avl_tree *tree)
+{
+ int count = 0;
+ recurse_tree (tree->root.link[0], &count, INT_MIN, 0);
+ if (count != tree->count)
+ {
+ printf (" Tree has %d nodes, but tree count is %d.\n",
+ count, tree->count);
+ done = 1;
+ }
+ if (done)
+ abort ();
+}
+
+/* Arrange the N elements of ARRAY in random order. */
+void
+shuffle (int *array, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ int j = i + rand () % (n - i);
+ int t = array[j];
+ array[j] = array[i];
+ array[i] = t;
+ }
+}
+
+/* Compares avl trees rooted at A and B, making sure that they are
+ identical. */
+void
+compare_trees (avl_node *a, avl_node *b)
+{
+ if (a == NULL || b == NULL)
+ {
+ assert (a == NULL && b == NULL);
+ return;
+ }
+ if (a->data != b->data || a->bal != b->bal
+ || ((a->link[0] != NULL) ^ (b->link[0] != NULL))
+ || ((a->link[1] != NULL) ^ (b->link[1] != NULL)))
+ {
+ printf (" Copied nodes differ: %d b=%d a->bal=%d b->bal=%d a:",
+ (int) a->data, (int) b->data, a->bal, b->bal);
+ if (a->link[0])
+ printf ("l");
+ if (a->link[1])
+ printf ("r");
+ printf (" b:");
+ if (b->link[0])
+ printf ("l");
+ if (b->link[1])
+ printf ("r");
+ printf ("\n");
+ abort ();
+ }
+ if (a->link[0] != NULL)
+ compare_trees (a->link[0], b->link[0]);
+ if (a->link[1] != NULL)
+ compare_trees (a->link[1], b->link[1]);
+}
+
+/* Simple stress test procedure for the AVL tree routines. Does the
+ following:
+
+ * Generate a random number seed. By default this is generated from
+ the current time. You can also pass a seed value on the command
+ line if you want to test the same case. The seed value is
+ displayed.
+
+ * Create a tree and insert the integers from 0 up to TREE_SIZE - 1
+ into it, in random order. Verify the tree structure after each
+ insertion.
+
+ * Remove each integer from the tree, in a different random order.
+ After each deletion, verify the tree structure; also, make a copy
+ of the tree into a new tree, verify the copy and compare it to the
+ original, then destroy the copy.
+
+ * Destroy the tree, increment the random seed value, and start over.
+
+ If you make any modifications to the avl tree routines, then you
+ might want to insert some calls to print_structure() at strategic
+ places in order to be able to see what's really going on. Also,
+ memory debuggers like Checker or Purify are very handy. */
+#define TREE_SIZE 1024
+#define N_ITERATIONS 16
+int
+main (int argc, char **argv)
+{
+ int array[TREE_SIZE];
+ int seed;
+ int iteration;
+
+ if (argc == 2)
+ seed = atoi (argv[1]);
+ else
+ seed = time (0) * 257 % 32768;
+
+ fputs ("Testing avl...\n", stdout);
+
+ for (iteration = 1; iteration <= N_ITERATIONS; iteration++)
+ {
+ avl_tree *tree;
+ int i;
+
+ printf ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed);
+ fflush (stdout);
+
+ srand (seed++);
+
+ for (i = 0; i < TREE_SIZE; i++)
+ array[i] = i;
+ shuffle (array, TREE_SIZE);
+
+ tree = avl_create (compare_ints, NULL);
+ for (i = 0; i < TREE_SIZE; i++)
+ avl_force_insert (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ shuffle (array, TREE_SIZE);
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ avl_tree *copy;
+
+ avl_delete (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ copy = avl_copy (tree, NULL);
+ verify_tree (copy);
+ compare_trees (tree->root.link[0], copy->root.link[0]);
+ avl_destroy (copy, NULL);
+
+ if (i % 128 == 0)
+ {
+ putchar ('.');
+ fflush (stdout);
+ }
+ }
+ fputs (" good.\n", stdout);
+
+ avl_destroy (tree, NULL);
+ }
+
+ return 0;
+}
+#endif /* SELF_TEST */
+
+/*
+ Local variables:
+ compile-command: "gcc -DSELF_TEST=1 -W -Wall -I. -o ./avl-test avl.c"
+ End:
+*/
+
diff --git a/avl-1.4.0/avl.h b/avl-1.4.0/avl.h
new file mode 100644
index 0000000..436a461
--- /dev/null
+++ b/avl-1.4.0/avl.h
@@ -0,0 +1,148 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avl.h in libavl. */
+
+#if !avl_h
+#define avl_h 1
+
+/* The default maximum height of 32 allows for AVL trees having
+ between 5,704,880 and 4,294,967,295 nodes, depending on order of
+ insertion. You may change this compile-time constant as you
+ wish. */
+#ifndef AVL_MAX_HEIGHT
+#define AVL_MAX_HEIGHT 32
+#endif
+
+/* Structure for a node in an AVL tree. */
+typedef struct avl_node
+ {
+ void *data; /* Pointer to data. */
+ struct avl_node *link[2]; /* Subtrees. */
+ signed char bal; /* Balance factor. */
+ char cache; /* Used during insertion. */
+ signed char pad[2]; /* Unused. Reserved for threaded trees. */
+ }
+avl_node;
+
+/* Used for traversing an AVL tree. */
+typedef struct avl_traverser
+ {
+ int init; /* Initialized? */
+ int nstack; /* Top of stack. */
+ const avl_node *p; /* Used for traversal. */
+ const avl_node *stack[AVL_MAX_HEIGHT];/* Descended trees. */
+ }
+avl_traverser;
+
+/* Initializer for avl_traverser. */
+#define AVL_TRAVERSER_INIT {0}
+
+/* Function types. */
+#if !AVL_FUNC_TYPES
+#define AVL_FUNC_TYPES 1
+typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
+typedef void (*avl_node_func) (void *data, void *param);
+typedef void *(*avl_copy_func) (void *data, void *param);
+#endif
+
+/* Structure which holds information about an AVL tree. */
+typedef struct avl_tree
+ {
+#if PSPP
+ struct arena **owner; /* Arena to store nodes. */
+#endif
+ avl_node root; /* Tree root node. */
+ avl_comparison_func cmp; /* Used to compare keys. */
+ int count; /* Number of nodes in the tree. */
+ void *param; /* Arbitary user data. */
+ }
+avl_tree;
+
+#if PSPP
+#define MAYBE_ARENA struct arena **owner,
+#else
+#define MAYBE_ARENA /* nothing */
+#endif
+
+/* General functions. */
+avl_tree *avl_create (MAYBE_ARENA avl_comparison_func, void *param);
+void avl_destroy (avl_tree *, avl_node_func);
+void avl_free (avl_tree *);
+int avl_count (const avl_tree *);
+avl_tree *avl_copy (MAYBE_ARENA const avl_tree *, avl_copy_func);
+
+/* Walk the tree. */
+void avl_walk (const avl_tree *, avl_node_func, void *param);
+void *avl_traverse (const avl_tree *, avl_traverser *);
+#define avl_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
+
+/* Search for a given item. */
+void **avl_probe (avl_tree *, void *);
+void *avl_delete (avl_tree *, const void *);
+void *avl_find (const avl_tree *, const void *);
+void *avl_find_close (const avl_tree *, const void *);
+
+#if __GCC__ >= 2
+extern inline void *
+avl_insert (avl_tree *tree, void *item)
+{
+ void **p = avl_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+extern inline void *
+avl_replace (avl_tree *tree, void *item)
+{
+ void **p = avl_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+#else /* not gcc */
+void *avl_insert (avl_tree *tree, void *item);
+void *avl_replace (avl_tree *tree, void *item);
+#endif /* not gcc */
+
+/* Easy assertions on insertion & deletion. */
+#ifndef NDEBUG
+#define avl_force_insert(A, B) \
+ do \
+ { \
+ void *r = avl_insert (A, B); \
+ assert (r == NULL); \
+ } \
+ while (0)
+void *avl_force_delete (avl_tree *, void *);
+#else
+#define avl_force_insert(A, B) \
+ avl_insert (A, B)
+#define avl_force_delete(A, B) \
+ avl_delete (A, B)
+#endif
+
+#endif /* avl_h */
diff --git a/avl-1.4.0/avl.html b/avl-1.4.0/avl.html
new file mode 100644
index 0000000..ef3e51e
--- /dev/null
+++ b/avl-1.4.0/avl.html
@@ -0,0 +1,1046 @@
+
+
+
+
+libavl manual
+
+
+
+libavl
+A library for manipulation of balanced binary trees
+Ben Pfaff
+
+
+
Table of Contents
+
+
+
+
+
+
+
+
+Consider some techniques that can be used to find a particular item in a
+data set. Typical methods include sequential searching, digital
+searching, hash tables, and binary searching.
+
+
+
+Sequential searching is simple, but slow (O(n)). Digital searching
+requires that the entire data set be known in advance, and memory
+efficient implementations are slow.
+
+
+
+Hash tables are fast (O(1)) for static data sets, but they can be
+wasteful of memory. It can be difficult to choose an effective hash
+function. Some hash tables variants also make deletion an expensive
+operation.
+
+
+
+
+Binary search techniques work almost as quickly (O(log(n)) on an ordered
+table, or on a binary tree. Binary trees also allow easy iteration over
+the data in the tree in sorted order. With hash tables it is necessary
+to sort the data before iterating, and after sorting the data is no
+longer in hash form.
+
+
+
+Binary trees are efficient for insertion, deletion, and searching, if
+data are inserted in random order. But, if data are inserted in order
+using a naive algorithm, binary search degenerates to sequential search.
+
+
+
+
+
+
+In turn, this problem can be solved by rebalancing the tree after
+each insertion or deletion. In rebalancing, nodes are rearranged via
+transformations called rotations using an algorithm that tends to
+minimize the tree's height.
+
+
+
+There are several schemes for rebalancing binary trees. The two most
+common types of balanced tree are AVL trees and red-black
+trees. libavl implements both types:
+
+
+
+
+-
+
+
+
+AVL trees, invented by Russian mathematicians G. M. Adel'son-Velskii and
+E. M. Landis, ensure that, for each node, the difference in height
+between its subtrees (the balance factor) is not greater than 1.
+
+
-
+
+Red-black trees, invented by R. Bayer and studied at length by
+L. J. Guibas and R. Sedgewick, assign each node of a tree a color (red
+or black), and specify a set of rules governing how red and black nodes
+may be arranged.
+
+
+
+The table below presents a comparison among unbalanced binary trees, AVL
+trees, and red-black trees. In the table, n is the number of
+nodes in the tree and h is the tree's height before the
+operation. lg is the base-2 logarithm function.
+
+
+
+
+Operation
+
+
+ Binary Tree
+ | AVL Tree
+ | Red-Black Tree
+
+
+ |
Time per insertion or deletion
+
+
+ O(h)
+ | O(lg n)
+ | O(lg n)
+
+
+ |
Time for insertion of k nodes having sequential values
+
+
+ O(k^2)
+ | O(n lg n)
+ | O(n lg n)
+
+
+ |
Time for insertion of k nodes having random values
+
+
+ O(n lg n)
+ | O(n lg n)
+ | O(n lg n)
+
+
+ |
Maximum number of rotations per insertion
+
+
+ 0
+ | 1
+ | lg n
+
+
+ |
Maximum number of rotations per deletion
+
+
+ 0
+ | lg n
+ | lg n
+
+
+ |
Maximum h as a function of n
+
+
+ n
+ | 1.44 lg (n + 2) - .328
+ | 2 lg (n + 1)
+
+
+ |
Minimum n as a function of h
+
+
+ h
+ | 2^((h + .328) / 1.44) - 2
+ | 2^(h / 2) - 1
+ |
+
+There are alternatives to AVL trees that share some of their properties.
+For instance, skip lists, 2-3 trees, and splay trees all allow O(log(n))
+insertion and deletion. The main disadvantage of these methods is that
+their operations are not as well documented in the literature.
+
+
+
+
+
+
+Threading is a clever method that simplifies binary tree
+traversal.
+
+
+
+Nodes in a unthreaded binary tree that have zero or one subnodes have
+two or one null subnode pointers, respectively. In a threaded binary
+tree, a left child pointer that would otherwise be null is used to point
+to the node's inorder(1)
+predecessor, and in a null right child pointer points to its inorder
+successor.
+
+
+
+In a threaded tree, it is always possible to find the next node and the
+previous node of a node, given only a pointer to the node in question.
+In an unthreaded tree, it's also necessary to have a list of the nodes
+between the node in question and root of the tree.
+
+
+
+Advantages of a threaded tree compared to an unthreaded one include:
+
+
+
+
+-
+
+Faster traversal and less memory usage during traversal, since no stack
+need be maintained.
+
+
-
+
+Greater generality, since one can go from a node to its successor or
+predecessor given only the node, simplifying algorithms that require
+moving forward and backward in a tree.
+
+
+
+Some disadvantages of threaded trees are:
+
+
+
+
+-
+
+Slower insertion and deletion, since threads need to be maintained. In
+somes cases, this can be alleviated by constructing the tree as an
+unthreaded tree, then threading it with a special libavl function.
+
+
-
+
+In theory, threaded trees need two extra bits per node to indicate
+whether each child pointer points to an ordinary node or the node's
+successor/predecessor node. In libavl, however, these bits are stored
+in a byte that is used for structure alignment padding in unthreaded
+binary trees, so no extra storage is used.
+
+
+
+A right-threaded binary tree is similar to a threaded binary tree,
+but threads are only maintained on the right side of each node. This
+allows for traversal to the right (toward larger values) but not to the
+left (toward smaller values). Right-threaded trees are convenient when
+the properties of a threaded tree are desirable, but traversal in
+reverse sort order is not necessary. Not threading the left links saves
+time in insertions and deletions.
+
+
+
+Left-threaded binary trees also exist, but they are not implemented by
+libavl. The same effect can be obtained by sorting the tree in the
+opposite order.
+
+
+
+
+
+
+
+The following types are defined and used by libavl:
+
+
+
+
+- Data Type: avl_tree
+
-
+
- Data Type: avlt_tree
+
-
+
- Data Type: avltr_tree
+
-
+
- Data Type: rb_tree
+
-
+These are the data types used to represent a tree. Although they are
+defined in the libavl header files, it should never be necessary to
+access them directly. Instead, all accesses should take place through
+libavl functions.
+
+
+
+
+
+- Data Type: avl_node
+
-
+
- Data Type: avlt_node
+
-
+
- Data Type: avltr_node
+
-
+
- Data Type: rb_node
+
-
+These are the data types used to represent individual nodes in a tree.
+Similar cautions apply as with
avl_tree
structures.
+
+
+
+
+
+- Data Type: avl_traverser
+
-
+
- Data Type: avlt_traverser
+
-
+
- Data Type: avltr_traverser
+
-
+
- Data Type: rb_traverser
+
-
+These are the data types used by the
avl_traverse
family of
+functions to iterate across the tree. Again, these are opaque
+structures.
+
+
+
+
+
+- Data Type: avl_comparison_func
+
-
+Every tree must have an ordering defined by a function of this type. It
+must have the following signature:
+
+
+
+
+int compare (const void *a, const void *b, void *param)
+
+
+
+The return value is expected to be like that returned by strcmp
+in the standard C library: negative if a < b, zero if
+a = b, positive if a > b. param is an
+arbitrary value defined by the user when the tree was created.
+
+
+
+
+
+- Data Type: avl_node_func
+
-
+This is a class of function called to perform an operation on a data
+item. Functions of this type have the following signature:
+
+
+
+
+void operate (void *data, void *param)
+
+
+
+data is the data item and param is an arbitrary user-defined
+value set when the tree was created.
+
+
+
+
+
+- Data Type: avl_copy_func
+
-
+
+
+
+This is a class of function called to make a new copy of a node's data.
+Functions of this type have the following signature:
+
+
+
+
+void *copy (void *data, void *param)
+
+
+
+The function should return a new copy of data. param is an
+arbitrary user-defined value set when the tree was created.
+
+
+
+
+
+- Macro: AVL_MAX_HEIGHT
+
-
+This macro defines the maximum height of an AVL tree that can be handled
+by functions that maintain a stack of nodes descended. The default
+value is 32, which allows for AVL trees with a maximum number of nodes
+between 5,704,880 and 4,294,967,295, depending on order of insertion.
+This macro may be defined by the user before including any AVL tree
+header file, in which case libavl will honor that value.
+
+
+
+
+
+- Macro: RB_MAX_HEIGHT
+
-
+This macro defines the maximum height of an AVL tree that can be handled
+by functions that maintain a stack of nodes descended. The default
+value is 32, which allows for red-black trees with a maximum number of
+nodes of at least 65535. This macro may be defined by the user before
+including the red-black tree header file, in which case libavl will
+honor that value.
+
+
+
+
+
+
+
+
+
+
+
+libavl is four libraries in one:
+
+
+
+
+-
+
+An unthreaded AVL tree library.
+
+
-
+
+A threaded AVL tree library.
+
+
-
+
+A right-threaded AVL tree library.
+
+
-
+
+A red-black tree library.
+
+
+
+Identifiers in these libraries are prefixed by avl_
,
+avlt_
, avltr_
, and rb_
, with corresponding header
+files `avl.h', `avlt.h', `avltr.h', and `rb.h',
+respectively. The functions that they declare are defined in the
+`.c' files with the same names.
+
+
+
+Most tree functions are implemented in all three libraries, but
+threading allows more generality of operation. So, the threaded and
+right-threaded libraries offer a few additional functions for finding
+the next or previous node from a given node. In addition, they offer
+functions for converting trees from threaded or right-threaded
+representations to unthreaded, and vice versa.(2)
+
+
+
+
+
+
+
+These functions deal with creation and destruction of AVL trees.
+
+
+
+
+- Function: avl_tree * avl_create (avl_comparison_func compare, void *param)
+
-
+
- Function: avlt_tree * avlt_create (avlt_comparison_func compare, void *param)
+
-
+
- Function: avltr_tree * avltr_create (avltr_comparison_func compare, void *param)
+
-
+
- Function: rb_tree * rb_create (avl_comparison_func compare, void *param)
+
-
+Create a new, empty tree with comparison function compare.
+Arbitrary user data param is saved so that it can be passed to
+user callback functions.
+
+
+
+
+
+- Function: void avl_destroy (avl_tree *tree, avl_node_func free)
+
-
+
- Function: void avlt_destroy (avlt_tree *tree, avl_node_func free)
+
-
+
- Function: void avltr_destroy (avltr_tree *tree, avl_node_func free)
+
-
+
- Function: void rb_destroy (rb_tree *tree, avl_node_func free)
+
-
+Destroys tree, releasing all of its storage. If free is
+non-null, then it is called for every node in postorder before that node
+is freed.
+
+
+
+
+
+- Function: void avl_free (avl_tree *tree)
+
-
+
- Function: void avlt_free (avlt_tree *tree)
+
-
+
- Function: void avltr_free (avltr_tree *tree)
+
-
+
- Function: void rb_free (rb_tree *tree)
+
-
+Destroys tree, releasing all of its storage. The data in each
+node is freed with a call to the standard C library function
+
free
.
+
+
+
+
+
+- Function: avl_tree * avl_copy (const avl_tree *tree, avl_copy_func copy)
+
-
+
- Function: avlt_tree * avl_copy (const avlt_tree *tree, avl_copy_func copy)
+
-
+
- Function: avltr_tree * avl_copy (const avltr_tree *tree, avl_copy_func copy)
+
-
+
- Function: rb_tree * rb_copy (const rb_tree *tree, avl_copy_func copy)
+
-
+Copies the contents of tree into a new tree, and returns the new
+tree. If copy is non-null, then it is called to make a new copy
+of each node's data; otherwise, the node data is copied verbatim into
+the new tree.
+
+
+
+
+
+- Function: int avl_count (const avl_tree *tree)
+
-
+
- Function: int avlt_count (const avlt_tree *tree)
+
-
+
- Function: int avltr_count (const avltr_tree *tree)
+
-
+
- Function: int rb_count (const rb_tree *tree)
+
-
+Returns the number of nodes in tree.
+
+
+
+
+
+- Function: void * xmalloc (size_t size)
+
-
+This is not a function defined by libavl. Instead, it is a function
+that the user program can define. It must allocate size bytes
+using
malloc
and return it. It can handle out-of-memory errors
+however it chooses, but it may not ever return a null pointer.
+
+
+
+If there is an xmalloc
function defined for use by libavl, the
+source files (`avl.c', `avlt.c', `avltr.c', `rb.c')
+must be compiled with HAVE_XMALLOC
defined. Otherwise, the
+library will use its internal static xmalloc
, which handles
+out-of-memory errors by printing a message `virtual memory
+exhausted' to stderr and terminating the program with exit code
+EXIT_FAILURE
.
+
+
+
+
+
+
+
+
+These function insert nodes, delete nodes, and search for nodes in
+trees.
+
+
+
+
+- Function: void ** avl_probe (avl_tree *tree, void *data)
+
-
+
- Function: void ** avlt_probe (avlt_tree *tree, void *data)
+
-
+
- Function: void ** avltr_probe (avltr_tree *tree, void *data)
+
-
+
- Function: void ** rb_probe (rb_tree *tree, void *data)
+
-
+These are the workhorse functions for tree insertion. They search
+tree for a node with data matching data. If found, a
+pointer to the matching data is returned. Otherwise, a new node is
+created for data, and a pointer to that data is returned. In
+either case, the pointer returned can be changed by the user, but the
+key data used by the tree's comparison must not be changed(3).
+
+
+
+It is usually easier to use one of the avl_insert
or
+avl_replace
functions instead of avl_probe
directly.
+
+
+
+Please note: It's not a particularly good idea to insert a null
+pointer as a data item into a tree, because several libavl functions
+return a null pointer to indicate failure. You can sometimes avoid a
+problem by using functions that return a pointer to a pointer instead of
+a plain pointer. Also be wary of this when casting an arithmetic type
+to a void pointer for insertion--on typical architectures, 0's become
+null pointers when this is done.
+
+
+
+
+
+- Function: void * avl_insert (avl_tree *tree, void *data)
+
-
+
- Function: void * avlt_insert (avlt_tree *tree, void *data)
+
-
+
- Function: void * avltr_insert (avltr_tree *tree, void *data)
+
-
+
- Function: void * rb_insert (rb_tree *tree, void *data)
+
-
+If a node with data matching data exists in tree, returns
+the matching data item. Otherwise, inserts data into tree
+and returns a null pointer.
+
+
+
+
+
+- Function: void avl_force_insert (avl_tree *tree, void *data)
+
-
+
- Function: void avlt_force_insert (avlt_tree *tree, void *data)
+
-
+
- Function: void avltr_force_insert (avltr_tree *tree, void *data)
+
-
+
- Function: void rb_force_insert (rb_tree *tree, void *data)
+
-
+Inserts data into tree. If a node with data matching
+data exists in tree, aborts the program with an assertion
+violation. This function is implemented as a macro; if it is used, the
+standard C header
assert.h
must also be included. If macro
+NDEBUG
is defined when a libavl header is included, these
+functions are short-circuited to a direct call to avl_insert
,
+and no check is performed.
+
+
+
+
+
+- Function: void * avl_replace (avl_tree *tree, void *data)
+
-
+
- Function: void * avlt_replace (avlt_tree *tree, void *data)
+
-
+
- Function: void * avltr_replace (avltr_tree *tree, void *data)
+
-
+
- Function: void * rb_replace (rb_tree *tree, void *data)
+
-
+If a node with data matching data, such that the comparison
+function returns 0, exists in tree, replaces the node's data with
+data and returns the node's former contents. Otherwise, inserts
+data into tree and returns a null pointer.
+
+
+
+
+
+- Function: void * avl_delete (avl_tree *tree, const void *data)
+
-
+
- Function: void * avlt_delete (avlt_tree *tree, const void *data)
+
-
+
- Function: void * avltr_delete (avltr_tree *tree, const void *data)
+
-
+
- Function: void * rb_delete (rb_tree *tree, const void *data)
+
-
+Searches tree for a node with data matching data. If found,
+the node is deleted and its data is returned. Otherwise, returns a null
+pointer.
+
+
+
+
+
+- Function: void * avl_force_delete (avl_tree *tree, const void *data)
+
-
+
- Function: void * avlt_force_delete (avlt_tree *tree, const void *data)
+
-
+
- Function: void * avltr_force_delete (avltr_tree *tree, const void *data)
+
-
+
- Function: void * rb_force_delete (rb_tree *tree, const void *data)
+
-
+Deletes a node with data matching data from tree. If no
+matching node is found, aborts the program with an assertion violation.
+If macro
NDEBUG
is declared when a libavl header is included,
+these functions are short-circuited to a direct call to
+avl_delete
, and no check is performed.
+
+
+
+
+
+
+
+
+These function search a tree for an item without making an insertion or
+a deletion.
+
+
+
+
+- Function: void * avl_find (avl_tree *tree, const void *data)
+
-
+
- Function: void ** avlt_find (avlt_tree *tree, const void *data)
+
-
+
- Function: void ** avltr_find (avltr_tree *tree, const void *data)
+
-
+
- Function: void * rb_find (rb_tree *tree, const void *data)
+
-
+Searches tree for a node with data matching data, If found,
+returns the node's data (for threaded and right-threaded trees, a
+pointer to the node's data). Otherwise, returns a null pointer.
+
+
+
+
+
+- Function: void * avl_find_close (avl_tree *tree, const void *data)
+
-
+
- Function: void ** avlt_find_close (avlt_tree *tree, const void *data)
+
-
+
- Function: void ** avltr_find_close (avltr_tree *tree, const void *data)
+
-
+
- Function: void * rb_find_close (rb_tree *tree, const void *data)
+
-
+Searches tree for a node with data matching data. If found,
+returns the node's data (for threaded and right-threaded trees, a
+pointer to the node's data). If no matching item is found, then it
+finds a node whose data is "close" to data; either the node
+closest in value to data, or the node either before or after the
+node with the closest value. Returns a null pointer if the tree does
+not contain any nodes.
+
+
+
+
+
+
+
+
+These functions allow the caller to iterate across the items in a tree.
+
+
+
+
+- Function: void avl_walk (const avl_tree *tree, avl_node_func operate, void *param)
+
-
+
- Function: void avlt_walk (const avlt_tree *tree, avl_node_func operate, void *param)
+
-
+
- Function: void avltr_walk (const avltr_tree *tree, avl_node_func operate, void *param)
+
-
+
- Function: void rb_walk (const rb_tree *tree, avl_node_func operate, void *param)
+
-
+Walks through all the nodes in tree, and calls function
+operate for each node in inorder. param overrides the value
+passed to
avl_create
(and family) for this operation only.
+operate must not change the key data in the nodes in a way that
+would reorder the data values or cause two values to become equal.
+
+
+
+
+
+- Function: void * avl_traverse (const avl_tree *tree, avl_traverser *trav)
+
-
+
- Function: void * avlt_traverse (const avlt_tree *tree, avlt_traverser *trav)
+
-
+
- Function: void * avltr_traverse (const avltr_tree *tree, avltr_traverser *trav)
+
-
+
- Function: void * rb_traverse (const rb_tree *tree, rb_traverser *trav)
+
-
+Returns each of tree's nodes' data values in sequence, then a null
+pointer to indicate the last item. trav must be initialized
+before the first call, either in a declaration like that below, or using
+one of the functions below.
+
+
+
+
+avl_traverser trav = AVL_TRAVERSER_INIT;
+
+
+
+Each avl_traverser
(and family) is a separate, independent
+iterator.
+
+
+
+For threaded and right-threaded trees, avlt_next
or
+avltr_next
, respectively, are faster and more memory-efficient
+than avlt_traverse
or avltr_traverse
.
+
+
+
+
+
+- Function: void * avl_init_traverser (avl_traverser *trav)
+
-
+
- Function: void * avlt_init_traverser (avlt_traverser *trav)
+
-
+
- Function: void * avltr_init_traverser (avltr_traverser *trav)
+
-
+
- Function: void * rb_init_traverser (rb_traverser *trav)
+
-
+Initializes the specified tree traverser structure. After this function
+is called, the next call to the corresponding
*_traverse
function
+will return the smallest value in the appropriate tree.
+
+
+
+
+
+- Function: void ** avlt_next (const avlt_tree *tree, void **data)
+
-
+
- Function: void ** avltr_next (const avltr_tree *tree, void **data)
+
-
+data must be a null pointer or a pointer to a data item in AVL
+tree tree. Returns a pointer to the next data item after
+data in tree in inorder (this is the first item if
+data is a null pointer), or a null pointer if data was the
+last item in tree.
+
+
+
+
+
+- Function: void ** avltr_prev (const avltr_tree *tree, void **data)
+
-
+data must be a null pointer or a pointer to a data item in AVL
+tree tree. Returns a pointer to the previous data item before
+data in tree in inorder (this is the last, or greatest
+valued, item if data is a null pointer), or a null pointer if
+data was the first item in tree.
+
+
+
+
+
+
+
+
+
+- Function: avlt_tree * avlt_thread (avl_tree *tree)
+
-
+
- Function: avltr_tree * avltr_thread (avl_tree *tree)
+
-
+Adds symmetric threads or right threads, respectively, to unthreaded AVL
+tree tree and returns a pointer to tree cast to the
+appropriate type. After one of these functions is called, threaded or
+right-threaded functions, as appropriate, must be used with tree;
+unthreaded functions may not be used.
+
+
+
+
+
+- Function: avl_tree * avlt_unthread (avlt_tree *tree)
+
-
+
- Function: avl_tree * avltr_unthread (avltr_tree *tree)
+
-
+Cuts all threads in threaded or right-threaded, respectively, AVL tree
+tree and returns a pointer to tree cast to
avl_tree
+*
. After one of these functions is called, unthreaded functions must
+be used with tree; threaded or right-threaded functions may not be
+used.
+
+
+
+
+
+
+
+
+
+
+
+
+libavl was written by Ben Pfaff blp@gnu.org.
+
+
+
+libavl's generic tree algorithms and AVL algorithms are based on those
+found in Donald Knuth's venerable Art of Computer Programming
+series from Addison-Wesley, primarily Volumes 1 and 3. libavl's
+red-black tree algorithms are based on those found in Cormen et al.,
+Introduction to Algorithms, 2nd ed., from MIT Press.
+
+
+
+
+
+
+
+
a
+
+Adel'son-Velskii, G. M.
+Art of Computer Programming
+author
+AVL tree
+avl_comparison_func
+avl_copy, avl_copy, avl_copy
+avl_copy_func
+avl_count
+avl_create
+avl_delete
+avl_destroy
+avl_find
+avl_find_close
+avl_force_delete
+avl_force_insert
+avl_free
+avl_init_traverser
+avl_insert
+AVL_MAX_HEIGHT
+avl_node
+avl_node_func
+avl_probe
+avl_replace
+avl_traverse
+avl_traverser
+avl_tree
+avl_walk
+avlt_count
+avlt_create
+avlt_delete
+avlt_destroy
+avlt_find
+avlt_find_close
+avlt_force_delete
+avlt_force_insert
+avlt_free
+avlt_init_traverser
+avlt_insert
+avlt_next
+avlt_node
+avlt_probe
+avlt_replace
+avlt_thread
+avlt_traverse
+avlt_traverser
+avlt_tree
+avlt_unthread
+avlt_walk
+avltr_count
+avltr_create
+avltr_delete
+avltr_destroy
+avltr_find
+avltr_find_close
+avltr_force_delete
+avltr_force_insert
+avltr_free
+avltr_init_traverser
+avltr_insert
+avltr_next
+avltr_node
+avltr_prev
+avltr_probe
+avltr_replace
+avltr_thread
+avltr_traverse
+avltr_traverser
+avltr_tree
+avltr_unthread
+avltr_walk
+
+b
+
+binary tree
+
+h
+
+hash table
+
+k
+
+Knuth, Donald Ervin
+
+l
+
+Landis, E. M.
+
+p
+
+Pfaff, Benjamin Levy
+
+r
+
+rb_copy
+rb_count
+rb_create
+rb_delete
+rb_destroy
+rb_find
+rb_find_close
+rb_force_delete
+rb_force_insert
+rb_free
+rb_init_traverser
+rb_insert
+RB_MAX_HEIGHT
+rb_node
+rb_probe
+rb_replace
+rb_traverse
+rb_traverser
+rb_tree
+rb_walk
+rebalancing
+red-black tree
+right threads
+
+t
+
+threads
+
+u
+
+unthreaded
+
+x
+
+xmalloc
+
+
+
+
+
Footnotes
+
+In tree traversal, inorder refers
+to visiting the nodes in their sorted order from smallest to largest.
+
+In general, you
+should build the sort of tree that you need to use, but occasionally it
+is useful to convert between tree types.
+
+It
+can be changed if this would not change the ordering of the nodes in the
+tree; i.e., if this would not cause the data in the node to be less than
+or equal to the previous node's data or greater than or equal to the
+next node's data.
+
+This document was generated on 6 October 1999 using the
+texi2html
+translator version 1.51a.
+
+
diff --git a/avl-1.4.0/avl.info b/avl-1.4.0/avl.info
new file mode 100644
index 0000000..8dd5330
--- /dev/null
+++ b/avl-1.4.0/avl.info
@@ -0,0 +1,708 @@
+This is avl.info, produced by makeinfo version 3.12n from avl.texinfo.
+
+ This file documents libavl, a library for the manipulation of
+balanced binary trees.
+
+ Copyright 1998, 1999 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of this
+manual provided the copyright notice and this permission notice are
+preserved on all copies.
+
+ Permission is granted to copy and distribute modified versions of
+this manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+ Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be stated in a
+translation approved by the Free Software Foundation.
+
+
+File: avl.info, Node: Top, Next: Introduction to balanced binary trees, Prev: (dir), Up: (dir)
+
+ This document describes libavl, a library for manipulation of
+balanced binary trees.
+
+ This document applies to libavl version 1.4.0.
+
+* Menu:
+
+* Introduction to balanced binary trees::
+* Introduction to threaded trees::
+* Types::
+* Functions::
+* Tree Creation::
+* Insertion::
+* Searching::
+* Iteration::
+* Conversion::
+* Author::
+* Index::
+
+
+File: avl.info, Node: Introduction to balanced binary trees, Next: Introduction to threaded trees, Prev: Top, Up: Top
+
+Introduction to balanced binary trees
+*************************************
+
+ Consider some techniques that can be used to find a particular item
+in a data set. Typical methods include sequential searching, digital
+searching, hash tables, and binary searching.
+
+ Sequential searching is simple, but slow (O(n)). Digital searching
+requires that the entire data set be known in advance, and memory
+efficient implementations are slow.
+
+ Hash tables are fast (O(1)) for static data sets, but they can be
+wasteful of memory. It can be difficult to choose an effective hash
+function. Some hash tables variants also make deletion an expensive
+operation.
+
+ Binary search techniques work almost as quickly (O(log(n)) on an
+ordered table, or on a binary tree. Binary trees also allow easy
+iteration over the data in the tree in sorted order. With hash tables
+it is necessary to sort the data before iterating, and after sorting
+the data is no longer in hash form.
+
+ Binary trees are efficient for insertion, deletion, and searching, if
+data are inserted in random order. But, if data are inserted in order
+using a naive algorithm, binary search degenerates to sequential search.
+
+ In turn, this problem can be solved by "rebalancing" the tree after
+each insertion or deletion. In rebalancing, nodes are rearranged via
+transformations called "rotations" using an algorithm that tends to
+minimize the tree's height.
+
+ There are several schemes for rebalancing binary trees. The two most
+common types of balanced tree are "AVL trees" and "red-black trees".
+libavl implements both types:
+
+ * AVL trees, invented by Russian mathematicians G. M.
+ Adel'son-Velskii and E. M. Landis, ensure that, for each node, the
+ difference in height between its subtrees (the "balance factor")
+ is not greater than 1.
+
+ * Red-black trees, invented by R. Bayer and studied at length by L.
+ J. Guibas and R. Sedgewick, assign each node of a tree a color (red
+ or black), and specify a set of rules governing how red and black
+ nodes may be arranged.
+
+ The table below presents a comparison among unbalanced binary trees,
+AVL trees, and red-black trees. In the table, N is the number of nodes
+in the tree and H is the tree's height before the operation. "lg" is
+the base-2 logarithm function.
+
+Operation
+ Binary Tree AVL Tree Red-Black Tree
+Time per insertion or deletion
+ O(H) O(lg N) O(lg N)
+Time for insertion of K nodes having sequential values
+ O(K^2) O(N lg N) O(N lg N)
+Time for insertion of K nodes having random values
+ O(N lg N) O(N lg N) O(N lg N)
+Maximum number of rotations per insertion
+ 0 1 lg N
+Maximum number of rotations per deletion
+ 0 lg N lg N
+Maximum H as a function of N
+ N 1.44 lg (N + 2) - .328 2 lg (N + 1)
+Minimum N as a function of H
+ H 2^((H + .328) / 1.44) - 2 2^(H / 2) - 1
+
+ There are alternatives to AVL trees that share some of their
+properties. For instance, skip lists, 2-3 trees, and splay trees all
+allow O(log(n)) insertion and deletion. The main disadvantage of these
+methods is that their operations are not as well documented in the
+literature.
+
+
+File: avl.info, Node: Introduction to threaded trees, Next: Types, Prev: Introduction to balanced binary trees, Up: Top
+
+Introduction to threaded trees
+******************************
+
+ "Threading" is a clever method that simplifies binary tree traversal.
+
+ Nodes in a unthreaded binary tree that have zero or one subnodes have
+two or one null subnode pointers, respectively. In a threaded binary
+tree, a left child pointer that would otherwise be null is used to point
+to the node's inorder(1) predecessor, and in a null right child pointer
+points to its inorder successor.
+
+ In a threaded tree, it is always possible to find the next node and
+the previous node of a node, given only a pointer to the node in
+question. In an unthreaded tree, it's also necessary to have a list of
+the nodes between the node in question and root of the tree.
+
+ Advantages of a threaded tree compared to an unthreaded one include:
+
+ * Faster traversal and less memory usage during traversal, since no
+ stack need be maintained.
+
+ * Greater generality, since one can go from a node to its successor
+ or predecessor given only the node, simplifying algorithms that
+ require moving forward and backward in a tree.
+
+ Some disadvantages of threaded trees are:
+
+ * Slower insertion and deletion, since threads need to be
+ maintained. In somes cases, this can be alleviated by
+ constructing the tree as an unthreaded tree, then threading it
+ with a special libavl function.
+
+ * In theory, threaded trees need two extra bits per node to indicate
+ whether each child pointer points to an ordinary node or the node's
+ successor/predecessor node. In libavl, however, these bits are
+ stored in a byte that is used for structure alignment padding in
+ unthreaded binary trees, so no extra storage is used.
+
+ A "right-threaded binary tree" is similar to a threaded binary tree,
+but threads are only maintained on the right side of each node. This
+allows for traversal to the right (toward larger values) but not to the
+left (toward smaller values). Right-threaded trees are convenient when
+the properties of a threaded tree are desirable, but traversal in
+reverse sort order is not necessary. Not threading the left links saves
+time in insertions and deletions.
+
+ Left-threaded binary trees also exist, but they are not implemented
+by libavl. The same effect can be obtained by sorting the tree in the
+opposite order.
+
+ ---------- Footnotes ----------
+
+ (1) In tree traversal, "inorder" refers to visiting the nodes in
+their sorted order from smallest to largest.
+
+
+File: avl.info, Node: Types, Next: Functions, Prev: Introduction to threaded trees, Up: Top
+
+Types
+*****
+
+ The following types are defined and used by libavl:
+
+ - Data Type: avl_tree
+ - Data Type: avlt_tree
+ - Data Type: avltr_tree
+ - Data Type: rb_tree
+ These are the data types used to represent a tree. Although they
+ are defined in the libavl header files, it should never be
+ necessary to access them directly. Instead, all accesses should
+ take place through libavl functions.
+
+ - Data Type: avl_node
+ - Data Type: avlt_node
+ - Data Type: avltr_node
+ - Data Type: rb_node
+ These are the data types used to represent individual nodes in a
+ tree. Similar cautions apply as with `avl_tree' structures.
+
+ - Data Type: avl_traverser
+ - Data Type: avlt_traverser
+ - Data Type: avltr_traverser
+ - Data Type: rb_traverser
+ These are the data types used by the `avl_traverse' family of
+ functions to iterate across the tree. Again, these are opaque
+ structures.
+
+ - Data Type: avl_comparison_func
+ Every tree must have an ordering defined by a function of this
+ type. It must have the following signature:
+
+ int COMPARE (const void *A, const void *B, void *PARAM)
+
+ The return value is expected to be like that returned by `strcmp'
+ in the standard C library: negative if A < B, zero if A = B,
+ positive if A > B. PARAM is an arbitrary value defined by the
+ user when the tree was created.
+
+ - Data Type: avl_node_func
+ This is a class of function called to perform an operation on a
+ data item. Functions of this type have the following signature:
+
+ void OPERATE (void *DATA, void *PARAM)
+
+ DATA is the data item and PARAM is an arbitrary user-defined value
+ set when the tree was created.
+
+ - Data Type: avl_copy_func
+ This is a class of function called to make a new copy of a node's
+ data. Functions of this type have the following signature:
+
+ void *COPY (void *DATA, void *PARAM)
+
+ The function should return a new copy of DATA. PARAM is an
+ arbitrary user-defined value set when the tree was created.
+
+ - Macro: AVL_MAX_HEIGHT
+ This macro defines the maximum height of an AVL tree that can be
+ handled by functions that maintain a stack of nodes descended.
+ The default value is 32, which allows for AVL trees with a maximum
+ number of nodes between 5,704,880 and 4,294,967,295, depending on
+ order of insertion. This macro may be defined by the user before
+ including any AVL tree header file, in which case libavl will
+ honor that value.
+
+ - Macro: RB_MAX_HEIGHT
+ This macro defines the maximum height of an AVL tree that can be
+ handled by functions that maintain a stack of nodes descended.
+ The default value is 32, which allows for red-black trees with a
+ maximum number of nodes of at least 65535. This macro may be
+ defined by the user before including the red-black tree header
+ file, in which case libavl will honor that value.
+
+
+File: avl.info, Node: Functions, Next: Tree Creation, Prev: Types, Up: Top
+
+Functions
+*********
+
+ libavl is four libraries in one:
+
+ * An unthreaded AVL tree library.
+
+ * A threaded AVL tree library.
+
+ * A right-threaded AVL tree library.
+
+ * A red-black tree library.
+
+ Identifiers in these libraries are prefixed by `avl_', `avlt_',
+`avltr_', and `rb_', with corresponding header files `avl.h', `avlt.h',
+`avltr.h', and `rb.h', respectively. The functions that they declare
+are defined in the `.c' files with the same names.
+
+ Most tree functions are implemented in all three libraries, but
+threading allows more generality of operation. So, the threaded and
+right-threaded libraries offer a few additional functions for finding
+the next or previous node from a given node. In addition, they offer
+functions for converting trees from threaded or right-threaded
+representations to unthreaded, and vice versa.(1)
+
+ ---------- Footnotes ----------
+
+ (1) In general, you should build the sort of tree that you need to
+use, but occasionally it is useful to convert between tree types.
+
+
+File: avl.info, Node: Tree Creation, Next: Insertion, Prev: Functions, Up: Top
+
+Tree Creation
+*************
+
+ These functions deal with creation and destruction of AVL trees.
+
+ - Function: avl_tree * avl_create (avl_comparison_func COMPARE, void
+ *PARAM)
+ - Function: avlt_tree * avlt_create (avlt_comparison_func COMPARE,
+ void *PARAM)
+ - Function: avltr_tree * avltr_create (avltr_comparison_func COMPARE,
+ void *PARAM)
+ - Function: rb_tree * rb_create (avl_comparison_func COMPARE, void
+ *PARAM)
+ Create a new, empty tree with comparison function COMPARE.
+ Arbitrary user data PARAM is saved so that it can be passed to
+ user callback functions.
+
+ - Function: void avl_destroy (avl_tree *TREE, avl_node_func FREE)
+ - Function: void avlt_destroy (avlt_tree *TREE, avl_node_func FREE)
+ - Function: void avltr_destroy (avltr_tree *TREE, avl_node_func FREE)
+ - Function: void rb_destroy (rb_tree *TREE, avl_node_func FREE)
+ Destroys TREE, releasing all of its storage. If FREE is non-null,
+ then it is called for every node in postorder before that node is
+ freed.
+
+ - Function: void avl_free (avl_tree *TREE)
+ - Function: void avlt_free (avlt_tree *TREE)
+ - Function: void avltr_free (avltr_tree *TREE)
+ - Function: void rb_free (rb_tree *TREE)
+ Destroys TREE, releasing all of its storage. The data in each
+ node is freed with a call to the standard C library function
+ `free'.
+
+ - Function: avl_tree * avl_copy (const avl_tree *TREE, avl_copy_func
+ COPY)
+ - Function: avlt_tree * avl_copy (const avlt_tree *TREE, avl_copy_func
+ COPY)
+ - Function: avltr_tree * avl_copy (const avltr_tree *TREE,
+ avl_copy_func COPY)
+ - Function: rb_tree * rb_copy (const rb_tree *TREE, avl_copy_func COPY)
+ Copies the contents of TREE into a new tree, and returns the new
+ tree. If COPY is non-null, then it is called to make a new copy
+ of each node's data; otherwise, the node data is copied verbatim
+ into the new tree.
+
+ - Function: int avl_count (const avl_tree *TREE)
+ - Function: int avlt_count (const avlt_tree *TREE)
+ - Function: int avltr_count (const avltr_tree *TREE)
+ - Function: int rb_count (const rb_tree *TREE)
+ Returns the number of nodes in TREE.
+
+ - Function: void * xmalloc (size_t SIZE)
+ This is not a function defined by libavl. Instead, it is a
+ function that the user program can define. It must allocate SIZE
+ bytes using `malloc' and return it. It can handle out-of-memory
+ errors however it chooses, but it may not ever return a null
+ pointer.
+
+ If there is an `xmalloc' function defined for use by libavl, the
+ source files (`avl.c', `avlt.c', `avltr.c', `rb.c') must be
+ compiled with `HAVE_XMALLOC' defined. Otherwise, the library will
+ use its internal static `xmalloc', which handles out-of-memory
+ errors by printing a message `virtual memory exhausted' to stderr
+ and terminating the program with exit code `EXIT_FAILURE'.
+
+
+File: avl.info, Node: Insertion, Next: Searching, Prev: Tree Creation, Up: Top
+
+Insertion and Deletion
+**********************
+
+ These function insert nodes, delete nodes, and search for nodes in
+trees.
+
+ - Function: void ** avl_probe (avl_tree *TREE, void *DATA)
+ - Function: void ** avlt_probe (avlt_tree *TREE, void *DATA)
+ - Function: void ** avltr_probe (avltr_tree *TREE, void *DATA)
+ - Function: void ** rb_probe (rb_tree *TREE, void *DATA)
+ These are the workhorse functions for tree insertion. They search
+ TREE for a node with data matching DATA. If found, a pointer to
+ the matching data is returned. Otherwise, a new node is created
+ for DATA, and a pointer to that data is returned. In either case,
+ the pointer returned can be changed by the user, but the key data
+ used by the tree's comparison must not be changed(1).
+
+ It is usually easier to use one of the `avl_insert' or
+ `avl_replace' functions instead of `avl_probe' directly.
+
+ *Please note:* It's not a particularly good idea to insert a null
+ pointer as a data item into a tree, because several libavl
+ functions return a null pointer to indicate failure. You can
+ sometimes avoid a problem by using functions that return a pointer
+ to a pointer instead of a plain pointer. Also be wary of this
+ when casting an arithmetic type to a void pointer for
+ insertion--on typical architectures, 0's become null pointers when
+ this is done.
+
+ - Function: void * avl_insert (avl_tree *TREE, void *DATA)
+ - Function: void * avlt_insert (avlt_tree *TREE, void *DATA)
+ - Function: void * avltr_insert (avltr_tree *TREE, void *DATA)
+ - Function: void * rb_insert (rb_tree *TREE, void *DATA)
+ If a node with data matching DATA exists in TREE, returns the
+ matching data item. Otherwise, inserts DATA into TREE and returns
+ a null pointer.
+
+ - Function: void avl_force_insert (avl_tree *TREE, void *DATA)
+ - Function: void avlt_force_insert (avlt_tree *TREE, void *DATA)
+ - Function: void avltr_force_insert (avltr_tree *TREE, void *DATA)
+ - Function: void rb_force_insert (rb_tree *TREE, void *DATA)
+ Inserts DATA into TREE. If a node with data matching DATA exists
+ in TREE, aborts the program with an assertion violation. This
+ function is implemented as a macro; if it is used, the standard C
+ header `assert.h' must also be included. If macro `NDEBUG' is
+ defined when a libavl header is included, these functions are
+ short-circuited to a direct call to `avl_insert', and no check is
+ performed.
+
+ - Function: void * avl_replace (avl_tree *TREE, void *DATA)
+ - Function: void * avlt_replace (avlt_tree *TREE, void *DATA)
+ - Function: void * avltr_replace (avltr_tree *TREE, void *DATA)
+ - Function: void * rb_replace (rb_tree *TREE, void *DATA)
+ If a node with data matching DATA, such that the comparison
+ function returns 0, exists in TREE, replaces the node's data with
+ DATA and returns the node's former contents. Otherwise, inserts
+ DATA into TREE and returns a null pointer.
+
+ - Function: void * avl_delete (avl_tree *TREE, const void *DATA)
+ - Function: void * avlt_delete (avlt_tree *TREE, const void *DATA)
+ - Function: void * avltr_delete (avltr_tree *TREE, const void *DATA)
+ - Function: void * rb_delete (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA. If found, the
+ node is deleted and its data is returned. Otherwise, returns a
+ null pointer.
+
+ - Function: void * avl_force_delete (avl_tree *TREE, const void *DATA)
+ - Function: void * avlt_force_delete (avlt_tree *TREE, const void
+ *DATA)
+ - Function: void * avltr_force_delete (avltr_tree *TREE, const void
+ *DATA)
+ - Function: void * rb_force_delete (rb_tree *TREE, const void *DATA)
+ Deletes a node with data matching DATA from TREE. If no matching
+ node is found, aborts the program with an assertion violation. If
+ macro `NDEBUG' is declared when a libavl header is included, these
+ functions are short-circuited to a direct call to `avl_delete',
+ and no check is performed.
+
+ ---------- Footnotes ----------
+
+ (1) It can be changed if this would not change the ordering of the
+nodes in the tree; i.e., if this would not cause the data in the node
+to be less than or equal to the previous node's data or greater than or
+equal to the next node's data.
+
+
+File: avl.info, Node: Searching, Next: Iteration, Prev: Insertion, Up: Top
+
+Searching
+*********
+
+ These function search a tree for an item without making an insertion
+or a deletion.
+
+ - Function: void * avl_find (avl_tree *TREE, const void *DATA)
+ - Function: void ** avlt_find (avlt_tree *TREE, const void *DATA)
+ - Function: void ** avltr_find (avltr_tree *TREE, const void *DATA)
+ - Function: void * rb_find (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA, If found,
+ returns the node's data (for threaded and right-threaded trees, a
+ pointer to the node's data). Otherwise, returns a null pointer.
+
+ - Function: void * avl_find_close (avl_tree *TREE, const void *DATA)
+ - Function: void ** avlt_find_close (avlt_tree *TREE, const void *DATA)
+ - Function: void ** avltr_find_close (avltr_tree *TREE, const void
+ *DATA)
+ - Function: void * rb_find_close (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA. If found,
+ returns the node's data (for threaded and right-threaded trees, a
+ pointer to the node's data). If no matching item is found, then it
+ finds a node whose data is "close" to DATA; either the node
+ closest in value to DATA, or the node either before or after the
+ node with the closest value. Returns a null pointer if the tree
+ does not contain any nodes.
+
+
+File: avl.info, Node: Iteration, Next: Conversion, Prev: Searching, Up: Top
+
+Iteration
+*********
+
+ These functions allow the caller to iterate across the items in a
+tree.
+
+ - Function: void avl_walk (const avl_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void avlt_walk (const avlt_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void avltr_walk (const avltr_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void rb_walk (const rb_tree *TREE, avl_node_func OPERATE,
+ void *PARAM)
+ Walks through all the nodes in TREE, and calls function OPERATE
+ for each node in inorder. PARAM overrides the value passed to
+ `avl_create' (and family) for this operation only. OPERATE must
+ not change the key data in the nodes in a way that would reorder
+ the data values or cause two values to become equal.
+
+ - Function: void * avl_traverse (const avl_tree *TREE, avl_traverser
+ *TRAV)
+ - Function: void * avlt_traverse (const avlt_tree *TREE,
+ avlt_traverser *TRAV)
+ - Function: void * avltr_traverse (const avltr_tree *TREE,
+ avltr_traverser *TRAV)
+ - Function: void * rb_traverse (const rb_tree *TREE, rb_traverser
+ *TRAV)
+ Returns each of TREE's nodes' data values in sequence, then a null
+ pointer to indicate the last item. TRAV must be initialized
+ before the first call, either in a declaration like that below, or
+ using one of the functions below.
+
+ avl_traverser trav = AVL_TRAVERSER_INIT;
+
+ Each `avl_traverser' (and family) is a separate, independent
+ iterator.
+
+ For threaded and right-threaded trees, `avlt_next' or
+ `avltr_next', respectively, are faster and more memory-efficient
+ than `avlt_traverse' or `avltr_traverse'.
+
+ - Function: void * avl_init_traverser (avl_traverser *TRAV)
+ - Function: void * avlt_init_traverser (avlt_traverser *TRAV)
+ - Function: void * avltr_init_traverser (avltr_traverser *TRAV)
+ - Function: void * rb_init_traverser (rb_traverser *TRAV)
+ Initializes the specified tree traverser structure. After this
+ function is called, the next call to the corresponding
+ `*_traverse' function will return the smallest value in the
+ appropriate tree.
+
+ - Function: void ** avlt_next (const avlt_tree *TREE, void **DATA)
+ - Function: void ** avltr_next (const avltr_tree *TREE, void **DATA)
+ DATA must be a null pointer or a pointer to a data item in AVL
+ tree TREE. Returns a pointer to the next data item after DATA in
+ TREE in inorder (this is the first item if DATA is a null
+ pointer), or a null pointer if DATA was the last item in TREE.
+
+ - Function: void ** avltr_prev (const avltr_tree *TREE, void **DATA)
+ DATA must be a null pointer or a pointer to a data item in AVL
+ tree TREE. Returns a pointer to the previous data item before
+ DATA in TREE in inorder (this is the last, or greatest valued,
+ item if DATA is a null pointer), or a null pointer if DATA was the
+ first item in TREE.
+
+
+File: avl.info, Node: Conversion, Next: Author, Prev: Iteration, Up: Top
+
+Conversion
+**********
+
+ - Function: avlt_tree * avlt_thread (avl_tree *TREE)
+ - Function: avltr_tree * avltr_thread (avl_tree *TREE)
+ Adds symmetric threads or right threads, respectively, to
+ unthreaded AVL tree TREE and returns a pointer to TREE cast to the
+ appropriate type. After one of these functions is called,
+ threaded or right-threaded functions, as appropriate, must be used
+ with TREE; unthreaded functions may not be used.
+
+ - Function: avl_tree * avlt_unthread (avlt_tree *TREE)
+ - Function: avl_tree * avltr_unthread (avltr_tree *TREE)
+ Cuts all threads in threaded or right-threaded, respectively, AVL
+ tree TREE and returns a pointer to TREE cast to `avl_tree *'.
+ After one of these functions is called, unthreaded functions must
+ be used with TREE; threaded or right-threaded functions may not be
+ used.
+
+
+File: avl.info, Node: Author, Next: Index, Prev: Conversion, Up: Top
+
+Author
+******
+
+ libavl was written by Ben Pfaff .
+
+ libavl's generic tree algorithms and AVL algorithms are based on
+those found in Donald Knuth's venerable `Art of Computer Programming'
+series from Addison-Wesley, primarily Volumes 1 and 3. libavl's
+red-black tree algorithms are based on those found in Cormen et al.,
+`Introduction to Algorithms', 2nd ed., from MIT Press.
+
+
+File: avl.info, Node: Index, Prev: Author, Up: Top
+
+Index
+*****
+
+* Menu:
+
+* `Art of Computer Programming': Author.
+* Adel'son-Velskii, G. M.: Introduction to balanced binary trees.
+* author: Author.
+* AVL tree: Introduction to balanced binary trees.
+* avl_comparison_func: Types.
+* avl_copy: Tree Creation.
+* avl_copy_func: Types.
+* avl_count: Tree Creation.
+* avl_create: Tree Creation.
+* avl_delete: Insertion.
+* avl_destroy: Tree Creation.
+* avl_find: Searching.
+* avl_find_close: Searching.
+* avl_force_delete: Insertion.
+* avl_force_insert: Insertion.
+* avl_free: Tree Creation.
+* avl_init_traverser: Iteration.
+* avl_insert: Insertion.
+* AVL_MAX_HEIGHT: Types.
+* avl_node: Types.
+* avl_node_func: Types.
+* avl_probe: Insertion.
+* avl_replace: Insertion.
+* avl_traverse: Iteration.
+* avl_traverser: Types.
+* avl_tree: Types.
+* avl_walk: Iteration.
+* avlt_count: Tree Creation.
+* avlt_create: Tree Creation.
+* avlt_delete: Insertion.
+* avlt_destroy: Tree Creation.
+* avlt_find: Searching.
+* avlt_find_close: Searching.
+* avlt_force_delete: Insertion.
+* avlt_force_insert: Insertion.
+* avlt_free: Tree Creation.
+* avlt_init_traverser: Iteration.
+* avlt_insert: Insertion.
+* avlt_next: Iteration.
+* avlt_node: Types.
+* avlt_probe: Insertion.
+* avlt_replace: Insertion.
+* avlt_thread: Conversion.
+* avlt_traverse: Iteration.
+* avlt_traverser: Types.
+* avlt_tree: Types.
+* avlt_unthread: Conversion.
+* avlt_walk: Iteration.
+* avltr_count: Tree Creation.
+* avltr_create: Tree Creation.
+* avltr_delete: Insertion.
+* avltr_destroy: Tree Creation.
+* avltr_find: Searching.
+* avltr_find_close: Searching.
+* avltr_force_delete: Insertion.
+* avltr_force_insert: Insertion.
+* avltr_free: Tree Creation.
+* avltr_init_traverser: Iteration.
+* avltr_insert: Insertion.
+* avltr_next: Iteration.
+* avltr_node: Types.
+* avltr_prev: Iteration.
+* avltr_probe: Insertion.
+* avltr_replace: Insertion.
+* avltr_thread: Conversion.
+* avltr_traverse: Iteration.
+* avltr_traverser: Types.
+* avltr_tree: Types.
+* avltr_unthread: Conversion.
+* avltr_walk: Iteration.
+* binary tree: Introduction to balanced binary trees.
+* hash table: Introduction to balanced binary trees.
+* Knuth, Donald Ervin: Author.
+* Landis, E. M.: Introduction to balanced binary trees.
+* Pfaff, Benjamin Levy: Author.
+* rb_copy: Tree Creation.
+* rb_count: Tree Creation.
+* rb_create: Tree Creation.
+* rb_delete: Insertion.
+* rb_destroy: Tree Creation.
+* rb_find: Searching.
+* rb_find_close: Searching.
+* rb_force_delete: Insertion.
+* rb_force_insert: Insertion.
+* rb_free: Tree Creation.
+* rb_init_traverser: Iteration.
+* rb_insert: Insertion.
+* RB_MAX_HEIGHT: Types.
+* rb_node: Types.
+* rb_probe: Insertion.
+* rb_replace: Insertion.
+* rb_traverse: Iteration.
+* rb_traverser: Types.
+* rb_tree: Types.
+* rb_walk: Iteration.
+* rebalancing: Introduction to balanced binary trees.
+* red-black tree: Introduction to balanced binary trees.
+* right threads: Functions.
+* threads: Functions.
+* unthreaded: Functions.
+* xmalloc: Tree Creation.
+
+
+
+Tag Table:
+Node: Top891
+Node: Introduction to balanced binary trees1340
+Node: Introduction to threaded trees5260
+Ref: Introduction to threaded trees-Footnote-17757
+Node: Types7871
+Node: Functions10904
+Ref: Functions-Footnote-111877
+Node: Tree Creation12014
+Node: Insertion15035
+Ref: Insertion-Footnote-119214
+Node: Searching19458
+Node: Iteration20863
+Node: Conversion23929
+Node: Author24875
+Node: Index25345
+
+End Tag Table
diff --git a/avl-1.4.0/avl.texinfo b/avl-1.4.0/avl.texinfo
new file mode 100644
index 0000000..9d06324
--- /dev/null
+++ b/avl-1.4.0/avl.texinfo
@@ -0,0 +1,679 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename avl.info
+@settitle libavl manual
+@setchapternewpage on
+@c %**end of header
+
+@syncodeindex vr cp
+@syncodeindex fn cp
+@syncodeindex tp cp
+
+@ifinfo
+This file documents libavl, a library for the manipulation of balanced
+binary trees.
+
+Copyright 1998, 1999 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of this
+manual provided the copyright notice and this permission notice are
+preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries a copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+
+@end ignore
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation
+approved by the Free Software Foundation.
+@end ifinfo
+
+@titlepage
+@title libavl
+@subtitle A library for manipulation of balanced binary trees
+@author Ben Pfaff
+
+@page
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1998, 1999 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of this
+manual provided the copyright notice and this permission notice are
+preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation
+approved by the Free Software Foundation.
+@end titlepage
+
+@node Top, Introduction to balanced binary trees, (dir), (dir)
+
+@ifinfo
+This document describes libavl, a library for manipulation of balanced
+binary trees.
+
+This document applies to libavl version 1.4.0.
+@end ifinfo
+
+@menu
+* Introduction to balanced binary trees::
+* Introduction to threaded trees::
+* Types::
+* Functions::
+* Tree Creation::
+* Insertion::
+* Searching::
+* Iteration::
+* Conversion::
+* Author::
+* Index::
+@end menu
+
+@node Introduction to balanced binary trees, Introduction to threaded trees, Top, Top
+@chapter Introduction to balanced binary trees
+
+@cindex hash table
+Consider some techniques that can be used to find a particular item in a
+data set. Typical methods include sequential searching, digital
+searching, hash tables, and binary searching.
+
+Sequential searching is simple, but slow (O(n)). Digital searching
+requires that the entire data set be known in advance, and memory
+efficient implementations are slow.
+
+Hash tables are fast (O(1)) for static data sets, but they can be
+wasteful of memory. It can be difficult to choose an effective hash
+function. Some hash tables variants also make deletion an expensive
+operation.
+
+@cindex binary tree
+Binary search techniques work almost as quickly (O(log(n)) on an ordered
+table, or on a binary tree. Binary trees also allow easy iteration over
+the data in the tree in sorted order. With hash tables it is necessary
+to sort the data before iterating, and after sorting the data is no
+longer in hash form.
+
+Binary trees are efficient for insertion, deletion, and searching, if
+data are inserted in random order. But, if data are inserted in order
+using a naive algorithm, binary search degenerates to sequential search.
+
+@cindex red-black tree
+@cindex AVL tree
+@cindex rebalancing
+In turn, this problem can be solved by @dfn{rebalancing} the tree after
+each insertion or deletion. In rebalancing, nodes are rearranged via
+transformations called @dfn{rotations} using an algorithm that tends to
+minimize the tree's height.
+
+There are several schemes for rebalancing binary trees. The two most
+common types of balanced tree are @dfn{AVL trees} and @dfn{red-black
+trees}. libavl implements both types:
+
+@itemize @bullet
+@item
+@cindex Landis, E. M.
+@cindex Adel'son-Velskii, G. M.
+AVL trees, invented by Russian mathematicians G. M. Adel'son-Velskii and
+E. M. Landis, ensure that, for each node, the difference in height
+between its subtrees (the @dfn{balance factor}) is not greater than 1.
+
+@item
+Red-black trees, invented by R. Bayer and studied at length by
+L. J. Guibas and R. Sedgewick, assign each node of a tree a color (red
+or black), and specify a set of rules governing how red and black nodes
+may be arranged.
+@end itemize
+
+The table below presents a comparison among unbalanced binary trees, AVL
+trees, and red-black trees. In the table, @var{n} is the number of
+nodes in the tree and @var{h} is the tree's height before the
+operation. @dfn{lg} is the base-2 logarithm function.
+
+@multitable @columnfractions .05 .30 .35 .30
+
+@need 333
+@item @w{Operation}
+@item
+@tab Binary Tree
+@tab AVL Tree
+@tab Red-Black Tree
+
+@need 333
+@item @w{Time per insertion or deletion}
+@item
+@tab O(@var{h})
+@tab O(lg @var{n})
+@tab O(lg @var{n})
+
+@need 333
+@item @w{Time for insertion of @var{k} nodes having sequential values}
+@item
+@tab O(@math{@var{k}^2})
+@tab O(@var{n} lg @var{n})
+@tab O(@var{n} lg @var{n})
+
+@need 333
+@item @w{Time for insertion of @var{k} nodes having random values}
+@item
+@tab O(@var{n} lg @var{n})
+@tab O(@var{n} lg @var{n})
+@tab O(@var{n} lg @var{n})
+
+@need 333
+@item @w{Maximum number of rotations per insertion}
+@item
+@tab 0
+@tab 1
+@tab lg @var{n}
+
+@need 333
+@item @w{Maximum number of rotations per deletion}
+@item
+@tab 0
+@tab lg @var{n}
+@tab lg @var{n}
+
+@need 333
+@item @w{Maximum @var{h} as a function of @var{n}}
+@item
+@tab @var{n}
+@tab 1.44 lg (@var{n} + 2) - .328
+@tab 2 lg (@var{n} + 1)
+
+@need 333
+@item @w{Minimum @var{n} as a function of @var{h}}
+@item
+@tab @var{h}
+@tab 2^((@var{h} + .328) / 1.44) - 2
+@tab 2^(@var{h} / 2) - 1
+@end multitable
+
+There are alternatives to AVL trees that share some of their properties.
+For instance, skip lists, 2-3 trees, and splay trees all allow O(log(n))
+insertion and deletion. The main disadvantage of these methods is that
+their operations are not as well documented in the literature.
+
+@node Introduction to threaded trees, Types, Introduction to balanced binary trees, Top
+@chapter Introduction to threaded trees
+
+@dfn{Threading} is a clever method that simplifies binary tree
+traversal.
+
+Nodes in a unthreaded binary tree that have zero or one subnodes have
+two or one null subnode pointers, respectively. In a threaded binary
+tree, a left child pointer that would otherwise be null is used to point
+to the node's inorder@footnote{In tree traversal, @dfn{inorder} refers
+to visiting the nodes in their sorted order from smallest to largest.}
+predecessor, and in a null right child pointer points to its inorder
+successor.
+
+In a threaded tree, it is always possible to find the next node and the
+previous node of a node, given only a pointer to the node in question.
+In an unthreaded tree, it's also necessary to have a list of the nodes
+between the node in question and root of the tree.
+
+Advantages of a threaded tree compared to an unthreaded one include:
+
+@itemize @bullet
+@item
+Faster traversal and less memory usage during traversal, since no stack
+need be maintained.
+
+@item
+Greater generality, since one can go from a node to its successor or
+predecessor given only the node, simplifying algorithms that require
+moving forward and backward in a tree.
+@end itemize
+
+Some disadvantages of threaded trees are:
+
+@itemize @bullet
+@item
+Slower insertion and deletion, since threads need to be maintained. In
+somes cases, this can be alleviated by constructing the tree as an
+unthreaded tree, then threading it with a special libavl function.
+
+@item
+In theory, threaded trees need two extra bits per node to indicate
+whether each child pointer points to an ordinary node or the node's
+successor/predecessor node. In libavl, however, these bits are stored
+in a byte that is used for structure alignment padding in unthreaded
+binary trees, so no extra storage is used.
+@end itemize
+
+A @dfn{right-threaded binary tree} is similar to a threaded binary tree,
+but threads are only maintained on the right side of each node. This
+allows for traversal to the right (toward larger values) but not to the
+left (toward smaller values). Right-threaded trees are convenient when
+the properties of a threaded tree are desirable, but traversal in
+reverse sort order is not necessary. Not threading the left links saves
+time in insertions and deletions.
+
+Left-threaded binary trees also exist, but they are not implemented by
+libavl. The same effect can be obtained by sorting the tree in the
+opposite order.
+
+@node Types, Functions, Introduction to threaded trees, Top
+@chapter Types
+
+The following types are defined and used by libavl:
+
+@deftp {Data Type} avl_tree
+@deftpx {Data Type} avlt_tree
+@deftpx {Data Type} avltr_tree
+@deftpx {Data Type} rb_tree
+These are the data types used to represent a tree. Although they are
+defined in the libavl header files, it should never be necessary to
+access them directly. Instead, all accesses should take place through
+libavl functions.
+@end deftp
+
+@deftp {Data Type} avl_node
+@deftpx {Data Type} avlt_node
+@deftpx {Data Type} avltr_node
+@deftpx {Data Type} rb_node
+These are the data types used to represent individual nodes in a tree.
+Similar cautions apply as with @code{avl_tree} structures.
+@end deftp
+
+@deftp {Data Type} avl_traverser
+@deftpx {Data Type} avlt_traverser
+@deftpx {Data Type} avltr_traverser
+@deftpx {Data Type} rb_traverser
+These are the data types used by the @code{avl_traverse} family of
+functions to iterate across the tree. Again, these are opaque
+structures.
+@end deftp
+
+@deftp {Data Type} avl_comparison_func
+Every tree must have an ordering defined by a function of this type. It
+must have the following signature:
+
+@smallexample
+int @var{compare} (const void *@var{a}, const void *@var{b}, void *@var{param})
+@end smallexample
+
+The return value is expected to be like that returned by @code{strcmp}
+in the standard C library: negative if @var{a} < @var{b}, zero if
+@var{a} = @var{b}, positive if @var{a} > @var{b}. @var{param} is an
+arbitrary value defined by the user when the tree was created.
+@end deftp
+
+@deftp {Data Type} avl_node_func
+This is a class of function called to perform an operation on a data
+item. Functions of this type have the following signature:
+
+@smallexample
+void @var{operate} (void *@var{data}, void *@var{param})
+@end smallexample
+
+@var{data} is the data item and @var{param} is an arbitrary user-defined
+value set when the tree was created.
+@end deftp
+
+@deftp {Data Type} avl_copy_func
+
+This is a class of function called to make a new copy of a node's data.
+Functions of this type have the following signature:
+
+@smallexample
+void *@var{copy} (void *@var{data}, void *@var{param})
+@end smallexample
+
+The function should return a new copy of @var{data}. @var{param} is an
+arbitrary user-defined value set when the tree was created.
+@end deftp
+
+@defmac AVL_MAX_HEIGHT
+This macro defines the maximum height of an AVL tree that can be handled
+by functions that maintain a stack of nodes descended. The default
+value is 32, which allows for AVL trees with a maximum number of nodes
+between 5,704,880 and 4,294,967,295, depending on order of insertion.
+This macro may be defined by the user before including any AVL tree
+header file, in which case libavl will honor that value.
+@end defmac
+
+@defmac RB_MAX_HEIGHT
+This macro defines the maximum height of an AVL tree that can be handled
+by functions that maintain a stack of nodes descended. The default
+value is 32, which allows for red-black trees with a maximum number of
+nodes of at least 65535. This macro may be defined by the user before
+including the red-black tree header file, in which case libavl will
+honor that value.
+@end defmac
+
+@node Functions, Tree Creation, Types, Top
+@chapter Functions
+
+@cindex unthreaded
+@cindex threads
+@cindex right threads
+libavl is four libraries in one:
+
+@itemize @bullet
+@item
+An unthreaded AVL tree library.
+
+@item
+A threaded AVL tree library.
+
+@item
+A right-threaded AVL tree library.
+
+@item
+A red-black tree library.
+@end itemize
+
+Identifiers in these libraries are prefixed by @code{avl_},
+@code{avlt_}, @code{avltr_}, and @code{rb_}, with corresponding header
+files @file{avl.h}, @file{avlt.h}, @file{avltr.h}, and @file{rb.h},
+respectively. The functions that they declare are defined in the
+@file{.c} files with the same names.
+
+Most tree functions are implemented in all three libraries, but
+threading allows more generality of operation. So, the threaded and
+right-threaded libraries offer a few additional functions for finding
+the next or previous node from a given node. In addition, they offer
+functions for converting trees from threaded or right-threaded
+representations to unthreaded, and vice versa.@footnote{In general, you
+should build the sort of tree that you need to use, but occasionally it
+is useful to convert between tree types.}
+
+@node Tree Creation, Insertion, Functions, Top
+@chapter Tree Creation
+
+These functions deal with creation and destruction of AVL trees.
+
+@deftypefun {avl_tree *} avl_create (avl_comparison_func @var{compare}, void *@var{param})
+@deftypefunx {avlt_tree *} avlt_create (avlt_comparison_func @var{compare}, void *@var{param})
+@deftypefunx {avltr_tree *} avltr_create (avltr_comparison_func @var{compare}, void *@var{param})
+@deftypefunx {rb_tree *} rb_create (avl_comparison_func @var{compare}, void *@var{param})
+Create a new, empty tree with comparison function @var{compare}.
+Arbitrary user data @var{param} is saved so that it can be passed to
+user callback functions.
+@end deftypefun
+
+@deftypefun {void} avl_destroy (avl_tree *@var{tree}, avl_node_func @var{free})
+@deftypefunx {void} avlt_destroy (avlt_tree *@var{tree}, avl_node_func @var{free})
+@deftypefunx {void} avltr_destroy (avltr_tree *@var{tree}, avl_node_func @var{free})
+@deftypefunx {void} rb_destroy (rb_tree *@var{tree}, avl_node_func @var{free})
+Destroys @var{tree}, releasing all of its storage. If @var{free} is
+non-null, then it is called for every node in postorder before that node
+is freed.
+@end deftypefun
+
+@deftypefun {void} avl_free (avl_tree *@var{tree})
+@deftypefunx {void} avlt_free (avlt_tree *@var{tree})
+@deftypefunx {void} avltr_free (avltr_tree *@var{tree})
+@deftypefunx {void} rb_free (rb_tree *@var{tree})
+Destroys @var{tree}, releasing all of its storage. The data in each
+node is freed with a call to the standard C library function
+@code{free}.
+@end deftypefun
+
+@deftypefun {avl_tree *} avl_copy (const avl_tree *@var{tree}, avl_copy_func @var{copy})
+@deftypefunx {avlt_tree *} avl_copy (const avlt_tree *@var{tree}, avl_copy_func @var{copy})
+@deftypefunx {avltr_tree *} avl_copy (const avltr_tree *@var{tree}, avl_copy_func @var{copy})
+@deftypefunx {rb_tree *} rb_copy (const rb_tree *@var{tree}, avl_copy_func @var{copy})
+Copies the contents of @var{tree} into a new tree, and returns the new
+tree. If @var{copy} is non-null, then it is called to make a new copy
+of each node's data; otherwise, the node data is copied verbatim into
+the new tree.
+@end deftypefun
+
+@deftypefun int avl_count (const avl_tree *@var{tree})
+@deftypefunx int avlt_count (const avlt_tree *@var{tree})
+@deftypefunx int avltr_count (const avltr_tree *@var{tree})
+@deftypefunx int rb_count (const rb_tree *@var{tree})
+Returns the number of nodes in @var{tree}.
+@end deftypefun
+
+@deftypefun {void *} xmalloc (size_t @var{size})
+This is not a function defined by libavl. Instead, it is a function
+that the user program can define. It must allocate @var{size} bytes
+using @code{malloc} and return it. It can handle out-of-memory errors
+however it chooses, but it may not ever return a null pointer.
+
+If there is an @code{xmalloc} function defined for use by libavl, the
+source files (@file{avl.c}, @file{avlt.c}, @file{avltr.c}, @file{rb.c})
+must be compiled with @code{HAVE_XMALLOC} defined. Otherwise, the
+library will use its internal static @code{xmalloc}, which handles
+out-of-memory errors by printing a message @samp{virtual memory
+exhausted} to stderr and terminating the program with exit code
+@code{EXIT_FAILURE}.
+@end deftypefun
+
+@node Insertion, Searching, Tree Creation, Top
+@chapter Insertion and Deletion
+
+These function insert nodes, delete nodes, and search for nodes in
+trees.
+
+@deftypefun {void **} avl_probe (avl_tree *@var{tree}, void *@var{data})
+@deftypefunx {void **} avlt_probe (avlt_tree *@var{tree}, void *@var{data})
+@deftypefunx {void **} avltr_probe (avltr_tree *@var{tree}, void *@var{data})
+@deftypefunx {void **} rb_probe (rb_tree *@var{tree}, void *@var{data})
+These are the workhorse functions for tree insertion. They search
+@var{tree} for a node with data matching @var{data}. If found, a
+pointer to the matching data is returned. Otherwise, a new node is
+created for @var{data}, and a pointer to that data is returned. In
+either case, the pointer returned can be changed by the user, but the
+key data used by the tree's comparison must not be changed@footnote{It
+can be changed if this would not change the ordering of the nodes in the
+tree; i.e., if this would not cause the data in the node to be less than
+or equal to the previous node's data or greater than or equal to the
+next node's data.}.
+
+It is usually easier to use one of the @code{avl_insert} or
+@code{avl_replace} functions instead of @code{avl_probe} directly.
+
+@strong{Please note:} It's not a particularly good idea to insert a null
+pointer as a data item into a tree, because several libavl functions
+return a null pointer to indicate failure. You can sometimes avoid a
+problem by using functions that return a pointer to a pointer instead of
+a plain pointer. Also be wary of this when casting an arithmetic type
+to a void pointer for insertion---on typical architectures, 0's become
+null pointers when this is done.
+@end deftypefun
+
+@deftypefun {void *} avl_insert (avl_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} avlt_insert (avlt_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} avltr_insert (avltr_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} rb_insert (rb_tree *@var{tree}, void *@var{data})
+If a node with data matching @var{data} exists in @var{tree}, returns
+the matching data item. Otherwise, inserts @var{data} into @var{tree}
+and returns a null pointer.
+@end deftypefun
+
+@deftypefun void avl_force_insert (avl_tree *@var{tree}, void *@var{data})
+@deftypefunx void avlt_force_insert (avlt_tree *@var{tree}, void *@var{data})
+@deftypefunx void avltr_force_insert (avltr_tree *@var{tree}, void *@var{data})
+@deftypefunx void rb_force_insert (rb_tree *@var{tree}, void *@var{data})
+Inserts @var{data} into @var{tree}. If a node with data matching
+@var{data} exists in @var{tree}, aborts the program with an assertion
+violation. This function is implemented as a macro; if it is used, the
+standard C header @code{assert.h} must also be included. If macro
+@code{NDEBUG} is defined when a libavl header is included, these
+functions are short-circuited to a direct call to @code{avl_insert},
+and no check is performed.
+@end deftypefun
+
+@deftypefun {void *} avl_replace (avl_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} avlt_replace (avlt_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} avltr_replace (avltr_tree *@var{tree}, void *@var{data})
+@deftypefunx {void *} rb_replace (rb_tree *@var{tree}, void *@var{data})
+If a node with data matching @var{data}, such that the comparison
+function returns 0, exists in @var{tree}, replaces the node's data with
+@var{data} and returns the node's former contents. Otherwise, inserts
+@var{data} into @var{tree} and returns a null pointer.
+@end deftypefun
+
+@deftypefun {void *} avl_delete (avl_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} avlt_delete (avlt_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} avltr_delete (avltr_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} rb_delete (rb_tree *@var{tree}, const void *@var{data})
+Searches @var{tree} for a node with data matching @var{data}. If found,
+the node is deleted and its data is returned. Otherwise, returns a null
+pointer.
+@end deftypefun
+
+@deftypefun {void *} avl_force_delete (avl_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} avlt_force_delete (avlt_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} avltr_force_delete (avltr_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} rb_force_delete (rb_tree *@var{tree}, const void *@var{data})
+Deletes a node with data matching @var{data} from @var{tree}. If no
+matching node is found, aborts the program with an assertion violation.
+If macro @code{NDEBUG} is declared when a libavl header is included,
+these functions are short-circuited to a direct call to
+@code{avl_delete}, and no check is performed.
+@end deftypefun
+
+@node Searching, Iteration, Insertion, Top
+@chapter Searching
+
+These function search a tree for an item without making an insertion or
+a deletion.
+
+@deftypefun {void *} avl_find (avl_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void **} avlt_find (avlt_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void **} avltr_find (avltr_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} rb_find (rb_tree *@var{tree}, const void *@var{data})
+Searches @var{tree} for a node with data matching @var{data}, If found,
+returns the node's data (for threaded and right-threaded trees, a
+pointer to the node's data). Otherwise, returns a null pointer.
+@end deftypefun
+
+@deftypefun {void *} avl_find_close (avl_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void **} avlt_find_close (avlt_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void **} avltr_find_close (avltr_tree *@var{tree}, const void *@var{data})
+@deftypefunx {void *} rb_find_close (rb_tree *@var{tree}, const void *@var{data})
+Searches @var{tree} for a node with data matching @var{data}. If found,
+returns the node's data (for threaded and right-threaded trees, a
+pointer to the node's data). If no matching item is found, then it
+finds a node whose data is ``close'' to @var{data}; either the node
+closest in value to @var{data}, or the node either before or after the
+node with the closest value. Returns a null pointer if the tree does
+not contain any nodes.
+@end deftypefun
+
+@node Iteration, Conversion, Searching, Top
+@chapter Iteration
+
+These functions allow the caller to iterate across the items in a tree.
+
+@deftypefun void avl_walk (const avl_tree *@var{tree}, avl_node_func @var{operate}, void *@var{param})
+@deftypefunx void avlt_walk (const avlt_tree *@var{tree}, avl_node_func @var{operate}, void *@var{param})
+@deftypefunx void avltr_walk (const avltr_tree *@var{tree}, avl_node_func @var{operate}, void *@var{param})
+@deftypefunx void rb_walk (const rb_tree *@var{tree}, avl_node_func @var{operate}, void *@var{param})
+Walks through all the nodes in @var{tree}, and calls function
+@var{operate} for each node in inorder. @var{param} overrides the value
+passed to @code{avl_create} (and family) for this operation only.
+@var{operate} must not change the key data in the nodes in a way that
+would reorder the data values or cause two values to become equal.
+@end deftypefun
+
+@deftypefun {void *} avl_traverse (const avl_tree *@var{tree}, avl_traverser *@var{trav})
+@deftypefunx {void *} avlt_traverse (const avlt_tree *@var{tree}, avlt_traverser *@var{trav})
+@deftypefunx {void *} avltr_traverse (const avltr_tree *@var{tree}, avltr_traverser *@var{trav})
+@deftypefunx {void *} rb_traverse (const rb_tree *@var{tree}, rb_traverser *@var{trav})
+Returns each of @var{tree}'s nodes' data values in sequence, then a null
+pointer to indicate the last item. @var{trav} must be initialized
+before the first call, either in a declaration like that below, or using
+one of the functions below.
+
+@smallexample
+avl_traverser trav = AVL_TRAVERSER_INIT;
+@end smallexample
+
+Each @code{avl_traverser} (and family) is a separate, independent
+iterator.
+
+For threaded and right-threaded trees, @code{avlt_next} or
+@code{avltr_next}, respectively, are faster and more memory-efficient
+than @code{avlt_traverse} or @code{avltr_traverse}.
+@end deftypefun
+
+@deftypefun {void *} avl_init_traverser (avl_traverser *@var{trav})
+@deftypefunx {void *} avlt_init_traverser (avlt_traverser *@var{trav})
+@deftypefunx {void *} avltr_init_traverser (avltr_traverser *@var{trav})
+@deftypefunx {void *} rb_init_traverser (rb_traverser *@var{trav})
+Initializes the specified tree traverser structure. After this function
+is called, the next call to the corresponding @code{*_traverse} function
+will return the smallest value in the appropriate tree.
+@end deftypefun
+
+@deftypefun {void **} avlt_next (const avlt_tree *@var{tree}, void **@var{data})
+@deftypefunx {void **} avltr_next (const avltr_tree *@var{tree}, void **@var{data})
+@var{data} must be a null pointer or a pointer to a data item in AVL
+tree @var{tree}. Returns a pointer to the next data item after
+@var{data} in @var{tree} in inorder (this is the first item if
+@var{data} is a null pointer), or a null pointer if @var{data} was the
+last item in @var{tree}.
+@end deftypefun
+
+@deftypefun {void **} avltr_prev (const avltr_tree *@var{tree}, void **@var{data})
+@var{data} must be a null pointer or a pointer to a data item in AVL
+tree @var{tree}. Returns a pointer to the previous data item before
+@var{data} in @var{tree} in inorder (this is the last, or greatest
+valued, item if @var{data} is a null pointer), or a null pointer if
+@var{data} was the first item in @var{tree}.
+@end deftypefun
+
+@node Conversion, Author, Iteration, Top
+@chapter Conversion
+
+@deftypefun {avlt_tree *} avlt_thread (avl_tree *@var{tree})
+@deftypefunx {avltr_tree *} avltr_thread (avl_tree *@var{tree})
+Adds symmetric threads or right threads, respectively, to unthreaded AVL
+tree @var{tree} and returns a pointer to @var{tree} cast to the
+appropriate type. After one of these functions is called, threaded or
+right-threaded functions, as appropriate, must be used with @var{tree};
+unthreaded functions may not be used.
+@end deftypefun
+
+@deftypefun {avl_tree *} avlt_unthread (avlt_tree *@var{tree})
+@deftypefunx {avl_tree *} avltr_unthread (avltr_tree *@var{tree})
+Cuts all threads in threaded or right-threaded, respectively, AVL tree
+@var{tree} and returns a pointer to @var{tree} cast to @code{avl_tree
+*}. After one of these functions is called, unthreaded functions must
+be used with @var{tree}; threaded or right-threaded functions may not be
+used.
+@end deftypefun
+
+@node Author, Index, Conversion, Top
+@chapter Author
+
+@cindex Pfaff, Benjamin Levy
+@cindex author
+@cindex Knuth, Donald Ervin
+@cindex @cite{Art of Computer Programming}
+libavl was written by Ben Pfaff @email{blp@@gnu.org}.
+
+libavl's generic tree algorithms and AVL algorithms are based on those
+found in Donald Knuth's venerable @cite{Art of Computer Programming}
+series from Addison-Wesley, primarily Volumes 1 and 3. libavl's
+red-black tree algorithms are based on those found in Cormen et al.,
+@cite{Introduction to Algorithms}, 2nd ed., from MIT Press.
+
+@node Index, , Author, Top
+@unnumbered Index
+
+@printindex cp
+
+@contents
+@bye
diff --git a/avl-1.4.0/avl.text b/avl-1.4.0/avl.text
new file mode 100644
index 0000000..9804050
--- /dev/null
+++ b/avl-1.4.0/avl.text
@@ -0,0 +1,636 @@
+This file documents libavl, a library for the manipulation of balanced
+binary trees.
+
+ Copyright 1998, 1999 Free Software Foundation, Inc.
+
+ Permission is granted to make and distribute verbatim copies of this
+manual provided the copyright notice and this permission notice are
+preserved on all copies.
+
+ Permission is granted to copy and distribute modified versions of
+this manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+ Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be stated in a
+translation approved by the Free Software Foundation.
+
+This document
+describes libavl, a library for manipulation of balanced binary trees.
+
+ This document applies to libavl version 1.4.0.
+
+Introduction to balanced binary trees
+*************************************
+
+ Consider some techniques that can be used to find a particular item
+in a data set. Typical methods include sequential searching, digital
+searching, hash tables, and binary searching.
+
+ Sequential searching is simple, but slow (O(n)). Digital searching
+requires that the entire data set be known in advance, and memory
+efficient implementations are slow.
+
+ Hash tables are fast (O(1)) for static data sets, but they can be
+wasteful of memory. It can be difficult to choose an effective hash
+function. Some hash tables variants also make deletion an expensive
+operation.
+
+ Binary search techniques work almost as quickly (O(log(n)) on an
+ordered table, or on a binary tree. Binary trees also allow easy
+iteration over the data in the tree in sorted order. With hash tables
+it is necessary to sort the data before iterating, and after sorting
+the data is no longer in hash form.
+
+ Binary trees are efficient for insertion, deletion, and searching, if
+data are inserted in random order. But, if data are inserted in order
+using a naive algorithm, binary search degenerates to sequential search.
+
+ In turn, this problem can be solved by "rebalancing" the tree after
+each insertion or deletion. In rebalancing, nodes are rearranged via
+transformations called "rotations" using an algorithm that tends to
+minimize the tree's height.
+
+ There are several schemes for rebalancing binary trees. The two most
+common types of balanced tree are "AVL trees" and "red-black trees".
+libavl implements both types:
+
+ * AVL trees, invented by Russian mathematicians G. M.
+ Adel'son-Velskii and E. M. Landis, ensure that, for each node, the
+ difference in height between its subtrees (the "balance factor")
+ is not greater than 1.
+
+ * Red-black trees, invented by R. Bayer and studied at length by L.
+ J. Guibas and R. Sedgewick, assign each node of a tree a color (red
+ or black), and specify a set of rules governing how red and black
+ nodes may be arranged.
+
+ The table below presents a comparison among unbalanced binary trees,
+AVL trees, and red-black trees. In the table, N is the number of nodes
+in the tree and H is the tree's height before the operation. "lg" is
+the base-2 logarithm function.
+
+Operation
+ Binary Tree AVL Tree Red-Black Tree
+Time per insertion or deletion
+ O(H) O(lg N) O(lg N)
+Time for insertion of K nodes having sequential values
+ O(K^2) O(N lg N) O(N lg N)
+Time for insertion of K nodes having random values
+ O(N lg N) O(N lg N) O(N lg N)
+Maximum number of rotations per insertion
+ 0 1 lg N
+Maximum number of rotations per deletion
+ 0 lg N lg N
+Maximum H as a function of N
+ N 1.44 lg (N + 2) - .328 2 lg (N + 1)
+Minimum N as a function of H
+ H 2^((H + .328) / 1.44) - 2 2^(H / 2) - 1
+
+ There are alternatives to AVL trees that share some of their
+properties. For instance, skip lists, 2-3 trees, and splay trees all
+allow O(log(n)) insertion and deletion. The main disadvantage of these
+methods is that their operations are not as well documented in the
+literature.
+
+Introduction to threaded trees
+******************************
+
+ "Threading" is a clever method that simplifies binary tree traversal.
+
+ Nodes in a unthreaded binary tree that have zero or one subnodes have
+two or one null subnode pointers, respectively. In a threaded binary
+tree, a left child pointer that would otherwise be null is used to point
+to the node's inorder(1) predecessor, and in a null right child pointer
+points to its inorder successor.
+
+ In a threaded tree, it is always possible to find the next node and
+the previous node of a node, given only a pointer to the node in
+question. In an unthreaded tree, it's also necessary to have a list of
+the nodes between the node in question and root of the tree.
+
+ Advantages of a threaded tree compared to an unthreaded one include:
+
+ * Faster traversal and less memory usage during traversal, since no
+ stack need be maintained.
+
+ * Greater generality, since one can go from a node to its successor
+ or predecessor given only the node, simplifying algorithms that
+ require moving forward and backward in a tree.
+
+ Some disadvantages of threaded trees are:
+
+ * Slower insertion and deletion, since threads need to be
+ maintained. In somes cases, this can be alleviated by
+ constructing the tree as an unthreaded tree, then threading it
+ with a special libavl function.
+
+ * In theory, threaded trees need two extra bits per node to indicate
+ whether each child pointer points to an ordinary node or the node's
+ successor/predecessor node. In libavl, however, these bits are
+ stored in a byte that is used for structure alignment padding in
+ unthreaded binary trees, so no extra storage is used.
+
+ A "right-threaded binary tree" is similar to a threaded binary tree,
+but threads are only maintained on the right side of each node. This
+allows for traversal to the right (toward larger values) but not to the
+left (toward smaller values). Right-threaded trees are convenient when
+the properties of a threaded tree are desirable, but traversal in
+reverse sort order is not necessary. Not threading the left links saves
+time in insertions and deletions.
+
+ Left-threaded binary trees also exist, but they are not implemented
+by libavl. The same effect can be obtained by sorting the tree in the
+opposite order.
+
+ ---------- Footnotes ----------
+
+ (1) In tree traversal, "inorder" refers to visiting the nodes in
+their sorted order from smallest to largest.
+
+Types
+*****
+
+ The following types are defined and used by libavl:
+
+ - Data Type: avl_tree
+ - Data Type: avlt_tree
+ - Data Type: avltr_tree
+ - Data Type: rb_tree
+ These are the data types used to represent a tree. Although they
+ are defined in the libavl header files, it should never be
+ necessary to access them directly. Instead, all accesses should
+ take place through libavl functions.
+
+ - Data Type: avl_node
+ - Data Type: avlt_node
+ - Data Type: avltr_node
+ - Data Type: rb_node
+ These are the data types used to represent individual nodes in a
+ tree. Similar cautions apply as with `avl_tree' structures.
+
+ - Data Type: avl_traverser
+ - Data Type: avlt_traverser
+ - Data Type: avltr_traverser
+ - Data Type: rb_traverser
+ These are the data types used by the `avl_traverse' family of
+ functions to iterate across the tree. Again, these are opaque
+ structures.
+
+ - Data Type: avl_comparison_func
+ Every tree must have an ordering defined by a function of this
+ type. It must have the following signature:
+
+ int COMPARE (const void *A, const void *B, void *PARAM)
+
+ The return value is expected to be like that returned by `strcmp'
+ in the standard C library: negative if A < B, zero if A = B,
+ positive if A > B. PARAM is an arbitrary value defined by the
+ user when the tree was created.
+
+ - Data Type: avl_node_func
+ This is a class of function called to perform an operation on a
+ data item. Functions of this type have the following signature:
+
+ void OPERATE (void *DATA, void *PARAM)
+
+ DATA is the data item and PARAM is an arbitrary user-defined value
+ set when the tree was created.
+
+ - Data Type: avl_copy_func
+ This is a class of function called to make a new copy of a node's
+ data. Functions of this type have the following signature:
+
+ void *COPY (void *DATA, void *PARAM)
+
+ The function should return a new copy of DATA. PARAM is an
+ arbitrary user-defined value set when the tree was created.
+
+ - Macro: AVL_MAX_HEIGHT
+ This macro defines the maximum height of an AVL tree that can be
+ handled by functions that maintain a stack of nodes descended.
+ The default value is 32, which allows for AVL trees with a maximum
+ number of nodes between 5,704,880 and 4,294,967,295, depending on
+ order of insertion. This macro may be defined by the user before
+ including any AVL tree header file, in which case libavl will
+ honor that value.
+
+ - Macro: RB_MAX_HEIGHT
+ This macro defines the maximum height of an AVL tree that can be
+ handled by functions that maintain a stack of nodes descended.
+ The default value is 32, which allows for red-black trees with a
+ maximum number of nodes of at least 65535. This macro may be
+ defined by the user before including the red-black tree header
+ file, in which case libavl will honor that value.
+
+Functions
+*********
+
+ libavl is four libraries in one:
+
+ * An unthreaded AVL tree library.
+
+ * A threaded AVL tree library.
+
+ * A right-threaded AVL tree library.
+
+ * A red-black tree library.
+
+ Identifiers in these libraries are prefixed by `avl_', `avlt_',
+`avltr_', and `rb_', with corresponding header files `avl.h', `avlt.h',
+`avltr.h', and `rb.h', respectively. The functions that they declare
+are defined in the `.c' files with the same names.
+
+ Most tree functions are implemented in all three libraries, but
+threading allows more generality of operation. So, the threaded and
+right-threaded libraries offer a few additional functions for finding
+the next or previous node from a given node. In addition, they offer
+functions for converting trees from threaded or right-threaded
+representations to unthreaded, and vice versa.(1)
+
+ ---------- Footnotes ----------
+
+ (1) In general, you should build the sort of tree that you need to
+use, but occasionally it is useful to convert between tree types.
+
+Tree Creation
+*************
+
+ These functions deal with creation and destruction of AVL trees.
+
+ - Function: avl_tree * avl_create (avl_comparison_func COMPARE, void
+ *PARAM)
+ - Function: avlt_tree * avlt_create (avlt_comparison_func COMPARE,
+ void *PARAM)
+ - Function: avltr_tree * avltr_create (avltr_comparison_func COMPARE,
+ void *PARAM)
+ - Function: rb_tree * rb_create (avl_comparison_func COMPARE, void
+ *PARAM)
+ Create a new, empty tree with comparison function COMPARE.
+ Arbitrary user data PARAM is saved so that it can be passed to
+ user callback functions.
+
+ - Function: void avl_destroy (avl_tree *TREE, avl_node_func FREE)
+ - Function: void avlt_destroy (avlt_tree *TREE, avl_node_func FREE)
+ - Function: void avltr_destroy (avltr_tree *TREE, avl_node_func FREE)
+ - Function: void rb_destroy (rb_tree *TREE, avl_node_func FREE)
+ Destroys TREE, releasing all of its storage. If FREE is non-null,
+ then it is called for every node in postorder before that node is
+ freed.
+
+ - Function: void avl_free (avl_tree *TREE)
+ - Function: void avlt_free (avlt_tree *TREE)
+ - Function: void avltr_free (avltr_tree *TREE)
+ - Function: void rb_free (rb_tree *TREE)
+ Destroys TREE, releasing all of its storage. The data in each
+ node is freed with a call to the standard C library function
+ `free'.
+
+ - Function: avl_tree * avl_copy (const avl_tree *TREE, avl_copy_func
+ COPY)
+ - Function: avlt_tree * avl_copy (const avlt_tree *TREE, avl_copy_func
+ COPY)
+ - Function: avltr_tree * avl_copy (const avltr_tree *TREE,
+ avl_copy_func COPY)
+ - Function: rb_tree * rb_copy (const rb_tree *TREE, avl_copy_func COPY)
+ Copies the contents of TREE into a new tree, and returns the new
+ tree. If COPY is non-null, then it is called to make a new copy
+ of each node's data; otherwise, the node data is copied verbatim
+ into the new tree.
+
+ - Function: int avl_count (const avl_tree *TREE)
+ - Function: int avlt_count (const avlt_tree *TREE)
+ - Function: int avltr_count (const avltr_tree *TREE)
+ - Function: int rb_count (const rb_tree *TREE)
+ Returns the number of nodes in TREE.
+
+ - Function: void * xmalloc (size_t SIZE)
+ This is not a function defined by libavl. Instead, it is a
+ function that the user program can define. It must allocate SIZE
+ bytes using `malloc' and return it. It can handle out-of-memory
+ errors however it chooses, but it may not ever return a null
+ pointer.
+
+ If there is an `xmalloc' function defined for use by libavl, the
+ source files (`avl.c', `avlt.c', `avltr.c', `rb.c') must be
+ compiled with `HAVE_XMALLOC' defined. Otherwise, the library will
+ use its internal static `xmalloc', which handles out-of-memory
+ errors by printing a message `virtual memory exhausted' to stderr
+ and terminating the program with exit code `EXIT_FAILURE'.
+
+Insertion and Deletion
+**********************
+
+ These function insert nodes, delete nodes, and search for nodes in
+trees.
+
+ - Function: void ** avl_probe (avl_tree *TREE, void *DATA)
+ - Function: void ** avlt_probe (avlt_tree *TREE, void *DATA)
+ - Function: void ** avltr_probe (avltr_tree *TREE, void *DATA)
+ - Function: void ** rb_probe (rb_tree *TREE, void *DATA)
+ These are the workhorse functions for tree insertion. They search
+ TREE for a node with data matching DATA. If found, a pointer to
+ the matching data is returned. Otherwise, a new node is created
+ for DATA, and a pointer to that data is returned. In either case,
+ the pointer returned can be changed by the user, but the key data
+ used by the tree's comparison must not be changed(1).
+
+ It is usually easier to use one of the `avl_insert' or
+ `avl_replace' functions instead of `avl_probe' directly.
+
+ *Please note:* It's not a particularly good idea to insert a null
+ pointer as a data item into a tree, because several libavl
+ functions return a null pointer to indicate failure. You can
+ sometimes avoid a problem by using functions that return a pointer
+ to a pointer instead of a plain pointer. Also be wary of this
+ when casting an arithmetic type to a void pointer for
+ insertion--on typical architectures, 0's become null pointers when
+ this is done.
+
+ - Function: void * avl_insert (avl_tree *TREE, void *DATA)
+ - Function: void * avlt_insert (avlt_tree *TREE, void *DATA)
+ - Function: void * avltr_insert (avltr_tree *TREE, void *DATA)
+ - Function: void * rb_insert (rb_tree *TREE, void *DATA)
+ If a node with data matching DATA exists in TREE, returns the
+ matching data item. Otherwise, inserts DATA into TREE and returns
+ a null pointer.
+
+ - Function: void avl_force_insert (avl_tree *TREE, void *DATA)
+ - Function: void avlt_force_insert (avlt_tree *TREE, void *DATA)
+ - Function: void avltr_force_insert (avltr_tree *TREE, void *DATA)
+ - Function: void rb_force_insert (rb_tree *TREE, void *DATA)
+ Inserts DATA into TREE. If a node with data matching DATA exists
+ in TREE, aborts the program with an assertion violation. This
+ function is implemented as a macro; if it is used, the standard C
+ header `assert.h' must also be included. If macro `NDEBUG' is
+ defined when a libavl header is included, these functions are
+ short-circuited to a direct call to `avl_insert', and no check is
+ performed.
+
+ - Function: void * avl_replace (avl_tree *TREE, void *DATA)
+ - Function: void * avlt_replace (avlt_tree *TREE, void *DATA)
+ - Function: void * avltr_replace (avltr_tree *TREE, void *DATA)
+ - Function: void * rb_replace (rb_tree *TREE, void *DATA)
+ If a node with data matching DATA, such that the comparison
+ function returns 0, exists in TREE, replaces the node's data with
+ DATA and returns the node's former contents. Otherwise, inserts
+ DATA into TREE and returns a null pointer.
+
+ - Function: void * avl_delete (avl_tree *TREE, const void *DATA)
+ - Function: void * avlt_delete (avlt_tree *TREE, const void *DATA)
+ - Function: void * avltr_delete (avltr_tree *TREE, const void *DATA)
+ - Function: void * rb_delete (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA. If found, the
+ node is deleted and its data is returned. Otherwise, returns a
+ null pointer.
+
+ - Function: void * avl_force_delete (avl_tree *TREE, const void *DATA)
+ - Function: void * avlt_force_delete (avlt_tree *TREE, const void
+ *DATA)
+ - Function: void * avltr_force_delete (avltr_tree *TREE, const void
+ *DATA)
+ - Function: void * rb_force_delete (rb_tree *TREE, const void *DATA)
+ Deletes a node with data matching DATA from TREE. If no matching
+ node is found, aborts the program with an assertion violation. If
+ macro `NDEBUG' is declared when a libavl header is included, these
+ functions are short-circuited to a direct call to `avl_delete',
+ and no check is performed.
+
+ ---------- Footnotes ----------
+
+ (1) It can be changed if this would not change the ordering of the
+nodes in the tree; i.e., if this would not cause the data in the node
+to be less than or equal to the previous node's data or greater than or
+equal to the next node's data.
+
+Searching
+*********
+
+ These function search a tree for an item without making an insertion
+or a deletion.
+
+ - Function: void * avl_find (avl_tree *TREE, const void *DATA)
+ - Function: void ** avlt_find (avlt_tree *TREE, const void *DATA)
+ - Function: void ** avltr_find (avltr_tree *TREE, const void *DATA)
+ - Function: void * rb_find (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA, If found,
+ returns the node's data (for threaded and right-threaded trees, a
+ pointer to the node's data). Otherwise, returns a null pointer.
+
+ - Function: void * avl_find_close (avl_tree *TREE, const void *DATA)
+ - Function: void ** avlt_find_close (avlt_tree *TREE, const void *DATA)
+ - Function: void ** avltr_find_close (avltr_tree *TREE, const void
+ *DATA)
+ - Function: void * rb_find_close (rb_tree *TREE, const void *DATA)
+ Searches TREE for a node with data matching DATA. If found,
+ returns the node's data (for threaded and right-threaded trees, a
+ pointer to the node's data). If no matching item is found, then it
+ finds a node whose data is "close" to DATA; either the node
+ closest in value to DATA, or the node either before or after the
+ node with the closest value. Returns a null pointer if the tree
+ does not contain any nodes.
+
+Iteration
+*********
+
+ These functions allow the caller to iterate across the items in a
+tree.
+
+ - Function: void avl_walk (const avl_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void avlt_walk (const avlt_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void avltr_walk (const avltr_tree *TREE, avl_node_func
+ OPERATE, void *PARAM)
+ - Function: void rb_walk (const rb_tree *TREE, avl_node_func OPERATE,
+ void *PARAM)
+ Walks through all the nodes in TREE, and calls function OPERATE
+ for each node in inorder. PARAM overrides the value passed to
+ `avl_create' (and family) for this operation only. OPERATE must
+ not change the key data in the nodes in a way that would reorder
+ the data values or cause two values to become equal.
+
+ - Function: void * avl_traverse (const avl_tree *TREE, avl_traverser
+ *TRAV)
+ - Function: void * avlt_traverse (const avlt_tree *TREE,
+ avlt_traverser *TRAV)
+ - Function: void * avltr_traverse (const avltr_tree *TREE,
+ avltr_traverser *TRAV)
+ - Function: void * rb_traverse (const rb_tree *TREE, rb_traverser
+ *TRAV)
+ Returns each of TREE's nodes' data values in sequence, then a null
+ pointer to indicate the last item. TRAV must be initialized
+ before the first call, either in a declaration like that below, or
+ using one of the functions below.
+
+ avl_traverser trav = AVL_TRAVERSER_INIT;
+
+ Each `avl_traverser' (and family) is a separate, independent
+ iterator.
+
+ For threaded and right-threaded trees, `avlt_next' or
+ `avltr_next', respectively, are faster and more memory-efficient
+ than `avlt_traverse' or `avltr_traverse'.
+
+ - Function: void * avl_init_traverser (avl_traverser *TRAV)
+ - Function: void * avlt_init_traverser (avlt_traverser *TRAV)
+ - Function: void * avltr_init_traverser (avltr_traverser *TRAV)
+ - Function: void * rb_init_traverser (rb_traverser *TRAV)
+ Initializes the specified tree traverser structure. After this
+ function is called, the next call to the corresponding
+ `*_traverse' function will return the smallest value in the
+ appropriate tree.
+
+ - Function: void ** avlt_next (const avlt_tree *TREE, void **DATA)
+ - Function: void ** avltr_next (const avltr_tree *TREE, void **DATA)
+ DATA must be a null pointer or a pointer to a data item in AVL
+ tree TREE. Returns a pointer to the next data item after DATA in
+ TREE in inorder (this is the first item if DATA is a null
+ pointer), or a null pointer if DATA was the last item in TREE.
+
+ - Function: void ** avltr_prev (const avltr_tree *TREE, void **DATA)
+ DATA must be a null pointer or a pointer to a data item in AVL
+ tree TREE. Returns a pointer to the previous data item before
+ DATA in TREE in inorder (this is the last, or greatest valued,
+ item if DATA is a null pointer), or a null pointer if DATA was the
+ first item in TREE.
+
+Conversion
+**********
+
+ - Function: avlt_tree * avlt_thread (avl_tree *TREE)
+ - Function: avltr_tree * avltr_thread (avl_tree *TREE)
+ Adds symmetric threads or right threads, respectively, to
+ unthreaded AVL tree TREE and returns a pointer to TREE cast to the
+ appropriate type. After one of these functions is called,
+ threaded or right-threaded functions, as appropriate, must be used
+ with TREE; unthreaded functions may not be used.
+
+ - Function: avl_tree * avlt_unthread (avlt_tree *TREE)
+ - Function: avl_tree * avltr_unthread (avltr_tree *TREE)
+ Cuts all threads in threaded or right-threaded, respectively, AVL
+ tree TREE and returns a pointer to TREE cast to `avl_tree *'.
+ After one of these functions is called, unthreaded functions must
+ be used with TREE; threaded or right-threaded functions may not be
+ used.
+
+Author
+******
+
+ libavl was written by Ben Pfaff .
+
+ libavl's generic tree algorithms and AVL algorithms are based on
+those found in Donald Knuth's venerable `Art of Computer Programming'
+series from Addison-Wesley, primarily Volumes 1 and 3. libavl's
+red-black tree algorithms are based on those found in Cormen et al.,
+`Introduction to Algorithms', 2nd ed., from MIT Press.
+
+Index
+*****
+
+* Menu:
+
+* `Art of Computer Programming': Author.
+* Adel'son-Velskii, G. M.: Introduction to balanced binary trees.
+* author: Author.
+* AVL tree: Introduction to balanced binary trees.
+* avl_comparison_func: Types.
+* avl_copy: Tree Creation.
+* avl_copy_func: Types.
+* avl_count: Tree Creation.
+* avl_create: Tree Creation.
+* avl_delete: Insertion.
+* avl_destroy: Tree Creation.
+* avl_find: Searching.
+* avl_find_close: Searching.
+* avl_force_delete: Insertion.
+* avl_force_insert: Insertion.
+* avl_free: Tree Creation.
+* avl_init_traverser: Iteration.
+* avl_insert: Insertion.
+* AVL_MAX_HEIGHT: Types.
+* avl_node: Types.
+* avl_node_func: Types.
+* avl_probe: Insertion.
+* avl_replace: Insertion.
+* avl_traverse: Iteration.
+* avl_traverser: Types.
+* avl_tree: Types.
+* avl_walk: Iteration.
+* avlt_count: Tree Creation.
+* avlt_create: Tree Creation.
+* avlt_delete: Insertion.
+* avlt_destroy: Tree Creation.
+* avlt_find: Searching.
+* avlt_find_close: Searching.
+* avlt_force_delete: Insertion.
+* avlt_force_insert: Insertion.
+* avlt_free: Tree Creation.
+* avlt_init_traverser: Iteration.
+* avlt_insert: Insertion.
+* avlt_next: Iteration.
+* avlt_node: Types.
+* avlt_probe: Insertion.
+* avlt_replace: Insertion.
+* avlt_thread: Conversion.
+* avlt_traverse: Iteration.
+* avlt_traverser: Types.
+* avlt_tree: Types.
+* avlt_unthread: Conversion.
+* avlt_walk: Iteration.
+* avltr_count: Tree Creation.
+* avltr_create: Tree Creation.
+* avltr_delete: Insertion.
+* avltr_destroy: Tree Creation.
+* avltr_find: Searching.
+* avltr_find_close: Searching.
+* avltr_force_delete: Insertion.
+* avltr_force_insert: Insertion.
+* avltr_free: Tree Creation.
+* avltr_init_traverser: Iteration.
+* avltr_insert: Insertion.
+* avltr_next: Iteration.
+* avltr_node: Types.
+* avltr_prev: Iteration.
+* avltr_probe: Insertion.
+* avltr_replace: Insertion.
+* avltr_thread: Conversion.
+* avltr_traverse: Iteration.
+* avltr_traverser: Types.
+* avltr_tree: Types.
+* avltr_unthread: Conversion.
+* avltr_walk: Iteration.
+* binary tree: Introduction to balanced binary trees.
+* hash table: Introduction to balanced binary trees.
+* Knuth, Donald Ervin: Author.
+* Landis, E. M.: Introduction to balanced binary trees.
+* Pfaff, Benjamin Levy: Author.
+* rb_copy: Tree Creation.
+* rb_count: Tree Creation.
+* rb_create: Tree Creation.
+* rb_delete: Insertion.
+* rb_destroy: Tree Creation.
+* rb_find: Searching.
+* rb_find_close: Searching.
+* rb_force_delete: Insertion.
+* rb_force_insert: Insertion.
+* rb_free: Tree Creation.
+* rb_init_traverser: Iteration.
+* rb_insert: Insertion.
+* RB_MAX_HEIGHT: Types.
+* rb_node: Types.
+* rb_probe: Insertion.
+* rb_replace: Insertion.
+* rb_traverse: Iteration.
+* rb_traverser: Types.
+* rb_tree: Types.
+* rb_walk: Iteration.
+* rebalancing: Introduction to balanced binary trees.
+* red-black tree: Introduction to balanced binary trees.
+* right threads: Functions.
+* threads: Functions.
+* unthreaded: Functions.
+* xmalloc: Tree Creation.
+
diff --git a/avl-1.4.0/avlt.c b/avl-1.4.0/avlt.c
new file mode 100644
index 0000000..d050fba
--- /dev/null
+++ b/avl-1.4.0/avlt.c
@@ -0,0 +1,1597 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avlt.c in libavl. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#if SELF_TEST
+#include
+#include
+#endif
+#include
+#include
+#include
+#include
+#include "avlt.h"
+
+/* Tag types. */
+#define PLUS +1
+#define MINUS -1
+
+#if !__GCC__ && !defined (inline)
+#define inline
+#endif
+
+#if __GNUC__ >= 2
+#define unused __attribute__ ((unused))
+#else
+#define unused
+#endif
+
+#ifdef HAVE_XMALLOC
+void *xmalloc (size_t);
+#else /* !HAVE_XMALLOC */
+/* Allocates SIZE bytes of space using malloc(). Aborts if out of
+ memory. */
+static void *
+xmalloc (size_t size)
+{
+ void *vp;
+ if (size == 0)
+ return NULL;
+ vp = malloc (size);
+ assert (vp != NULL);
+ if (vp == NULL)
+ {
+ fprintf (stderr, "virtual memory exhausted\n");
+ exit (EXIT_FAILURE);
+ }
+ return vp;
+}
+#endif /* !HAVE_XMALLOC */
+
+/* Creates an AVL tree in arena OWNER (which can be NULL). The arena
+ is owned by the caller, not by the AVL tree. CMP is a order
+ function for the data to be stored in the tree. PARAM is arbitrary
+ data that becomes an argument to the comparison function. */
+avlt_tree *
+avlt_create (avl_comparison_func cmp, void *param)
+{
+ avlt_tree *tree;
+
+ assert (cmp != NULL);
+ tree = xmalloc (sizeof (avlt_tree));
+
+ tree->root.link[0] = tree->root.link[1] = &tree->root;
+ tree->root.tag[0] = MINUS;
+ tree->root.tag[1] = PLUS;
+ tree->cmp = cmp;
+ tree->count = 0;
+ tree->param = param;
+
+ return tree;
+}
+
+/* Destroy tree TREE. Function FREE_FUNC is called for every node in
+ the tree as it is destroyed.
+
+ No effect if the tree has an arena owner and free_func is NULL.
+ The caller owns the arena and must destroy it itself.
+
+ Do not attempt to reuse the tree after it has been freed. Create a
+ new one. */
+void
+avlt_destroy (avlt_tree *tree, avl_node_func free_func)
+{
+ assert (tree != NULL);
+
+ if (tree->root.link[0] != &tree->root)
+ {
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal). */
+
+ /* T1. */
+ avlt_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ avlt_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ for (;;)
+ {
+ /* T3. */
+ ab[ap] = 0;
+ an[ap++] = p;
+ if (p->tag[0] == MINUS)
+ break;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if (ab[ap] == 0)
+ {
+ ab[ap++] = 1;
+ if (p->tag[1] == MINUS)
+ continue;
+ p = p->link[1];
+ break;
+ }
+
+ if (free_func)
+ free_func (p->data, tree->param);
+ free (p);
+ }
+ }
+ }
+
+ done:
+ free (tree);
+}
+
+/* avlt_destroy() with FREE_FUNC hardcoded as free(). */
+void
+avlt_free (avlt_tree *tree)
+{
+ avlt_destroy (tree, (avl_node_func) free);
+}
+
+/* Return the number of nodes in TREE. */
+int
+avlt_count (const avlt_tree *tree)
+{
+ assert (tree != NULL);
+ return tree->count;
+}
+
+/* Copy the contents of TREE to a new tree in arena OWNER. If COPY is
+ non-NULL, then each data item is passed to function COPY, and the
+ return values are inserted into the new tree; otherwise, the items
+ are copied verbatim from the old tree to the new tree. Returns the
+ new tree. */
+avlt_tree *
+avlt_copy (const avlt_tree *tree, avl_copy_func copy)
+{
+ /* Knuth's Algorithm 2.3.1C (copying a binary tree). Additionally
+ uses Algorithm 2.3.1I (insertion into a threaded binary tree) and
+ Algorithm 2.3.1 exercise 17 (preorder successor in threaded
+ binary tree). */
+
+ avlt_tree *new_tree;
+
+ const avlt_node *p;
+ avlt_node *q;
+
+ assert (tree != NULL);
+ new_tree = avlt_create (tree->cmp, tree->param);
+ new_tree->count = tree->count;
+ p = &tree->root;
+ if (p->link[0] == p)
+ return new_tree;
+ q = &new_tree->root;
+
+ for (;;)
+ {
+ /* C4. This is Algorithm 2.3.1I modified for insertion to the
+ left. Step I2 is not necessary. */
+ if (p->tag[0] == PLUS)
+ {
+ avlt_node *r = xmalloc (sizeof (avlt_node));
+
+ r->link[0] = q->link[0];
+ r->tag[0] = q->tag[0];
+ q->link[0] = r;
+ q->tag[0] = PLUS;
+ r->link[1] = q;
+ r->tag[1] = MINUS;
+ }
+
+ /* C5: Find preorder successors of P and Q. This is Algorithm
+ 2.3.1 exercise 17 but applies its actions to Q as well as
+ P. */
+ if (p->tag[0] == PLUS)
+ {
+ p = p->link[0];
+ q = q->link[0];
+ }
+ else
+ {
+ while (p->tag[1] == MINUS)
+ {
+ p = p->link[1];
+ q = q->link[1];
+ }
+ p = p->link[1];
+ q = q->link[1];
+ }
+
+ /* C6. */
+ if (p == &tree->root)
+ {
+ assert (q == &new_tree->root);
+ return new_tree;
+ }
+
+ /* C2. This is Algorithm 2.3.1I. Step I2 is not necessary. */
+ if (p->tag[1] == PLUS)
+ {
+ avlt_node *r = xmalloc (sizeof (avlt_node));
+
+ r->link[1] = q->link[1];
+ r->tag[1] = q->tag[1];
+ q->link[1] = r;
+ q->tag[1] = PLUS;
+ r->link[0] = q;
+ r->tag[0] = MINUS;
+ }
+
+ /* C3. */
+ q->bal = p->bal;
+ if (copy == NULL)
+ q->data = p->data;
+ else
+ q->data = copy (p->data, tree->param);
+ }
+}
+
+/* Threads the unthreaded AVL tree TREE in-place, and returns TREE cast to
+ avlt_tree *. */
+avlt_tree *
+avlt_thread (struct avl_tree *_tree)
+{
+ /* Uses Knuth's Algorithm 2.3.1 exercise 30 (thread an unthreaded
+ tree, with Algorithm 2.3.1T (inorder traversal) for computing
+ Q$. */
+
+ avlt_tree *tree = (avlt_tree *) _tree;
+
+ /* Algorithm T's variables. */
+ avlt_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ avlt_node **ap; /* Stack A: stack pointer. */
+ avlt_node *tp; /* P. */
+
+ /* Algorithm L's variables. */
+ avlt_node *p, *q;
+
+ assert (tree != NULL);
+
+ /* T1. */
+ ap = an;
+ tp = tree->root.link[0];
+
+ /* L1. */
+ q = &tree->root;
+ q->link[1] = q;
+
+ for (;;)
+ {
+ /* L2. */
+ {
+ /* T2. */
+ while (tp != NULL)
+ {
+ /* T3. */
+ *ap++ = tp;
+ tp = tp->link[0];
+ }
+
+ /* T4. Modified to visit HEAD after fully traversing the
+ tree. */
+ if (ap == an)
+ tp = &tree->root;
+ else
+ tp = *--ap;
+
+ /* T5: Visit P. */
+ p = tp;
+ }
+
+ /* L3. */
+ if (q->link[1] == NULL)
+ {
+ q->link[1] = p;
+ q->tag[1] = MINUS;
+ }
+ else
+ q->tag[1] = PLUS;
+
+ if (p->link[0] == NULL)
+ {
+ p->link[0] = q;
+ p->tag[0] = MINUS;
+ }
+ else
+ p->tag[0] = PLUS;
+
+ /* L4. */
+ if (p == &tree->root)
+ return tree;
+ q = p;
+
+ /* T5: Next. */
+ tp = tp->link[1];
+ }
+}
+
+/* Unthreads the threaded tree TREE in-place, and returns TREE cast to
+ avl_tree *. */
+struct avl_tree *
+avlt_unthread (avlt_tree *tree)
+{
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal). */
+
+ /* T1. */
+ avlt_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ avlt_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p != &tree->root)
+ for (;;)
+ {
+ /* T2. */
+ for (;;)
+ {
+ /* T3. */
+ ab[ap] = 0;
+ an[ap++] = p;
+ if (p->tag[0] == MINUS)
+ break;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if (ab[ap] == 0)
+ {
+ ab[ap++] = 1;
+ if (p->tag[1] == MINUS)
+ continue;
+ p = p->link[1];
+ break;
+ }
+
+ if (p->tag[0] == MINUS)
+ p->link[0] = NULL;
+ if (p->tag[1] == MINUS)
+ p->link[1] = NULL;
+ }
+ }
+ else
+ tree->root.link[0] = NULL;
+
+ done:
+ tree->root.link[1] = NULL;
+ return (struct avl_tree *) tree;
+}
+
+/* Walk tree TREE in inorder, calling WALK_FUNC at each node. Passes
+ PARAM to WALK_FUNC. */
+void
+avlt_walk (const avlt_tree *tree, avl_node_func walk_func, void *param)
+{
+ const avlt_node *p;
+
+ /* Uses Knuth's algorithm 2.3.1D (threaded inorder successor). */
+ assert (tree && walk_func);
+
+ p = &tree->root;
+ for (;;)
+ {
+ if (p->tag[1] == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->tag[0] == PLUS)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ return;
+
+ walk_func (p->data, param);
+ }
+}
+
+/* Each call to this function for a given TREE and TRAV return the
+ next item in the tree in inorder. Initialize the first element of
+ TRAV (init) to 0 before calling the first time. Returns NULL when
+ out of elements. */
+void *
+avlt_traverse (const avlt_tree *tree, avlt_traverser *trav)
+{
+ const avlt_node *p;
+
+ assert (tree && trav);
+
+ if (trav->init == 0)
+ {
+ p = &tree->root;
+ trav->init = 1;
+ }
+ else
+ p = trav->p;
+
+ /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */
+ if (p->tag[1] == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->tag[0] == PLUS)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ {
+ trav->init = 0;
+ return NULL;
+ }
+ else
+ {
+ trav->p = p;
+ return (void *) p->data;
+ }
+}
+
+/* Given ITEM, a pointer to a data item in TREE (or NULL), returns a
+ pointer to the next item in the tree in comparison order, or NULL
+ if ITEM is the last item. */
+void **
+avlt_next (const avlt_tree *tree, void **item)
+{
+ const avlt_node *p;
+
+ assert (tree != NULL);
+ if (item == NULL)
+ p = &tree->root;
+ else
+ p = (avlt_node *) (((char *) item) - offsetof (avlt_node, data));
+
+ /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */
+ if (p->tag[1] == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->tag[0] == PLUS)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ return NULL;
+
+ return (void **) &p->data;
+}
+
+/* Given ITEM, a pointer to a data item in TREE (or NULL), returns a
+ pointer to the previous item in the tree in comparison order, or
+ NULL if ITEM is the first item. */
+void **
+avlt_prev (const avlt_tree *tree, void **item)
+{
+ const avlt_node *p;
+
+ assert (tree != NULL);
+ if (item == NULL)
+ {
+ /* Find node with greatest value. */
+ p = tree->root.link[0];
+ if (p == &tree->root)
+ return NULL;
+ while (p->tag[1] == PLUS)
+ p = p->link[1];
+ }
+ else
+ {
+ p = (avlt_node *) (((char *) item) - offsetof (avlt_node, data));
+
+ /* Knuth's Algorithm 2.3.1S (threaded inorder successor)
+ modified to find the predecessor node. */
+ if (p->tag[0] == MINUS)
+ p = p->link[0];
+ else
+ {
+ assert (p->tag[0] == PLUS);
+ p = p->link[0];
+ while (p->tag[1] == PLUS)
+ p = p->link[1];
+ }
+ }
+
+ if (p == &tree->root)
+ return NULL;
+
+ return (void **) &p->data;
+}
+
+/* Search TREE for an item matching ITEM. If found, returns a pointer
+ to the address of the item. If none is found, ITEM is inserted
+ into the tree, and a pointer to the address of ITEM is returned.
+ In either case, the pointer returned can be changed by the caller,
+ or the returned data item can be directly edited, but the key data
+ in the item must not be changed. */
+void **
+avlt_probe (avlt_tree *tree, void *item)
+{
+ /* Uses Knuth's Algorithm 6.2.3A (balanced tree search and
+ insertion), modified for a threaded binary tree. Caches results
+ of comparisons. In empirical tests this eliminates about 25% of
+ the comparisons seen under random insertions. */
+
+ /* A1. */
+ avlt_node *t;
+ avlt_node *s, *p, *q, *r;
+
+ assert (tree != NULL);
+ t = &tree->root;
+ s = p = t->link[0];
+
+ if (t->tag[0] == MINUS)
+ {
+ tree->count++;
+ assert (tree->count == 1);
+ t->tag[0] = PLUS;
+ q = t->link[0] = xmalloc (sizeof (avlt_node));
+ q->data = item;
+ q->link[0] = q->link[1] = t;
+ q->tag[0] = q->tag[1] = MINUS;
+ q->bal = 0;
+ return &q->data;
+ }
+
+ for (;;)
+ {
+ /* A2. */
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ /* A3. */
+ if (diff < 0)
+ {
+ p->cache = 0;
+ q = p->link[0];
+ if (p->tag[0] == MINUS)
+ {
+ q = xmalloc (sizeof (avlt_node));
+ q->link[0] = p->link[0];
+ q->tag[0] = p->tag[0];
+ p->link[0] = q;
+ p->tag[0] = PLUS;
+ q->link[1] = p;
+ q->tag[1] = MINUS;
+ break;
+ }
+ }
+ /* A4. */
+ else if (diff > 0)
+ {
+ p->cache = 1;
+ q = p->link[1];
+ if (p->tag[1] == MINUS)
+ {
+ q = xmalloc (sizeof (avlt_node));
+ q->link[1] = p->link[1];
+ q->tag[1] = p->tag[1];
+ p->link[1] = q;
+ p->tag[1] = PLUS;
+ q->link[0] = p;
+ q->tag[0] = MINUS;
+ break;
+ }
+ }
+ else
+ /* A2. */
+ return &p->data;
+
+ /* A3, A4. */
+ if (q->bal != 0)
+ t = p, s = q;
+ p = q;
+ }
+
+ /* A5. */
+ tree->count++;
+ q->data = item;
+ q->bal = 0;
+
+ /* A6. */
+ r = p = s->link[(int) s->cache];
+ while (p != q)
+ {
+ p->bal = p->cache * 2 - 1;
+ p = p->link[(int) p->cache];
+ }
+
+ /* A7. */
+ if (s->cache == 0)
+ {
+ /* a = -1. */
+ if (s->bal == 0)
+ {
+ s->bal = -1;
+ return &q->data;
+ }
+ else if (s->bal == +1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == -1);
+ if (r->bal == -1)
+ {
+ /* A8. */
+ p = r;
+ s->link[0] = r->link[1];
+ s->tag[0] = r->tag[1];
+ r->link[1] = s;
+ r->tag[1] = PLUS;
+ if (s->link[0] == s)
+ {
+ s->link[0] = r;
+ s->tag[0] = MINUS;
+ }
+ r->tag[0] = r->tag[1] = PLUS;
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == +1);
+ p = r->link[1];
+ r->link[1] = p->link[0];
+ p->link[0] = r;
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ if (p->bal == -1)
+ s->bal = 1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == +1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ p->tag[0] = p->tag[1] = PLUS;
+ if (s->link[0] == s)
+ {
+ s->link[0] = p;
+ s->tag[0] = MINUS;
+ }
+ if (r->link[1] == r)
+ {
+ r->link[1] = p;
+ r->tag[1] = MINUS;
+ }
+ }
+ }
+ else
+ {
+ /* a == +1. */
+ if (s->bal == 0)
+ {
+ s->bal = 1;
+ return &q->data;
+ }
+ else if (s->bal == -1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == +1);
+ if (r->bal == +1)
+ {
+ /* A8. */
+ p = r;
+ s->link[1] = r->link[0];
+ s->tag[1] = r->tag[0];
+ r->link[0] = s;
+ r->tag[0] = PLUS;
+ if (s->link[1] == s)
+ {
+ s->link[1] = r;
+ s->tag[1] = MINUS;
+ }
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ r->link[0] = p->link[1];
+ p->link[1] = r;
+ s->link[1] = p->link[0];
+ p->link[0] = s;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = 1;
+ }
+ p->tag[0] = p->tag[1] = PLUS;
+ if (s->link[1] == s)
+ {
+ s->link[1] = p;
+ s->tag[1] = MINUS;
+ }
+ if (r->link[0] == r)
+ {
+ r->link[0] = p;
+ r->tag[0] = MINUS;
+ }
+ p->bal = 0;
+ }
+ }
+
+ /* A10. */
+ if (t != &tree->root && s == t->link[1])
+ t->link[1] = p;
+ else
+ t->link[0] = p;
+
+ return &q->data;
+}
+
+/* Search TREE for an item matching ITEM, and return a pointer to it
+ if found. */
+void **
+avlt_find (const avlt_tree *tree, const void *item)
+{
+ const avlt_node *p;
+
+ assert (tree != NULL);
+ if (tree->root.tag[0] == MINUS)
+ /* Tree is empty. */
+ return NULL;
+
+ p = tree->root.link[0];
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+ int t;
+
+ /* A3. */
+ if (diff < 0)
+ t = 0;
+ else if (diff > 0)
+ t = 1;
+ else
+ return (void **) &p->data;
+
+ if (p->tag[t] == PLUS)
+ p = p->link[t];
+ else
+ return NULL;
+ }
+}
+
+/* Search TREE for an item close to the value of ITEM, and return it.
+ This function will return a null pointer only if TREE is empty. */
+void **
+avlt_find_close (const avlt_tree *tree, const void *item)
+{
+ const avlt_node *p;
+
+ assert (tree != NULL);
+ if (tree->root.tag[0] == MINUS)
+ /* Tree is empty. */
+ return NULL;
+
+ p = tree->root.link[0];
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+ int t;
+
+ /* A3. */
+ if (diff < 0)
+ t = 0;
+ else if (diff > 0)
+ t = 1;
+ else
+ return (void **) &p->data;
+
+ if (p->tag[t] == PLUS)
+ p = p->link[t];
+ else
+ return (void **) &p->data;
+ }
+}
+
+/* Searches AVL tree TREE for an item matching ITEM. If found, the
+ item is removed from the tree and the actual item found is returned
+ to the caller. If no item matching ITEM exists in the tree,
+ returns NULL. */
+void *
+avlt_delete (avlt_tree *tree, const void *item)
+{
+ /* Uses my Algorithm DT, which can be found at
+ http://www.msu.edu/user/pfaffben/avl. Algorithm DT is based on
+ Knuth's Algorithms 6.2.2D (Tree deletion), 6.2.3A (Balanced tree
+ search and insertion), 2.3.1I (Insertion into a threaded binary
+ trees), and the notes on pages 465-466 of Vol. 3. */
+
+ /* D1. */
+ avlt_node *pa[AVL_MAX_HEIGHT]; /* Stack P: Nodes. */
+ unsigned char a[AVL_MAX_HEIGHT]; /* Stack P: Bits. */
+ int k = 1; /* Stack P: Pointer. */
+
+ avlt_node *p;
+
+ assert (tree != NULL);
+
+ if (tree->root.tag[0] == MINUS)
+ /* Empty tree. */
+ return NULL;
+
+ a[0] = 0;
+ pa[0] = &tree->root;
+ p = tree->root.link[0];
+ for (;;)
+ {
+ /* D2. */
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ if (diff == 0)
+ break;
+
+ /* D3, D4. */
+ pa[k] = p;
+ if (diff < 0)
+ {
+ if (p->tag[0] == PLUS)
+ {
+ p = p->link[0];
+ a[k] = 0;
+ }
+ else
+ return NULL;
+ }
+ else if (diff > 0)
+ {
+ if (p->tag[1] == PLUS)
+ {
+ p = p->link[1];
+ a[k] = 1;
+ }
+ else
+ return NULL;
+ }
+
+ k++;
+ }
+ tree->count--;
+
+ item = p->data;
+
+ {
+ avlt_node *t = p;
+ avlt_node **q = &pa[k - 1]->link[(int) a[k - 1]];
+
+ /* D5. */
+ if (t->tag[1] == MINUS)
+ {
+ if (t->tag[0] == PLUS)
+ {
+ avlt_node *const x = t->link[0];
+
+ *q = x;
+ (*q)->bal = 0;
+ if (x->tag[1] == MINUS)
+ {
+ if (a[k - 1] == 1)
+ x->link[1] = t->link[1];
+ else
+ x->link[1] = pa[k - 1];
+ }
+ }
+ else
+ {
+ *q = t->link[a[k - 1]];
+ pa[k - 1]->tag[a[k - 1]] = MINUS;
+ }
+ }
+ else
+ {
+ /* D6. */
+ avlt_node *r = t->link[1];
+ if (r->tag[0] == MINUS)
+ {
+ r->link[0] = t->link[0];
+ r->tag[0] = t->tag[0];
+ r->bal = t->bal;
+ if (r->tag[0] == PLUS)
+ {
+ avlt_node *s = r->link[0];
+ while (s->tag[1] == PLUS)
+ s = s->link[1];
+ assert (s->tag[1] == MINUS);
+ s->link[1] = r;
+ }
+ *q = r;
+ a[k] = 1;
+ pa[k++] = r;
+ }
+ else
+ {
+ /* D7. */
+ avlt_node *s = r->link[0];
+
+ a[k] = 1;
+ pa[k++] = t;
+
+ a[k] = 0;
+ pa[k++] = r;
+
+ /* D8. */
+ while (s->tag[0] != MINUS)
+ {
+ r = s;
+ s = r->link[0];
+ a[k] = 0;
+ pa[k++] = r;
+ }
+
+ /* D9. */
+ t->data = s->data;
+ if (s->tag[1] == MINUS)
+ {
+ r->tag[0] = MINUS;
+ r->link[0] = t;
+ }
+ else
+ {
+ r->link[0] = s->link[1];
+ if (s->link[1]->tag[0] == MINUS)
+ s->link[1]->link[0] = t;
+ }
+ p = s;
+ }
+ }
+ }
+
+ free (p);
+
+ assert (k > 0);
+ /* D10. */
+ while (--k)
+ {
+ avlt_node *const s = pa[k];
+
+ if (a[k] == 0)
+ {
+ avlt_node *const r = s->link[1];
+
+ /* D10. */
+ if (s->bal == -1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = +1;
+ break;
+ }
+
+ assert (s->bal == +1);
+ if (s->tag[1] == MINUS || r->bal == 0)
+ {
+ /* D11. */
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ r->bal = -1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == +1)
+ {
+ /* D12. */
+ if (PLUS == (s->tag[1] = r->tag[0]))
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ r->tag[0] = PLUS;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[a[k - 1]] = r;
+ }
+ else
+ {
+ /* D13. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ if (PLUS == (r->tag[0] = p->tag[1]))
+ r->link[0] = p->link[1];
+ p->link[1] = r;
+ p->tag[1] = PLUS;
+ if (MINUS == (s->tag[1] = p->tag[0]))
+ s->link[1] = p;
+ else
+ s->link[1] = p->link[0];
+ p->link[0] = s;
+ p->tag[0] = PLUS;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = +1;
+ }
+ p->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ pa[k - 1]->tag[(int) a[k - 1]] = PLUS;
+ }
+ }
+ else
+ {
+ avlt_node *const r = s->link[0];
+
+ /* D10. */
+ if (s->bal == +1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = -1;
+ break;
+ }
+
+ assert (s->bal == -1);
+ if (s->tag[0] == MINUS || r->bal == 0)
+ {
+ /* D11. */
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ r->bal = +1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == -1)
+ {
+ /* D12. */
+ if (PLUS == (s->tag[0] = r->tag[1]))
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ r->tag[1] = PLUS;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[a[k - 1]] = r;
+ }
+ else
+ {
+ /* D13. */
+ assert (r->bal == +1);
+ p = r->link[1];
+ if (PLUS == (r->tag[1] = p->tag[0]))
+ r->link[1] = p->link[0];
+ p->link[0] = r;
+ p->tag[0] = PLUS;
+ if (MINUS == (s->tag[0] = p->tag[1]))
+ s->link[0] = p;
+ else
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ p->tag[1] = PLUS;
+ if (p->bal == -1)
+ s->bal = +1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == +1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ pa[k - 1]->tag[(int) a[k - 1]] = PLUS;
+ }
+ }
+ }
+
+ return (void *) item;
+}
+
+/* Inserts ITEM into TREE. Returns NULL if the item was inserted,
+ otherwise a pointer to the duplicate item. */
+void *
+avlt_insert (avlt_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avlt_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+/* If ITEM does not exist in TREE, inserts it and returns NULL. If a
+ matching item does exist, it is replaced by ITEM and the item
+ replaced is returned. The caller is responsible for freeing the
+ item returned. */
+void *
+avlt_replace (avlt_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avlt_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+
+/* Delete ITEM from TREE when you know that ITEM must be in TREE. For
+ debugging purposes. */
+void *
+(avlt_force_delete) (avlt_tree *tree, void *item)
+{
+ void *found = avlt_delete (tree, item);
+ assert (found != NULL);
+ return found;
+}
+
+#if SELF_TEST
+
+/* Size of the tree used for testing. */
+#define TREE_SIZE 1024
+
+/* Used to flag delayed aborting. */
+int done = 0;
+
+/* Count the number of nodes in TREE below and including NODE. */
+int
+count (avlt_tree *tree, avlt_node *node)
+{
+ int n = 1;
+ if (node->tag[0] == PLUS)
+ n += count (tree, node->link[0]);
+ if (node->tag[1] == PLUS)
+ n += count (tree, node->link[1]);
+ return n;
+}
+
+/* Print the structure of node NODE of an avl tree, which is LEVEL
+ levels from the top of the tree. Uses different delimiters to
+ visually distinguish levels. */
+void
+print_structure (avlt_tree *tree, avlt_node *node, int level)
+{
+ char lc[] = "([{<`";
+ char rc[] = ")]}>'";
+
+ assert (node != NULL);
+ if (level >= 10)
+ {
+ printf ("Too deep, giving up.\n");
+ done = 1;
+ return;
+ }
+ if (node == &tree->root)
+ {
+ printf (" root");
+ return;
+ }
+ printf (" %c%d", lc[level % 5], (int) node->data);
+ fflush (stdout);
+
+ {
+ int i;
+
+ for (i = 0; i <= 1; i++)
+ {
+ if (node->tag[i] == PLUS)
+ print_structure (tree, node->link[i], level + 1);
+ else if (node->link[i] != &tree->root)
+ printf (" :%d", (int) node->link[i]->data);
+ else
+ printf (" :r");
+ fflush (stdout);
+ }
+ }
+ printf ("%c", rc[level % 5]);
+ fflush (stdout);
+}
+
+/* Compare two integers A and B and return a strcmp()-type result. */
+int
+compare_ints (const void *a, const void *b, void *param unused)
+{
+ return ((int) a) - ((int) b);
+}
+
+/* Print the value of integer A. */
+void
+print_int (void *a, void *param unused)
+{
+ printf (" %d", (int) a);
+}
+
+/* Linearly print contents of TREE. */
+void
+print_contents (avlt_tree *tree)
+{
+ avlt_walk (tree, print_int, NULL);
+ printf ("\n");
+}
+
+/* Examine NODE in a avl tree. *COUNT is increased by the number of
+ nodes in the tree, including the current one. If the node is the
+ root of the tree, PARENT should be INT_MIN, otherwise it should be
+ the parent node value. DIR is the direction that the current node
+ is linked from the parent: -1 for left child, +1 for right child;
+ it is not used if PARENT is INT_MIN. Returns the height of the
+ tree rooted at NODE. */
+int
+recurse_tree (avlt_tree *tree, avlt_node *node, int *count, int parent,
+ int dir, unsigned char *nodes, unsigned char *threads)
+{
+ if (node != &tree->root)
+ {
+ int d = (int) node->data;
+ int nl = 0;
+ int nr = 0;
+
+ (*count)++;
+
+ assert (d >= 0 && d < TREE_SIZE);
+ if (nodes[d / 8] & (1 << (d % 8)))
+ {
+ printf (" Arrived at node %d by two different paths.\n", d);
+ done = 1;
+ }
+ else
+ nodes[d / 8] |= 1 << (d % 8);
+
+ if (node->tag[0] == PLUS)
+ nl = recurse_tree (tree, node->link[0], count, d, -1, nodes, threads);
+ else if (node->link[0] != &tree->root)
+ {
+ int dl = (int) node->link[0]->data;
+ assert (dl >= 0 && dl < TREE_SIZE);
+ threads[dl / 8] |= 1 << (dl % 8);
+ }
+
+ if (node->tag[1] == PLUS)
+ nr = recurse_tree (tree, node->link[1], count, d, 1, nodes, threads);
+ else if (node->link[1] != &tree->root)
+ {
+ int dr = (int) node->link[1]->data;
+ assert (dr >= 0 && dr < TREE_SIZE);
+ threads[dr / 8] |= 1 << (dr % 8);
+ }
+
+ if (nr - nl != node->bal)
+ {
+ printf (" Node %d has incorrect balance: right height=%d, "
+ "left height=%d, difference=%d, but balance factor=%d.\n",
+ d, nr, nl, nr - nl, node->bal);
+ done = 1;
+ }
+
+ if (node->bal < -1 || node->bal > 1)
+ {
+ printf (" Node %d has invalid balance factor %d.\n",
+ d, node->bal);
+ done = 1;
+ }
+
+ if (parent != INT_MIN)
+ {
+ assert (dir == -1 || dir == +1);
+ if (dir == -1 && d > parent)
+ {
+ printf (" Node %d is smaller than its left child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ else if (dir == +1 && d < parent)
+ {
+ printf (" Node %d is larger than its right child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ }
+ assert (node->bal >= -1 && node->bal <= 1);
+ return 1 + (nl > nr ? nl : nr);
+ }
+ else return 0;
+}
+
+/* Check that everything about TREE is kosher. */
+void
+verify_tree (avlt_tree *tree)
+{
+ {
+ unsigned char nodes[(TREE_SIZE + 7) / 8];
+ unsigned char threads[(TREE_SIZE + 7) / 8];
+
+ int count = 0;
+ int i;
+
+ memset (nodes, 0, (TREE_SIZE + 7) / 8);
+ memset (threads, 0, (TREE_SIZE + 7) / 8);
+
+ recurse_tree (tree, tree->root.link[0], &count, INT_MIN, 0, nodes,
+ threads);
+
+ if (count != tree->count)
+ {
+ printf (" Tree should have %d nodes, but tree count by recursive "
+ "descent is %d.\n", tree->count, count);
+ done = 1;
+ }
+
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ int thread = threads[i / 8] & (1 << (i % 8));
+ int node = nodes[i / 8] & (1 << (i % 8));
+
+ if (thread && !node)
+ {
+ printf (" A thread leads to ``node'' %d, which is "
+ "not in the tree.", i);
+ done = 1;
+ }
+ }
+ }
+
+ /* Check right threads. */
+ {
+ int count = 0;
+ int last = INT_MIN;
+ void **data = NULL;
+
+ while (NULL != (data = avlt_next (tree, data)))
+ {
+ if (((int) *data) < last)
+ {
+ printf (" Misordered right threads.\n");
+ abort ();
+ }
+ else if (((int) *data) == last)
+ {
+ printf (" Loop in right threads detected on %d.\n", last);
+ abort ();
+ }
+ last = (int) *data;
+ count++;
+ }
+ if (count != tree->count)
+ {
+ printf (" Tree should have %d nodes, but tree count by right threads "
+ "is %d.\n", tree->count, count);
+ done = 1;
+ }
+ }
+
+ /* Check left threads. */
+ {
+ int count = 0;
+ int last = INT_MAX;
+ void **data = NULL;
+
+ while (NULL != (data = avlt_prev (tree, data)))
+ {
+ if (((int) *data) > last)
+ {
+ printf (" Misordered left threads.\n");
+ abort ();
+ }
+ else if (((int) *data) == last)
+ {
+ printf (" Loop in left threads detected on %d.\n", last);
+ abort ();
+ }
+ last = (int) *data;
+ count++;
+ }
+ if (count != tree->count)
+ {
+ printf (" Tree should have %d nodes, but tree count by left threads "
+ "is %d.\n", tree->count, count);
+ done = 1;
+ }
+ }
+
+ if (done)
+ abort ();
+}
+
+/* Arrange the N elements of ARRAY in random order. */
+void
+shuffle (int *array, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ int j = i + rand () % (n - i);
+ int t = array[j];
+ array[j] = array[i];
+ array[i] = t;
+ }
+}
+
+/* Compares avl trees rooted at A and B, making sure that they are
+ identical. */
+void
+compare_trees (avlt_node *a, avlt_node *b)
+{
+ int diff = 0;
+
+ assert (a && b);
+
+ /* Separating these conditions makes it easier to pinpoint bad data
+ under a memory debugger like Checker because each test is a
+ separate statement. */
+ diff |= a->data != b->data;
+ diff |= a->bal != b->bal;
+ diff |= ((a->tag[0] == PLUS) ^ (b->tag[0] == PLUS));
+ diff |= ((a->tag[1] == PLUS) ^ (b->tag[1] == PLUS));
+ if (diff)
+ {
+ printf (" Copied nodes differ: %d b=%d a->bal=%d b->bal=%d a:",
+ (int) a->data, (int) b->data, a->bal, b->bal);
+ if (a->link[0])
+ printf ("l");
+ if (a->link[1])
+ printf ("r");
+ printf (" b:");
+ if (b->link[0])
+ printf ("l");
+ if (b->link[1])
+ printf ("r");
+ printf ("\n");
+ abort ();
+ }
+ if (a->tag[0] == PLUS)
+ compare_trees (a->link[0], b->link[0]);
+ if (a->tag[1] == PLUS)
+ compare_trees (a->link[1], b->link[1]);
+}
+
+/* Simple stress test procedure for the AVL tree routines. Does the
+ following:
+
+ * Generate a random number seed. By default this is generated from
+ the current time. You can also pass a seed value on the command
+ line if you want to test the same case. The seed value is
+ displayed.
+
+ * Create a tree and insert the integers from 0 up to TREE_SIZE - 1
+ into it, in random order. Verify the tree structure after each
+ insertion.
+
+ * Remove each integer from the tree, in a different random order.
+ After each deletion, verify the tree structure; also, make a copy
+ of the tree into a new tree, verify the copy and compare it to the
+ original, then destroy the copy.
+
+ * Destroy the tree, increment the random seed value, and start over.
+
+ If you make any modifications to the avl tree routines, then you
+ might want to insert some calls to print_structure() at strategic
+ places in order to be able to see what's really going on. Also,
+ memory debuggers like Checker or Purify are very handy. */
+#define N_ITERATIONS 16
+int
+main (int argc, char **argv)
+{
+ int array[TREE_SIZE];
+ int seed;
+ int iteration;
+
+ if (argc == 2)
+ seed = atoi (argv[1]);
+ else
+ seed = time (0) * 257 % 32768;
+
+ fputs ("Testing avlt...\n", stdout);
+
+ for (iteration = 1; iteration <= N_ITERATIONS; iteration++)
+ {
+ avlt_tree *tree;
+ int i;
+
+ printf ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed);
+ fflush (stdout);
+
+ srand (seed++);
+
+ for (i = 0; i < TREE_SIZE; i++)
+ array[i] = i;
+ shuffle (array, TREE_SIZE);
+
+ tree = avlt_create (compare_ints, NULL);
+ for (i = 0; i < TREE_SIZE; i++)
+ avlt_force_insert (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ shuffle (array, TREE_SIZE);
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ avlt_tree *copy;
+
+ avlt_delete (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ copy = avlt_copy (tree, NULL);
+ verify_tree (copy);
+ if (tree->root.link[0] != &tree->root)
+ compare_trees (tree->root.link[0], copy->root.link[0]);
+ else if (copy->root.link[1] != ©->root)
+ printf (" Empty tree results in nonempty copy.\n"), abort ();
+ avlt_destroy (copy, NULL);
+
+ if (i % 128 == 0)
+ {
+ putchar ('.');
+ fflush (stdout);
+ }
+ }
+ fputs (" good.\n", stdout);
+
+ avlt_destroy (tree, NULL);
+ }
+
+ return 0;
+}
+#endif /* SELF_TEST */
+
+/*
+ Local variables:
+ compile-command: "gcc -DSELF_TEST=1 -W -Wall -I. -o ./avlt-test avlt.c"
+ End:
+*/
+
diff --git a/avl-1.4.0/avlt.h b/avl-1.4.0/avlt.h
new file mode 100644
index 0000000..94272b4
--- /dev/null
+++ b/avl-1.4.0/avlt.h
@@ -0,0 +1,142 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avlt.h in libavl. */
+
+#if !avlt_h
+#define avlt_h 1
+
+/* The default maximum height of 32 allows for AVL trees having
+ between 5,704,880 and 4,294,967,295 nodes, depending on order of
+ insertion. You may change this compile-time constant as you
+ wish. */
+#ifndef AVL_MAX_HEIGHT
+#define AVL_MAX_HEIGHT 32
+#endif
+
+/* Structure for a node in a threaded AVL tree. */
+typedef struct avlt_node
+ {
+ void *data; /* Pointer to data. */
+ struct avlt_node *link[2]; /* Subtrees or threads. */
+ signed char bal; /* Balance factor. */
+ char cache; /* Used during insertion. */
+ signed char tag[2]; /* Left and right thread tags. */
+ }
+avlt_node;
+
+/* Used for traversing a threaded AVL tree. */
+typedef struct avlt_traverser
+ {
+ int init; /* Initialized? */
+ const avlt_node *p; /* Last node returned. */
+ }
+avlt_traverser;
+
+/* Initializer for avlt_traverser. */
+#define AVLT_TRAVERSER_INIT {0}
+
+/* Function types. */
+#if !AVL_FUNC_TYPES
+#define AVL_FUNC_TYPES 1
+typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
+typedef void (*avl_node_func) (void *data, void *param);
+typedef void *(*avl_copy_func) (void *data, void *param);
+#endif
+
+/* Structure which holds information about a threaded AVL tree. */
+typedef struct avlt_tree
+ {
+ avlt_node root; /* Tree root node. */
+ avl_comparison_func cmp; /* Used to compare keys. */
+ int count; /* Number of nodes in the tree. */
+ void *param; /* Arbitary user data. */
+ }
+avlt_tree;
+
+/* General functions. */
+avlt_tree *avlt_create (avl_comparison_func, void *param);
+void avlt_destroy (avlt_tree *, avl_node_func);
+void avlt_free (avlt_tree *);
+int avlt_count (const avlt_tree *);
+avlt_tree *avlt_copy (const avlt_tree *, avl_copy_func);
+struct avl_tree;
+avlt_tree *avlt_thread (struct avl_tree *);
+struct avl_tree *avlt_unthread (avlt_tree *);
+
+/* Walk the tree. */
+void avlt_walk (const avlt_tree *, avl_node_func, void *param);
+void *avlt_traverse (const avlt_tree *, avlt_traverser *);
+#define avlt_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
+void **avlt_next (const avlt_tree *tree, void **item);
+void **avlt_prev (const avlt_tree *tree, void **item);
+
+/* Search for a given item. */
+void **avlt_probe (avlt_tree *, void *);
+void *avlt_delete (avlt_tree *, const void *);
+void **avlt_find (const avlt_tree *, const void *);
+void **avlt_find_close (const avlt_tree *, const void *);
+
+#if __GCC__ >= 2
+extern inline void *
+avlt_insert (avlt_tree *tree, void *item)
+{
+ void **p = avlt_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+extern inline void *
+avlt_replace (avlt_tree *tree, void *item)
+{
+ void **p = avlt_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+#else /* not gcc */
+void *avlt_insert (avlt_tree *tree, void *item);
+void *avlt_replace (avlt_tree *tree, void *item);
+#endif /* not gcc */
+
+/* Easy assertions on insertion & deletion. */
+#ifndef NDEBUG
+#define avlt_force_insert(A, B) \
+ do \
+ { \
+ void *r = avlt_insert (A, B); \
+ assert (r == NULL); \
+ } \
+ while (0)
+void *avlt_force_delete (avlt_tree *, void *);
+#else
+#define avlt_force_insert(A, B) \
+ avlt_insert (A, B)
+#define avlt_force_delete(A, B) \
+ avlt_delete (A, B)
+#endif
+
+#endif /* avlt_h */
diff --git a/avl-1.4.0/avltr.c b/avl-1.4.0/avltr.c
new file mode 100644
index 0000000..2831bee
--- /dev/null
+++ b/avl-1.4.0/avltr.c
@@ -0,0 +1,1538 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avltr.c in libavl. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#if SELF_TEST
+#include
+#include
+#endif
+#include
+#include
+#include
+#include
+#include "avltr.h"
+
+/* Tag types. */
+#define PLUS +1
+#define MINUS -1
+
+#if !__GCC__ && !defined (inline)
+#define inline
+#endif
+
+void
+print_structure (avltr_tree *tree, avltr_node *node, int level);
+
+#if __GNUC__ >= 2
+#define unused __attribute__ ((unused))
+#else
+#define unused
+#endif
+
+#ifdef HAVE_XMALLOC
+void *xmalloc (size_t);
+#else /* !HAVE_XMALLOC */
+/* Allocates SIZE bytes of space using malloc(). Aborts if out of
+ memory. */
+static void *
+xmalloc (size_t size)
+{
+ void *vp;
+ if (size == 0)
+ return NULL;
+ vp = malloc (size);
+ assert (vp != NULL);
+ if (vp == NULL)
+ {
+ fprintf (stderr, "virtual memory exhausted\n");
+ exit (EXIT_FAILURE);
+ }
+ return vp;
+}
+#endif /* !HAVE_XMALLOC */
+
+/* Creates an AVL tree in arena OWNER (which can be NULL). The arena
+ is owned by the caller, not by the AVL tree. CMP is a order
+ function for the data to be stored in the tree. PARAM is arbitrary
+ data that becomes an argument to the comparison function. */
+avltr_tree *
+avltr_create (avl_comparison_func cmp, void *param)
+{
+ avltr_tree *tree;
+
+ assert (cmp != NULL);
+ tree = xmalloc (sizeof (avltr_tree));
+
+ tree->root.link[0] = NULL;
+ tree->root.link[1] = &tree->root;
+ tree->root.rtag = PLUS;
+ tree->cmp = cmp;
+ tree->count = 0;
+ tree->param = param;
+
+ return tree;
+}
+
+/* Destroy tree TREE. Function FREE_FUNC is called for every node in
+ the tree as it is destroyed.
+
+ No effect if the tree has an arena owner and free_func is NULL.
+ The caller owns the arena and must destroy it itself.
+
+ Do not attempt to reuse the tree after it has been freed. Create a
+ new one. */
+void
+avltr_destroy (avltr_tree *tree, avl_node_func free_func)
+{
+ assert (tree != NULL);
+
+ if (tree->root.link[0] != &tree->root)
+ {
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal), further modified for right-threaded
+ trees. */
+
+ /* T1. */
+ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ avltr_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ while (p != NULL)
+ {
+ /* T3. */
+ ab[ap] = 0;
+ an[ap++] = p;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if (ab[ap] == 0)
+ {
+ ab[ap++] = 1;
+ if (p->rtag == MINUS)
+ continue;
+ p = p->link[1];
+ break;
+ }
+
+ if (free_func)
+ free_func (p->data, tree->param);
+ free (p);
+ }
+ }
+ }
+
+ done:
+ free (tree);
+}
+
+/* avltr_destroy() with FREE_FUNC hardcoded as free(). */
+void
+avltr_free (avltr_tree *tree)
+{
+ avltr_destroy (tree, (avl_node_func) free);
+}
+
+/* Return the number of nodes in TREE. */
+int
+avltr_count (const avltr_tree *tree)
+{
+ assert (tree != NULL);
+ return tree->count;
+}
+
+/* Copy the contents of TREE to a new tree in arena OWNER. If COPY is
+ non-NULL, then each data item is passed to function COPY, and the
+ return values are inserted into the new tree; otherwise, the items
+ are copied verbatim from the old tree to the new tree. Returns the
+ new tree. */
+avltr_tree *
+avltr_copy (const avltr_tree *tree, avl_copy_func copy)
+{
+ /* Knuth's Algorithm 2.3.1C (copying a binary tree). Additionally
+ uses Algorithm 2.3.1I (insertion into a threaded binary tree) and
+ Algorithm 2.3.1 exercise 17 (preorder successor in threaded
+ binary tree). */
+
+ avltr_tree *new_tree;
+
+ const avltr_node *p;
+ avltr_node *q;
+
+ assert (tree != NULL);
+ new_tree = avltr_create (tree->cmp, tree->param);
+ new_tree->count = tree->count;
+ p = &tree->root;
+ if (p->link[0] == p)
+ return new_tree;
+ q = &new_tree->root;
+
+ for (;;)
+ {
+ /* C4. This is Algorithm 2.3.1 exercise 23 for insertion to the
+ left in a right-threaded binary tree. */
+ if (p->link[0] != NULL)
+ {
+ avltr_node *r = xmalloc (sizeof (avltr_node));
+
+ q->link[0] = r;
+ r->link[0] = NULL;
+ r->link[1] = q;
+ r->rtag = MINUS;
+ }
+
+ /* C5: Find preorder successors of P and Q. This is Algorithm
+ 2.3.1 exercise 17 but applies its actions to Q as well as
+ P. */
+ if (p->link[0] != NULL)
+ {
+ p = p->link[0];
+ q = q->link[0];
+ }
+ else
+ {
+ while (p->rtag == MINUS)
+ {
+ p = p->link[1];
+ q = q->link[1];
+ }
+ p = p->link[1];
+ q = q->link[1];
+ }
+
+ /* C6. */
+ if (p == &tree->root)
+ {
+ assert (q == &new_tree->root);
+ return new_tree;
+ }
+
+ /* C2. This is Algorithm 2.3.1 exercise 23 for insertion to the
+ right in a right-threaded binary tree. */
+ if (p->rtag == PLUS)
+ {
+ avltr_node *r = xmalloc (sizeof (avltr_node));
+
+ r->link[1] = q->link[1];
+ r->rtag = q->rtag;
+ q->link[1] = r;
+ q->rtag = PLUS;
+ r->link[0] = NULL;
+ }
+
+ /* C3. */
+ q->bal = p->bal;
+ if (copy == NULL)
+ q->data = p->data;
+ else
+ q->data = copy (p->data, tree->param);
+ }
+}
+
+/* Threads the unthreaded AVL tree TREE in-place, and returns TREE cast to
+ avltr_tree *. */
+avltr_tree *
+avltr_thread (struct avl_tree *_tree)
+{
+ /* Uses Knuth's Algorithm 2.3.1 exercise 30 (thread an unthreaded
+ tree, with Algorithm 2.3.1T (inorder traversal) for computing
+ Q$. */
+
+ avltr_tree *tree = (avltr_tree *) _tree;
+
+ /* Algorithm T's variables. */
+ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ avltr_node **ap; /* Stack A: stack pointer. */
+ avltr_node *tp; /* P. */
+
+ /* Algorithm L's variables. */
+ avltr_node *p, *q;
+
+ assert (tree != NULL);
+
+ /* T1. */
+ ap = an;
+ tp = tree->root.link[0];
+
+ /* L1. */
+ q = &tree->root;
+ q->link[1] = q;
+
+ for (;;)
+ {
+ /* L2. */
+ {
+ /* T2. */
+ while (tp != NULL)
+ {
+ /* T3. */
+ *ap++ = tp;
+ tp = tp->link[0];
+ }
+
+ /* T4. Modified to visit HEAD after fully traversing the
+ tree. */
+ if (ap == an)
+ tp = &tree->root;
+ else
+ tp = *--ap;
+
+ /* T5: Visit P. */
+ p = tp;
+ }
+
+ /* L3. */
+ if (q->link[1] == NULL)
+ {
+ q->link[1] = p;
+ q->rtag = MINUS;
+ }
+ else
+ q->rtag = PLUS;
+
+ /* L4. */
+ if (p == &tree->root)
+ return tree;
+ q = p;
+
+ /* T5: Next. */
+ tp = tp->link[1];
+ }
+}
+
+/* Unthreads the threaded tree TREE in-place, and returns TREE cast to
+ avl_tree *. */
+struct avl_tree *
+avltr_unthread (avltr_tree *tree)
+{
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal). */
+
+ /* T1. */
+ avltr_node *an[AVL_MAX_HEIGHT]; /* Stack A: nodes. */
+ char ab[AVL_MAX_HEIGHT]; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ avltr_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p != NULL)
+ for (;;)
+ {
+ /* T2. */
+ for (;;)
+ {
+ /* T3. */
+ ab[ap] = 0;
+ an[ap++] = p;
+ if (p->link[0] == NULL)
+ break;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if (ab[ap] == 0)
+ {
+ ab[ap++] = 1;
+ if (p->rtag == MINUS)
+ continue;
+ p = p->link[1];
+ break;
+ }
+
+ if (p->rtag == MINUS)
+ p->link[1] = NULL;
+ }
+ }
+ else
+ tree->root.link[0] = NULL;
+
+ done:
+ tree->root.link[1] = NULL;
+ return (struct avl_tree *) tree;
+}
+
+/* Walk tree TREE in inorder, calling WALK_FUNC at each node. Passes
+ PARAM to WALK_FUNC. */
+void
+avltr_walk (const avltr_tree *tree, avl_node_func walk_func, void *param)
+{
+ const avltr_node *p = &tree->root;
+
+ /* Uses Knuth's algorithm 2.3.1D (threaded inorder successor). */
+ assert (tree && walk_func);
+
+ for (;;)
+ {
+ if (p->rtag == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->link[0] != NULL)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ return;
+
+ walk_func (p->data, param);
+ }
+}
+
+/* Each call to this function for a given TREE and TRAV return the
+ next item in the tree in inorder. Initialize the first element of
+ TRAV (init) to 0 before calling the first time. Returns NULL when
+ out of elements. */
+void *
+avltr_traverse (const avltr_tree *tree, avltr_traverser *trav)
+{
+ const avltr_node *p;
+
+ assert (tree && trav);
+
+ if (trav->init == 0)
+ {
+ p = &tree->root;
+ trav->init = 1;
+ }
+ else
+ p = trav->p;
+
+ /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */
+ if (p->rtag == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->link[0] != NULL)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ {
+ trav->init = 0;
+ return NULL;
+ }
+ else
+ {
+ trav->p = p;
+ return (void *) p->data;
+ }
+}
+
+/* Given ITEM, a pointer to a data item in TREE (or NULL), returns a
+ pointer to the next item in the tree in comparison order, or NULL
+ if ITEM is the last item. */
+void **
+avltr_next (const avltr_tree *tree, void **item)
+{
+ const avltr_node *p;
+
+ assert (tree != NULL);
+ if (item == NULL)
+ p = &tree->root;
+ else
+ p = (avltr_node *) (((char *) item) - offsetof (avltr_node, data));
+
+ /* Knuth's Algorithm 2.3.1S (threaded inorder successor). */
+ if (p->rtag == MINUS)
+ p = p->link[1];
+ else
+ {
+ p = p->link[1];
+ while (p->link[0] != NULL)
+ p = p->link[0];
+ }
+
+ if (p == &tree->root)
+ return NULL;
+
+ return (void **) &p->data;
+}
+
+/* Search TREE for an item matching ITEM. If found, returns a pointer
+ to the address of the item. If none is found, ITEM is inserted
+ into the tree, and a pointer to the address of ITEM is returned.
+ In either case, the pointer returned can be changed by the caller,
+ or the returned data item can be directly edited, but the key data
+ in the item must not be changed. */
+void **
+avltr_probe (avltr_tree *tree, void *item)
+{
+ /* Uses Knuth's Algorithm 6.2.3A (balanced tree search and
+ insertion), modified for a right-threaded binary tree. Caches
+ results of comparisons. In empirical tests this eliminates about
+ 25% of the comparisons seen under random insertions. */
+
+ /* A1. */
+ avltr_node *t;
+ avltr_node *s, *p, *q, *r;
+
+ assert (tree != NULL);
+ t = &tree->root;
+ s = p = t->link[0];
+
+ if (s == NULL)
+ {
+ tree->count++;
+ assert (tree->count == 1);
+ q = t->link[0] = xmalloc (sizeof (avltr_node));
+ q->data = item;
+ q->link[0] = NULL;
+ q->link[1] = t;
+ q->rtag = MINUS;
+ q->bal = 0;
+ return &q->data;
+ }
+
+ for (;;)
+ {
+ /* A2. */
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ /* A3. */
+ if (diff < 0)
+ {
+ p->cache = 0;
+ q = p->link[0];
+ if (q == NULL)
+ {
+ /* Algorithm 2.3.1 exercise 23 for insertion to the left
+ in a right-threaded binary tree. */
+ q = xmalloc (sizeof (avltr_node));
+ p->link[0] = q;
+ q->link[0] = NULL;
+ q->link[1] = p;
+ q->rtag = MINUS;
+ break;
+ }
+ }
+ /* A4. */
+ else if (diff > 0)
+ {
+ p->cache = 1;
+ q = p->link[1];
+ if (p->rtag == MINUS)
+ {
+ /* Algorithm 2.3.1 exercise 23 for insertion to the right
+ in a right-threaded binary tree. */
+ q = xmalloc (sizeof (avltr_node));
+ q->link[1] = p->link[1];
+ q->rtag = p->rtag;
+ p->link[1] = q;
+ p->rtag = PLUS;
+ q->link[0] = NULL;
+ break;
+ }
+ assert (q != NULL);
+ }
+ else
+ /* A2. */
+ return &p->data;
+
+ /* A3, A4. */
+ if (q->bal != 0)
+ t = p, s = q;
+ p = q;
+ }
+
+ /* A5. */
+ tree->count++;
+ q->data = item;
+ q->bal = 0;
+
+ /* A6. */
+ r = p = s->link[(int) s->cache];
+ while (p != q)
+ {
+ p->bal = p->cache * 2 - 1;
+ p = p->link[(int) p->cache];
+ }
+
+ /* A7. */
+ if (s->cache == 0)
+ {
+ /* a = -1. */
+ if (s->bal == 0)
+ {
+ s->bal = -1;
+ return &q->data;
+ }
+ else if (s->bal == +1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == -1);
+ if (r->bal == -1)
+ {
+ /* A8. */
+ p = r;
+ if (r->rtag == MINUS)
+ {
+ s->link[0] = NULL;
+ r->link[1] = s;
+ r->rtag = PLUS;
+ }
+ else
+ {
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ }
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == +1);
+ p = r->link[1];
+ r->link[1] = p->link[0];
+ p->link[0] = r;
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ if (p->bal == -1)
+ s->bal = 1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == +1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ p->rtag = PLUS;
+ if (s->link[0] == s)
+ s->link[0] = NULL;
+ if (r->link[1] == NULL)
+ {
+ r->link[1] = p;
+ r->rtag = MINUS;
+ }
+ }
+ }
+ else
+ {
+ /* a == +1. */
+ if (s->bal == 0)
+ {
+ s->bal = 1;
+ return &q->data;
+ }
+ else if (s->bal == -1)
+ {
+ s->bal = 0;
+ return &q->data;
+ }
+
+ assert (s->bal == +1);
+ if (r->bal == +1)
+ {
+ /* A8. */
+ p = r;
+ if (r->link[0] == NULL)
+ {
+ s->rtag = MINUS;
+ r->link[0] = s;
+ }
+ else
+ {
+ s->link[1] = r->link[0];
+ s->rtag = PLUS;
+ r->link[0] = s;
+ }
+ s->bal = r->bal = 0;
+ }
+ else
+ {
+ /* A9. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ r->link[0] = p->link[1];
+ p->link[1] = r;
+ s->link[1] = p->link[0];
+ p->link[0] = s;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = 1;
+ }
+ p->rtag = PLUS;
+ if (s->link[1] == NULL)
+ {
+ s->link[1] = p;
+ s->rtag = MINUS;
+ }
+ if (r->link[0] == r)
+ r->link[0] = NULL;
+ p->bal = 0;
+ }
+ }
+
+ /* A10. */
+ if (t != &tree->root && s == t->link[1])
+ t->link[1] = p;
+ else
+ t->link[0] = p;
+
+ return &q->data;
+}
+
+/* Search TREE for an item matching ITEM, and return a pointer to it
+ if found. */
+void **
+avltr_find (const avltr_tree *tree, const void *item)
+{
+ const avltr_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p == NULL)
+ return NULL;
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ /* A3. */
+ if (diff < 0)
+ {
+ p = p->link[0];
+ if (p == NULL)
+ return NULL;
+ }
+ else if (diff > 0)
+ {
+ if (p->rtag == MINUS)
+ return NULL;
+ p = p->link[1];
+ }
+ else
+ return (void **) &p->data;
+ }
+}
+
+/* Search TREE for an item close to the value of ITEM, and return it.
+ This function will return a null pointer only if TREE is empty. */
+void **
+avltr_find_close (const avltr_tree *tree, const void *item)
+{
+ const avltr_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p == NULL)
+ return NULL;
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ /* A3. */
+ if (diff < 0)
+ {
+ if (p->link[0])
+ p = p->link[0];
+ else
+ return (void **) &p->data;
+ }
+ else if (diff > 0)
+ {
+ if (p->rtag == MINUS)
+ return (void **) &p->data;
+ p = p->link[1];
+ }
+ else
+ return (void **) &p->data;
+ }
+}
+
+/* Searches AVL tree TREE for an item matching ITEM. If found, the
+ item is removed from the tree and the actual item found is returned
+ to the caller. If no item matching ITEM exists in the tree,
+ returns NULL. */
+void *
+avltr_delete (avltr_tree *tree, const void *item)
+{
+ /* Uses my Algorithm DTR, which can be found at
+ http://www.msu.edu/user/pfaffben/avl. Algorithm DT is based on
+ Knuth's Algorithms 6.2.2D (Tree deletion), 6.2.3A (Balanced tree
+ search and insertion), 2.3.1I (Insertion into a threaded binary
+ trees), and the notes on pages 465-466 of Vol. 3. */
+
+ /* D1. */
+ avltr_node *pa[AVL_MAX_HEIGHT]; /* Stack P: Nodes. */
+ unsigned char a[AVL_MAX_HEIGHT]; /* Stack P: Bits. */
+ int k = 1; /* Stack P: Pointer. */
+
+ avltr_node *p;
+
+ assert (tree != NULL);
+
+ a[0] = 0;
+ pa[0] = &tree->root;
+ p = tree->root.link[0];
+ if (p == NULL)
+ return NULL;
+ for (;;)
+ {
+ /* D2. */
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ if (diff == 0)
+ break;
+
+ /* D3, D4. */
+ pa[k] = p;
+ if (diff < 0)
+ {
+ if (p->link[0] != NULL)
+ {
+ p = p->link[0];
+ a[k] = 0;
+ }
+ else
+ return NULL;
+ }
+ else if (diff > 0)
+ {
+ if (p->rtag == PLUS)
+ {
+ p = p->link[1];
+ a[k] = 1;
+ }
+ else
+ return NULL;
+ }
+
+ k++;
+ }
+ tree->count--;
+
+ item = p->data;
+
+ {
+ avltr_node *t = p;
+ avltr_node **q = &pa[k - 1]->link[(int) a[k - 1]];
+
+ /* D5. */
+ if (t->rtag == MINUS)
+ {
+ if (t->link[0] != NULL)
+ {
+ avltr_node *const x = t->link[0];
+
+ *q = x;
+ (*q)->bal = 0;
+ if (x->rtag == MINUS)
+ {
+ if (a[k - 1] == 1)
+ x->link[1] = t->link[1];
+ else
+ x->link[1] = pa[k - 1];
+ }
+ }
+ else
+ {
+ *q = t->link[a[k - 1]];
+ if (a[k - 1] == 0)
+ pa[k - 1]->link[0] = NULL;
+ else
+ pa[k - 1]->rtag = MINUS;
+ }
+ }
+ else
+ {
+ /* D6. */
+ avltr_node *r = t->link[1];
+ if (r->link[0] == NULL)
+ {
+ r->link[0] = t->link[0];
+ r->bal = t->bal;
+ if (r->link[0] != NULL)
+ {
+ avltr_node *s = r->link[0];
+ while (s->rtag == PLUS)
+ s = s->link[1];
+ assert (s->rtag == MINUS);
+ s->link[1] = r;
+ }
+ *q = r;
+ a[k] = 1;
+ pa[k++] = r;
+ }
+ else
+ {
+ /* D7. */
+ avltr_node *s = r->link[0];
+
+ a[k] = 1;
+ pa[k++] = t;
+
+ a[k] = 0;
+ pa[k++] = r;
+
+ /* D8. */
+ while (s->link[0] != NULL)
+ {
+ r = s;
+ s = r->link[0];
+ a[k] = 0;
+ pa[k++] = r;
+ }
+
+ /* D9. */
+ t->data = s->data;
+ if (s->rtag == PLUS)
+ r->link[0] = s->link[1];
+ else
+ r->link[0] = NULL;
+ p = s;
+ }
+ }
+ }
+
+ free (p);
+
+ assert (k > 0);
+ /* D10. */
+ while (--k)
+ {
+ avltr_node *const s = pa[k];
+
+ if (a[k] == 0)
+ {
+ avltr_node *const r = s->link[1];
+
+ /* D10. */
+ if (s->bal == -1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = +1;
+ break;
+ }
+
+ assert (s->bal == +1);
+ if (s->rtag == MINUS || r->bal == 0)
+ {
+ /* D11. */
+ s->link[1] = r->link[0];
+ r->link[0] = s;
+ r->bal = -1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == +1)
+ {
+ /* D12. */
+ if (r->link[0] != NULL)
+ {
+ s->rtag = PLUS;
+ s->link[1] = r->link[0];
+ }
+ else
+ s->rtag = MINUS;
+ r->link[0] = s;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[a[k - 1]] = r;
+ }
+ else
+ {
+ /* D13. */
+ assert (r->bal == -1);
+ p = r->link[0];
+ if (p->rtag == PLUS)
+ r->link[0] = p->link[1];
+ else
+ r->link[0] = NULL;
+ p->link[1] = r;
+ p->rtag = PLUS;
+ if (p->link[0] == NULL)
+ {
+ s->link[1] = p;
+ s->rtag = MINUS;
+ }
+ else
+ {
+ s->link[1] = p->link[0];
+ s->rtag = PLUS;
+ }
+ p->link[0] = s;
+ if (p->bal == +1)
+ s->bal = -1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == -1);
+ s->bal = 0, r->bal = +1;
+ }
+ p->bal = 0;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ if (a[k - 1] == 1)
+ pa[k - 1]->rtag = PLUS;
+ }
+ }
+ else
+ {
+ avltr_node *const r = s->link[0];
+
+ /* D10. */
+ if (s->bal == +1)
+ {
+ s->bal = 0;
+ continue;
+ }
+ else if (s->bal == 0)
+ {
+ s->bal = -1;
+ break;
+ }
+
+ assert (s->bal == -1);
+ if (s->link[0] == NULL || r->bal == 0)
+ {
+ /* D11. */
+ s->link[0] = r->link[1];
+ r->link[1] = s;
+ r->bal = +1;
+ pa[k - 1]->link[(int) a[k - 1]] = r;
+ break;
+ }
+ else if (r->bal == -1)
+ {
+ /* D12. */
+ if (r->rtag == PLUS)
+ s->link[0] = r->link[1];
+ else
+ s->link[0] = NULL;
+ r->link[1] = s;
+ r->rtag = PLUS;
+ s->bal = r->bal = 0;
+ pa[k - 1]->link[a[k - 1]] = r;
+ }
+ else
+ {
+ /* D13. */
+ assert (r->bal == +1);
+ p = r->link[1];
+ if (p->link[0] != NULL)
+ {
+ r->rtag = PLUS;
+ r->link[1] = p->link[0];
+ }
+ else
+ r->rtag = MINUS;
+ p->link[0] = r;
+ if (p->rtag == MINUS)
+ s->link[0] = NULL;
+ else
+ s->link[0] = p->link[1];
+ p->link[1] = s;
+ p->rtag = PLUS;
+ if (p->bal == -1)
+ s->bal = +1, r->bal = 0;
+ else if (p->bal == 0)
+ s->bal = r->bal = 0;
+ else
+ {
+ assert (p->bal == +1);
+ s->bal = 0, r->bal = -1;
+ }
+ p->bal = 0;
+ if (a[k - 1] == 1)
+ pa[k - 1]->rtag = PLUS;
+ pa[k - 1]->link[(int) a[k - 1]] = p;
+ }
+ }
+ }
+
+ return (void *) item;
+}
+
+/* Inserts ITEM into TREE. Returns NULL if the item was inserted,
+ otherwise a pointer to the duplicate item. */
+void *
+avltr_insert (avltr_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avltr_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+/* If ITEM does not exist in TREE, inserts it and returns NULL. If a
+ matching item does exist, it is replaced by ITEM and the item
+ replaced is returned. The caller is responsible for freeing the
+ item returned. */
+void *
+avltr_replace (avltr_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = avltr_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+
+/* Delete ITEM from TREE when you know that ITEM must be in TREE. For
+ debugging purposes. */
+void *
+(avltr_force_delete) (avltr_tree *tree, void *item)
+{
+ void *found = avltr_delete (tree, item);
+ assert (found != NULL);
+ return found;
+}
+
+#if SELF_TEST
+
+/* Size of the tree used for testing. */
+#define TREE_SIZE 1024
+
+/* Used to flag delayed aborting. */
+int done = 0;
+
+/* Count the number of nodes in TREE below and including NODE. */
+int
+count (avltr_tree *tree, avltr_node *node)
+{
+ int n = 1;
+ if (node->link[0] != NULL)
+ n += count (tree, node->link[0]);
+ if (node->rtag == PLUS)
+ n += count (tree, node->link[1]);
+ return n;
+}
+
+/* Print the structure of node NODE of an avl tree, which is LEVEL
+ levels from the top of the tree. Uses different delimiters to
+ visually distinguish levels. */
+void
+print_structure (avltr_tree *tree, avltr_node *node, int level)
+{
+ char lc[] = "([{<`";
+ char rc[] = ")]}>'";
+
+ if (node == NULL)
+ {
+ printf (" :nil");
+ return;
+ }
+ else if (level >= 10)
+ {
+ printf ("Too deep, giving up.\n");
+ done = 1;
+ return;
+ }
+ else if (node == &tree->root)
+ {
+ printf (" root");
+ return;
+ }
+ printf (" %c%d", lc[level % 5], (int) node->data);
+ fflush (stdout);
+
+ print_structure (tree, node->link[0], level + 1);
+ fflush (stdout);
+
+ if (node->rtag == PLUS)
+ print_structure (tree, node->link[1], level + 1);
+ else if (node->link[1] != &tree->root)
+ printf (" :%d", (int) node->link[1]->data);
+ else
+ printf (" :r");
+ fflush (stdout);
+
+ printf ("%c", rc[level % 5]);
+ fflush (stdout);
+}
+
+/* Compare two integers A and B and return a strcmp()-type result. */
+int
+compare_ints (const void *a, const void *b, void *param unused)
+{
+ return ((int) a) - ((int) b);
+}
+
+/* Print the value of integer A. */
+void
+print_int (void *a, void *param unused)
+{
+ printf (" %d", (int) a);
+}
+
+/* Linearly print contents of TREE. */
+void
+print_contents (avltr_tree *tree)
+{
+ avltr_walk (tree, print_int, NULL);
+ printf ("\n");
+}
+
+/* Examine NODE in a avl tree. *COUNT is increased by the number of
+ nodes in the tree, including the current one. If the node is the
+ root of the tree, PARENT should be INT_MIN, otherwise it should be
+ the parent node value. DIR is the direction that the current node
+ is linked from the parent: -1 for left child, +1 for right child;
+ it is not used if PARENT is INT_MIN. Returns the height of the
+ tree rooted at NODE. */
+int
+recurse_tree (avltr_tree *tree, avltr_node *node, int *count, int parent,
+ int dir, unsigned char *nodes, unsigned char *threads)
+{
+ if (node != NULL && node != &tree->root)
+ {
+ int d = (int) node->data;
+ int nl = 0;
+ int nr = 0;
+
+ (*count)++;
+
+ assert (d >= 0 && d < TREE_SIZE);
+ if (nodes[d / 8] & (1 << (d % 8)))
+ {
+ printf (" Arrived at node %d by two different paths.\n", d);
+ done = 1;
+ }
+ else
+ nodes[d / 8] |= 1 << (d % 8);
+
+ if (node->link[0] != NULL)
+ nl = recurse_tree (tree, node->link[0], count, d, -1, nodes, threads);
+
+ if (node->rtag == PLUS)
+ {
+ if (node->link[1] == NULL)
+ {
+ printf (" Null thread link.\n");
+ done = 1;
+ }
+ nr = recurse_tree (tree, node->link[1], count, d, 1, nodes, threads);
+ }
+ else if (node->link[1] != &tree->root)
+ {
+ int dr = (int) node->link[1]->data;
+ assert (dr >= 0 && dr < TREE_SIZE);
+ if (threads[dr / 8] & (1 << dr % 8))
+ {
+ printf (" Multiple threads to node %d.\n", d);
+ done = 1;
+ }
+ threads[dr / 8] |= 1 << (dr % 8);
+ }
+
+ if (nr - nl != node->bal)
+ {
+ printf (" Node %d has incorrect balance: right height=%d, "
+ "left height=%d, difference=%d, but balance factor=%d.\n",
+ d, nr, nl, nr - nl, node->bal);
+ done = 1;
+ }
+
+ if (node->bal < -1 || node->bal > 1)
+ {
+ printf (" Node %d has invalid balance factor %d.\n", d, node->bal);
+ done = 1;
+ }
+
+ if (parent != INT_MIN)
+ {
+ assert (dir == -1 || dir == +1);
+ if (dir == -1 && d > parent)
+ {
+ printf (" Node %d is smaller than its left child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ else if (dir == +1 && d < parent)
+ {
+ printf (" Node %d is larger than its right child %d.\n",
+ parent, d);
+ done = 1;
+ }
+ }
+ assert (node->bal >= -1 && node->bal <= 1);
+ return 1 + (nl > nr ? nl : nr);
+ }
+ else return 0;
+}
+
+/* Check that everything about TREE is kosher. */
+void
+verify_tree (avltr_tree *tree)
+{
+ {
+ unsigned char nodes[(TREE_SIZE + 7) / 8];
+ unsigned char threads[(TREE_SIZE + 7) / 8];
+
+ int count = 0;
+ int i;
+
+ memset (nodes, 0, (TREE_SIZE + 7) / 8);
+ memset (threads, 0, (TREE_SIZE + 7) / 8);
+
+ recurse_tree (tree, tree->root.link[0], &count, INT_MIN, 0, nodes,
+ threads);
+
+ if (count != tree->count)
+ {
+ printf (" Tree should have %d nodes, but tree count by recursive "
+ "descent is %d.\n", tree->count, count);
+ done = 1;
+ }
+
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ int thread = threads[i / 8] & (1 << (i % 8));
+ int node = nodes[i / 8] & (1 << (i % 8));
+
+ if (thread && !node)
+ {
+ printf (" A thread leads to ``node'' %d, "
+ "which is not in the tree.", i);
+ done = 1;
+ }
+ }
+ }
+
+ /* Check threads. */
+ {
+ int count = 0;
+ int last = INT_MIN;
+ void **data = NULL;
+
+ while (NULL != (data = avltr_next (tree, data)))
+ {
+ if (((int) *data) < last)
+ {
+ printf (" Misordered right threads.\n");
+ abort ();
+ }
+ else if (((int) *data) == last)
+ {
+ printf (" Loop in right threads detected on %d.\n", last);
+ abort ();
+ }
+ last = (int) *data;
+ count++;
+ }
+
+ if (count != tree->count)
+ {
+ printf (" Tree should have %d nodes, but tree count by right threads "
+ "is %d.\n", tree->count, count);
+ done = 1;
+ }
+ }
+
+ if (done)
+ abort ();
+}
+
+/* Arrange the N elements of ARRAY in random order. */
+void
+shuffle (int *array, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ int j = i + rand () % (n - i);
+ int t = array[j];
+ array[j] = array[i];
+ array[i] = t;
+ }
+}
+
+/* Compares avl trees rooted at A and B, making sure that they are
+ identical. */
+void
+compare_trees (avltr_node *a, avltr_node *b)
+{
+ int diff = 0;
+
+ assert (a && b);
+
+ /* Separating these conditions makes it easier to pinpoint bad data
+ under a memory debugger like Checker because each test is a
+ separate statement. */
+ diff |= a->data != b->data;
+ diff |= a->bal != b->bal;
+ diff |= ((a->link[0] != NULL) ^ (b->link[0] != NULL));
+ diff |= ((a->rtag == PLUS) ^ (b->rtag == PLUS));
+ if (diff)
+ {
+ printf (" Copied nodes differ: %d b=%d a->bal=%d b->bal=%d a:",
+ (int) a->data, (int) b->data, a->bal, b->bal);
+ if (a->link[0])
+ printf ("l");
+ if (a->link[1])
+ printf ("r");
+ printf (" b:");
+ if (b->link[0])
+ printf ("l");
+ if (b->link[1])
+ printf ("r");
+ printf ("\n");
+ abort ();
+ }
+ if (a->link[0] != NULL)
+ compare_trees (a->link[0], b->link[0]);
+ if (a->rtag == PLUS)
+ compare_trees (a->link[1], b->link[1]);
+}
+
+/* Simple stress test procedure for the AVL tree routines. Does the
+ following:
+
+ * Generate a random number seed. By default this is generated from
+ the current time. You can also pass a seed value on the command
+ line if you want to test the same case. The seed value is
+ displayed.
+
+ * Create a tree and insert the integers from 0 up to TREE_SIZE - 1
+ into it, in random order. Verify the tree structure after each
+ insertion.
+
+ * Remove each integer from the tree, in a different random order.
+ After each deletion, verify the tree structure; also, make a copy
+ of the tree into a new tree, verify the copy and compare it to the
+ original, then destroy the copy.
+
+ * Destroy the tree, increment the random seed value, and start over.
+
+ If you make any modifications to the avl tree routines, then you
+ might want to insert some calls to print_structure() at strategic
+ places in order to be able to see what's really going on. Also,
+ memory debuggers like Checker or Purify are very handy. */
+#define N_ITERATIONS 16
+int
+main (int argc, char **argv)
+{
+ int array[TREE_SIZE];
+ int seed;
+ int iteration;
+
+ if (argc == 2)
+ seed = atoi (argv[1]);
+ else
+ seed = time (0) * 257 % 32768;
+
+ fputs ("Testing avltr...\n", stdout);
+
+ for (iteration = 1; iteration <= N_ITERATIONS; iteration++)
+ {
+ avltr_tree *tree;
+ int i;
+
+ printf ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed);
+ fflush (stdout);
+
+ srand (seed++);
+
+ for (i = 0; i < TREE_SIZE; i++)
+ array[i] = i;
+ shuffle (array, TREE_SIZE);
+
+ tree = avltr_create (compare_ints, NULL);
+ for (i = 0; i < TREE_SIZE; i++)
+ avltr_force_insert (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ shuffle (array, TREE_SIZE);
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ avltr_tree *copy;
+
+ avltr_delete (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ copy = avltr_copy (tree, NULL);
+ verify_tree (copy);
+ if (tree->root.link[0] != NULL)
+ compare_trees (tree->root.link[0], copy->root.link[0]);
+ else if (copy->root.link[0] != NULL)
+ {
+ printf (" Empty tree results in nonempty copy.\n");
+ abort ();
+ }
+ avltr_destroy (copy, NULL);
+
+ if (i % 128 == 0)
+ {
+ putchar ('.');
+ fflush (stdout);
+ }
+ }
+ fputs (" good.\n", stdout);
+
+ avltr_destroy (tree, NULL);
+ }
+
+ return 0;
+}
+#endif /* SELF_TEST */
+
+/*
+ Local variables:
+ compile-command: "gcc -DSELF_TEST=1 -W -Wall -I. -o ./avltr-test avltr.c"
+ End:
+*/
+
diff --git a/avl-1.4.0/avltr.h b/avl-1.4.0/avltr.h
new file mode 100644
index 0000000..27465ef
--- /dev/null
+++ b/avl-1.4.0/avltr.h
@@ -0,0 +1,142 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file avltr.h in libavl. */
+
+#if !avltr_h
+#define avltr_h 1
+
+/* The default maximum height of 32 allows for AVL trees having
+ between 5,704,880 and 4,294,967,295 nodes, depending on order of
+ insertion. You may change this compile-time constant as you
+ wish. */
+#ifndef AVL_MAX_HEIGHT
+#define AVL_MAX_HEIGHT 32
+#endif
+
+/* Structure for a node in a right-threaded AVL tree. */
+typedef struct avltr_node
+ {
+ void *data; /* Pointer to data. */
+ struct avltr_node *link[2]; /* Subtrees or threads. */
+ signed char bal; /* Balance factor. */
+ char cache; /* Used during insertion. */
+ char pad; /* Reserved for fully threaded trees. */
+ signed char rtag; /* Right thread tag. */
+ }
+avltr_node;
+
+/* Used for traversing a right-threaded AVL tree. */
+typedef struct avltr_traverser
+ {
+ int init; /* Initialized? */
+ const avltr_node *p; /* Last node returned. */
+ }
+avltr_traverser;
+
+/* Initializer for avltr_traverser. */
+#define AVLTR_TRAVERSER_INIT {0}
+
+/* Function types. */
+#if !AVL_FUNC_TYPES
+#define AVL_FUNC_TYPES 1
+typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
+typedef void (*avl_node_func) (void *data, void *param);
+typedef void *(*avl_copy_func) (void *data, void *param);
+#endif
+
+/* Structure which holds information about a threaded AVL tree. */
+typedef struct avltr_tree
+ {
+ avltr_node root; /* Tree root node. */
+ avl_comparison_func cmp; /* Used to compare keys. */
+ int count; /* Number of nodes in the tree. */
+ void *param; /* Arbitary user data. */
+ }
+avltr_tree;
+
+/* General functions. */
+avltr_tree *avltr_create (avl_comparison_func, void *param);
+void avltr_destroy (avltr_tree *, avl_node_func);
+void avltr_free (avltr_tree *);
+int avltr_count (const avltr_tree *);
+avltr_tree *avltr_copy (const avltr_tree *, avl_copy_func);
+struct avl_tree;
+avltr_tree *avltr_thread (struct avl_tree *);
+struct avl_tree *avltr_unthread (avltr_tree *);
+
+/* Walk the tree. */
+void avltr_walk (const avltr_tree *, avl_node_func, void *param);
+void *avltr_traverse (const avltr_tree *, avltr_traverser *);
+#define avlt_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
+void **avltr_next (const avltr_tree *tree, void **item);
+
+/* Search for a given item. */
+void **avltr_probe (avltr_tree *, void *);
+void *avltr_delete (avltr_tree *, const void *);
+void **avltr_find (const avltr_tree *, const void *);
+void **avltr_find_close (const avltr_tree *, const void *);
+
+#if __GCC__ >= 2
+extern inline void *
+avltr_insert (avltr_tree *tree, void *item)
+{
+ void **p = avltr_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+extern inline void *
+avltr_replace (avltr_tree *tree, void *item)
+{
+ void **p = avltr_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+#else /* not gcc */
+void *avltr_insert (avltr_tree *tree, void *item);
+void *avltr_replace (avltr_tree *tree, void *item);
+#endif /* not gcc */
+
+/* Easy assertions on insertion & deletion. */
+#ifndef NDEBUG
+#define avltr_force_insert(A, B) \
+ do \
+ { \
+ void *r = avltr_insert (A, B); \
+ assert (r == NULL); \
+ } \
+ while (0)
+void *avltr_force_delete (avltr_tree *, void *);
+#else
+#define avltr_force_insert(A, B) \
+ avltr_insert (A, B)
+#define avltr_force_delete(A, B) \
+ avltr_delete (A, B)
+#endif
+
+#endif /* avltr_h */
diff --git a/avl-1.4.0/configure b/avl-1.4.0/configure
new file mode 100755
index 0000000..5b955a9
--- /dev/null
+++ b/avl-1.4.0/configure
@@ -0,0 +1,1297 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=avl.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:556: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
+echo "configure:609: checking whether build environment is sane" >&5
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftestfile`
+ fi
+ if test "$*" != "X $srcdir/configure conftestfile" \
+ && test "$*" != "X conftestfile $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { echo "configure: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" 1>&2; exit 1; }
+ fi
+
+ test "$2" = conftestfile
+ )
+then
+ # Ok.
+ :
+else
+ { echo "configure: error: newly created file is older than distributed files!
+Check your system clock" 1>&2; exit 1; }
+fi
+rm -f conftest*
+echo "$ac_t""yes" 1>&6
+if test "$program_transform_name" = s,x,x,; then
+ program_transform_name=
+else
+ # Double any \ or $. echo might interpret backslashes.
+ cat <<\EOF_SED > conftestsed
+s,\\,\\\\,g; s,\$,$$,g
+EOF_SED
+ program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
+ rm -f conftestsed
+fi
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,${program_prefix},; $program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
+
+# sed with no file args requires a program.
+test "$program_transform_name" = "" && program_transform_name="s,x,x,"
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:666: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+PACKAGE=avl
+
+VERSION=1.4.0
+
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+ { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
+fi
+cat >> confdefs.h <> confdefs.h <&6
+echo "configure:712: checking for working aclocal" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+ ACLOCAL=aclocal
+ echo "$ac_t""found" 1>&6
+else
+ ACLOCAL="$missing_dir/missing aclocal"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
+echo "configure:725: checking for working autoconf" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoconf --version) < /dev/null > /dev/null 2>&1; then
+ AUTOCONF=autoconf
+ echo "$ac_t""found" 1>&6
+else
+ AUTOCONF="$missing_dir/missing autoconf"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working automake""... $ac_c" 1>&6
+echo "configure:738: checking for working automake" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (automake --version) < /dev/null > /dev/null 2>&1; then
+ AUTOMAKE=automake
+ echo "$ac_t""found" 1>&6
+else
+ AUTOMAKE="$missing_dir/missing automake"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
+echo "configure:751: checking for working autoheader" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (autoheader --version) < /dev/null > /dev/null 2>&1; then
+ AUTOHEADER=autoheader
+ echo "$ac_t""found" 1>&6
+else
+ AUTOHEADER="$missing_dir/missing autoheader"
+ echo "$ac_t""missing" 1>&6
+fi
+
+echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
+echo "configure:764: checking for working makeinfo" >&5
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf. Sigh.
+if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
+ MAKEINFO=makeinfo
+ echo "$ac_t""found" 1>&6
+else
+ MAKEINFO="$missing_dir/missing makeinfo"
+ echo "$ac_t""missing" 1>&6
+fi
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:780: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:810: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:861: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:893: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 904 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:935: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:940: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:968: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1002: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS </dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@PACKAGE@%$PACKAGE%g
+s%@VERSION@%$VERSION%g
+s%@ACLOCAL@%$ACLOCAL%g
+s%@AUTOCONF@%$AUTOCONF%g
+s%@AUTOMAKE@%$AUTOMAKE%g
+s%@AUTOHEADER@%$AUTOHEADER%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@CC@%$CC%g
+s%@RANLIB@%$RANLIB%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/avl-1.4.0/configure.in b/avl-1.4.0/configure.in
new file mode 100644
index 0000000..118f3c8
--- /dev/null
+++ b/avl-1.4.0/configure.in
@@ -0,0 +1,5 @@
+AC_INIT(avl.c)
+AM_INIT_AUTOMAKE(avl, 1.4.0)
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT(Makefile)
diff --git a/avl-1.4.0/install-sh b/avl-1.4.0/install-sh
new file mode 100755
index 0000000..e9de238
--- /dev/null
+++ b/avl-1.4.0/install-sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/avl-1.4.0/missing b/avl-1.4.0/missing
new file mode 100755
index 0000000..7789652
--- /dev/null
+++ b/avl-1.4.0/missing
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard , 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing - GNU libit 0.0"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`configure.in'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`configure.in'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`configure.in'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case "$f" in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/avl-1.4.0/mkinstalldirs b/avl-1.4.0/mkinstalldirs
new file mode 100755
index 0000000..6b3b5fc
--- /dev/null
+++ b/avl-1.4.0/mkinstalldirs
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman
+# Created: 1993-05-16
+# Public domain
+
+# $Id$
+
+errstatus=0
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/avl-1.4.0/rb.c b/avl-1.4.0/rb.c
new file mode 100644
index 0000000..b0ec05d
--- /dev/null
+++ b/avl-1.4.0/rb.c
@@ -0,0 +1,1083 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file rb.c in libavl. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#if SELF_TEST
+#include
+#include
+#endif
+#include
+#include
+#include
+#include "rb.h"
+
+#if !PSPP && !__GCC__
+#define inline
+#endif
+
+#if __GNUC__ >= 2
+#define unused __attribute__ ((unused))
+#else
+#define unused
+#endif
+
+#ifdef HAVE_XMALLOC
+void *xmalloc (size_t);
+#else /* !HAVE_XMALLOC */
+/* Allocates SIZE bytes of space using malloc(). Aborts if out of
+ memory. */
+static void *
+xmalloc (size_t size)
+{
+ void *vp;
+
+ if (size == 0)
+ return NULL;
+ vp = malloc (size);
+
+ assert (vp != NULL);
+ if (vp == NULL)
+ {
+ fprintf (stderr, "virtual memory exhausted\n");
+ exit (EXIT_FAILURE);
+ }
+ return vp;
+}
+#endif /* !HAVE_XMALLOC */
+
+/* Creates a red-black tree in arena OWNER (which can be NULL). The
+ arena is owned by the caller, not by the red-black tree. CMP is a
+ order function for the data to be stored in the tree. PARAM is
+ arbitrary data that becomes an argument to the comparison
+ function. */
+rb_tree *
+rb_create (MAYBE_ARENA avl_comparison_func cmp, void *param)
+{
+ rb_tree *tree;
+
+ assert (cmp != NULL);
+ tree = xmalloc (sizeof (rb_tree));
+
+ tree->root.link[0] = NULL;
+ tree->root.link[1] = NULL;
+ tree->cmp = cmp;
+ tree->count = 0;
+ tree->param = param;
+
+ return tree;
+}
+
+/* Destroy tree TREE. Function FREE_FUNC is called for every node in
+ the tree as it is destroyed.
+
+ No effect if the tree has an arena owner and free_func is NULL.
+ The caller owns the arena and must destroy it itself.
+
+ Do not attempt to reuse the tree after it has been freed. Create a
+ new one. */
+void
+rb_destroy (rb_tree *tree, avl_node_func free_func)
+{
+ assert (tree != NULL);
+
+ {
+ /* Uses Knuth's Algorithm 2.3.1T as modified in exercise 13
+ (postorder traversal). */
+
+ /* T1. */
+ rb_node *an[RB_MAX_HEIGHT]; /* Stack A: nodes. */
+ unsigned long ab = 0; /* Stack A: bits. */
+ int ap = 0; /* Stack A: height. */
+ rb_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ while (p != NULL)
+ {
+ /* T3. */
+ ab &= ~(1ul << ap);
+ an[ap++] = p;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ for (;;)
+ {
+ if (ap == 0)
+ goto done;
+
+ p = an[--ap];
+ if ((ab & (1ul << ap)) == 0)
+ {
+ ab |= (1ul << ap++);
+ p = p->link[1];
+ break;
+ }
+
+ if (free_func)
+ free_func (p->data, tree->param);
+ free (p);
+ }
+ }
+ }
+
+ done:
+ free (tree);
+}
+
+/* rb_destroy() with FREE_FUNC hardcoded as free(). */
+void
+rb_free (rb_tree *tree)
+{
+ rb_destroy (tree, (avl_node_func) free);
+}
+
+/* Return the number of nodes in TREE. */
+int
+rb_count (const rb_tree *tree)
+{
+ assert (tree != NULL);
+ return tree->count;
+}
+
+/* Copy the contents of TREE to a new tree in arena OWNER. If COPY is
+ non-NULL, then each data item is passed to function COPY, and the
+ return values are inserted into the new tree; otherwise, the items
+ are copied verbatim from the old tree to the new tree. Returns the
+ new tree. */
+rb_tree *
+rb_copy (MAYBE_ARENA const rb_tree *tree, avl_copy_func copy)
+{
+ /* This is a combination of Knuth's Algorithm 2.3.1C (copying a
+ binary tree) and Algorithm 2.3.1T as modified by exercise 12
+ (preorder traversal). */
+
+ rb_tree *new_tree;
+
+ /* PT1. */
+ const rb_node *pa[RB_MAX_HEIGHT]; /* Stack PA: nodes. */
+ const rb_node **pp = pa; /* Stack PA: stack pointer. */
+ const rb_node *p = &tree->root;
+
+ /* QT1. */
+ rb_node *qa[RB_MAX_HEIGHT]; /* Stack QA: nodes. */
+ rb_node **qp = qa; /* Stack QA: stack pointer. */
+ rb_node *q;
+
+ assert (tree != NULL);
+ new_tree = rb_create (tree->cmp, tree->param);
+ new_tree->count = tree->count;
+ q = &new_tree->root;
+
+ for (;;)
+ {
+ /* C4. */
+ if (p->link[0] != NULL)
+ {
+ rb_node *r = xmalloc (sizeof (rb_node));
+ r->link[0] = r->link[1] = NULL;
+ q->link[0] = r;
+ }
+
+ /* C5: Find preorder successors of P and Q. */
+ goto start;
+ for (;;)
+ {
+ /* PT2. */
+ while (p != NULL)
+ {
+ goto escape;
+ start:
+ /* PT3. */
+ *pp++ = p;
+ *qp++ = q;
+ p = p->link[0];
+ q = q->link[0];
+ }
+
+ /* PT4. */
+ if (pp == pa)
+ {
+ assert (qp == qa);
+ return new_tree;
+ }
+
+ p = *--pp;
+ q = *--qp;
+
+ /* PT5. */
+ p = p->link[1];
+ q = q->link[1];
+ }
+ escape:
+
+ /* C2. */
+ if (p->link[1])
+ {
+ rb_node *r = xmalloc (sizeof (rb_node));
+ r->link[0] = r->link[1] = NULL;
+ q->link[1] = r;
+ }
+
+ /* C3. */
+ q->color = p->color;
+ if (copy == NULL)
+ q->data = p->data;
+ else
+ q->data = copy (p->data, tree->param);
+ }
+}
+
+/* Walk tree TREE in inorder, calling WALK_FUNC at each node. Passes
+ PARAM to WALK_FUNC. */
+void
+rb_walk (const rb_tree *tree, avl_node_func walk_func, void *param)
+{
+ /* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+ assert (tree && walk_func);
+
+ {
+ /* T1. */
+ const rb_node *an[RB_MAX_HEIGHT]; /* Stack A: nodes. */
+ const rb_node **ap = an; /* Stack A: stack pointer. */
+ const rb_node *p = tree->root.link[0];
+
+ for (;;)
+ {
+ /* T2. */
+ while (p != NULL)
+ {
+ /* T3. */
+ *ap++ = p;
+ p = p->link[0];
+ }
+
+ /* T4. */
+ if (ap == an)
+ return;
+ p = *--ap;
+
+ /* T5. */
+ walk_func (p->data, param);
+ p = p->link[1];
+ }
+ }
+}
+
+/* Each call to this function for a given TREE and TRAV return the
+ next item in the tree in inorder. Initialize the first element of
+ TRAV (init) to 0 before calling the first time. Returns NULL when
+ out of elements. */
+void *
+rb_traverse (const rb_tree *tree, rb_traverser *trav)
+{
+ assert (tree && trav);
+
+ /* Uses Knuth's algorithm 2.3.1T (inorder traversal). */
+ if (trav->init == 0)
+ {
+ /* T1. */
+ trav->init = 1;
+ trav->nstack = 0;
+ trav->p = tree->root.link[0];
+ }
+ else
+ /* T5. */
+ trav->p = trav->p->link[1];
+
+ for (;;)
+ {
+ /* T2. */
+ while (trav->p != NULL)
+ {
+ /* T3. */
+ trav->stack[trav->nstack++] = trav->p;
+ trav->p = trav->p->link[0];
+ }
+
+ /* T4. */
+ if (trav->nstack == 0)
+ {
+ trav->init = 0;
+ return NULL;
+ }
+ trav->p = trav->stack[--trav->nstack];
+
+ /* T5. */
+ return trav->p->data;
+ }
+}
+
+/* Search TREE for an item matching ITEM. If found, returns a pointer
+ to the address of the item. If none is found, ITEM is inserted
+ into the tree, and a pointer to the address of ITEM is returned.
+ In either case, the pointer returned can be changed by the caller,
+ or the returned data item can be directly edited, but the key data
+ in the item must not be changed. */
+void **
+rb_probe (rb_tree *tree, void *item)
+{
+ /* Algorithm based on RB-Insert from section 14.3 of _Introduction
+ to Algorithms_, Cormen et al., MIT Press 1990, ISBN
+ 0-262-03141-8. */
+
+ rb_node *ap[RB_MAX_HEIGHT]; /* Stack A: Nodes. */
+ char ad[RB_MAX_HEIGHT]; /* Stack A: Directions. */
+ int ak = 1; /* Stack A: Pointer. */
+
+ rb_node *t, *x, *y, *n;
+
+ assert (tree != NULL);
+ t = &tree->root;
+ x = t->link[0];
+
+ if (x == NULL)
+ {
+ tree->count++;
+ assert (tree->count == 1);
+ x = t->link[0] = xmalloc (sizeof (rb_node));
+ x->data = item;
+ x->link[0] = x->link[1] = NULL;
+ x->color = RB_BLACK;
+ return &x->data;
+ }
+
+ ad[0] = 0;
+ ap[0] = &tree->root;
+
+ for (;;)
+ {
+ int diff = tree->cmp (item, x->data, tree->param);
+
+ if (diff < 0)
+ {
+ ap[ak] = x;
+ ad[ak++] = 0;
+ y = x->link[0];
+ if (y == NULL)
+ {
+ n = x = x->link[0] = xmalloc (sizeof (rb_node));
+ break;
+ }
+ }
+ else if (diff > 0)
+ {
+ ap[ak] = x;
+ ad[ak++] = 1;
+ y = x->link[1];
+ if (y == NULL)
+ {
+ n = x = x->link[1] = xmalloc (sizeof (rb_node));
+ break;
+ }
+ }
+ else
+ return &x->data;
+
+ x = y;
+ }
+
+ tree->count++;
+ x->data = item;
+ x->link[0] = x->link[1] = NULL;
+ x->color = RB_RED;
+
+ for (;;)
+ {
+ if (ak < 3 || ap[ak - 1]->color != RB_RED)
+ break;
+
+ if (ad[ak - 2] == 0)
+ {
+ y = ap[ak - 2]->link[1];
+ if (y != NULL && y->color == RB_RED)
+ {
+ /* Case 1. */
+ ap[ak - 1]->color = y->color = RB_BLACK;
+ ap[ak - 2]->color = RB_RED;
+ ak -= 2;
+ }
+ else
+ {
+ if (ad[ak - 1] == 1)
+ {
+ /* Case 2. */
+ x = ap[ak - 1];
+ y = x->link[1];
+ x->link[1] = y->link[0];
+ y->link[0] = x;
+ ap[ak - 2]->link[0] = y;
+ }
+ else
+ y = ap[ak - 1];
+
+ /* Case 3. */
+ x = ap[ak - 2];
+ x->color = RB_RED;
+ y->color = RB_BLACK;
+
+ x->link[0] = y->link[1];
+ y->link[1] = x;
+ ap[ak - 3]->link[(int) ad[ak - 3]] = y;
+
+ break;
+ }
+ }
+ else
+ {
+ y = ap[ak - 2]->link[0];
+ if (y != NULL && y->color == RB_RED)
+ {
+ /* Case 1. */
+ ap[ak - 1]->color = y->color = RB_BLACK;
+ ap[ak - 2]->color = RB_RED;
+ ak -= 2;
+ }
+ else
+ {
+ if (ad[ak - 1] == 0)
+ {
+ /* Case 2. */
+ x = ap[ak - 1];
+ y = x->link[0];
+ x->link[0] = y->link[1];
+ y->link[1] = x;
+ ap[ak - 2]->link[1] = y;
+ }
+ else
+ y = ap[ak - 1];
+
+ /* Case 3. */
+ x = ap[ak - 2];
+ x->color = RB_RED;
+ y->color = RB_BLACK;
+
+ x->link[1] = y->link[0];
+ y->link[0] = x;
+ ap[ak - 3]->link[(int) ad[ak - 3]] = y;
+ break;
+ }
+ }
+ }
+
+ tree->root.link[0]->color = RB_BLACK;
+
+ return &n->data;
+}
+
+/* Search TREE for an item matching ITEM, and return it if found. */
+void *
+rb_find (const rb_tree *tree, const void *item)
+{
+ const rb_node *p;
+
+ assert (tree != NULL);
+ for (p = tree->root.link[0]; p; )
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+
+ if (diff < 0)
+ p = p->link[0];
+ else if (diff > 0)
+ p = p->link[1];
+ else
+ return p->data;
+ }
+
+ return NULL;
+}
+
+/* Search TREE for an item close to the value of ITEM, and return it.
+ This function will return a null pointer only if TREE is empty. */
+void *
+rb_find_close (const rb_tree *tree, const void *item)
+{
+ const rb_node *p;
+
+ assert (tree != NULL);
+ p = tree->root.link[0];
+ if (p == NULL)
+ return NULL;
+
+ for (;;)
+ {
+ int diff = tree->cmp (item, p->data, tree->param);
+ int t;
+
+ if (diff < 0)
+ t = 0;
+ else if (diff > 0)
+ t = 1;
+ else
+ return p->data;
+
+ if (p->link[t])
+ p = p->link[t];
+ else
+ return p->data;
+ }
+}
+
+/* Searches red-black tree TREE for an item matching ITEM. If found,
+ the item is removed from the tree and the actual item found is
+ returned to the caller. If no item matching ITEM exists in the
+ tree, returns NULL. */
+void *
+rb_delete (rb_tree *tree, const void *item)
+{
+ /* Algorithm based on RB-Delete and RB-Delete-Fixup from section
+ 14.4 of _Introduction to Algorithms_, Cormen et al., MIT Press
+ 1990, ISBN 0-262-03141-8. */
+
+ rb_node *pa[RB_MAX_HEIGHT]; /* Stack P: Nodes. */
+ char a[RB_MAX_HEIGHT]; /* Stack P: Bits. */
+ int k = 1; /* Stack P: Pointer. */
+
+ rb_node *w, *x, *y, *z;
+
+ assert (tree != NULL);
+
+ a[0] = 0;
+ pa[0] = &tree->root;
+ z = tree->root.link[0];
+ for (;;)
+ {
+ int diff;
+
+ if (z == NULL)
+ return NULL;
+
+ diff = tree->cmp (item, z->data, tree->param);
+ if (diff == 0)
+ break;
+
+ pa[k] = z;
+ if (diff < 0)
+ {
+ z = z->link[0];
+ a[k] = 0;
+ }
+ else if (diff > 0)
+ {
+ z = z->link[1];
+ a[k] = 1;
+ }
+ k++;
+ }
+ tree->count--;
+
+ item = z->data;
+
+ /* RB-Delete: Line 1. */
+ if (z->link[0] == NULL || z->link[1] == NULL)
+ {
+ /* Line 2. */
+ y = z;
+
+ /* Lines 4-6. */
+ if (y->link[0] != NULL)
+ x = y->link[0];
+ else
+ x = y->link[1];
+
+ pa[k - 1]->link[(int) a[k - 1]] = x;
+ }
+ else
+ {
+ pa[k] = z;
+ a[k++] = 1;
+
+ /* Line 3. */
+ y = z->link[1];
+ while (y->link[0])
+ {
+ pa[k] = y;
+ a[k++] = 0;
+ y = y->link[0];
+ }
+
+ /* Lines 4-6. */
+ x = y->link[1];
+
+ /* Lines 13-15. */
+ z->data = y->data;
+ pa[k - 1]->link[(int) a[k - 1]] = x;
+ }
+
+ /* Line 16. */
+ if (y->color == RB_RED)
+ {
+ free (y);
+ return (void *) item;
+ }
+
+ free (y);
+
+ /* Numbers below are line numbers from RB-Delete-Fixup. */
+ while (k > 1 && (x == NULL || x->color == RB_BLACK)) /* 1 */
+ {
+ if (a[k - 1] == 0) /* 2 */
+ {
+ w = pa[k - 1]->link[1]; /* 3 */
+
+ if (w->color == RB_RED) /* 4 */
+ {
+ /* Case 1. */
+ w->color = RB_BLACK; /* 5 */
+ pa[k - 1]->color = RB_RED; /* 6 */
+
+ pa[k - 1]->link[1] = w->link[0]; /* 7 */
+ w->link[0] = pa[k - 1];
+ pa[k - 2]->link[(int) a[k - 2]] = w;
+
+ pa[k] = pa[k - 1];
+ a[k] = 0;
+ pa[k - 1] = w;
+ k++;
+
+ w = pa[k - 1]->link[1]; /* 8 */
+ }
+
+ if ((w->link[0] == NULL || w->link[0]->color == RB_BLACK) /* 9 */
+ && (w->link[1] == NULL || w->link[1]->color == RB_BLACK))
+ {
+ /* Case 2. */
+ w->color = RB_RED; /* 10 */
+
+ x = pa[k - 1]; /* 11 */
+ k--;
+ }
+ else
+ {
+ if (w->link[1] == NULL || w->link[1]->color == RB_BLACK) /* 12 */
+ {
+ /* Case 3. */
+ w->link[0]->color = RB_BLACK; /* 13 */
+ w->color = RB_RED; /* 14 */
+
+ y = w->link[0]; /* 15 */
+ w->link[0] = y->link[1];
+ y->link[1] = w;
+
+ w = pa[k - 1]->link[1] = y; /* 16 */
+ }
+
+ /* Case 4. */
+ w->color = pa[k - 1]->color; /* 17 */
+ pa[k - 1]->color = RB_BLACK; /* 18 */
+ w->link[1]->color = RB_BLACK; /* 19 */
+
+ pa[k - 1]->link[1] = w->link[0]; /* 20 */
+ w->link[0] = pa[k - 1];
+ pa[k - 2]->link[(int) a[k - 2]] = w;
+
+ x = tree->root.link[0]; /* 21 */
+ break;
+ }
+ }
+ else
+ {
+ w = pa[k - 1]->link[0];
+ if (w->color == RB_RED)
+ {
+ /* Case 1. */
+ w->color = RB_BLACK;
+ pa[k - 1]->color = RB_RED;
+
+ pa[k - 1]->link[0] = w->link[1];
+ w->link[1] = pa[k - 1];
+ pa[k - 2]->link[(int) a[k - 2]] = w;
+
+ pa[k] = pa[k - 1];
+ a[k] = 1;
+ pa[k - 1] = w;
+ k++;
+
+ w = pa[k - 1]->link[0];
+ }
+
+ if ((w->link[0] == NULL || w->link[0]->color == RB_BLACK)
+ && (w->link[1] == NULL || w->link[1]->color == RB_BLACK))
+ {
+ /* Case 2. */
+ w->color = RB_RED;
+ x = pa[k - 1];
+ k--;
+ }
+ else
+ {
+ if (w->link[0] == NULL || w->link[0]->color == RB_BLACK)
+ {
+ /* Case 3. */
+ w->link[1]->color = RB_BLACK;
+ w->color = RB_RED;
+
+ y = w->link[1];
+ w->link[1] = y->link[0];
+ y->link[0] = w;
+
+ w = pa[k - 1]->link[0] = y;
+ }
+
+ /* Case 4. */
+ w->color = pa[k - 1]->color;
+ pa[k - 1]->color = RB_BLACK;
+ w->link[0]->color = RB_BLACK;
+
+ pa[k - 1]->link[0] = w->link[1];
+ w->link[1] = pa[k - 1];
+ pa[k - 2]->link[(int) a[k - 2]] = w;
+
+ x = tree->root.link[0];
+ break;
+ }
+ }
+ }
+
+ if (x != NULL)
+ x->color = RB_BLACK; /* 23 */
+
+ return (void *) item;
+}
+
+/* Inserts ITEM into TREE. Returns NULL if the item was inserted,
+ otherwise a pointer to the duplicate item. */
+void *
+rb_insert (rb_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = rb_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+/* If ITEM does not exist in TREE, inserts it and returns NULL. If a
+ matching item does exist, it is replaced by ITEM and the item
+ replaced is returned. The caller is responsible for freeing the
+ item returned. */
+void *
+rb_replace (rb_tree *tree, void *item)
+{
+ void **p;
+
+ assert (tree != NULL);
+
+ p = rb_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+
+/* Delete ITEM from TREE when you know that ITEM must be in TREE. For
+ debugging purposes. */
+void *
+(rb_force_delete) (rb_tree *tree, void *item)
+{
+ void *found = rb_delete (tree, item);
+ assert (found != NULL);
+ return found;
+}
+
+#if SELF_TEST
+
+/* Used to flag delayed aborting. */
+int done = 0;
+
+/* Print the structure of node NODE of a red-black tree, which is
+ LEVEL levels from the top of the tree. Uses different delimiters
+ to visually distinguish levels. */
+void
+print_structure (rb_node *node, int level)
+{
+ char lc[] = "([{<`/";
+ char rc[] = ")]}>'\\";
+
+ assert (level <= 10);
+
+ if (node == NULL)
+ {
+ printf (" nil");
+ fflush (stdout);
+ return;
+ }
+ printf (" %c%d%c",
+ lc[level % 6], (int) node->data,
+ node->color == RB_BLACK ? 'b' : 'r');
+ fflush (stdout);
+ if (node->link[0] || node->link[1])
+ print_structure (node->link[0], level + 1);
+ if (node->link[1])
+ print_structure (node->link[1], level + 1);
+ printf ("%c", rc[level % 6]);
+ fflush (stdout);
+}
+
+/* Compare two integers A and B and return a strcmp()-type result. */
+int
+compare_ints (const void *a, const void *b, void *param unused)
+{
+ return ((int) a) - ((int) b);
+}
+
+/* Print the value of integer A. */
+void
+print_int (void *a, void *param unused)
+{
+ printf (" %d", (int) a);
+}
+
+/* Linearly print contents of TREE. */
+void
+print_contents (rb_tree *tree)
+{
+ rb_walk (tree, print_int, NULL);
+ printf ("\n");
+}
+
+/* Examine NODE in a red-black tree. *COUNT is increased by the
+ number of nodes in the tree, including the current one. Returns
+ the number of black nodes (including this node) in a path from this
+ node to any leaf. */
+int
+recurse_tree (rb_node *node, int *count, int ge, int le)
+{
+ if (node)
+ {
+ const int d = (int) node->data;
+ int nl = 1;
+ int nr = 1;
+
+ (*count)++;
+
+ if (!(d >= ge) || !(d <= le))
+ {
+ printf (" Node %d is out of order in the tree.\n", d);
+ done = 1;
+ }
+
+ if (node->link[0])
+ nl = recurse_tree (node->link[0], count, ge, d - 1);
+ if (node->link[1])
+ nr = recurse_tree (node->link[1], count, d + 1, le);
+
+ if (node->color != RB_RED && node->color != RB_BLACK)
+ {
+ printf (" Node %d is neither red nor black (%d).\n", d, node->color);
+ done = 1;
+ }
+
+ if (node->color == RB_RED
+ && node->link[0] && node->link[0]->color == RB_RED)
+ {
+ printf (" Red node %d has red left child %d\n",
+ d, (int) node->link[0]->data);
+ done = 1;
+ }
+
+ if (node->color == RB_RED
+ && node->link[1] && node->link[1]->color == RB_RED)
+ {
+ printf (" Red node %d has red right child %d\n",
+ d, (int) node->link[1]->data);
+ done = 1;
+ }
+
+ if (nl != nr)
+ {
+ printf (" Node %d has two different black-heights: left bh=%d, "
+ "right bh=%d\n", d, nl, nr);
+ done = 1;
+ }
+
+ return (node->color == RB_BLACK) + nl;
+ }
+ else return 1;
+}
+
+/* Check that everything about TREE is kosher. */
+void
+verify_tree (rb_tree *tree)
+{
+ int count = 0;
+ recurse_tree (tree->root.link[0], &count, INT_MIN, INT_MAX);
+ if (count != tree->count)
+ {
+ printf (" Tree has %d nodes, but tree count is %d.\n",
+ count, tree->count);
+ done = 1;
+ }
+ if (done)
+ abort ();
+}
+
+/* Arrange the N elements of ARRAY in random order. */
+void
+shuffle (int *array, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ int j = i + rand () % (n - i);
+ int t = array[j];
+ array[j] = array[i];
+ array[i] = t;
+ }
+}
+
+/* Compares red-black trees rooted at A and B, making sure that they
+ are identical. */
+void
+compare_trees (rb_node *a, rb_node *b)
+{
+ if (a == NULL || b == NULL)
+ {
+ assert (a == NULL && b == NULL);
+ return;
+ }
+ if (a->data != b->data || a->color != b->color
+ || ((a->link[0] != NULL) ^ (b->link[0] != NULL))
+ || ((a->link[1] != NULL) ^ (b->link[1] != NULL)))
+ {
+ printf (" Copied nodes differ: %d b=%d a->color=%d b->color=%d a:",
+ (int) a->data, (int) b->data, a->color, b->color);
+ if (a->link[0])
+ printf ("l");
+ if (a->link[1])
+ printf ("r");
+ printf (" b:");
+ if (b->link[0])
+ printf ("l");
+ if (b->link[1])
+ printf ("r");
+ printf ("\n");
+ abort ();
+ }
+ if (a->link[0] != NULL)
+ compare_trees (a->link[0], b->link[0]);
+ if (a->link[1] != NULL)
+ compare_trees (a->link[1], b->link[1]);
+}
+
+/* Simple stress test procedure for the red-black tree routines. Does
+ the following:
+
+ * Generate a random number seed. By default this is generated from
+ the current time. You can also pass a seed value on the command
+ line if you want to test the same case. The seed value is
+ displayed.
+
+ * Create a tree and insert the integers from 0 up to TREE_SIZE - 1
+ into it, in random order. Verify the tree structure after each
+ insertion.
+
+ * Remove each integer from the tree, in a different random order.
+ After each deletion, verify the tree structure; also, make a copy
+ of the tree into a new tree, verify the copy and compare it to the
+ original, then destroy the copy.
+
+ * Destroy the tree, increment the random seed value, and start over.
+
+ If you make any modifications to the red-black tree routines, then
+ you might want to insert some calls to print_structure() at
+ strategic places in order to be able to see what's really going on.
+ Also, memory debuggers like Checker or Purify are very handy. */
+#define TREE_SIZE 16
+#define N_ITERATIONS 1024
+int
+main (int argc, char **argv)
+{
+ int array[TREE_SIZE];
+ int seed;
+ int iteration;
+
+ if (argc == 2)
+ seed = atoi (argv[1]);
+ else
+ seed = time (0) * 257 % 32768;
+
+ fputs ("Testing rb...\n", stdout);
+
+ for (iteration = 1; iteration <= N_ITERATIONS; iteration++)
+ {
+ rb_tree *tree;
+ int i;
+
+ printf ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed);
+ fflush (stdout);
+
+ srand (seed++);
+
+ for (i = 0; i < TREE_SIZE; i++)
+ array[i] = i;
+ shuffle (array, TREE_SIZE);
+
+ tree = rb_create (compare_ints, NULL);
+ for (i = 0; i < TREE_SIZE; i++)
+ rb_force_insert (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ shuffle (array, TREE_SIZE);
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ rb_tree *copy;
+
+ rb_delete (tree, (void *) (array[i]));
+ verify_tree (tree);
+
+ copy = rb_copy (tree, NULL);
+ verify_tree (copy);
+ compare_trees (tree->root.link[0], copy->root.link[0]);
+ rb_destroy (copy, NULL);
+
+ if (i % 128 == 0)
+ {
+ putchar ('.');
+ fflush (stdout);
+ }
+ }
+ fputs (" good.\n", stdout);
+
+ rb_destroy (tree, NULL);
+ }
+
+ return 0;
+}
+#endif /* SELF_TEST */
+
+/*
+ Local variables:
+ compile-command: "gcc -DSELF_TEST=1 -W -Wall -I. -o ./rb-test rb.c"
+ End:
+*/
diff --git a/avl-1.4.0/rb.h b/avl-1.4.0/rb.h
new file mode 100644
index 0000000..26a9f49
--- /dev/null
+++ b/avl-1.4.0/rb.h
@@ -0,0 +1,155 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file rb.h in libavl. */
+
+#if !rb_h
+#define rb_h 1
+
+/* The default maximum height of 32 allows for red-black trees having
+ between 65,535 and 4,294,967,295 nodes, depending on order of
+ insertion. You may change this compile-time constant as you
+ wish. */
+#ifndef RB_MAX_HEIGHT
+#define RB_MAX_HEIGHT 32
+#endif
+
+/* Node colors. */
+enum
+ {
+ RB_BLACK,
+ RB_RED,
+ };
+
+/* Structure for a node in a red-black tree. */
+typedef struct rb_node
+ {
+ void *data; /* Pointer to data. */
+ struct rb_node *link[2]; /* Subtrees. */
+ signed char color; /* Color. */
+ char cache; /* Used during insertion. */
+ signed char pad[2]; /* Unused. Reserved for threaded trees. */
+ }
+rb_node;
+
+/* Used for traversing a red-black tree. */
+typedef struct rb_traverser
+ {
+ int init; /* Initialized? */
+ int nstack; /* Top of stack. */
+ const rb_node *p; /* Used for traversal. */
+ const rb_node *stack[RB_MAX_HEIGHT];/* Descended trees. */
+ }
+rb_traverser;
+
+/* Initializer for rb_traverser. */
+#define RB_TRAVERSER_INIT {0}
+
+/* Function types. */
+#if !AVL_FUNC_TYPES
+#define AVL_FUNC_TYPES 1
+typedef int (*avl_comparison_func) (const void *a, const void *b, void *param);
+typedef void (*avl_node_func) (void *data, void *param);
+typedef void *(*avl_copy_func) (void *data, void *param);
+#endif
+
+/* Structure which holds information about a red-black tree. */
+typedef struct rb_tree
+ {
+#if PSPP
+ struct arena **owner; /* Arena to store nodes. */
+#endif
+ rb_node root; /* Tree root node. */
+ avl_comparison_func cmp; /* Used to compare keys. */
+ int count; /* Number of nodes in the tree. */
+ void *param; /* Arbitary user data. */
+ }
+rb_tree;
+
+#if PSPP
+#define MAYBE_ARENA struct arena **owner,
+#else
+#define MAYBE_ARENA /* nothing */
+#endif
+
+/* General functions. */
+rb_tree *rb_create (MAYBE_ARENA avl_comparison_func, void *param);
+void rb_destroy (rb_tree *, avl_node_func);
+void rb_free (rb_tree *);
+int rb_count (const rb_tree *);
+rb_tree *rb_copy (MAYBE_ARENA const rb_tree *, avl_copy_func);
+
+/* Walk the tree. */
+void rb_walk (const rb_tree *, avl_node_func, void *param);
+void *rb_traverse (const rb_tree *, rb_traverser *);
+#define rb_init_traverser(TRAVERSER) ((TRAVERSER)->init = 0)
+
+/* Search for a given item. */
+void **rb_probe (rb_tree *, void *);
+void *rb_delete (rb_tree *, const void *);
+void *rb_find (const rb_tree *, const void *);
+void *rb_find_close (const rb_tree *, const void *);
+
+#if __GCC__ >= 2
+extern inline void *
+rb_insert (rb_tree *tree, void *item)
+{
+ void **p = rb_probe (tree, item);
+ return (*p == item) ? NULL : *p;
+}
+
+extern inline void *
+rb_replace (rb_tree *tree, void *item)
+{
+ void **p = rb_probe (tree, item);
+ if (*p == item)
+ return NULL;
+ else
+ {
+ void *r = *p;
+ *p = item;
+ return r;
+ }
+}
+#else /* not gcc */
+void *rb_insert (rb_tree *tree, void *item);
+void *rb_replace (rb_tree *tree, void *item);
+#endif /* not gcc */
+
+/* Easy assertions on insertion & deletion. */
+#ifndef NDEBUG
+#define rb_force_insert(A, B) \
+ do \
+ { \
+ void *r = rb_insert (A, B); \
+ assert (r == NULL); \
+ } \
+ while (0)
+void *rb_force_delete (rb_tree *, void *);
+#else
+#define rb_force_insert(A, B) \
+ rb_insert (A, B)
+#define rb_force_delete(A, B) \
+ rb_delete (A, B)
+#endif
+
+#endif /* rb_h */
diff --git a/avl-1.4.0/texinfo.tex b/avl-1.4.0/texinfo.tex
new file mode 100644
index 0000000..aa52853
--- /dev/null
+++ b/avl-1.4.0/texinfo.tex
@@ -0,0 +1,5484 @@
+% texinfo.tex -- TeX macros to handle Texinfo files.
+%
+% Load plain if necessary, i.e., if running under initex.
+\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
+%
+\def\texinfoversion{1999-01-05}%
+%
+% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98
+% Free Software Foundation, Inc.
+%
+% This texinfo.tex file is free software; you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2, or (at
+% your option) any later version.
+%
+% This texinfo.tex file is distributed in the hope that it will be
+% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+% General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this texinfo.tex file; see the file COPYING. If not, write
+% to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+% Boston, MA 02111-1307, USA.
+%
+% In other words, you are welcome to use, share and improve this program.
+% You are forbidden to forbid anyone else to use, share and improve
+% what you give them. Help stamp out software-hoarding!
+%
+% Please try the latest version of texinfo.tex before submitting bug
+% reports; you can get the latest version from:
+% ftp://ftp.gnu.org/pub/gnu/texinfo.tex
+% /home/gd/gnu/doc/texinfo.tex on the GNU machines.
+% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
+% ftp://tug.org/tex/texinfo.tex
+% ftp://ctan.org/macros/texinfo/texinfo.tex
+% (and all CTAN mirrors, finger ctan@ctan.org for a list).
+% The texinfo.tex in the texinfo distribution itself could well be out
+% of date, so if that's what you're using, please check.
+%
+% Send bug reports to bug-texinfo@gnu.org.
+% Please include a precise test case in each bug report,
+% including a complete document with which we can reproduce the problem.
+%
+% To process a Texinfo manual with TeX, it's most reliable to use the
+% texi2dvi shell script that comes with the distribution. For simple
+% manuals, however, you can get away with:
+% tex foo.texi
+% texindex foo.??
+% tex foo.texi
+% tex foo.texi
+% dvips foo.dvi -o # or whatever, to process the dvi file.
+% The extra runs of TeX get the cross-reference information correct.
+% Sometimes one run after texindex suffices, and sometimes you need more
+% than two; texi2dvi does it as many times as necessary.
+
+\message{Loading texinfo [version \texinfoversion]:}
+
+% If in a .fmt file, print the version number
+% and turn on active characters that we couldn't do earlier because
+% they might have appeared in the input file name.
+\everyjob{\message{[Texinfo version \texinfoversion]}%
+ \catcode`+=\active \catcode`\_=\active}
+
+% Save some parts of plain tex whose names we will redefine.
+
+\let\ptexb=\b
+\let\ptexbullet=\bullet
+\let\ptexc=\c
+\let\ptexcomma=\,
+\let\ptexdot=\.
+\let\ptexdots=\dots
+\let\ptexend=\end
+\let\ptexequiv=\equiv
+\let\ptexexclam=\!
+\let\ptexi=\i
+\let\ptexlbrace=\{
+\let\ptexrbrace=\}
+\let\ptexstar=\*
+\let\ptext=\t
+
+% We never want plain's outer \+ definition in Texinfo.
+% For @tex, we can use \tabalign.
+\let\+ = \relax
+
+
+\message{Basics,}
+\chardef\other=12
+
+% If this character appears in an error message or help string, it
+% starts a new line in the output.
+\newlinechar = `^^J
+
+% Set up fixed words for English if not already set.
+\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
+\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
+\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
+\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
+\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
+\ifx\putwordon\undefined \gdef\putwordon{on}\fi
+\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
+\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
+\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
+\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
+\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
+\ifx\putwordShortContents\undefined \gdef\putwordShortContents{Short Contents}\fi
+\ifx\putwordTableofContents\undefined\gdef\putwordTableofContents{Table of Contents}\fi
+
+% Ignore a token.
+%
+\def\gobble#1{}
+
+\hyphenation{ap-pen-dix}
+\hyphenation{mini-buf-fer mini-buf-fers}
+\hyphenation{eshell}
+\hyphenation{white-space}
+
+% Margin to add to right of even pages, to left of odd pages.
+\newdimen \bindingoffset
+\newdimen \normaloffset
+\newdimen\pagewidth \newdimen\pageheight
+
+% Sometimes it is convenient to have everything in the transcript file
+% and nothing on the terminal. We don't just call \tracingall here,
+% since that produces some useless output on the terminal.
+%
+\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
+\ifx\eTeXversion\undefined
+\def\loggingall{\tracingcommands2 \tracingstats2
+ \tracingpages1 \tracingoutput1 \tracinglostchars1
+ \tracingmacros2 \tracingparagraphs1 \tracingrestores1
+ \showboxbreadth\maxdimen\showboxdepth\maxdimen
+}%
+\else
+\def\loggingall{\tracingcommands3 \tracingstats2
+ \tracingpages1 \tracingoutput1 \tracinglostchars1
+ \tracingmacros2 \tracingparagraphs1 \tracingrestores1
+ \tracingscantokens1 \tracingassigns1 \tracingifs1
+ \tracinggroups1 \tracingnesting2
+ \showboxbreadth\maxdimen\showboxdepth\maxdimen
+}%
+\fi
+
+% For @cropmarks command.
+% Do @cropmarks to get crop marks.
+%
+\newif\ifcropmarks
+\let\cropmarks = \cropmarkstrue
+%
+% Dimensions to add cropmarks at corners.
+% Added by P. A. MacKay, 12 Nov. 1986
+%
+\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
+\newdimen\cornerlong \cornerlong=1pc
+\newdimen\cornerthick \cornerthick=.3pt
+\newdimen\topandbottommargin \topandbottommargin=.75in
+
+% Main output routine.
+\chardef\PAGE = 255
+\output = {\onepageout{\pagecontents\PAGE}}
+
+\newbox\headlinebox
+\newbox\footlinebox
+
+% \onepageout takes a vbox as an argument. Note that \pagecontents
+% does insertions, but you have to call it yourself.
+\def\onepageout#1{%
+ \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
+ %
+ \ifodd\pageno \advance\hoffset by \bindingoffset
+ \else \advance\hoffset by -\bindingoffset\fi
+ %
+ % Do this outside of the \shipout so @code etc. will be expanded in
+ % the headline as they should be, not taken literally (outputting ''code).
+ \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
+ \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
+ %
+ {%
+ % Have to do this stuff outside the \shipout because we want it to
+ % take effect in \write's, yet the group defined by the \vbox ends
+ % before the \shipout runs.
+ %
+ \escapechar = `\\ % use backslash in output files.
+ \indexdummies % don't expand commands in the output.
+ \normalturnoffactive % \ in index entries must not stay \, e.g., if
+ % the page break happens to be in the middle of an example.
+ \shipout\vbox{%
+ \ifcropmarks \vbox to \outervsize\bgroup
+ \hsize = \outerhsize
+ \vskip-\topandbottommargin
+ \vtop to0pt{%
+ \line{\ewtop\hfil\ewtop}%
+ \nointerlineskip
+ \line{%
+ \vbox{\moveleft\cornerthick\nstop}%
+ \hfill
+ \vbox{\moveright\cornerthick\nstop}%
+ }%
+ \vss}%
+ \vskip\topandbottommargin
+ \line\bgroup
+ \hfil % center the page within the outer (page) hsize.
+ \ifodd\pageno\hskip\bindingoffset\fi
+ \vbox\bgroup
+ \fi
+ %
+ \unvbox\headlinebox
+ \pagebody{#1}%
+ \ifdim\ht\footlinebox > 0pt
+ % Only leave this space if the footline is nonempty.
+ % (We lessened \vsize for it in \oddfootingxxx.)
+ % The \baselineskip=24pt in plain's \makefootline has no effect.
+ \vskip 2\baselineskip
+ \unvbox\footlinebox
+ \fi
+ %
+ \ifcropmarks
+ \egroup % end of \vbox\bgroup
+ \hfil\egroup % end of (centering) \line\bgroup
+ \vskip\topandbottommargin plus1fill minus1fill
+ \boxmaxdepth = \cornerthick
+ \vbox to0pt{\vss
+ \line{%
+ \vbox{\moveleft\cornerthick\nsbot}%
+ \hfill
+ \vbox{\moveright\cornerthick\nsbot}%
+ }%
+ \nointerlineskip
+ \line{\ewbot\hfil\ewbot}%
+ }%
+ \egroup % \vbox from first cropmarks clause
+ \fi
+ }% end of \shipout\vbox
+ }% end of group with \turnoffactive
+ \advancepageno
+ \ifnum\outputpenalty>-20000 \else\dosupereject\fi
+}
+
+\newinsert\margin \dimen\margin=\maxdimen
+
+\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
+{\catcode`\@ =11
+\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
+% marginal hacks, juha@viisa.uucp (Juha Takala)
+\ifvoid\margin\else % marginal info is present
+ \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
+\dimen@=\dp#1 \unvbox#1
+\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
+\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
+}
+
+% Here are the rules for the cropmarks. Note that they are
+% offset so that the space between them is truly \outerhsize or \outervsize
+% (P. A. MacKay, 12 November, 1986)
+%
+\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
+\def\nstop{\vbox
+ {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
+\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
+\def\nsbot{\vbox
+ {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
+
+% Parse an argument, then pass it to #1. The argument is the rest of
+% the input line (except we remove a trailing comment). #1 should be a
+% macro which expects an ordinary undelimited TeX argument.
+%
+\def\parsearg#1{%
+ \let\next = #1%
+ \begingroup
+ \obeylines
+ \futurelet\temp\parseargx
+}
+
+% If the next token is an obeyed space (from an @example environment or
+% the like), remove it and recurse. Otherwise, we're done.
+\def\parseargx{%
+ % \obeyedspace is defined far below, after the definition of \sepspaces.
+ \ifx\obeyedspace\temp
+ \expandafter\parseargdiscardspace
+ \else
+ \expandafter\parseargline
+ \fi
+}
+
+% Remove a single space (as the delimiter token to the macro call).
+{\obeyspaces %
+ \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
+
+{\obeylines %
+ \gdef\parseargline#1^^M{%
+ \endgroup % End of the group started in \parsearg.
+ %
+ % First remove any @c comment, then any @comment.
+ % Result of each macro is put in \toks0.
+ \argremovec #1\c\relax %
+ \expandafter\argremovecomment \the\toks0 \comment\relax %
+ %
+ % Call the caller's macro, saved as \next in \parsearg.
+ \expandafter\next\expandafter{\the\toks0}%
+ }%
+}
+
+% Since all \c{,omment} does is throw away the argument, we can let TeX
+% do that for us. The \relax here is matched by the \relax in the call
+% in \parseargline; it could be more or less anything, its purpose is
+% just to delimit the argument to the \c.
+\def\argremovec#1\c#2\relax{\toks0 = {#1}}
+\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
+
+% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
+% @end itemize @c foo
+% will have two active spaces as part of the argument with the
+% `itemize'. Here we remove all active spaces from #1, and assign the
+% result to \toks0.
+%
+% This loses if there are any *other* active characters besides spaces
+% in the argument -- _ ^ +, for example -- since they get expanded.
+% Fortunately, Texinfo does not define any such commands. (If it ever
+% does, the catcode of the characters in questionwill have to be changed
+% here.) But this means we cannot call \removeactivespaces as part of
+% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
+% that \parsearg gets might well have any character at all in it.
+%
+\def\removeactivespaces#1{%
+ \begingroup
+ \ignoreactivespaces
+ \edef\temp{#1}%
+ \global\toks0 = \expandafter{\temp}%
+ \endgroup
+}
+
+% Change the active space to expand to nothing.
+%
+\begingroup
+ \obeyspaces
+ \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
+\endgroup
+
+
+\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
+
+%% These are used to keep @begin/@end levels from running away
+%% Call \inENV within environments (after a \begingroup)
+\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
+\def\ENVcheck{%
+\ifENV\errmessage{Still within an environment; press RETURN to continue}
+\endgroup\fi} % This is not perfect, but it should reduce lossage
+
+% @begin foo is the same as @foo, for now.
+\newhelp\EMsimple{Press RETURN to continue.}
+
+\outer\def\begin{\parsearg\beginxxx}
+
+\def\beginxxx #1{%
+\expandafter\ifx\csname #1\endcsname\relax
+{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
+\csname #1\endcsname\fi}
+
+% @end foo executes the definition of \Efoo.
+%
+\def\end{\parsearg\endxxx}
+\def\endxxx #1{%
+ \removeactivespaces{#1}%
+ \edef\endthing{\the\toks0}%
+ %
+ \expandafter\ifx\csname E\endthing\endcsname\relax
+ \expandafter\ifx\csname \endthing\endcsname\relax
+ % There's no \foo, i.e., no ``environment'' foo.
+ \errhelp = \EMsimple
+ \errmessage{Undefined command `@end \endthing'}%
+ \else
+ \unmatchedenderror\endthing
+ \fi
+ \else
+ % Everything's ok; the right environment has been started.
+ \csname E\endthing\endcsname
+ \fi
+}
+
+% There is an environment #1, but it hasn't been started. Give an error.
+%
+\def\unmatchedenderror#1{%
+ \errhelp = \EMsimple
+ \errmessage{This `@end #1' doesn't have a matching `@#1'}%
+}
+
+% Define the control sequence \E#1 to give an unmatched @end error.
+%
+\def\defineunmatchedend#1{%
+ \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
+}
+
+
+% Single-spacing is done by various environments (specifically, in
+% \nonfillstart and \quotations).
+\newskip\singlespaceskip \singlespaceskip = 12.5pt
+\def\singlespace{%
+ % Why was this kern here? It messes up equalizing space above and below
+ % environments. --karl, 6may93
+ %{\advance \baselineskip by -\singlespaceskip
+ %\kern \baselineskip}%
+ \setleading \singlespaceskip
+}
+
+%% Simple single-character @ commands
+
+% @@ prints an @
+% Kludge this until the fonts are right (grr).
+\def\@{{\tt\char64}}
+
+% This is turned off because it was never documented
+% and you can use @w{...} around a quote to suppress ligatures.
+%% Define @` and @' to be the same as ` and '
+%% but suppressing ligatures.
+%\def\`{{`}}
+%\def\'{{'}}
+
+% Used to generate quoted braces.
+\def\mylbrace {{\tt\char123}}
+\def\myrbrace {{\tt\char125}}
+\let\{=\mylbrace
+\let\}=\myrbrace
+\begingroup
+ % Definitions to produce actual \{ & \} command in an index.
+ \catcode`\{ = 12 \catcode`\} = 12
+ \catcode`\[ = 1 \catcode`\] = 2
+ \catcode`\@ = 0 \catcode`\\ = 12
+ @gdef@lbracecmd[\{]%
+ @gdef@rbracecmd[\}]%
+@endgroup
+
+% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
+% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
+\let\, = \c
+\let\dotaccent = \.
+\def\ringaccent#1{{\accent23 #1}}
+\let\tieaccent = \t
+\let\ubaraccent = \b
+\let\udotaccent = \d
+
+% Other special characters: @questiondown @exclamdown
+% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
+\def\questiondown{?`}
+\def\exclamdown{!`}
+
+% Dotless i and dotless j, used for accents.
+\def\imacro{i}
+\def\jmacro{j}
+\def\dotless#1{%
+ \def\temp{#1}%
+ \ifx\temp\imacro \ptexi
+ \else\ifx\temp\jmacro \j
+ \else \errmessage{@dotless can be used only with i or j}%
+ \fi\fi
+}
+
+% Be sure we're in horizontal mode when doing a tie, since we make space
+% equivalent to this in @example-like environments. Otherwise, a space
+% at the beginning of a line will start with \penalty -- and
+% since \penalty is valid in vertical mode, we'd end up putting the
+% penalty on the vertical list instead of in the new paragraph.
+{\catcode`@ = 11
+ % Avoid using \@M directly, because that causes trouble
+ % if the definition is written into an index file.
+ \global\let\tiepenalty = \@M
+ \gdef\tie{\leavevmode\penalty\tiepenalty\ }
+}
+
+% @: forces normal size whitespace following.
+\def\:{\spacefactor=1000 }
+
+% @* forces a line break.
+\def\*{\hfil\break\hbox{}\ignorespaces}
+
+% @. is an end-of-sentence period.
+\def\.{.\spacefactor=3000 }
+
+% @! is an end-of-sentence bang.
+\def\!{!\spacefactor=3000 }
+
+% @? is an end-of-sentence query.
+\def\?{?\spacefactor=3000 }
+
+% @w prevents a word break. Without the \leavevmode, @w at the
+% beginning of a paragraph, when TeX is still in vertical mode, would
+% produce a whole line of output instead of starting the paragraph.
+\def\w#1{\leavevmode\hbox{#1}}
+
+% @group ... @end group forces ... to be all on one page, by enclosing
+% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
+% to keep its height that of a normal line. According to the rules for
+% \topskip (p.114 of the TeXbook), the glue inserted is
+% max (\topskip - \ht (first item), 0). If that height is large,
+% therefore, no glue is inserted, and the space between the headline and
+% the text is small, which looks bad.
+%
+\def\group{\begingroup
+ \ifnum\catcode13=\active \else
+ \errhelp = \groupinvalidhelp
+ \errmessage{@group invalid in context where filling is enabled}%
+ \fi
+ %
+ % The \vtop we start below produces a box with normal height and large
+ % depth; thus, TeX puts \baselineskip glue before it, and (when the
+ % next line of text is done) \lineskip glue after it. (See p.82 of
+ % the TeXbook.) Thus, space below is not quite equal to space
+ % above. But it's pretty close.
+ \def\Egroup{%
+ \egroup % End the \vtop.
+ \endgroup % End the \group.
+ }%
+ %
+ \vtop\bgroup
+ % We have to put a strut on the last line in case the @group is in
+ % the midst of an example, rather than completely enclosing it.
+ % Otherwise, the interline space between the last line of the group
+ % and the first line afterwards is too small. But we can't put the
+ % strut in \Egroup, since there it would be on a line by itself.
+ % Hence this just inserts a strut at the beginning of each line.
+ \everypar = {\strut}%
+ %
+ % Since we have a strut on every line, we don't need any of TeX's
+ % normal interline spacing.
+ \offinterlineskip
+ %
+ % OK, but now we have to do something about blank
+ % lines in the input in @example-like environments, which normally
+ % just turn into \lisppar, which will insert no space now that we've
+ % turned off the interline space. Simplest is to make them be an
+ % empty paragraph.
+ \ifx\par\lisppar
+ \edef\par{\leavevmode \par}%
+ %
+ % Reset ^^M's definition to new definition of \par.
+ \obeylines
+ \fi
+ %
+ % Do @comment since we are called inside an environment such as
+ % @example, where each end-of-line in the input causes an
+ % end-of-line in the output. We don't want the end-of-line after
+ % the `@group' to put extra space in the output. Since @group
+ % should appear on a line by itself (according to the Texinfo
+ % manual), we don't worry about eating any user text.
+ \comment
+}
+%
+% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
+% message, so this ends up printing `@group can only ...'.
+%
+\newhelp\groupinvalidhelp{%
+group can only be used in environments such as @example,^^J%
+where each line of input produces a line of output.}
+
+% @need space-in-mils
+% forces a page break if there is not space-in-mils remaining.
+
+\newdimen\mil \mil=0.001in
+
+\def\need{\parsearg\needx}
+
+% Old definition--didn't work.
+%\def\needx #1{\par %
+%% This method tries to make TeX break the page naturally
+%% if the depth of the box does not fit.
+%{\baselineskip=0pt%
+%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
+%\prevdepth=-1000pt
+%}}
+
+\def\needx#1{%
+ % Go into vertical mode, so we don't make a big box in the middle of a
+ % paragraph.
+ \par
+ %
+ % Don't add any leading before our big empty box, but allow a page
+ % break, since the best break might be right here.
+ \allowbreak
+ \nointerlineskip
+ \vtop to #1\mil{\vfil}%
+ %
+ % TeX does not even consider page breaks if a penalty added to the
+ % main vertical list is 10000 or more. But in order to see if the
+ % empty box we just added fits on the page, we must make it consider
+ % page breaks. On the other hand, we don't want to actually break the
+ % page after the empty box. So we use a penalty of 9999.
+ %
+ % There is an extremely small chance that TeX will actually break the
+ % page at this \penalty, if there are no other feasible breakpoints in
+ % sight. (If the user is using lots of big @group commands, which
+ % almost-but-not-quite fill up a page, TeX will have a hard time doing
+ % good page breaking, for example.) However, I could not construct an
+ % example where a page broke at this \penalty; if it happens in a real
+ % document, then we can reconsider our strategy.
+ \penalty9999
+ %
+ % Back up by the size of the box, whether we did a page break or not.
+ \kern -#1\mil
+ %
+ % Do not allow a page break right after this kern.
+ \nobreak
+}
+
+% @br forces paragraph break
+
+\let\br = \par
+
+% @dots{} output an ellipsis using the current font.
+% We do .5em per period so that it has the same spacing in a typewriter
+% font as three actual period characters.
+%
+\def\dots{%
+ \leavevmode
+ \hbox to 1.5em{%
+ \hskip 0pt plus 0.25fil minus 0.25fil
+ .\hss.\hss.%
+ \hskip 0pt plus 0.5fil minus 0.5fil
+ }%
+}
+
+% @enddots{} is an end-of-sentence ellipsis.
+%
+\def\enddots{%
+ \leavevmode
+ \hbox to 2em{%
+ \hskip 0pt plus 0.25fil minus 0.25fil
+ .\hss.\hss.\hss.%
+ \hskip 0pt plus 0.5fil minus 0.5fil
+ }%
+ \spacefactor=3000
+}
+
+
+% @page forces the start of a new page
+%
+\def\page{\par\vfill\supereject}
+
+% @exdent text....
+% outputs text on separate line in roman font, starting at standard page margin
+
+% This records the amount of indent in the innermost environment.
+% That's how much \exdent should take out.
+\newskip\exdentamount
+
+% This defn is used inside fill environments such as @defun.
+\def\exdent{\parsearg\exdentyyy}
+\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
+
+% This defn is used inside nofill environments such as @example.
+\def\nofillexdent{\parsearg\nofillexdentyyy}
+\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
+\leftline{\hskip\leftskip{\rm#1}}}}
+
+% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
+
+\def\inmargin#1{%
+\strut\vadjust{\nobreak\kern-\strutdepth
+ \vtop to \strutdepth{\baselineskip\strutdepth\vss
+ \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
+\newskip\inmarginspacing \inmarginspacing=1cm
+\def\strutdepth{\dp\strutbox}
+
+%\hbox{{\rm#1}}\hfil\break}}
+
+% @include file insert text of that file as input.
+% Allow normal characters that we make active in the argument (a file name).
+\def\include{\begingroup
+ \catcode`\\=12
+ \catcode`~=12
+ \catcode`^=12
+ \catcode`_=12
+ \catcode`|=12
+ \catcode`<=12
+ \catcode`>=12
+ \catcode`+=12
+ \parsearg\includezzz}
+% Restore active chars for included file.
+\def\includezzz#1{\endgroup\begingroup
+ % Read the included file in a group so nested @include's work.
+ \def\thisfile{#1}%
+ \input\thisfile
+\endgroup}
+
+\def\thisfile{}
+
+% @center line outputs that line, centered
+
+\def\center{\parsearg\centerzzz}
+\def\centerzzz #1{{\advance\hsize by -\leftskip
+\advance\hsize by -\rightskip
+\centerline{#1}}}
+
+% @sp n outputs n lines of vertical space
+
+\def\sp{\parsearg\spxxx}
+\def\spxxx #1{\vskip #1\baselineskip}
+
+% @comment ...line which is ignored...
+% @c is the same as @comment
+% @ignore ... @end ignore is another way to write a comment
+
+\def\comment{\begingroup \catcode`\^^M=\other%
+\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
+\commentxxx}
+{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
+
+\let\c=\comment
+
+% @paragraphindent is defined for the Info formatting commands only.
+\let\paragraphindent=\comment
+
+% Prevent errors for section commands.
+% Used in @ignore and in failing conditionals.
+\def\ignoresections{%
+\let\chapter=\relax
+\let\unnumbered=\relax
+\let\top=\relax
+\let\unnumberedsec=\relax
+\let\unnumberedsection=\relax
+\let\unnumberedsubsec=\relax
+\let\unnumberedsubsection=\relax
+\let\unnumberedsubsubsec=\relax
+\let\unnumberedsubsubsection=\relax
+\let\section=\relax
+\let\subsec=\relax
+\let\subsubsec=\relax
+\let\subsection=\relax
+\let\subsubsection=\relax
+\let\appendix=\relax
+\let\appendixsec=\relax
+\let\appendixsection=\relax
+\let\appendixsubsec=\relax
+\let\appendixsubsection=\relax
+\let\appendixsubsubsec=\relax
+\let\appendixsubsubsection=\relax
+\let\contents=\relax
+\let\smallbook=\relax
+\let\titlepage=\relax
+}
+
+% Used in nested conditionals, where we have to parse the Texinfo source
+% and so want to turn off most commands, in case they are used
+% incorrectly.
+%
+\def\ignoremorecommands{%
+ \let\defcodeindex = \relax
+ \let\defcv = \relax
+ \let\deffn = \relax
+ \let\deffnx = \relax
+ \let\defindex = \relax
+ \let\defivar = \relax
+ \let\defmac = \relax
+ \let\defmethod = \relax
+ \let\defop = \relax
+ \let\defopt = \relax
+ \let\defspec = \relax
+ \let\deftp = \relax
+ \let\deftypefn = \relax
+ \let\deftypefun = \relax
+ \let\deftypevar = \relax
+ \let\deftypevr = \relax
+ \let\defun = \relax
+ \let\defvar = \relax
+ \let\defvr = \relax
+ \let\ref = \relax
+ \let\xref = \relax
+ \let\printindex = \relax
+ \let\pxref = \relax
+ \let\settitle = \relax
+ \let\setchapternewpage = \relax
+ \let\setchapterstyle = \relax
+ \let\everyheading = \relax
+ \let\evenheading = \relax
+ \let\oddheading = \relax
+ \let\everyfooting = \relax
+ \let\evenfooting = \relax
+ \let\oddfooting = \relax
+ \let\headings = \relax
+ \let\include = \relax
+ \let\lowersections = \relax
+ \let\down = \relax
+ \let\raisesections = \relax
+ \let\up = \relax
+ \let\set = \relax
+ \let\clear = \relax
+ \let\item = \relax
+}
+
+% Ignore @ignore ... @end ignore.
+%
+\def\ignore{\doignore{ignore}}
+
+% Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
+%
+\def\ifinfo{\doignore{ifinfo}}
+\def\ifhtml{\doignore{ifhtml}}
+\def\ifnottex{\doignore{ifnottex}}
+\def\html{\doignore{html}}
+\def\menu{\doignore{menu}}
+\def\direntry{\doignore{direntry}}
+
+% @dircategory CATEGORY -- specify a category of the dir file
+% which this file should belong to. Ignore this in TeX.
+\let\dircategory = \comment
+
+% Ignore text until a line `@end #1'.
+%
+\def\doignore#1{\begingroup
+ % Don't complain about control sequences we have declared \outer.
+ \ignoresections
+ %
+ % Define a command to swallow text until we reach `@end #1'.
+ % This @ is a catcode 12 token (that is the normal catcode of @ in
+ % this texinfo.tex file). We change the catcode of @ below to match.
+ \long\def\doignoretext##1@end #1{\enddoignore}%
+ %
+ % Make sure that spaces turn into tokens that match what \doignoretext wants.
+ \catcode32 = 10
+ %
+ % Ignore braces, too, so mismatched braces don't cause trouble.
+ \catcode`\{ = 9
+ \catcode`\} = 9
+ %
+ % We must not have @c interpreted as a control sequence.
+ \catcode`\@ = 12
+ %
+ % Make the letter c a comment character so that the rest of the line
+ % will be ignored. This way, the document can have (for example)
+ % @c @end ifinfo
+ % and the @end ifinfo will be properly ignored.
+ % (We've just changed @ to catcode 12.)
+ \catcode`\c = 14
+ %
+ % And now expand that command.
+ \doignoretext
+}
+
+% What we do to finish off ignored text.
+%
+\def\enddoignore{\endgroup\ignorespaces}%
+
+\newif\ifwarnedobs\warnedobsfalse
+\def\obstexwarn{%
+ \ifwarnedobs\relax\else
+ % We need to warn folks that they may have trouble with TeX 3.0.
+ % This uses \immediate\write16 rather than \message to get newlines.
+ \immediate\write16{}
+ \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
+ \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
+ \immediate\write16{If you are running another version of TeX, relax.}
+ \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
+ \immediate\write16{ Then upgrade your TeX installation if you can.}
+ \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
+ \immediate\write16{If you are stuck with version 3.0, run the}
+ \immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
+ \immediate\write16{ to use a workaround.}
+ \immediate\write16{}
+ \global\warnedobstrue
+ \fi
+}
+
+% **In TeX 3.0, setting text in \nullfont hangs tex. For a
+% workaround (which requires the file ``dummy.tfm'' to be installed),
+% uncomment the following line:
+%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
+
+% Ignore text, except that we keep track of conditional commands for
+% purposes of nesting, up to an `@end #1' command.
+%
+\def\nestedignore#1{%
+ \obstexwarn
+ % We must actually expand the ignored text to look for the @end
+ % command, so that nested ignore constructs work. Thus, we put the
+ % text into a \vbox and then do nothing with the result. To minimize
+ % the change of memory overflow, we follow the approach outlined on
+ % page 401 of the TeXbook: make the current font be a dummy font.
+ %
+ \setbox0 = \vbox\bgroup
+ % Don't complain about control sequences we have declared \outer.
+ \ignoresections
+ %
+ % Define `@end #1' to end the box, which will in turn undefine the
+ % @end command again.
+ \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
+ %
+ % We are going to be parsing Texinfo commands. Most cause no
+ % trouble when they are used incorrectly, but some commands do
+ % complicated argument parsing or otherwise get confused, so we
+ % undefine them.
+ %
+ % We can't do anything about stray @-signs, unfortunately;
+ % they'll produce `undefined control sequence' errors.
+ \ignoremorecommands
+ %
+ % Set the current font to be \nullfont, a TeX primitive, and define
+ % all the font commands to also use \nullfont. We don't use
+ % dummy.tfm, as suggested in the TeXbook, because not all sites
+ % might have that installed. Therefore, math mode will still
+ % produce output, but that should be an extremely small amount of
+ % stuff compared to the main input.
+ %
+ \nullfont
+ \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont
+ \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont
+ \let\tensf = \nullfont
+ % Similarly for index fonts (mostly for their use in
+ % smallexample)
+ \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont
+ \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont
+ \let\indsf = \nullfont
+ %
+ % Don't complain when characters are missing from the fonts.
+ \tracinglostchars = 0
+ %
+ % Don't bother to do space factor calculations.
+ \frenchspacing
+ %
+ % Don't report underfull hboxes.
+ \hbadness = 10000
+ %
+ % Do minimal line-breaking.
+ \pretolerance = 10000
+ %
+ % Do not execute instructions in @tex
+ \def\tex{\doignore{tex}}%
+ % Do not execute macro definitions.
+ % `c' is a comment character, so the word `macro' will get cut off.
+ \def\macro{\doignore{ma}}%
+}
+
+% @set VAR sets the variable VAR to an empty value.
+% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
+%
+% Since we want to separate VAR from REST-OF-LINE (which might be
+% empty), we can't just use \parsearg; we have to insert a space of our
+% own to delimit the rest of the line, and then take it out again if we
+% didn't need it. Make sure the catcode of space is correct to avoid
+% losing inside @example, for instance.
+%
+\def\set{\begingroup\catcode` =10
+ \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
+ \parsearg\setxxx}
+\def\setxxx#1{\setyyy#1 \endsetyyy}
+\def\setyyy#1 #2\endsetyyy{%
+ \def\temp{#2}%
+ \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
+ \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
+ \fi
+ \endgroup
+}
+% Can't use \xdef to pre-expand #2 and save some time, since \temp or
+% \next or other control sequences that we've defined might get us into
+% an infinite loop. Consider `@set foo @cite{bar}'.
+\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
+
+% @clear VAR clears (i.e., unsets) the variable VAR.
+%
+\def\clear{\parsearg\clearxxx}
+\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
+
+% @value{foo} gets the text saved in variable foo.
+%
+{
+ \catcode`\_ = \active
+ %
+ % We might end up with active _ or - characters in the argument if
+ % we're called from @code, as @code{@value{foo-bar_}}. So \let any
+ % such active characters to their normal equivalents.
+ \gdef\value{\begingroup
+ \catcode`\-=12 \catcode`\_=12
+ \indexbreaks \let_\normalunderscore
+ \valuexxx}
+}
+\def\valuexxx#1{\expandablevalue{#1}\endgroup}
+
+% We have this subroutine so that we can handle at least some @value's
+% properly in indexes (we \let\value to this in \indexdummies). Ones
+% whose names contain - or _ still won't work, but we can't do anything
+% about that. The command has to be fully expandable, since the result
+% winds up in the index file. This means that if the variable's value
+% contains other Texinfo commands, it's almost certain it will fail
+% (although perhaps we could fix that with sufficient work to do a
+% one-level expansion on the result, instead of complete).
+%
+\def\expandablevalue#1{%
+ \expandafter\ifx\csname SET#1\endcsname\relax
+ {[No value for ``#1'']}%
+ \else
+ \csname SET#1\endcsname
+ \fi
+}
+
+% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
+% with @set.
+%
+\def\ifset{\parsearg\ifsetxxx}
+\def\ifsetxxx #1{%
+ \expandafter\ifx\csname SET#1\endcsname\relax
+ \expandafter\ifsetfail
+ \else
+ \expandafter\ifsetsucceed
+ \fi
+}
+\def\ifsetsucceed{\conditionalsucceed{ifset}}
+\def\ifsetfail{\nestedignore{ifset}}
+\defineunmatchedend{ifset}
+
+% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
+% defined with @set, or has been undefined with @clear.
+%
+\def\ifclear{\parsearg\ifclearxxx}
+\def\ifclearxxx #1{%
+ \expandafter\ifx\csname SET#1\endcsname\relax
+ \expandafter\ifclearsucceed
+ \else
+ \expandafter\ifclearfail
+ \fi
+}
+\def\ifclearsucceed{\conditionalsucceed{ifclear}}
+\def\ifclearfail{\nestedignore{ifclear}}
+\defineunmatchedend{ifclear}
+
+% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
+% following, through the first @end iftex (etc.). Make `@end iftex'
+% (etc.) valid only after an @iftex.
+%
+\def\iftex{\conditionalsucceed{iftex}}
+\def\ifnothtml{\conditionalsucceed{ifnothtml}}
+\def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
+\defineunmatchedend{iftex}
+\defineunmatchedend{ifnothtml}
+\defineunmatchedend{ifnotinfo}
+
+% We can't just want to start a group at @iftex (for example) and end it
+% at @end iftex, since then @set commands inside the conditional have no
+% effect (they'd get reverted at the end of the group). So we must
+% define \Eiftex to redefine itself to be its previous value. (We can't
+% just define it to fail again with an ``unmatched end'' error, since
+% the @ifset might be nested.)
+%
+\def\conditionalsucceed#1{%
+ \edef\temp{%
+ % Remember the current value of \E#1.
+ \let\nece{prevE#1} = \nece{E#1}%
+ %
+ % At the `@end #1', redefine \E#1 to be its previous value.
+ \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
+ }%
+ \temp
+}
+
+% We need to expand lots of \csname's, but we don't want to expand the
+% control sequences after we've constructed them.
+%
+\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
+
+% @asis just yields its argument. Used with @table, for example.
+%
+\def\asis#1{#1}
+
+% @math means output in math mode.
+% We don't use $'s directly in the definition of \math because control
+% sequences like \math are expanded when the toc file is written. Then,
+% we read the toc file back, the $'s will be normal characters (as they
+% should be, according to the definition of Texinfo). So we must use a
+% control sequence to switch into and out of math mode.
+%
+% This isn't quite enough for @math to work properly in indices, but it
+% seems unlikely it will ever be needed there.
+%
+\let\implicitmath = $
+\def\math#1{\implicitmath #1\implicitmath}
+
+% @bullet and @minus need the same treatment as @math, just above.
+\def\bullet{\implicitmath\ptexbullet\implicitmath}
+\def\minus{\implicitmath-\implicitmath}
+
+% @refill is a no-op.
+\let\refill=\relax
+
+% If working on a large document in chapters, it is convenient to
+% be able to disable indexing, cross-referencing, and contents, for test runs.
+% This is done with @novalidate (before @setfilename).
+%
+\newif\iflinks \linkstrue % by default we want the aux files.
+\let\novalidate = \linksfalse
+
+% @setfilename is done at the beginning of every texinfo file.
+% So open here the files we need to have open while reading the input.
+% This makes it possible to make a .fmt file for texinfo.
+\def\setfilename{%
+ \iflinks
+ \readauxfile
+ \fi % \openindices needs to do some work in any case.
+ \openindices
+ \fixbackslash % Turn off hack to swallow `\input texinfo'.
+ \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
+ %
+ % If texinfo.cnf is present on the system, read it.
+ % Useful for site-wide @afourpaper, etc.
+ % Just to be on the safe side, close the input stream before the \input.
+ \openin 1 texinfo.cnf
+ \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
+ \closein1
+ \temp
+ %
+ \comment % Ignore the actual filename.
+}
+
+% Called from \setfilename.
+%
+\def\openindices{%
+ \newindex{cp}%
+ \newcodeindex{fn}%
+ \newcodeindex{vr}%
+ \newcodeindex{tp}%
+ \newcodeindex{ky}%
+ \newcodeindex{pg}%
+}
+
+% @bye.
+\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
+
+
+\message{fonts,}
+% Font-change commands.
+
+% Texinfo sort of supports the sans serif font style, which plain TeX does not.
+% So we set up a \sf analogous to plain's \rm, etc.
+\newfam\sffam
+\def\sf{\fam=\sffam \tensf}
+\let\li = \sf % Sometimes we call it \li, not \sf.
+
+% We don't need math for this one.
+\def\ttsl{\tenttsl}
+
+% Use Computer Modern fonts at \magstephalf (11pt).
+\newcount\mainmagstep
+\mainmagstep=\magstephalf
+
+% Set the font macro #1 to the font named #2, adding on the
+% specified font prefix (normally `cm').
+% #3 is the font's design size, #4 is a scale factor
+\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
+
+% Use cm as the default font prefix.
+% To specify the font prefix, you must define \fontprefix
+% before you read in texinfo.tex.
+\ifx\fontprefix\undefined
+\def\fontprefix{cm}
+\fi
+% Support font families that don't use the same naming scheme as CM.
+\def\rmshape{r}
+\def\rmbshape{bx} %where the normal face is bold
+\def\bfshape{b}
+\def\bxshape{bx}
+\def\ttshape{tt}
+\def\ttbshape{tt}
+\def\ttslshape{sltt}
+\def\itshape{ti}
+\def\itbshape{bxti}
+\def\slshape{sl}
+\def\slbshape{bxsl}
+\def\sfshape{ss}
+\def\sfbshape{ss}
+\def\scshape{csc}
+\def\scbshape{csc}
+
+\ifx\bigger\relax
+\let\mainmagstep=\magstep1
+\setfont\textrm\rmshape{12}{1000}
+\setfont\texttt\ttshape{12}{1000}
+\else
+\setfont\textrm\rmshape{10}{\mainmagstep}
+\setfont\texttt\ttshape{10}{\mainmagstep}
+\fi
+% Instead of cmb10, you many want to use cmbx10.
+% cmbx10 is a prettier font on its own, but cmb10
+% looks better when embedded in a line with cmr10.
+\setfont\textbf\bfshape{10}{\mainmagstep}
+\setfont\textit\itshape{10}{\mainmagstep}
+\setfont\textsl\slshape{10}{\mainmagstep}
+\setfont\textsf\sfshape{10}{\mainmagstep}
+\setfont\textsc\scshape{10}{\mainmagstep}
+\setfont\textttsl\ttslshape{10}{\mainmagstep}
+\font\texti=cmmi10 scaled \mainmagstep
+\font\textsy=cmsy10 scaled \mainmagstep
+
+% A few fonts for @defun, etc.
+\setfont\defbf\bxshape{10}{\magstep1} %was 1314
+\setfont\deftt\ttshape{10}{\magstep1}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
+
+% Fonts for indices and small examples (9pt).
+% We actually use the slanted font rather than the italic,
+% because texinfo normally uses the slanted fonts for that.
+% Do not make many font distinctions in general in the index, since they
+% aren't very useful.
+\setfont\ninett\ttshape{9}{1000}
+\setfont\ninettsl\ttslshape{10}{900}
+\setfont\indrm\rmshape{9}{1000}
+\setfont\indit\itshape{9}{1000}
+\setfont\indsl\slshape{9}{1000}
+\let\indtt=\ninett
+\let\indttsl=\ninettsl
+\let\indsf=\indrm
+\let\indbf=\indrm
+\setfont\indsc\scshape{10}{900}
+\font\indi=cmmi9
+\font\indsy=cmsy9
+
+% Fonts for title page:
+\setfont\titlerm\rmbshape{12}{\magstep3}
+\setfont\titleit\itbshape{10}{\magstep4}
+\setfont\titlesl\slbshape{10}{\magstep4}
+\setfont\titlett\ttbshape{12}{\magstep3}
+\setfont\titlettsl\ttslshape{10}{\magstep4}
+\setfont\titlesf\sfbshape{17}{\magstep1}
+\let\titlebf=\titlerm
+\setfont\titlesc\scbshape{10}{\magstep4}
+\font\titlei=cmmi12 scaled \magstep3
+\font\titlesy=cmsy10 scaled \magstep4
+\def\authorrm{\secrm}
+
+% Chapter (and unnumbered) fonts (17.28pt).
+\setfont\chaprm\rmbshape{12}{\magstep2}
+\setfont\chapit\itbshape{10}{\magstep3}
+\setfont\chapsl\slbshape{10}{\magstep3}
+\setfont\chaptt\ttbshape{12}{\magstep2}
+\setfont\chapttsl\ttslshape{10}{\magstep3}
+\setfont\chapsf\sfbshape{17}{1000}
+\let\chapbf=\chaprm
+\setfont\chapsc\scbshape{10}{\magstep3}
+\font\chapi=cmmi12 scaled \magstep2
+\font\chapsy=cmsy10 scaled \magstep3
+
+% Section fonts (14.4pt).
+\setfont\secrm\rmbshape{12}{\magstep1}
+\setfont\secit\itbshape{10}{\magstep2}
+\setfont\secsl\slbshape{10}{\magstep2}
+\setfont\sectt\ttbshape{12}{\magstep1}
+\setfont\secttsl\ttslshape{10}{\magstep2}
+\setfont\secsf\sfbshape{12}{\magstep1}
+\let\secbf\secrm
+\setfont\secsc\scbshape{10}{\magstep2}
+\font\seci=cmmi12 scaled \magstep1
+\font\secsy=cmsy10 scaled \magstep2
+
+% \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad.
+% \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded.
+% \setfont\ssecsl\slshape{10}{\magstep1}
+% \setfont\ssectt\ttshape{10}{\magstep1}
+% \setfont\ssecsf\sfshape{10}{\magstep1}
+
+%\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx.
+%\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than
+%\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1.
+%\setfont\ssectt\ttshape{10}{1315}
+%\setfont\ssecsf\sfshape{10}{1315}
+
+%\let\ssecbf=\ssecrm
+
+% Subsection fonts (13.15pt).
+\setfont\ssecrm\rmbshape{12}{\magstephalf}
+\setfont\ssecit\itbshape{10}{1315}
+\setfont\ssecsl\slbshape{10}{1315}
+\setfont\ssectt\ttbshape{12}{\magstephalf}
+\setfont\ssecttsl\ttslshape{10}{1315}
+\setfont\ssecsf\sfbshape{12}{\magstephalf}
+\let\ssecbf\ssecrm
+\setfont\ssecsc\scbshape{10}{\magstep1}
+\font\sseci=cmmi12 scaled \magstephalf
+\font\ssecsy=cmsy10 scaled 1315
+% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
+% but that is not a standard magnification.
+
+% In order for the font changes to affect most math symbols and letters,
+% we have to define the \textfont of the standard families. Since
+% texinfo doesn't allow for producing subscripts and superscripts, we
+% don't bother to reset \scriptfont and \scriptscriptfont (which would
+% also require loading a lot more fonts).
+%
+\def\resetmathfonts{%
+ \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
+ \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
+ \textfont\ttfam = \tentt \textfont\sffam = \tensf
+}
+
+
+% The font-changing commands redefine the meanings of \tenSTYLE, instead
+% of just \STYLE. We do this so that font changes will continue to work
+% in math mode, where it is the current \fam that is relevant in most
+% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam
+% \tenbf}, for example. By redefining \tenbf, we obviate the need to
+% redefine \bf itself.
+\def\textfonts{%
+ \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
+ \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
+ \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
+ \resetmathfonts}
+\def\titlefonts{%
+ \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
+ \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
+ \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
+ \let\tenttsl=\titlettsl
+ \resetmathfonts \setleading{25pt}}
+\def\titlefont#1{{\titlefonts\rm #1}}
+\def\chapfonts{%
+ \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
+ \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
+ \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
+ \resetmathfonts \setleading{19pt}}
+\def\secfonts{%
+ \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
+ \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
+ \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
+ \resetmathfonts \setleading{16pt}}
+\def\subsecfonts{%
+ \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
+ \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
+ \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
+ \resetmathfonts \setleading{15pt}}
+\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
+\def\indexfonts{%
+ \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
+ \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
+ \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl
+ \resetmathfonts \setleading{12pt}}
+
+% Set up the default fonts, so we can use them for creating boxes.
+%
+\textfonts
+
+% Define these so they can be easily changed for other fonts.
+\def\angleleft{$\langle$}
+\def\angleright{$\rangle$}
+
+% Count depth in font-changes, for error checks
+\newcount\fontdepth \fontdepth=0
+
+% Fonts for short table of contents.
+\setfont\shortcontrm\rmshape{12}{1000}
+\setfont\shortcontbf\bxshape{12}{1000}
+\setfont\shortcontsl\slshape{12}{1000}
+
+%% Add scribe-like font environments, plus @l for inline lisp (usually sans
+%% serif) and @ii for TeX italic
+
+% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
+% unless the following character is such as not to need one.
+\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
+\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
+\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
+
+\let\i=\smartitalic
+\let\var=\smartslanted
+\let\dfn=\smartslanted
+\let\emph=\smartitalic
+\let\cite=\smartslanted
+
+\def\b#1{{\bf #1}}
+\let\strong=\b
+
+% We can't just use \exhyphenpenalty, because that only has effect at
+% the end of a paragraph. Restore normal hyphenation at the end of the
+% group within which \nohyphenation is presumably called.
+%
+\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
+\def\restorehyphenation{\hyphenchar\font = `- }
+
+\def\t#1{%
+ {\tt \rawbackslash \frenchspacing #1}%
+ \null
+}
+\let\ttfont=\t
+\def\samp#1{`\tclose{#1}'\null}
+\setfont\smallrm\rmshape{8}{1000}
+\font\smallsy=cmsy9
+\def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{%
+ \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
+ \vbox{\hrule\kern-0.4pt
+ \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
+ \kern-0.4pt\hrule}%
+ \kern-.06em\raise0.4pt\hbox{\angleright}}}}
+% The old definition, with no lozenge:
+%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
+\def\ctrl #1{{\tt \rawbackslash \hat}#1}
+
+% @file, @option are the same as @samp.
+\let\file=\samp
+\let\option=\samp
+
+% @code is a modification of @t,
+% which makes spaces the same size as normal in the surrounding text.
+\def\tclose#1{%
+ {%
+ % Change normal interword space to be same as for the current font.
+ \spaceskip = \fontdimen2\font
+ %
+ % Switch to typewriter.
+ \tt
+ %
+ % But `\ ' produces the large typewriter interword space.
+ \def\ {{\spaceskip = 0pt{} }}%
+ %
+ % Turn off hyphenation.
+ \nohyphenation
+ %
+ \rawbackslash
+ \frenchspacing
+ #1%
+ }%
+ \null
+}
+
+% We *must* turn on hyphenation at `-' and `_' in \code.
+% Otherwise, it is too hard to avoid overfull hboxes
+% in the Emacs manual, the Library manual, etc.
+
+% Unfortunately, TeX uses one parameter (\hyphenchar) to control
+% both hyphenation at - and hyphenation within words.
+% We must therefore turn them both off (\tclose does that)
+% and arrange explicitly to hyphenate at a dash.
+% -- rms.
+{
+ \catcode`\-=\active
+ \catcode`\_=\active
+ %
+ \global\def\code{\begingroup
+ \catcode`\-=\active \let-\codedash
+ \catcode`\_=\active \let_\codeunder
+ \codex
+ }
+ %
+ % If we end up with any active - characters when handling the index,
+ % just treat them as a normal -.
+ \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
+}
+
+\def\realdash{-}
+\def\codedash{-\discretionary{}{}{}}
+\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
+\def\codex #1{\tclose{#1}\endgroup}
+
+%\let\exp=\tclose %Was temporary
+
+% @kbd is like @code, except that if the argument is just one @key command,
+% then @kbd has no effect.
+
+% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
+% `example' (@kbd uses ttsl only inside of @example and friends),
+% or `code' (@kbd uses normal tty font always).
+\def\kbdinputstyle{\parsearg\kbdinputstylexxx}
+\def\kbdinputstylexxx#1{%
+ \def\arg{#1}%
+ \ifx\arg\worddistinct
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
+ \else\ifx\arg\wordexample
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
+ \else\ifx\arg\wordcode
+ \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+ \fi\fi\fi
+}
+\def\worddistinct{distinct}
+\def\wordexample{example}
+\def\wordcode{code}
+
+% Default is kbdinputdistinct. (Too much of a hassle to call the macro,
+% the catcodes are wrong for parsearg to work.)
+\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
+
+\def\xkey{\key}
+\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
+\ifx\one\xkey\ifx\threex\three \key{#2}%
+\else{\tclose{\kbdfont\look}}\fi
+\else{\tclose{\kbdfont\look}}\fi}
+
+% For @url, @env, @command quotes seem unnecessary, so use \code.
+\let\url=\code
+\let\env=\code
+\let\command=\code
+
+% @uref (abbreviation for `urlref') takes an optional second argument
+% specifying the text to display. First (mandatory) arg is the url.
+% Perhaps eventually put in a hypertex \special here.
+%
+\def\uref#1{\urefxxx #1,,\finish}
+\def\urefxxx#1,#2,#3\finish{%
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \unhbox0\ (\code{#1})%
+ \else
+ \code{#1}%
+ \fi
+}
+
+% rms does not like the angle brackets --karl, 17may97.
+% So now @email is just like @uref.
+%\def\email#1{\angleleft{\tt #1}\angleright}
+\let\email=\uref
+
+% Check if we are currently using a typewriter font. Since all the
+% Computer Modern typewriter fonts have zero interword stretch (and
+% shrink), and it is reasonable to expect all typewriter fonts to have
+% this property, we can check that font parameter.
+%
+\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
+
+% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
+% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
+%
+\def\dmn#1{\thinspace #1}
+
+\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
+
+% @l was never documented to mean ``switch to the Lisp font'',
+% and it is not used as such in any manual I can find. We need it for
+% Polish suppressed-l. --karl, 22sep96.
+%\def\l#1{{\li #1}\null}
+
+% Explicit font changes: @r, @sc, undocumented @ii.
+\def\r#1{{\rm #1}} % roman font
+\def\sc#1{{\smallcaps#1}} % smallcaps font
+\def\ii#1{{\it #1}} % italic font
+
+% @acronym downcases the argument and prints in smallcaps.
+\def\acronym#1{{\smallcaps \lowercase{#1}}}
+
+% @pounds{} is a sterling sign.
+\def\pounds{{\it\$}}
+
+
+\message{page headings,}
+
+\newskip\titlepagetopglue \titlepagetopglue = 1.5in
+\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
+
+% First the title page. Must do @settitle before @titlepage.
+\newif\ifseenauthor
+\newif\iffinishedtitlepage
+
+% Do an implicit @contents or @shortcontents after @end titlepage if the
+% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
+%
+\newif\ifsetcontentsaftertitlepage
+ \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
+\newif\ifsetshortcontentsaftertitlepage
+ \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
+
+\def\shorttitlepage{\parsearg\shorttitlepagezzz}
+\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
+ \endgroup\page\hbox{}\page}
+
+\def\titlepage{\begingroup \parindent=0pt \textfonts
+ \let\subtitlerm=\tenrm
+ \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
+ %
+ \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
+ %
+ % Leave some space at the very top of the page.
+ \vglue\titlepagetopglue
+ %
+ % Now you can print the title using @title.
+ \def\title{\parsearg\titlezzz}%
+ \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
+ % print a rule at the page bottom also.
+ \finishedtitlepagefalse
+ \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
+ % No rule at page bottom unless we print one at the top with @title.
+ \finishedtitlepagetrue
+ %
+ % Now you can put text using @subtitle.
+ \def\subtitle{\parsearg\subtitlezzz}%
+ \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
+ %
+ % @author should come last, but may come many times.
+ \def\author{\parsearg\authorzzz}%
+ \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
+ {\authorfont \leftline{##1}}}%
+ %
+ % Most title ``pages'' are actually two pages long, with space
+ % at the top of the second. We don't want the ragged left on the second.
+ \let\oldpage = \page
+ \def\page{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ \oldpage
+ \let\page = \oldpage
+ \hbox{}}%
+% \def\page{\oldpage \hbox{}}
+}
+
+\def\Etitlepage{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ % It is important to do the page break before ending the group,
+ % because the headline and footline are only empty inside the group.
+ % If we use the new definition of \page, we always get a blank page
+ % after the title page, which we certainly don't want.
+ \oldpage
+ \endgroup
+ %
+ % If they want short, they certainly want long too.
+ \ifsetshortcontentsaftertitlepage
+ \shortcontents
+ \contents
+ \global\let\shortcontents = \relax
+ \global\let\contents = \relax
+ \fi
+ %
+ \ifsetcontentsaftertitlepage
+ \contents
+ \global\let\contents = \relax
+ \global\let\shortcontents = \relax
+ \fi
+ %
+ \HEADINGSon
+}
+
+\def\finishtitlepage{%
+ \vskip4pt \hrule height 2pt width \hsize
+ \vskip\titlepagebottomglue
+ \finishedtitlepagetrue
+}
+
+%%% Set up page headings and footings.
+
+\let\thispage=\folio
+
+\newtoks\evenheadline % headline on even pages
+\newtoks\oddheadline % headline on odd pages
+\newtoks\evenfootline % footline on even pages
+\newtoks\oddfootline % footline on odd pages
+
+% Now make Tex use those variables
+\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
+ \else \the\evenheadline \fi}}
+\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
+ \else \the\evenfootline \fi}\HEADINGShook}
+\let\HEADINGShook=\relax
+
+% Commands to set those variables.
+% For example, this is what @headings on does
+% @evenheading @thistitle|@thispage|@thischapter
+% @oddheading @thischapter|@thispage|@thistitle
+% @evenfooting @thisfile||
+% @oddfooting ||@thisfile
+
+\def\evenheading{\parsearg\evenheadingxxx}
+\def\oddheading{\parsearg\oddheadingxxx}
+\def\everyheading{\parsearg\everyheadingxxx}
+
+\def\evenfooting{\parsearg\evenfootingxxx}
+\def\oddfooting{\parsearg\oddfootingxxx}
+\def\everyfooting{\parsearg\everyfootingxxx}
+
+{\catcode`\@=0 %
+
+\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
+\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
+\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
+\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
+\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
+
+\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
+\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
+\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
+\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
+ \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
+ %
+ % Leave some space for the footline. Hopefully ok to assume
+ % @evenfooting will not be used by itself.
+ \global\advance\pageheight by -\baselineskip
+ \global\advance\vsize by -\baselineskip
+}
+
+\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
+%
+}% unbind the catcode of @.
+
+% @headings double turns headings on for double-sided printing.
+% @headings single turns headings on for single-sided printing.
+% @headings off turns them off.
+% @headings on same as @headings double, retained for compatibility.
+% @headings after turns on double-sided headings after this page.
+% @headings doubleafter turns on double-sided headings after this page.
+% @headings singleafter turns on single-sided headings after this page.
+% By default, they are off at the start of a document,
+% and turned `on' after @end titlepage.
+
+\def\headings #1 {\csname HEADINGS#1\endcsname}
+
+\def\HEADINGSoff{
+\global\evenheadline={\hfil} \global\evenfootline={\hfil}
+\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
+\HEADINGSoff
+% When we turn headings on, set the page number to 1.
+% For double-sided printing, put current file name in lower left corner,
+% chapter name on inside top of right hand pages, document
+% title on inside top of left hand pages, and page numbers on outside top
+% edge of all pages.
+\def\HEADINGSdouble{
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+\let\contentsalignmacro = \chappager
+
+% For single-sided printing, chapter title goes across top left of page,
+% page number on top right.
+\def\HEADINGSsingle{
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+\def\HEADINGSon{\HEADINGSdouble}
+
+\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
+\let\HEADINGSdoubleafter=\HEADINGSafter
+\def\HEADINGSdoublex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+
+\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
+\def\HEADINGSsinglex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+
+% Subroutines used in generating headings
+% Produces Day Month Year style of output.
+\def\today{\number\day\space
+\ifcase\month\or
+January\or February\or March\or April\or May\or June\or
+July\or August\or September\or October\or November\or December\fi
+\space\number\year}
+
+% Use this if you want the Month Day, Year style of output.
+%\def\today{\ifcase\month\or
+%January\or February\or March\or April\or May\or June\or
+%July\or August\or September\or October\or November\or December\fi
+%\space\number\day, \number\year}
+
+% @settitle line... specifies the title of the document, for headings
+% It generates no output of its own
+
+\def\thistitle{No Title}
+\def\settitle{\parsearg\settitlezzz}
+\def\settitlezzz #1{\gdef\thistitle{#1}}
+
+
+\message{tables,}
+% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
+
+% default indentation of table text
+\newdimen\tableindent \tableindent=.8in
+% default indentation of @itemize and @enumerate text
+\newdimen\itemindent \itemindent=.3in
+% margin between end of table item and start of table text.
+\newdimen\itemmargin \itemmargin=.1in
+
+% used internally for \itemindent minus \itemmargin
+\newdimen\itemmax
+
+% Note @table, @vtable, and @vtable define @item, @itemx, etc., with
+% these defs.
+% They also define \itemindex
+% to index the item name in whatever manner is desired (perhaps none).
+
+\newif\ifitemxneedsnegativevskip
+
+\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
+
+\def\internalBitem{\smallbreak \parsearg\itemzzz}
+\def\internalBitemx{\itemxpar \parsearg\itemzzz}
+
+\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
+\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
+
+\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
+\def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
+
+\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
+ \itemzzz {#1}}
+
+\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
+ \itemzzz {#1}}
+
+\def\itemzzz #1{\begingroup %
+ \advance\hsize by -\rightskip
+ \advance\hsize by -\tableindent
+ \setbox0=\hbox{\itemfont{#1}}%
+ \itemindex{#1}%
+ \nobreak % This prevents a break before @itemx.
+ %
+ % If the item text does not fit in the space we have, put it on a line
+ % by itself, and do not allow a page break either before or after that
+ % line. We do not start a paragraph here because then if the next
+ % command is, e.g., @kindex, the whatsit would get put into the
+ % horizontal list on a line by itself, resulting in extra blank space.
+ \ifdim \wd0>\itemmax
+ %
+ % Make this a paragraph so we get the \parskip glue and wrapping,
+ % but leave it ragged-right.
+ \begingroup
+ \advance\leftskip by-\tableindent
+ \advance\hsize by\tableindent
+ \advance\rightskip by0pt plus1fil
+ \leavevmode\unhbox0\par
+ \endgroup
+ %
+ % We're going to be starting a paragraph, but we don't want the
+ % \parskip glue -- logically it's part of the @item we just started.
+ \nobreak \vskip-\parskip
+ %
+ % Stop a page break at the \parskip glue coming up. Unfortunately
+ % we can't prevent a possible page break at the following
+ % \baselineskip glue.
+ \nobreak
+ \endgroup
+ \itemxneedsnegativevskipfalse
+ \else
+ % The item text fits into the space. Start a paragraph, so that the
+ % following text (if any) will end up on the same line.
+ \noindent
+ % Do this with kerns and \unhbox so that if there is a footnote in
+ % the item text, it can migrate to the main vertical list and
+ % eventually be printed.
+ \nobreak\kern-\tableindent
+ \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
+ \unhbox0
+ \nobreak\kern\dimen0
+ \endgroup
+ \itemxneedsnegativevskiptrue
+ \fi
+}
+
+\def\item{\errmessage{@item while not in a table}}
+\def\itemx{\errmessage{@itemx while not in a table}}
+\def\kitem{\errmessage{@kitem while not in a table}}
+\def\kitemx{\errmessage{@kitemx while not in a table}}
+\def\xitem{\errmessage{@xitem while not in a table}}
+\def\xitemx{\errmessage{@xitemx while not in a table}}
+
+% Contains a kludge to get @end[description] to work.
+\def\description{\tablez{\dontindex}{1}{}{}{}{}}
+
+% @table, @ftable, @vtable.
+\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
+{\obeylines\obeyspaces%
+\gdef\tablex #1^^M{%
+\tabley\dontindex#1 \endtabley}}
+
+\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
+{\obeylines\obeyspaces%
+\gdef\ftablex #1^^M{%
+\tabley\fnitemindex#1 \endtabley
+\def\Eftable{\endgraf\afterenvbreak\endgroup}%
+\let\Etable=\relax}}
+
+\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
+{\obeylines\obeyspaces%
+\gdef\vtablex #1^^M{%
+\tabley\vritemindex#1 \endtabley
+\def\Evtable{\endgraf\afterenvbreak\endgroup}%
+\let\Etable=\relax}}
+
+\def\dontindex #1{}
+\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
+\def\vritemindex #1{\doind {vr}{\code{#1}}}%
+
+{\obeyspaces %
+\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
+\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
+
+\def\tablez #1#2#3#4#5#6{%
+\aboveenvbreak %
+\begingroup %
+\def\Edescription{\Etable}% Necessary kludge.
+\let\itemindex=#1%
+\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
+\ifnum 0#4>0 \tableindent=#4\mil \fi %
+\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
+\def\itemfont{#2}%
+\itemmax=\tableindent %
+\advance \itemmax by -\itemmargin %
+\advance \leftskip by \tableindent %
+\exdentamount=\tableindent
+\parindent = 0pt
+\parskip = \smallskipamount
+\ifdim \parskip=0pt \parskip=2pt \fi%
+\def\Etable{\endgraf\afterenvbreak\endgroup}%
+\let\item = \internalBitem %
+\let\itemx = \internalBitemx %
+\let\kitem = \internalBkitem %
+\let\kitemx = \internalBkitemx %
+\let\xitem = \internalBxitem %
+\let\xitemx = \internalBxitemx %
+}
+
+% This is the counter used by @enumerate, which is really @itemize
+
+\newcount \itemno
+
+\def\itemize{\parsearg\itemizezzz}
+
+\def\itemizezzz #1{%
+ \begingroup % ended by the @end itemize
+ \itemizey {#1}{\Eitemize}
+}
+
+\def\itemizey #1#2{%
+\aboveenvbreak %
+\itemmax=\itemindent %
+\advance \itemmax by -\itemmargin %
+\advance \leftskip by \itemindent %
+\exdentamount=\itemindent
+\parindent = 0pt %
+\parskip = \smallskipamount %
+\ifdim \parskip=0pt \parskip=2pt \fi%
+\def#2{\endgraf\afterenvbreak\endgroup}%
+\def\itemcontents{#1}%
+\let\item=\itemizeitem}
+
+% Set sfcode to normal for the chars that usually have another value.
+% These are `.?!:;,'
+\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
+ \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
+
+% \splitoff TOKENS\endmark defines \first to be the first token in
+% TOKENS, and \rest to be the remainder.
+%
+\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
+
+% Allow an optional argument of an uppercase letter, lowercase letter,
+% or number, to specify the first label in the enumerated list. No
+% argument is the same as `1'.
+%
+\def\enumerate{\parsearg\enumeratezzz}
+\def\enumeratezzz #1{\enumeratey #1 \endenumeratey}
+\def\enumeratey #1 #2\endenumeratey{%
+ \begingroup % ended by the @end enumerate
+ %
+ % If we were given no argument, pretend we were given `1'.
+ \def\thearg{#1}%
+ \ifx\thearg\empty \def\thearg{1}\fi
+ %
+ % Detect if the argument is a single token. If so, it might be a
+ % letter. Otherwise, the only valid thing it can be is a number.
+ % (We will always have one token, because of the test we just made.
+ % This is a good thing, since \splitoff doesn't work given nothing at
+ % all -- the first parameter is undelimited.)
+ \expandafter\splitoff\thearg\endmark
+ \ifx\rest\empty
+ % Only one token in the argument. It could still be anything.
+ % A ``lowercase letter'' is one whose \lccode is nonzero.
+ % An ``uppercase letter'' is one whose \lccode is both nonzero, and
+ % not equal to itself.
+ % Otherwise, we assume it's a number.
+ %
+ % We need the \relax at the end of the \ifnum lines to stop TeX from
+ % continuing to look for a .
+ %
+ \ifnum\lccode\expandafter`\thearg=0\relax
+ \numericenumerate % a number (we hope)
+ \else
+ % It's a letter.
+ \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
+ \lowercaseenumerate % lowercase letter
+ \else
+ \uppercaseenumerate % uppercase letter
+ \fi
+ \fi
+ \else
+ % Multiple tokens in the argument. We hope it's a number.
+ \numericenumerate
+ \fi
+}
+
+% An @enumerate whose labels are integers. The starting integer is
+% given in \thearg.
+%
+\def\numericenumerate{%
+ \itemno = \thearg
+ \startenumeration{\the\itemno}%
+}
+
+% The starting (lowercase) letter is in \thearg.
+\def\lowercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more lowercase letters in @enumerate; get a bigger
+ alphabet}%
+ \fi
+ \char\lccode\itemno
+ }%
+}
+
+% The starting (uppercase) letter is in \thearg.
+\def\uppercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more uppercase letters in @enumerate; get a bigger
+ alphabet}
+ \fi
+ \char\uccode\itemno
+ }%
+}
+
+% Call itemizey, adding a period to the first argument and supplying the
+% common last two arguments. Also subtract one from the initial value in
+% \itemno, since @item increments \itemno.
+%
+\def\startenumeration#1{%
+ \advance\itemno by -1
+ \itemizey{#1.}\Eenumerate\flushcr
+}
+
+% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
+% to @enumerate.
+%
+\def\alphaenumerate{\enumerate{a}}
+\def\capsenumerate{\enumerate{A}}
+\def\Ealphaenumerate{\Eenumerate}
+\def\Ecapsenumerate{\Eenumerate}
+
+% Definition of @item while inside @itemize.
+
+\def\itemizeitem{%
+\advance\itemno by 1
+{\let\par=\endgraf \smallbreak}%
+\ifhmode \errmessage{In hmode at itemizeitem}\fi
+{\parskip=0in \hskip 0pt
+\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
+\vadjust{\penalty 1200}}%
+\flushcr}
+
+% @multitable macros
+% Amy Hendrickson, 8/18/94, 3/6/96
+%
+% @multitable ... @end multitable will make as many columns as desired.
+% Contents of each column will wrap at width given in preamble. Width
+% can be specified either with sample text given in a template line,
+% or in percent of \hsize, the current width of text on page.
+
+% Table can continue over pages but will only break between lines.
+
+% To make preamble:
+%
+% Either define widths of columns in terms of percent of \hsize:
+% @multitable @columnfractions .25 .3 .45
+% @item ...
+%
+% Numbers following @columnfractions are the percent of the total
+% current hsize to be used for each column. You may use as many
+% columns as desired.
+
+
+% Or use a template:
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item ...
+% using the widest term desired in each column.
+%
+% For those who want to use more than one line's worth of words in
+% the preamble, break the line within one argument and it
+% will parse correctly, i.e.,
+%
+% @multitable {Column 1 template} {Column 2 template} {Column 3
+% template}
+% Not:
+% @multitable {Column 1 template} {Column 2 template}
+% {Column 3 template}
+
+% Each new table line starts with @item, each subsequent new column
+% starts with @tab. Empty columns may be produced by supplying @tab's
+% with nothing between them for as many times as empty columns are needed,
+% ie, @tab@tab@tab will produce two empty columns.
+
+% @item, @tab, @multitable or @end multitable do not need to be on their
+% own lines, but it will not hurt if they are.
+
+% Sample multitable:
+
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item first col stuff @tab second col stuff @tab third col
+% @item
+% first col stuff
+% @tab
+% second col stuff
+% @tab
+% third col
+% @item first col stuff @tab second col stuff
+% @tab Many paragraphs of text may be used in any column.
+%
+% They will wrap at the width determined by the template.
+% @item@tab@tab This will be in third column.
+% @end multitable
+
+% Default dimensions may be reset by user.
+% @multitableparskip is vertical space between paragraphs in table.
+% @multitableparindent is paragraph indent in table.
+% @multitablecolmargin is horizontal space to be left between columns.
+% @multitablelinespace is space to leave between table items, baseline
+% to baseline.
+% 0pt means it depends on current normal line spacing.
+%
+\newskip\multitableparskip
+\newskip\multitableparindent
+\newdimen\multitablecolspace
+\newskip\multitablelinespace
+\multitableparskip=0pt
+\multitableparindent=6pt
+\multitablecolspace=12pt
+\multitablelinespace=0pt
+
+% Macros used to set up halign preamble:
+%
+\let\endsetuptable\relax
+\def\xendsetuptable{\endsetuptable}
+\let\columnfractions\relax
+\def\xcolumnfractions{\columnfractions}
+\newif\ifsetpercent
+
+% #1 is the part of the @columnfraction before the decimal point, which
+% is presumably either 0 or the empty string (but we don't check, we
+% just throw it away). #2 is the decimal part, which we use as the
+% percent of \hsize for this column.
+\def\pickupwholefraction#1.#2 {%
+ \global\advance\colcount by 1
+ \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
+ \setuptable
+}
+
+\newcount\colcount
+\def\setuptable#1{%
+ \def\firstarg{#1}%
+ \ifx\firstarg\xendsetuptable
+ \let\go = \relax
+ \else
+ \ifx\firstarg\xcolumnfractions
+ \global\setpercenttrue
+ \else
+ \ifsetpercent
+ \let\go\pickupwholefraction
+ \else
+ \global\advance\colcount by 1
+ \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
+ % typically that is always in the input, anyway.
+ \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
+ \fi
+ \fi
+ \ifx\go\pickupwholefraction
+ % Put the argument back for the \pickupwholefraction call, so
+ % we'll always have a period there to be parsed.
+ \def\go{\pickupwholefraction#1}%
+ \else
+ \let\go = \setuptable
+ \fi%
+ \fi
+ \go
+}
+
+% multitable syntax
+\def\tab{&\hskip1sp\relax} % 2/2/96
+ % tiny skip here makes sure this column space is
+ % maintained, even if it is never used.
+
+% @multitable ... @end multitable definitions:
+%
+\def\multitable{\parsearg\dotable}
+\def\dotable#1{\bgroup
+ \vskip\parskip
+ \let\item\crcr
+ \tolerance=9500
+ \hbadness=9500
+ \setmultitablespacing
+ \parskip=\multitableparskip
+ \parindent=\multitableparindent
+ \overfullrule=0pt
+ \global\colcount=0
+ \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
+ %
+ % To parse everything between @multitable and @item:
+ \setuptable#1 \endsetuptable
+ %
+ % \everycr will reset column counter, \colcount, at the end of
+ % each line. Every column entry will cause \colcount to advance by one.
+ % The table preamble
+ % looks at the current \colcount to find the correct column width.
+ \everycr{\noalign{%
+ %
+ % \filbreak%% keeps underfull box messages off when table breaks over pages.
+ % Maybe so, but it also creates really weird page breaks when the table
+ % breaks over pages. Wouldn't \vfil be better? Wait until the problem
+ % manifests itself, so it can be fixed for real --karl.
+ \global\colcount=0\relax}}%
+ %
+ % This preamble sets up a generic column definition, which will
+ % be used as many times as user calls for columns.
+ % \vtop will set a single line and will also let text wrap and
+ % continue for many paragraphs if desired.
+ \halign\bgroup&\global\advance\colcount by 1\relax
+ \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
+ %
+ % In order to keep entries from bumping into each other
+ % we will add a \leftskip of \multitablecolspace to all columns after
+ % the first one.
+ %
+ % If a template has been used, we will add \multitablecolspace
+ % to the width of each template entry.
+ %
+ % If the user has set preamble in terms of percent of \hsize we will
+ % use that dimension as the width of the column, and the \leftskip
+ % will keep entries from bumping into each other. Table will start at
+ % left margin and final column will justify at right margin.
+ %
+ % Make sure we don't inherit \rightskip from the outer environment.
+ \rightskip=0pt
+ \ifnum\colcount=1
+ % The first column will be indented with the surrounding text.
+ \advance\hsize by\leftskip
+ \else
+ \ifsetpercent \else
+ % If user has not set preamble in terms of percent of \hsize
+ % we will advance \hsize by \multitablecolspace.
+ \advance\hsize by \multitablecolspace
+ \fi
+ % In either case we will make \leftskip=\multitablecolspace:
+ \leftskip=\multitablecolspace
+ \fi
+ % Ignoring space at the beginning and end avoids an occasional spurious
+ % blank line, when TeX decides to break the line at the space before the
+ % box from the multistrut, so the strut ends up on a line by itself.
+ % For example:
+ % @multitable @columnfractions .11 .89
+ % @item @code{#}
+ % @tab Legal holiday which is valid in major parts of the whole country.
+ % Is automatically provided with highlighting sequences respectively marking
+ % characters.
+ \noindent\ignorespaces##\unskip\multistrut}\cr
+}
+
+\def\setmultitablespacing{% test to see if user has set \multitablelinespace.
+% If so, do nothing. If not, give it an appropriate dimension based on
+% current baselineskip.
+\ifdim\multitablelinespace=0pt
+%% strut to put in table in case some entry doesn't have descenders,
+%% to keep lines equally spaced
+\let\multistrut = \strut
+%% Test to see if parskip is larger than space between lines of
+%% table. If not, do nothing.
+%% If so, set to same dimension as multitablelinespace.
+\else
+\gdef\multistrut{\vrule height\multitablelinespace depth\dp0
+width0pt\relax} \fi
+\ifdim\multitableparskip>\multitablelinespace
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
+\fi%
+\ifdim\multitableparskip=0pt
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
+\fi}
+
+
+\message{indexing,}
+% Index generation facilities
+
+% Define \newwrite to be identical to plain tex's \newwrite
+% except not \outer, so it can be used within \newindex.
+{\catcode`\@=11
+\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
+
+% \newindex {foo} defines an index named foo.
+% It automatically defines \fooindex such that
+% \fooindex ...rest of line... puts an entry in the index foo.
+% It also defines \fooindfile to be the number of the output channel for
+% the file that accumulates this index. The file's extension is foo.
+% The name of an index should be no more than 2 characters long
+% for the sake of vms.
+%
+\def\newindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
+ \noexpand\doindex{#1}}
+}
+
+% @defindex foo == \newindex{foo}
+
+\def\defindex{\parsearg\newindex}
+
+% Define @defcodeindex, like @defindex except put all entries in @code.
+
+\def\newcodeindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{%
+ \noexpand\docodeindex{#1}}
+}
+
+\def\defcodeindex{\parsearg\newcodeindex}
+
+% @synindex foo bar makes index foo feed into index bar.
+% Do this instead of @defindex foo if you don't want it as a separate index.
+% The \closeout helps reduce unnecessary open files; the limit on the
+% Acorn RISC OS is a mere 16 files.
+\def\synindex#1 #2 {%
+ \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
+ \expandafter\closeout\csname#1indfile\endcsname
+ \expandafter\let\csname#1indfile\endcsname=\synindexfoo
+ \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
+ \noexpand\doindex{#2}}%
+}
+
+% @syncodeindex foo bar similar, but put all entries made for index foo
+% inside @code.
+\def\syncodeindex#1 #2 {%
+ \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
+ \expandafter\closeout\csname#1indfile\endcsname
+ \expandafter\let\csname#1indfile\endcsname=\synindexfoo
+ \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
+ \noexpand\docodeindex{#2}}%
+}
+
+% Define \doindex, the driver for all \fooindex macros.
+% Argument #1 is generated by the calling \fooindex macro,
+% and it is "foo", the name of the index.
+
+% \doindex just uses \parsearg; it calls \doind for the actual work.
+% This is because \doind is more useful to call from other macros.
+
+% There is also \dosubind {index}{topic}{subtopic}
+% which makes an entry in a two-level index such as the operation index.
+
+\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
+\def\singleindexer #1{\doind{\indexname}{#1}}
+
+% like the previous two, but they put @code around the argument.
+\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
+\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
+
+\def\indexdummies{%
+\def\ { }%
+% Take care of the plain tex accent commands.
+\def\"{\realbackslash "}%
+\def\`{\realbackslash `}%
+\def\'{\realbackslash '}%
+\def\^{\realbackslash ^}%
+\def\~{\realbackslash ~}%
+\def\={\realbackslash =}%
+\def\b{\realbackslash b}%
+\def\c{\realbackslash c}%
+\def\d{\realbackslash d}%
+\def\u{\realbackslash u}%
+\def\v{\realbackslash v}%
+\def\H{\realbackslash H}%
+% Take care of the plain tex special European modified letters.
+\def\oe{\realbackslash oe}%
+\def\ae{\realbackslash ae}%
+\def\aa{\realbackslash aa}%
+\def\OE{\realbackslash OE}%
+\def\AE{\realbackslash AE}%
+\def\AA{\realbackslash AA}%
+\def\o{\realbackslash o}%
+\def\O{\realbackslash O}%
+\def\l{\realbackslash l}%
+\def\L{\realbackslash L}%
+\def\ss{\realbackslash ss}%
+% Take care of texinfo commands likely to appear in an index entry.
+% (Must be a way to avoid doing expansion at all, and thus not have to
+% laboriously list every single command here.)
+\def\@{@}% will be @@ when we switch to @ as escape char.
+% Need these in case \tex is in effect and \{ is a \delimiter again.
+% But can't use \lbracecmd and \rbracecmd because texindex assumes
+% braces and backslashes are used only as delimiters.
+\let\{ = \mylbrace
+\let\} = \myrbrace
+\def\_{{\realbackslash _}}%
+\def\w{\realbackslash w }%
+\def\bf{\realbackslash bf }%
+%\def\rm{\realbackslash rm }%
+\def\sl{\realbackslash sl }%
+\def\sf{\realbackslash sf}%
+\def\tt{\realbackslash tt}%
+\def\gtr{\realbackslash gtr}%
+\def\less{\realbackslash less}%
+\def\hat{\realbackslash hat}%
+\def\TeX{\realbackslash TeX}%
+\def\dots{\realbackslash dots }%
+\def\result{\realbackslash result}%
+\def\equiv{\realbackslash equiv}%
+\def\expansion{\realbackslash expansion}%
+\def\print{\realbackslash print}%
+\def\error{\realbackslash error}%
+\def\point{\realbackslash point}%
+\def\copyright{\realbackslash copyright}%
+\def\tclose##1{\realbackslash tclose {##1}}%
+\def\code##1{\realbackslash code {##1}}%
+\def\uref##1{\realbackslash uref {##1}}%
+\def\url##1{\realbackslash url {##1}}%
+\def\env##1{\realbackslash env {##1}}%
+\def\command##1{\realbackslash command {##1}}%
+\def\option##1{\realbackslash option {##1}}%
+\def\dotless##1{\realbackslash dotless {##1}}%
+\def\samp##1{\realbackslash samp {##1}}%
+\def\,##1{\realbackslash ,{##1}}%
+\def\t##1{\realbackslash t {##1}}%
+\def\r##1{\realbackslash r {##1}}%
+\def\i##1{\realbackslash i {##1}}%
+\def\b##1{\realbackslash b {##1}}%
+\def\sc##1{\realbackslash sc {##1}}%
+\def\cite##1{\realbackslash cite {##1}}%
+\def\key##1{\realbackslash key {##1}}%
+\def\file##1{\realbackslash file {##1}}%
+\def\var##1{\realbackslash var {##1}}%
+\def\kbd##1{\realbackslash kbd {##1}}%
+\def\dfn##1{\realbackslash dfn {##1}}%
+\def\emph##1{\realbackslash emph {##1}}%
+\def\acronym##1{\realbackslash acronym {##1}}%
+%
+% Handle some cases of @value -- where the variable name does not
+% contain - or _, and the value does not contain any
+% (non-fully-expandable) commands.
+\let\value = \expandablevalue
+%
+\unsepspaces
+}
+
+% If an index command is used in an @example environment, any spaces
+% therein should become regular spaces in the raw index file, not the
+% expansion of \tie (\\leavevmode \penalty \@M \ ).
+{\obeyspaces
+ \gdef\unsepspaces{\obeyspaces\let =\space}}
+
+% \indexnofonts no-ops all font-change commands.
+% This is used when outputting the strings to sort the index by.
+\def\indexdummyfont#1{#1}
+\def\indexdummytex{TeX}
+\def\indexdummydots{...}
+
+\def\indexnofonts{%
+% Just ignore accents.
+\let\,=\indexdummyfont
+\let\"=\indexdummyfont
+\let\`=\indexdummyfont
+\let\'=\indexdummyfont
+\let\^=\indexdummyfont
+\let\~=\indexdummyfont
+\let\==\indexdummyfont
+\let\b=\indexdummyfont
+\let\c=\indexdummyfont
+\let\d=\indexdummyfont
+\let\u=\indexdummyfont
+\let\v=\indexdummyfont
+\let\H=\indexdummyfont
+\let\dotless=\indexdummyfont
+% Take care of the plain tex special European modified letters.
+\def\oe{oe}%
+\def\ae{ae}%
+\def\aa{aa}%
+\def\OE{OE}%
+\def\AE{AE}%
+\def\AA{AA}%
+\def\o{o}%
+\def\O{O}%
+\def\l{l}%
+\def\L{L}%
+\def\ss{ss}%
+\let\w=\indexdummyfont
+\let\t=\indexdummyfont
+\let\r=\indexdummyfont
+\let\i=\indexdummyfont
+\let\b=\indexdummyfont
+\let\emph=\indexdummyfont
+\let\strong=\indexdummyfont
+\let\cite=\indexdummyfont
+\let\sc=\indexdummyfont
+%Don't no-op \tt, since it isn't a user-level command
+% and is used in the definitions of the active chars like <, >, |...
+%\let\tt=\indexdummyfont
+\let\tclose=\indexdummyfont
+\let\code=\indexdummyfont
+\let\url=\indexdummyfont
+\let\uref=\indexdummyfont
+\let\env=\indexdummyfont
+\let\command=\indexdummyfont
+\let\option=\indexdummyfont
+\let\file=\indexdummyfont
+\let\samp=\indexdummyfont
+\let\kbd=\indexdummyfont
+\let\key=\indexdummyfont
+\let\var=\indexdummyfont
+\let\TeX=\indexdummytex
+\let\dots=\indexdummydots
+\def\@{@}%
+}
+
+% To define \realbackslash, we must make \ not be an escape.
+% We must first make another character (@) an escape
+% so we do not become unable to do a definition.
+
+{\catcode`\@=0 \catcode`\\=\other
+ @gdef@realbackslash{\}}
+
+\let\indexbackslash=0 %overridden during \printindex.
+\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
+
+% For \ifx comparisons.
+\def\emptymacro{\empty}
+
+% Most index entries go through here, but \dosubind is the general case.
+%
+\def\doind#1#2{\dosubind{#1}{#2}\empty}
+
+% Workhorse for all \fooindexes.
+% #1 is name of index, #2 is stuff to put there, #3 is subentry --
+% \empty if called from \doind, as we usually are. The main exception
+% is with defuns, which call us directly.
+%
+\def\dosubind#1#2#3{%
+ % Put the index entry in the margin if desired.
+ \ifx\SETmarginindex\relax\else
+ \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
+ \fi
+ {%
+ \count255=\lastpenalty
+ {%
+ \indexdummies % Must do this here, since \bf, etc expand at this stage
+ \escapechar=`\\
+ {%
+ \let\folio = 0% We will expand all macros now EXCEPT \folio.
+ \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
+ % so it will be output as is; and it will print as backslash.
+ %
+ \def\thirdarg{#3}%
+ %
+ % If third arg is present, precede it with space in sort key.
+ \ifx\thirdarg\emptymacro
+ \let\subentry = \empty
+ \else
+ \def\subentry{ #3}%
+ \fi
+ %
+ % First process the index-string with all font commands turned off
+ % to get the string to sort by.
+ {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
+ %
+ % Now produce the complete index entry, with both the sort key and the
+ % original text, including any font commands.
+ \toks0 = {#2}%
+ \edef\temp{%
+ \write\csname#1indfile\endcsname{%
+ \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
+ }%
+ %
+ % If third (subentry) arg is present, add it to the index string.
+ \ifx\thirdarg\emptymacro \else
+ \toks0 = {#3}%
+ \edef\temp{\temp{\the\toks0}}%
+ \fi
+ %
+ % If a skip is the last thing on the list now, preserve it
+ % by backing up by \lastskip, doing the \write, then inserting
+ % the skip again. Otherwise, the whatsit generated by the
+ % \write will make \lastskip zero. The result is that sequences
+ % like this:
+ % @end defun
+ % @tindex whatever
+ % @defun ...
+ % will have extra space inserted, because the \medbreak in the
+ % start of the @defun won't see the skip inserted by the @end of
+ % the previous defun.
+ %
+ % But don't do any of this if we're not in vertical mode. We
+ % don't want to do a \vskip and prematurely end a paragraph.
+ %
+ % Avoid page breaks due to these extra skips, too.
+ %
+ \iflinks
+ \ifvmode
+ \skip0 = \lastskip
+ \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
+ \fi
+ %
+ \temp % do the write
+ %
+ %
+ \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
+ \fi
+ }%
+ }%
+ \penalty\count255
+ }%
+}
+
+% The index entry written in the file actually looks like
+% \entry {sortstring}{page}{topic}
+% or
+% \entry {sortstring}{page}{topic}{subtopic}
+% The texindex program reads in these files and writes files
+% containing these kinds of lines:
+% \initial {c}
+% before the first topic whose initial is c
+% \entry {topic}{pagelist}
+% for a topic that is used without subtopics
+% \primary {topic}
+% for the beginning of a topic that is used with subtopics
+% \secondary {subtopic}{pagelist}
+% for each subtopic.
+
+% Define the user-accessible indexing commands
+% @findex, @vindex, @kindex, @cindex.
+
+\def\findex {\fnindex}
+\def\kindex {\kyindex}
+\def\cindex {\cpindex}
+\def\vindex {\vrindex}
+\def\tindex {\tpindex}
+\def\pindex {\pgindex}
+
+\def\cindexsub {\begingroup\obeylines\cindexsub}
+{\obeylines %
+\gdef\cindexsub "#1" #2^^M{\endgroup %
+\dosubind{cp}{#2}{#1}}}
+
+% Define the macros used in formatting output of the sorted index material.
+
+% @printindex causes a particular index (the ??s file) to get printed.
+% It does not print any chapter heading (usually an @unnumbered).
+%
+\def\printindex{\parsearg\doprintindex}
+\def\doprintindex#1{\begingroup
+ \dobreak \chapheadingskip{10000}%
+ %
+ \indexfonts \rm
+ \tolerance = 9500
+ \indexbreaks
+ %
+ % See if the index file exists and is nonempty.
+ % Change catcode of @ here so that if the index file contains
+ % \initial {@}
+ % as its first line, TeX doesn't complain about mismatched braces
+ % (because it thinks @} is a control sequence).
+ \catcode`\@ = 11
+ \openin 1 \jobname.#1s
+ \ifeof 1
+ % \enddoublecolumns gets confused if there is no text in the index,
+ % and it loses the chapter title and the aux file entries for the
+ % index. The easiest way to prevent this problem is to make sure
+ % there is some text.
+ (Index is nonexistent)
+ \else
+ %
+ % If the index file exists but is empty, then \openin leaves \ifeof
+ % false. We have to make TeX try to read something from the file, so
+ % it can discover if there is anything in it.
+ \read 1 to \temp
+ \ifeof 1
+ (Index is empty)
+ \else
+ % Index files are almost Texinfo source, but we use \ as the escape
+ % character. It would be better to use @, but that's too big a change
+ % to make right now.
+ \def\indexbackslash{\rawbackslashxx}%
+ \catcode`\\ = 0
+ \escapechar = `\\
+ \begindoublecolumns
+ \input \jobname.#1s
+ \enddoublecolumns
+ \fi
+ \fi
+ \closein 1
+\endgroup}
+
+% These macros are used by the sorted index file itself.
+% Change them to control the appearance of the index.
+
+\def\initial#1{{%
+ % Some minor font changes for the special characters.
+ \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
+ %
+ % Remove any glue we may have, we'll be inserting our own.
+ \removelastskip
+ %
+ % We like breaks before the index initials, so insert a bonus.
+ \penalty -300
+ %
+ % Typeset the initial. Making this add up to a whole number of
+ % baselineskips increases the chance of the dots lining up from column
+ % to column. It still won't often be perfect, because of the stretch
+ % we need before each entry, but it's better.
+ %
+ % No shrink because it confuses \balancecolumns.
+ \vskip 1.67\baselineskip plus .5\baselineskip
+ \leftline{\secbf #1}%
+ \vskip .33\baselineskip plus .1\baselineskip
+ %
+ % Do our best not to break after the initial.
+ \nobreak
+}}
+
+% This typesets a paragraph consisting of #1, dot leaders, and then #2
+% flush to the right margin. It is used for index and table of contents
+% entries. The paragraph is indented by \leftskip.
+%
+\def\entry#1#2{\begingroup
+ %
+ % Start a new paragraph if necessary, so our assignments below can't
+ % affect previous text.
+ \par
+ %
+ % Do not fill out the last line with white space.
+ \parfillskip = 0in
+ %
+ % No extra space above this paragraph.
+ \parskip = 0in
+ %
+ % Do not prefer a separate line ending with a hyphen to fewer lines.
+ \finalhyphendemerits = 0
+ %
+ % \hangindent is only relevant when the entry text and page number
+ % don't both fit on one line. In that case, bob suggests starting the
+ % dots pretty far over on the line. Unfortunately, a large
+ % indentation looks wrong when the entry text itself is broken across
+ % lines. So we use a small indentation and put up with long leaders.
+ %
+ % \hangafter is reset to 1 (which is the value we want) at the start
+ % of each paragraph, so we need not do anything with that.
+ \hangindent = 2em
+ %
+ % When the entry text needs to be broken, just fill out the first line
+ % with blank space.
+ \rightskip = 0pt plus1fil
+ %
+ % A bit of stretch before each entry for the benefit of balancing columns.
+ \vskip 0pt plus1pt
+ %
+ % Start a ``paragraph'' for the index entry so the line breaking
+ % parameters we've set above will have an effect.
+ \noindent
+ %
+ % Insert the text of the index entry. TeX will do line-breaking on it.
+ #1%
+ % The following is kludged to not output a line of dots in the index if
+ % there are no page numbers. The next person who breaks this will be
+ % cursed by a Unix daemon.
+ \def\tempa{{\rm }}%
+ \def\tempb{#2}%
+ \edef\tempc{\tempa}%
+ \edef\tempd{\tempb}%
+ \ifx\tempc\tempd\ \else%
+ %
+ % If we must, put the page number on a line of its own, and fill out
+ % this line with blank space. (The \hfil is overwhelmed with the
+ % fill leaders glue in \indexdotfill if the page number does fit.)
+ \hfil\penalty50
+ \null\nobreak\indexdotfill % Have leaders before the page number.
+ %
+ % The `\ ' here is removed by the implicit \unskip that TeX does as
+ % part of (the primitive) \par. Without it, a spurious underfull
+ % \hbox ensues.
+ \ #2% The page number ends the paragraph.
+ \fi%
+ \par
+\endgroup}
+
+% Like \dotfill except takes at least 1 em.
+\def\indexdotfill{\cleaders
+ \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
+
+\def\primary #1{\line{#1\hfil}}
+
+\newskip\secondaryindent \secondaryindent=0.5cm
+
+\def\secondary #1#2{
+{\parfillskip=0in \parskip=0in
+\hangindent =1in \hangafter=1
+\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
+}}
+
+% Define two-column mode, which we use to typeset indexes.
+% Adapted from the TeXbook, page 416, which is to say,
+% the manmac.tex format used to print the TeXbook itself.
+\catcode`\@=11
+
+\newbox\partialpage
+\newdimen\doublecolumnhsize
+
+\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
+ % Grab any single-column material above us.
+ \output = {\global\setbox\partialpage = \vbox{%
+ %
+ % Here is a possibility not foreseen in manmac: if we accumulate a
+ % whole lot of material, we might end up calling this \output
+ % routine twice in a row (see the doublecol-lose test, which is
+ % essentially a couple of indexes with @setchapternewpage off). In
+ % that case, we must prevent the second \partialpage from
+ % simply overwriting the first, causing us to lose the page.
+ % This will preserve it until a real output routine can ship it
+ % out. Generally, \partialpage will be empty when this runs and
+ % this will be a no-op.
+ \unvbox\partialpage
+ %
+ % Unvbox the main output page.
+ \unvbox255
+ \kern-\topskip \kern\baselineskip
+ }}%
+ \eject % run that output routine to set \partialpage
+ %
+ % Use the double-column output routine for subsequent pages.
+ \output = {\doublecolumnout}%
+ %
+ % Change the page size parameters. We could do this once outside this
+ % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
+ % format, but then we repeat the same computation. Repeating a couple
+ % of assignments once per index is clearly meaningless for the
+ % execution time, so we may as well do it in one place.
+ %
+ % First we halve the line length, less a little for the gutter between
+ % the columns. We compute the gutter based on the line length, so it
+ % changes automatically with the paper format. The magic constant
+ % below is chosen so that the gutter has the same value (well, +-<1pt)
+ % as it did when we hard-coded it.
+ %
+ % We put the result in a separate register, \doublecolumhsize, so we
+ % can restore it in \pagesofar, after \hsize itself has (potentially)
+ % been clobbered.
+ %
+ \doublecolumnhsize = \hsize
+ \advance\doublecolumnhsize by -.04154\hsize
+ \divide\doublecolumnhsize by 2
+ \hsize = \doublecolumnhsize
+ %
+ % Double the \vsize as well. (We don't need a separate register here,
+ % since nobody clobbers \vsize.)
+ \advance\vsize by -\ht\partialpage
+ \vsize = 2\vsize
+}
+
+% The double-column output routine for all double-column pages except
+% the last.
+%
+\def\doublecolumnout{%
+ \splittopskip=\topskip \splitmaxdepth=\maxdepth
+ % Get the available space for the double columns -- the normal
+ % (undoubled) page height minus any material left over from the
+ % previous page.
+ \dimen@ = \vsize
+ \divide\dimen@ by 2
+ %
+ % box0 will be the left-hand column, box2 the right.
+ \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
+ \onepageout\pagesofar
+ \unvbox255
+ \penalty\outputpenalty
+}
+\def\pagesofar{%
+ % Re-output the contents of the output page -- any previous material,
+ % followed by the two boxes we just split, in box0 and box2.
+ \advance\vsize by \ht\partialpage
+ \unvbox\partialpage
+ %
+ \hsize = \doublecolumnhsize
+ \wd0=\hsize \wd2=\hsize
+ \hbox to\pagewidth{\box0\hfil\box2}%
+}
+\def\enddoublecolumns{%
+ \output = {%
+ % Split the last of the double-column material. Leave it on the
+ % current page, no automatic page break.
+ \balancecolumns
+ %
+ % If we end up splitting too much material for the current page,
+ % though, there will be another page break right after this \output
+ % invocation ends. Having called \balancecolumns once, we do not
+ % want to call it again. Therefore, reset \output to its normal
+ % definition right away. (We hope \balancecolumns will never be
+ % called on to balance too much material, but if it is, this makes
+ % the output somewhat more palatable.)
+ \global\output = {\onepageout{\pagecontents\PAGE}}%
+ }%
+ \eject
+ \endgroup % started in \begindoublecolumns
+ %
+ % \pagegoal was set to the doubled \vsize above, since we restarted
+ % the current page. We're now back to normal single-column
+ % typesetting, so reset \pagegoal to the normal \vsize (after the
+ % \endgroup where \vsize got restored).
+ \pagegoal = \vsize
+}
+\def\balancecolumns{%
+ % Called at the end of the double column material.
+ \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
+ \dimen@ = \ht0
+ \advance\dimen@ by \topskip
+ \advance\dimen@ by-\baselineskip
+ \divide\dimen@ by 2 % target to split to
+ %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
+ \splittopskip = \topskip
+ % Loop until we get a decent breakpoint.
+ {%
+ \vbadness = 10000
+ \loop
+ \global\setbox3 = \copy0
+ \global\setbox1 = \vsplit3 to \dimen@
+ \ifdim\ht3>\dimen@
+ \global\advance\dimen@ by 1pt
+ \repeat
+ }%
+ %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
+ \setbox0=\vbox to\dimen@{\unvbox1}%
+ \setbox2=\vbox to\dimen@{\unvbox3}%
+ %
+ \pagesofar
+}
+\catcode`\@ = \other
+
+
+\message{sectioning,}
+% Define chapters, sections, etc.
+
+\newcount\chapno
+\newcount\secno \secno=0
+\newcount\subsecno \subsecno=0
+\newcount\subsubsecno \subsubsecno=0
+
+% This counter is funny since it counts through charcodes of letters A, B, ...
+\newcount\appendixno \appendixno = `\@
+\def\appendixletter{\char\the\appendixno}
+
+% Each @chapter defines this as the name of the chapter.
+% page headings and footings can use it. @section does likewise.
+\def\thischapter{}
+\def\thissection{}
+
+\newcount\absseclevel % used to calculate proper heading level
+\newcount\secbase\secbase=0 % @raise/lowersections modify this count
+
+% @raisesections: treat @section as chapter, @subsection as section, etc.
+\def\raisesections{\global\advance\secbase by -1}
+\let\up=\raisesections % original BFox name
+
+% @lowersections: treat @chapter as section, @section as subsection, etc.
+\def\lowersections{\global\advance\secbase by 1}
+\let\down=\lowersections % original BFox name
+
+% Choose a numbered-heading macro
+% #1 is heading level if unmodified by @raisesections or @lowersections
+% #2 is text for heading
+\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
+\ifcase\absseclevel
+ \chapterzzz{#2}
+\or
+ \seczzz{#2}
+\or
+ \numberedsubseczzz{#2}
+\or
+ \numberedsubsubseczzz{#2}
+\else
+ \ifnum \absseclevel<0
+ \chapterzzz{#2}
+ \else
+ \numberedsubsubseczzz{#2}
+ \fi
+\fi
+}
+
+% like \numhead, but chooses appendix heading levels
+\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
+\ifcase\absseclevel
+ \appendixzzz{#2}
+\or
+ \appendixsectionzzz{#2}
+\or
+ \appendixsubseczzz{#2}
+\or
+ \appendixsubsubseczzz{#2}
+\else
+ \ifnum \absseclevel<0
+ \appendixzzz{#2}
+ \else
+ \appendixsubsubseczzz{#2}
+ \fi
+\fi
+}
+
+% like \numhead, but chooses numberless heading levels
+\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
+\ifcase\absseclevel
+ \unnumberedzzz{#2}
+\or
+ \unnumberedseczzz{#2}
+\or
+ \unnumberedsubseczzz{#2}
+\or
+ \unnumberedsubsubseczzz{#2}
+\else
+ \ifnum \absseclevel<0
+ \unnumberedzzz{#2}
+ \else
+ \unnumberedsubsubseczzz{#2}
+ \fi
+\fi
+}
+
+% @chapter, @appendix, @unnumbered.
+\def\thischaptername{No Chapter Title}
+\outer\def\chapter{\parsearg\chapteryyy}
+\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
+\def\chapterzzz #1{%
+\secno=0 \subsecno=0 \subsubsecno=0
+\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
+\chapmacro {#1}{\the\chapno}%
+\gdef\thissection{#1}%
+\gdef\thischaptername{#1}%
+% We don't substitute the actual chapter name into \thischapter
+% because we don't want its macros evaluated now.
+\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
+ {\the\chapno}}}%
+\temp
+\donoderef
+\global\let\section = \numberedsec
+\global\let\subsection = \numberedsubsec
+\global\let\subsubsection = \numberedsubsubsec
+}
+
+\outer\def\appendix{\parsearg\appendixyyy}
+\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
+\def\appendixzzz #1{%
+\secno=0 \subsecno=0 \subsubsecno=0
+\global\advance \appendixno by 1
+\message{\putwordAppendix\space \appendixletter}%
+\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
+\gdef\thissection{#1}%
+\gdef\thischaptername{#1}%
+\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
+ {\putwordAppendix{} \appendixletter}}}%
+\temp
+\appendixnoderef
+\global\let\section = \appendixsec
+\global\let\subsection = \appendixsubsec
+\global\let\subsubsection = \appendixsubsubsec
+}
+
+% @centerchap is like @unnumbered, but the heading is centered.
+\outer\def\centerchap{\parsearg\centerchapyyy}
+\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
+
+% @top is like @unnumbered.
+\outer\def\top{\parsearg\unnumberedyyy}
+
+\outer\def\unnumbered{\parsearg\unnumberedyyy}
+\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
+\def\unnumberedzzz #1{%
+\secno=0 \subsecno=0 \subsubsecno=0
+%
+% This used to be simply \message{#1}, but TeX fully expands the
+% argument to \message. Therefore, if #1 contained @-commands, TeX
+% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
+% expanded @cite (which turns out to cause errors because \cite is meant
+% to be executed, not expanded).
+%
+% Anyway, we don't want the fully-expanded definition of @cite to appear
+% as a result of the \message, we just want `@cite' itself. We use
+% \the to achieve this: TeX expands \the only once,
+% simply yielding the contents of . (We also do this for
+% the toc entries.)
+\toks0 = {#1}\message{(\the\toks0)}%
+%
+\unnumbchapmacro {#1}%
+\gdef\thischapter{#1}\gdef\thissection{#1}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
+\temp
+\unnumbnoderef
+\global\let\section = \unnumberedsec
+\global\let\subsection = \unnumberedsubsec
+\global\let\subsubsection = \unnumberedsubsubsec
+}
+
+% Sections.
+\outer\def\numberedsec{\parsearg\secyyy}
+\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
+\def\seczzz #1{%
+\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
+ {\the\chapno}{\the\secno}}}%
+\temp
+\donoderef
+\nobreak
+}
+
+\outer\def\appendixsection{\parsearg\appendixsecyyy}
+\outer\def\appendixsec{\parsearg\appendixsecyyy}
+\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
+\def\appendixsectionzzz #1{%
+\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
+\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
+ {\appendixletter}{\the\secno}}}%
+\temp
+\appendixnoderef
+\nobreak
+}
+
+\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
+\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
+\def\unnumberedseczzz #1{%
+\plainsecheading {#1}\gdef\thissection{#1}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
+\temp
+\unnumbnoderef
+\nobreak
+}
+
+% Subsections.
+\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
+\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
+\def\numberedsubseczzz #1{%
+\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
+ {\the\chapno}{\the\secno}{\the\subsecno}}}%
+\temp
+\donoderef
+\nobreak
+}
+
+\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
+\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
+\def\appendixsubseczzz #1{%
+\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
+\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
+ {\appendixletter}{\the\secno}{\the\subsecno}}}%
+\temp
+\appendixnoderef
+\nobreak
+}
+
+\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
+\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
+\def\unnumberedsubseczzz #1{%
+\plainsubsecheading {#1}\gdef\thissection{#1}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
+ {\the\toks0}}}%
+\temp
+\unnumbnoderef
+\nobreak
+}
+
+% Subsubsections.
+\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
+\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
+\def\numberedsubsubseczzz #1{%
+\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+\subsubsecheading {#1}
+ {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
+ {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
+\temp
+\donoderef
+\nobreak
+}
+
+\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
+\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
+\def\appendixsubsubseczzz #1{%
+\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
+\subsubsecheading {#1}
+ {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
+ {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
+\temp
+\appendixnoderef
+\nobreak
+}
+
+\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
+\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
+\def\unnumberedsubsubseczzz #1{%
+\plainsubsubsecheading {#1}\gdef\thissection{#1}%
+\toks0 = {#1}%
+\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
+ {\the\toks0}}}%
+\temp
+\unnumbnoderef
+\nobreak
+}
+
+% These are variants which are not "outer", so they can appear in @ifinfo.
+% Actually, they should now be obsolete; ordinary section commands should work.
+\def\infotop{\parsearg\unnumberedzzz}
+\def\infounnumbered{\parsearg\unnumberedzzz}
+\def\infounnumberedsec{\parsearg\unnumberedseczzz}
+\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
+\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
+
+\def\infoappendix{\parsearg\appendixzzz}
+\def\infoappendixsec{\parsearg\appendixseczzz}
+\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
+\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
+
+\def\infochapter{\parsearg\chapterzzz}
+\def\infosection{\parsearg\sectionzzz}
+\def\infosubsection{\parsearg\subsectionzzz}
+\def\infosubsubsection{\parsearg\subsubsectionzzz}
+
+% These macros control what the section commands do, according
+% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
+% Define them by default for a numbered chapter.
+\global\let\section = \numberedsec
+\global\let\subsection = \numberedsubsec
+\global\let\subsubsection = \numberedsubsubsec
+
+% Define @majorheading, @heading and @subheading
+
+% NOTE on use of \vbox for chapter headings, section headings, and such:
+% 1) We use \vbox rather than the earlier \line to permit
+% overlong headings to fold.
+% 2) \hyphenpenalty is set to 10000 because hyphenation in a
+% heading is obnoxious; this forbids it.
+% 3) Likewise, headings look best if no \parindent is used, and
+% if justification is not attempted. Hence \raggedright.
+
+
+\def\majorheading{\parsearg\majorheadingzzz}
+\def\majorheadingzzz #1{%
+{\advance\chapheadingskip by 10pt \chapbreak }%
+{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}\bigskip \par\penalty 200}
+
+\def\chapheading{\parsearg\chapheadingzzz}
+\def\chapheadingzzz #1{\chapbreak %
+{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}\bigskip \par\penalty 200}
+
+% @heading, @subheading, @subsubheading.
+\def\heading{\parsearg\plainsecheading}
+\def\subheading{\parsearg\plainsubsecheading}
+\def\subsubheading{\parsearg\plainsubsubsecheading}
+
+% These macros generate a chapter, section, etc. heading only
+% (including whitespace, linebreaking, etc. around it),
+% given all the information in convenient, parsed form.
+
+%%% Args are the skip and penalty (usually negative)
+\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
+
+\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
+
+%%% Define plain chapter starts, and page on/off switching for it
+% Parameter controlling skip before chapter headings (if needed)
+
+\newskip\chapheadingskip
+
+\def\chapbreak{\dobreak \chapheadingskip {-4000}}
+\def\chappager{\par\vfill\supereject}
+\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
+
+\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
+
+\def\CHAPPAGoff{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chapbreak
+\global\let\pagealignmacro=\chappager}
+
+\def\CHAPPAGon{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chappager
+\global\let\pagealignmacro=\chappager
+\global\def\HEADINGSon{\HEADINGSsingle}}
+
+\def\CHAPPAGodd{
+\global\let\contentsalignmacro = \chapoddpage
+\global\let\pchapsepmacro=\chapoddpage
+\global\let\pagealignmacro=\chapoddpage
+\global\def\HEADINGSon{\HEADINGSdouble}}
+
+\CHAPPAGon
+
+\def\CHAPFplain{
+\global\let\chapmacro=\chfplain
+\global\let\unnumbchapmacro=\unnchfplain
+\global\let\centerchapmacro=\centerchfplain}
+
+% Plain chapter opening.
+% #1 is the text, #2 the chapter number or empty if unnumbered.
+\def\chfplain#1#2{%
+ \pchapsepmacro
+ {%
+ \chapfonts \rm
+ \def\chapnum{#2}%
+ \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+ \hangindent = \wd0 \centerparametersmaybe
+ \unhbox0 #1\par}%
+ }%
+ \nobreak\bigskip % no page break after a chapter title
+ \nobreak
+}
+
+% Plain opening for unnumbered.
+\def\unnchfplain#1{\chfplain{#1}{}}
+
+% @centerchap -- centered and unnumbered.
+\let\centerparametersmaybe = \relax
+\def\centerchfplain#1{{%
+ \def\centerparametersmaybe{%
+ \advance\rightskip by 3\rightskip
+ \leftskip = \rightskip
+ \parfillskip = 0pt
+ }%
+ \chfplain{#1}{}%
+}}
+
+\CHAPFplain % The default
+
+\def\unnchfopen #1{%
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}\bigskip \par\nobreak
+}
+
+\def\chfopen #1#2{\chapoddpage {\chapfonts
+\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
+\par\penalty 5000 %
+}
+
+\def\centerchfopen #1{%
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt
+ \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
+}
+
+\def\CHAPFopen{
+\global\let\chapmacro=\chfopen
+\global\let\unnumbchapmacro=\unnchfopen
+\global\let\centerchapmacro=\centerchfopen}
+
+
+% Section titles.
+\newskip\secheadingskip
+\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
+\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
+\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
+
+% Subsection titles.
+\newskip \subsecheadingskip
+\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
+\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
+\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
+
+% Subsubsection titles.
+\let\subsubsecheadingskip = \subsecheadingskip
+\let\subsubsecheadingbreak = \subsecheadingbreak
+\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
+\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
+
+
+% Print any size section title.
+%
+% #1 is the section type (sec/subsec/subsubsec), #2 is the section
+% number (maybe empty), #3 the text.
+\def\sectionheading#1#2#3{%
+ {%
+ \expandafter\advance\csname #1headingskip\endcsname by \parskip
+ \csname #1headingbreak\endcsname
+ }%
+ {%
+ % Switch to the right set of fonts.
+ \csname #1fonts\endcsname \rm
+ %
+ % Only insert the separating space if we have a section number.
+ \def\secnum{#2}%
+ \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
+ %
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+ \hangindent = \wd0 % zero if no section number
+ \unhbox0 #3}%
+ }%
+ \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
+}
+
+
+\message{toc,}
+\newwrite\tocfile
+
+% Write an entry to the toc file, opening it if necessary.
+% Called from @chapter, etc. We supply {\folio} at the end of the
+% argument, which will end up as the last argument to the \...entry macro.
+%
+% We open the .toc file here instead of at @setfilename or any other
+% given time so that @contents can be put in the document anywhere.
+%
+\newif\iftocfileopened
+\def\writetocentry#1{%
+ \iftocfileopened\else
+ \immediate\openout\tocfile = \jobname.toc
+ \global\tocfileopenedtrue
+ \fi
+ \iflinks \write\tocfile{#1{\folio}}\fi
+}
+
+\newskip\contentsrightmargin \contentsrightmargin=1in
+\newcount\savepageno
+\newcount\lastnegativepageno \lastnegativepageno = -1
+
+% Finish up the main text and prepare to read what we've written
+% to \tocfile.
+%
+\def\startcontents#1{%
+ % If @setchapternewpage on, and @headings double, the contents should
+ % start on an odd page, unlike chapters. Thus, we maintain
+ % \contentsalignmacro in parallel with \pagealignmacro.
+ % From: Torbjorn Granlund
+ \contentsalignmacro
+ \immediate\closeout\tocfile
+ %
+ % Don't need to put `Contents' or `Short Contents' in the headline.
+ % It is abundantly clear what they are.
+ \unnumbchapmacro{#1}\def\thischapter{}%
+ \savepageno = \pageno
+ \begingroup % Set up to handle contents files properly.
+ \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
+ % We can't do this, because then an actual ^ in a section
+ % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
+ %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
+ \raggedbottom % Worry more about breakpoints than the bottom.
+ \advance\hsize by -\contentsrightmargin % Don't use the full line length.
+ %
+ % Roman numerals for page numbers.
+ \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
+}
+
+
+% Normal (long) toc.
+\def\contents{%
+ \startcontents{\putwordTableofContents}%
+ \openin 1 \jobname.toc
+ \ifeof 1 \else
+ \closein 1
+ \input \jobname.toc
+ \fi
+ \vfill \eject
+ \endgroup
+ \lastnegativepageno = \pageno
+ \pageno = \savepageno
+}
+
+% And just the chapters.
+\def\summarycontents{%
+ \startcontents{\putwordShortContents}%
+ %
+ \let\chapentry = \shortchapentry
+ \let\unnumbchapentry = \shortunnumberedentry
+ % We want a true roman here for the page numbers.
+ \secfonts
+ \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
+ \rm
+ \hyphenpenalty = 10000
+ \advance\baselineskip by 1pt % Open it up a little.
+ \def\secentry ##1##2##3##4{}
+ \def\unnumbsecentry ##1##2{}
+ \def\subsecentry ##1##2##3##4##5{}
+ \def\unnumbsubsecentry ##1##2{}
+ \def\subsubsecentry ##1##2##3##4##5##6{}
+ \def\unnumbsubsubsecentry ##1##2{}
+ \openin 1 \jobname.toc
+ \ifeof 1 \else
+ \closein 1
+ \input \jobname.toc
+ \fi
+ \vfill \eject
+ \endgroup
+ \lastnegativepageno = \pageno
+ \pageno = \savepageno
+}
+\let\shortcontents = \summarycontents
+
+% These macros generate individual entries in the table of contents.
+% The first argument is the chapter or section name.
+% The last argument is the page number.
+% The arguments in between are the chapter number, section number, ...
+
+% Chapter-level things, for both the long and short contents.
+\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
+
+% See comments in \dochapentry re vbox and related settings
+\def\shortchapentry#1#2#3{%
+ \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
+}
+
+% Typeset the label for a chapter or appendix for the short contents.
+% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
+% We could simplify the code here by writing out an \appendixentry
+% command in the toc file for appendices, instead of using \chapentry
+% for both, but it doesn't seem worth it.
+\setbox0 = \hbox{\shortcontrm \putwordAppendix }
+\newdimen\shortappendixwidth \shortappendixwidth = \wd0
+
+\def\shortchaplabel#1{%
+ % We typeset #1 in a box of constant width, regardless of the text of
+ % #1, so the chapter titles will come out aligned.
+ \setbox0 = \hbox{#1}%
+ \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
+ %
+ % This space should be plenty, since a single number is .5em, and the
+ % widest letter (M) is 1em, at least in the Computer Modern fonts.
+ % (This space doesn't include the extra space that gets added after
+ % the label; that gets put in by \shortchapentry above.)
+ \advance\dimen0 by 1.1em
+ \hbox to \dimen0{#1\hfil}%
+}
+
+\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
+\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
+
+% Sections.
+\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
+\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
+
+% Subsections.
+\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
+\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
+
+% And subsubsections.
+\def\subsubsecentry#1#2#3#4#5#6{%
+ \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
+\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
+
+% This parameter controls the indentation of the various levels.
+\newdimen\tocindent \tocindent = 3pc
+
+% Now for the actual typesetting. In all these, #1 is the text and #2 is the
+% page number.
+%
+% If the toc has to be broken over pages, we want it to be at chapters
+% if at all possible; hence the \penalty.
+\def\dochapentry#1#2{%
+ \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
+ \begingroup
+ \chapentryfonts
+ \tocentry{#1}{\dopageno{#2}}%
+ \endgroup
+ \nobreak\vskip .25\baselineskip plus.1\baselineskip
+}
+
+\def\dosecentry#1#2{\begingroup
+ \secentryfonts \leftskip=\tocindent
+ \tocentry{#1}{\dopageno{#2}}%
+\endgroup}
+
+\def\dosubsecentry#1#2{\begingroup
+ \subsecentryfonts \leftskip=2\tocindent
+ \tocentry{#1}{\dopageno{#2}}%
+\endgroup}
+
+\def\dosubsubsecentry#1#2{\begingroup
+ \subsubsecentryfonts \leftskip=3\tocindent
+ \tocentry{#1}{\dopageno{#2}}%
+\endgroup}
+
+% Final typesetting of a toc entry; we use the same \entry macro as for
+% the index entries, but we want to suppress hyphenation here. (We
+% can't do that in the \entry macro, since index entries might consist
+% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
+\def\tocentry#1#2{\begingroup
+ \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
+ % Do not use \turnoffactive in these arguments. Since the toc is
+ % typeset in cmr, so characters such as _ would come out wrong; we
+ % have to do the usual translation tricks.
+ \entry{#1}{#2}%
+\endgroup}
+
+% Space between chapter (or whatever) number and the title.
+\def\labelspace{\hskip1em \relax}
+
+\def\dopageno#1{{\rm #1}}
+\def\doshortpageno#1{{\rm #1}}
+
+\def\chapentryfonts{\secfonts \rm}
+\def\secentryfonts{\textfonts}
+\let\subsecentryfonts = \textfonts
+\let\subsubsecentryfonts = \textfonts
+
+
+\message{environments,}
+
+% Since these characters are used in examples, it should be an even number of
+% \tt widths. Each \tt character is 1en, so two makes it 1em.
+% Furthermore, these definitions must come after we define our fonts.
+\newbox\dblarrowbox \newbox\longdblarrowbox
+\newbox\pushcharbox \newbox\bullbox
+\newbox\equivbox \newbox\errorbox
+
+%{\tentt
+%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
+%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
+%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
+%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
+% Adapted from the manmac format (p.420 of TeXbook)
+%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
+% depth .1ex\hfil}
+%}
+
+% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+\def\point{$\star$}
+\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
+\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
+\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
+\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
+
+% Adapted from the TeXbook's \boxit.
+{\tentt \global\dimen0 = 3em}% Width of the box.
+\dimen2 = .55pt % Thickness of rules
+% The text. (`r' is open on the right, `e' somewhat less so on the left.)
+\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
+
+\global\setbox\errorbox=\hbox to \dimen0{\hfil
+ \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
+ \advance\hsize by -2\dimen2 % Rules.
+ \vbox{
+ \hrule height\dimen2
+ \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
+ \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
+ \kern3pt\vrule width\dimen2}% Space to right.
+ \hrule height\dimen2}
+ \hfil}
+
+% The @error{} command.
+\def\error{\leavevmode\lower.7ex\copy\errorbox}
+
+% @tex ... @end tex escapes into raw Tex temporarily.
+% One exception: @ is still an escape character, so that @end tex works.
+% But \@ or @@ will get a plain tex @ character.
+
+\def\tex{\begingroup
+ \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
+ \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
+ \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
+ \catcode `\%=14
+ \catcode 43=12 % plus
+ \catcode`\"=12
+ \catcode`\==12
+ \catcode`\|=12
+ \catcode`\<=12
+ \catcode`\>=12
+ \escapechar=`\\
+ %
+ \let\b=\ptexb
+ \let\bullet=\ptexbullet
+ \let\c=\ptexc
+ \let\,=\ptexcomma
+ \let\.=\ptexdot
+ \let\dots=\ptexdots
+ \let\equiv=\ptexequiv
+ \let\!=\ptexexclam
+ \let\i=\ptexi
+ \let\{=\ptexlbrace
+ \let\+=\tabalign
+ \let\}=\ptexrbrace
+ \let\*=\ptexstar
+ \let\t=\ptext
+ %
+ \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
+ \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
+ \def\@{@}%
+\let\Etex=\endgroup}
+
+% Define @lisp ... @endlisp.
+% @lisp does a \begingroup so it can rebind things,
+% including the definition of @endlisp (which normally is erroneous).
+
+% Amount to narrow the margins by for @lisp.
+\newskip\lispnarrowing \lispnarrowing=0.4in
+
+% This is the definition that ^^M gets inside @lisp, @example, and other
+% such environments. \null is better than a space, since it doesn't
+% have any width.
+\def\lisppar{\null\endgraf}
+
+% Make each space character in the input produce a normal interword
+% space in the output. Don't allow a line break at this space, as this
+% is used only in environments like @example, where each line of input
+% should produce a line of output anyway.
+%
+{\obeyspaces %
+\gdef\sepspaces{\obeyspaces\let =\tie}}
+
+% Define \obeyedspace to be our active space, whatever it is. This is
+% for use in \parsearg.
+{\sepspaces%
+\global\let\obeyedspace= }
+
+% This space is always present above and below environments.
+\newskip\envskipamount \envskipamount = 0pt
+
+% Make spacing and below environment symmetrical. We use \parskip here
+% to help in doing that, since in @example-like environments \parskip
+% is reset to zero; thus the \afterenvbreak inserts no space -- but the
+% start of the next paragraph will insert \parskip
+%
+\def\aboveenvbreak{{\advance\envskipamount by \parskip
+\endgraf \ifdim\lastskip<\envskipamount
+\removelastskip \penalty-50 \vskip\envskipamount \fi}}
+
+\let\afterenvbreak = \aboveenvbreak
+
+% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins.
+\let\nonarrowing=\relax
+
+% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
+% environment contents.
+\font\circle=lcircle10
+\newdimen\circthick
+\newdimen\cartouter\newdimen\cartinner
+\newskip\normbskip\newskip\normpskip\newskip\normlskip
+\circthick=\fontdimen8\circle
+%
+\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
+\def\ctr{{\hskip 6pt\circle\char'010}}
+\def\cbl{{\circle\char'012\hskip -6pt}}
+\def\cbr{{\hskip 6pt\circle\char'011}}
+\def\carttop{\hbox to \cartouter{\hskip\lskip
+ \ctl\leaders\hrule height\circthick\hfil\ctr
+ \hskip\rskip}}
+\def\cartbot{\hbox to \cartouter{\hskip\lskip
+ \cbl\leaders\hrule height\circthick\hfil\cbr
+ \hskip\rskip}}
+%
+\newskip\lskip\newskip\rskip
+
+\long\def\cartouche{%
+\begingroup
+ \lskip=\leftskip \rskip=\rightskip
+ \leftskip=0pt\rightskip=0pt %we want these *outside*.
+ \cartinner=\hsize \advance\cartinner by-\lskip
+ \advance\cartinner by-\rskip
+ \cartouter=\hsize
+ \advance\cartouter by 18.4pt % allow for 3pt kerns on either
+% side, and for 6pt waste from
+% each corner char, and rule thickness
+ \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
+ % Flag to tell @lisp, etc., not to narrow margin.
+ \let\nonarrowing=\comment
+ \vbox\bgroup
+ \baselineskip=0pt\parskip=0pt\lineskip=0pt
+ \carttop
+ \hbox\bgroup
+ \hskip\lskip
+ \vrule\kern3pt
+ \vbox\bgroup
+ \hsize=\cartinner
+ \kern3pt
+ \begingroup
+ \baselineskip=\normbskip
+ \lineskip=\normlskip
+ \parskip=\normpskip
+ \vskip -\parskip
+\def\Ecartouche{%
+ \endgroup
+ \kern3pt
+ \egroup
+ \kern3pt\vrule
+ \hskip\rskip
+ \egroup
+ \cartbot
+ \egroup
+\endgroup
+}}
+
+
+% This macro is called at the beginning of all the @example variants,
+% inside a group.
+\def\nonfillstart{%
+ \aboveenvbreak
+ \inENV % This group ends at the end of the body
+ \hfuzz = 12pt % Don't be fussy
+ \sepspaces % Make spaces be word-separators rather than space tokens.
+ \singlespace
+ \let\par = \lisppar % don't ignore blank lines
+ \obeylines % each line of input is a line of output
+ \parskip = 0pt
+ \parindent = 0pt
+ \emergencystretch = 0pt % don't try to avoid overfull boxes
+ % @cartouche defines \nonarrowing to inhibit narrowing
+ % at next level down.
+ \ifx\nonarrowing\relax
+ \advance \leftskip by \lispnarrowing
+ \exdentamount=\lispnarrowing
+ \let\exdent=\nofillexdent
+ \let\nonarrowing=\relax
+ \fi
+}
+
+% Define the \E... control sequence only if we are inside the particular
+% environment, so the error checking in \end will work.
+%
+% To end an @example-like environment, we first end the paragraph (via
+% \afterenvbreak's vertical glue), and then the group. That way we keep
+% the zero \parskip that the environments set -- \parskip glue will be
+% inserted at the beginning of the next paragraph in the document, after
+% the environment.
+%
+\def\nonfillfinish{\afterenvbreak\endgroup}
+
+% @lisp: indented, narrowed, typewriter font.
+\def\lisp{\begingroup
+ \nonfillstart
+ \let\Elisp = \nonfillfinish
+ \tt
+ \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
+ \gobble % eat return
+}
+
+% @example: Same as @lisp.
+\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
+
+% @small... is usually equivalent to the non-small (@smallbook
+% redefines). We must call \example (or whatever) last in the
+% definition, since it reads the return following the @example (or
+% whatever) command.
+%
+% This actually allows (for example) @end display inside an
+% @smalldisplay. Too bad, but makeinfo will catch the error anyway.
+%
+\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
+\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
+\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
+\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
+
+% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
+% Originally contributed by Pavel@xerox.
+\def\smalllispx{\begingroup
+ \def\Esmalllisp{\nonfillfinish\endgroup}%
+ \def\Esmallexample{\nonfillfinish\endgroup}%
+ \indexfonts
+ \lisp
+}
+
+% @display: same as @lisp except keep current font.
+%
+\def\display{\begingroup
+ \nonfillstart
+ \let\Edisplay = \nonfillfinish
+ \gobble
+}
+
+% @smalldisplay (when @smallbook): @display plus smaller fonts.
+%
+\def\smalldisplayx{\begingroup
+ \def\Esmalldisplay{\nonfillfinish\endgroup}%
+ \indexfonts \rm
+ \display
+}
+
+% @format: same as @display except don't narrow margins.
+%
+\def\format{\begingroup
+ \let\nonarrowing = t
+ \nonfillstart
+ \let\Eformat = \nonfillfinish
+ \gobble
+}
+
+% @smallformat (when @smallbook): @format plus smaller fonts.
+%
+\def\smallformatx{\begingroup
+ \def\Esmallformat{\nonfillfinish\endgroup}%
+ \indexfonts \rm
+ \format
+}
+
+% @flushleft (same as @format).
+%
+\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
+
+% @flushright.
+%
+\def\flushright{\begingroup
+ \let\nonarrowing = t
+ \nonfillstart
+ \let\Eflushright = \nonfillfinish
+ \advance\leftskip by 0pt plus 1fill
+ \gobble
+}
+
+% @quotation does normal linebreaking (hence we can't use \nonfillstart)
+% and narrows the margins.
+%
+\def\quotation{%
+ \begingroup\inENV %This group ends at the end of the @quotation body
+ {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
+ \singlespace
+ \parindent=0pt
+ % We have retained a nonzero parskip for the environment, since we're
+ % doing normal filling. So to avoid extra space below the environment...
+ \def\Equotation{\parskip = 0pt \nonfillfinish}%
+ %
+ % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
+ \ifx\nonarrowing\relax
+ \advance\leftskip by \lispnarrowing
+ \advance\rightskip by \lispnarrowing
+ \exdentamount = \lispnarrowing
+ \let\nonarrowing = \relax
+ \fi
+}
+
+
+\message{defuns,}
+% Define formatter for defuns
+% First, allow user to change definition object font (\df) internally
+\def\setdeffont #1 {\csname DEF#1\endcsname}
+
+\newskip\defbodyindent \defbodyindent=.4in
+\newskip\defargsindent \defargsindent=50pt
+\newskip\deftypemargin \deftypemargin=12pt
+\newskip\deflastargmargin \deflastargmargin=18pt
+
+\newcount\parencount
+% define \functionparens, which makes ( and ) and & do special things.
+% \functionparens affects the group it is contained in.
+\def\activeparens{%
+\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
+\catcode`\[=\active \catcode`\]=\active}
+
+% Make control sequences which act like normal parenthesis chars.
+\let\lparen = ( \let\rparen = )
+
+{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
+
+% Be sure that we always have a definition for `(', etc. For example,
+% if the fn name has parens in it, \boldbrax will not be in effect yet,
+% so TeX would otherwise complain about undefined control sequence.
+\global\let(=\lparen \global\let)=\rparen
+\global\let[=\lbrack \global\let]=\rbrack
+
+\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
+\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
+% This is used to turn on special parens
+% but make & act ordinary (given that it's active).
+\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
+
+% Definitions of (, ) and & used in args for functions.
+% This is the definition of ( outside of all parentheses.
+\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
+ \global\advance\parencount by 1
+}
+%
+% This is the definition of ( when already inside a level of parens.
+\gdef\opnested{\char`\(\global\advance\parencount by 1 }
+%
+\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
+ % also in that case restore the outer-level definition of (.
+ \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
+ \global\advance \parencount by -1 }
+% If we encounter &foo, then turn on ()-hacking afterwards
+\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
+%
+\gdef\normalparens{\boldbrax\let&=\ampnr}
+} % End of definition inside \activeparens
+%% These parens (in \boldbrax) actually are a little bolder than the
+%% contained text. This is especially needed for [ and ]
+\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
+\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
+\def\ampnr{\&}
+\def\lbrb{{\bf\char`\[}}
+\def\rbrb{{\bf\char`\]}}
+
+% First, defname, which formats the header line itself.
+% #1 should be the function name.
+% #2 should be the type of definition, such as "Function".
+
+\def\defname #1#2{%
+% Get the values of \leftskip and \rightskip as they were
+% outside the @def...
+\dimen2=\leftskip
+\advance\dimen2 by -\defbodyindent
+\noindent
+\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
+\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
+\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
+\parshape 2 0in \dimen0 \defargsindent \dimen1
+% Now output arg 2 ("Function" or some such)
+% ending at \deftypemargin from the right margin,
+% but stuck inside a box of width 0 so it does not interfere with linebreaking
+{% Adjust \hsize to exclude the ambient margins,
+% so that \rightline will obey them.
+\advance \hsize by -\dimen2
+\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
+% Make all lines underfull and no complaints:
+\tolerance=10000 \hbadness=10000
+\advance\leftskip by -\defbodyindent
+\exdentamount=\defbodyindent
+{\df #1}\enskip % Generate function name
+}
+
+% Actually process the body of a definition
+% #1 should be the terminating control sequence, such as \Edefun.
+% #2 should be the "another name" control sequence, such as \defunx.
+% #3 should be the control sequence that actually processes the header,
+% such as \defunheader.
+
+\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup %
+\catcode 61=\active % 61 is `='
+\obeylines\activeparens\spacesplit#3}
+
+% #1 is the \E... control sequence to end the definition (which we define).
+% #2 is the \...x control sequence for consecutive fns (which we define).
+% #3 is the control sequence to call to resume processing.
+% #4, delimited by the space, is the class name.
+%
+\def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
+
+% @deftypemethod has an extra argument that nothing else does. Sigh.
+% #1 is the \E... control sequence to end the definition (which we define).
+% #2 is the \...x control sequence for consecutive fns (which we define).
+% #3 is the control sequence to call to resume processing.
+% #4, delimited by the space, is the class name.
+% #5 is the method's return type.
+%
+\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV %
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
+
+\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2##1 ##2 {\def#4{##1}%
+\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
+
+% These parsing functions are similar to the preceding ones
+% except that they do not make parens into active characters.
+% These are used for "variables" since they have no arguments.
+
+\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2{\begingroup\obeylines\spacesplit#3}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup %
+\catcode 61=\active %
+\obeylines\spacesplit#3}
+
+% This is used for \def{tp,vr}parsebody. It could probably be used for
+% some of the others, too, with some judicious conditionals.
+%
+\def\parsebodycommon#1#2#3{%
+ \begingroup\inENV %
+ \medbreak %
+ % Define the end token that this defining construct specifies
+ % so that it will exit this group.
+ \def#1{\endgraf\endgroup\medbreak}%
+ \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
+ \parindent=0in
+ \advance\leftskip by \defbodyindent
+ \exdentamount=\defbodyindent
+ \begingroup\obeylines
+}
+
+\def\defvrparsebody#1#2#3#4 {%
+ \parsebodycommon{#1}{#2}{#3}%
+ \spacesplit{#3{#4}}%
+}
+
+% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
+% type is just `struct', because we lose the braces in `{struct
+% termios}' when \spacesplit reads its undelimited argument. Sigh.
+% \let\deftpparsebody=\defvrparsebody
+%
+% So, to get around this, we put \empty in with the type name. That
+% way, TeX won't find exactly `{...}' as an undelimited argument, and
+% won't strip off the braces.
+%
+\def\deftpparsebody #1#2#3#4 {%
+ \parsebodycommon{#1}{#2}{#3}%
+ \spacesplit{\parsetpheaderline{#3{#4}}}\empty
+}
+
+% Fine, but then we have to eventually remove the \empty *and* the
+% braces (if any). That's what this does.
+%
+\def\removeemptybraces\empty#1\relax{#1}
+
+% After \spacesplit has done its work, this is called -- #1 is the final
+% thing to call, #2 the type name (which starts with \empty), and #3
+% (which might be empty) the arguments.
+%
+\def\parsetpheaderline#1#2#3{%
+ #1{\removeemptybraces#2\relax}{#3}%
+}%
+
+\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
+\medbreak %
+% Define the end token that this defining construct specifies
+% so that it will exit this group.
+\def#1{\endgraf\endgroup\medbreak}%
+\def#2##1 ##2 {\def#4{##1}%
+\begingroup\obeylines\spacesplit{#3{##2}}}%
+\parindent=0in
+\advance\leftskip by \defbodyindent
+\exdentamount=\defbodyindent
+\begingroup\obeylines\spacesplit{#3{#5}}}
+
+% Split up #2 at the first space token.
+% call #1 with two arguments:
+% the first is all of #2 before the space token,
+% the second is all of #2 after that space token.
+% If #2 contains no space token, all of it is passed as the first arg
+% and the second is passed as empty.
+
+{\obeylines
+\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
+\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
+\ifx\relax #3%
+#1{#2}{}\else #1{#2}{#3#4}\fi}}
+
+% So much for the things common to all kinds of definitions.
+
+% Define @defun.
+
+% First, define the processing that is wanted for arguments of \defun
+% Use this to expand the args and terminate the paragraph they make up
+
+\def\defunargs #1{\functionparens \sl
+% Expand, preventing hyphenation at `-' chars.
+% Note that groups don't affect changes in \hyphenchar.
+\hyphenchar\tensl=0
+#1%
+\hyphenchar\tensl=45
+\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
+\interlinepenalty=10000
+\advance\rightskip by 0pt plus 1fil
+\endgraf\nobreak\vskip -\parskip\nobreak
+}
+
+\def\deftypefunargs #1{%
+% Expand, preventing hyphenation at `-' chars.
+% Note that groups don't affect changes in \hyphenchar.
+% Use \boldbraxnoamp, not \functionparens, so that & is not special.
+\boldbraxnoamp
+\tclose{#1}% avoid \code because of side effects on active chars
+\interlinepenalty=10000
+\advance\rightskip by 0pt plus 1fil
+\endgraf\nobreak\vskip -\parskip\nobreak
+}
+
+% Do complete processing of one @defun or @defunx line already parsed.
+
+% @deffn Command forward-char nchars
+
+\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
+
+\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
+\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% @defun == @deffn Function
+
+\def\defun{\defparsebody\Edefun\defunx\defunheader}
+
+\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Function}%
+\defunargs {#2}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% @deftypefun int foobar (int @var{foo}, float @var{bar})
+
+\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
+
+% #1 is the data type. #2 is the name and args.
+\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
+% #1 is the data type, #2 the name, #3 the args.
+\def\deftypefunheaderx #1#2 #3\relax{%
+\doind {fn}{\code{#2}}% Make entry in function index
+\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}%
+\deftypefunargs {#3}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
+
+\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
+
+% \defheaderxcond#1\relax$$$
+% puts #1 in @code, followed by a space, but does nothing if #1 is null.
+\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
+
+% #1 is the classification. #2 is the data type. #3 is the name and args.
+\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
+% #1 is the classification, #2 the data type, #3 the name, #4 the args.
+\def\deftypefnheaderx #1#2#3 #4\relax{%
+\doind {fn}{\code{#3}}% Make entry in function index
+\begingroup
+\normalparens % notably, turn off `&' magic, which prevents
+% at least some C++ text from working
+\defname {\defheaderxcond#2\relax$$$#3}{#1}%
+\deftypefunargs {#4}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% @defmac == @deffn Macro
+
+\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
+
+\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Macro}%
+\defunargs {#2}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% @defspec == @deffn Special Form
+
+\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
+
+\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
+\begingroup\defname {#1}{Special Form}%
+\defunargs {#2}\endgroup %
+\catcode 61=\other % Turn off change made in \defparsebody
+}
+
+% This definition is run if you use @defunx
+% anywhere other than immediately after a @defun or @defunx.
+
+\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
+\def\defunx #1 {\errmessage{@defunx in invalid context}}
+\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
+\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
+\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
+\def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}}
+\def\deftypefunx #1 {\errmessage{@deftypefunx in invalid context}}
+
+% @defmethod, and so on
+
+% @defop CATEGORY CLASS OPERATION ARG...
+
+\def\defop #1 {\def\defoptype{#1}%
+\defopparsebody\Edefop\defopx\defopheader\defoptype}
+
+\def\defopheader #1#2#3{%
+\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
+\begingroup\defname {#2}{\defoptype{} on #1}%
+\defunargs {#3}\endgroup %
+}
+
+% @deftypemethod CLASS RETURN-TYPE METHOD ARG...
+%
+\def\deftypemethod{%
+ \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
+%
+% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
+\def\deftypemethodheader#1#2#3#4{%
+ \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
+ \begingroup
+ \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
+ \deftypefunargs{#4}%
+ \endgroup
+}
+
+% @defmethod == @defop Method
+%
+\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
+%
+% #1 is the class name, #2 the method name, #3 the args.
+\def\defmethodheader#1#2#3{%
+ \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
+ \begingroup
+ \defname{#2}{\putwordMethodon\ \code{#1}}%
+ \defunargs{#3}%
+ \endgroup
+}
+
+% @defcv {Class Option} foo-class foo-flag
+
+\def\defcv #1 {\def\defcvtype{#1}%
+\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
+
+\def\defcvarheader #1#2#3{%
+\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
+\begingroup\defname {#2}{\defcvtype{} of #1}%
+\defvarargs {#3}\endgroup %
+}
+
+% @defivar == @defcv {Instance Variable}
+
+\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
+
+\def\defivarheader #1#2#3{%
+\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
+\begingroup\defname {#2}{Instance Variable of #1}%
+\defvarargs {#3}\endgroup %
+}
+
+% These definitions are run if you use @defmethodx, etc.,
+% anywhere other than immediately after a @defmethod, etc.
+
+\def\defopx #1 {\errmessage{@defopx in invalid context}}
+\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
+\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
+\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
+
+% Now @defvar
+
+% First, define the processing that is wanted for arguments of @defvar.
+% This is actually simple: just print them in roman.
+% This must expand the args and terminate the paragraph they make up
+\def\defvarargs #1{\normalparens #1%
+\interlinepenalty=10000
+\endgraf\nobreak\vskip -\parskip\nobreak}
+
+% @defvr Counter foo-count
+
+\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
+
+\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
+\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
+
+% @defvar == @defvr Variable
+
+\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
+
+\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
+\begingroup\defname {#1}{Variable}%
+\defvarargs {#2}\endgroup %
+}
+
+% @defopt == @defvr {User Option}
+
+\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
+
+\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
+\begingroup\defname {#1}{User Option}%
+\defvarargs {#2}\endgroup %
+}
+
+% @deftypevar int foobar
+
+\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
+
+% #1 is the data type. #2 is the name, perhaps followed by text that
+% is actually part of the data type, which should not be put into the index.
+\def\deftypevarheader #1#2{%
+\dovarind#2 \relax% Make entry in variables index
+\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}%
+\interlinepenalty=10000
+\endgraf\nobreak\vskip -\parskip\nobreak
+\endgroup}
+\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
+
+% @deftypevr {Global Flag} int enable
+
+\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
+
+\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
+\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
+\interlinepenalty=10000
+\endgraf\nobreak\vskip -\parskip\nobreak
+\endgroup}
+
+% This definition is run if you use @defvarx
+% anywhere other than immediately after a @defvar or @defvarx.
+
+\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
+\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
+\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
+\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
+\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
+
+% Now define @deftp
+% Args are printed in bold, a slight difference from @defvar.
+
+\def\deftpargs #1{\bf \defvarargs{#1}}
+
+% @deftp Class window height width ...
+
+\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
+
+\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
+\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
+
+% This definition is run if you use @deftpx, etc
+% anywhere other than immediately after a @deftp, etc.
+
+\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
+
+
+\message{macros,}
+% @macro.
+
+% To do this right we need a feature of e-TeX, \scantokens,
+% which we arrange to emulate with a temporary file in ordinary TeX.
+\ifx\eTeXversion\undefined
+ \newwrite\macscribble
+ \def\scanmacro#1{%
+ \begingroup \newlinechar`\^^M
+ \immediate\openout\macscribble=\jobname.tmp
+ \immediate\write\macscribble{#1}%
+ \immediate\closeout\macscribble
+ \let\xeatspaces\eatspaces
+ \input \jobname.tmp
+ \endgroup
+}
+\else
+\def\scanmacro#1{%
+\begingroup \newlinechar`\^^M
+\let\xeatspaces\eatspaces\scantokens{#1}\endgroup}
+\fi
+
+\newcount\paramno % Count of parameters
+\newtoks\macname % Macro name
+\newif\ifrecursive % Is it recursive?
+
+% Utility routines.
+% Thisdoes \let #1 = #2, except with \csnames.
+\def\cslet#1#2{%
+\expandafter\expandafter
+\expandafter\let
+\expandafter\expandafter
+\csname#1\endcsname
+\csname#2\endcsname}
+
+% Trim leading and trailing spaces off a string.
+% Concepts from aro-bend problem 15 (see CTAN).
+{\catcode`\@=11
+\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
+\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
+\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
+\def\unbrace#1{#1}
+\unbrace{\gdef\trim@@@ #1 } #2@{#1}
+}
+
+% Trim a single trailing ^^M off a string.
+{\catcode`\^^M=12\catcode`\Q=3%
+\gdef\eatcr #1{\eatcra #1Q^^MQ}%
+\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
+\gdef\eatcrb#1Q#2Q{#1}%
+}
+
+% Macro bodies are absorbed as an argument in a context where
+% all characters are catcode 10, 11 or 12, except \ which is active
+% (as in normal texinfo). It is necessary to change the definition of \.
+
+% It's necessary to have hard CRs when the macro is executed. This is
+% done by making ^^M (\endlinechar) catcode 12 when reading the macro
+% body, and then making it the \newlinechar in \scanmacro.
+
+\def\macrobodyctxt{%
+ \catcode`\~=12
+ \catcode`\^=12
+ \catcode`\_=12
+ \catcode`\|=12
+ \catcode`\<=12
+ \catcode`\>=12
+ \catcode`\+=12
+ \catcode`\{=12
+ \catcode`\}=12
+ \catcode`\@=12
+ \catcode`\^^M=12
+ \usembodybackslash}
+
+\def\macroargctxt{%
+ \catcode`\~=12
+ \catcode`\^=12
+ \catcode`\_=12
+ \catcode`\|=12
+ \catcode`\<=12
+ \catcode`\>=12
+ \catcode`\+=12
+ \catcode`\@=12
+ \catcode`\\=12}
+
+% \mbodybackslash is the definition of \ in @macro bodies.
+% It maps \foo\ => \csname macarg.foo\endcsname => #N
+% where N is the macro parameter number.
+% We define \csname macarg.\endcsname to be \realbackslash, so
+% \\ in macro replacement text gets you a backslash.
+
+{\catcode`@=0 @catcode`@\=@active
+ @gdef@usembodybackslash{@let\=@mbodybackslash}
+ @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
+}
+\expandafter\def\csname macarg.\endcsname{\realbackslash}
+
+\def\macro{\recursivefalse\parsearg\macroxxx}
+\def\rmacro{\recursivetrue\parsearg\macroxxx}
+
+\def\macroxxx#1{%
+ \getargs{#1}% now \macname is the macname and \argl the arglist
+ \ifx\argl\empty % no arguments
+ \paramno=0%
+ \else
+ \expandafter\parsemargdef \argl;%
+ \fi
+ \expandafter\ifx \csname macsave.\the\macname\endcsname \relax
+ \cslet{macsave.\the\macname}{\the\macname}%
+ \else
+ \message{Warning: redefining \the\macname}%
+ \fi
+ \begingroup \macrobodyctxt
+ \ifrecursive \expandafter\parsermacbody
+ \else \expandafter\parsemacbody
+ \fi}
+
+\def\unmacro{\parsearg\unmacroxxx}
+\def\unmacroxxx#1{%
+ \expandafter\ifx \csname macsave.\the\macname\endcsname \relax
+ \errmessage{Macro \the\macname\ not defined.}%
+ \else
+ \cslet{#1}{macsave.#1}%
+ \expandafter\let \csname macsave.\the\macname\endcsname \undefined
+ \fi
+}
+
+% This makes use of the obscure feature that if the last token of a
+% is #, then the preceding argument is delimited by
+% an opening brace, and that opening brace is not consumed.
+\def\getargs#1{\getargsxxx#1{}}
+\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
+\def\getmacname #1 #2\relax{\macname={#1}}
+\def\getmacargs#1{\def\argl{#1}}
+
+% Parse the optional {params} list. Set up \paramno and \paramlist
+% so \defmacro knows what to do. Define \macarg.blah for each blah
+% in the params list, to be ##N where N is the position in that list.
+% That gets used by \mbodybackslash (above).
+
+% We need to get `macro parameter char #' into several definitions.
+% The technique used is stolen from LaTeX: let \hash be something
+% unexpandable, insert that wherever you need a #, and then redefine
+% it to # just before using the token list produced.
+%
+% The same technique is used to protect \eatspaces till just before
+% the macro is used.
+
+\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
+ \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
+\def\parsemargdefxxx#1,{%
+ \if#1;\let\next=\relax
+ \else \let\next=\parsemargdefxxx
+ \advance\paramno by 1%
+ \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
+ {\xeatspaces{\hash\the\paramno}}%
+ \edef\paramlist{\paramlist\hash\the\paramno,}%
+ \fi\next}
+
+% These two commands read recursive and nonrecursive macro bodies.
+% (They're different since rec and nonrec macros end differently.)
+
+\long\def\parsemacbody#1@end macro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+\long\def\parsermacbody#1@end rmacro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+
+% This defines the macro itself. There are six cases: recursive and
+% nonrecursive macros of zero, one, and many arguments.
+% Much magic with \expandafter here.
+% \xdef is used so that macro definitions will survive the file
+% they're defined in; @include reads the file inside a group.
+\def\defmacro{%
+ \let\hash=##% convert placeholders to macro parameter chars
+ \ifrecursive
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\scanmacro{\temp}}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup\noexpand\scanmacro{\temp}}%
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\csname\the\macname xx\endcsname}
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{\egroup\noexpand\scanmacro{\temp}}%
+ \fi
+ \else
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\csname\the\macname xx\endcsname}
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \fi
+ \fi}
+
+\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
+
+% \braceorline decides whether the next nonwhitespace character is a
+% {. If so it reads up to the closing }, if not, it reads the whole
+% line. Whatever was read is then fed to the next control sequence
+% as an argument (by \parsebrace or \parsearg)
+\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
+\def\braceorlinexxx{%
+ \ifx\nchar\bgroup\else
+ \expandafter\parsearg
+ \fi \next}
+
+
+\message{cross references,}
+\newwrite\auxfile
+
+\newif\ifhavexrefs % True if xref values are known.
+\newif\ifwarnedxrefs % True if we warned once that they aren't known.
+
+% @inforef is relatively simple.
+\def\inforef #1{\inforefzzz #1,,,,**}
+\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
+ node \samp{\ignorespaces#1{}}}
+
+% @node's job is to define \lastnode.
+\def\node{\ENVcheck\parsearg\nodezzz}
+\def\nodezzz#1{\nodexxx [#1,]}
+\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
+\let\nwnode=\node
+\let\lastnode=\relax
+
+% The sectioning commands (@chapter, etc.) call these.
+\def\donoderef{%
+ \ifx\lastnode\relax\else
+ \expandafter\expandafter\expandafter\setref{\lastnode}%
+ {Ysectionnumberandtype}%
+ \global\let\lastnode=\relax
+ \fi
+}
+\def\unnumbnoderef{%
+ \ifx\lastnode\relax\else
+ \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
+ \global\let\lastnode=\relax
+ \fi
+}
+\def\appendixnoderef{%
+ \ifx\lastnode\relax\else
+ \expandafter\expandafter\expandafter\setref{\lastnode}%
+ {Yappendixletterandtype}%
+ \global\let\lastnode=\relax
+ \fi
+}
+
+
+% @anchor{NAME} -- define xref target at arbitrary point.
+%
+\def\anchor#1{\setref{#1}{Ynothing}}
+
+
+% \setref{NAME}{SNT} defines a cross-reference point NAME, namely
+% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have
+% to set \indexdummies so commands such as @code in a section title
+% aren't expanded. It would be nicer not to expand the titles in the
+% first place, but there's so many layers that that is hard to do.
+%
+\def\setref#1#2{{%
+ \indexdummies
+ \dosetq{#1-title}{Ytitle}%
+ \dosetq{#1-pg}{Ypagenumber}%
+ \dosetq{#1-snt}{#2}
+}}
+
+% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
+% the node name, #2 the name of the Info cross-reference, #3 the printed
+% node name, #4 the name of the Info file, #5 the name of the printed
+% manual. All but the node name can be omitted.
+%
+\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
+\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
+\def\ref#1{\xrefX[#1,,,,,,,]}
+\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
+ \def\printedmanual{\ignorespaces #5}%
+ \def\printednodename{\ignorespaces #3}%
+ \setbox1=\hbox{\printedmanual}%
+ \setbox0=\hbox{\printednodename}%
+ \ifdim \wd0 = 0pt
+ % No printed node name was explicitly given.
+ \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
+ % Use the node name inside the square brackets.
+ \def\printednodename{\ignorespaces #1}%
+ \else
+ % Use the actual chapter/section title appear inside
+ % the square brackets. Use the real section title if we have it.
+ \ifdim \wd1 > 0pt
+ % It is in another manual, so we don't have it.
+ \def\printednodename{\ignorespaces #1}%
+ \else
+ \ifhavexrefs
+ % We know the real title if we have the xref values.
+ \def\printednodename{\refx{#1-title}{}}%
+ \else
+ % Otherwise just copy the Info node name.
+ \def\printednodename{\ignorespaces #1}%
+ \fi%
+ \fi
+ \fi
+ \fi
+ %
+ % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
+ % insert empty discretionaries after hyphens, which means that it will
+ % not find a line break at a hyphen in a node names. Since some manuals
+ % are best written with fairly long node names, containing hyphens, this
+ % is a loss. Therefore, we give the text of the node name again, so it
+ % is as if TeX is seeing it for the first time.
+ \ifdim \wd1 > 0pt
+ \putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
+ \else
+ % _ (for example) has to be the character _ for the purposes of the
+ % control sequence corresponding to the node, but it has to expand
+ % into the usual \leavevmode...\vrule stuff for purposes of
+ % printing. So we \turnoffactive for the \refx-snt, back on for the
+ % printing, back off for the \refx-pg.
+ {\normalturnoffactive
+ % Only output a following space if the -snt ref is nonempty; for
+ % @unnumbered and @anchor, it won't be.
+ \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
+ \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
+ }%
+ % [mynode],
+ [\printednodename],\space
+ % page 3
+ \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
+ \fi
+\endgroup}
+
+% \dosetq is the interface for calls from other macros
+
+% Use \normalturnoffactive so that punctuation chars such as underscore
+% and backslash work in node names. (\turnoffactive doesn't do \.)
+\def\dosetq#1#2{%
+ {\let\folio=0
+ \normalturnoffactive
+ \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
+ \iflinks
+ \next
+ \fi
+ }%
+}
+
+% \internalsetq {foo}{page} expands into
+% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
+% When the aux file is read, ' is the escape character
+
+\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
+
+% Things to be expanded by \internalsetq
+
+\def\Ypagenumber{\folio}
+
+\def\Ytitle{\thissection}
+
+\def\Ynothing{}
+
+\def\Ysectionnumberandtype{%
+\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
+\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
+\else \ifnum \subsubsecno=0 %
+\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
+\else %
+\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
+\fi \fi \fi }
+
+\def\Yappendixletterandtype{%
+\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
+\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
+\else \ifnum \subsubsecno=0 %
+\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
+\else %
+\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
+\fi \fi \fi }
+
+\gdef\xreftie{'tie}
+
+% Use TeX 3.0's \inputlineno to get the line number, for better error
+% messages, but if we're using an old version of TeX, don't do anything.
+%
+\ifx\inputlineno\thisisundefined
+ \let\linenumber = \empty % Non-3.0.
+\else
+ \def\linenumber{\the\inputlineno:\space}
+\fi
+
+% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
+% If its value is nonempty, SUFFIX is output afterward.
+
+\def\refx#1#2{%
+ \expandafter\ifx\csname X#1\endcsname\relax
+ % If not defined, say something at least.
+ \angleleft un\-de\-fined\angleright
+ \iflinks
+ \ifhavexrefs
+ \message{\linenumber Undefined cross reference `#1'.}%
+ \else
+ \ifwarnedxrefs\else
+ \global\warnedxrefstrue
+ \message{Cross reference values unknown; you must run TeX again.}%
+ \fi
+ \fi
+ \fi
+ \else
+ % It's defined, so just use it.
+ \csname X#1\endcsname
+ \fi
+ #2% Output the suffix in any case.
+}
+
+% This is the macro invoked by entries in the aux file.
+%
+\def\xrdef#1{\begingroup
+ % Reenable \ as an escape while reading the second argument.
+ \catcode`\\ = 0
+ \afterassignment\endgroup
+ \expandafter\gdef\csname X#1\endcsname
+}
+
+% Read the last existing aux file, if any. No error if none exists.
+\def\readauxfile{\begingroup
+ \catcode`\^^@=\other
+ \catcode`\^^A=\other
+ \catcode`\^^B=\other
+ \catcode`\^^C=\other
+ \catcode`\^^D=\other
+ \catcode`\^^E=\other
+ \catcode`\^^F=\other
+ \catcode`\^^G=\other
+ \catcode`\^^H=\other
+ \catcode`\^^K=\other
+ \catcode`\^^L=\other
+ \catcode`\^^N=\other
+ \catcode`\^^P=\other
+ \catcode`\^^Q=\other
+ \catcode`\^^R=\other
+ \catcode`\^^S=\other
+ \catcode`\^^T=\other
+ \catcode`\^^U=\other
+ \catcode`\^^V=\other
+ \catcode`\^^W=\other
+ \catcode`\^^X=\other
+ \catcode`\^^Z=\other
+ \catcode`\^^[=\other
+ \catcode`\^^\=\other
+ \catcode`\^^]=\other
+ \catcode`\^^^=\other
+ \catcode`\^^_=\other
+ \catcode`\@=\other
+ \catcode`\^=\other
+ % It was suggested to define this as 7, which would allow ^^e4 etc.
+ % in xref tags, i.e., node names. But since ^^e4 notation isn't
+ % supported in the main text, it doesn't seem desirable. Furthermore,
+ % that is not enough: for node names that actually contain a ^
+ % character, we would end up writing a line like this: 'xrdef {'hat
+ % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
+ % argument, and \hat is not an expandable control sequence. It could
+ % all be worked out, but why? Either we support ^^ or we don't.
+ %
+ % The other change necessary for this was to define \auxhat:
+ % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
+ % and then to call \auxhat in \setq.
+ %
+ \catcode`\~=\other
+ \catcode`\[=\other
+ \catcode`\]=\other
+ \catcode`\"=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\$=\other
+ \catcode`\#=\other
+ \catcode`\&=\other
+ \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
+ % Make the characters 128-255 be printing characters
+ {%
+ \count 1=128
+ \def\loop{%
+ \catcode\count 1=\other
+ \advance\count 1 by 1
+ \ifnum \count 1<256 \loop \fi
+ }%
+ }%
+ % The aux file uses ' as the escape (for now).
+ % Turn off \ as an escape so we do not lose on
+ % entries which were dumped with control sequences in their names.
+ % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
+ % Reference to such entries still does not work the way one would wish,
+ % but at least they do not bomb out when the aux file is read in.
+ \catcode`\{=1
+ \catcode`\}=2
+ \catcode`\%=\other
+ \catcode`\'=0
+ \catcode`\\=\other
+ %
+ \openin 1 \jobname.aux
+ \ifeof 1 \else
+ \closein 1
+ \input \jobname.aux
+ \global\havexrefstrue
+ \global\warnedobstrue
+ \fi
+ % Open the new aux file. TeX will close it automatically at exit.
+ \openout\auxfile=\jobname.aux
+\endgroup}
+
+
+% Footnotes.
+
+\newcount \footnoteno
+
+% The trailing space in the following definition for supereject is
+% vital for proper filling; pages come out unaligned when you do a
+% pagealignmacro call if that space before the closing brace is
+% removed. (Generally, numeric constants should always be followed by a
+% space to prevent strange expansion errors.)
+\def\supereject{\par\penalty -20000\footnoteno =0 }
+
+% @footnotestyle is meaningful for info output only.
+\let\footnotestyle=\comment
+
+\let\ptexfootnote=\footnote
+
+{\catcode `\@=11
+%
+% Auto-number footnotes. Otherwise like plain.
+\gdef\footnote{%
+ \global\advance\footnoteno by \@ne
+ \edef\thisfootno{$^{\the\footnoteno}$}%
+ %
+ % In case the footnote comes at the end of a sentence, preserve the
+ % extra spacing after we do the footnote number.
+ \let\@sf\empty
+ \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
+ %
+ % Remove inadvertent blank space before typesetting the footnote number.
+ \unskip
+ \thisfootno\@sf
+ \footnotezzz
+}%
+
+% Don't bother with the trickery in plain.tex to not require the
+% footnote text as a parameter. Our footnotes don't need to be so general.
+%
+% Oh yes, they do; otherwise, @ifset and anything else that uses
+% \parseargline fail inside footnotes because the tokens are fixed when
+% the footnote is read. --karl, 16nov96.
+%
+\long\gdef\footnotezzz{\insert\footins\bgroup
+ % We want to typeset this text as a normal paragraph, even if the
+ % footnote reference occurs in (for example) a display environment.
+ % So reset some parameters.
+ \interlinepenalty\interfootnotelinepenalty
+ \splittopskip\ht\strutbox % top baseline for broken footnotes
+ \splitmaxdepth\dp\strutbox
+ \floatingpenalty\@MM
+ \leftskip\z@skip
+ \rightskip\z@skip
+ \spaceskip\z@skip
+ \xspaceskip\z@skip
+ \parindent\defaultparindent
+ %
+ % Hang the footnote text off the number.
+ \hang
+ \textindent{\thisfootno}%
+ %
+ % Don't crash into the line above the footnote text. Since this
+ % expands into a box, it must come within the paragraph, lest it
+ % provide a place where TeX can split the footnote.
+ \footstrut
+ \futurelet\next\fo@t
+}
+\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
+ \else\let\next\f@t\fi \next}
+\def\f@@t{\bgroup\aftergroup\@foot\let\next}
+\def\f@t#1{#1\@foot}
+\def\@foot{\strut\egroup}
+
+}%end \catcode `\@=11
+
+% Set the baselineskip to #1, and the lineskip and strut size
+% correspondingly. There is no deep meaning behind these magic numbers
+% used as factors; they just match (closely enough) what Knuth defined.
+%
+\def\lineskipfactor{.08333}
+\def\strutheightpercent{.70833}
+\def\strutdepthpercent {.29167}
+%
+\def\setleading#1{%
+ \normalbaselineskip = #1\relax
+ \normallineskip = \lineskipfactor\normalbaselineskip
+ \normalbaselines
+ \setbox\strutbox =\hbox{%
+ \vrule width0pt height\strutheightpercent\baselineskip
+ depth \strutdepthpercent \baselineskip
+ }%
+}
+
+% @| inserts a changebar to the left of the current line. It should
+% surround any changed text. This approach does *not* work if the
+% change spans more than two lines of output. To handle that, we would
+% have adopt a much more difficult approach (putting marks into the main
+% vertical list for the beginning and end of each change).
+%
+\def\|{%
+ % \vadjust can only be used in horizontal mode.
+ \leavevmode
+ %
+ % Append this vertical mode material after the current line in the output.
+ \vadjust{%
+ % We want to insert a rule with the height and depth of the current
+ % leading; that is exactly what \strutbox is supposed to record.
+ \vskip-\baselineskip
+ %
+ % \vadjust-items are inserted at the left edge of the type. So
+ % the \llap here moves out into the left-hand margin.
+ \llap{%
+ %
+ % For a thicker or thinner bar, change the `1pt'.
+ \vrule height\baselineskip width1pt
+ %
+ % This is the space between the bar and the text.
+ \hskip 12pt
+ }%
+ }%
+}
+
+% For a final copy, take out the rectangles
+% that mark overfull boxes (in case you have decided
+% that the text looks ok even though it passes the margin).
+%
+\def\finalout{\overfullrule=0pt}
+
+% @image. We use the macros from epsf.tex to support this.
+% If epsf.tex is not installed and @image is used, we complain.
+%
+% Check for and read epsf.tex up front. If we read it only at @image
+% time, we might be inside a group, and then its definitions would get
+% undone and the next image would fail.
+\openin 1 = epsf.tex
+\ifeof 1 \else
+ \closein 1
+ % Do not bother showing banner with post-v2.7 epsf.tex (available in
+ % doc/epsf.tex until it shows up on ctan).
+ \def\epsfannounce{\toks0 = }%
+ \input epsf.tex
+\fi
+%
+\newif\ifwarnednoepsf
+\newhelp\noepsfhelp{epsf.tex must be installed for images to
+ work. It is also included in the Texinfo distribution, or you can get
+ it from ftp://ftp.tug.org/tex/epsf.tex.}
+%
+% Only complain once about lack of epsf.tex.
+\def\image#1{%
+ \ifx\epsfbox\undefined
+ \ifwarnednoepsf \else
+ \errhelp = \noepsfhelp
+ \errmessage{epsf.tex not found, images will be ignored}%
+ \global\warnednoepsftrue
+ \fi
+ \else
+ \imagexxx #1,,,\finish
+ \fi
+}
+%
+% Arguments to @image:
+% #1 is (mandatory) image filename; we tack on .eps extension.
+% #2 is (optional) width, #3 is (optional) height.
+% #4 is just the usual extra ignored arg for parsing this stuff.
+\def\imagexxx#1,#2,#3,#4\finish{%
+ % \epsfbox itself resets \epsf?size at each figure.
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
+ \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
+ % If the image is by itself, center it.
+ \ifvmode
+ \nobreak\medskip
+ \nobreak
+ \centerline{\epsfbox{#1.eps}}%
+ \bigbreak
+ \else
+ \epsfbox{#1.eps}%
+ \fi
+}
+
+
+\message{paper sizes,}
+% And other related parameters.
+
+\newdimen\defaultparindent \defaultparindent = 15pt
+
+\chapheadingskip = 15pt plus 4pt minus 2pt
+\secheadingskip = 12pt plus 3pt minus 2pt
+\subsecheadingskip = 9pt plus 2pt minus 2pt
+
+% Prevent underfull vbox error messages.
+\vbadness = 10000
+
+% Don't be so finicky about underfull hboxes, either.
+\hbadness = 2000
+
+% Following George Bush, just get rid of widows and orphans.
+\widowpenalty=10000
+\clubpenalty=10000
+
+% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
+% using an old version of TeX, don't do anything. We want the amount of
+% stretch added to depend on the line length, hence the dependence on
+% \hsize. This makes it come to about 9pt for the 8.5x11 format. We
+% call this whenever the paper size is set.
+%
+\def\setemergencystretch{%
+ \ifx\emergencystretch\thisisundefined
+ % Allow us to assign to \emergencystretch anyway.
+ \def\emergencystretch{\dimen0}%
+ \else
+ \emergencystretch = \hsize
+ \divide\emergencystretch by 45
+ \fi
+}
+
+% Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
+% 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can
+% set \parskip and call \setleading for \baselineskip.
+%
+\def\internalpagesizes#1#2#3#4#5#6{%
+ \voffset = #3\relax
+ \topskip = #6\relax
+ \splittopskip = \topskip
+ %
+ \vsize = #1\relax
+ \advance\vsize by \topskip
+ \outervsize = \vsize
+ \advance\outervsize by 2\topandbottommargin
+ \pageheight = \vsize
+ %
+ \hsize = #2\relax
+ \outerhsize = \hsize
+ \advance\outerhsize by 0.5in
+ \pagewidth = \hsize
+ %
+ \normaloffset = #4\relax
+ \bindingoffset = #5\relax
+ %
+ \parindent = \defaultparindent
+ \setemergencystretch
+}
+
+% @letterpaper (the default).
+\def\letterpaper{{\globaldefs = 1
+ \parskip = 3pt plus 2pt minus 1pt
+ \setleading{13.2pt}%
+ %
+ % If page is nothing but text, make it come out even.
+ \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
+}}
+
+% Use @smallbook to reset parameters for 7x9.5 (or so) format.
+\def\smallbook{{\globaldefs = 1
+ \parskip = 2pt plus 1pt
+ \setleading{12pt}%
+ %
+ \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
+ %
+ \lispnarrowing = 0.3in
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \deftypemargin = 0pt
+ \defbodyindent = .5cm
+ %
+ \let\smalldisplay = \smalldisplayx
+ \let\smallexample = \smalllispx
+ \let\smallformat = \smallformatx
+ \let\smalllisp = \smalllispx
+}}
+
+% Use @afourpaper to print on European A4 paper.
+\def\afourpaper{{\globaldefs = 1
+ \setleading{12pt}%
+ \parskip = 3pt plus 2pt minus 1pt
+ %
+ \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
+ %
+ \tolerance = 700
+ \hfuzz = 1pt
+}}
+
+% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin
+% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
+\def\afourlatex{{\globaldefs = 1
+ \setleading{13.6pt}%
+ %
+ \afourpaper
+ \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
+ %
+ \globaldefs = 0
+}}
+
+% Use @afourwide to print on European A4 paper in wide format.
+\def\afourwide{%
+ \afourpaper
+ \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
+ %
+ \globaldefs = 0
+}
+
+% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
+% Perhaps we should allow setting the margins, \topskip, \parskip,
+% and/or leading, also. Or perhaps we should compute them somehow.
+%
+\def\pagesizes{\parsearg\pagesizesxxx}
+\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
+\def\pagesizesyyy#1,#2,#3\finish{{%
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
+ \globaldefs = 1
+ %
+ \parskip = 3pt plus 2pt minus 1pt
+ \setleading{13.2pt}%
+ %
+ \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
+}}
+
+% Set default to letter.
+%
+\letterpaper
+
+\message{and turning on texinfo input format.}
+
+% Define macros to output various characters with catcode for normal text.
+\catcode`\"=\other
+\catcode`\~=\other
+\catcode`\^=\other
+\catcode`\_=\other
+\catcode`\|=\other
+\catcode`\<=\other
+\catcode`\>=\other
+\catcode`\+=\other
+\def\normaldoublequote{"}
+\def\normaltilde{~}
+\def\normalcaret{^}
+\def\normalunderscore{_}
+\def\normalverticalbar{|}
+\def\normalless{<}
+\def\normalgreater{>}
+\def\normalplus{+}
+
+% This macro is used to make a character print one way in ttfont
+% where it can probably just be output, and another way in other fonts,
+% where something hairier probably needs to be done.
+%
+% #1 is what to print if we are indeed using \tt; #2 is what to print
+% otherwise. Since all the Computer Modern typewriter fonts have zero
+% interword stretch (and shrink), and it is reasonable to expect all
+% typewriter fonts to have this, we can check that font parameter.
+%
+\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
+
+% Turn off all special characters except @
+% (and those which the user can use as if they were ordinary).
+% Most of these we simply print from the \tt font, but for some, we can
+% use math or other variants that look better in normal text.
+
+\catcode`\"=\active
+\def\activedoublequote{{\tt\char34}}
+\let"=\activedoublequote
+\catcode`\~=\active
+\def~{{\tt\char126}}
+\chardef\hat=`\^
+\catcode`\^=\active
+\def^{{\tt \hat}}
+
+\catcode`\_=\active
+\def_{\ifusingtt\normalunderscore\_}
+% Subroutine for the previous macro.
+\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
+
+\catcode`\|=\active
+\def|{{\tt\char124}}
+\chardef \less=`\<
+\catcode`\<=\active
+\def<{{\tt \less}}
+\chardef \gtr=`\>
+\catcode`\>=\active
+\def>{{\tt \gtr}}
+\catcode`\+=\active
+\def+{{\tt \char 43}}
+%\catcode 27=\active
+%\def^^[{$\diamondsuit$}
+
+% Set up an active definition for =, but don't enable it most of the time.
+{\catcode`\==\active
+\global\def={{\tt \char 61}}}
+
+\catcode`+=\active
+\catcode`\_=\active
+
+% If a .fmt file is being used, characters that might appear in a file
+% name cannot be active until we have parsed the command line.
+% So turn them off again, and have \everyjob (or @setfilename) turn them on.
+% \otherifyactive is called near the end of this file.
+\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
+
+\catcode`\@=0
+
+% \rawbackslashxx output one backslash character in current font
+\global\chardef\rawbackslashxx=`\\
+%{\catcode`\\=\other
+%@gdef@rawbackslashxx{\}}
+
+% \rawbackslash redefines \ as input to do \rawbackslashxx.
+{\catcode`\\=\active
+@gdef@rawbackslash{@let\=@rawbackslashxx }}
+
+% \normalbackslash outputs one backslash in fixed width font.
+\def\normalbackslash{{\tt\rawbackslashxx}}
+
+% Say @foo, not \foo, in error messages.
+\escapechar=`\@
+
+% \catcode 17=0 % Define control-q
+\catcode`\\=\active
+
+% Used sometimes to turn off (effectively) the active characters
+% even after parsing them.
+@def@turnoffactive{@let"=@normaldoublequote
+@let\=@realbackslash
+@let~=@normaltilde
+@let^=@normalcaret
+@let_=@normalunderscore
+@let|=@normalverticalbar
+@let<=@normalless
+@let>=@normalgreater
+@let+=@normalplus}
+
+@def@normalturnoffactive{@let"=@normaldoublequote
+@let\=@normalbackslash
+@let~=@normaltilde
+@let^=@normalcaret
+@let_=@normalunderscore
+@let|=@normalverticalbar
+@let<=@normalless
+@let>=@normalgreater
+@let+=@normalplus}
+
+% Make _ and + \other characters, temporarily.
+% This is canceled by @fixbackslash.
+@otherifyactive
+
+% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
+% That is what \eatinput is for; after that, the `\' should revert to printing
+% a backslash.
+%
+@gdef@eatinput input texinfo{@fixbackslash}
+@global@let\ = @eatinput
+
+% On the other hand, perhaps the file did not have a `\input texinfo'. Then
+% the first `\{ in the file would cause an error. This macro tries to fix
+% that, assuming it is called before the first `\' could plausibly occur.
+% Also back turn on active characters that might appear in the input
+% file name, in case not using a pre-dumped format.
+%
+@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi
+ @catcode`+=@active @catcode`@_=@active}
+
+% These look ok in all fonts, so just make them not special. The @rm below
+% makes sure that the current font starts out as the newly loaded cmr10
+@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
+
+@textfonts
+@rm
+
+@c Local variables:
+@c eval: (add-hook 'write-file-hooks 'time-stamp)
+@c page-delimiter: "^\\\\message"
+@c time-stamp-start: "def\\\\texinfoversion{"
+@c time-stamp-format: "%:y-%02m-%02d"
+@c time-stamp-end: "}"
+@c End:
diff --git a/avl-1.4.0/thread-test.c b/avl-1.4.0/thread-test.c
new file mode 100644
index 0000000..20eead4
--- /dev/null
+++ b/avl-1.4.0/thread-test.c
@@ -0,0 +1,142 @@
+/* libavl - manipulates AVL trees.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The author may be contacted at on the
+ Internet, or as Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA
+ through more mundane means. */
+
+/* This is file thread-test.c in libavl. */
+
+#if HAVE_CONFIG_H
+#include
+#endif
+#include
+#include
+#include
+#include
+#include "avl.h"
+#include "avlt.h"
+#include "avltr.h"
+
+#if __GNUC__ >= 2
+#define unused __attribute__ ((unused))
+#else
+#define unused
+#endif
+
+/* Compare two integers A and B and return a strcmp()-type result. */
+int
+compare_ints (const void *a, const void *b, void unused *param)
+{
+ return ((int) a) - ((int) b);
+}
+
+/* Arrange the N elements of ARRAY in random order. */
+void
+shuffle (int *array, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ int j = i + rand () % (n - i);
+ int t = array[j];
+ array[j] = array[i];
+ array[i] = t;
+ }
+}
+
+
+/* Simple stress test procedure for the AVL tree threading/unthreading
+ routines. */
+#define TREE_SIZE 1024
+#define N_ITERATIONS 16
+int
+main (int argc, char **argv)
+{
+ int array[TREE_SIZE];
+ int seed;
+ int iteration;
+
+ if (argc == 2)
+ seed = atoi (argv[1]);
+ else
+ seed = time (0) * 257 % 32768;
+
+ fputs ("Testing threading and unthreading...\n", stdout);
+ for (iteration = 1; iteration <= N_ITERATIONS; iteration++)
+ {
+ avl_tree *tree;
+ avl_traverser trav = AVL_TRAVERSER_INIT;
+ void **nodep = NULL;
+ void *node;
+ int i;
+
+ printf ("Iteration %4d/%4d: seed=%5d", iteration, N_ITERATIONS, seed);
+ fflush (stdout);
+
+ srand (seed++);
+
+ for (i = 0; i < TREE_SIZE; i++)
+ array[i] = i + 1;
+ shuffle (array, TREE_SIZE);
+
+ tree = avl_create (compare_ints, NULL);
+ for (i = 0; i < TREE_SIZE; i++)
+ avl_force_insert (tree, (void *) (array[i]));
+
+ shuffle (array, TREE_SIZE);
+ for (i = 0; i < TREE_SIZE; i++)
+ {
+ avlt_tree *t;
+ avltr_tree *tr;
+
+ avl_delete (tree, (void *) (array[i]));
+
+ while ((node = avl_traverse (tree, &trav)) != NULL);
+
+ t = avlt_thread (tree);
+ while ((nodep = avlt_next (t, nodep)) != NULL);
+ while ((nodep = avlt_prev (t, nodep)) != NULL);
+ avlt_unthread (t);
+
+ tr = avltr_thread (tree);
+ while ((nodep = avltr_next (tr, nodep)) != NULL);
+ avltr_unthread (tr);
+
+ while ((node = avl_traverse (tree, &trav)) != NULL);
+
+ if (i % 128 == 0)
+ {
+ putchar ('.');
+ fflush (stdout);
+ }
+ }
+ fputs (" good.\n", stdout);
+
+ avl_destroy (tree, NULL);
+ }
+
+ return 0;
+}
+
+/*
+ Local variables:
+ compile-command: "gcc -W -Wall -I. -o ./thread-test thread-test.c avl.c avlt.c avltr.c"
+ End:
+*/
diff --git a/bit b/bit
new file mode 100755
index 0000000..0c46d58
--- /dev/null
+++ b/bit
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#
+# $Id$
+#
+
+#
+# Build all add-on packages for the current RTEMS_MAKEFILE_PATH architecture.
+#
+set -ex
+
+PACKAGES="avl-1.4.0 ncurses-5.3 readline-4.3 libtecla-1.4.1 zlib-1.1.4"
+
+# make sure it is clean before we start
+for p in $PACKAGES
+do
+ (cd $p ; make clean distclean || true)
+done
+
+for p in $PACKAGES
+do
+ cd $p
+ makefile="../RTEMS_Makefiles/Makefile.$p"
+ if [ \! -r "$makefile" ]
+ then
+ makefile="`echo $makefile | sed -e '/-.*/s///'`"
+ fi
+ if [ -r "$makefile" ]
+ then
+ make -w -f "$makefile"
+ else
+ make -w
+ make -w install
+ fi
+ cd ..
+done
+
+for p in $PACKAGES
+do
+ (cd $p ; make clean distclean || true)
+done
diff --git a/bit_bfd b/bit_bfd
new file mode 100644
index 0000000..a6568f6
--- /dev/null
+++ b/bit_bfd
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+#
+# $Id$
+#
+
+#
+# Where to find the binutils source
+#
+BINUTILS_SRC_DIR=~/src/RTEMS/bt/binutils-2.13.1
+set -ex
+
+rm -rf build
+mkdir build
+cd build
+make -w BINUTILS_SRC_DIR="$BINUTILS_SRC_DIR" -f ../RTEMS_Makefiles/Makefile.bfd
+cd ..
+rm -rf build
diff --git a/examples/avl/BuildTests.sh b/examples/avl/BuildTests.sh
new file mode 100644
index 0000000..b0cc752
--- /dev/null
+++ b/examples/avl/BuildTests.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -x
+
+SRCDIR=../../avl-1.4.0
+
+for TEST in avl avlt avltr rb
+do
+ rm -f $TEST.c
+ ln -s $SRCDIR/$TEST.c .
+ make TEST=$TEST SRCDIR=$SRCDIR
+ rm -f $TEST.c
+done
diff --git a/examples/avl/Makefile b/examples/avl/Makefile
new file mode 100644
index 0000000..1283f0a
--- /dev/null
+++ b/examples/avl/Makefile
@@ -0,0 +1,70 @@
+#
+# $Id$
+#
+# Templates/Makefile.leaf
+# Template leaf node Makefile
+#
+
+# C source names, if any, go here -- minus the .c
+C_PIECES= init $(TEST)
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+# C++ source names, if any, go here -- minus the .cc
+CC_PIECES=
+CC_FILES=$(CC_PIECES:%=%.cc)
+CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+# Assembly source names, if any, go here -- minus the .s
+S_PIECES=
+S_FILES=$(S_PIECES:%=%.s)
+S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+PGMS=${ARCH}/$(TEST)
+
+#
+# RTEMS managers go here
+#
+MANAGERS=io event message semaphore
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS += -I$(SRCDIR) -DSELF_TEST=1 -Dmain=ncchk
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x200000 # network needs more space
+CFLAGS_DEBUG_V +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGMS)
+
+${ARCH}/$(TEST): ${OBJS} ${LINK_FILES}
+ $(make-exe)
+
+# Install the program(s), appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ $(INSTALL_VARIANT) -m 555 ${PGMS} /usr/local/tftpboot/bootfiles/m68360/
diff --git a/examples/avl/README b/examples/avl/README
new file mode 100644
index 0000000..72cab38
--- /dev/null
+++ b/examples/avl/README
@@ -0,0 +1,4 @@
+This directory contains a script and a makefile to build RTEMS
+executable images of the avl test programs. To build all
+the tests:
+ sh BuildTests.sh
diff --git a/examples/avl/init.c b/examples/avl/init.c
new file mode 100644
index 0000000..eb33c84
--- /dev/null
+++ b/examples/avl/init.c
@@ -0,0 +1,51 @@
+/*
+ * Root task
+ *
+ * $Revision$ $Date$ $Author$
+ */
+#include
+#include
+#include
+
+/*
+ ***********************************************************************
+ * RTEMS CONFIGURATION *
+ ***********************************************************************
+ */
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MAXIMUM_TASKS 20
+#define CONFIGURE_MAXIMUM_SEMAPHORES 10
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 52489
+
+#define CONFIGURE_INIT
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+#define CONFIGURE_INIT_TASK_STACK_SIZE (40*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 100
+rtems_task Init (rtems_task_argument argument);
+
+#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
+rtems_driver_address_table Device_drivers[] = {
+ CONSOLE_DRIVER_TABLE_ENTRY,
+ CLOCK_DRIVER_TABLE_ENTRY,
+};
+
+#include
+
+extern int main (int argc, char **argv);
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ putenv ("TERM=xterm");
+ main (0, NULL);
+ rtems_task_suspend (RTEMS_SELF);
+}
diff --git a/examples/ncurses/BuildTests.sh b/examples/ncurses/BuildTests.sh
new file mode 100644
index 0000000..f8c2f68
--- /dev/null
+++ b/examples/ncurses/BuildTests.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+set -x
+
+SRCDIR=../../ncurses-5.2/test
+
+for TEST in \
+ blue \
+ bs \
+ cardfile \
+ ditto \
+ filter \
+ firework \
+ firstlast \
+ gdc \
+ hanoi \
+ hashtest \
+ keynames \
+ knight \
+ lrtest \
+ ncurses \
+ newdemo \
+ rain \
+ tclock \
+ testaddch \
+ testcurs \
+ testscanw \
+ view \
+ worm \
+ xmas
+do
+ rm -f $TEST.c
+ ln -s $SRCDIR/$TEST.c .
+ make TEST=$TEST SRCDIR=$SRCDIR
+ rm -f $TEST.c
+done
diff --git a/examples/ncurses/Makefile b/examples/ncurses/Makefile
new file mode 100644
index 0000000..dfd0cb9
--- /dev/null
+++ b/examples/ncurses/Makefile
@@ -0,0 +1,70 @@
+#
+# $Id$
+#
+# Templates/Makefile.leaf
+# Template leaf node Makefile
+#
+
+# C source names, if any, go here -- minus the .c
+C_PIECES= init $(TEST)
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+# C++ source names, if any, go here -- minus the .cc
+CC_PIECES=
+CC_FILES=$(CC_PIECES:%=%.cc)
+CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+# Assembly source names, if any, go here -- minus the .s
+S_PIECES=
+S_FILES=$(S_PIECES:%=%.s)
+S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+PGMS=${ARCH}/$(TEST)
+
+#
+# RTEMS managers go here
+#
+MANAGERS=io event message semaphore
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS += -I$(SRCDIR) -Dmain=ncchk -DRETSIGTYPE=void
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS += -lm -lpanel -lform -lmenu -lncurses
+CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x200000 # network needs more space
+CFLAGS_DEBUG_V +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGMS)
+
+${ARCH}/$(TEST): ${OBJS} ${LINK_FILES}
+ $(make-exe)
+
+# Install the program(s), appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ $(INSTALL_VARIANT) -m 555 ${PGMS} /usr/local/tftpboot/bootfiles/m68360/
diff --git a/examples/ncurses/README b/examples/ncurses/README
new file mode 100644
index 0000000..beb3c32
--- /dev/null
+++ b/examples/ncurses/README
@@ -0,0 +1,4 @@
+This directory contains a script and a makefile to build RTEMS
+executable images of the ncurses test programs. To build all
+the tests:
+ sh BuildTests.sh
diff --git a/examples/ncurses/init.c b/examples/ncurses/init.c
new file mode 100644
index 0000000..8a81a1a
--- /dev/null
+++ b/examples/ncurses/init.c
@@ -0,0 +1,52 @@
+/*
+ * Root task
+ *
+ * $Revision$ $Date$ $Author$
+ */
+#include
+#include
+#include
+
+/*
+ ***********************************************************************
+ * RTEMS CONFIGURATION *
+ ***********************************************************************
+ */
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MAXIMUM_TASKS 20
+#define CONFIGURE_MAXIMUM_SEMAPHORES 10
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 52489
+
+#define CONFIGURE_INIT
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+#define CONFIGURE_INIT_TASK_STACK_SIZE (40*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 100
+rtems_task Init (rtems_task_argument argument);
+
+#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
+rtems_driver_address_table Device_drivers[] = {
+ CONSOLE_DRIVER_TABLE_ENTRY,
+ CLOCK_DRIVER_TABLE_ENTRY,
+};
+
+#include
+
+extern int main (int argc, char **argv);
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ putenv ("TERM=xterm");
+ putenv ("NCURSES_TRACE=20");
+ main (0, NULL);
+ rtems_task_suspend (RTEMS_SELF);
+}
diff --git a/examples/readline/.gdbinit b/examples/readline/.gdbinit
new file mode 100644
index 0000000..f198616
--- /dev/null
+++ b/examples/readline/.gdbinit
@@ -0,0 +1 @@
+directory ../../readline
diff --git a/examples/readline/Makefile b/examples/readline/Makefile
new file mode 100644
index 0000000..7794c86
--- /dev/null
+++ b/examples/readline/Makefile
@@ -0,0 +1,70 @@
+#
+# $Id$
+#
+# Templates/Makefile.leaf
+# Template leaf node Makefile
+#
+
+# C source names, if any, go here -- minus the .c
+C_PIECES= init rlgeneric
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+# C++ source names, if any, go here -- minus the .cc
+CC_PIECES=
+CC_FILES=$(CC_PIECES:%=%.cc)
+CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+# Assembly source names, if any, go here -- minus the .s
+S_PIECES=
+S_FILES=$(S_PIECES:%=%.s)
+S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
+
+SRCS=$(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+PGMS=${ARCH}/rlchk
+
+#
+# RTEMS managers go here
+#
+MANAGERS=io event message semaphore
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS += -Dmain=rlchk
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS += -lreadline -lncurses
+CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x200000 # network needs more space
+CFLAGS_DEBUG_V +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGMS)
+
+${ARCH}/rlchk: ${OBJS} ${LINK_FILES}
+ $(make-exe)
+
+# Install the program(s), appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ $(INSTALL_VARIANT) -m 555 ${PGMS} /usr/local/tftpboot/bootfiles/m68360/
diff --git a/examples/readline/init.c b/examples/readline/init.c
new file mode 100644
index 0000000..1336cfe
--- /dev/null
+++ b/examples/readline/init.c
@@ -0,0 +1,51 @@
+/*
+ * Root task
+ *
+ * $Revision$ $Date$ $Author$
+ */
+#include
+#include
+#include
+
+/*
+ ***********************************************************************
+ * RTEMS CONFIGURATION *
+ ***********************************************************************
+ */
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MAXIMUM_TASKS 20
+#define CONFIGURE_MAXIMUM_SEMAPHORES 10
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 52489
+
+#define CONFIGURE_INIT
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 100
+rtems_task Init (rtems_task_argument argument);
+
+#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
+rtems_driver_address_table Device_drivers[] = {
+ CONSOLE_DRIVER_TABLE_ENTRY,
+ CLOCK_DRIVER_TABLE_ENTRY,
+};
+
+#include
+
+extern int main (int argc, char **argv);
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ putenv ("TERM=xterm");
+ main (0, NULL);
+ rtems_task_suspend (RTEMS_SELF);
+}
diff --git a/examples/readline/rlgeneric.c b/examples/readline/rlgeneric.c
new file mode 100644
index 0000000..2bb5da4
--- /dev/null
+++ b/examples/readline/rlgeneric.c
@@ -0,0 +1,30 @@
+/*
+ * Host version of readline test program.
+ * Works as RTEMS version when included in rlchk.c
+ */
+#include
+#include
+#include
+#include
+#include
+
+int
+main (int argc, char **argv)
+{
+ char *line;
+
+ rl_bind_key ('\t', rl_insert);
+ stifle_history (10);
+ for (;;) {
+ line = readline ("Enter a line: ");
+ if (line && *line)
+ add_history (line);
+ printf ("Line: `%s'\n", line);
+ if (line && !strcmp (line, "dump")) {
+ rl_dump_variables (0,0);
+ rl_dump_functions (0,0);
+ }
+ free (line);
+ }
+ return 0;
+}
diff --git a/libtecla-1.4.1/CHANGES b/libtecla-1.4.1/CHANGES
new file mode 100644
index 0000000..45073e0
--- /dev/null
+++ b/libtecla-1.4.1/CHANGES
@@ -0,0 +1,1492 @@
+In the following log, modification dates are listed using the European
+convention in which the day comes before the month (ie. DD/MM/YYYY).
+The most recent modifications are listed first.
+
+25/05/2002 mcs@astro.caltech.edu (based on suggestions by Paul Smith)
+ pathutil.c
+ Apparently, under QNX pathconf("/",_PC_PATH_MAX) returns
+ EINVAL. At Paul's suggestion I have modified the code to
+ silently substitute the existing MAX_PATHLEN_FALLBACK
+ value if pathconf() returns an error of any kind.
+ homedir.c
+ Under QNX, sysconf(_SC_GETPW_R_SIZE_MAX) also apparently
+ returns EINVAL, so as with pathconf() I modified the code
+ to substitute a fallback default, rather than
+ complaining and failing.
+ enhance.c
+ Paul told me that the inclusion of sys/termios.h was
+ causing compilation of enhance.c to fail under QNX. This
+ line is a bug. The correct thing to do is include
+ termios.h without a sub-directory prefix, as I was
+ already doing futher up in the file, so I have just
+ removed the errant include line.
+
+12/02/2002 mcs@astro.caltech.edu
+ getline.c configure.in configure
+ Mac OS X doesn't have a term.h or termcap.h, but it does
+ define prototypes for tputs() and setupterm(), so the
+ default prototypes that I was including if no headers
+ where available, upset it. I've removed these prototypes.
+ I also now conditionally include whichever is found of
+ curses.h and ncurses/curses.h for both termcap and
+ terminfo (before I wasn't including curses.h when
+ termcap was selected).
+
+12/02/2002 mcs@astro.caltech.edu
+ Updated version number to 1.4.1, ready for a micro
+ release.
+
+12/02/2002 mcs@astro.caltech.edu
+ html/index.html
+ Added Mac OS X and Cygwin to the list of systems that
+ can compile libtecla.
+
+12/02/2002 mcs@astro.caltech.edu
+ getline.c
+ Under Mac OS X, the tputs() callback function returns
+ void, instead of the int return value used by other
+ systems. This declaration is now used if both __MACH__
+ and __APPLE__ are defined. Hopefully these are the
+ correct system macros to check. Thanks for Stephan
+ Fiedler for providing information on Mac OS X.
+
+11/02/2002 mcs@astro.caltech.edu
+ configure.in configure getline.c
+ Some systems don't have term.h, and others have it hidden
+ in an ncurses sub-directory of the standard system include
+ directory. If term.h can't be found, simply don't include
+ it. If it is in an ncurses sub-directory, include
+ ncurses/term.h instead of term.h.
+
+04/02/2002 mcs@astro.caltech.edu
+ configure.in configure Makefile.in Makefile.rules
+ Use ranlib on systems that need it (Mac OS X). Also,
+ make all components of the installation directories where
+ needed, instead of assuming that they exist.
+
+04/02/2002 mcs@astro.caltech.edu
+ getline.c
+ When the tab completion binding was unbound from the tab
+ key, hitting the tab key caused gl_get_line() to ring the
+ bell instead of inserting a tab character. This is
+ problematic when using the 'enhance' program with
+ Jython, since tabs are important in Python. I have
+ corrected this.
+
+10/12/2001 Version 1.4.0 released.
+
+10/12/2001 mcs@astro.caltech.edu
+ getline.c
+ If the TIOCGWINSZ ioctl doesn't work, as is the case when
+ running in an emacs shell, leave the size unchanged, rather
+ than returning a fatal error.
+
+07/12/2001 mcs@astro.caltech.edu
+ configure.in configure
+ Now that the configure version of CFLAGS is included in
+ the makefile, I noticed that the optimization flags -g
+ and -O2 had been added. It turns out that if CFLAGS isn't
+ already set, the autoconf AC_PROG_CC macro initializes it
+ with these two optimization flags. Since this would break
+ backwards compatibility in embedded distributions that
+ already use the OPT= makefile argument, and because
+ turning debugging on needlessly bloats the library, I now
+ make sure that CFLAGS is set before calling this macro.
+
+07/12/2001 mcs@astro.caltech.edu
+ enhance.c
+ Use argv[0] in error reports instead of using a
+ hardcoded macro.
+
+07/12/2001 mcs@astro.caltech.edu
+ getline.c
+ The cut buffer wasn't being cleared after being
+ used as a work buffer by gl_load_history().
+
+06/12/2001 mcs@astro.caltech.edu
+ configure.in configure
+ I removed my now redundant definition of SUN_TPUTS from
+ CFLAGS. I also added "-I/usr/include" to CFLAGS under
+ Solaris to prevent gcc from seeing conflicting versions
+ of system header files in /usr/local/include.
+
+06/12/2001 Markus Gyger (logged here by mcs)
+ Lots of files.
+ Lots of corrections to misspellings and typos in the
+ comments.
+ getline.c
+ Markus reverted a supposed fix that I added a day or two
+ ago. I had incorrectly thought that in Solaris 8, Sun had
+ finally brought their declaration of the callback
+ function of tputs() into line with other systems, but it
+ turned out that gcc was pulling in a GNU version of
+ term.h from /usr/local/include, and this was what
+ confused me.
+
+05/12/2001 mcs@astro.caltech.edu
+ Makefile.in
+ I added @CFLAGS@ to the CFLAGS assignment, so that
+ if CFLAGS is set as an environment variable when
+ configure is run, the corresponding make variable
+ includes its values in the output makefile.
+
+05/12/2001 mcs@astro.caltech.edu
+ getline.c libtecla.h libtecla.map man3/gl_get_line.3
+ man3/gl_last_signal.3
+ I added a function that programs can use to find out
+ which signal caused gl_get_line() to return EINTR.
+
+05/12/2001 mcs@astro.caltech.edu
+ getline.c
+ When the newline action was triggered by a printable
+ character, it failed to display that character. It now
+ does. Also, extra control codes that I had added, to
+ clear to the end of the display after the carriage return,
+ but before displaying the prompt, were confusing expect
+ scripts, so I have removed them. This step is now done
+ instead in gl_redisplay() after displaying the full input
+ line.
+
+05/12/2001 mcs@astro.caltech.edu
+ getline.c man3/gl_get_line.3
+ A user convinced me that continuing to invoke meta
+ keybindings for meta characters that are printable is a
+ bad idea, as is allowing users to ask to have setlocale()
+ called behind the application's back. I have thus changed
+ this. The setlocale configuration option has gone, and
+ gl_get_line() is now completely 8-bit clean, by default.
+ This means that if a meta character is printable, it is
+ treated as a literal character, rather than a potential
+ M-c binding. Meta bindings can still be invoked via
+ their Esc-c equivalents, and indeed most terminal
+ emulators either output such escape pairs by default when
+ the meta character is pressed, or can be configured to do
+ so. I have documented how to configure xterm to do this,
+ in the man page.
+
+03/12/2001 mcs@astro.caltech.edu
+ getline.c man3/gl_get_line.3
+ gl_get_line() by default now prints any 8-bit printable
+ characters that don't match keybindings. Previously
+ characters > 127 were only printed if preceded by the
+ literal-next action. Alternatively, by placing the
+ command literal_if_printable in the tecla configuration
+ file, all printable characters are treated as literal
+ characters, even if they are bound to action functions.
+
+ For international users of programs written by
+ programmers that weren't aware of the need to call
+ setlocale() to support alternate character sets, the
+ configuration file can now also contain the single-word
+ command "setlocale", which tells gl_get_line() to remedy
+ this.
+
+27/11/2001 mcs@astro.caltech.edu
+ demo.c demo2.c enhance man3/gl_get_line.3
+ All demos and programs now call setlocale(LC_CTYPE,"").
+ This makes them support character sets of different
+ locales, where specified with the LC_CTYPE, LC_ALL, or
+ LANG environment variables. I also added this to the demo
+ in the man page, and documented its effect.
+
+27/11/2001 mcs@astro.caltech.edu
+ getline.c
+ When displaying unsigned characters with values over
+ 127 literally, previously it was assumed that they would
+ all be displayable. Now isprint() is consulted, and if it
+ says that a character isn't printable, the character code
+ is displayed in octal like \307. In non-C locales, some
+ characters with values > 127 are displayable, and
+ isprint() tells gl_get_line() which are and which aren't.
+
+27/11/2001 mcs@astro.caltech.edu
+ getline.c pathutil.c history.c enhance.c demo2.c
+ All arguments of the ctype.h character class functions
+ are now cast to (int)(unsigned char). Previously they
+ were cast to (int), which doesn't correctly conform to
+ the requirements of the C standard, and could cause
+ problems for characters with values > 127 on systems
+ with signed char's.
+
+26/11/2001 mcs@astro.caltech.edu
+ man3/enhance.3 man3/libtecla.3
+ I started writing a man page for the enhance program.
+
+26/11/2001 mcs@astro.caltech.edu
+ Makefile.in Makefile.rules INSTALL
+ It is now possible to specify whether the demos and other
+ programs are to be built, by overriding the default
+ values of the DEMOS, PROGRAMS and PROGRAMS_R variables.
+ I have also documented the BINDIR variable and the
+ install_bin makefile target.
+
+22/11/2001 mcs@astro.caltech.edu
+ getline.c libtecla.h libtecla.map man3/gl_get_line.3
+ man3/gl_ignore_signal.3 man3/gl_trap_signal.3
+ Signal handling has now been modified to be customizable.
+ Signals that are trapped by default can be removed from
+ the list of trapped signals, and signals that aren't
+ currently trapped, can be added to the list. Applications
+ can also specify the signal and terminal environments in
+ which an application's signal handler is invoked, and
+ what gl_get_line() does after the signal handler returns.
+
+13/11/2001 mcs@astro.caltech.edu
+ getline.c man3/gl_get_line.3
+ Added half-bright, reverse-video and blinking text to the
+ available prompt formatting options.
+ getline.c
+ Removed ^O from the default VT100 sgr0 capability
+ string. Apparently it can cause problems with some
+ terminal emulators, and we don't need it, since it turns
+ off the alternative character set mode, which we don't
+ use.
+ getline.c
+ gl_tigetstr() and gl_tgetstr() didn't guard against the
+ error returns of tigetstr() and tgetstr() respectively.
+ They now do.
+
+11/11/2001 mcs@astro.caltech.edu
+ getline.c libtecla.h libtecla.map man3/gl_get_line.3
+ man3/gl_prompt_style.3
+ Although the default remains to display the prompt string
+ literally, the new gl_prompt_style() function can be used
+ to enable text attribute formatting directives in prompt
+ strings, such as underlining, bold font, and highlighting
+ directives.
+
+09/11/2001 mcs@astro.caltech.edu
+ enhance.c Makefile.rules configure.in configure
+ I added a new program to the distribution that allows one
+ to run most third party programs with the tecla library
+ providing command-line editing.
+
+08/11/2001 mcs@astro.caltech.edu
+ libtecla.h getline.c man3/gl_get_line.3 history.c history.h
+ I added a max_lines argument to gl_show_history() and
+ _glh_show_history(). This can optionally be used to
+ set a limit on the number of history lines displayed.
+ libtecla.h getline.c man3/gl_get_line.3
+ I added a new function called gl_replace_prompt(). This
+ can be used by gl_get_line() callback functions to
+ request that a new prompt be use when they return.
+
+06/11/2001 mcs@astro.caltech.edu
+ getline.c man3/gl_get_line.3
+ I implemented, bound and documented the list-history
+ action, used for listing historical lines of the current
+ history group.
+ getline.c man3/gl_get_line.3 man3/gl_echo_mode.3
+ I wrote functions to specify and query whether subsequent
+ lines will be visible as they are being typed.
+
+28/10/2001 mcs@astro.caltech.edu
+ getline.c man3/gl_get_line.3
+ For those cases where a terminal provides its own
+ high-level terminal editing facilities, you can now
+ specify an edit-mode argument of 'none'. This disables
+ all tecla key bindings, and by using canonical terminal
+ input mode instead of raw input mode, editing is left up
+ to the terminal driver.
+
+21/10/2001 mcs@astro.caltech.edu
+ libtecla.h getline.c history.c history.h
+ man3/gl_get_line.3 man3/gl_history_info.3
+ I added the new gl_state_of_history(),
+ gl_range_of_history() and gl_size_of_history()
+ functions for querying information about the
+ history list.
+ history.c
+ While testing the new gl_size_of_history()
+ function, I noticed that when the history buffer
+ wrapped, any location nodes of old lines between
+ the most recent line and the end of the buffer
+ weren't being removed. This could result in bogus
+ entries appearing at the start of the history list.
+ Now fixed.
+
+20/10/2001 mcs@astro.caltech.edu
+
+ libtecla.h getline.c history.c history.h
+ man3/gl_get_line.3 man3/gl_lookup_history.3
+ I added a function called gl_lookup_history(), that
+ the application can use to lookup lines in the history
+ list.
+ libtecla.h getline.c history.c history.h man3/gl_get_line.3
+ gl_show_history() now takes a format string argument
+ to control how the line is displayed, and with what
+ information. It also now provides the option of either
+ displaying all history lines or just those of the
+ current history group.
+ getline.c man3/gl_get_line.3
+ gl_get_line() only archives lines in the history buffer
+ if the newline action was invoked by a newline or
+ carriage return character.
+
+16/10/2001 mcs@astro.caltech.edu
+
+ history.c history.h getline.c libtecla.h libtecla.map
+ man3/gl_get_line.3 man3/gl_resize_history.3
+ man3/gl_limit_history.3 man3/gl_clear_history.3
+ man3/gl_toggle_history.3
+ I added a number of miscellaneous history configuration
+ functions. You can now resize or delete the history
+ buffer, limit the number of lines that are allowed in the
+ buffer, clear either all history or just the history of
+ the current history group, and temporarily enable and
+ disable the history mechanism.
+
+13/10/2001 mcs@astro.caltech.edu
+
+ getline.c
+ tputs_fp is now only declared if using termcap or
+ terminfo.
+ getline.c libtecla.map man3/gl_get_line.3
+ man3/gl_terminal_size.3
+ I added a public gl_terminal_size() function for
+ updating and querying the current size of the terminal.
+ update_version configure.in libtecla.h
+ A user noted that on systems where the configure script
+ couldn't be used, it was inconvenient to have the version
+ number macros set by the configure script, so they are
+ now specified in libtecla.h. To reduce the likelihood
+ that the various files where the version number now
+ appears might get out of sync, I have written the
+ update_version script, which changes the version number
+ in all of these files to a given value.
+
+01/10/2001 mcs@astro.caltech.edu
+
+ getline.c history.c history.h man3/gl_get_line.3
+ I added a max_lines argument to gl_save_history(), to
+ allow people to optionally place a ceiling on the number
+ of history lines saved. Specifying this as -1 sets the
+ ceiling to infinity.
+
+01/10/2001 mcs@astro.caltech.edu
+
+ configure.in configure
+ Under digital unix, getline wouldn't compile with
+ _POSIX_C_SOURCE set, due to type definitions needed by
+ select being excluded by this flag. Defining the
+ _OSF_SOURCE macro as well on this system, resolved this.
+
+30/09/2001 mcs@astro.caltech.edu
+
+ getline.c libtecla.h history.c history.h man3/gl_get_line.3
+ man3/gl_group_history.3
+ I implemented history streams. History streams
+ effectively allow multiple history lists to be stored in
+ a single history buffer. Lines in the buffer are tagged
+ with the current stream identification number, and
+ lookups only consider lines that are marked with the
+ current stream identifier.
+ getline.c libtecla.h history.c history.h man3/gl_get_line.3
+ man3/gl_show_history.3
+ The new gl_show_history function displays the current
+ history to a given stdio output stream.
+
+29/09/2001 mcs@astro.caltech.edu
+
+ getline.c
+ Previously new_GetLine() installed a persistent signal
+ handler to be sure to catch the SIGWINCH (terminal size
+ change) signal between calls to gl_get_line(). This had
+ the drawback that if multiple GetLine objects were
+ created, only the first GetLine object used after the
+ signal was received, would see the signal and adapt to
+ the new terminal size. Instead of this, a signal handler
+ for sigwinch is only installed while gl_get_line() is
+ running, and just after installing this handler,
+ gl_get_line() checks for terminal size changes that
+ might have occurred while the signal handler wasn't
+ installed.
+ getline.c
+ Dynamically allocated copies of capability strings looked
+ up in the terminfo or termcap databases are now made, so
+ that calls to setupterm() etc for one GetLine object
+ don't get trashed when another GetLine object calls
+ setupterm() etc. It is now safe to allocate and use
+ multiple GetLine objects, albeit only within a single
+ thread.
+
+28/09/2001 mcs@astro.caltech.edu
+
+ version.c Makefile.rules
+ I added a function for querying the version number of
+ the library.
+
+26/09/2001 mcs@astro.caltech.edu
+
+ getline.c man3/gl_get_line.3
+ I added the new gl_watch_fd() function, which allows
+ applications to register callback functions to be invoked
+ when activity is seen on arbitrary file descriptors while
+ gl_get_line() is awaiting keyboard input from the user.
+
+ keytab.c
+ If a request is received to delete a non-existent
+ binding, which happens to be an ambiguous prefix of other
+ bindings no complaint is now generated about it being
+ ambiguous.
+
+23/09/2001 mcs@astro.caltech.edu
+
+ getline.c history.c history.h man3/gl_get_line.3
+ libtecla.map demo.c
+ I added new public functions for saving and restoring the
+ contents of the history list. The demo program now uses
+ these functions to load and save history in ~/.demo_history.
+
+23/09/2001 mcs@astro.caltech.edu
+
+ getline.c
+ On trying the demo for the first time on a KDE konsole
+ terminal, I discovered that the default M-O binding
+ to repeat history was hiding the arrow keys, which are
+ M-OA etc. I have removed this binding. The M-o (ie the
+ lower case version of this), is still bound.
+
+18/09/2001 mcs@astro.caltech.edu
+
+ getline.c man3/gl_get_line.3 libtecla.map
+ Automatic reading of ~/.teclarc is now postponed until
+ the first call to gl_get_line(), to give the application
+ the chance to specify alternative configuration sources
+ with the new function gl_configure_getline(). The latter
+ function allows configuration to be done with a string, a
+ specified application-specific file, and/or a specified
+ user-specific file. I also added a read-init-files action
+ function, for re-reading the configuration files, if any.
+ This is by default bound to ^X^R. This is all documented
+ in gl_get_line.3.
+
+08/09/2001 mcs@astro.caltech.edu
+
+ getline.c man3/gl_get_line.3
+ It is now possible to bind actions to key-sequences
+ that start with printable characters. Previously
+ keysequences were required to start with meta or control
+ characters. This is documented in gl_get_line.3.
+
+ getline.c man3/gl_get_line.3
+ A customized completion function can now arrange for
+ gl_get_line() to return the current input line whenever a
+ successful completion has been made. This is signalled by
+ setting the last character of the optional continuation
+ suffix to a newline character. This is documented in
+ gl_get_line.3.
+
+05/07/2001 Bug reported by Mike MacFaden, fixed by mcs
+
+ configure.in
+ There was a bug in the configure script that only
+ revealed itself on systems without termcap but not
+ terminfo (eg. NetBSD). I traced the bug back to a lack of
+ sufficient quoting of multi-line m4 macro arguments in
+ configure.in, and have now fixed this and recreated the
+ configure script.
+
+05/07/2001 Bug reported and patched by Mike MacFaden (patch modified
+ by mcs to match original intentions).
+
+ getline.c
+ getline.c wouldn't compile when termcap was selected as
+ the terminal information database. setupterm() was being
+ passed a non-existent variable, in place of the term[]
+ argument of gl_control_strings(). Also if
+ gl_change_terminal() is called with term==NULL, "ansi"
+ is now substituted.
+
+02/07/2001 Version 1.3.3 released.
+
+27/06/2001 mcs@astro.caltech.edu
+
+ getline.c expand.c cplmatch.c
+ Added checks to fprintf() statements that write to the
+ terminal.
+ getline.c
+ Move the cursor to the end of the line before suspending,
+ so that the cursor doesn't get left in the middle of the
+ input line.
+ Makefile.in
+ On systems that don't support shared libraries, the
+ distclean target of make deleted libtecla.h. This has
+ now been fixed.
+ getline.c
+ gl_change_terminal() was being called by gl_change_editor(),
+ with the unwanted side effect that raw terminal modes were
+ stored as those to be restored later, if called by an
+ action function. gl_change_terminal() was being called in
+ this case to re-establish terminal-specific key bindings,
+ so I have just split this part of the function out into
+ a separate function for both gl_change_editor() and
+ gl_change_terminal() to call.
+
+12/06/2001 mcs@astro.caltech.edu
+
+ getline.c
+ Signal handling has been improved. Many more signals are
+ now trapped, and instead of using a simple flag set by a
+ signal handler, race conditions are avoided by blocking
+ signals during most of the gl_get_line() code, and
+ unblocking them via calls to sigsetjmp(), just before
+ attempting to read each new character from the user.
+ The matching use of siglongjmp() in the signal
+ handlers ensures that signals are reblocked correctly
+ before they are handled. In most cases, signals cause
+ gl_get_line() to restore the terminal modes and signal
+ handlers of the calling application, then resend the
+ signal to the application. In the case of SIGINT, SIGHUP,
+ SIGPIPE, and SIGQUIT, if the process still exists after
+ the signals are resent, gl_get_line() immediately returns
+ with appropriate values assigned to errno. If SIGTSTP,
+ SIGTTIN or SIGTTOU signals are received, the process is
+ suspended. If any other signal is received, and the
+ process continues to exist after the signal is resent to
+ the calling application, line input is resumed after the
+ terminal is put back into raw mode, the gl_get_line()
+ signal handling is restored, and the input line redrawn.
+ man/gl_get_line(3)
+ I added a SIGNAL HANDLING section to the gl_get_line()
+ man page, describing the new signal handling features.
+
+21/05/2001 Version 1.3.2 released.
+
+21/05/2001 mcs@astro.caltech.edu
+
+ getline.c
+ When vi-replace-char was used to replace the character at
+ the end of the line, it left the cursor one character to
+ its right instead of on top of it. Now rememdied.
+ getline.c
+ When undoing, to properly emulate vi, the cursor is now
+ left at the leftmost of the saved and current cursor
+ positions.
+ getline.c man3/gl_get_line.3
+ Implemented find-parenthesis (%), delete-to-paren (M-d%),
+ vi-change-to-paren (M-c%), copy-to-paren (M-y%).
+ cplfile.c pcache.c
+ In three places I was comparing the last argument of
+ strncmp() to zero instead of the return value of
+ strncmp().
+
+20/05/2001 mcs@astro.caltech.edu
+
+ getline.c man3/gl_get_line.3
+ Implemented and documented the vi-repeat-change action,
+ bound to the period key. This repeats the last action
+ that modified the input line.
+
+19/05/2001 mcs@astro.caltech.edu
+
+ man3/gl_get_line.3
+ I documented the new action functions and bindings
+ provided by Tim Eliseo, plus the ring-bell action and
+ the new "nobeep" configuration option.
+ getline.c
+ I modified gl_change_editor() to remove and reinstate the
+ terminal settings as well as the default bindings, since
+ these have editor-specific differences. I also modified
+ it to not abort if a key-sequence can't be bound for some
+ reason. This allows the new vi-mode and emacs-mode
+ bindings to be used safely.
+ getline.c
+ When the line was re-displayed on receipt of a SIGWINCH
+ signal, the result wasn't visible until the next
+ character was typed, since a call to fflush() was needed.
+ gl_redisplay_line() now calls gl_flush_output() to remedy
+ this.
+
+17/05/2001 mcs@astro.catlech.edu
+
+ getline.c
+ Under Linux, calling fflush(gl->output_fd) hangs if
+ terminal output has been suspended with ^S. With the
+ tecla library taking responsability for reading the stop
+ and start characters this was a problem, because once
+ hung in fflush(), the keyboard input loop wasn't entered,
+ so the user couldn't type the start character to resume
+ output. To remedy this, I now have the terminal process
+ these characters, rather than the library.
+
+12/05/2001 mcs@astro.caltech.edu
+
+ getline.c
+ The literal-next action is now implemented as a single
+ function which reads the next character itself.
+ Previously it just set a flag which effected the
+ interpretation of the next character read by the input
+ loop.
+ getline.c
+ Added a ring-bell action function. This is currently
+ unbound to any key by default, but it is used internally,
+ and can be used by users that want to disable any of the
+ default key-bindings.
+
+12/05/2001 Tim Eliseo (logged here by mcs)
+
+ getline.c
+ Don't reset gl->number until after calling an action
+ function. By looking at whether gl->number is <0 or
+ not, action functions can then tell whether the count
+ that they were passed was explicitly specified by the
+ user, as opposed to being defaulted to 1.
+ getline.c
+ In vi, the position at which input mode is entered
+ acts as a barrier to backward motion for the few
+ backward moving actions that are enabled in input mode.
+ Tim added this barrier to getline.
+ getline.c
+ In gl_get_line() after reading an input line, or
+ having the read aborted by a signal, the sig_atomic_t
+ gl_pending_signal was being compared to zero instead
+ of -1 to see if no signals had been received.
+ gl_get_line() will thus have been calling raise(-1),
+ which luckily didn't seem to do anything. Tim also
+ arranged for errno to be set to EINTR when a signal
+ aborts gl_get_line().
+ getline.c
+ The test in gl_add_char_to_line() for detecting
+ when overwriting a character with a wider character,
+ had a < where it needed a >. Overwriting with a wider
+ character thus overwrote trailing characters. Tim also
+ removed a redundant copy of the character into the
+ line buffer.
+ getline.c
+ gl_cursor_left() and gl->cursor_right() were executing
+ a lot of redundant code, when the existing call to the
+ recently added gl_place_cursor() function, does all that
+ is necessary.
+ getline.c
+ Remove redundant code from backward_kill_line() by
+ re-implimenting in terms of gl_place_cursor() and
+ gl_delete_chars().
+ getline.c
+ gl_forward_delete_char() now records characters in cut
+ buffer when in vi command mode.
+ getline.c
+ In vi mode gl_backward_delete_char() now only deletes
+ up to the point at which input mode was entered. Also
+ gl_delete_chars() restores from the undo buffer when
+ deleting in vi insert mode.
+ getline.c
+ Added action functions, vi-delete-goto-column,
+ vi-change-to-bol, vi-change-line, emacs-mode, vi-mode,
+ vi-forward-change-find, vi-backward-change-find,
+ vi-forward-change-to, vi-backward-change-to,
+ vi-change-goto-col, forward-delete-find, backward-delete-find,
+ forward-delete-to, backward-delete-to,
+ delete-refind, delete-invert-refind, forward-copy-find,
+ backward-copy-find, forward-copy-to, backward-copy-to
+ copy-goto-column, copy-rest-of-line, copy-to-bol, copy-line,
+ history-re-search-forward, history-re-search-backward.
+
+06/05/2001 Version 1.3.1 released.
+
+03/05/2001 mcs@astro.caltech.edu
+
+ configure.in
+ Old versions of GNU ld don't accept version scripts.
+ Under Linux I thus added a test to try out ld with
+ the --version-script argument to see if it works.
+ If not, version scripts aren't used.
+ configure.in
+ My test for versions of Solaris earlier than 7
+ failed when confronted by a three figure version
+ number (2.5.1). Fixed.
+
+30/04/2001 mcs@astro.caltech.edu
+
+ getline.c
+ In vi mode, history-search-backward and
+ history-search-forward weren't doing anything when
+ invoked at the start of an empty line, whereas
+ they should have acted like up-history and down-history.
+ Makefile.in Makefile.rules
+ When shared libraries are being created, the build
+ procedure now arranges for any alternate library
+ links to be created as well, before linking the
+ demos. Without this the demos always linked to the
+ static libraries (which was perfectly ok, but wasn't a
+ good example).
+ Makefile.in Makefile.rules
+ On systems on which shared libraries were being created,
+ if there were no alternate list of names, make would
+ abort due to a Bourne shell 'for' statement that didn't
+ have any arguments. Currently there are no systems who's
+ shared library configurations would trigger this
+ problem.
+ Makefile.rules
+ The demos now relink to take account of changes to the
+ library.
+ configure.in configure
+ When determining whether the reentrant version of the
+ library should be compiled by default, the configure
+ script now attempts to compile a dummy program that
+ includes all of the appropriate system headers and
+ defines _POSIX_C_SOURCE. This should now be a robust test
+ on systems which use C macros to alias these function
+ names to other internal functions.
+ configure.in
+ Under Solaris 2.6 and earlier, the curses library is in
+ /usr/ccs/lib. Gcc wasn't finding this. In addition to
+ remedying this, I had to remove "-z text" from
+ LINK_SHARED under Solaris to get it to successfully
+ compile the shared library against the static curses
+ library.
+ configure.in
+ Under Linux the -soname directive was being used
+ incorrectly, citing the fully qualified name of the
+ library instead of its major version alias. This will
+ unfortunately mean that binaries linked with the 1.2.3
+ and 1.2.4 versions of the shared library won't use
+ later versions of the library unless relinked.
+
+30/04/2001 mcs@astro.caltech.edu
+
+ getline.c
+ In gl_get_input_line(), don't redundantly copy the
+ start_line if start_line == gl->line.
+
+30/04/2001 Version 1.3.0 released.
+
+28/04/2001 mcs@astro.caltech.edu
+
+ configure.in
+ I removed the --no-undefined directive from the Linux
+ LINK_SHARED command. After recent patches to our RedHat
+ 7.0 systems ld started reporting some internal symbols of
+ libc as being undefined. Using nm on libc indicated that
+ the offending symbols are indeed defined, albeit as
+ "common" symbols, so there appears to be a bug in
+ RedHat's ld. Removing this flag allows the tecla shared
+ library to compile, and programs appear to function fine.
+ man3/gl_get_line.3
+ The default key-sequence used to invoke the
+ read-from-file action was incorrectly cited as ^Xi
+ instead of ^X^F.
+
+26/04/2001 mcs@astro.caltech.edu
+
+ getline.c man3/gl_get_line.3
+ A new vi-style editing mode was added. This involved
+ adding many new action functions, adding support for
+ specifying editing modes in users' ~/.teclarc files,
+ writing a higher level cursor motion function to support
+ the different line-end bounds required in vi command
+ mode, and a few small changes to support the fact that vi
+ has two modes, input mode and command mode with different
+ bindings.
+
+ When vi editing mode is enabled, any binding that starts
+ with an escape or a meta character, is interpreted as a
+ command-mode binding, and switches the library to vi
+ command mode if not already in that mode. Once in command
+ mode the first character of all keysequences entered
+ until input mode is re-enabled, are quietly coerced to
+ meta characters before being looked up in the key-binding
+ table. So, for example, in the key-binding table, the
+ standard vi command-mode 'w' key, which moves the cursor
+ one word to the right, is represented by M-w. This
+ emulates vi's dual sets of bindings in a natural way
+ without needing large changes to the library, or new
+ binding syntaxes. Since cursor keys normally emit
+ keysequences which start with escape, it also does
+ something sensible when a cursor key is pressed during
+ input mode (unlike true vi, which gets upset).
+
+ I also added a ^Xg binding for the new list-glob action
+ to both the emacs and vi key-binding tables. This lists
+ the files that match the wild-card expression that
+ precedes it on the command line.
+
+ The function that reads in ~/.teclarc used to tell
+ new_GetLine() to abort if it encountered anything that it
+ didn't understand in this file. It now just reports an
+ error and continues onto the next line.
+ Makefile.in:
+ When passing LIBS=$(LIBS) to recursive invokations of
+ make, quotes weren't included around the $(LIBS) part.
+ This would cause problems if LIBS ever contained more
+ than one word (with the supplied configure script this
+ doesn't happen currently). I added these quotes.
+ expand.c man3/ef_expand_file.3:
+ I wrote a new public function called ef_list_expansions(),
+ to list the matching filenames returned by
+ ef_expand_file().
+
+ I also fixed the example in the man page, which cited
+ exp->file instead of exp->files, and changed the
+ dangerous name 'exp' with 'expn'.
+ keytab.c:
+ Key-binding tables start with 100 elements, and are
+ supposedly incremented in size by 100 elements whenever
+ the a table runs out of space. The realloc arguments to
+ do this were wrong. This would have caused problems if
+ anybody added a lot of personal bindings in their
+ ~/.teclarc file. I only noticed it because the number of
+ key bindings needed by the new vi mode exceeded this
+ number.
+ libtecla.map
+ ef_expand_file() is now reported as having been added in
+ the upcoming 1.3.0 release.
+
+25/03/2001 Markus Gyger (logged here by mcs)
+
+ Makefile.in:
+ Make symbolic links to alternative shared library names
+ relative instead of absolute.
+ Makefile.rules:
+ The HP-UX libtecla.map.opt file should be made in the
+ compilation directory, to allow the source code directory
+ to be on a readonly filesystem.
+ cplmatch.c demo2.c history.c pcache.c
+ To allow the library to be compiled with a C++ compiler,
+ without generating warnings, a few casts were added where
+ void* return values were being assigned directly to
+ none void* pointer variables.
+
+25/03/2001 mcs@astro.caltech.edu
+
+ libtecla.map:
+ Added comment header to explain the purpose of the file.
+ Also added cpl_init_FileArgs to the list of exported
+ symbols. This symbol is deprecated, and no longer
+ documented, but for backwards compatibility, it should
+ still be exported.
+ configure:
+ I had forgotten to run autoconf before releasing version
+ 1.2.4, so I have just belatedly done so. This enables
+ Markus' changes to "configure.in" documented previously,
+ (see 17/03/2001).
+
+20/03/2001 John Levon (logged here by mcs)
+
+ libtecla.h
+ A couple of the function prototypes in libtecla.h have
+ (FILE *) argument declarations, which means that stdio.h
+ needs to be included. The header file should be self
+ contained, so libtecla.h now includes stdio.h.
+
+18/03/2001 Version 1.2.4 released.
+
+ README html/index.html configure.in
+ Incremented minor version from 3 to 4.
+
+18/03/2001 mcs@astro.caltech.edu
+
+ getline.c
+ The fix for the end-of-line problem that I released a
+ couple of weeks ago, only worked for the first line,
+ because I was handling this case when the cursor position
+ was equal to the last column, rather than when the cursor
+ position modulo ncolumn was zero.
+ Makefile.in Makefile.rules
+ The demos are now made by default, their rules now being
+ int Makefile.rules instead of Makefile.in.
+ INSTALL
+ I documented how to compile the library in a different
+ directory than the distribution directory.
+ I also documented features designed to facilitate
+ configuring and building the library as part of another
+ package.
+
+17/03/2001 Markus Gyger (logged here by mcs)
+
+ getline.c
+ Until now cursor motions were done one at a time. Markus
+ has added code to make use the of the terminfo capability
+ that moves the cursor by more than one position at a
+ time. This greatly improves performance when editing near
+ the start of long lines.
+ getline.c
+ To further improve performance, Markus switched from
+ writing one character at a time to the terminal, using
+ the write() system call, to using C buffered output
+ streams. The output buffer is only flushed when
+ necessary.
+ Makefile.rules Makefile.in configure.in
+ Added support for compiling for different architectures
+ in different directories. Simply create another directory
+ and run the configure script located in the original
+ directory.
+ Makefile.in configure.in libtecla.map
+ Under Solaris, Linux and HP-UX, symbols that are to be
+ exported by tecla shared libraries are explicitly specified
+ via symbol map files. Only publicly documented functions
+ are thus visible to applications.
+ configure.in
+ When linking shared libraries under Solaris SPARC,
+ registers that are reserved for applications are marked
+ as off limits to the library, using -xregs=no%appl when
+ compiling with Sun cc, or -mno-app-regs when compiling
+ with gcc. Also removed -z redlocsym for Solaris, which
+ caused problems under some releases of ld.
+ homedir.c (after minor changes by mcs)
+ Under ksh, ~+ expands to the current value of the ksh
+ PWD environment variable, which contains the path of
+ the current working directory, including any symbolic
+ links that were traversed to get there. The special
+ username "+" is now treated equally by tecla, except
+ that it substitutes the return value of getcwd() if PWD
+ either isn't set, or if it points at a different
+ directory than that reported by getcwd().
+
+08/03/2001 Version 1.2.3 released.
+
+08/03/2001 mcs@astro.caltech.edu
+
+ getline.c
+ On compiling the library under HP-UX for the first time
+ I encountered and fixed a couple of bugs:
+
+ 1. On all systems except Solaris, the callback function
+ required by tputs() takes an int argument for the
+ character that is to be printed. Under Solaris it
+ takes a char argument. The callback function was
+ passing this argument, regardless of type, to write(),
+ which wrote the first byte of the argument. This was
+ fine under Solaris and under little-endian systems,
+ because the first byte contained the character to be
+ written, but on big-endian systems, it always wrote
+ the zero byte at the other end of the word. As a
+ result, no control characters were being written to
+ the terminal.
+ 2. While attempting to start a newline after the user hit
+ enter, the library was outputting the control sequence
+ for moving the cursor down, instead of the newline
+ character. On many systems the control sequence for
+ moving the cursor down happends to be a newline
+ character, but under HP-UX it isn't. The result was
+ that no new line was being started under HP-UX.
+
+04/03/2001 mcs@astro.caltech.edu
+
+ configure.in Makefile.in Makefile.stub configure config.guess
+ config.sub Makefile.rules install-sh PORTING README INSTALL
+ Configuration and compilation of the library is now
+ performed with the help of an autoconf configure
+ script. In addition to relieving the user of the need to
+ edit the Makefile, this also allows automatic compilation
+ of the reentrant version of the library on platforms that
+ can handle it, along with the creation of shared
+ libraries where configured. On systems that aren't known
+ to the configure script, just the static tecla library is
+ compiled. This is currently the case on all systems
+ except Linux, Solaris and HP-UX. In the hope that
+ installers will provide specific conigurations for other
+ systems, the configure.in script is heavily commented,
+ and instructions on how to use are included in a new
+ PORTING file.
+
+24/02/2001 Version 1.2b released.
+
+22/02/2001 mcs@astro.caltech.edu
+
+ getline.c
+ It turns out that most terminals, but not all, on writing
+ a character in the rightmost column, don't wrap the
+ cursor onto the next line until the next character is
+ output. This library wasn't aware of this and thus if one
+ tried to reposition the cursor from the last column,
+ gl_get_line() thought that it was moving relative to a
+ point on the next line, and thus moved the cursor up a
+ line. The fix was to write one extra character when in
+ the last column to force the cursor onto the next line,
+ then backup the cursor to the start of the new line.
+ getline.c
+ On terminal initialization, the dynamic LINES and COLUMNS
+ environment variables were ignored unless
+ terminfo/termcap didn't return sensible dimensions. In
+ practice, when present they should override the static
+ versions in the terminfo/termcap databases. This is the
+ new behavior. In reality this probably won't have caused
+ many problems, because a SIGWINCH signal which informs of
+ terminal size changes is sent when the terminal is
+ opened, so the dimensions established during
+ initialization quickly get updated on most systems.
+
+18/02/2001 Version 1.2a released.
+
+18/02/2001 mcs@astro.caltech.edu
+
+ getline.c
+ Three months ago I moved the point at which termios.h
+ was included in getline.c. Unfortunately, I didn't notice
+ that this moved it to after the test for TIOCGWINSZ being
+ defined. This resulted in SIGWINCH signals not being
+ trapped for, and thus terminal size changes went
+ unnoticed. I have now moved the test to after the
+ inclusion of termios.h.
+
+12/02/2001 Markus Gyger (described here by mcs)
+
+ man3/pca_lookup_file.3 man3/gl_get_line.3
+ man3/ef_expand_file.3 man3/cpl_complete_word.3
+ In the 1.2 release of the library, all functions in the
+ library were given man pages. Most of these simply
+ include one of the above 4 man pages, which describe the
+ functions while describing the modules that they are in.
+ Markus added all of these function names to the lists in
+ the "NAME" headers of the respective man pages.
+ Previously only the primary function of each module was
+ named there.
+
+11/02/2001 mcs@astro.caltech.edu
+
+ getline.c
+ On entering a line that wrapped over two or more
+ terminal, if the user pressed enter when the cursor
+ wasn't on the last of the wrapped lines, the text of the
+ wrapped lines that followed it got mixed up with the next
+ line written by the application, or the next input
+ line. Somehow this slipped through the cracks and wasn't
+ noticed until now. Anyway, it is fixed now.
+
+09/02/2001 Version 1.2 released.
+
+04/02/2001 mcs@astro.caltech.edu
+
+ pcache.c libtecla.h
+ With all filesystems local, demo2 was very fast to start
+ up, but on a Sun system with one of the target
+ directories being on a remote nfs mounted filesystem, the
+ startup time was many seconds. This was due to the
+ executable selection callback being applied to all files
+ in the path at startup. To avoid this, all files are now
+ included in the cache, and the application specified
+ file-selection callback is only called on files as they
+ are matched. Whether the callback rejected or accepted
+ them is then cached so that the next time an already
+ checked file is looked at, the callback doesn't have to
+ be called. As a result, startup is now fast on all
+ systems, and since usually there are only a few matching
+ file completions at a time, the delay during completion
+ is also usually small. The only exception is if the user
+ tries to complete an empty string, at which point all
+ files have to be checked. Having done this once, however,
+ doing it again is fast.
+ man3/pca_lookup_file.3
+ I added a man page documenting the new PathCache module.
+ man3/.3
+ I have added man pages for all of the functions in each
+ of the modules. These 1-line pages use the .so directive
+ to redirect nroff to the man page of the parent module.
+ man Makefile update_html
+ I renamed man to man3 to make it easier to test man page
+ rediction, and updated Makefile and update_html
+ accordingly. I also instructed update_html to ignore
+ 1-line man pages when making html equivalents of the man
+ pages.
+ cplmatch.c
+ In cpl_list_completions() the size_t return value of
+ strlen() was being used as the length argument of a "%*s"
+ printf directive. This ought to be an int, so the return
+ value of strlen() is now cast to int. This would have
+ caused problems on architectures where the size of a
+ size_t is not equal to the size of an int.
+
+02/02/2001 mcs@astro.caltech.edu
+
+ getline.c
+ Under UNIX, certain terminal bindings are set using the
+ stty command. This, for example, specifies which control
+ key generates a user-interrupt (usually ^C or ^Y). What I
+ hadn't realized was that ASCII NUL is used as the way to
+ specify that one of these bindings is unset. I have now
+ modified the code to skip unset bindings, leaving the
+ corresponding action bound to the built-in default, or a
+ user provided binding.
+
+28/01/2001 mcs@astro.caltech.edu
+
+ pcache.c libtecla.h
+ A new module was added which supports searching for files
+ in any colon separated list of directories, such as the
+ unix execution PATH environment variable. Files in these
+ directories, after being individually okayed for
+ inclusion via an application provided callback, are
+ cached in a PathCache object. You can then look up the
+ full pathname of a given filename, or you can use the
+ provided completion callback to list possible completions
+ in the path-list. The contents of relative directories,
+ such as ".", obviously can't be cached, so these
+ directories are read on the fly during lookups and
+ completions. The obvious application of this facility is
+ to provide Tab-completion of commands, and thus a
+ callback to place executable files in the cache, is
+ provided.
+ demo2.c
+ This new program demonstrates the new PathCache
+ module. It reads and processes lines of input until the
+ word 'exit' is entered, or C-d is pressed. The default
+ tab-completion callback is replaced with one which at the
+ start of a line, looks up completions of commands in the
+ user's execution path, and when invoked in other parts of
+ the line, reverts to normal filename completion. Whenever
+ a new line is entered, it extracts the first word on the
+ line, looks it up in the user's execution path to see if
+ it corresponds to a known command file, and if so,
+ displays the full pathname of the file, along with the
+ remaining arguments.
+ cplfile.c
+ I added an optional pair of callback function/data
+ members to the new cpl_file_completions() configuration
+ structure. Where provided, this callback is asked
+ on a file-by-file basis, which files should be included
+ in the list of file completions. For example, a callback
+ is provided for listing only completions of executable
+ files.
+ cplmatch.c
+ When listing completions, the length of the type suffix
+ of each completion wasn't being taken into account
+ correctly when computing the column widths. Thus the
+ listing appeared ragged sometimes. This is now fixed.
+ pathutil.c
+ I added a function for prepending a string to a path,
+ and another for testing whether a pathname referred to
+ an executable file.
+
+28/01/2001 mcs@astro.caltech.edu
+
+ libtecla.h cplmatch.c man/cpl_complete_word.3
+ The use of a publically defined structure to configure
+ the cpl_file_completions() callback was flawed, so a new
+ approach has been designed, and the old method, albeit
+ still supported, is no longer documented in the man
+ pages. The definition of the CplFileArgs structure in
+ libtecla.h is now accompanied by comments warning people
+ not to modify it, since modifications could break
+ applications linked to shared versions of the tecla
+ library. The new method involves an opaque CplFileConf
+ object, instances of which are returned by a provided
+ constructor function, configured with provided accessor
+ functions, and when no longer needed, deleted with a
+ provided destructor function. This is documented in the
+ cpl_complete_word man page. The cpl_file_completions()
+ callback distinguishes what type of configuration
+ structure it has been sent by virtue of a code placed at
+ the beginning of the CplFileConf argument by its
+ constructor.
+
+04/01/2001 mcs@astro.caltech.edu (Release of version 1.1j)
+
+ getline.c
+ I added upper-case bindings for the default meta-letter
+ keysequences such as M-b. They thus continue to work
+ when the user has caps-lock on.
+ Makefile
+ I re-implemented the "install" target in terms of new
+ install_lib, install_inc and install_man targets. When
+ distributing the library with other packages, these new
+ targets allows for finer grained control of the
+ installation process.
+
+30/12/2000 mcs@astro.caltech.edu
+
+ getline.c man/gl_get_line.3
+ I realized that the recall-history action that I
+ implemented wasn't what Markus had asked me for. What he
+ actually wanted was for down-history to continue going
+ forwards through a previous history recall session if no
+ history recall session had been started while entering
+ the current line. I have thus removed the recall-history
+ action and modified the down-history action function
+ accordingly.
+
+24/12/2000 mcs@astro.caltech.edu
+
+ getline.c
+ I modified gl_get_line() to allow the previously returned
+ line to be passed in the start_line argument.
+ getline.c man/gl_get_line.3
+ I added a recall-history action function, bound to M^P.
+ This recalls the last recalled history line, regardless
+ of whether it was from the current or previous line.
+
+13/12/2000 mcs@astro.caltech.edu (Release of version 1.1i)
+
+ getline.c history.h history.c man/gl_get_line.3
+ I implemented the equivalent of the ksh Operate action. I
+ have named the tecla equivalent "repeat-history". This
+ causes the line that is to be edited to returned, and
+ arranges for the next most recent history line to be
+ preloaded on the next call to gl_get_line(). Repeated
+ invocations of this action thus result in successive
+ history lines being repeated - hence the
+ name. Implementing the ksh Operate action was suggested
+ by Markus Gyger. In ksh it is bound to ^O, but since ^O
+ is traditionally bound by the default terminal settings,
+ to stop-output, I have bound the tecla equivalent to M-o.
+
+01/12/2000 mcs@astro.caltech.edu (Release of version 1.1h)
+
+ getline.c keytab.c keytab.h man/gl_get_line.3
+ I added a digit-argument action, to allow repeat
+ counts for actions to be entered. As in both tcsh
+ and readline, this is bound by default to each of
+ M-0, M-1 through to M-9, the number being appended
+ to the current repeat count. Once one of these has been
+ pressed, the subsequent digits of the repeat count can be
+ typed with or without the meta key pressed. It is also
+ possible to bind digit-argument to other keys, with or
+ without a numeric final keystroke. See man page for
+ details.
+
+ getline.c man/gl_get_line.3
+ Markus noted that my choice of M-< for the default
+ binding of read-from-file, could be confusing, since
+ readline binds this to beginning-of-history. I have
+ thus rebound it to ^X^F (ie. like find-file in emacs).
+
+ getline.c history.c history.h man/gl_get_line.3
+ I have now implemented equivalents of the readline
+ beginning-of-history and end-of-history actions.
+ These are bound to M-< and M-> respectively.
+
+ history.c history.h
+ I Moved the definition of the GlHistory type, and
+ its subordinate types from history.h to history.c.
+ There is no good reason for any other module to
+ have access to the innards of this structure.
+
+27/11/2000 mcs@astro.caltech.edu (Release of version 1.1g)
+
+ getline.c man/gl_get_line.3
+ I added a "read-from-file" action function and bound it
+ by default to M-<. This causes gl_get_line() to
+ temporarily return input from the file who's name
+ precedes the cursor.
+
+26/11/2000 mcs@astro.caltech.edu
+
+ getline.c keytab.c keytab.h man/gl_get_line.3
+ I have reworked some of the keybinding code again.
+
+ Now, within key binding strings, in addition to the
+ previously existing notation, you can now use M-a to
+ denote meta-a, and C-a to denote control-a. For example,
+ a key binding which triggers when the user presses the
+ meta key, the control key and the letter [
+ simultaneously, can now be denoted by M-C-[, or M-^[ or
+ \EC-[ or \E^[.
+
+ I also updated the man page to use M- instead of \E in
+ the list of default bindings, since this looks cleaner.
+
+ getline.c man/gl_get_line.3
+ I added a copy-region-as-kill action function and
+ gave it a default binding to M-w.
+
+22/11/2000 mcs@astro.caltech.edu
+
+ *.c
+ Markus Gyger sent me a copy of a previous version of
+ the library, with const qualifiers added in appropriate
+ places. I have done the same for the latest version.
+ Among other things, this gets rid of the warnings
+ that are generated if one tells the compiler to
+ const qualify literal strings.
+
+ getline.c getline.h glconf.c
+ I have moved the contents of glconf.c and the declaration
+ of the GetLine structure into getline.c. This is cleaner,
+ since now only functions in getline.c can mess with the
+ innards of GetLine objects. It also clears up some problems
+ with system header inclusion order under Solaris, and also
+ the possibility that this might result in inconsistent
+ system macro definitions, which in turn could cause different
+ declarations of the structure to be seen in different files.
+
+ hash.c
+ I wrote a wrapper function to go around strcmp(), such that
+ when hash.c is compiled with a C++ compiler, the pointer
+ to the wrapper function is a C++ function pointer.
+ This makes it compatible with comparison function pointer
+ recorded in the hash table.
+
+ cplmatch.c getline.c libtecla.h
+ Markus noted that the Sun C++ compiler wasn't able to
+ match up the declaration of cpl_complete_word() in
+ libtecla.h, where it is surrounded by a extern "C" {}
+ wrapper, with the definition of this function in
+ cplmatch.c. My suspicion is that the compiler looks not
+ only at the function name, but also at the function
+ arguments to see if two functions match, and that the
+ match_fn() argument, being a fully blown function pointer
+ declaration, got interpetted as that of a C function in
+ one case, and a C++ function in the other, thus
+ preventing a match.
+
+ To fix this I now define a CplMatchFn typedef in libtecla.h,
+ and use this to declare the match_fn callback.
+
+20/11/2000 (Changes suggested by Markus Gyger to support C++ compilers):
+ expand.c
+ Renamed a variable called "explicit" to "xplicit", to
+ avoid conflicts when compiling with C++ compilers.
+ *.c
+ Added explicit casts when converting from (void *) to
+ other pointer types. This isn't needed in C but it is
+ in C++.
+ getline.c
+ tputs() has a strange declaration under Solaris. I was
+ enabling this declaration when the SPARC feature-test
+ macro was set. Markus changed the test to hinge on the
+ __sun and __SVR4 macros.
+ direader.c glconf.c stringrp.c
+ I had omitted to include string.h in these two files.
+
+ Markus also suggested some other changes, which are still
+ under discussion. With the just above changes however, the
+ library compiles without complaint using g++.
+
+19/11/2000 mcs@astro.caltech.edu
+ getline.h getline.c keytab.c keytab.h glconf.c
+ man/gl_get_line.3
+ I added support for backslash escapes (include \e
+ for the keyboard escape key) and literal binary
+ characters to the characters allowed within key sequences
+ of key bindings.
+
+ getline.h getline.c keytab.c keytab.h glconf.c
+ man/gl_get_line.3
+ I introduced symbolic names for the arrow keys, and
+ modified the library to use the cursor key sequences
+ reported by terminfo/termcap in addition to the default
+ ANSI ones. Anything bound to the symbolically named arrow
+ keys also gets bound to the default and terminfo/termcap
+ cursor key sequences. Note that under Solaris
+ terminfo/termcap report the properties of hardware X
+ terminals when TERM is xterm instead of the terminal
+ emulator properties, and the cursor keys on these two
+ systems generate different key sequences. This is an
+ example of why extra default sequences are needed.
+
+ getline.h getline.c keytab.c
+ For some reason I was using \e to represent the escape
+ character. This is supported by gcc, which thus doesn't
+ emit a warning except with the -pedantic flag, but isn't
+ part of standard C. I now use a macro to define escape
+ as \033 in getline.h, and this is now used wherever the
+ escape character is needed.
+
+17/11/2000 mcs@astro.caltech.edu (Release of version 1.1d)
+
+ getline.c, man/gl_get_line(3), html/gl_get_line.html
+ In tcsh ^D is bound to a function which does different
+ things depending on where the cursor is within the input
+ line. I have implemented its equivalent in the tecla
+ library. When invoked at the end of the line this action
+ function displays possible completions. When invoked on
+ an empty line it causes gl_get_line() to return NULL,
+ thus signalling end of input. When invoked within a line
+ it invokes forward-delete-char, as before. The new action
+ function is called del-char-or-list-or-eof.
+
+ getline.c, man/gl_get_line(3), html/gl_get_line.html
+ I found that the complete-word and expand-file actions
+ had underscores in their names instead of hyphens. This
+ made them different from all other action functions, so I
+ have changed the underscores to hyphens.
+
+ homedir.c
+ On SCO UnixWare while getpwuid_r() is available, the
+ associated _SC_GETPW_R_SIZE_MAX macro used by sysconf()
+ to find out how big to make the buffer to pass to this
+ function to cater for any password entry, doesn't
+ exist. I also hadn't catered for the case where sysconf()
+ reports that this limit is indeterminate. I have thus
+ change the code to substitute a default limit of 1024 if
+ either the above macro isn't defined or if sysconf() says
+ that the associated limit is indeterminate.
+
+17/11/2000 mcs@astro.caltech.edu (Release of version 1.1c)
+
+ getline.c, getline.h, history.c, history.h
+ I have modified the way that the history recall functions
+ operate, to make them better emulate the behavior of
+ tcsh. Previously the history search bindings always
+ searched for the prefix that preceded the cursor, then
+ left the cursor at the same point in the line, so that a
+ following search would search using the same prefix. This
+ isn't how tcsh operates. On finding a matching line, tcsh
+ puts the cursor at the end of the line, but arranges for
+ the followup search to continue with the same prefix,
+ unless the user does any cursor motion or character
+ insertion operations in between, in which case it changes
+ the search prefix to the new set of characters that are
+ before the cursor. There are other complications as well,
+ which I have attempted to emulate. As far as I can
+ tell, the tecla history recall facilities now fully
+ emulate those of tcsh.
+
+16/11/2000 mcs@astro.caltech.edu (Release of version 1.1b)
+
+ demo.c:
+ One can now quit from the demo by typing exit.
+
+ keytab.c:
+ The first entry of the table was getting deleted
+ by _kt_clear_bindings() regardless of the source
+ of the binding. This deleted the up-arrow binding.
+ Symptoms noted by gazelle@yin.interaccess.com.
+
+ getline.h:
+ Depending on which system include files were include
+ before the inclusion of getline.h, SIGWINCH and
+ TIOCGWINSZ might or might not be defined. This resulted
+ in different definitions of the GetLine object in
+ different files, and thus some very strange bugs! I have
+ now added #includes for the necessary system header files
+ in getline.h itself. The symptom was that on creating a
+ ~/.teclarc file, the demo program complained of a NULL
+ argument to kt_set_keybinding() for the first line of the
+ file.
+
+15/11/2000 mcs@astro.caltech.edu (Release of version 1.1a)
+
+ demo.c:
+ I had neglected to check the return value of
+ new_GetLine() in the demo program. Oops.
+
+ getline.c libtecla.h:
+ I wrote gl_change_terminal(). This allows one to change to
+ a different terminal or I/O stream, by specifying the
+ stdio streams to use for input and output, along with the
+ type of terminal that they are connected to.
+
+ getline.c libtecla.h:
+ Renamed GetLine::isterm to GetLine::is_term. Standard
+ C reserves names that start with "is" followed by
+ alphanumeric characters, so this avoids potential
+ clashes in the future.
+
+ keytab.c keytab.h
+ Each key-sequence can now have different binding
+ functions from different sources, with the user provided
+ binding having the highest precedence, followed by the
+ default binding, followed by any terminal specific
+ binding. This allows gl_change_terminal() to redefine the
+ terminal-specific bindings each time that
+ gl_change_terminal() is called, without overwriting the
+ user specified or default bindings. In the future, it will
+ also allow for reconfiguration of user specified
+ bindings after the call to new_GetLine(). Ie. deleting a
+ user specified binding should reinstate any default or
+ terminal specific binding.
+
+ man/cpl_complete_word.3 html/cpl_complete_word.html
+ man/ef_expand_file.3 html/ef_expand_file.html
+ man/gl_get_line.3 html/gl_get_line.html
+ I added sections on thread safety to the man pages of the
+ individual modules.
+
+ man/gl_get_line.3 html/gl_get_line.html
+ I documented the new gl_change_terminal() function.
+
+ man/gl_get_line.3 html/gl_get_line.html
+ In the description of the ~/.teclarc configuration file,
+ I had omitted the 'bind' command word in the example
+ entry. I have now remedied this.
diff --git a/libtecla-1.4.1/INSTALL b/libtecla-1.4.1/INSTALL
new file mode 100644
index 0000000..1a1b036
--- /dev/null
+++ b/libtecla-1.4.1/INSTALL
@@ -0,0 +1,168 @@
+To compile and optionally install the library, it is first necessary
+to create a makefile for your system, by typing:
+
+ ./configure
+
+The Makefile that this generates is designed to install the files of
+the library in subdirectories of /usr/local/. If you would prefer to
+install them under a different directory, you can type:
+
+ ./configure --prefix /wherever
+
+Where you would replace /wherever with your chosen directory. Other
+command-line options are available, and can be listed by typing:
+
+ ./configure --help
+
+Having run the configure script, you are then ready to make the
+library. To do this, just type:
+
+ make
+
+What 'make' does depends on whether the configure script knows about
+your system. If the configure script doesn't know anything specific
+about your system, it will arrange for 'make' to produce the static
+tecla library, called libtecla.a, and if possible, the reentrant
+version of this called libtecla_r.a. If it does know about your
+system, it will also create shared libraries if possible. If you are
+on a system that isn't known, and you would like shared libraries to
+be compiled, please read the file called PORTING to see how this can
+be achieved.
+
+To install the library, its include file and it manual pages, type:
+
+ make install
+
+Note that this will also compile the library if you haven't already
+done so.
+
+Having compiled the library, if you wish, you can test it by running
+the demo programs. After building the library, you should find two
+programs, called demo and demo2, in the current directory.
+
+The first of the demos programs reads input lines from the user, and
+writes what was typed back to the screen. While typing a line of
+input, you can experiment with line editing, tab completion, history
+recall etc.. For details about these line editing features, see the
+man page gl_get_line(3). If you haven't installed this yet, you can
+see it anyway by typing:
+
+ nroff -man man3/gl_get_line.3 | more
+
+The second demo program, called demo2, demonstrates command-completion
+with the UNIX PATH. If you type in a partial command name, and press
+TAB, the command name will be completed if possible, and possible
+completions will be listed if it is ambiguous. When you then enter the
+line, the demo program then prints out the full pathname of the
+command that you typed. If you type anything after the command name,
+filename completion with the tab key reverts to its default behavior
+of completing filenames in the current directory.
+
+COMPILING IN A DIFFERENT DIRECTORY
+----------------------------------
+If you unpack the distribution in a directory which is visible from
+multiple hosts which have different architectures, you have the option
+of compiling the library for the different architectures in different
+directories. You might for example create a sub-directory for each
+architecture, under the top level directory of the distribution. You
+would then log in to a host of one of these architectures, cd to the
+sub-directory that you created for it, and type:
+
+ ../configure
+
+The configure script then creates a makefile in the current directory
+which is designed to build the library, object files, demos etc for
+the architecture of the current host, in the current directory, using
+the original source code in ../. You then repeat this procedure on
+hosts of other architectures.
+
+The compilation directories don't have to be sub-directories of the
+top level directory of the distribution. That was just described as an
+example. They can be anywhere you like.
+
+Every rule in the makefiles that are generated by the configure
+script, cites the paths of the target and source files explicitly, so
+this procedure should work on any system, without the need for vpath
+makefile support.
+
+EMBEDDING IN OTHER PACKAGE DISTRIBUTIONS
+----------------------------------------
+
+If you distribute the library with another package, which has its own
+heirarchy and configuration procedures, the following installation
+options may be of interest to you. At first glance, the use of a GNU
+configure script by the tecla library, may appear to reduce your
+options for controlling what gets made, and where it gets installed,
+but this isn't the case, because many of the parameters configured by
+the configure script are assigned to make variables which can be
+overriden when you run make.
+
+For example, lets say that you have your own configuration script in
+the parent directory of the libtecla top-level directory. In your
+configuration script, you would first need to have the following line:
+
+ (cd libtecla; ./configure)
+
+Now, from your makefile or whatever script you use to build your
+application, you would need to make the library. Assuming that your
+makefile or build script is in the parent directory of the libtecla
+distribution, the following line tells make to just make the
+non-reentrant, static version of the tecla library, and to install it
+and the tecla include file in sub-directories called lib and include
+in your current directory.
+
+ (cd libtecla; make LIBDIR=../lib INCDIR=../include TARGETS=normal TARGET_LIBS="static" install_lib install_inc)
+
+First, the LIBDIR=../lib means that on installing the library, it
+should be placed in the directory libtecla/../lib. Similarly INCDIR
+tells make where to place the include files. The install_lib and
+install_inc targets tell make to install the libraries and the include
+file. Because the install_man and install_bin targets have been
+omitted in this example, the man pages and programs aren't installed.
+If you were to include these additional targets then you could use the
+MANDIR and BINDIR variables, respectively to control where they were
+installed.
+
+The TARGETS variable is used to specify which of the normal and
+reentrant versions of the library are compiled. This can contain one
+or both of the words "normal" and "reentrant". If you don't specify
+this when you invoke make, the default value generated by the
+configure script will be used. Depending on whether reentrant POSIX
+functions are available for compilation of the reentrant version, this
+will be either "normal" or "normal reentrant".
+
+The TARGET_LIBS variable is used to specify which of the static and
+shared libraries are to be built. This can contain one or both of the
+words "static" and "shared". If you don't specify this when you invoke
+make, the default value generated by the configure script will be
+used. Depending on whether the configure script knows how to create
+shared libraries on the target system, this will be either "static" or
+"static shared". Beware that shared libraries aren't supported on many
+systems, so requiring "shared" will limit which systems you can
+compile your package on. Also note that unless your package installs
+the tecla library in a directory which all users of your program will
+have access to, you should only compile the static version.
+Instructions for adding shared-library creation rules for new systems
+are included in the PORTING file.
+
+The OPT variable can be used to change the default optimization from
+the default of "-O" to something else.
+
+The DEMOS variable controls whether the demo programs are built.
+Normally this has the value "demos", which tells the makefile to build
+the demo programs. Setting it to an empty string stops the demos from
+being built.
+
+The PROGRAMS variable is used to specify which programs are to be
+built and subsequently installed. All available programs are built by
+default. Currently there is only one such program, selected by
+specifying the word "enhance". This program uses tecla-enhanced
+pseudo-terminals to layer command line editing on top of third party
+programs.
+
+The PROGRAMS_R variable serves the same purpose as the PROGRAMS
+variable, except that programs listed here are linked with the
+reentrant version of the library, and should be specified with a _r
+suffix. Currently this variable is empty by default.
+
+Martin Shepherd (mcs@astro.caltech.edu)
diff --git a/libtecla-1.4.1/LICENSE.TERMS b/libtecla-1.4.1/LICENSE.TERMS
new file mode 100644
index 0000000..275eef5
--- /dev/null
+++ b/libtecla-1.4.1/LICENSE.TERMS
@@ -0,0 +1,28 @@
+Copyright (c) 2000, 2001 by Martin C. Shepherd.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
diff --git a/libtecla-1.4.1/Makefile b/libtecla-1.4.1/Makefile
new file mode 100644
index 0000000..15116b5
--- /dev/null
+++ b/libtecla-1.4.1/Makefile
@@ -0,0 +1,3 @@
+default:
+ ./configure
+ make
diff --git a/libtecla-1.4.1/Makefile.in b/libtecla-1.4.1/Makefile.in
new file mode 100644
index 0000000..f691375
--- /dev/null
+++ b/libtecla-1.4.1/Makefile.in
@@ -0,0 +1,225 @@
+#-----------------------------------------------------------------------
+# This is the template that the libtecla configure script uses to create
+# the libtecla Makefile. It does this by replacing all instances of
+# @name@ with the value of the correspondingly named configuration
+# variable. You should find another file in the same directory as this
+# one, called "configure.in". The latter file contains extensive comments
+# explaining how this all works.
+#-----------------------------------------------------------------------
+
+# Where is the source code?
+
+srcdir = @srcdir@
+
+# Where do you want to install the library, its header file, and the man pages?
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+LIBDIR=@libdir@
+INCDIR=@includedir@
+MANDIR=@mandir@
+BINDIR=@bindir@
+
+# Which C compiler do you want to use?
+
+CC = @CC@
+
+# If 'make' doesn't define the MAKE variable, define it here.
+
+@SET_MAKE@
+
+# To use RANLIB set the RANLIB variable to ranlib. Otherwise set it to
+# :, which is the bourne shell do-nothing command.
+
+RANLIB = @RANLIB@
+
+# The following optional defines change the characteristics of the library.
+#
+# USE_TERMINFO
+# Use the terminfo terminal information database when looking up
+# terminal characteristics. Most modern UNIX and UNIX-like operating
+# systems support terminfo, so this define should normally be included.
+# If in doubt leave it in, and see if the library compiles.
+# USE_TERMCAP
+# If you don't have terminfo but do have the termcap database, replace
+# the -DUSE_TERMINFO with -DUSE_TERMCAP. If there is a termcap.h in
+# /usr/include/, also add -DHAVE_TERMCAP_H.
+#
+# If neither USE_TERMINFO nor USE_TERMCAP are included, ANSI VT100 control
+# sequences will be used to control all terminal types.
+#
+# For Solaris and Linux, use:
+#
+# DEFINES = -DUSE_TERMINFO
+#
+
+DEFINES = @DEFS@
+
+#
+# The following defines are used in addition to the above when compiling
+# the reentrant version of the library. Note that the definition of
+# _POSIX_C_SOURCE to request reentrant functions, has the unfortunate
+# side-effect on some systems of stopping the TIOCGWINSZ ioctl macro from
+# getting defined. This in turn stops the library from being
+# able to respond to terminal size changes. Under Solaris this can be
+# remedied by adding -D__EXTENSIONS__. On linux this isn't necessary.
+# If you don't get this right, the library will still work, but
+# it will get confused if the terminal size gets changed and you try to
+# edit a line that exceeds the terminal width.
+#
+# Thus on Solaris you should use:
+#
+# DEFINES_R = -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__
+#
+# and on linux you should use:
+#
+# DEFINES_R = -D_POSIX_C_SOURCE=199506L
+#
+
+DEFINES_R = -D_POSIX_C_SOURCE=199506L
+
+#
+# The compiler optimization flags. I like to keep this separate so
+# that I can set it to -g from the 'make' command line without having
+# to edit this file when debugging the library. If you aren't working
+# on modifying the library, leave this set to -O.
+#
+
+OPT = -O
+
+#
+# These are paranoid gcc warning flags to use when compiling new code.
+# Simply invoke make with WARNING_FLAGS='$(PEDANTIC_FLAGS)'.
+#
+PEDANTIC_FLAGS=-Wall -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
+
+#
+# Specify any extra compiler warning options that you want to use.
+# Leave this blank unless you are porting the library to a new system,
+# or modifying the library.
+#
+
+WARNING_FLAGS=
+
+#
+# If you want to compile the demo program, specify any system
+# libraries that are needed for the terminal I/O functions.
+#
+# If you are using terminfo, you will probably only need -lcurses.
+# For termcap you may need -ltermcap or -ltermlib.
+#
+# For Solaris, use:
+#
+# LIBS = -lcurses
+#
+# For linux, use:
+#
+# LIBS = -lncurses
+#
+
+LIBS = @LIBS@
+
+#
+# List the default target libraries. This should be one or
+# both of the words "normal" and "reentrant".
+#
+TARGETS = @TARGETS@
+
+#
+# List which types of the above libraries are required.
+# This should be one or both of the words "static" and "shared".
+#
+TARGET_LIBS = @TARGET_LIBS@
+
+#
+# If you want the demo programs to be built, the following variable
+# should be assigned the single word: demos. If it isn't assigned
+# anything, the demo programs won't be built.
+#
+DEMOS = demos
+
+#
+# List the programs that are to be made by default.
+#
+PROGRAMS = enhance
+
+#
+# List programs for which reentrant versions are to be built by default.
+#
+PROGRAMS_R =
+
+#-----------------------------------------------------------------------
+# You shouldn't need to change anything below this line.
+#-----------------------------------------------------------------------
+
+CFLAGS = $(OPT) $(WARNING_FLAGS) $(DEFINES) @CFLAGS@ @SHARED_CFLAGS@
+
+default: $(TARGETS)
+
+normal:
+ @$(MAKE) -f $(srcdir)/Makefile.rules TARGETS="$(TARGET_LIBS)" SUFFIX="" CFLAGS="$(CFLAGS)" CC="$(CC)" OBJDIR=normal_obj LINK_SHARED='@LINK_SHARED@' SHARED_EXT='@SHARED_EXT@' SHARED_ALT='@SHARED_ALT@' LIBS='$(LIBS)' srcdir='$(srcdir)' LIBDIR='$(LIBDIR)' LN_S='@LN_S@' DEMOS="$(DEMOS)" PROGRAMS='$(PROGRAMS)' RANLIB='$(RANLIB)'
+
+reentrant:
+ @$(MAKE) -f $(srcdir)/Makefile.rules TARGETS="$(TARGET_LIBS)" SUFFIX="_r" CFLAGS="$(CFLAGS) $(DEFINES_R)" CC="$(CC)" OBJDIR=reentrant_obj LINK_SHARED='@LINK_SHARED@' SHARED_EXT='@SHARED_EXT@' SHARED_ALT='@SHARED_ALT@' LIBS='$(LIBS)' srcdir='$(srcdir)' LIBDIR='$(LIBDIR)' LN_S='@LN_S@' DEMOS="$(DEMOS)" PROGRAMS='$(PROGRAMS_R)' RANLIB='$(RANLIB)'
+
+demos: normal
+
+demos_r: reentrant
+
+clean:
+ rm -rf *.o normal_obj reentrant_obj libtecla*.a demo demo2 demo_r demo2_r enhance *~ man3/*~ html/*~ compile_reentrant compile_normal
+ @endings="@SHARED_EXT@ @SHARED_ALT@" ; \
+ for alt in $$endings ; do \
+ lib="libtecla*$$alt" ; \
+ rm -f $$lib; echo rm -f $$lib ; \
+ done
+
+distclean: clean
+ rm -f config.cache config.status config.log Makefile libtecla.map.opt
+ cp $(srcdir)/Makefile.stub Makefile
+
+install_lib: $(TARGETS) $(LIBDIR)
+ @for lib in libtecla.a libtecla_r.a ; do \
+ if [ -f $$lib ] ; then \
+ cp $$lib $(LIBDIR)/ ; chmod ugo+r $(LIBDIR)/$$lib; \
+ echo "cp $$lib $(LIBDIR)/ ; chmod ugo+r $(LIBDIR)/$$lib"; \
+ fi ; \
+ done
+ @for lib in libtecla libtecla_r ; do \
+ src="$$lib@SHARED_EXT@"; \
+ if [ -f $$src ] ; then \
+ dst="$(LIBDIR)/$$src"; \
+ cp -f $$src $$dst; chmod a=rX $$dst; \
+ echo "cp -f $$src $$dst ; chmod a=rX $$dst"; \
+ endings="@SHARED_ALT@" ; \
+ for alt in $$endings ; do \
+ lnk="$$lib$$alt"; \
+ (cd $(LIBDIR); rm -f $$lnk; @LN_S@ $$src $$lnk); \
+ echo "(cd $(LIBDIR); rm -f $$lnk; @LN_S@ $$src $$lnk)"; \
+ done ; \
+ fi ; \
+ done
+
+install_inc: $(INCDIR)
+ @if [ -f $(srcdir)/libtecla.h ]; then \
+ cp $(srcdir)/libtecla.h $(INCDIR)/ ; chmod ugo+r $(INCDIR)/libtecla.h; \
+ echo "cp $(srcdir)/libtecla.h $(INCDIR)/ ; chmod ugo+r $(INCDIR)/libtecla.h"; \
+ fi
+
+install_man: $(MANDIR) $(MANDIR)/man3
+ cd $(srcdir)/man3 && for page in *.3; do cp $$page $(MANDIR)/man3; chmod ugo+r $(MANDIR)/man3/$$page; done
+
+install_bin: $(BINDIR) $(PROGRAMS) $(PROGRAMS_R)
+ progs="$(PROGRAMS) $(PROGRAMS_R)"; \
+ for prog in $$progs; do \
+ cp $$prog $(BINDIR)/; \
+ chmod ugo+rx $(BINDIR)/$$prog; \
+ done
+
+install: install_lib install_inc install_man install_bin
+
+# Make any missing installation directories.
+
+$(MANDIR) $(MANDIR)/man3 $(LIBDIR) $(INCDIR) $(BINDIR):
+ $(srcdir)/install-sh -d $@
+ chmod ugo+rx $@
diff --git a/libtecla-1.4.1/Makefile.rules b/libtecla-1.4.1/Makefile.rules
new file mode 100644
index 0000000..6552057
--- /dev/null
+++ b/libtecla-1.4.1/Makefile.rules
@@ -0,0 +1,142 @@
+default: $(OBJDIR) $(TARGETS) $(DEMOS) $(PROGRAMS)
+
+#-----------------------------------------------------------------------
+# You shouldn't need to change anything in this file.
+#-----------------------------------------------------------------------
+
+# Create the directory in which the object files will be created.
+
+$(OBJDIR):
+ mkdir $(OBJDIR)
+
+# Construct the compilation command.
+
+COMPILE = $(CC) -c $(CFLAGS) -o $@
+
+LIB_OBJECTS = $(OBJDIR)/getline.o $(OBJDIR)/keytab.o $(OBJDIR)/freelist.o \
+ $(OBJDIR)/strngmem.o $(OBJDIR)/hash.o $(OBJDIR)/history.o \
+ $(OBJDIR)/direader.o $(OBJDIR)/homedir.o $(OBJDIR)/pathutil.o \
+ $(OBJDIR)/expand.o $(OBJDIR)/stringrp.o $(OBJDIR)/cplfile.o \
+ $(OBJDIR)/cplmatch.o $(OBJDIR)/pcache.o $(OBJDIR)/version.o
+
+# List all of the programs that this makefile can build.
+
+PROGS = demo$(SUFFIX) demo2$(SUFFIX) enhance$(SUFFIX)
+
+static: libtecla$(SUFFIX).a
+
+libtecla$(SUFFIX).a: $(LIB_OBJECTS)
+ ar -ru $@ $(LIB_OBJECTS); \
+ $(RANLIB) $@; \
+ rm -f $(PROGS)
+
+shared: libtecla$(SUFFIX)$(SHARED_EXT)
+
+libtecla$(SUFFIX)$(SHARED_EXT): $(LIB_OBJECTS) $(srcdir)/libtecla.map \
+ libtecla.map.opt
+ $(LINK_SHARED)
+ @endings="$(SHARED_ALT)" ; \
+ for alt in $$endings ; do \
+ lnk="libtecla$(SUFFIX)$$alt"; \
+ echo "rm -f $$lnk; $(LN_S) $@ $$lnk"; \
+ rm -f $$lnk; $(LN_S) $@ $$lnk; \
+ done; \
+ rm -f $(PROGS)
+
+libtecla.map.opt: $(srcdir)/libtecla.map
+ sed -n 's/^[ ]*\([_a-zA-Z0-9]*\)[ ]*;.*/+e \1/p' $? >$@
+
+demos: demo$(SUFFIX) demo2$(SUFFIX)
+
+demo$(SUFFIX): $(OBJDIR)/demo.o
+ LD_RUN_PATH="$(LIBDIR):$$LD_RUN_PATH:`pwd`" $(CC) $(CFLAGS) -o $@ \
+ $(OBJDIR)/demo.o -L. -ltecla$(SUFFIX) $(LIBS)
+
+demo2$(SUFFIX): $(OBJDIR)/demo2.o
+ LD_RUN_PATH="$(LIBDIR):$$LD_RUN_PATH:`pwd`" $(CC) $(CFLAGS) -o $@ \
+ $(OBJDIR)/demo2.o -L. -ltecla$(SUFFIX) $(LIBS)
+
+enhance$(SUFFIX): $(OBJDIR)/enhance.o
+ LD_RUN_PATH="$(LIBDIR):$$LD_RUN_PATH:`pwd`" $(CC) $(CFLAGS) -o $@ \
+ $(OBJDIR)/enhance.o -L. -ltecla$(SUFFIX) $(LIBS)
+
+#-----------------------------------------------------------------------
+# Object file dependencies.
+#-----------------------------------------------------------------------
+
+$(OBJDIR)/getline.o: $(srcdir)/getline.c $(srcdir)/pathutil.h \
+ $(srcdir)/libtecla.h $(OBJDIR)/keytab.h $(srcdir)/history.h \
+ $(srcdir)/freelist.h $(srcdir)/stringrp.h $(srcdir)/getline.h
+ $(COMPILE) $(srcdir)/getline.c
+
+$(OBJDIR)/keytab.o: $(srcdir)/keytab.c $(OBJDIR)/keytab.h \
+ $(srcdir)/strngmem.h $(srcdir)/getline.h
+ $(COMPILE) $(srcdir)/keytab.c
+
+$(OBJDIR)/strngmem.o: $(srcdir)/strngmem.c $(srcdir)/strngmem.h \
+ $(srcdir)/freelist.h
+ $(COMPILE) $(srcdir)/strngmem.c
+
+$(OBJDIR)/freelist.o: $(srcdir)/freelist.c $(srcdir)/freelist.h
+ $(COMPILE) $(srcdir)/freelist.c
+
+$(OBJDIR)/hash.o: $(srcdir)/hash.c $(srcdir)/hash.h $(srcdir)/strngmem.h \
+ $(srcdir)/freelist.h
+ $(COMPILE) $(srcdir)/hash.c
+
+$(OBJDIR)/history.o: $(srcdir)/history.c $(srcdir)/history.h \
+ $(srcdir)/freelist.h
+ $(COMPILE) $(srcdir)/history.c
+
+$(OBJDIR)/expand.o: $(srcdir)/expand.c $(srcdir)/freelist.h \
+ $(srcdir)/direader.h $(srcdir)/pathutil.h $(srcdir)/homedir.h \
+ $(srcdir)/stringrp.h $(srcdir)/libtecla.h
+ $(COMPILE) $(srcdir)/expand.c
+
+$(OBJDIR)/direader.o: $(srcdir)/direader.c $(srcdir)/direader.h
+ $(COMPILE) $(srcdir)/direader.c
+
+$(OBJDIR)/homedir.o: $(srcdir)/homedir.c $(srcdir)/pathutil.h \
+ $(srcdir)/homedir.h
+ $(COMPILE) $(srcdir)/homedir.c
+
+$(OBJDIR)/pathutil.o: $(srcdir)/pathutil.c $(srcdir)/pathutil.h
+ $(COMPILE) $(srcdir)/pathutil.c
+
+$(OBJDIR)/stringrp.o: $(srcdir)/stringrp.c $(srcdir)/freelist.h \
+ $(srcdir)/stringrp.h
+ $(COMPILE) $(srcdir)/stringrp.c
+
+$(OBJDIR)/cplfile.o: $(srcdir)/cplfile.c $(srcdir)/libtecla.h \
+ $(srcdir)/direader.h $(srcdir)/homedir.h $(srcdir)/pathutil.h \
+ $(srcdir)/cplfile.h
+ $(COMPILE) $(srcdir)/cplfile.c
+
+$(OBJDIR)/cplmatch.o: $(srcdir)/cplmatch.c $(srcdir)/libtecla.h \
+ $(srcdir)/stringrp.h $(srcdir)/pathutil.h $(srcdir)/cplfile.h
+ $(COMPILE) $(srcdir)/cplmatch.c
+
+$(OBJDIR)/pcache.o: $(srcdir)/pcache.c $(srcdir)/libtecla.h \
+ $(srcdir)/pathutil.h $(srcdir)/homedir.h $(srcdir)/freelist.h \
+ $(srcdir)/direader.h $(srcdir)/stringrp.h
+ $(COMPILE) $(srcdir)/pcache.c
+
+$(OBJDIR)/demo.o: $(srcdir)/demo.c $(srcdir)/libtecla.h
+ $(COMPILE) $(srcdir)/demo.c
+
+$(OBJDIR)/demo2.o: $(srcdir)/demo2.c $(srcdir)/libtecla.h
+ $(COMPILE) $(srcdir)/demo2.c
+
+$(OBJDIR)/version.o: $(srcdir)/version.c $(srcdir)/libtecla.h
+ $(COMPILE) $(srcdir)/version.c
+
+$(OBJDIR)/enhance.o: $(srcdir)/enhance.c $(srcdir)/libtecla.h
+ $(COMPILE) $(srcdir)/enhance.c
+
+#-----------------------------------------------------------------------
+# Include file dependencies.
+#-----------------------------------------------------------------------
+
+$(OBJDIR)/keytab.h: $(srcdir)/keytab.h $(srcdir)/libtecla.h \
+ $(srcdir)/hash.h $(srcdir)/strngmem.h
+ cp $(srcdir)/keytab.h $@
diff --git a/libtecla-1.4.1/Makefile.stub b/libtecla-1.4.1/Makefile.stub
new file mode 100644
index 0000000..15116b5
--- /dev/null
+++ b/libtecla-1.4.1/Makefile.stub
@@ -0,0 +1,3 @@
+default:
+ ./configure
+ make
diff --git a/libtecla-1.4.1/PORTING b/libtecla-1.4.1/PORTING
new file mode 100644
index 0000000..db39818
--- /dev/null
+++ b/libtecla-1.4.1/PORTING
@@ -0,0 +1,38 @@
+The Tecla library was written with portability in mind, so no
+modifications to the source code should be needed on UNIX or LINUX
+platforms. The default compilation and linking arrangements should
+also work unchanged on these systems, but if no specific configuration
+has been provided for your system, shared libraries won't be compiled.
+Configuring these requires modifications to be made to the file:
+
+ configure.in
+
+This file is heavily commented (comments start with the word dnl) and
+is relatively simple, so the instructions and suggestions that you
+find in this file should be sufficient to help you figure out how to
+add a configuration for your system. This file is an input file to the
+GNU autoconf program, which uses it as a template for generating the
+distributed configure script. If autoconf is installed on your system,
+creating a new configure script is a simple matter of typing.
+
+ autoconf
+
+To avoid confusion with the leftovers of the previous configuration,
+you should then do the following:
+
+ rm -f config.cache
+ ./configure
+ make clean
+ ./configure
+ make
+
+The first ./configure creates a new makefile for your system, allowing
+you to type 'make clean' to discard any files that were compiled with
+the previous configuration. Since 'make clean' also deletes the new
+makefile, a second invokation of the configure script is then
+performed to re-create the makefile. The final make then creates the
+tecla library from scratch.
+
+Once you have confirmed that the new configuration works, please send
+the modified "configure.in" template to mcs@astro.caltech.edu, so that
+your changes can be included in subsequent releases.
diff --git a/libtecla-1.4.1/README b/libtecla-1.4.1/README
new file mode 100644
index 0000000..894819d
--- /dev/null
+++ b/libtecla-1.4.1/README
@@ -0,0 +1,53 @@
+This is version 1.4.1 of the tecla command-line editing library.
+
+For the current official release, please direct your browser to:
+
+ http://www.astro.caltech.edu/~mcs/tecla/index.html
+
+The tecla library provides UNIX and LINUX programs with interactive
+command line editing facilities, similar to those of the unix tcsh
+shell. In addition to simple command-line editing, it supports recall
+of previously entered command lines, TAB completion of file names, and
+in-line wild-card expansion of filenames. The internal functions
+which perform file-name completion and wild-card expansion are also
+available externally for optional use by programs, along with a module
+for tab-completion and lookup of filenames in a list of directories.
+
+Note that special care has been taken to allow the use of this library
+in threaded programs. The option to enable this is discussed in the
+Makefile, and specific discussions of thread safety are presented in
+the included man pages.
+
+For instructions on how to compile and install the library, please see
+the INSTALL file, which should be in the same directory as this file.
+
+Copyright and Disclaimer
+------------------------
+Copyright (c) 2000, 2001 by Martin C. Shepherd.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
diff --git a/libtecla-1.4.1/RELEASE.NOTES b/libtecla-1.4.1/RELEASE.NOTES
new file mode 100644
index 0000000..1b18a4a
--- /dev/null
+++ b/libtecla-1.4.1/RELEASE.NOTES
@@ -0,0 +1,357 @@
+This file lists major changes which accompany each new release.
+
+Version 1.4.1:
+
+ This is a maintenance release. It includes minor changes to support
+ Mac OS X (Darwin), the QNX real-time operating system, and Cygwin
+ under Windows. It also fixes an oversight that was preventing the
+ tab key from inserting tab characters when users unbound the
+ complete-word action from it.
+
+Version 1.4.0:
+
+ The contents of the history list can now be saved and restored with
+ the new gl_save_history() and gl_load_history() functions.
+
+ Event handlers can now be registered to watch for and respond to I/O
+ on arbitrary file descriptors while gl_get_line() is waiting for
+ terminal input from the user. See the gl_get_line(3) man page
+ for details on gl_watch_fd().
+
+ As an optional alternative to getting configuration information only
+ from ~/.teclarc, the new gl_configure_getline() function allows
+ configuration commands to be taken from any of, a string, a
+ specified application-specific file, and/or a specified
+ user-specific file. See the gl_get_line(3) man page for details.
+
+ The version number of the library can now be queried using the
+ libtecla_version() function. See the libtecla(3) man page.
+
+ The new gl_group_history() function allows applications to group
+ different types of input line in the history buffer, and arrange for
+ only members of the appropriate group to be recalled on a given call
+ to gl_get_line(). See the gl_get_line(3) man page.
+
+ The new gl_show_history() function displays the current history list
+ to a given stdio output stream. See the gl_get_line(3) man page.
+
+ new_GetLine() now allows you to specify a history buffer size of
+ zero, thus requesting that no history buffer be allocated. You can
+ subsequently resize or delete the history buffer at any time, by
+ calling gl_resize_history(), limit the number of lines that are
+ allowed in the buffer by calling gl_limit_history(), clear either
+ all history lines from the history list, or just the history lines
+ that are associated with the current history group, by calling
+ gl_clear_history, and toggle the history mechanism on and off by
+ calling gl_toggle_history().
+
+ The new gl_terminal_size() function can be used to query the
+ current terminal size. It can also be used to supply a default
+ terminal size on systems where no mechanism is available for
+ looking up the size.
+
+ The contents and configuration of the history list can now be
+ obtained by the calling application, by calling the new
+ gl_lookup_history(), gl_state_of_history(), gl_range_of_history()
+ and gl_size_of_history() functions. See the gl_get_line(3) man page.
+
+ Echoing of the input line as it is typed, can now be turned on and
+ off via the new gl_echo_mode() function. While echoing is disabled,
+ newly entered input lines are omitted from the history list. See
+ the gl_get_line(3) man page.
+
+ While the default remains to display the prompt string literally,
+ the new gl_prompt_style() function can be used to enable text
+ attribute formatting directives in prompt strings, such as
+ underlining, bold font, and highlighting directives.
+
+ Signal handling in gl_get_line() is now customizable. The default
+ signal handling behavior remains essentially the same, except that
+ the SIGTSTP, SIGTTIN and SIGTTOU are now forwarded to the
+ corresponding signal handler of the calling program, instead of
+ causing a SIGSTOP to be sent to the application. It is now possible
+ to remove signals from the list that are trapped by gl_get_line(),
+ as well as add new signals to this list. The signal and terminal
+ environments in which the signal handler of the calling program is
+ invoked, and what gl_get_line() does after the signal handler
+ returns, is now customizable on a per signal basis. You can now also
+ query the last signal that was caught by gl_get_line(). This is
+ useful when gl_get_line() aborts with errno=EINTR, and you need to
+ know which signal caused it to abort.
+
+ Key-sequences bound to action functions can now start with printable
+ characters. Previously only keysequences starting with control or
+ meta characters were permitted.
+
+ gl_get_line() is now 8-bit clean. If the calling program has
+ correctly called setlocale(LC_CTYPE,""), then the user can select an
+ alternate locale by setting the standard LC_CTYPE, LC_ALL, or LANG
+ environment variables, and international characters can then be
+ entered directly, either by using a non-US keyboard, or by using a
+ compose key on a standard US keyboard. Note that in locales in which
+ meta characters become printable, meta characters no longer match
+ M-c bindings, which then have to be entered using their escape-c
+ equivalents. Fortunately most modern terminal emulators either
+ output the escape-c version by default when the meta key is used, or
+ can be configured to do so (see the gl_get_line(3) man page), so in
+ most cases you can continue to use the meta key.
+
+ Completion callback functions can now tell gl_get_line() to return
+ the input line immediately after a successful tab completion, simply
+ by setting the last character of the optional continuation suffix to
+ a newline character (ie. in the call to cpl_add_completion()).
+
+ It is now safe to create and use multiple GetLine objects, albeit
+ still only from a single thread. In conjunction with the new
+ gl_configure_getline() function, this optionally allows multiple
+ GetLine objects with different bindings to be used to implement
+ different input modes.
+
+ The edit-mode configuration command now accepts the argument,
+ none. This tells gl_get_line() to revert to using just the native
+ line editing facilities provided by the terminal driver. This could
+ be used if the termcap or terminfo entry of the host terminal were
+ badly corrupted.
+
+ Application callback functions invoked by gl_get_line() can now
+ change the displayed prompt using the gl_replace_prompt() function.
+
+ Their is now an optional program distributed with the library. This
+ is a beta release of a program which adds tecla command-line editing
+ to virtually any third party application without the application
+ needing to be linked to the library. See the enhance(3) man page for
+ further details. Although built and installed by default, the
+ INSTALL document explains how to prevent this.
+
+ The INSTALL document now explains how you can stop the demo programs
+ from being built and installed.
+
+ NetBSD/termcap fixes. Mike MacFaden reported two problems that he
+ saw when compiling libtecla under NetBSD. Both cases were related to
+ the use of termcap. Most systems use terminfo, so this problem has
+ gone unnoticed until now, and won't have affected the grand majority
+ of users. The configure script had a bug which prevented the check
+ for CPP working properly, and getline.c wouldn't compile due to an
+ undeclared variable when USE_TERMCAP was defined. Both problems have
+ now been fixed. Note that if you successfully compiled version
+ 1.3.3, this problem didn't affect you.
+
+ An unfortunate and undocumented binding of the key-sequence M-O was
+ shadowing the arrow-key bindings on systems that use ^[OA etc. I
+ have removed this binding (the documented lower case M-o binding
+ remains bound). Under the KDE konsole terminal this was causing the
+ arrow keys to do something other than expected.
+
+ There was a bug in the history list code which could result in
+ strange entries appearing at the start of the history list once
+ enough history lines had been added to the list to cause the
+ circular history buffer to wrap. This is now fixed.
+
+Version 1.3.3:
+
+ Signal handling has been re-written, and documentation of its
+ behaviour has been added to the gl_get_line(3) man page. In addition
+ to eliminating race conditions, and appropriately setting errno for
+ those signals that abort gl_get_line(), many more signals are now
+ intercepted, making it less likely that the terminal will be left in
+ raw mode by a signal that isn't trapped by gl_get_line().
+
+ A bug was also fixed that was leaving the terminal in raw mode if
+ the editing mode was changed interactively between vi and emacs.
+ This was only noticeable when running programs from old shells that
+ don't reset terminal modes.
+
+Version 1.3.2:
+
+ Tim Eliseo contributed a number of improvements to vi mode,
+ including a fuller set of vi key-bindings, implementation of the vi
+ constraint that the cursor can't backup past the point at which
+ input mode was entered, and restoration of overwritten characters
+ when backspacing in overwrite mode. There are also now new bindings
+ to allow users to toggle between vi and emacs modes interactively.
+ The terminal bell is now used in some circumstances, such as when an
+ unrecognized key sequence is entered. This can be turned off by the
+ new nobeep option in the tecla configuration file.
+
+ Unrelated to the above, a problem under Linux which prevented ^Q
+ from being used to resume terminal output after the user had pressed
+ ^S, has been fixed.
+
+Version 1.3.1:
+
+ In vi mode a bug was preventing the history-search-backward and
+ history-search-forward actions from doing anything when invoked on
+ empty lines. On empty lines they now act like up-history and
+ down-history respectively, as in emacs mode.
+
+ When creating shared libraries under Linux, the -soname directive
+ was being used incorrectly. The result is that Linux binaries linked
+ with the 1.2.3, 1.2.4 and 1.3.0 versions of the tecla shared
+ libraries, will refuse to see other versions of the shared library
+ until relinked with version 1.3.1 or higher.
+
+ The configure script can now handle the fact that under Solaris-2.6
+ and earlier, the only curses library is a static one that hides in
+ /usr/ccs/lib. Under Linux it now also caters for old versions of GNU
+ ld which don't accept version scripts.
+
+ The demos are now linked against the shared version of the library
+ if possible. Previously they were always linked with the static
+ version.
+
+Version 1.3.0:
+
+ The major change in this release is the addition of an optional vi
+ command-line editing mode in gl_get_line(), along with lots of new
+ action functions to support its bindings. To enable this, first
+ create a ~/.teclarc file if you don't already have one, then add the
+ following line to it.
+
+ edit-mode vi
+
+ The default vi bindings, which are designed to mimic those of the vi
+ editor as closely as possible, are described in the gl_get_line(3)
+ man page.
+
+ A new convenience function called ef_list_expansions() has been
+ added for listing filename expansions. See the ef_list_expansions(3)
+ man page for details. This is used in a new list-glob binding, bound
+ to ^Xg in emacs mode, and ^G in vi input mode.
+
+ A bug has been fixed in the key-binding table expansion code. This
+ bug would have caused problems to anybody who defined more than
+ about 18 personalized key-bindings in their ~/.teclarc file.
+
+Version 1.2.4:
+
+ Buffered I/O is now used for writing to terminals, and where
+ supported, cursor motion is done with move-n-positions terminfo
+ capabilities instead of doing lots of move-1-position requests. This
+ greatly improves how the library feels over slow links.
+
+ You can now optionally compile different architectures in different
+ directories, without having to make multiple copies of the
+ distribution. This is documented in the INSTALL file.
+
+ The ksh ~+ directive is now supported.
+
+ Thanks to Markus Gyger for the above improvements.
+
+ Documentation has been added to the INSTALL file describing features
+ designed to facilitate configuration and installation of the library
+ as part of larger packages. These features are intended to remove
+ the need to modify the tecla distribution's configuration and build
+ procedures when embedding the libtecla distribution in other package
+ distributions.
+
+ A previous fix to stop the cursor from warping when the last
+ character of the input line was in the last column of the terminal,
+ was only being used for the first terminal line of the input line.
+ It is now used for all subsequent lines as well, as originally
+ intended.
+
+Version 1.2.3:
+
+ The installation procedure has been better automated with the
+ addition of an autoconf configure script. This means that installers
+ can now compile and install the library by typing:
+
+ ./configure
+ make
+ make install
+
+ On all systems this makes at least the normal static version of the
+ tecla library. It also makes the reentrant version if reentrant
+ POSIX functions are detected. Under Solaris, Linux and HP-UX the
+ configuration script arranges for shared libraries to be compiled in
+ addition to the static libraries. It is hoped that installers will
+ return information about how to compile shared libraries on other
+ systems, for inclusion in future releases, and to this end, a new
+ PORTING guide has been provided.
+
+ The versioning number scheme has been changed. This release would
+ have been 1.2c, but instead will be refered to as 1.2.3. The
+ versioning scheme, based on conventions used by Sun Microsystems, is
+ described in configure.in.
+
+ The library was also tested under HP-UX, and this revealed two
+ serious bugs, both of which have now been fixed.
+
+ The first bug prevented the library from writing control codes to
+ terminals on big-endian machines, with the exception of those
+ running under Solaris. This was due to an int variable being used
+ where a char was needed.
+
+ The second bug had the symptom that on systems that don't use the
+ newline character as the control code for moving the cursor down a
+ line, a newline wasn't started when the user hit enter.
+
+Version 1.2b:
+
+ Two more minor bug fixes:
+
+ Many terminals don't wrap the cursor to the next line when a
+ character is written to the rightmost terminal column. Instead, they
+ delay starting a new line until one more character is written, at
+ which point they move the cursor two positions. gl_get_line()
+ wasn't aware of this, so cursor repositionings just after writing
+ the last character of a column, caused it to erroneously go up a
+ line. This has now been remedied, using a method that should work
+ regardless of whether a terminal exhibits this behavior or not.
+
+ Some systems dynamically record the current terminal dimensions in
+ environment variables called LINES and COLUMNS. On such systems,
+ during the initial terminal setup, these values should override the
+ static values read from the terminal information databases, and now
+ do. Previously they were only used if the dimensions returned by
+ terminfo/termcap looked bogus.
+
+Version 1.2a:
+
+ This minor release fixes the following two bugs:
+
+ The initial terminal size and subsequent changes thereto, weren't
+ being noticed by gl_get_line(). This was because the test for the
+ existence of TIOCWINSZ was erroneously placed before the inclusion
+ of termios.h. One of the results was that on input lines that
+ spanned more than one terminal line, the cursor occasionally jumped
+ unexpectedly to the previous terminal line.
+
+ On entering a line that wrapped over multiple terminal lines,
+ gl_get_line() simply output a carriage-return line-feed at the point
+ at which the user pressed return. Thus if one typed in such a line,
+ then moved back onto one of the earlier terminal lines before
+ hitting return, the cursor was left on a line containing part of the
+ line that had just been entered. This didn't do any harm, but it
+ looked a mess.
+
+Version 1.2:
+
+ A new facility for looking up and completing filenames in UNIX-style
+ paths has now been added (eg. you can search for, or complete
+ commands using the UNIX PATH environment variable). See the
+ pca_lookup_file(3) man page.
+
+ The already existing filename completion callback can now be made
+ selective in what types of files it lists. See the
+ cpl_complete_word(3) man page.
+
+ Due to its potential to break applications when changed, the use of
+ the publically defined CplFileArgs structure to configure the
+ cpl_file_completions() callback is now deprecated. The definition
+ of this structure has been frozen, and its documentation has been
+ removed from the man pages. It will remain supported, but if you
+ have used it, you are recommended to switch to the new method, which
+ involves a new opaque configuration object, allocated via a provided
+ constructor function, configured via accessor functions, and
+ eventually deleted with a provided destructor function. The
+ cpl_file_completions() callback distinguishes which structure type
+ it has been sent by virtue of a code placed at the start of the new
+ structure by the constructor. It is assumed that no existing
+ applications set the boolean 'escaped' member of the CplFileArgs
+ structure to 4568. The new method is documented in the
+ cpl_complete_word(3) man page.
+
+Version 1.1j
+
+ This was the initial public release on freshmeat.org.
diff --git a/libtecla-1.4.1/config.guess b/libtecla-1.4.1/config.guess
new file mode 100644
index 0000000..0ce538b
--- /dev/null
+++ b/libtecla-1.4.1/config.guess
@@ -0,0 +1,1183 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner .
+# Please send patches to .
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# Use $HOST_CC if defined. $CC may point to a cross-compiler
+if test x"$CC_FOR_BUILD" = x; then
+ if test x"$HOST_CC" != x; then
+ CC_FOR_BUILD="$HOST_CC"
+ else
+ if test x"$CC" != x; then
+ CC_FOR_BUILD="$CC"
+ else
+ CC_FOR_BUILD=cc
+ fi
+ fi
+fi
+
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # Netbsd (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ # Determine the machine/vendor (is the vendor relevant).
+ case "${UNAME_MACHINE}" in
+ amiga) machine=m68k-cbm ;;
+ arm32) machine=arm-unknown ;;
+ atari*) machine=m68k-atari ;;
+ sun3*) machine=m68k-sun ;;
+ mac68k) machine=m68k-apple ;;
+ macppc) machine=powerpc-apple ;;
+ hp3[0-9][05]) machine=m68k-hp ;;
+ ibmrt|romp-ibm) machine=romp-ibm ;;
+ *) machine=${UNAME_MACHINE}-unknown ;;
+ esac
+ # The Operating System including object format.
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ # The OS release
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ cat <$dummy.s
+ .data
+\$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ esac
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-cbm-sysv4
+ exit 0;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i?86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ sed 's/^ //' << EOF >$dummy.c
+ #include
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:4)
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=4.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include
+ #include
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+ rm -f $dummy.c $dummy
+ esac
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ sed 's/^ //' << EOF >$dummy.c
+ #include
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i?86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*X-MP:*:*:*)
+ echo xmp-cray-unicos
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY-2:*:*:*)
+ echo cray2-cray-unicos
+ exit 0 ;;
+ F300:UNIX_System_V:*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ F301:UNIX_System_V:*:*)
+ echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ *:Linux:*:*)
+
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ ld_help_string=`cd /; ld --help 2>&1`
+ ld_supported_emulations=`echo $ld_help_string \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ *ia64)
+ echo "${UNAME_MACHINE}-unknown-linux"
+ exit 0
+ ;;
+ i?86linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0
+ ;;
+ elf_i?86)
+ echo "${UNAME_MACHINE}-pc-linux"
+ exit 0
+ ;;
+ i?86coff)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0
+ ;;
+ sparclinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ armlinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32arm*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+ exit 0
+ ;;
+ armelf_linux*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ m68klinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32ppc | elf32ppclinux)
+ # Determine Lib Version
+ cat >$dummy.c <
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unkown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.c $dummy
+ echo powerpc-unknown-linux-gnu${LIBC}
+ exit 0
+ ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ cat <$dummy.s
+ .data
+ \$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+ main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ esac
+
+ objdump --private-headers $dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >$dummy.c < /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ elif test "${UNAME_MACHINE}" = "s390"; then
+ echo s390-ibm-linux && exit 0
+ else
+ # Either a pre-BFD a.out linker (linux-gnuoldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
+ test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ cat >$dummy.c <
+#ifdef __cplusplus
+#include /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+ printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+ i?86:DYNIX/ptx:4*:*)
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i?86:*:5:7*)
+ # Fixed at (any) Pentium or better
+ UNAME_MACHINE=i586
+ if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+ echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ i?86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ i?86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes .
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:*:6*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ if test "${UNAME_MACHINE}" = "x86pc"; then
+ UNAME_MACHINE=pc
+ fi
+ echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-W:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >$dummy.c <
+# include
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+ printf ("vax-dec-bsd\n"); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/libtecla-1.4.1/config.sub b/libtecla-1.4.1/config.sub
new file mode 100644
index 0000000..c8e7785
--- /dev/null
+++ b/libtecla-1.4.1/config.sub
@@ -0,0 +1,1268 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+#
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner .
+# Please send patches to .
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+if [ x$1 = x ]
+then
+ echo Configuration name missing. 1>&2
+ echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
+ echo "or $0 ALIAS" 1>&2
+ echo where ALIAS is a recognized configuration type. 1>&2
+ exit 1
+fi
+
+# First pass through any local machine types.
+case $1 in
+ *local*)
+ echo $1
+ exit 0
+ ;;
+ *)
+ ;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 \
+ | x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | hppa64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+ | alphaev6[78] \
+ | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+ | mips64vr5000 | miprs64vr5000el | mcore \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+ | thumb | d10v | fr30 | avr)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i[34567]86)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+ | xmp-* | ymp-* \
+ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+ | hppa2.0n-* | hppa64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+ | alphaev6[78]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+ | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
+ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+ | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+ | bs2000-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-cbm
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-cbm
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-cbm
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ cray2)
+ basic_machine=cray2-cray
+ os=-unicos
+ ;;
+ [ctj]90-cray)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i[34567]86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i[34567]86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i[34567]86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i[34567]86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ i386-go32 | go32)
+ basic_machine=i386-unknown
+ os=-go32
+ ;;
+ i386-mingw32 | mingw32)
+ basic_machine=i386-unknown
+ os=-mingw32
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux-gnu
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux-gnu
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos)
+ basic_machine=i386-unknown
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexen-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=rs6000-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=t3e-cray
+ os=-unicos
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xmp)
+ basic_machine=xmp-cray
+ os=-unicos
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ mips)
+ if [ x$os = x-linux-gnu ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sparc | sparcv9)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i[34567]86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -*MiNT)
+ os=-mint
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f301-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -*MiNT)
+ vendor=atari
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
diff --git a/libtecla-1.4.1/configure b/libtecla-1.4.1/configure
new file mode 100755
index 0000000..feaa587
--- /dev/null
+++ b/libtecla-1.4.1/configure
@@ -0,0 +1,1939 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=getline.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+MAJOR_VER="1"
+
+
+
+MINOR_VER="4"
+
+
+
+MICRO_VER="1"
+
+
+CFLAGS="$CFLAGS"
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:543: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:573: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:624: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:656: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 667 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:698: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:703: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:731: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:765: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:794: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+for ac_prog in gawk mawk nawk awk
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:821: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AWK="$ac_prog"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+AWK="$ac_cv_prog_AWK"
+if test -n "$AWK"; then
+ echo "$ac_t""$AWK" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+test -n "$AWK" && break
+done
+
+
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:855: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_RANLIB="ranlib"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+ echo "$ac_t""$RANLIB" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:931: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:952: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:970: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+
+
+case $target in
+*-sun-solaris2.[0-6]|*-sun-solaris2.[0-6].*)
+ LIBS="$LIBS -L/usr/ccs/lib"
+ ;;
+esac
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:1002: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1040: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1057: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for tigetstr in -lcurses""... $ac_c" 1>&6
+echo "configure:1082: checking for tigetstr in -lcurses" >&5
+ac_lib_var=`echo curses'_'tigetstr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lcurses $LIBS"
+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+
+ cat >> confdefs.h <<\EOF
+#define USE_TERMINFO 1
+EOF
+
+ LIBS="$LIBS -lcurses"
+
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for tigetstr in -lncurses""... $ac_c" 1>&6
+echo "configure:1126: checking for tigetstr in -lncurses" >&5
+ac_lib_var=`echo ncurses'_'tigetstr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lncurses $LIBS"
+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+
+ cat >> confdefs.h <<\EOF
+#define USE_TERMINFO 1
+EOF
+
+ LIBS="$LIBS -lncurses"
+
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for tgetstr in -lcurses""... $ac_c" 1>&6
+echo "configure:1170: checking for tgetstr in -lcurses" >&5
+ac_lib_var=`echo curses'_'tgetstr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lcurses $LIBS"
+cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+
+ cat >> confdefs.h <<\EOF
+#define USE_TERMCAP 1
+EOF
+
+ LIBS="$LIBS -lcurses"
+ ac_safe=`echo "termcap.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for termcap.h""... $ac_c" 1>&6
+echo "configure:1212: checking for termcap.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_TERMCAP_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+fi
+
+
+
+ac_safe=`echo "term.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for term.h""... $ac_c" 1>&6
+echo "configure:1259: checking for term.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1269: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_TERM_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+
+ ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
+echo "configure:1294: checking for ncurses/term.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1304: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_NCURSES_TERM_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
+
+
+ac_safe=`echo "curses.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for curses.h""... $ac_c" 1>&6
+echo "configure:1335: checking for curses.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1345: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_CURSES_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+
+ ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
+echo "configure:1370: checking for ncurses/curses.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1380: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_NCURSES_CURSES_H 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
+
+
+
+TARGETS="normal reentrant"
+
+
+echo $ac_n "checking for reentrant functions""... $ac_c" 1>&6
+echo "configure:1414: checking for reentrant functions" >&5
+if eval "test \"`echo '$''{'tecla_cv_reentrant'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ KEPT_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199506L"
+ cat > conftest.$ac_ext <
+#include
+#include
+#include
+#include
+
+int main() {
+
+ (void) readdir_r(NULL, NULL, NULL);
+ (void) getpwuid_r(geteuid(), NULL, NULL, 0, NULL);
+ (void) getpwnam_r(NULL, NULL, NULL, 0, NULL);
+
+; return 0; }
+EOF
+if { (eval echo configure:1439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ tecla_cv_reentrant=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ tecla_cv_reentrant=no
+fi
+rm -f conftest*
+ CFLAGS="$KEPT_CFLAGS"
+
+fi
+
+echo "$ac_t""$tecla_cv_reentrant" 1>&6
+
+
+if test $tecla_cv_reentrant = no; then
+ TARGETS="normal"
+fi
+
+
+echo $ac_n "checking for select system call""... $ac_c" 1>&6
+echo "configure:1462: checking for select system call" >&5
+if eval "test \"`echo '$''{'tecla_cv_select'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <
+#endif
+#include
+#include
+#include
+
+int main() {
+
+ fd_set fds;
+ int nready;
+ FD_ZERO(&fds);
+ FD_SET(1, &fds);
+ nready = select(2, &fds, &fds, &fds, NULL);
+
+; return 0; }
+EOF
+if { (eval echo configure:1488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ tecla_cv_select=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ tecla_cv_select=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$tecla_cv_select" 1>&6
+
+
+if test $tecla_cv_select = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SELECT 1
+EOF
+
+fi
+
+
+echo $ac_n "checking for SysV pseudo-terminals""... $ac_c" 1>&6
+echo "configure:1513: checking for SysV pseudo-terminals" >&5
+if eval "test \"`echo '$''{'tecla_cv_sysv_pty'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <
+#include
+#include
+
+int main() {
+
+ char *name = ptsname(0);
+ int i1 = grantpt(0);
+ int i2 = unlockpt(0);
+ int i3 = ioctl(0, I_PUSH, "ptem");
+ return 0;
+
+; return 0; }
+EOF
+if { (eval echo configure:1536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ tecla_cv_sysv_pty=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ tecla_cv_sysv_pty=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$tecla_cv_sysv_pty" 1>&6
+
+
+if test $tecla_cv_sysv_pty = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYSV_PTY 1
+EOF
+
+fi
+
+
+
+SHARED_EXT=""
+
+
+
+SHARED_ALT=""
+
+
+
+SHARED_CFLAGS=""
+
+
+
+LINK_SHARED=""
+
+
+case $target in
+*solaris*)
+ cat >> confdefs.h <<\EOF
+#define __EXTENSIONS__ 1
+EOF
+
+ SHARED_EXT=".so.${MAJOR_VER}"
+ SHARED_ALT=".so"
+ LINK_SHARED='ld -G -M $$(srcdir)/libtecla.map -o $$@ -h $$(@F) -z defs -i $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="-Kpic"
+ case $CC in
+ */cc|cc) SHARED_CFLAGS="$SHARED_CFLAGS -xstrconst" ;;
+ gcc) CFLAGS="-I/usr/include $CFLAGS" ;;
+ esac
+ case $target in
+ *sparc*) SHARED_CFLAGS="$SHARED_CFLAGS -xregs=no%appl"
+ esac
+ ;;
+*linux*)
+ SHARED_EXT=".so.${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}"
+ SHARED_ALT=".so .so.${MAJOR_VER}"
+
+
+ echo $ac_n "checking for --version-script in GNU ld""... $ac_c" 1>&6
+echo "configure:1600: checking for --version-script in GNU ld" >&5
+if eval "test \"`echo '$''{'tecla_cv_gnu_ld_script'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ if (echo 'void dummy(void) {return;}' > dummy.c; $CC -c -fpic dummy.c; \
+ ld -o dummy.so dummy.o -shared --version-script=$srcdir/libtecla.map) 1>&2 2>/dev/null; then
+ tecla_cv_gnu_ld_script=yes
+ else
+ tecla_cv_gnu_ld_script=no
+ fi
+ rm -f dummy.c dummy.o dummy.so
+
+fi
+
+echo "$ac_t""$tecla_cv_gnu_ld_script" 1>&6
+ if test $tecla_cv_gnu_ld_script = yes; then
+ VERSION_OPT='--version-script=$$(srcdir)/libtecla.map'
+ else
+ VERSION_OPT=''
+ fi
+
+ LINK_SHARED='ld -o $$@ -soname libtecla$$(SUFFIX).so.'${MAJOR_VER}' -shared '$VERSION_OPT' $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="-fpic"
+ ;;
+*hpux*)
+ SHARED_EXT=".${MAJOR_VER}"
+ SHARED_ALT=".sl"
+ LINK_SHARED='ld -b +h $$(@F) +k +vshlibunsats -o $$@ -c libtecla.map.opt $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="+z"
+ ;;
+*dec-osf*)
+ cat >> confdefs.h <<\EOF
+#define _OSF_SOURCE 1
+EOF
+
+ ;;
+esac
+
+
+if test "$GCC"_ = "yes"_ && test "$LINK_SHARED"_ != "_" ; then
+ SHARED_CFLAGS="-fpic"
+ case $target_os in
+ sparc*solaris*) SHARED_CFLAGS="$SHARED_CFLAGS -mno-app-regs"
+ esac
+ LINK_SHARED="$LINK_SHARED `gcc -print-libgcc-file-name`"
+fi
+
+
+
+
+
+if test "$LINK_SHARED"_ != "_"; then
+ TARGET_LIBS="static shared"
+else
+ TARGET_LIBS="static"
+ LINK_SHARED="@:"
+fi
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS </dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@MAJOR_VER@%$MAJOR_VER%g
+s%@MINOR_VER@%$MINOR_VER%g
+s%@MICRO_VER@%$MICRO_VER%g
+s%@CC@%$CC%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@LN_S@%$LN_S%g
+s%@AWK@%$AWK%g
+s%@RANLIB@%$RANLIB%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@CPP@%$CPP%g
+s%@TARGETS@%$TARGETS%g
+s%@SHARED_EXT@%$SHARED_EXT%g
+s%@SHARED_ALT@%$SHARED_ALT%g
+s%@SHARED_CFLAGS@%$SHARED_CFLAGS%g
+s%@LINK_SHARED@%$LINK_SHARED%g
+s%@TARGET_LIBS@%$TARGET_LIBS%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/libtecla-1.4.1/configure.in b/libtecla-1.4.1/configure.in
new file mode 100644
index 0000000..3b083b9
--- /dev/null
+++ b/libtecla-1.4.1/configure.in
@@ -0,0 +1,412 @@
+dnl This is the input file which autoconf uses to construct a
+dnl "configure" script for the tecla library. It is a bourne shell
+dnl script which autoconf pre-processes with the m4 preprocessor to
+dnl expand autoconf-defined m4 macros such as AC_INIT(). The
+dnl following line just initializes autoconf. Autoconf interprets the
+dnl single argument as the name of an arbitrary file, which it uses to
+dnl ensure that it is being run correctly from the directory which
+dnl contains the libtecla source code.
+
+AC_INIT(getline.c)
+
+dnl Here we set the major version number of the tecla library.
+dnl Incrementing this number implies that a change has been made to
+dnl the library's public interface, which makes it binary incompatible
+dnl with programs that were linked with previous shared versions of
+dnl the tecla library. Incompatible changes of this type should be
+dnl avoided at all costs, so it is hoped that the major version number
+dnl won't ever have to change. The major version number must be a
+dnl small integer number, preferably a single numeric digit.
+
+AC_SUBST(MAJOR_VER)
+MAJOR_VER="1"
+
+dnl Set the minor version number of the tecla library. This number
+dnl should be incremented by one whenever additional functionality,
+dnl such as new functions or modules, are added to the library. The
+dnl idea is that a program that was linked with a shared library of
+dnl the same major version number, but a lower minor version number,
+dnl will continue to function when the run-time loader links it
+dnl against the updated version. The minor version number must be a
+dnl small integer number, which should be reset to 0 whenever the
+dnl major version number is incremented.
+
+AC_SUBST(MINOR_VER)
+MINOR_VER="4"
+
+dnl Set the micro version number of the tecla library. This is
+dnl incremented whenever modifications to the library are made which
+dnl make no changes to the public interface, but which fix bugs and/or
+dnl improve the behind-the-scenes implementation. The micro version
+dnl number should be reset to 0 whenever the minor version number is
+dnl incremented. The micro version number must be a small integer
+dnl number.
+
+AC_SUBST(MICRO_VER)
+MICRO_VER="1"
+
+dnl The AC_PROG_CC line looks for a C compiler, and if gcc is chosen,
+dnl sets the $GCC shell variable to "yes". Make sure that CFLAGS is
+dnl set to something first, to prevent AC_PROG_CC from substituting -g
+dnl for the optimization level.
+
+CFLAGS="$CFLAGS"
+AC_PROG_CC
+
+dnl Apparently not all implementations of the 'make' command define
+dnl the MAKE variable. The following directive creates a variable
+dnl called SET_MAKE which when expanded in a makefile is either empty
+dnl if the local 'make' command was found to define the MAKE variable,
+dnl or contains an assignment which will give the MAKE variable the
+dnl value 'make'.
+
+AC_PROG_MAKE_SET
+
+dnl The following directive causes autoconf to see if symbolic links
+dnl are supported on the current filesystem. If so, it sets the
+dnl variable LN_S to "ln -s". Otherwise it sets LN_S to just "ln".
+dnl This allows us to create symbolic links where possible, but falls
+dnl back to creating hard links where symbolic links aren't available.
+
+AC_PROG_LN_S
+
+dnl The following macro searches for the best implementation of awk
+dnl on the host system, and records it in the AWK shell variable.
+
+AC_PROG_AWK
+
+dnl If ranlib is needed on the target system, the RANLIB make variable
+dnl is set to ranlib. Otherwise it is set to :, which is the do-nothing
+dnl command of the bourne shell.
+
+AC_PROG_RANLIB
+
+dnl The following directive tells autoconf to figure out the target
+dnl system type and assign a canonical name for this to the $target
+dnl shell variable. This is used below in the target-specific case
+dnl statement.
+
+AC_CANONICAL_SYSTEM
+
+dnl In early versions of Solaris, some libraries are in /usr/ccs/lib,
+dnl where gcc doesn't look. The tests below for the curses library
+dnl would thus fail without this directory being added to the search
+dnl path. We thus add it here before the tests. Note that in the
+dnl following, since [ and ] are m4 quotes, and m4 will remove the
+dnl outermost quotes when it processes this file, we have to double
+dnl them up here to get [0-6] to appear in the output configure
+dnl script.
+
+case $target in
+*-sun-solaris2.[[0-6]]|*-sun-solaris2.[[0-6]].*)
+ LIBS="$LIBS -L/usr/ccs/lib"
+ ;;
+esac
+
+dnl The following lines look for terminfo functions in the normal
+dnl curses library. If not found, they are searched for in the GNU
+dnl ncurses library. If the terminfo functions still aren't found,
+dnl then termcap functions are searched for in the curses library. If
+dnl either set of functions is found, the corresponding variable
+dnl USE_TERMINFO or USE_TERMCAP is arranged to be defined in CFLAGS,
+dnl via the exported DEFINES shell variable, and the library in which
+dnl they were found is appended to the LIBS shell variable.
+
+AC_CHECK_LIB(curses, tigetstr, [
+ AC_DEFINE(USE_TERMINFO)
+ LIBS="$LIBS -lcurses"
+], [AC_CHECK_LIB(ncurses, tigetstr, [
+ AC_DEFINE(USE_TERMINFO)
+ LIBS="$LIBS -lncurses"
+], [AC_CHECK_LIB(curses, tgetstr, [
+ AC_DEFINE(USE_TERMCAP)
+ LIBS="$LIBS -lcurses"
+ AC_CHECK_HEADER(termcap.h, AC_DEFINE(HAVE_TERMCAP_H))
+])])])
+
+dnl Some systems don't have term.h, some systems squirrel it away
+dnl in an ncurses sub-directory of the system include directory.
+dnl If term.h exists in the normal location, arrange for HAVE_TERM_H
+dnl to be added to CFLAGS in the Makefile, by appending it to the
+dnl DEFINES shell variable. Otherwise, if it exists under an ncurses
+dnl sub-directory, arrange for HAVE_NCURSES_TERM_H to be set instead.
+dnl If it isn't found in either of these places, neither of these
+dnl variables is set, so term.h just doesn't get included.
+
+AC_CHECK_HEADER(term.h, AC_DEFINE(HAVE_TERM_H), [
+ AC_CHECK_HEADER(ncurses/term.h, AC_DEFINE(HAVE_NCURSES_TERM_H))
+])
+
+dnl Do the same search for curses.h.
+
+AC_CHECK_HEADER(curses.h, AC_DEFINE(HAVE_CURSES_H), [
+ AC_CHECK_HEADER(ncurses/curses.h, AC_DEFINE(HAVE_NCURSES_CURSES_H))
+])
+
+dnl The following variable lists the targets that will be created if
+dnl the user runs make without any arguments. Initially we assume
+dnl that we can create both the normal and the reentrant versions
+dnl of the library.
+
+AC_SUBST(TARGETS)
+TARGETS="normal reentrant"
+
+dnl Check for reentrant functions by attempting to compile and link a
+dnl temporary program which calls them, being sure to include the
+dnl appropriate headers and define _POSIX_C_SOURCE, just in case any
+dnl of the functions are defined as macros. In the following,
+dnl AC_CACHE_CHECK outputs the message "checking for reentrant
+dnl functions". If this check has been done before, it assigns the
+dnl cached yes/no value to tecla_cv_reentrant. Otherwise it uses
+dnl AC_TRY_LINK() to attempt to compile and link the specified dummy
+dnl program, and sets tecla_cv_reentrant to yes or no, depending on
+dnl whether this succeeds. Finally it caches the value of
+dnl tecla_cv_reentrant in the file config.cache, and writes "yes" or
+dnl "no" to the terminal.
+
+AC_CACHE_CHECK(for reentrant functions, tecla_cv_reentrant, [
+ KEPT_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199506L"
+ AC_TRY_LINK([
+#include
+#include
+#include
+#include
+#include
+ ], [
+ (void) readdir_r(NULL, NULL, NULL);
+ (void) getpwuid_r(geteuid(), NULL, NULL, 0, NULL);
+ (void) getpwnam_r(NULL, NULL, NULL, 0, NULL);
+ ], tecla_cv_reentrant=yes, tecla_cv_reentrant=no)
+ CFLAGS="$KEPT_CFLAGS"
+])
+
+dnl If the necessary reentrant functions weren't found to be
+dnl available, default to only compiling the non-reentrant version of
+dnl the library.
+
+if test $tecla_cv_reentrant = no; then
+ TARGETS="normal"
+fi
+
+dnl Check for the select system call with the normal arguments,
+dnl by attempting to compile and link a temporary program which
+dnl calls it, being sure to include the appropriate headers.
+dnl In the following, AC_CACHE_CHECK outputs the message
+dnl "checking for select system call". If this check has been done
+dnl before, it assigns the cached yes/no value to tecla_cv_select.
+dnl Otherwise it uses AC_TRY_LINK() to attempt to compile and link
+dnl the specified dummy program, and sets tecla_cv_select to yes
+dnl or no, depending on whether this succeeds. Finally it caches
+dnl the value of tecla_cv_select in the file config.cache, and
+dnl writes "yes" or "no" to the terminal.
+
+AC_CACHE_CHECK(for select system call, tecla_cv_select, [
+ AC_TRY_LINK([
+#ifdef HAVE_SELECT_H
+#include
+#endif
+#include
+#include
+#include
+ ], [
+ fd_set fds;
+ int nready;
+ FD_ZERO(&fds);
+ FD_SET(1, &fds);
+ nready = select(2, &fds, &fds, &fds, NULL);
+ ], tecla_cv_select=yes, tecla_cv_select=no)
+])
+
+dnl If the select function was available, arrange for HAVE_SELECT to
+dnl be defined by CFLAGS.
+
+if test $tecla_cv_select = yes; then
+ AC_DEFINE(HAVE_SELECT)
+fi
+
+dnl Check if this system supports the system V pseudo terminal interface.
+
+AC_CACHE_CHECK(for SysV pseudo-terminals, tecla_cv_sysv_pty, [
+ AC_TRY_LINK([
+#include
+#include
+#include
+ ], [
+ char *name = ptsname(0);
+ int i1 = grantpt(0);
+ int i2 = unlockpt(0);
+ int i3 = ioctl(0, I_PUSH, "ptem");
+ return 0;
+ ], tecla_cv_sysv_pty=yes, tecla_cv_sysv_pty=no)
+])
+
+dnl If the system-V pseudo-terminal interface is available, arrange
+dnl for HAVE_SYSV_PTY to be defined by CFLAGS.
+
+if test $tecla_cv_sysv_pty = yes; then
+ AC_DEFINE(HAVE_SYSV_PTY)
+fi
+
+dnl The following variable contains the extension to append to
+dnl "libtecla" and "libtecla_r" when creating shared libraries on the
+dnl target platform. This is system dependent and is ignored if
+dnl LINK_SHARED remains an empty string. On most platforms that
+dnl support shared libaries, this will be .so.$MAJOR_VER, where
+dnl MAJOR_VER is the major version number described above, which on
+dnl some systems, tells the run-time loader if the program being
+dnl loaded is binary compatible with a given version of the library
+dnl (see the discussion of MAJOR_VER near the top of this file).
+dnl The following empty default can be overriden on a system by system
+dnl basis later in this file.
+
+AC_SUBST(SHARED_EXT)
+SHARED_EXT=""
+
+dnl When a shared library is installed with the extension $SHARED_EXT,
+dnl you can optionally produce other copies of this library with
+dnl different extensions. This is done using symbolic or hard links,
+dnl depending on what is available on the current filesystem, and the
+dnl extensions to use for these links are listed in the following
+dnl variable, separated by spaces. The following empty default can be
+dnl overriden on a system by system basis later in this file.
+
+AC_SUBST(SHARED_ALT)
+SHARED_ALT=""
+
+dnl The following variable lists extra compilation flags needed to
+dnl create object files that can be included in shared libraries.
+dnl Normally one would include a flag to tell the C compiler to
+dnl compile position-independent code. This option commonly includes
+dnl the acronym 'pic'.
+
+AC_SUBST(SHARED_CFLAGS)
+SHARED_CFLAGS=""
+
+dnl On systems that support shared libraries, the following variable
+dnl provides the command needed to make a shared library. In this
+dnl variable, $$@ will be replaced with the name of the shared
+dnl library, $$(LIB_OBJECTS) will be replaced with a space separated
+dnl list of the object files that are to be included in the library,
+dnl and libtecla$$(SUFFIX) will be the name of the library being
+dnl built, minus the system-specific extension (eg. libtecla or
+dnl libtecla_r). If LINK_SHARED is left as an empty string, shared
+dnl library creation will not attempted. If your system supports
+dnl shared library creation, you should override the default value of
+dnl this variable in the target-specific case statement later in this
+dnl file.
+
+AC_SUBST(LINK_SHARED)
+LINK_SHARED=""
+
+dnl The following bourne shell case statement is where system
+dnl dependencies can be added. In particular, if your system supports
+dnl shared library creation, the following switch is the place to
+dnl configure it. To do so you will first need to find out what target
+dnl type was just assigned by the AC_CANONICAL_SYSTEM macro executed
+dnl previously. The target type of your current system can be
+dnl determined by cd'ing to the top level directory of the tecla
+dnl distribution, and typing the command "sh config.guess". This will
+dnl report what autoconf thinks the system type is. Note that this
+dnl will be very specific, so if you know that the configuration
+dnl parameters that you are about to provide apply to different
+dnl versions of the current system type, you can express this in the
+dnl case statement by using a wild-card in place of the version
+dnl number, or by using an | alternation to list one or more version
+dnl names. Beware that autoconf uses [] as quote characters, so if you
+dnl want to use a regexp character range like [a-z], you should write
+dnl this as [[a-z]].
+
+case $target in
+*solaris*)
+ AC_DEFINE(__EXTENSIONS__)
+ SHARED_EXT=".so.${MAJOR_VER}"
+ SHARED_ALT=".so"
+ LINK_SHARED='ld -G -M $$(srcdir)/libtecla.map -o $$@ -h $$(@F) -z defs -i $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="-Kpic"
+ case $CC in
+ */cc|cc) SHARED_CFLAGS="$SHARED_CFLAGS -xstrconst" ;;
+ gcc) CFLAGS="-I/usr/include $CFLAGS" ;;
+ esac
+ case $target in
+ *sparc*) SHARED_CFLAGS="$SHARED_CFLAGS -xregs=no%appl"
+ esac
+ ;;
+*linux*)
+ SHARED_EXT=".so.${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}"
+ SHARED_ALT=".so .so.${MAJOR_VER}"
+
+dnl See if the installed version of Gnu ld accepts version scripts.
+
+ AC_CACHE_CHECK([for --version-script in GNU ld], tecla_cv_gnu_ld_script, [
+ if (echo 'void dummy(void) {return;}' > dummy.c; $CC -c -fpic dummy.c; \
+ ld -o dummy.so dummy.o -shared --version-script=$srcdir/libtecla.map) 1>&2 2>/dev/null; then
+ tecla_cv_gnu_ld_script=yes
+ else
+ tecla_cv_gnu_ld_script=no
+ fi
+ rm -f dummy.c dummy.o dummy.so
+ ])
+ if test $tecla_cv_gnu_ld_script = yes; then
+ VERSION_OPT='--version-script=$$(srcdir)/libtecla.map'
+ else
+ VERSION_OPT=''
+ fi
+
+ LINK_SHARED='ld -o $$@ -soname libtecla$$(SUFFIX).so.'${MAJOR_VER}' -shared '$VERSION_OPT' $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="-fpic"
+ ;;
+*hpux*)
+ SHARED_EXT=".${MAJOR_VER}"
+ SHARED_ALT=".sl"
+ LINK_SHARED='ld -b +h $$(@F) +k +vshlibunsats -o $$@ -c libtecla.map.opt $$(LIB_OBJECTS) $$(LIBS) -lc'
+ SHARED_CFLAGS="+z"
+ ;;
+*dec-osf*)
+ AC_DEFINE(_OSF_SOURCE)
+ ;;
+esac
+
+dnl The following statement checks to see if the GNU C compiler has
+dnl been chosen instead of the normal compiler of the host operating
+dnl system. If it has, and shared library creation has been
+dnl configured, it replaces the shared-library-specific C compilation
+dnl flags with those supported by gcc. Also append the gcc run-time
+dnl library to the shared library link line.
+
+if test "$GCC"_ = "yes"_ && test "$LINK_SHARED"_ != "_" ; then
+ SHARED_CFLAGS="-fpic"
+ case $target_os in
+ sparc*solaris*) SHARED_CFLAGS="$SHARED_CFLAGS -mno-app-regs"
+ esac
+ LINK_SHARED="$LINK_SHARED `gcc -print-libgcc-file-name`"
+fi
+
+dnl The following variable will list which types of libraries,
+dnl "static", and possibly "shared", are to be created and installed.
+
+AC_SUBST(TARGET_LIBS)
+
+dnl If shared library creation has been configured, add shared
+dnl libraries to the list of libraries to be built.
+
+if test "$LINK_SHARED"_ != "_"; then
+ TARGET_LIBS="static shared"
+else
+ TARGET_LIBS="static"
+ LINK_SHARED="@:"
+fi
+
+dnl The following directive must always be the last line of any
+dnl autoconf script. It causes autoconf to create the configure
+dnl script, which for each argument of AC_OUTPUT, will look for a
+dnl filename formed by appending ".in" to the argument, preprocess
+dnl that file, replacing @VAR@ directives with the corresponding value
+dnl of the specified shell variable VAR, as set above in this file,
+dnl and write the resulting output to the filename given in the
+dnl argument. Note that only shell variables that were exported above
+dnl with the AC_SUBST() directive will be substituted in @VAR@
+dnl directives (some macros like AC_PROG_CC also call AC_SUBST for you
+dnl for the variables that they output).
+
+AC_OUTPUT(Makefile)
diff --git a/libtecla-1.4.1/cplfile.c b/libtecla-1.4.1/cplfile.c
new file mode 100644
index 0000000..73eef1d
--- /dev/null
+++ b/libtecla-1.4.1/cplfile.c
@@ -0,0 +1,874 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * Standard includes.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Local includes.
+ */
+#include "libtecla.h"
+#include "direader.h"
+#include "homedir.h"
+#include "pathutil.h"
+#include "cplfile.h"
+
+/*
+ * Set the maximum length allowed for usernames.
+ * names.
+ */
+#define USR_LEN 100
+
+/*
+ * Set the maximum length allowed for environment variable names.
+ */
+#define ENV_LEN 100
+
+/*
+ * Set the max length of the error-reporting string. There is no point
+ * in this being longer than the width of a typical terminal window.
+ * In composing error messages, I have assumed that this number is
+ * at least 80, so you don't decrease it below this number.
+ */
+#define ERRLEN 200
+
+/*
+ * The resources needed to complete a filename are maintained in objects
+ * of the following type.
+ */
+struct CompleteFile {
+ DirReader *dr; /* A directory reader */
+ HomeDir *home; /* A home directory expander */
+ PathName *path; /* The buffer in which to accumulate the path */
+ PathName *buff; /* A pathname work buffer */
+ char usrnam[USR_LEN+1]; /* The buffer used when reading the names of */
+ /* users. */
+ char envnam[ENV_LEN+1]; /* The buffer used when reading the names of */
+ /* environment variables. */
+ char errmsg[ERRLEN+1]; /* The error-report buffer */
+};
+
+static int cf_expand_home_dir(CompleteFile *cf, const char *user);
+static int cf_complete_username(CompleteFile *cf, WordCompletion *cpl,
+ const char *prefix, const char *line,
+ int word_start, int word_end, int escaped);
+static HOME_DIR_FN(cf_homedir_callback);
+static int cf_complete_entry(CompleteFile *cf, WordCompletion *cpl,
+ const char *line, int word_start, int word_end,
+ int escaped, CplCheckFn *check_fn,
+ void *check_data);
+static char *cf_read_name(CompleteFile *cf, const char *type,
+ const char *string, int slen,
+ char *nambuf, int nammax);
+static int cf_prepare_suffix(CompleteFile *cf, const char *suffix,
+ int add_escapes);
+
+/*
+ * A stack based object of the following type is used to pass data to the
+ * cf_homedir_callback() function.
+ */
+typedef struct {
+ CompleteFile *cf; /* The file-completion resource object */
+ WordCompletion *cpl; /* The string-completion rsource object */
+ const char *prefix; /* The username prefix to be completed */
+ const char *line; /* The line from which the prefix was extracted */
+ int word_start; /* The index in line[] of the start of the username */
+ int word_end; /* The index in line[] following the end of the prefix */
+ int escaped; /* If true, add escapes to the completion suffixes */
+} CfHomeArgs;
+
+/*.......................................................................
+ * Create a new file-completion object.
+ *
+ * Output:
+ * return CompleteFile * The new object, or NULL on error.
+ */
+CompleteFile *_new_CompleteFile(void)
+{
+ CompleteFile *cf; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ cf = (CompleteFile *) malloc(sizeof(CompleteFile));
+ if(!cf) {
+ fprintf(stderr, "_new_CompleteFile: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to _del_CompleteFile().
+ */
+ cf->dr = NULL;
+ cf->home = NULL;
+ cf->path = NULL;
+ cf->buff = NULL;
+ cf->usrnam[0] = '\0';
+ cf->envnam[0] = '\0';
+ cf->errmsg[0] = '\0';
+/*
+ * Create the object that is used for reading directories.
+ */
+ cf->dr = _new_DirReader();
+ if(!cf->dr)
+ return _del_CompleteFile(cf);
+/*
+ * Create the object that is used to lookup home directories.
+ */
+ cf->home = _new_HomeDir();
+ if(!cf->home)
+ return _del_CompleteFile(cf);
+/*
+ * Create the buffer in which the completed pathname is accumulated.
+ */
+ cf->path = _new_PathName();
+ if(!cf->path)
+ return _del_CompleteFile(cf);
+/*
+ * Create a pathname work buffer.
+ */
+ cf->buff = _new_PathName();
+ if(!cf->buff)
+ return _del_CompleteFile(cf);
+ return cf;
+}
+
+/*.......................................................................
+ * Delete a file-completion object.
+ *
+ * Input:
+ * cf CompleteFile * The object to be deleted.
+ * Output:
+ * return CompleteFile * The deleted object (always NULL).
+ */
+CompleteFile *_del_CompleteFile(CompleteFile *cf)
+{
+ if(cf) {
+ cf->dr = _del_DirReader(cf->dr);
+ cf->home = _del_HomeDir(cf->home);
+ cf->path = _del_PathName(cf->path);
+ cf->buff = _del_PathName(cf->buff);
+ free(cf);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Look up the possible completions of the incomplete filename that
+ * lies between specified indexes of a given command-line string.
+ *
+ * Input:
+ * cpl WordCompletion * The object in which to record the completions.
+ * cf CompleteFile * The filename-completion resource object.
+ * line const char * The string containing the incomplete filename.
+ * word_start int The index of the first character in line[]
+ * of the incomplete filename.
+ * word_end int The index of the character in line[] that
+ * follows the last character of the incomplete
+ * filename.
+ * escaped int If true, backslashes in line[] are
+ * interpreted as escaping the characters
+ * that follow them, and any spaces, tabs,
+ * backslashes, or wildcard characters in the
+ * returned suffixes will be similarly escaped.
+ * If false, backslashes will be interpreted as
+ * literal parts of the file name, and no
+ * backslashes will be added to the returned
+ * suffixes.
+ * check_fn CplCheckFn * If not zero, this argument specifies a
+ * function to call to ask whether a given
+ * file should be included in the list
+ * of completions.
+ * check_data void * Anonymous data to be passed to check_fn().
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error. A description of the error can be
+ * acquired by calling _cf_last_error(cf).
+ */
+int _cf_complete_file(WordCompletion *cpl, CompleteFile *cf,
+ const char *line, int word_start, int word_end,
+ int escaped, CplCheckFn *check_fn, void *check_data)
+{
+ const char *lptr; /* A pointer into line[] */
+ int nleft; /* The number of characters still to be processed */
+ /* in line[]. */
+/*
+ * Check the arguments.
+ */
+ if(!cpl || !cf || !line || word_end < word_start) {
+ if(cf)
+ strcpy(cf->errmsg, "_cf_complete_file: Invalid arguments");
+ return 1;
+ };
+/*
+ * Clear the buffer in which the filename will be constructed.
+ */
+ _pn_clear_path(cf->path);
+/*
+ * How many characters are to be processed?
+ */
+ nleft = word_end - word_start;
+/*
+ * Get a pointer to the start of the incomplete filename.
+ */
+ lptr = line + word_start;
+/*
+ * If the first character is a tilde, then perform home-directory
+ * interpolation.
+ */
+ if(nleft > 0 && *lptr == '~') {
+ int slen;
+ if(!cf_read_name(cf, "User", ++lptr, --nleft, cf->usrnam, USR_LEN))
+ return 1;
+/*
+ * Advance over the username in the input line.
+ */
+ slen = strlen(cf->usrnam);
+ lptr += slen;
+ nleft -= slen;
+/*
+ * If we haven't hit the end of the input string then we have a complete
+ * username to translate to the corresponding home directory.
+ */
+ if(nleft > 0) {
+ if(cf_expand_home_dir(cf, cf->usrnam))
+ return 1;
+/*
+ * ~user and ~ are usually followed by a directory separator to
+ * separate them from the file contained in the home directory.
+ * If the home directory is the root directory, then we don't want
+ * to follow the home directory by a directory separator, so we should
+ * skip over it so that it doesn't get copied into the filename.
+ */
+ if(strcmp(cf->path->name, FS_ROOT_DIR) == 0 &&
+ strncmp(lptr, FS_DIR_SEP, FS_DIR_SEP_LEN) == 0) {
+ lptr += FS_DIR_SEP_LEN;
+ nleft -= FS_DIR_SEP_LEN;
+ };
+/*
+ * If we have reached the end of the input string, then the username
+ * may be incomplete, and we should attempt to complete it.
+ */
+ } else {
+/*
+ * Look up the possible completions of the username.
+ */
+ return cf_complete_username(cf, cpl, cf->usrnam, line, word_start+1,
+ word_end, escaped);
+ };
+ };
+/*
+ * Copy the rest of the path, stopping to expand $envvar expressions
+ * where encountered.
+ */
+ while(nleft > 0) {
+ int seglen; /* The length of the next segment to be copied */
+/*
+ * Find the length of the next segment to be copied, stopping if an
+ * unescaped '$' is seen, or the end of the path is reached.
+ */
+ for(seglen=0; seglen < nleft; seglen++) {
+ int c = lptr[seglen];
+ if(escaped && c == '\\')
+ seglen++;
+ else if(c == '$')
+ break;
+/*
+ * We will be completing the last component of the file name,
+ * so whenever a directory separator is seen, assume that it
+ * might be the start of the last component, and mark the character
+ * that follows it as the start of the name that is to be completed.
+ */
+ if(nleft >= FS_DIR_SEP_LEN &&
+ strncmp(lptr + seglen, FS_DIR_SEP, FS_DIR_SEP_LEN)==0) {
+ word_start = (lptr + seglen) - line + FS_DIR_SEP_LEN;
+ };
+ };
+/*
+ * We have reached either the end of the filename or the start of
+ * $environment_variable expression. Record the newly checked
+ * segment of the filename in the output filename, removing
+ * backslash-escapes where needed.
+ */
+ if(_pn_append_to_path(cf->path, lptr, seglen, escaped) == NULL) {
+ strcpy(cf->errmsg, "Insufficient memory to complete filename");
+ return 1;
+ };
+ lptr += seglen;
+ nleft -= seglen;
+/*
+ * If the above loop finished before we hit the end of the filename,
+ * then this was because an unescaped $ was seen. In this case, interpolate
+ * the value of the environment variable that follows it into the output
+ * filename.
+ */
+ if(nleft > 0) {
+ char *value; /* The value of the environment variable */
+ int vlen; /* The length of the value string */
+ int nlen; /* The length of the environment variable name */
+/*
+ * Read the name of the environment variable.
+ */
+ if(!cf_read_name(cf, "Environment", ++lptr, --nleft, cf->envnam, ENV_LEN))
+ return 1;
+/*
+ * Advance over the environment variable name in the input line.
+ */
+ nlen = strlen(cf->envnam);
+ lptr += nlen;
+ nleft -= nlen;
+/*
+ * Get the value of the environment variable.
+ */
+ value = getenv(cf->envnam);
+ if(!value) {
+ const char *fmt = "Unknown environment variable: %.*s";
+ sprintf(cf->errmsg, fmt, ERRLEN - strlen(fmt), cf->envnam);
+ return 1;
+ };
+ vlen = strlen(value);
+/*
+ * If we are at the start of the filename and the first character of the
+ * environment variable value is a '~', attempt home-directory
+ * interpolation.
+ */
+ if(cf->path->name[0] == '\0' && value[0] == '~') {
+ if(!cf_read_name(cf, "User", value+1, vlen-1, cf->usrnam, USR_LEN) ||
+ cf_expand_home_dir(cf, cf->usrnam))
+ return 1;
+/*
+ * If the home directory is the root directory, and the ~usrname expression
+ * was followed by a directory separator, prevent the directory separator
+ * from being appended to the root directory by skipping it in the
+ * input line.
+ */
+ if(strcmp(cf->path->name, FS_ROOT_DIR) == 0 &&
+ strncmp(lptr, FS_DIR_SEP, FS_DIR_SEP_LEN) == 0) {
+ lptr += FS_DIR_SEP_LEN;
+ nleft -= FS_DIR_SEP_LEN;
+ };
+ } else {
+/*
+ * Append the value of the environment variable to the output path.
+ */
+ if(_pn_append_to_path(cf->path, value, strlen(value), escaped)==NULL) {
+ strcpy(cf->errmsg, "Insufficient memory to complete filename");
+ return 1;
+ };
+/*
+ * Prevent extra directory separators from being added.
+ */
+ if(nleft >= FS_DIR_SEP_LEN &&
+ strcmp(cf->path->name, FS_ROOT_DIR) == 0 &&
+ strncmp(lptr, FS_DIR_SEP, FS_DIR_SEP_LEN) == 0) {
+ lptr += FS_DIR_SEP_LEN;
+ nleft -= FS_DIR_SEP_LEN;
+ } else if(vlen > FS_DIR_SEP_LEN &&
+ strcmp(value + vlen - FS_DIR_SEP_LEN, FS_DIR_SEP)==0) {
+ cf->path->name[vlen-FS_DIR_SEP_LEN] = '\0';
+ };
+ };
+/*
+ * If adding the environment variable didn't form a valid directory,
+ * we can't complete the line, since there is no way to separate append
+ * a partial filename to an environment variable reference without
+ * that appended part of the name being seen later as part of the
+ * environment variable name. Thus if the currently constructed path
+ * isn't a directory, quite now with no completions having been
+ * registered.
+ */
+ if(!_pu_path_is_dir(cf->path->name))
+ return 0;
+/*
+ * For the reasons given above, if we have reached the end of the filename
+ * with the expansion of an environment variable, the only allowed
+ * completion involves the addition of a directory separator.
+ */
+ if(nleft == 0) {
+ if(cpl_add_completion(cpl, line, lptr-line, word_end, FS_DIR_SEP,
+ "", "")) {
+ strncpy(cf->errmsg, cpl_last_error(cpl), ERRLEN);
+ cf->errmsg[ERRLEN] = '\0';
+ return 1;
+ };
+ return 0;
+ };
+ };
+ };
+/*
+ * Complete the filename if possible.
+ */
+ return cf_complete_entry(cf, cpl, line, word_start, word_end, escaped,
+ check_fn, check_data);
+}
+
+/*.......................................................................
+ * Return a description of the last path-completion error that occurred.
+ *
+ * Input:
+ * cf CompleteFile * The path-completion resource object.
+ * Output:
+ * return const char * The description of the last error.
+ */
+const char *_cf_last_error(CompleteFile *cf)
+{
+ return cf ? cf->errmsg : "NULL CompleteFile argument";
+}
+
+/*.......................................................................
+ * Lookup the home directory of the specified user, or the current user
+ * if no name is specified, appending it to output pathname.
+ *
+ * Input:
+ * cf CompleteFile * The pathname completion resource object.
+ * user const char * The username to lookup, or "" to lookup the
+ * current user.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int cf_expand_home_dir(CompleteFile *cf, const char *user)
+{
+/*
+ * Attempt to lookup the home directory.
+ */
+ const char *home_dir = _hd_lookup_home_dir(cf->home, user);
+/*
+ * Failed?
+ */
+ if(!home_dir) {
+ strncpy(cf->errmsg, _hd_last_home_dir_error(cf->home), ERRLEN);
+ cf->errmsg[ERRLEN] = '\0';
+ return 1;
+ };
+/*
+ * Append the home directory to the pathname string.
+ */
+ if(_pn_append_to_path(cf->path, home_dir, -1, 0) == NULL) {
+ strcpy(cf->errmsg, "Insufficient memory for home directory expansion");
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Lookup and report all completions of a given username prefix.
+ *
+ * Input:
+ * cf CompleteFile * The filename-completion resource object.
+ * cpl WordCompletion * The object in which to record the completions.
+ * prefix const char * The prefix of the usernames to lookup.
+ * line const char * The command-line in which the username appears.
+ * word_start int The index within line[] of the start of the
+ * username that is being completed.
+ * word_end int The index within line[] of the character which
+ * follows the incomplete username.
+ * escaped int True if the completions need to have special
+ * characters escaped.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int cf_complete_username(CompleteFile *cf, WordCompletion *cpl,
+ const char *prefix, const char *line,
+ int word_start, int word_end, int escaped)
+{
+/*
+ * Set up a container of anonymous arguments to be sent to the
+ * username-lookup iterator.
+ */
+ CfHomeArgs args;
+ args.cf = cf;
+ args.cpl = cpl;
+ args.prefix = prefix;
+ args.line = line;
+ args.word_start = word_start;
+ args.word_end = word_end;
+ args.escaped = escaped;
+/*
+ * Iterate through the list of users, recording those which start
+ * with the specified prefix.
+ */
+ if(_hd_scan_user_home_dirs(cf->home, &args, cf_homedir_callback)) {
+ strncpy(cf->errmsg, _hd_last_home_dir_error(cf->home), ERRLEN);
+ cf->errmsg[ERRLEN] = '\0';
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * The user/home-directory scanner callback function (see homedir.h)
+ * used by cf_complete_username().
+ */
+static HOME_DIR_FN(cf_homedir_callback)
+{
+/*
+ * Get the file-completion resources from the anonymous data argument.
+ */
+ CfHomeArgs *args = (CfHomeArgs *) data;
+ WordCompletion *cpl = args->cpl;
+ CompleteFile *cf = args->cf;
+/*
+ * Get the length of the username prefix.
+ */
+ int prefix_len = strlen(args->prefix);
+/*
+ * Get the length of the latest user name that is to be compared to
+ * the prefix.
+ */
+ int name_len = strlen(usrnam);
+/*
+ * See if the latest username starts with the prefix that we are
+ * searching for, and record its suffix in the array of matches if so.
+ */
+ if(name_len >= prefix_len && strncmp(args->prefix, usrnam, prefix_len)==0) {
+/*
+ * Copy the username into the pathname work buffer, adding backslash
+ * escapes where needed.
+ */
+ if(cf_prepare_suffix(cf, usrnam+prefix_len, args->escaped)) {
+ strncpy(errmsg, cf->errmsg, maxerr);
+ errmsg[maxerr] = '\0';
+ return 1;
+ };
+/*
+ * Report the completion suffix that was copied above.
+ */
+ if(cpl_add_completion(cpl, args->line, args->word_start, args->word_end,
+ cf->buff->name, FS_DIR_SEP, FS_DIR_SEP)) {
+ strncpy(errmsg, cpl_last_error(cpl), maxerr);
+ errmsg[maxerr] = '\0';
+ return 1;
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Report possible completions of the filename in cf->path->name[].
+ *
+ * Input:
+ * cf CompleteFile * The file-completion resource object.
+ * cpl WordCompletion * The object in which to record the completions.
+ * line const char * The input line, as received by the callback
+ * function.
+ * word_start int The index within line[] of the start of the
+ * last component of the filename that is being
+ * completed.
+ * word_end int The index within line[] of the character which
+ * follows the incomplete filename.
+ * escaped int If true, escape special characters in the
+ * completion suffixes.
+ * check_fn CplCheckFn * If not zero, this argument specifies a
+ * function to call to ask whether a given
+ * file should be included in the list
+ * of completions.
+ * check_data void * Anonymous data to be passed to check_fn().
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int cf_complete_entry(CompleteFile *cf, WordCompletion *cpl,
+ const char *line, int word_start, int word_end,
+ int escaped, CplCheckFn *check_fn,
+ void *check_data)
+{
+ const char *dirpath; /* The name of the parent directory */
+ int start; /* The index of the start of the last filename */
+ /* component in the transcribed filename. */
+ const char *prefix; /* The filename prefix to be completed */
+ int prefix_len; /* The length of the filename prefix */
+ const char *file_name; /* The lastest filename being compared */
+ int waserr = 0; /* True after errors */
+ int terminated=0; /* True if the directory part had to be terminated */
+/*
+ * Get the pathname string and its current length.
+ */
+ char *pathname = cf->path->name;
+ int pathlen = strlen(pathname);
+/*
+ * Locate the start of the final component of the pathname.
+ */
+ for(start=pathlen - 1; start >= 0 &&
+ strncmp(pathname + start, FS_DIR_SEP, FS_DIR_SEP_LEN) != 0; start--)
+ ;
+/*
+ * Is the parent directory the root directory?
+ */
+ if(start==0 ||
+ (start < 0 && strncmp(pathname, FS_ROOT_DIR, FS_ROOT_DIR_LEN) == 0)) {
+ dirpath = FS_ROOT_DIR;
+ start += FS_ROOT_DIR_LEN;
+/*
+ * If we found a directory separator then the part which precedes the
+ * last component is the name of the directory to be opened.
+ */
+ } else if(start > 0) {
+/*
+ * The _dr_open_dir() function requires the directory name to be '\0'
+ * terminated, so temporarily do this by overwriting the first character
+ * of the directory separator.
+ */
+ pathname[start] = '\0';
+ dirpath = pathname;
+ terminated = 1;
+/*
+ * We reached the start of the pathname before finding a directory
+ * separator, so arrange to open the current working directory.
+ */
+ } else {
+ start = 0;
+ dirpath = FS_PWD;
+ };
+/*
+ * Attempt to open the directory.
+ */
+ if(_dr_open_dir(cf->dr, dirpath, NULL)) {
+ const char *fmt = "Can't open directory: %.*s";
+ sprintf(cf->errmsg, fmt, ERRLEN - strlen(fmt), dirpath);
+ return 1;
+ };
+/*
+ * If removed above, restore the directory separator and skip over it
+ * to the start of the filename.
+ */
+ if(terminated) {
+ memcpy(pathname + start, FS_DIR_SEP, FS_DIR_SEP_LEN);
+ start += FS_DIR_SEP_LEN;
+ };
+/*
+ * Get the filename prefix and its length.
+ */
+ prefix = pathname + start;
+ prefix_len = strlen(prefix);
+/*
+ * Traverse the directory, looking for files who's prefixes match the
+ * last component of the pathname.
+ */
+ while((file_name = _dr_next_file(cf->dr)) != NULL && !waserr) {
+ int name_len = strlen(file_name);
+/*
+ * Is the latest filename a possible completion of the filename prefix?
+ */
+ if(name_len >= prefix_len && strncmp(prefix, file_name, prefix_len)==0) {
+/*
+ * When listing all files in a directory, don't list files that start
+ * with '.'. This is how hidden files are denoted in UNIX.
+ */
+ if(prefix_len > 0 || file_name[0] != '.') {
+/*
+ * Copy the completion suffix into the work pathname cf->buff->name,
+ * adding backslash escapes if needed.
+ */
+ if(cf_prepare_suffix(cf, file_name + prefix_len, escaped)) {
+ waserr = 1;
+ } else {
+/*
+ * We want directories to be displayed with directory suffixes,
+ * and other fully completed filenames to be followed by spaces.
+ * To check the type of the file, append the current suffix
+ * to the path being completed, check the filetype, then restore
+ * the path to its original form.
+ */
+ const char *cont_suffix = ""; /* The suffix to add if fully */
+ /* completed. */
+ const char *type_suffix = ""; /* The suffix to add when listing */
+ if(_pn_append_to_path(cf->path, file_name + prefix_len,
+ -1, escaped) == NULL) {
+ strcpy(cf->errmsg, "Insufficient memory to complete filename.");
+ return 1;
+ };
+/*
+ * Specify suffixes according to the file type.
+ */
+ if(_pu_path_is_dir(cf->path->name)) {
+ cont_suffix = FS_DIR_SEP;
+ type_suffix = FS_DIR_SEP;
+ } else if(!check_fn || check_fn(check_data, cf->path->name)) {
+ cont_suffix = " ";
+ } else {
+ cf->path->name[pathlen] = '\0';
+ continue;
+ };
+/*
+ * Remove the temporarily added suffix.
+ */
+ cf->path->name[pathlen] = '\0';
+/*
+ * Record the latest completion.
+ */
+ if(cpl_add_completion(cpl, line, word_start, word_end, cf->buff->name,
+ type_suffix, cont_suffix))
+ waserr = 1;
+ };
+ };
+ };
+ };
+/*
+ * Close the directory.
+ */
+ _dr_close_dir(cf->dr);
+ return waserr;
+}
+
+/*.......................................................................
+ * Read a username or environment variable name, stopping when a directory
+ * separator is seen, when the end of the string is reached, or the
+ * output buffer overflows.
+ *
+ * Input:
+ * cf CompleteFile * The file-completion resource object.
+ * type char * The capitalized name of the type of name being read.
+ * string char * The string who's prefix contains the name.
+ * slen int The number of characters in string[].
+ * nambuf char * The output name buffer.
+ * nammax int The longest string that will fit in nambuf[], excluding
+ * the '\0' terminator.
+ * Output:
+ * return char * A pointer to nambuf on success. On error NULL is
+ * returned and a description of the error is recorded
+ * in cf->errmsg[].
+ */
+static char *cf_read_name(CompleteFile *cf, const char *type,
+ const char *string, int slen,
+ char *nambuf, int nammax)
+{
+ int namlen; /* The number of characters in nambuf[] */
+ const char *sptr; /* A pointer into string[] */
+/*
+ * Work out the max number of characters that should be copied.
+ */
+ int nmax = nammax < slen ? nammax : slen;
+/*
+ * Get the environment variable name that follows the dollar.
+ */
+ for(sptr=string,namlen=0;
+ namlen < nmax && (slen-namlen < FS_DIR_SEP_LEN ||
+ strncmp(sptr, FS_DIR_SEP, FS_DIR_SEP_LEN) != 0);
+ namlen++) {
+ nambuf[namlen] = *sptr++;
+ };
+/*
+ * Did the name overflow the buffer?
+ */
+ if(namlen >= nammax) {
+ const char *fmt = "%.*s name too long";
+ sprintf(cf->errmsg, fmt, ERRLEN - strlen(fmt), type);
+ return NULL;
+ };
+/*
+ * Terminate the string.
+ */
+ nambuf[namlen] = '\0';
+ return nambuf;
+}
+
+/*.......................................................................
+ * Using the work buffer cf->buff, make a suitably escaped copy of a
+ * given completion suffix, ready to be passed to cpl_add_completion().
+ *
+ * Input:
+ * cf CompleteFile * The file-completion resource object.
+ * suffix char * The suffix to be copied.
+ * add_escapes int If true, escape special characters.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int cf_prepare_suffix(CompleteFile *cf, const char *suffix,
+ int add_escapes)
+{
+ const char *sptr; /* A pointer into suffix[] */
+ int nbsl; /* The number of backslashes to add to the suffix */
+ int i;
+/*
+ * How long is the suffix?
+ */
+ int suffix_len = strlen(suffix);
+/*
+ * Clear the work buffer.
+ */
+ _pn_clear_path(cf->buff);
+/*
+ * Count the number of backslashes that will have to be added to
+ * escape spaces, tabs, backslashes and wildcard characters.
+ */
+ nbsl = 0;
+ if(add_escapes) {
+ for(sptr = suffix; *sptr; sptr++) {
+ switch(*sptr) {
+ case ' ': case '\t': case '\\': case '*': case '?': case '[':
+ nbsl++;
+ break;
+ };
+ };
+ };
+/*
+ * Arrange for the output path buffer to have sufficient room for the
+ * both the suffix and any backslashes that have to be inserted.
+ */
+ if(_pn_resize_path(cf->buff, suffix_len + nbsl) == NULL) {
+ strcpy(cf->errmsg, "Insufficient memory to complete filename");
+ return 1;
+ };
+/*
+ * If the suffix doesn't need any escapes, copy it directly into the
+ * work buffer.
+ */
+ if(nbsl==0) {
+ strcpy(cf->buff->name, suffix);
+ } else {
+/*
+ * Make a copy with special characters escaped?
+ */
+ if(nbsl > 0) {
+ const char *src = suffix;
+ char *dst = cf->buff->name;
+ for(i=0; i
+#include
+#include
+
+/*
+ * Local includes.
+ */
+#include "libtecla.h"
+#include "stringrp.h"
+#include "pathutil.h"
+#include "cplfile.h"
+
+/*
+ * Specify the number of strings to allocate when the string free-list
+ * is exhausted. This also sets the number of elements to expand the
+ * matches[] array by whenever it is found to be too small.
+ */
+#define STR_BLK_FACT 100
+
+/*
+ * Set the max length of the error-reporting string. There is no point
+ * in this being longer than the width of a typical terminal window.
+ * In composing error messages, I have assumed that this number is
+ * at least 80, so don't decrease it below 80.
+ */
+#define ERRLEN 200
+
+/*
+ * Completion matches are recorded in containers of the following
+ * type.
+ */
+struct WordCompletion {
+ StringGroup *sg; /* Memory for a group of strings */
+ int matches_dim; /* The allocated size of result.matches[] */
+ char errmsg[ERRLEN+1]; /* The error-reporting buffer */
+ CplMatches result; /* Completions to be returned to the caller */
+ CompleteFile *cf; /* The resources used for filename completion */
+};
+
+static void cpl_sort_matches(WordCompletion *cpl);
+static void cpl_zap_duplicates(WordCompletion *cpl);
+static void cpl_clear_completions(WordCompletion *cpl);
+static int cpl_cmp_matches(const void *v1, const void *v2);
+static int cpl_cmp_suffixes(const void *v1, const void *v2);
+
+/*
+ * The new_CplFileConf() constructor sets the integer first member of
+ * the returned object to the following magic number. On seeing this,
+ * cpl_file_completions() knows when it is passed a valid CplFileConf
+ * object.
+ */
+#define CFC_ID_CODE 4568
+
+/*
+ * A pointer to a structure of the following type can be passed to
+ * the builtin file-completion callback function to modify its behavior.
+ */
+struct CplFileConf {
+ int id; /* new_CplFileConf() sets this to CFC_ID_CODE */
+ int escaped; /* If none-zero, backslashes in the input line are */
+ /* interpreted as escaping special characters and */
+ /* spaces, and any special characters and spaces in */
+ /* the listed completions will also be escaped with */
+ /* added backslashes. This is the default behaviour. */
+ /* If zero, backslashes are interpreted as being */
+ /* literal parts of the filename, and none are added */
+ /* to the completion suffixes. */
+ int file_start; /* The index in the input line of the first character */
+ /* of the filename. If you specify -1 here, */
+ /* cpl_file_completions() identifies the */
+ /* the start of the filename by looking backwards for */
+ /* an unescaped space, or the beginning of the line. */
+ CplCheckFn *chk_fn; /* If not zero, this argument specifies a */
+ /* function to call to ask whether a given */
+ /* file should be included in the list */
+ /* of completions. */
+ void *chk_data; /* Anonymous data to be passed to check_fn(). */
+};
+
+static void cpl_init_FileConf(CplFileConf *cfc);
+
+/*.......................................................................
+ * Create a new string-completion object.
+ *
+ * Output:
+ * return WordCompletion * The new object, or NULL on error.
+ */
+WordCompletion *new_WordCompletion(void)
+{
+ WordCompletion *cpl; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ cpl = (WordCompletion *) malloc(sizeof(WordCompletion));
+ if(!cpl) {
+ fprintf(stderr, "new_WordCompletion: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to del_WordCompletion().
+ */
+ cpl->sg = NULL;
+ cpl->matches_dim = 0;
+ cpl->result.suffix = NULL;
+ cpl->result.cont_suffix = NULL;
+ cpl->result.matches = NULL;
+ cpl->result.nmatch = 0;
+ cpl->cf = NULL;
+/*
+ * Allocate an object that allows a group of strings to be allocated
+ * efficiently by placing many of them in contiguous string segments.
+ */
+ cpl->sg = _new_StringGroup(_pu_pathname_dim());
+ if(!cpl->sg)
+ return del_WordCompletion(cpl);
+/*
+ * Allocate an array for matching completions. This will be extended later
+ * if needed.
+ */
+ cpl->matches_dim = STR_BLK_FACT;
+ cpl->result.matches = (CplMatch *) malloc(sizeof(cpl->result.matches[0]) *
+ cpl->matches_dim);
+ if(!cpl->result.matches) {
+ fprintf(stderr,
+ "new_WordCompletion: Insufficient memory to allocate array of matches.\n");
+ return del_WordCompletion(cpl);
+ };
+/*
+ * Allocate a filename-completion resource object.
+ */
+ cpl->cf = _new_CompleteFile();
+ if(!cpl->cf)
+ return del_WordCompletion(cpl);
+ return cpl;
+}
+
+/*.......................................................................
+ * Delete a string-completion object.
+ *
+ * Input:
+ * cpl WordCompletion * The object to be deleted.
+ * Output:
+ * return WordCompletion * The deleted object (always NULL).
+ */
+WordCompletion *del_WordCompletion(WordCompletion *cpl)
+{
+ if(cpl) {
+ cpl->sg = _del_StringGroup(cpl->sg);
+ if(cpl->result.matches) {
+ free(cpl->result.matches);
+ cpl->result.matches = NULL;
+ cpl->cf = _del_CompleteFile(cpl->cf);
+ };
+ free(cpl);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * This function is designed to be called by CplMatchFn callback
+ * functions. It adds one possible completion of the token that is being
+ * completed to an array of completions. If the completion needs any
+ * special quoting to be valid when displayed in the input line, this
+ * quoting must be included in the string.
+ *
+ * Input:
+ * cpl WordCompletion * The argument of the same name that was passed
+ * to the calling CplMatchFn callback function.
+ * line const char * The input line, as received by the callback
+ * function.
+ * word_start int The index within line[] of the start of the
+ * word that is being completed.
+ * word_end int The index within line[] of the character which
+ * follows the incomplete word, as received by the
+ * calling callback function.
+ * suffix const char * The appropriately quoted string that could
+ * be appended to the incomplete token to complete
+ * it. A copy of this string will be allocated
+ * internally.
+ * type_suffix const char * When listing multiple completions, gl_get_line()
+ * appends this string to the completion to indicate
+ * its type to the user. If not pertinent pass "".
+ * Otherwise pass a literal or static string.
+ * cont_suffix const char * If this turns out to be the only completion,
+ * gl_get_line() will append this string as
+ * a continuation. For example, the builtin
+ * file-completion callback registers a directory
+ * separator here for directory matches, and a
+ * space otherwise. If the match were a function
+ * name you might want to append an open
+ * parenthesis, etc.. If not relevant pass "".
+ * Otherwise pass a literal or static string.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int cpl_add_completion(WordCompletion *cpl, const char *line,
+ int word_start, int word_end, const char *suffix,
+ const char *type_suffix, const char *cont_suffix)
+{
+ CplMatch *match; /* The container of the new match */
+ char *string; /* A newly allocated copy of the completion string */
+/*
+ * Check the arguments.
+ */
+ if(!cpl)
+ return 1;
+ if(!suffix)
+ return 0;
+ if(!type_suffix)
+ type_suffix = "";
+ if(!cont_suffix)
+ cont_suffix = "";
+/*
+ * Do we need to extend the array of matches[]?
+ */
+ if(cpl->result.nmatch+1 > cpl->matches_dim) {
+ int needed = cpl->matches_dim + STR_BLK_FACT;
+ CplMatch *matches = (CplMatch *) realloc(cpl->result.matches,
+ sizeof(cpl->result.matches[0]) * needed);
+ if(!matches) {
+ strcpy(cpl->errmsg, "Insufficient memory to extend array of matches.");
+ return 1;
+ };
+ cpl->result.matches = matches;
+ cpl->matches_dim = needed;
+ };
+/*
+ * Allocate memory to store the combined completion prefix and the
+ * new suffix.
+ */
+ string = _sg_alloc_string(cpl->sg, word_end-word_start + strlen(suffix));
+ if(!string) {
+ strcpy(cpl->errmsg, "Insufficient memory to extend array of matches.");
+ return 1;
+ };
+/*
+ * Compose the string.
+ */
+ strncpy(string, line + word_start, word_end - word_start);
+ strcpy(string + word_end - word_start, suffix);
+/*
+ * Record the new match.
+ */
+ match = cpl->result.matches + cpl->result.nmatch++;
+ match->completion = string;
+ match->suffix = string + word_end - word_start;
+ match->type_suffix = type_suffix;
+/*
+ * Record the continuation suffix.
+ */
+ cpl->result.cont_suffix = cont_suffix;
+ return 0;
+}
+
+/*.......................................................................
+ * Sort the array of matches.
+ *
+ * Input:
+ * cpl WordCompletion * The completion resource object.
+ */
+static void cpl_sort_matches(WordCompletion *cpl)
+{
+ qsort(cpl->result.matches, cpl->result.nmatch,
+ sizeof(cpl->result.matches[0]), cpl_cmp_matches);
+}
+
+/*.......................................................................
+ * This is a qsort() comparison function used to sort matches.
+ *
+ * Input:
+ * v1, v2 void * Pointers to the two matches to be compared.
+ * Output:
+ * return int -1 -> v1 < v2.
+ * 0 -> v1 == v2
+ * 1 -> v1 > v2
+ */
+static int cpl_cmp_matches(const void *v1, const void *v2)
+{
+ const CplMatch *m1 = (const CplMatch *) v1;
+ const CplMatch *m2 = (const CplMatch *) v2;
+ return strcmp(m1->completion, m2->completion);
+}
+
+/*.......................................................................
+ * Sort the array of matches in order of their suffixes.
+ *
+ * Input:
+ * cpl WordCompletion * The completion resource object.
+ */
+static void cpl_sort_suffixes(WordCompletion *cpl)
+{
+ qsort(cpl->result.matches, cpl->result.nmatch,
+ sizeof(cpl->result.matches[0]), cpl_cmp_suffixes);
+}
+
+/*.......................................................................
+ * This is a qsort() comparison function used to sort matches in order of
+ * their suffixes.
+ *
+ * Input:
+ * v1, v2 void * Pointers to the two matches to be compared.
+ * Output:
+ * return int -1 -> v1 < v2.
+ * 0 -> v1 == v2
+ * 1 -> v1 > v2
+ */
+static int cpl_cmp_suffixes(const void *v1, const void *v2)
+{
+ const CplMatch *m1 = (const CplMatch *) v1;
+ const CplMatch *m2 = (const CplMatch *) v2;
+ return strcmp(m1->suffix, m2->suffix);
+}
+
+/*.......................................................................
+ * Find the common prefix of all of the matching completion matches,
+ * and record a pointer to it in cpl->result.suffix. Note that this has
+ * the side effect of sorting the matches into suffix order.
+ *
+ * Input:
+ * cpl WordCompletion * The completion resource object.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int cpl_common_suffix(WordCompletion *cpl)
+{
+ CplMatches *result; /* The result container */
+ const char *first, *last; /* The first and last matching suffixes */
+ int length; /* The length of the common suffix */
+/*
+ * Get the container of the array of matching files.
+ */
+ result = &cpl->result;
+/*
+ * No matching completions?
+ */
+ if(result->nmatch < 1)
+ return 0;
+/*
+ * Sort th matches into suffix order.
+ */
+ cpl_sort_suffixes(cpl);
+/*
+ * Given that the array of matches is sorted, the first and last
+ * suffixes are those that differ most in their prefixes, so the common
+ * prefix of these strings is the longest common prefix of all of the
+ * suffixes.
+ */
+ first = result->matches[0].suffix;
+ last = result->matches[result->nmatch - 1].suffix;
+/*
+ * Find the point at which the first and last matching strings
+ * first difffer.
+ */
+ while(*first && *first == *last) {
+ first++;
+ last++;
+ };
+/*
+ * How long is the common suffix?
+ */
+ length = first - result->matches[0].suffix;
+/*
+ * Allocate memory to record the common suffix.
+ */
+ result->suffix = _sg_alloc_string(cpl->sg, length);
+ if(!result->suffix) {
+ strcpy(cpl->errmsg,
+ "Insufficient memory to record common completion suffix.");
+ return 1;
+ };
+/*
+ * Record the common suffix.
+ */
+ strncpy(result->suffix, result->matches[0].suffix, length);
+ result->suffix[length] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Discard the contents of the array of possible completion matches.
+ *
+ * Input:
+ * cpl WordCompletion * The word-completion resource object.
+ */
+static void cpl_clear_completions(WordCompletion *cpl)
+{
+/*
+ * Discard all of the strings.
+ */
+ _clr_StringGroup(cpl->sg);
+/*
+ * Record the fact that the array is now empty.
+ */
+ cpl->result.nmatch = 0;
+ cpl->result.suffix = NULL;
+ cpl->result.cont_suffix = "";
+/*
+ * Also clear the error message.
+ */
+ cpl->errmsg[0] = '\0';
+ return;
+}
+
+/*.......................................................................
+ * Given an input line and the point at which it completion is to be
+ * attempted, return an array of possible completions.
+ *
+ * Input:
+ * cpl WordCompletion * The completion resource object.
+ * line char * The current input line.
+ * word_end int The index of the character in line[] which
+ * follows the end of the token that is being
+ * completed.
+ * data void * Anonymous 'data' to be passed to match_fn().
+ * match_fn CplMatchFn * The function that will identify the prefix
+ * to be completed from the input line, and
+ * record completion matches.
+ * Output:
+ * return CplMatches * The container of the array of possible
+ * completions. The returned pointer refers
+ * to a container owned by the parent WordCompletion
+ * object, and its contents thus potentially
+ * change on every call to cpl_matches().
+ * On error, NULL is returned, and a description
+ * of the error can be acquired by calling
+ * cpl_last_error(cpl).
+ */
+CplMatches *cpl_complete_word(WordCompletion *cpl, const char *line,
+ int word_end, void *data,
+ CplMatchFn *match_fn)
+{
+ int line_len; /* The total length of the input line */
+/*
+ * How long is the input line?
+ */
+ line_len = strlen(line);
+/*
+ * Check the arguments.
+ */
+ if(!cpl || !line || !match_fn || word_end < 0 || word_end > line_len) {
+ if(cpl)
+ strcpy(cpl->errmsg, "cpl_complete_word: Invalid arguments.");
+ return NULL;
+ };
+/*
+ * Clear the return container.
+ */
+ cpl_clear_completions(cpl);
+/*
+ * Have the matching function record possible completion matches in
+ * cpl->result.matches.
+ */
+ if(match_fn(cpl, data, line, word_end)) {
+ if(cpl->errmsg[0] == '\0')
+ strcpy(cpl->errmsg, "Error completing word.");
+ return NULL;
+ };
+/*
+ * Record a copy of the common initial part of all of the prefixes
+ * in cpl->result.common.
+ */
+ if(cpl_common_suffix(cpl))
+ return NULL;
+/*
+ * Sort the matches into lexicographic order.
+ */
+ cpl_sort_matches(cpl);
+/*
+ * Discard any duplicate matches.
+ */
+ cpl_zap_duplicates(cpl);
+/*
+ * If there is more than one match, discard the continuation suffix.
+ */
+ if(cpl->result.nmatch > 1)
+ cpl->result.cont_suffix = "";
+/*
+ * Return the array of matches.
+ */
+ return &cpl->result;
+}
+
+/*.......................................................................
+ * Print out an array of matching completions.
+ *
+ * Input:
+ * result CplMatches * The container of the sorted array of
+ * completions.
+ * fp FILE * The output stream to write to.
+ * term_width int The width of the terminal.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int cpl_list_completions(CplMatches *result, FILE *fp, int term_width)
+{
+ int maxlen; /* The length of the longest matching string */
+ int width; /* The width of a column */
+ int ncol; /* The number of columns to list */
+ int nrow; /* The number of rows needed to list all of the matches */
+ int row,col; /* The row and column being written to */
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(!result || !fp) {
+ fprintf(stderr, "cpl_list_completions: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Not enough space to list anything?
+ */
+ if(term_width < 1)
+ return 0;
+/*
+ * Work out the maximum length of the matching strings.
+ */
+ maxlen = 0;
+ for(i=0; inmatch; i++) {
+ CplMatch *match = result->matches + i;
+ int len = strlen(match->completion) +
+ strlen(match->type_suffix);
+ if(len > maxlen)
+ maxlen = len;
+ };
+/*
+ * Nothing to list?
+ */
+ if(maxlen == 0)
+ return 0;
+/*
+ * Split the available terminal width into columns of maxlen + 2 characters.
+ */
+ width = maxlen + 2;
+ ncol = term_width / width;
+/*
+ * If the column width is greater than the terminal width, the matches will
+ * just have to overlap onto the next line.
+ */
+ if(ncol < 1)
+ ncol = 1;
+/*
+ * How many rows will be needed?
+ */
+ nrow = (result->nmatch + ncol - 1) / ncol;
+/*
+ * Print the matches out in ncol columns, sorted in row order within each
+ * column.
+ */
+ for(row=0; row < nrow; row++) {
+ for(col=0; col < ncol; col++) {
+ int m = col*nrow + row;
+ if(m < result->nmatch) {
+ CplMatch *match = result->matches + m;
+ if(fprintf(fp, "%s%-*s%s", match->completion,
+ (int) (ncol > 1 ? maxlen - strlen(match->completion):0),
+ match->type_suffix, colerrmsg : "NULL WordCompletion argument";
+}
+
+/*.......................................................................
+ * When an error occurs while performing a completion, you registerf a
+ * terse description of the error by calling cpl_record_error(). This
+ * message will then be returned on the next call to cpl_last_error().
+ *
+ * Input:
+ * cpl WordCompletion * The string-completion resource object that was
+ * originally passed to the callback.
+ * errmsg const char * The description of the error.
+ */
+void cpl_record_error(WordCompletion *cpl, const char *errmsg)
+{
+ if(cpl && errmsg) {
+ strncpy(cpl->errmsg, errmsg, ERRLEN);
+ cpl->errmsg[ERRLEN] = '\0';
+ };
+}
+
+/*.......................................................................
+ * This is the builtin completion callback function which performs file
+ * completion.
+ *
+ * Input:
+ * cpl WordCompletion * An opaque pointer to the object that will
+ * contain the matches. This should be filled
+ * via zero or more calls to cpl_add_completion().
+ * data void * Either NULL to request the default
+ * file-completion behavior, or a pointer to a
+ * CplFileConf structure, whose members specify
+ * a different behavior.
+ * line char * The current input line.
+ * word_end int The index of the character in line[] which
+ * follows the end of the token that is being
+ * completed.
+ * Output
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+CPL_MATCH_FN(cpl_file_completions)
+{
+ const char *start_path; /* The pointer to the start of the pathname */
+ /* in line[]. */
+ CplFileConf *conf; /* The new-style configuration object. */
+/*
+ * The following configuration object will be used if the caller didn't
+ * provide one.
+ */
+ CplFileConf default_conf;
+/*
+ * This function can be called externally, so check its arguments.
+ */
+ if(!cpl)
+ return 1;
+ if(!line || word_end < 0) {
+ strcpy(cpl->errmsg, "cpl_file_completions: Invalid arguments.");
+ return 1;
+ };
+/*
+ * The 'data' argument is either a CplFileConf pointer, identifiable
+ * by having an integer id code as its first member, or the deprecated
+ * CplFileArgs pointer, or can be NULL to request the default
+ * configuration.
+ */
+ if(data && *(int *)data == CFC_ID_CODE) {
+ conf = (CplFileConf *) data;
+ } else {
+/*
+ * Select the defaults.
+ */
+ conf = &default_conf;
+ cpl_init_FileConf(&default_conf);
+/*
+ * If we have been passed an instance of the deprecated CplFileArgs
+ * structure, copy its configuration parameters over the defaults.
+ */
+ if(data) {
+ CplFileArgs *args = (CplFileArgs *) data;
+ conf->escaped = args->escaped;
+ conf->file_start = args->file_start;
+ };
+ };
+/*
+ * Get the start of the filename. If not specified by the caller
+ * identify it by searching backwards in the input line for an
+ * unescaped space or the start of the line.
+ */
+ if(conf->file_start < 0) {
+ start_path = _pu_start_of_path(line, word_end);
+ if(!start_path) {
+ strcpy(cpl->errmsg, "Unable to find the start of the filename.");
+ return 1;
+ };
+ } else {
+ start_path = line + conf->file_start;
+ };
+/*
+ * Perform the completion.
+ */
+ if(_cf_complete_file(cpl, cpl->cf, line, start_path - line, word_end,
+ conf->escaped, conf->chk_fn, conf->chk_data)) {
+ cpl_record_error(cpl, _cf_last_error(cpl->cf));
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Initialize a CplFileArgs structure with default configuration
+ * parameters. Note that the CplFileArgs configuration type is
+ * deprecated. The opaque CplFileConf object should be used in future
+ * applications.
+ *
+ * Input:
+ * cfa CplFileArgs * The configuration object of the
+ * cpl_file_completions() callback.
+ */
+void cpl_init_FileArgs(CplFileArgs *cfa)
+{
+ if(cfa) {
+ cfa->escaped = 1;
+ cfa->file_start = -1;
+ };
+}
+
+/*.......................................................................
+ * Initialize a CplFileConf structure with default configuration
+ * parameters.
+ *
+ * Input:
+ * cfc CplFileConf * The configuration object of the
+ * cpl_file_completions() callback.
+ */
+static void cpl_init_FileConf(CplFileConf *cfc)
+{
+ if(cfc) {
+ cfc->id = CFC_ID_CODE;
+ cfc->escaped = 1;
+ cfc->file_start = -1;
+ cfc->chk_fn = 0;
+ cfc->chk_data = NULL;
+ };
+}
+
+/*.......................................................................
+ * Create a new CplFileConf object and initialize it with defaults.
+ *
+ * Output:
+ * return CplFileConf * The new object, or NULL on error.
+ */
+CplFileConf *new_CplFileConf(void)
+{
+ CplFileConf *cfc; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ cfc = (CplFileConf *)malloc(sizeof(CplFileConf));
+ if(!cfc)
+ return NULL;
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to del_CplFileConf().
+ */
+ cpl_init_FileConf(cfc);
+ return cfc;
+}
+
+/*.......................................................................
+ * Delete a CplFileConf object.
+ *
+ * Input:
+ * cfc CplFileConf * The object to be deleted.
+ * Output:
+ * return CplFileConf * The deleted object (always NULL).
+ */
+CplFileConf *del_CplFileConf(CplFileConf *cfc)
+{
+ if(cfc) {
+/*
+ * Delete the container.
+ */
+ free(cfc);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * If backslashes in the filename should be treated as literal
+ * characters, call the following function with literal=1. Otherwise
+ * the default is to treat them as escape characters, used for escaping
+ * spaces etc..
+ *
+ * Input:
+ * cfc CplFileConf * The cpl_file_completions() configuration object
+ * to be configured.
+ * literal int Pass non-zero here to enable literal interpretation
+ * of backslashes. Pass 0 to turn off literal
+ * interpretation.
+ */
+void cfc_literal_escapes(CplFileConf *cfc, int literal)
+{
+ if(cfc)
+ cfc->escaped = !literal;
+}
+
+/*.......................................................................
+ * Call this function if you know where the index at which the
+ * filename prefix starts in the input line. Otherwise by default,
+ * or if you specify start_index to be -1, the filename is taken
+ * to start after the first unescaped space preceding the cursor,
+ * or the start of the line, which ever comes first.
+ *
+ * Input:
+ * cfc CplFileConf * The cpl_file_completions() configuration object
+ * to be configured.
+ * start_index int The index of the start of the filename in
+ * the input line, or -1 to select the default.
+ */
+void cfc_file_start(CplFileConf *cfc, int start_index)
+{
+ if(cfc)
+ cfc->file_start = start_index;
+}
+
+/*.......................................................................
+ * If you only want certain types of files to be included in the
+ * list of completions, you use the following function to specify a
+ * callback function which will be called to ask whether a given file
+ * should be included.
+ *
+ * Input:
+ * cfc CplFileConf * The cpl_file_completions() configuration object
+ * to be configured.
+ * chk_fn CplCheckFn * Zero to disable filtering, or a pointer to a
+ * function that returns 1 if a given file should
+ * be included in the list of completions.
+ * chk_data void * Anonymous data to be passed to chk_fn()
+ * every time that it is called.
+ */
+void cfc_set_check_fn(CplFileConf *cfc, CplCheckFn *chk_fn, void *chk_data)
+{
+ if(cfc) {
+ cfc->chk_fn = chk_fn;
+ cfc->chk_data = chk_data;
+ };
+}
+
+/*.......................................................................
+ * The following CplCheckFn callback returns non-zero if the specified
+ * filename is that of an executable.
+ */
+CPL_CHECK_FN(cpl_check_exe)
+{
+ return _pu_path_is_exe(pathname);
+}
+
+/*.......................................................................
+ * Remove duplicates from a sorted array of matches.
+ *
+ * Input:
+ * cpl WordCompletion * The completion resource object.
+ */
+static void cpl_zap_duplicates(WordCompletion *cpl)
+{
+ CplMatch *matches; /* The array of matches */
+ int nmatch; /* The number of elements in matches[] */
+ const char *completion; /* The completion string of the last unique match */
+ const char *type_suffix; /* The type of the last unique match */
+ int src; /* The index of the match being considered */
+ int dst; /* The index at which to record the next */
+ /* unique match. */
+/*
+ * Get the array of matches and the number of matches that it
+ * contains.
+ */
+ matches = cpl->result.matches;
+ nmatch = cpl->result.nmatch;
+/*
+ * No matches?
+ */
+ if(nmatch < 1)
+ return;
+/*
+ * Initialize the comparison strings with the first match.
+ */
+ completion = matches[0].completion;
+ type_suffix = matches[0].type_suffix;
+/*
+ * Go through the array of matches, copying each new unrecorded
+ * match at the head of the array, while discarding duplicates.
+ */
+ for(src=dst=1; srccompletion) != 0 ||
+ strcmp(type_suffix, match->type_suffix) != 0) {
+ if(src != dst)
+ matches[dst] = *match;
+ dst++;
+ completion = match->completion;
+ type_suffix = match->type_suffix;
+ };
+ };
+/*
+ * Record the number of unique matches that remain.
+ */
+ cpl->result.nmatch = dst;
+ return;
+}
diff --git a/libtecla-1.4.1/demo.c b/libtecla-1.4.1/demo.c
new file mode 100644
index 0000000..8bee92d
--- /dev/null
+++ b/libtecla-1.4.1/demo.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2000, 2001 by the California Institute of Technology.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "libtecla.h"
+
+int main(int argc, char *argv[])
+{
+ char *line; /* A line of input */
+ GetLine *gl; /* The line editor */
+ int major,minor,micro; /* The version number of the library */
+/*
+ * Create the line editor, specifying a max line length of 500 bytes,
+ * and 10000 bytes to allocate to storage of historical input lines.
+ */
+ gl = new_GetLine(500, 5000);
+ if(!gl)
+ return 1;
+/*
+ * If the user has the LC_CTYPE or LC_ALL environment variables set,
+ * enable display of characters corresponding to the specified locale.
+ */
+ (void) setlocale(LC_CTYPE, "");
+/*
+ * Lookup and display the version number of the library.
+ */
+ libtecla_version(&major, &minor, µ);
+ printf("Welcome to the demo program of libtecla version %d.%d.%d\n",
+ major, minor, micro);
+/*
+ * Load history.
+ */
+ (void) gl_load_history(gl, "~/.demo_history", "#");
+/*
+ * Read lines of input from the user and print them to stdout.
+ */
+ do {
+/*
+ * Get a new line from the user.
+ */
+ line = gl_get_line(gl, "$ ", NULL, 0);
+ if(!line)
+ break;
+/*
+ * Display what was entered.
+ */
+ if(printf("You entered: %s", line) < 0 || fflush(stdout))
+ break;
+/*
+ * If the user types "exit", quit the program.
+ */
+ if(strcmp(line, "exit\n")==0)
+ break;
+ else if(strcmp(line, "history\n")==0)
+ gl_show_history(gl, stdout, "%N %T %H\n", 0, -1);
+ else if(strcmp(line, "size\n")==0) {
+ GlTerminalSize size = gl_terminal_size(gl, 80, 24);
+ printf("Terminal size = %d columns x %d lines.\n", size.ncolumn,
+ size.nline);
+ };
+ } while(1);
+/*
+ * Save historical command lines.
+ */
+ (void) gl_save_history(gl, "~/.demo_history", "#", -1);
+/*
+ * Clean up.
+ */
+ gl = del_GetLine(gl);
+ return 0;
+}
+
diff --git a/libtecla-1.4.1/demo2.c b/libtecla-1.4.1/demo2.c
new file mode 100644
index 0000000..e1e80c6
--- /dev/null
+++ b/libtecla-1.4.1/demo2.c
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "libtecla.h"
+
+/*
+ * Encapsulate the resources needed by this demo.
+ */
+typedef struct {
+ GetLine *gl; /* The line editor */
+ PathCache *pc; /* A cache of executables in the user's path */
+ PcaPathConf *ppc; /* The configuration argument of pca_path_completions() */
+} DemoRes;
+
+/*
+ * The following functions allocate and free instances of the above
+ * structure.
+ */
+static DemoRes *new_DemoRes(void);
+static DemoRes *del_DemoRes(DemoRes *res);
+
+/*
+ * Search backwards for the start of a pathname.
+ */
+static char *start_of_path(const char *string, int back_from);
+
+/*
+ * Find the array indexes of the first character of the first
+ * space-delimited word in the specified string, and of the character
+ * that follows it.
+ */
+static int get_word_limits(const char *string, int *wa, int *wb);
+
+/*
+ * This is the demonstration completion callback function (defined below).
+ */
+static CPL_MATCH_FN(demo_cpl_fn);
+
+/*.......................................................................
+ * This demo takes no arguments. It reads lines of input until the
+ * word 'exit' is entered, or C-d is pressed. It replaces the default
+ * tab-completion callback with one which when invoked at the start of
+ * a line, looks up completions of commands in the user's execution
+ * path, and when invoked in other parts of the line, reverts to
+ * normal filename completion. Whenever a new line is entered, it
+ * extracts the first word on the line, looks it up in the user's
+ * execution path to see if it corresponds to a known executable file,
+ * and if so, displays the full pathname of the file, along with the
+ * remaining arguments.
+ */
+int main(int argc, char *argv[])
+{
+ char *line; /* A line of input */
+ DemoRes *res; /* The resources of the demo */
+ int wa,wb; /* The delimiting indexes of a word in line[] */
+ int major,minor,micro; /* The version number of the library */
+/*
+ * Allocate the resources needed by this demo.
+ */
+ res = new_DemoRes();
+ if(!res)
+ return 1;
+/*
+ * If the user has the LC_CTYPE or LC_ALL environment variables set,
+ * enable display of characters corresponding to the specified locale.
+ */
+ (void) setlocale(LC_CTYPE, "");
+/*
+ * Lookup and display the version number of the library.
+ */
+ libtecla_version(&major, &minor, µ);
+ printf("Welcome to the demo2 program of libtecla version %d.%d.%d\n",
+ major, minor, micro);
+/*
+ * Read lines of input from the user and print them to stdout.
+ */
+ do {
+/*
+ * Get a new line from the user.
+ */
+ line = gl_get_line(res->gl, "$ ", NULL, 0);
+ if(!line)
+ break;
+/*
+ * Work out the extent of the first word in the input line, and
+ * try to identify this as a command in the path, displaying the
+ * full pathname of the match if found.
+ */
+ if(get_word_limits(line, &wa, &wb) == 0) {
+ char *cmd = pca_lookup_file(res->pc, line + wa, wb-wa, 0);
+ if(cmd) {
+ printf("Command=%s\n", cmd);
+ printf("Arguments=%s", line+wb);
+ } else {
+ printf("Command not found\n");
+ };
+ };
+/*
+ * If the user types "exit", quit the program.
+ */
+ if(strcmp(line, "exit\n")==0)
+ break;
+ } while(1);
+/*
+ * Clean up.
+ */
+ res = del_DemoRes(res);
+ return 0;
+}
+
+/*.......................................................................
+ * This completion callback searches for completions of executables in
+ * the user's path when invoked on a word at the start of the path, and
+ * performs normal filename completion elsewhere.
+ */
+static CPL_MATCH_FN(demo_cpl_fn)
+{
+/*
+ * Get the resource object that was passed to gl_customize_completion().
+ */
+ DemoRes *res = (DemoRes *) data;
+/*
+ * Find the start of the filename prefix to be completed, searching
+ * backwards for the first unescaped space, or the start of the line.
+ */
+ char *start = start_of_path(line, word_end);
+/*
+ * Skip spaces preceding the start of the prefix.
+ */
+ while(start > line && isspace((int)(unsigned char) start[-1]))
+ start--;
+/*
+ * If the filename prefix is at the start of the line, attempt
+ * to complete the filename as a command in the path. Otherwise
+ * perform normal filename completion.
+ */
+ return (start == line) ?
+ pca_path_completions(cpl, res->ppc, line, word_end) :
+ cpl_file_completions(cpl, NULL, line, word_end);
+}
+
+/*.......................................................................
+ * Search backwards for the potential start of a filename. This
+ * looks backwards from the specified index in a given string,
+ * stopping at the first unescaped space or the start of the line.
+ *
+ * Input:
+ * string const char * The string to search backwards in.
+ * back_from int The index of the first character in string[]
+ * that follows the pathname.
+ * Output:
+ * return char * The pointer to the first character of
+ * the potential pathname, or NULL on error.
+ */
+static char *start_of_path(const char *string, int back_from)
+{
+ int i, j;
+/*
+ * Search backwards from the specified index.
+ */
+ for(i=back_from-1; i>=0; i--) {
+ int c = string[i];
+/*
+ * Stop on unescaped spaces.
+ */
+ if(isspace((int)(unsigned char)c)) {
+/*
+ * The space can't be escaped if we are at the start of the line.
+ */
+ if(i==0)
+ break;
+/*
+ * Find the extent of the escape characters which precedes the space.
+ */
+ for(j=i-1; j>=0 && string[j]=='\\'; j--)
+ ;
+/*
+ * If there isn't an odd number of escape characters before the space,
+ * then the space isn't escaped.
+ */
+ if((i - 1 - j) % 2 == 0)
+ break;
+ };
+ };
+ return (char *)string + i + 1;
+}
+
+/*.......................................................................
+ * Create a new DemoRes object containing the resources needed by the
+ * demo.
+ *
+ * Output:
+ * return DemoRes * The new object, or NULL on error.
+ */
+static DemoRes *new_DemoRes(void)
+{
+ DemoRes *res; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ res = (DemoRes *)malloc(sizeof(DemoRes));
+ if(!res) {
+ fprintf(stderr, "new_DemoRes: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to del_DemoRes().
+ */
+ res->gl = NULL;
+ res->pc = NULL;
+ res->ppc = NULL;
+/*
+ * Create the line editor, specifying a max line length of 500 bytes,
+ * and 10000 bytes to allocate to storage of historical input lines.
+ */
+ res->gl = new_GetLine(500, 10000);
+ if(!res->gl)
+ return del_DemoRes(res);
+/*
+ * Enable text attribute formatting directives in prompt strings.
+ */
+ gl_prompt_style(res->gl, GL_FORMAT_PROMPT);
+/*
+ * Allocate a cache of the executable files found in the user's path.
+ */
+ res->pc = new_PathCache();
+ if(!res->pc)
+ return del_DemoRes(res);
+/*
+ * Populate the cache with the contents of the user's path.
+ */
+ if(pca_scan_path(res->pc, getenv("PATH")))
+ return del_DemoRes(res);
+/*
+ * Arrange for susequent calls to pca_lookup_file() and pca_path_completions()
+ * to only report files that are executable by the user.
+ */
+ pca_set_check_fn(res->pc, cpl_check_exe, NULL);
+/*
+ * Allocate a configuration object for use with pca_path_completions().
+ */
+ res->ppc = new_PcaPathConf(res->pc);
+ if(!res->ppc)
+ return del_DemoRes(res);
+/*
+ * Replace the builtin filename completion callback with one which
+ * searches for completions of executables in the user's path when
+ * invoked on a word at the start of the path, and completes files
+ * elsewhere.
+ */
+ if(gl_customize_completion(res->gl, res, demo_cpl_fn))
+ return del_DemoRes(res);
+ return res;
+}
+
+/*.......................................................................
+ * Delete a DemoRes object.
+ *
+ * Input:
+ * res DemoRes * The object to be deleted.
+ * Output:
+ * return DemoRes * The deleted object (always NULL).
+ */
+static DemoRes *del_DemoRes(DemoRes *res)
+{
+ if(res) {
+ res->gl = del_GetLine(res->gl);
+ res->pc = del_PathCache(res->pc);
+ res->ppc = del_PcaPathConf(res->ppc);
+ free(res);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Return the limits of the word at the start of a given string, ignoring
+ * leading white-space, and interpretting the first unescaped space, tab or
+ * the end of the line, as the end of the word.
+ *
+ * Input:
+ * string const char * The string to tokenize.
+ * Input/Output:
+ * wa,wb int * The indexes of the first character of the word,
+ * and the character which follows the last
+ * character of the word, will be assigned to
+ * *wa and *wb, respectively.
+ * Output:
+ * return int 0 - A word was found.
+ * 1 - No word was found before the end of the
+ * string.
+ */
+static int get_word_limits(const char *string, int *wa, int *wb)
+{
+ int escaped = 0; /* True if the next character is escaped */
+/*
+ * Skip leading white-space.
+ */
+ for(*wa=0; isspace((int)(unsigned char)string[*wa]); (*wa)++)
+ ;
+/*
+ * Find the first unescaped space, stopping early if the end of the
+ * string is reached.
+ */
+ for(*wb = *wa; ; (*wb)++) {
+ int c = string[*wb];
+ if(c=='\\')
+ escaped = !escaped;
+ else if((!escaped && isspace((int)(unsigned char)c)) || c=='\0')
+ break;
+ };
+ return *wa == *wb;
+}
diff --git a/libtecla-1.4.1/direader.c b/libtecla-1.4.1/direader.c
new file mode 100644
index 0000000..8a81fbf
--- /dev/null
+++ b/libtecla-1.4.1/direader.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * Standard includes.
+ */
+#include
+#include
+#include
+#include
+
+/*
+ * Operating system includes.
+ */
+#include
+#include
+#include
+#include
+
+#include "direader.h"
+
+/*
+ * Use the reentrant POSIX threads version of readdir()?
+ */
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199506L
+#define USE_READDIR_R 1
+#endif
+
+/*
+ * Set the max length of the error-reporting string. There is no point
+ * in this being longer than the width of a typical terminal window.
+ * In composing error messages, I have assumed that this number is
+ * at least 80, so you don't decrease it below this number.
+ */
+#define ERRLEN 200
+
+/*
+ * Objects of the following type are used to maintain the resources
+ * needed to read directories.
+ */
+struct DirReader {
+ DIR *dir; /* The directory stream (if open, NULL otherwise) */
+ struct dirent *file; /* The latest directory entry */
+ char errmsg[ERRLEN+1]; /* Error-report buffer */
+#ifdef USE_READDIR_R
+ struct dirent *buffer; /* A buffer used by the threaded version of readdir */
+ int buffer_dim; /* The allocated size of buffer[] */
+#endif
+};
+
+static int _dr_path_is_dir(const char *pathname);
+
+/*.......................................................................
+ * Create a new DirReader object.
+ *
+ * Output:
+ * return DirReader * The new object, or NULL on error.
+ */
+DirReader *_new_DirReader(void)
+{
+ DirReader *dr; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ dr = (DirReader *) malloc(sizeof(DirReader));
+ if(!dr) {
+ fprintf(stderr, "_new_DirReader: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to _del_DirReader().
+ */
+ dr->dir = NULL;
+ dr->file = NULL;
+ dr->errmsg[0] = '\0';
+#ifdef USE_READDIR_R
+ dr->buffer = NULL;
+ dr->buffer_dim = 0;
+#endif
+ return dr;
+}
+
+/*.......................................................................
+ * Delete a DirReader object.
+ *
+ * Input:
+ * dr DirReader * The object to be deleted.
+ * Output:
+ * return DirReader * The deleted object (always NULL).
+ */
+DirReader *_del_DirReader(DirReader *dr)
+{
+ if(dr) {
+ _dr_close_dir(dr);
+#ifdef USE_READDIR_R
+ free(dr->buffer);
+#endif
+ free(dr);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Open a new directory.
+ *
+ * Input:
+ * dr DirReader * The directory reader resource object.
+ * path const char * The directory to be opened.
+ * Input/Output:
+ * errmsg char ** If an error occurs and errmsg isn't NULL, a
+ * pointer to an error description will be assigned
+ * to *errmsg.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error (see *errmsg for a description).
+ */
+int _dr_open_dir(DirReader *dr, const char *path, char **errmsg)
+{
+ DIR *dir = NULL; /* The directory stream */
+/*
+ * If a directory is already open, close it first.
+ */
+ (void) _dr_close_dir(dr);
+/*
+ * Is the path a directory?
+ */
+ if(!_dr_path_is_dir(path)) {
+ if(errmsg) {
+ const char *fmt = "Can't open directory: %.*s\n";
+ sprintf(dr->errmsg, fmt, ERRLEN - strlen(fmt), path);
+ *errmsg = dr->errmsg;
+ };
+ return 1;
+ };
+/*
+ * Attempt to open the directory.
+ */
+ dir = opendir(path);
+ if(!dir) {
+ if(errmsg) {
+ const char *fmt = "Can't open directory: %.*s\n";
+ sprintf(dr->errmsg, fmt, ERRLEN - strlen(fmt), path);
+ *errmsg = dr->errmsg;
+ };
+ return 1;
+ };
+/*
+ * If using POSIX threads, allocate a buffer for readdir_r().
+ */
+#ifdef USE_READDIR_R
+ {
+ size_t size;
+ int name_max = pathconf(path, _PC_NAME_MAX);
+#ifdef NAME_MAX
+ if(name_max < 0)
+ name_max = NAME_MAX;
+#endif
+ if(name_max < 0) {
+ if(errmsg) {
+ strcpy(dr->errmsg, "Unable to deduce readdir() buffer size.");
+ *errmsg = dr->errmsg;
+ };
+ closedir(dir);
+ return 1;
+ };
+/*
+ * How big a buffer do we need to allocate?
+ */
+ size = sizeof(struct dirent) + name_max;
+/*
+ * Extend the buffer?
+ */
+ if(size > dr->buffer_dim || !dr->buffer) {
+ struct dirent *buffer = (struct dirent *) (dr->buffer ?
+ realloc(dr->buffer, size) :
+ malloc(size));
+ if(!buffer) {
+ if(errmsg) {
+ strcpy(dr->errmsg, "Insufficient memory for readdir() buffer.");
+ *errmsg = dr->errmsg;
+ };
+ closedir(dir);
+ return 1;
+ };
+ dr->buffer = buffer;
+ dr->buffer_dim = size;
+ };
+ };
+#endif
+/*
+ * Record the successfully opened directory.
+ */
+ dr->dir = dir;
+ return 0;
+}
+
+/*.......................................................................
+ * If the DirReader object is currently contains an open directory,
+ * close it.
+ *
+ * Input:
+ * dr DirReader * The directory reader resource object.
+ */
+void _dr_close_dir(DirReader *dr)
+{
+ if(dr && dr->dir) {
+ closedir(dr->dir);
+ dr->dir = NULL;
+ dr->file = NULL;
+ dr->errmsg[0] = '\0';
+ };
+}
+
+/*.......................................................................
+ * Read the next file from the directory opened with _dr_open_dir().
+ *
+ * Input:
+ * dr DirReader * The directory reader resource object.
+ * Output:
+ * return char * The name of the new file, or NULL if we reached
+ * the end of the directory.
+ */
+char *_dr_next_file(DirReader *dr)
+{
+/*
+ * Are we currently reading a directory?
+ */
+ if(dr->dir) {
+/*
+ * Read the next directory entry.
+ */
+#ifdef USE_READDIR_R
+ if(readdir_r(dr->dir, dr->buffer, &dr->file) == 0 && dr->file)
+ return dr->file->d_name;
+#else
+ dr->file = readdir(dr->dir);
+ if(dr->file)
+ return dr->file->d_name;
+#endif
+ };
+/*
+ * When the end of a directory is reached, close it.
+ */
+ _dr_close_dir(dr);
+ return NULL;
+}
+
+/*.......................................................................
+ * Return 1 if the specified pathname refers to a directory.
+ *
+ * Input:
+ * pathname const char * The path to test.
+ * Output:
+ * return int 0 - Not a directory.
+ * 1 - pathname[] refers to a directory.
+ */
+static int _dr_path_is_dir(const char *pathname)
+{
+ struct stat statbuf; /* The file-statistics return buffer */
+/*
+ * Look up the file attributes.
+ */
+ if(stat(pathname, &statbuf) < 0)
+ return 0;
+/*
+ * Is the file a directory?
+ */
+ return S_ISDIR(statbuf.st_mode) != 0;
+}
diff --git a/libtecla-1.4.1/direader.h b/libtecla-1.4.1/direader.h
new file mode 100644
index 0000000..2cf178e
--- /dev/null
+++ b/libtecla-1.4.1/direader.h
@@ -0,0 +1,44 @@
+#ifndef dirreader_h
+#define dirreader_h
+
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+typedef struct DirReader DirReader;
+
+DirReader *_new_DirReader(void);
+DirReader *_del_DirReader(DirReader *dr);
+
+int _dr_open_dir(DirReader *dr, const char *pathname, char **errmsg);
+char *_dr_next_file(DirReader *dr);
+void _dr_close_dir(DirReader *dr);
+
+#endif
diff --git a/libtecla-1.4.1/enhance.c b/libtecla-1.4.1/enhance.c
new file mode 100644
index 0000000..72f5061
--- /dev/null
+++ b/libtecla-1.4.1/enhance.c
@@ -0,0 +1,689 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#if HAVE_SYSV_PTY
+#include /* System-V stream I/O */
+char *ptsname(int fd);
+int grantpt(int fd);
+int unlockpt(int fd);
+#endif
+
+#include "libtecla.h"
+
+/*
+ * Pseudo-terminal devices are found in the following directory.
+ */
+#define PTY_DEV_DIR "/dev/"
+
+/*
+ * Pseudo-terminal controller device file names start with the following
+ * prefix.
+ */
+#define PTY_CNTRL "pty"
+
+/*
+ * Pseudo-terminal slave device file names start with the following
+ * prefix.
+ */
+#define PTY_SLAVE "tty"
+
+/*
+ * Specify the maximum suffix length for the control and slave device
+ * names.
+ */
+#define PTY_MAX_SUFFIX 10
+
+/*
+ * Set the maximum length of the master and slave terminal device filenames,
+ * including space for a terminating '\0'.
+ */
+#define PTY_MAX_NAME (sizeof(PTY_DEV_DIR)-1 + \
+ (sizeof(PTY_SLAVE) > sizeof(PTY_CNTRL) ? \
+ sizeof(PTY_SLAVE) : sizeof(PTY_CNTRL))-1 \
+ + PTY_MAX_SUFFIX + 1)
+/*
+ * Set the maximum length of an input line.
+ */
+#define PTY_MAX_LINE 4096
+
+/*
+ * Set the size of the buffer used for accumulating bytes written by the
+ * user's terminal to its stdout.
+ */
+#define PTY_MAX_READ 1000
+
+/*
+ * Set the amount of memory used to record history.
+ */
+#define PTY_HIST_SIZE 10000
+
+/*
+ * Set the timeout delay used to check for quickly arriving
+ * sequential output from the application.
+ */
+#define PTY_READ_TIMEOUT 100000 /* micro-seconds */
+
+static int pty_open_master(const char *prog, int *cntrl, char *slave_name);
+static int pty_open_slave(const char *prog, char *slave_name);
+static int pty_child(const char *prog, int slave, char *argv[]);
+static int pty_parent(const char *prog, int cntrl);
+static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff);
+static GL_FD_EVENT_FN(pty_read_from_program);
+static int pty_write_to_fd(int fd, const char *string, int n);
+static void pty_child_exited(int sig);
+static int pty_master_readable(int fd, long usec);
+
+/*.......................................................................
+ * Run a program with enhanced terminal editing facilities.
+ *
+ * Usage:
+ * enhance program [args...]
+ */
+int main(int argc, char *argv[])
+{
+ int cntrl = -1; /* The fd of the pseudo-terminal controller device */
+ int slave = -1; /* The fd of the pseudo-terminal slave device */
+ pid_t pid; /* The return value of fork() */
+ int status; /* The return statuses of the parent and child functions */
+ char slave_name[PTY_MAX_NAME]; /* The filename of the slave end of the */
+ /* pseudo-terminal. */
+ char *prog; /* The name of the program (ie. argv[0]) */
+/*
+ * Check the arguments.
+ */
+ if(argc < 2) {
+ fprintf(stderr, "Usage: %s [arguments...]\n", argv[0]);
+ return 1;
+ };
+/*
+ * Get the name of the program.
+ */
+ prog = argv[0];
+/*
+ * If the user has the LC_CTYPE or LC_ALL environment variables set,
+ * enable display of characters corresponding to the specified locale.
+ */
+ (void) setlocale(LC_CTYPE, "");
+/*
+ * If the program is taking its input from a pipe or a file, or
+ * sending its output to something other than a terminal, run the
+ * program without tecla.
+ */
+ if(!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)) {
+ if(execvp(argv[1], argv + 1) < 0) {
+ fprintf(stderr, "%s: Unable to execute %s (%s).\n", prog, argv[1],
+ strerror(errno));
+ fflush(stderr);
+ _exit(1);
+ };
+ };
+/*
+ * Open the master side of a pseudo-terminal pair, and return
+ * the corresponding file descriptor and the filename of the
+ * slave end of the pseudo-terminal.
+ */
+ if(pty_open_master(prog, &cntrl, slave_name))
+ return 1;
+/*
+ * Set up a signal handler to watch for the child process exiting.
+ */
+ signal(SIGCHLD, pty_child_exited);
+/*
+ * The above signal handler sends the parent process a SIGINT signal.
+ * This signal is caught by gl_get_line(), which resets the terminal
+ * settings, and if the application signal handler for this signal
+ * doesn't abort the process, gl_get_line() returns NULL with errno
+ * set to EINTR. Arrange to ignore the signal, so that gl_get_line()
+ * returns and we have a chance to cleanup.
+ */
+ signal(SIGINT, SIG_IGN);
+/*
+ * We will read user input in one process, and run the user's program
+ * in a child process.
+ */
+ pid = fork();
+ if(pid < 0) {
+ fprintf(stderr, "%s: Unable to fork child process (%s).\n", prog,
+ strerror(errno));
+ return 1;
+ };
+/*
+ * Are we the parent?
+ */
+ if(pid!=0) {
+ status = pty_parent(prog, cntrl);
+ close(cntrl);
+ } else {
+ close(cntrl); /* The child doesn't use the slave device */
+ signal(SIGCHLD, pty_child_exited);
+ if((slave = pty_open_slave(prog, slave_name)) >= 0) {
+ status = pty_child(prog, slave, argv + 1);
+ close(slave);
+ } else {
+ status = 1;
+ };
+ };
+ return status;
+}
+
+/*.......................................................................
+ * Open the master side of a pseudo-terminal pair, and return
+ * the corresponding file descriptor and the filename of the
+ * slave end of the pseudo-terminal.
+ *
+ * Input/Output:
+ * prog const char * The name of this program.
+ * cntrl int * The file descriptor of the pseudo-terminal
+ * controller device will be assigned tp *cntrl.
+ * slave_name char * The file-name of the pseudo-terminal slave device
+ * will be recorded in slave_name[], which must have
+ * at least PTY_MAX_NAME elements.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int pty_open_master(const char *prog, int *cntrl, char *slave_name)
+{
+ char master_name[PTY_MAX_NAME]; /* The filename of the master device */
+ DIR *dir; /* The directory iterator */
+ struct dirent *file; /* A file in "/dev" */
+/*
+ * Mark the controller device as not opened yet.
+ */
+ *cntrl = -1;
+/*
+ * On systems with the Sys-V pseudo-terminal interface, we don't
+ * have to search for a free master terminal. We just open /dev/ptmx,
+ * and if there is a free master terminal device, we are given a file
+ * descriptor connected to it.
+ */
+#if HAVE_SYSV_PTY
+ *cntrl = open("/dev/ptmx", O_RDWR);
+ if(*cntrl >= 0) {
+/*
+ * Get the filename of the slave side of the pseudo-terminal.
+ */
+ char *name = ptsname(*cntrl);
+ if(name) {
+ if(strlen(name)+1 > PTY_MAX_NAME) {
+ fprintf(stderr, "%s: Slave pty filename too long.\n", prog);
+ return 1;
+ };
+ strcpy(slave_name, name);
+/*
+ * If unable to get the slave name, discard the controller file descriptor,
+ * ready to try a search instead.
+ */
+ } else {
+ close(*cntrl);
+ *cntrl = -1;
+ };
+ } else {
+#endif
+/*
+ * On systems without /dev/ptmx, or if opening /dev/ptmx failed,
+ * we open one master terminal after another, until one that isn't
+ * in use by another program is found.
+ *
+ * Open the devices directory.
+ */
+ dir = opendir(PTY_DEV_DIR);
+ if(!dir) {
+ fprintf(stderr, "%s: Couldn't open %s (%s)\n", prog, PTY_DEV_DIR,
+ strerror(errno));
+ return 1;
+ };
+/*
+ * Look for pseudo-terminal controller device files in the devices
+ * directory.
+ */
+ while(*cntrl < 0 && (file = readdir(dir))) {
+ if(strncmp(file->d_name, PTY_CNTRL, sizeof(PTY_CNTRL)-1) == 0) {
+/*
+ * Get the common extension of the control and slave filenames.
+ */
+ const char *ext = file->d_name + sizeof(PTY_CNTRL)-1;
+ if(strlen(ext) > PTY_MAX_SUFFIX)
+ continue;
+/*
+ * Attempt to open the control file.
+ */
+ strcpy(master_name, PTY_DEV_DIR);
+ strcat(master_name, PTY_CNTRL);
+ strcat(master_name, ext);
+ *cntrl = open(master_name, O_RDWR);
+ if(*cntrl < 0)
+ continue;
+/*
+ * Attempt to open the matching slave file.
+ */
+ strcpy(slave_name, PTY_DEV_DIR);
+ strcat(slave_name, PTY_SLAVE);
+ strcat(slave_name, ext);
+ };
+ };
+ closedir(dir);
+#if HAVE_SYSV_PTY
+ };
+#endif
+/*
+ * Did we fail to find a pseudo-terminal pair that we could open?
+ */
+ if(*cntrl < 0) {
+ fprintf(stderr, "%s: Unable to find a free pseudo-terminal.\n", prog);
+ return 1;
+ };
+/*
+ * System V systems require the program that opens the master to
+ * grant access to the slave side of the pseudo-terminal.
+ */
+#ifdef HAVE_SYSV_PTY
+ if(grantpt(*cntrl) < 0 ||
+ unlockpt(*cntrl) < 0) {
+ fprintf(stderr, "%s: Unable to unlock terminal (%s).\n", prog,
+ strerror(errno));
+ return 1;
+ };
+#endif
+/*
+ * Success.
+ */
+ return 0;
+}
+
+/*.......................................................................
+ * Open the slave end of a pseudo-terminal.
+ *
+ * Input:
+ * prog const char * The name of this program.
+ * slave_name char * The filename of the slave device.
+ * Output:
+ * return int The file descriptor of the successfully opened
+ * slave device, or < 0 on error.
+ */
+static int pty_open_slave(const char *prog, char *slave_name)
+{
+ int fd; /* The file descriptor of the slave device */
+/*
+ * Place the process in its own process group. In system-V based
+ * OS's, this ensures that when the pseudo-terminal is opened, it
+ * becomes the controlling terminal of the process.
+ */
+ if(setsid() < 0) {
+ fprintf(stderr, "%s: Unable to form new process group (%s).\n", prog,
+ strerror(errno));
+ return -1;
+ };
+/*
+ * Attempt to open the specified device.
+ */
+ fd = open(slave_name, O_RDWR);
+ if(fd < 0) {
+ fprintf(stderr, "%s: Unable to open pseudo-terminal slave device (%s).\n",
+ prog, strerror(errno));
+ return -1;
+ };
+/*
+ * On system-V streams based systems, we need to push the stream modules
+ * that implement pseudo-terminal and termio interfaces. At least on
+ * Solaris, which pushes these automatically when a slave is opened,
+ * this is redundant, so ignore errors when pushing the modules.
+ */
+#if HAVE_SYSV_PTY
+ (void) ioctl(fd, I_PUSH, "ptem");
+ (void) ioctl(fd, I_PUSH, "ldterm");
+/*
+ * On BSD based systems other than SunOS 4.x, the following makes the
+ * pseudo-terminal the controlling terminal of the child process.
+ * According to the pseudo-terminal example code in Steven's
+ * Advanced programming in the unix environment, the !defined(CIBAUD)
+ * part of the clause prevents this from being used under SunOS. Since
+ * I only have his code with me, and won't have access to the book,
+ * I don't know why this is necessary.
+ */
+#elif defined(TIOCSCTTY) && !defined(CIBAUD)
+ if(ioctl(fd, TIOCSCTTY, (char *) 0) < 0) {
+ fprintf(stderr, "%s: Unable to establish controlling terminal (%s).\n",
+ prog, strerror(errno));
+ close(fd);
+ return -1;
+ };
+#endif
+ return fd;
+}
+
+/*.......................................................................
+ * Read input from the controlling terminal of the program, using
+ * gl_get_line(), and feed it to the user's program running in a child
+ * process, via the controller side of the pseudo-terminal. Also pass
+ * data received from the user's program via the conroller end of
+ * the pseudo-terminal, to stdout.
+ *
+ * Input:
+ * prog const char * The name of this program.
+ * cntrl int The file descriptor of the controller end of the
+ * pseudo-terminal.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int pty_parent(const char *prog, int cntrl)
+{
+ GetLine *gl = NULL; /* The gl_get_line() resource object */
+ char *line; /* An input line read from the user */
+ char *rbuff=NULL; /* A buffer for reading from the pseudo terminal */
+/*
+ * Allocate the gl_get_line() resource object.
+ */
+ gl = new_GetLine(PTY_MAX_LINE, PTY_HIST_SIZE);
+ if(!gl)
+ return pty_stop_parent(1, cntrl, gl, rbuff);
+/*
+ * Allocate a buffer to use to accumulate bytes read from the
+ * pseudo-terminal.
+ */
+ rbuff = (char *) malloc(PTY_MAX_READ+1);
+ if(!rbuff)
+ return pty_stop_parent(1, cntrl, gl, rbuff);
+ rbuff[0] = '\0';
+/*
+ * Register an event handler to watch for data appearing from the
+ * user's program on the controller end of the pseudo terminal.
+ */
+ if(gl_watch_fd(gl, cntrl, GLFD_READ, pty_read_from_program, rbuff))
+ return pty_stop_parent(1, cntrl, gl, rbuff);
+/*
+ * Read input lines from the user and pass them on to the user's program,
+ * by writing to the controller end of the pseudo-terminal.
+ */
+ while((line=gl_get_line(gl, rbuff, NULL, 0))) {
+ if(pty_write_to_fd(cntrl, line, strlen(line)))
+ return pty_stop_parent(1, cntrl, gl, rbuff);
+ rbuff[0] = '\0';
+ };
+ return pty_stop_parent(0, cntrl, gl, rbuff);
+}
+
+/*.......................................................................
+ * This is a private return function of pty_parent(), used to release
+ * dynamically allocated resources, close the controller end of the
+ * pseudo-terminal, and wait for the child to exit. It returns the
+ * exit status of the child process, unless the caller reports an
+ * error itself, in which case the caller's error status is returned.
+ *
+ * Input:
+ * waserr int True if the caller is calling this function because
+ * an error occured.
+ * cntrl int The file descriptor of the controller end of the
+ * pseudo-terminal.
+ * gl GetLine * The resource object of gl_get_line().
+ * rbuff char * The buffer used to accumulate bytes read from
+ * the pseudo-terminal.
+ * Output:
+ * return int The desired exit status of the program.
+ */
+static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff)
+{
+ int status; /* The return status of the child process */
+/*
+ * Close the controller end of the terminal.
+ */
+ close(cntrl);
+/*
+ * Delete the resource object.
+ */
+ gl = del_GetLine(gl);
+/*
+ * Delete the read buffer.
+ */
+ if(rbuff)
+ free(rbuff);
+/*
+ * Wait for the user's program to end.
+ */
+ (void) wait(&status);
+/*
+ * Return either our error status, or the return status of the child
+ * program.
+ */
+ return waserr ? 1 : status;
+}
+
+/*.......................................................................
+ * Run the user's program, with its stdin and stdout connected to the
+ * slave end of the psuedo-terminal.
+ *
+ * Input:
+ * prog const char * The name of this program.
+ * slave int The file descriptor of the slave end of the
+ * pseudo terminal.
+ * argv char *[] The argument vector to pass to the user's program,
+ * where argv[0] is the name of the user's program,
+ * and the last argument is followed by a pointer
+ * to NULL.
+ * Output:
+ * return int If this function returns at all, an error must
+ * have occured when trying to overlay the process
+ * with the user's program. In this case 1 is
+ * returned.
+ */
+static int pty_child(const char *prog, int slave, char *argv[])
+{
+ struct termios attr; /* The terminal attributes */
+/*
+ * We need to stop the pseudo-terminal from echoing everything that we send it.
+ */
+ if(tcgetattr(slave, &attr)) {
+ fprintf(stderr, "%s: Can't get pseudo-terminal attributes (%s).\n", prog,
+ strerror(errno));
+ return 1;
+ };
+ attr.c_lflag &= ~(ECHO);
+ while(tcsetattr(slave, TCSADRAIN, &attr)) {
+ if(errno != EINTR) {
+ fprintf(stderr, "%s: tcsetattr error: %s\n", prog, strerror(errno));
+ return 1;
+ };
+ };
+/*
+ * Arrange for stdin, stdout and stderr to be connected to the slave device,
+ * ignoring errors that imply that either stdin or stdout is closed.
+ */
+ while(dup2(slave, STDIN_FILENO) < 0 && errno==EINTR)
+ ;
+ while(dup2(slave, STDOUT_FILENO) < 0 && errno==EINTR)
+ ;
+ while(dup2(slave, STDERR_FILENO) < 0 && errno==EINTR)
+ ;
+/*
+ * Run the user's program.
+ */
+ if(execvp(argv[0], argv) < 0) {
+ fprintf(stderr, "%s: Unable to execute %s (%s).\n", prog, argv[0],
+ strerror(errno));
+ fflush(stderr);
+ _exit(1);
+ };
+ return 0; /* This should never be reached */
+}
+
+/*.......................................................................
+ * This is the event-handler that is called by gl_get_line() whenever
+ * there is tet waiting to be read from the user's program, via the
+ * controller end of the pseudo-terminal. See libtecla.h for details
+ * about its arguments.
+ */
+static GL_FD_EVENT_FN(pty_read_from_program)
+{
+ char *nlptr; /* A pointer to the last newline in the accumulated string */
+ char *crptr; /* A pointer to the last '\r' in the accumulated string */
+ char *nextp; /* A pointer to the next unprocessed character */
+/*
+ * Get the read buffer in which we are accumulating a line to be
+ * forwarded to stdout.
+ */
+ char *rbuff = (char *) data;
+/*
+ * New data may arrive while we are processing the current read, and
+ * it is more efficient to display this here than to keep returning to
+ * gl_get_line() and have it display the latest prefix as a prompt,
+ * followed by the current input line, so we loop, delaying a bit at
+ * the end of each iteration to check for more data arriving from
+ * the application, before finally returning to gl_get_line() when
+ * no more input is available.
+ */
+ do {
+/*
+ * Get the current length of the output string.
+ */
+ int len = strlen(rbuff);
+/*
+ * Read the text from the program.
+ */
+ int nnew = read(fd, rbuff + len, PTY_MAX_READ - len);
+ if(nnew < 0)
+ return GLFD_ABORT;
+ len += nnew;
+/*
+ * Nul terminate the accumulated string.
+ */
+ rbuff[len] = '\0';
+/*
+ * Find the last newline and last carriage return in the buffer, if any.
+ */
+ nlptr = strrchr(rbuff, '\n');
+ crptr = strrchr(rbuff, '\r');
+/*
+ * We want to output up to just before the last newline or carriage
+ * return. If there are no newlines of carriage returns in the line,
+ * and the buffer is full, then we should output the whole line. In
+ * all cases a new output line will be started after the latest text
+ * has been output. The intention is to leave any incomplete line
+ * in the buffer, for (perhaps temporary) use as the current prompt.
+ */
+ if(nlptr) {
+ nextp = crptr && crptr < nlptr ? crptr : nlptr;
+ } else if(crptr) {
+ nextp = crptr;
+ } else if(len >= PTY_MAX_READ) {
+ nextp = rbuff + len;
+ } else {
+ nextp = NULL;
+ };
+/*
+ * Do we have any text to output yet?
+ */
+ if(nextp) {
+/*
+ * If there was already some text in rbuff before this function
+ * was called, then it will have been used as a prompt. Arrange
+ * to rewrite this prefix, plus the new suffix, by moving back to
+ * the start of the line.
+ */
+ if(len > 0)
+ (void) pty_write_to_fd(STDOUT_FILENO, "\r", 1);
+/*
+ * Write everything up to the last newline to stdout.
+ */
+ (void) pty_write_to_fd(STDOUT_FILENO, rbuff, nextp - rbuff);
+/*
+ * Start a new line.
+ */
+ (void) pty_write_to_fd(STDOUT_FILENO, "\r\n", 2);
+/*
+ * Skip trailing carriage returns and newlines.
+ */
+ while(*nextp=='\n' || *nextp=='\r')
+ nextp++;
+/*
+ * Move any unwritten text following the newline, to the start of the
+ * buffer.
+ */
+ memmove(rbuff, nextp, len - (nextp - rbuff) + 1);
+ };
+ } while(pty_master_readable(fd, PTY_READ_TIMEOUT));
+/*
+ * Make the incomplete line in the output buffer the current prompt.
+ */
+ gl_replace_prompt(gl, rbuff);
+ return GLFD_REFRESH;
+}
+
+/*.......................................................................
+ * Write a given string to a specified file descriptor.
+ *
+ * Input:
+ * fd int The file descriptor to write to.
+ * string const char * The string to write (of at least 'n' characters).
+ * n int The number of characters to write.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int pty_write_to_fd(int fd, const char *string, int n)
+{
+ int ndone = 0; /* The number of characters written so far */
+/*
+ * Do as many writes as are needed to write the whole string.
+ */
+ while(ndone < n) {
+ int nnew = write(fd, string + ndone, n - ndone);
+ if(nnew > 0)
+ ndone += nnew;
+ else if(errno != EINTR)
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This is the signal handler that is called when the child process
+ * that is running the user's program exits for any reason. It closes
+ * the slave end of the terminal, so that gl_get_line() in the parent
+ * process sees an end of file.
+ */
+static void pty_child_exited(int sig)
+{
+ raise(SIGINT);
+}
+
+/*.......................................................................
+ * Return non-zero after a given amount of time if there is data waiting
+ * to be read from a given file descriptor.
+ *
+ * Input:
+ * fd int The descriptor to watch.
+ * usec long The number of micro-seconds to wait for input to
+ * arrive before giving up.
+ * Output:
+ * return int 0 - No data is waiting to be read (or select isn't
+ * available).
+ * 1 - Data is waiting to be read.
+ */
+static int pty_master_readable(int fd, long usec)
+{
+#if HAVE_SELECT
+ fd_set rfds; /* The set of file descriptors to check */
+ struct timeval timeout; /* The timeout */
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = usec;
+ return select(fd+1, &rfds, NULL, NULL, &timeout) == 1;
+#else
+ return 0;
+#endif
+}
diff --git a/libtecla-1.4.1/expand.c b/libtecla-1.4.1/expand.c
new file mode 100644
index 0000000..c1600ab
--- /dev/null
+++ b/libtecla-1.4.1/expand.c
@@ -0,0 +1,1265 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "freelist.h"
+#include "direader.h"
+#include "pathutil.h"
+#include "homedir.h"
+#include "stringrp.h"
+#include "libtecla.h"
+
+/*
+ * Specify the number of elements to extend the files[] array by
+ * when it proves to be too small. This also sets the initial size
+ * of the array.
+ */
+#define MATCH_BLK_FACT 256
+
+/*
+ * A list of directory iterators is maintained using nodes of the
+ * following form.
+ */
+typedef struct DirNode DirNode;
+struct DirNode {
+ DirNode *next; /* The next directory in the list */
+ DirNode *prev; /* The node that precedes this node in the list */
+ DirReader *dr; /* The directory reader object */
+};
+
+typedef struct {
+ FreeList *mem; /* Memory for DirNode list nodes */
+ DirNode *head; /* The head of the list of used and unused cache nodes */
+ DirNode *next; /* The next unused node between head and tail */
+ DirNode *tail; /* The tail of the list of unused cache nodes */
+} DirCache;
+
+/*
+ * Specify how many directory cache nodes to allocate at a time.
+ */
+#define DIR_CACHE_BLK 20
+
+/*
+ * Set the maximum length allowed for usernames.
+ */
+#define USR_LEN 100
+
+/*
+ * Set the maximum length allowed for environment variable names.
+ */
+#define ENV_LEN 100
+
+/*
+ * Set the max length of the error-reporting string. There is no point
+ * in this being longer than the width of a typical terminal window.
+ * In composing error messages, I have assumed that this number is
+ * at least 80, so you don't decrease it below this number.
+ */
+#define ERRLEN 200
+
+struct ExpandFile {
+ StringGroup *sg; /* A list of string segments in which */
+ /* matching filenames are stored. */
+ DirCache cache; /* The cache of directory reader objects */
+ PathName *path; /* The pathname being matched */
+ HomeDir *home; /* Home-directory lookup object */
+ int files_dim; /* The allocated dimension of result.files[] */
+ char usrnam[USR_LEN+1]; /* A user name */
+ char envnam[ENV_LEN+1]; /* An environment variable name */
+ char errmsg[ERRLEN+1]; /* Error-report buffer */
+ FileExpansion result; /* The container used to return the results of */
+ /* expanding a path. */
+};
+
+static int ef_record_pathname(ExpandFile *ef, const char *pathname,
+ int remove_escapes);
+static char *ef_cache_pathname(ExpandFile *ef, const char *pathname,
+ int remove_escapes);
+static void ef_clear_files(ExpandFile *ef);
+
+static DirNode *ef_open_dir(ExpandFile *ef, const char *pathname);
+static DirNode *ef_close_dir(ExpandFile *ef, DirNode *node);
+static char *ef_expand_special(ExpandFile *ef, const char *path, int pathlen);
+static int ef_match_relative_pathname(ExpandFile *ef, DirReader *dr,
+ const char *pattern, int separate);
+static int ef_matches_range(int c, const char *pattern, const char **endp);
+static int ef_string_matches_pattern(const char *file, const char *pattern,
+ int xplicit, const char *nextp);
+static int ef_cmp_strings(const void *v1, const void *v2);
+
+/*.......................................................................
+ * Create the resources needed to expand filenames.
+ *
+ * Output:
+ * return ExpandFile * The new object, or NULL on error.
+ */
+ExpandFile *new_ExpandFile(void)
+{
+ ExpandFile *ef; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ ef = (ExpandFile *) malloc(sizeof(ExpandFile));
+ if(!ef) {
+ fprintf(stderr, "new_ExpandFile: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to del_ExpandFile().
+ */
+ ef->sg = NULL;
+ ef->cache.mem = NULL;
+ ef->cache.head = NULL;
+ ef->cache.next = NULL;
+ ef->cache.tail = NULL;
+ ef->path = NULL;
+ ef->home = NULL;
+ ef->result.files = NULL;
+ ef->result.nfile = 0;
+ ef->usrnam[0] = '\0';
+ ef->envnam[0] = '\0';
+ ef->errmsg[0] = '\0';
+/*
+ * Allocate a list of string segments for storing filenames.
+ */
+ ef->sg = _new_StringGroup(_pu_pathname_dim());
+ if(!ef->sg)
+ return del_ExpandFile(ef);
+/*
+ * Allocate a freelist for allocating directory cache nodes.
+ */
+ ef->cache.mem = _new_FreeList("new_ExpandFile", sizeof(DirNode), DIR_CACHE_BLK);
+ if(!ef->cache.mem)
+ return del_ExpandFile(ef);
+/*
+ * Allocate a pathname buffer.
+ */
+ ef->path = _new_PathName();
+ if(!ef->path)
+ return del_ExpandFile(ef);
+/*
+ * Allocate an object for looking up home-directories.
+ */
+ ef->home = _new_HomeDir();
+ if(!ef->home)
+ return del_ExpandFile(ef);
+/*
+ * Allocate an array for files. This will be extended later if needed.
+ */
+ ef->files_dim = MATCH_BLK_FACT;
+ ef->result.files = (char **) malloc(sizeof(ef->result.files[0]) *
+ ef->files_dim);
+ if(!ef->result.files) {
+ fprintf(stderr,
+ "new_ExpandFile: Insufficient memory to allocate array of files.\n");
+ return del_ExpandFile(ef);
+ };
+ return ef;
+}
+
+/*.......................................................................
+ * Delete a ExpandFile object.
+ *
+ * Input:
+ * ef ExpandFile * The object to be deleted.
+ * Output:
+ * return ExpandFile * The deleted object (always NULL).
+ */
+ExpandFile *del_ExpandFile(ExpandFile *ef)
+{
+ if(ef) {
+ DirNode *dnode;
+/*
+ * Delete the string segments.
+ */
+ ef->sg = _del_StringGroup(ef->sg);
+/*
+ * Delete the cached directory readers.
+ */
+ for(dnode=ef->cache.head; dnode; dnode=dnode->next)
+ dnode->dr = _del_DirReader(dnode->dr);
+/*
+ * Delete the memory from which the DirNode list was allocated, thus
+ * deleting the list at the same time.
+ */
+ ef->cache.mem = _del_FreeList("del_ExpandFile", ef->cache.mem, 1);
+ ef->cache.head = ef->cache.tail = ef->cache.next = NULL;
+/*
+ * Delete the pathname buffer.
+ */
+ ef->path = _del_PathName(ef->path);
+/*
+ * Delete the home-directory lookup object.
+ */
+ ef->home = _del_HomeDir(ef->home);
+/*
+ * Delete the array of pointers to files.
+ */
+ if(ef->result.files) {
+ free(ef->result.files);
+ ef->result.files = NULL;
+ };
+/*
+ * Delete the container.
+ */
+ free(ef);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Expand a pathname, converting ~user/ and ~/ patterns at the start
+ * of the pathname to the corresponding home directories, replacing
+ * $envvar with the value of the corresponding environment variable,
+ * and then, if there are any wildcards, matching these against existing
+ * filenames.
+ *
+ * If no errors occur, a container is returned containing the array of
+ * files that resulted from the expansion. If there were no wildcards
+ * in the input pathname, this will contain just the original pathname
+ * after expansion of ~ and $ expressions. If there were any wildcards,
+ * then the array will contain the files that matched them. Note that
+ * if there were any wildcards but no existing files match them, this
+ * is counted as an error and NULL is returned.
+ *
+ * The supported wildcards and their meanings are:
+ * * - Match any sequence of zero or more characters.
+ * ? - Match any single character.
+ * [chars] - Match any single character that appears in 'chars'.
+ * If 'chars' contains an expression of the form a-b,
+ * then any character between a and b, including a and b,
+ * matches. The '-' character looses its special meaning
+ * as a range specifier when it appears at the start
+ * of the sequence of characters.
+ * [^chars] - The same as [chars] except that it matches any single
+ * character that doesn't appear in 'chars'.
+ *
+ * Wildcard expressions are applied to individual filename components.
+ * They don't match across directory separators. A '.' character at
+ * the beginning of a filename component must also be matched
+ * explicitly by a '.' character in the input pathname, since these
+ * are UNIX's hidden files.
+ *
+ * Input:
+ * ef ExpandFile * The pathname expansion resource object.
+ * path char * The path name to be expanded.
+ * pathlen int The length of the suffix of path[] that
+ * constitutes the filename to be expanded,
+ * or -1 to specify that the whole of the
+ * path string should be used. Note that
+ * regardless of the value of this argument,
+ * path[] must contain a '\0' terminated
+ * string, since this function checks that
+ * pathlen isn't mistakenly too long.
+ * Output:
+ * return FileExpansion * A pointer to a container within the given
+ * ExpandFile object. This contains an array
+ * of the pathnames that resulted from expanding
+ * ~ and $ expressions and from matching any
+ * wildcards, sorted into lexical order.
+ * This container and its contents will be
+ * recycled on subsequent calls, so if you need
+ * to keep the results of two successive runs,
+ * you will either have to allocate a private
+ * copy of the array, or use two ExpandFile
+ * objects.
+ *
+ * On error NULL is returned. A description
+ * of the error can be acquired by calling the
+ * ef_last_error() function.
+ */
+FileExpansion *ef_expand_file(ExpandFile *ef, const char *path, int pathlen)
+{
+ DirNode *dnode; /* A directory-reader cache node */
+ const char *dirname; /* The name of the top level directory of the search */
+ const char *pptr; /* A pointer into path[] */
+ int wild; /* True if the path contains any wildcards */
+/*
+ * Check the arguments.
+ */
+ if(!ef || !path) {
+ if(ef)
+ strcpy(ef->errmsg, "ef_expand_file: NULL path argument");
+ else
+ fprintf(stderr, "ef_expand_file: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * If the caller specified that the whole of path[] be matched,
+ * work out the corresponding length.
+ */
+ if(pathlen < 0 || pathlen > strlen(path))
+ pathlen = strlen(path);
+/*
+ * Discard previous expansion results.
+ */
+ ef_clear_files(ef);
+/*
+ * Preprocess the path, expanding ~/, ~user/ and $envvar references,
+ * using ef->path as a work directory and returning a pointer to
+ * a copy of the resulting pattern in the cache.
+ */
+ path = ef_expand_special(ef, path, pathlen);
+ if(!path)
+ return NULL;
+/*
+ * Clear the pathname buffer.
+ */
+ _pn_clear_path(ef->path);
+/*
+ * Does the pathname contain any wildcards?
+ */
+ for(wild=0,pptr=path; !wild && *pptr; pptr++) {
+ switch(*pptr) {
+ case '\\': /* Skip escaped characters */
+ if(pptr[1])
+ pptr++;
+ break;
+ case '*': case '?': case '[': /* A wildcard character? */
+ wild = 1;
+ break;
+ };
+ };
+/*
+ * If there are no wildcards to match, copy the current expanded
+ * path into the output array, removing backslash escapes while doing so.
+ */
+ if(!wild) {
+ if(ef_record_pathname(ef, path, 1))
+ return NULL;
+/*
+ * Does the filename exist?
+ */
+ ef->result.exists = _pu_file_exists(ef->result.files[0]);
+/*
+ * Match wildcards against existing files.
+ */
+ } else {
+/*
+ * Only existing files that match the pattern will be returned in the
+ * cache.
+ */
+ ef->result.exists = 1;
+/*
+ * Treat matching of the root-directory as a special case since it
+ * isn't contained in a directory.
+ */
+ if(strcmp(path, FS_ROOT_DIR) == 0) {
+ if(ef_record_pathname(ef, FS_ROOT_DIR, 0))
+ return NULL;
+ } else {
+/*
+ * What should the top level directory of the search be?
+ */
+ if(strncmp(path, FS_ROOT_DIR, FS_ROOT_DIR_LEN) == 0) {
+ dirname = FS_ROOT_DIR;
+ if(!_pn_append_to_path(ef->path, FS_ROOT_DIR, -1, 0)) {
+ strcpy(ef->errmsg, "Insufficient memory to record path");
+ return NULL;
+ };
+ path += FS_ROOT_DIR_LEN;
+ } else {
+ dirname = FS_PWD;
+ };
+/*
+ * Open the top-level directory of the search.
+ */
+ dnode = ef_open_dir(ef, dirname);
+ if(!dnode)
+ return NULL;
+/*
+ * Recursively match successive directory components of the path.
+ */
+ if(ef_match_relative_pathname(ef, dnode->dr, path, 0)) {
+ dnode = ef_close_dir(ef, dnode);
+ return NULL;
+ };
+/*
+ * Cleanup.
+ */
+ dnode = ef_close_dir(ef, dnode);
+ };
+/*
+ * No files matched?
+ */
+ if(ef->result.nfile < 1) {
+ strcpy(ef->errmsg, "No files match");
+ return NULL;
+ };
+/*
+ * Sort the pathnames that matched.
+ */
+ qsort(ef->result.files, ef->result.nfile, sizeof(ef->result.files[0]),
+ ef_cmp_strings);
+ };
+/*
+ * Return the result container.
+ */
+ return &ef->result;
+}
+
+/*.......................................................................
+ * Attempt to recursively match the given pattern with the contents of
+ * the current directory, descending sub-directories as needed.
+ *
+ * Input:
+ * ef ExpandFile * The pathname expansion resource object.
+ * dr DirReader * The directory reader object of the directory
+ * to be searched.
+ * pattern const char * The pattern to match with files in the current
+ * directory.
+ * separate int When appending a filename from the specified
+ * directory to ef->pathname, insert a directory
+ * separator between the existing pathname and
+ * the filename, unless separate is zero.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int ef_match_relative_pathname(ExpandFile *ef, DirReader *dr,
+ const char *pattern, int separate)
+{
+ const char *nextp; /* The pointer to the character that follows the part */
+ /* of the pattern that is to be matched with files */
+ /* in the current directory. */
+ char *file; /* The name of the file being matched */
+ int pathlen; /* The length of ef->pathname[] on entry to this */
+ /* function */
+/*
+ * Record the current length of the pathname string recorded in
+ * ef->pathname[].
+ */
+ pathlen = strlen(ef->path->name);
+/*
+ * Get a pointer to the character that follows the end of the part of
+ * the pattern that should be matched to files within the current directory.
+ * This will either point to a directory separator, or to the '\0' terminator
+ * of the pattern string.
+ */
+ for(nextp=pattern; *nextp && strncmp(nextp, FS_DIR_SEP, FS_DIR_SEP_LEN) != 0;
+ nextp++)
+ ;
+/*
+ * Read each file from the directory, attempting to match it to the
+ * current pattern.
+ */
+ while((file=_dr_next_file(dr)) != NULL) {
+/*
+ * Does the latest file match the pattern up to nextp?
+ */
+ if(ef_string_matches_pattern(file, pattern, file[0]=='.', nextp)) {
+/*
+ * Append the new directory entry to the current matching pathname.
+ */
+ if((separate && _pn_append_to_path(ef->path, FS_DIR_SEP, -1, 0)==NULL) ||
+ _pn_append_to_path(ef->path, file, -1, 0)==NULL) {
+ strcpy(ef->errmsg, "Insufficient memory to record path");
+ return 1;
+ };
+/*
+ * If we have reached the end of the pattern, record the accumulated
+ * pathname in the list of matching files.
+ */
+ if(*nextp == '\0') {
+ if(ef_record_pathname(ef, ef->path->name, 0))
+ return 1;
+/*
+ * If the matching directory entry is a subdirectory, and the
+ * next character of the pattern is a directory separator,
+ * recursively call the current function to scan the sub-directory
+ * for matches.
+ */
+ } else if(_pu_path_is_dir(ef->path->name) &&
+ strncmp(nextp, FS_DIR_SEP, FS_DIR_SEP_LEN) == 0) {
+/*
+ * If the pattern finishes with the directory separator, then
+ * record the pathame as matching.
+ */
+ if(nextp[FS_DIR_SEP_LEN] == '\0') {
+ if(ef_record_pathname(ef, ef->path->name, 0))
+ return 1;
+/*
+ * Match files within the directory.
+ */
+ } else {
+ DirNode *subdnode = ef_open_dir(ef, ef->path->name);
+ if(subdnode) {
+ if(ef_match_relative_pathname(ef, subdnode->dr,
+ nextp+FS_DIR_SEP_LEN, 1)) {
+ subdnode = ef_close_dir(ef, subdnode);
+ return 1;
+ };
+ subdnode = ef_close_dir(ef, subdnode);
+ };
+ };
+ };
+/*
+ * Remove the latest filename from the pathname string, so that
+ * another matching file can be appended.
+ */
+ ef->path->name[pathlen] = '\0';
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Record a new matching filename.
+ *
+ * Input:
+ * ef ExpandFile * The filename-match resource object.
+ * pathname const char * The pathname to record.
+ * remove_escapes int If true, remove backslash escapes in the
+ * recorded copy of the pathname.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error (ef->errmsg will contain a
+ * description of the error).
+ */
+static int ef_record_pathname(ExpandFile *ef, const char *pathname,
+ int remove_escapes)
+{
+ char *copy; /* The recorded copy of pathname[] */
+/*
+ * Attempt to make a copy of the pathname in the cache.
+ */
+ copy = ef_cache_pathname(ef, pathname, remove_escapes);
+ if(!copy)
+ return 1;
+/*
+ * If there isn't room to record a pointer to the recorded pathname in the
+ * array of files, attempt to extend the array.
+ */
+ if(ef->result.nfile + 1 > ef->files_dim) {
+ int files_dim = ef->files_dim + MATCH_BLK_FACT;
+ char **files = (char **) realloc(ef->result.files,
+ files_dim * sizeof(files[0]));
+ if(!files) {
+ sprintf(ef->errmsg,
+ "Insufficient memory to record all of the matching filenames");
+ return 1;
+ };
+ ef->result.files = files;
+ ef->files_dim = files_dim;
+ };
+/*
+ * Record a pointer to the new match.
+ */
+ ef->result.files[ef->result.nfile++] = copy;
+ return 0;
+}
+
+/*.......................................................................
+ * Record a pathname in the cache.
+ *
+ * Input:
+ * ef ExpandFile * The filename-match resource object.
+ * pathname char * The pathname to record.
+ * remove_escapes int If true, remove backslash escapes in the
+ * copy of the pathname.
+ * Output:
+ * return char * The pointer to the copy of the pathname.
+ * On error NULL is returned and a description
+ * of the error is left in ef->errmsg[].
+ */
+static char *ef_cache_pathname(ExpandFile *ef, const char *pathname,
+ int remove_escapes)
+{
+ char *copy = _sg_store_string(ef->sg, pathname, remove_escapes);
+ if(!copy)
+ strcpy(ef->errmsg, "Insufficient memory to store pathname");
+ return copy;
+}
+
+/*.......................................................................
+ * Clear the results of the previous expansion operation, ready for the
+ * next.
+ *
+ * Input:
+ * ef ExpandFile * The pathname expansion resource object.
+ */
+static void ef_clear_files(ExpandFile *ef)
+{
+ _clr_StringGroup(ef->sg);
+ _pn_clear_path(ef->path);
+ ef->result.exists = 0;
+ ef->result.nfile = 0;
+ ef->errmsg[0] = '\0';
+ return;
+}
+
+/*.......................................................................
+ * Get a new directory reader object from the cache.
+ *
+ * Input:
+ * ef ExpandFile * The pathname expansion resource object.
+ * pathname const char * The pathname of the directory.
+ * Output:
+ * return DirNode * The cache entry of the new directory reader,
+ * or NULL on error. On error, ef->errmsg will
+ * contain a description of the error.
+ */
+static DirNode *ef_open_dir(ExpandFile *ef, const char *pathname)
+{
+ char *errmsg = NULL; /* An error message from a called function */
+ DirNode *node; /* The cache node used */
+/*
+ * Get the directory reader cache.
+ */
+ DirCache *cache = &ef->cache;
+/*
+ * Extend the cache if there are no free cache nodes.
+ */
+ if(!cache->next) {
+ node = (DirNode *) _new_FreeListNode(cache->mem);
+ if(!node) {
+ sprintf(ef->errmsg, "Insufficient memory to open a new directory");
+ return NULL;
+ };
+/*
+ * Initialize the cache node.
+ */
+ node->next = NULL;
+ node->prev = NULL;
+ node->dr = NULL;
+/*
+ * Allocate a directory reader object.
+ */
+ node->dr = _new_DirReader();
+ if(!node->dr) {
+ sprintf(ef->errmsg, "Insufficient memory to open a new directory");
+ node = (DirNode *) _del_FreeListNode(cache->mem, node);
+ return NULL;
+ };
+/*
+ * Append the node to the cache list.
+ */
+ node->prev = cache->tail;
+ if(cache->tail)
+ cache->tail->next = node;
+ else
+ cache->head = node;
+ cache->next = cache->tail = node;
+ };
+/*
+ * Get the first unused node, but don't remove it from the list yet.
+ */
+ node = cache->next;
+/*
+ * Attempt to open the specified directory.
+ */
+ if(_dr_open_dir(node->dr, pathname, &errmsg)) {
+ strncpy(ef->errmsg, errmsg, ERRLEN);
+ ef->errmsg[ERRLEN] = '\0';
+ return NULL;
+ };
+/*
+ * Now that we have successfully opened the specified directory,
+ * remove the cache node from the list, and relink the list around it.
+ */
+ cache->next = node->next;
+ if(node->prev)
+ node->prev->next = node->next;
+ else
+ cache->head = node->next;
+ if(node->next)
+ node->next->prev = node->prev;
+ else
+ cache->tail = node->prev;
+ node->next = node->prev = NULL;
+/*
+ * Return the successfully initialized cache node to the caller.
+ */
+ return node;
+}
+
+/*.......................................................................
+ * Return a directory reader object to the cache, after first closing
+ * the directory that it was managing.
+ *
+ * Input:
+ * ef ExpandFile * The pathname expansion resource object.
+ * node DirNode * The cache entry of the directory reader, as returned
+ * by ef_open_dir().
+ * Output:
+ * return DirNode * The deleted DirNode (ie. allways NULL).
+ */
+static DirNode *ef_close_dir(ExpandFile *ef, DirNode *node)
+{
+/*
+ * Get the directory reader cache.
+ */
+ DirCache *cache = &ef->cache;
+/*
+ * Close the directory.
+ */
+ _dr_close_dir(node->dr);
+/*
+ * Return the node to the tail of the cache list.
+ */
+ node->next = NULL;
+ node->prev = cache->tail;
+ if(cache->tail)
+ cache->tail->next = node;
+ else
+ cache->head = cache->tail = node;
+ if(!cache->next)
+ cache->next = node;
+ return NULL;
+}
+
+/*.......................................................................
+ * Return non-zero if the specified file name matches a given glob
+ * pattern.
+ *
+ * Input:
+ * file const char * The file-name component to be matched to the pattern.
+ * pattern const char * The start of the pattern to match against file[].
+ * xplicit int If non-zero, the first character must be matched
+ * explicitly (ie. not with a wildcard).
+ * nextp const char * The pointer to the the character following the
+ * end of the pattern in pattern[].
+ * Output:
+ * return int 0 - Doesn't match.
+ * 1 - The file-name string matches the pattern.
+ */
+static int ef_string_matches_pattern(const char *file, const char *pattern,
+ int xplicit, const char *nextp)
+{
+ const char *pptr = pattern; /* The pointer used to scan the pattern */
+ const char *fptr = file; /* The pointer used to scan the filename string */
+/*
+ * Match each character of the pattern in turn.
+ */
+ while(pptr < nextp) {
+/*
+ * Handle the next character of the pattern.
+ */
+ switch(*pptr) {
+/*
+ * A match zero-or-more characters wildcard operator.
+ */
+ case '*':
+/*
+ * Skip the '*' character in the pattern.
+ */
+ pptr++;
+/*
+ * If wildcards aren't allowed, the pattern doesn't match.
+ */
+ if(xplicit)
+ return 0;
+/*
+ * If the pattern ends with a the '*' wildcard, then the
+ * rest of the filename matches this.
+ */
+ if(pptr >= nextp)
+ return 1;
+/*
+ * Using the wildcard to match successively longer sections of
+ * the remaining characters of the filename, attempt to match
+ * the tail of the filename against the tail of the pattern.
+ */
+ for( ; *fptr; fptr++) {
+ if(ef_string_matches_pattern(fptr, pptr, 0, nextp))
+ return 1;
+ };
+ return 0; /* The pattern following the '*' didn't match */
+ break;
+/*
+ * A match-one-character wildcard operator.
+ */
+ case '?':
+/*
+ * If there is a character to be matched, skip it and advance the
+ * pattern pointer.
+ */
+ if(!xplicit && *fptr) {
+ fptr++;
+ pptr++;
+/*
+ * If we hit the end of the filename string, there is no character
+ * matching the operator, so the string doesn't match.
+ */
+ } else {
+ return 0;
+ };
+ break;
+/*
+ * A character range operator, with the character ranges enclosed
+ * in matching square brackets.
+ */
+ case '[':
+ if(xplicit || !ef_matches_range(*fptr++, ++pptr, &pptr))
+ return 0;
+ break;
+/*
+ * A backslash in the pattern prevents the following character as
+ * being seen as a special character.
+ */
+ case '\\':
+ pptr++;
+ /* Note fallthrough to default */
+/*
+ * A normal character to be matched explicitly.
+ */
+ default:
+ if(*fptr == *pptr) {
+ fptr++;
+ pptr++;
+ } else {
+ return 0;
+ };
+ break;
+ };
+/*
+ * After passing the first character, turn off the explicit match
+ * requirement.
+ */
+ xplicit = 0;
+ };
+/*
+ * To get here the pattern must have been exhausted. If the filename
+ * string matched, then the filename string must also have been
+ * exhausted.
+ */
+ return *fptr == '\0';
+}
+
+/*.......................................................................
+ * Match a character range expression terminated by an unescaped close
+ * square bracket.
+ *
+ * Input:
+ * c int The character to be matched with the range
+ * pattern.
+ * pattern const char * The range pattern to be matched (ie. after the
+ * initiating '[' character).
+ * endp const char ** On output a pointer to the character following the
+ * range expression will be assigned to *endp.
+ * Output:
+ * return int 0 - Doesn't match.
+ * 1 - The character matched.
+ */
+static int ef_matches_range(int c, const char *pattern, const char **endp)
+{
+ const char *pptr = pattern; /* The pointer used to scan the pattern */
+ int invert = 0; /* True to invert the sense of the match */
+ int matched = 0; /* True if the character matched the pattern */
+/*
+ * If the first character is a caret, the sense of the match is
+ * inverted and only if the character isn't one of those in the
+ * range, do we say that it matches.
+ */
+ if(*pptr == '^') {
+ pptr++;
+ invert = 1;
+ };
+/*
+ * The hyphen is only a special character when it follows the first
+ * character of the range (not including the caret).
+ */
+ if(*pptr == '-') {
+ pptr++;
+ if(c == '-') {
+ *endp = pptr;
+ matched = 1;
+ };
+/*
+ * Skip other leading '-' characters since they make no sense.
+ */
+ while(*pptr == '-')
+ pptr++;
+ };
+/*
+ * The hyphen is only a special character when it follows the first
+ * character of the range (not including the caret or a hyphen).
+ */
+ if(*pptr == ']') {
+ pptr++;
+ if(c == ']') {
+ *endp = pptr;
+ matched = 1;
+ };
+ };
+/*
+ * Having dealt with the characters that have special meanings at
+ * the beginning of a character range expression, see if the
+ * character matches any of the remaining characters of the range,
+ * up until a terminating ']' character is seen.
+ */
+ while(!matched && *pptr && *pptr != ']') {
+/*
+ * Is this a range of characters signaled by the two end characters
+ * separated by a hyphen?
+ */
+ if(*pptr == '-') {
+ if(pptr[1] != ']') {
+ if(c >= pptr[-1] && c <= pptr[1])
+ matched = 1;
+ pptr += 2;
+ };
+/*
+ * A normal character to be compared directly.
+ */
+ } else if(*pptr++ == c) {
+ matched = 1;
+ };
+ };
+/*
+ * Find the terminating ']'.
+ */
+ while(*pptr && *pptr != ']')
+ pptr++;
+/*
+ * Did we find a terminating ']'?
+ */
+ if(*pptr == ']') {
+ *endp = pptr + 1;
+ return matched ? !invert : invert;
+ };
+/*
+ * If the pattern didn't end with a ']' then it doesn't match, regardless
+ * of the value of the required sense of the match.
+ */
+ *endp = pptr;
+ return 0;
+}
+
+/*.......................................................................
+ * This is a qsort() comparison function used to sort strings.
+ *
+ * Input:
+ * v1, v2 void * Pointers to the two strings to be compared.
+ * Output:
+ * return int -1 -> v1 < v2.
+ * 0 -> v1 == v2
+ * 1 -> v1 > v2
+ */
+static int ef_cmp_strings(const void *v1, const void *v2)
+{
+ char * const *s1 = (char * const *) v1;
+ char * const *s2 = (char * const *) v2;
+ return strcmp(*s1, *s2);
+}
+
+/*.......................................................................
+ * Preprocess a path, expanding ~/, ~user/ and $envvar references, using
+ * ef->path as a work buffer, then copy the result into a cache entry,
+ * and return a pointer to this copy.
+ *
+ * Input:
+ * ef ExpandFile * The resource object of the file matcher.
+ * pathlen int The length of the prefix of path[] to be expanded.
+ * Output:
+ * return char * A pointer to a copy of the output path in the
+ * cache. On error NULL is returned, and a description
+ * of the error is left in ef->errmsg[].
+ */
+static char *ef_expand_special(ExpandFile *ef, const char *path, int pathlen)
+{
+ int spos; /* The index of the start of the path segment that needs */
+ /* to be copied from path[] to the output pathname. */
+ int ppos; /* The index of a character in path[] */
+ char *pptr; /* A pointer into the output path */
+ int escaped; /* True if the previous character was a '\' */
+ int i;
+/*
+ * Clear the pathname buffer.
+ */
+ _pn_clear_path(ef->path);
+/*
+ * We need to perform two passes, one to expand environment variables
+ * and a second to do tilde expansion. This caters for the case
+ * where an initial dollar expansion yields a tilde expression.
+ */
+ escaped = 0;
+ for(spos=ppos=0; ppos < pathlen; ppos++) {
+ int c = path[ppos];
+ if(escaped) {
+ escaped = 0;
+ } else if(c == '\\') {
+ escaped = 1;
+ } else if(c == '$') {
+ int envlen; /* The length of the environment variable */
+ char *value; /* The value of the environment variable */
+/*
+ * Record the preceding unrecorded part of the pathname.
+ */
+ if(spos < ppos && _pn_append_to_path(ef->path, path + spos, ppos-spos, 0)
+ == NULL) {
+ strcpy(ef->errmsg, "Insufficient memory to expand path");
+ return NULL;
+ };
+/*
+ * Skip the dollar.
+ */
+ ppos++;
+/*
+ * Copy the environment variable name that follows the dollar into
+ * ef->envnam[], stopping if a directory separator or end of string
+ * is seen.
+ */
+ for(envlen=0; envlenenvnam[envlen] = path[ppos++];
+/*
+ * If the username overflowed the buffer, treat it as invalid (note that
+ * on most unix systems only 8 characters are allowed in a username,
+ * whereas our ENV_LEN is much bigger than that.
+ */
+ if(envlen >= ENV_LEN) {
+ strcpy(ef->errmsg, "Environment variable name too long");
+ return NULL;
+ };
+/*
+ * Terminate the environment variable name.
+ */
+ ef->envnam[envlen] = '\0';
+/*
+ * Lookup the value of the environment variable.
+ */
+ value = getenv(ef->envnam);
+ if(!value) {
+ const char *fmt = "No expansion found for: $%.*s";
+ sprintf(ef->errmsg, fmt, ERRLEN - strlen(fmt), ef->envnam);
+ return NULL;
+ };
+/*
+ * Copy the value of the environment variable into the output pathname.
+ */
+ if(_pn_append_to_path(ef->path, value, -1, 0) == NULL) {
+ strcpy(ef->errmsg, "Insufficient memory to expand path");
+ return NULL;
+ };
+/*
+ * Record the start of the uncopied tail of the input pathname.
+ */
+ spos = ppos;
+ };
+ };
+/*
+ * Record the uncopied tail of the pathname.
+ */
+ if(spos < ppos && _pn_append_to_path(ef->path, path + spos, ppos-spos, 0)
+ == NULL) {
+ strcpy(ef->errmsg, "Insufficient memory to expand path");
+ return NULL;
+ };
+/*
+ * If the first character of the resulting pathname is a tilde,
+ * then attempt to substitute the home directory of the specified user.
+ */
+ pptr = ef->path->name;
+ if(*pptr == '~' && path[0] != '\\') {
+ int usrlen; /* The length of the username following the tilde */
+ const char *homedir; /* The home directory of the user */
+ int homelen; /* The length of the home directory string */
+ int plen; /* The current length of the path */
+ int skip=0; /* The number of characters to skip after the ~user */
+/*
+ * Get the current length of the output path.
+ */
+ plen = strlen(ef->path->name);
+/*
+ * Skip the tilde.
+ */
+ pptr++;
+/*
+ * Copy the optional username that follows the tilde into ef->usrnam[].
+ */
+ for(usrlen=0; usrlenusrnam[usrlen] = *pptr++;
+/*
+ * If the username overflowed the buffer, treat it as invalid (note that
+ * on most unix systems only 8 characters are allowed in a username,
+ * whereas our USR_LEN is much bigger than that.
+ */
+ if(usrlen >= USR_LEN) {
+ strcpy(ef->errmsg, "Username too long");
+ return NULL;
+ };
+/*
+ * Terminate the username string.
+ */
+ ef->usrnam[usrlen] = '\0';
+/*
+ * Lookup the home directory of the user.
+ */
+ homedir = _hd_lookup_home_dir(ef->home, ef->usrnam);
+ if(!homedir) {
+ strncpy(ef->errmsg, _hd_last_home_dir_error(ef->home), ERRLEN);
+ ef->errmsg[ERRLEN] = '\0';
+ return NULL;
+ };
+ homelen = strlen(homedir);
+/*
+ * ~user and ~ are usually followed by a directory separator to
+ * separate them from the file contained in the home directory.
+ * If the home directory is the root directory, then we don't want
+ * to follow the home directory by a directory separator, so we must
+ * erase it.
+ */
+ if(strcmp(homedir, FS_ROOT_DIR) == 0 &&
+ strncmp(pptr, FS_DIR_SEP, FS_DIR_SEP_LEN) == 0) {
+ skip = FS_DIR_SEP_LEN;
+ };
+/*
+ * If needed, increase the size of the pathname buffer to allow it
+ * to accomodate the home directory instead of the tilde expression.
+ * Note that pptr may not be valid after this call.
+ */
+ if(_pn_resize_path(ef->path, plen - usrlen - 1 - skip + homelen)==NULL) {
+ strcpy(ef->errmsg, "Insufficient memory to expand filename");
+ return NULL;
+ };
+/*
+ * Move the part of the pathname that follows the tilde expression to
+ * the end of where the home directory will need to be inserted.
+ */
+ memmove(ef->path->name + homelen,
+ ef->path->name + 1 + usrlen + skip, plen - usrlen - 1 - skip+1);
+/*
+ * Write the home directory at the beginning of the string.
+ */
+ for(i=0; ipath->name[i] = homedir[i];
+ };
+/*
+ * Copy the result into the cache, and return a pointer to the copy.
+ */
+ return ef_cache_pathname(ef, ef->path->name, 0);
+}
+
+/*.......................................................................
+ * Return a description of the last path-expansion error that occurred.
+ *
+ * Input:
+ * ef ExpandFile * The path-expansion resource object.
+ * Output:
+ * return char * The description of the last error.
+ */
+const char *ef_last_error(ExpandFile *ef)
+{
+ return ef ? ef->errmsg : "NULL ExpandFile argument";
+}
+
+/*.......................................................................
+ * Print out an array of matching files.
+ *
+ * Input:
+ * result FileExpansion * The container of the sorted array of
+ * expansions.
+ * fp FILE * The output stream to write to.
+ * term_width int The width of the terminal.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int ef_list_expansions(FileExpansion *result, FILE *fp, int term_width)
+{
+ int maxlen; /* The length of the longest matching string */
+ int width; /* The width of a column */
+ int ncol; /* The number of columns to list */
+ int nrow; /* The number of rows needed to list all of the expansions */
+ int row,col; /* The row and column being written to */
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(!result || !fp) {
+ fprintf(stderr, "ef_list_expansions: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Not enough space to list anything?
+ */
+ if(term_width < 1)
+ return 0;
+/*
+ * Work out the maximum length of the matching filenames.
+ */
+ maxlen = 0;
+ for(i=0; infile; i++) {
+ int len = strlen(result->files[i]);
+ if(len > maxlen)
+ maxlen = len;
+ };
+/*
+ * Nothing to list?
+ */
+ if(maxlen == 0)
+ return 0;
+/*
+ * Split the available terminal width into columns of maxlen + 2 characters.
+ */
+ width = maxlen + 2;
+ ncol = term_width / width;
+/*
+ * If the column width is greater than the terminal width, the matches will
+ * just have to overlap onto the next line.
+ */
+ if(ncol < 1)
+ ncol = 1;
+/*
+ * How many rows will be needed?
+ */
+ nrow = (result->nfile + ncol - 1) / ncol;
+/*
+ * Print the expansions out in ncol columns, sorted in row order within each
+ * column.
+ */
+ for(row=0; row < nrow; row++) {
+ for(col=0; col < ncol; col++) {
+ int m = col*nrow + row;
+ if(m < result->nfile) {
+ const char *filename = result->files[m];
+ if(fprintf(fp, "%s%-*s%s", filename,
+ (int) (ncol > 1 ? maxlen - strlen(filename):0), "",
+ col
+#include
+
+#include "freelist.h"
+
+typedef struct FreeListBlock FreeListBlock;
+struct FreeListBlock {
+ FreeListBlock *next; /* The next block in the list */
+ char *nodes; /* The array of free-list nodes */
+};
+
+struct FreeList {
+ size_t node_size; /* The size of a free-list node */
+ unsigned blocking_factor; /* The number of nodes per block */
+ long nbusy; /* The number of nodes that are in use */
+ FreeListBlock *block; /* The head of the list of free-list blocks */
+ void *free_list; /* The free-list of nodes */
+};
+
+static FreeListBlock *_new_FreeListBlock(FreeList *fl);
+static FreeListBlock *_del_FreeListBlock(FreeListBlock *fl);
+static void _thread_FreeListBlock(FreeList *fl, FreeListBlock *block);
+
+/*.......................................................................
+ * Allocate a new free-list from blocks of 'blocking_factor' objects of size
+ * node_size.
+ *
+ * Input:
+ * caller const char * The name of the calling function, for use in
+ * error messages, or NULL to not report errors
+ * to stderr.
+ * node_size size_t The size of the free-list nodes to be returned
+ * by _new_FreeListNode(). Use sizeof() to
+ * determine this.
+ * blocking_factor unsigned The number of objects of size 'object_size'
+ * to allocate per block.
+ * Output:
+ * return FreeList * The new freelist, or NULL on error.
+ */
+FreeList *_new_FreeList(const char *caller, size_t node_size,
+ unsigned blocking_factor)
+{
+ FreeList *fl; /* The new free-list container */
+/*
+ * When a free-list node is on the free-list, it is used as a (void *)
+ * link field. Roundup node_size to a mulitple of the size of a void
+ * pointer. This, plus the fact that the array of nodes is obtained via
+ * malloc, which returns memory suitably aligned for any object, will
+ * ensure that the first sizeof(void *) bytes of each node will be
+ * suitably aligned to use as a (void *) link pointer.
+ */
+ node_size = sizeof(void *) *
+ ((node_size + sizeof(void *) - 1) / sizeof(void *));
+/*
+ * Enfore a minimum block size.
+ */
+ if(blocking_factor < 1)
+ blocking_factor = 1;
+/*
+ * Allocate the container of the free list.
+ */
+ fl = (FreeList *) malloc(sizeof(FreeList));
+ if(!fl) {
+ if(caller)
+ fprintf(stderr, "_new_FreeList (%s): Insufficient memory.\n", caller);
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to _del_FreeList().
+ */
+ fl->node_size = node_size;
+ fl->blocking_factor = blocking_factor;
+ fl->nbusy = 0;
+ fl->block = NULL;
+ fl->free_list = NULL;
+/*
+ * Allocate the first block of memory.
+ */
+ fl->block = _new_FreeListBlock(fl);
+ if(!fl->block) {
+ if(caller)
+ fprintf(stderr, "_new_FreeList (%s): Insufficient memory.\n", caller);
+ return _del_FreeList(caller, fl, 1);
+ };
+/*
+ * Add the new list of nodes to the free-list.
+ */
+ fl->free_list = fl->block->nodes;
+/*
+ * Return the free-list for use.
+ */
+ return fl;
+}
+
+/*.......................................................................
+ * Re-thread a freelist to reclaim all allocated nodes.
+ * This function should not be called unless if it is known that none
+ * of the currently allocated nodes are still being used.
+ *
+ * Input:
+ * fl FreeList * The free-list to be reset, or NULL.
+ */
+void _rst_FreeList(FreeList *fl)
+{
+ if(fl) {
+ FreeListBlock *block;
+/*
+ * Re-thread the nodes of each block into individual free-lists.
+ */
+ for(block=fl->block; block; block=block->next)
+ _thread_FreeListBlock(fl, block);
+/*
+ * Link all of the block freelists into one large freelist.
+ */
+ fl->free_list = NULL;
+ for(block=fl->block; block; block=block->next) {
+/*
+ * Locate the last node of the current block.
+ */
+ char *last_node = block->nodes + fl->node_size *
+ (fl->blocking_factor - 1);
+/*
+ * Make the link-field of the last node point to the first
+ * node of the current freelist, then make the first node of the
+ * new block the start of the freelist.
+ */
+ *(void **)last_node = fl->free_list;
+ fl->free_list = block->nodes;
+ };
+/*
+ * All allocated nodes have now been returned to the freelist.
+ */
+ fl->nbusy = 0;
+ };
+}
+
+/*.......................................................................
+ * Delete a free-list.
+ *
+ * Input:
+ * caller const char * The name of the calling function, for use in
+ * error messages, or NULL if error messages
+ * shouldn't be reported to stderr.
+ * fl FreeList * The free-list to be deleted, or NULL.
+ * force int If force==0 then _del_FreeList() will complain
+ * and refuse to delete the free-list if any
+ * of nodes have not been returned to the free-list.
+ * If force!=0 then _del_FreeList() will not check
+ * whether any nodes are still in use and will
+ * always delete the list.
+ * Output:
+ * return FreeList * Always NULL (even if the list couldn't be
+ * deleted).
+ */
+FreeList *_del_FreeList(const char *caller, FreeList *fl, int force)
+{
+ if(fl) {
+/*
+ * Check whether any nodes are in use.
+ */
+ if(!force && _busy_FreeListNodes(fl) != 0) {
+ if(caller)
+ fprintf(stderr, "_del_FreeList (%s): %ld nodes are still in use.\n",
+ caller, _busy_FreeListNodes(fl));
+ return NULL;
+ };
+/*
+ * Delete the list blocks.
+ */
+ {
+ FreeListBlock *next = fl->block;
+ while(next) {
+ FreeListBlock *block = next;
+ next = block->next;
+ block = _del_FreeListBlock(block);
+ };
+ };
+ fl->block = NULL;
+ fl->free_list = NULL;
+/*
+ * Discard the container.
+ */
+ free(fl);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Allocate a new object from a free-list.
+ *
+ * Input:
+ * fl FreeList * The free-list to return an object from.
+ * Output:
+ * return void * A new object of the size that was specified via
+ * the node_size argument of _new_FreeList() when
+ * the free-list was created, or NULL if there
+ * is insufficient memory, or 'fl' is NULL.
+ */
+void *_new_FreeListNode(FreeList *fl)
+{
+ void *node; /* The node to be returned */
+/*
+ * Check arguments.
+ */
+ if(!fl)
+ return NULL;
+/*
+ * If the free-list has been exhausted extend it by allocating
+ * another block of nodes.
+ */
+ if(!fl->free_list) {
+ FreeListBlock *block = _new_FreeListBlock(fl);
+ if(!block)
+ return NULL;
+/*
+ * Prepend the new block to the list of free-list blocks.
+ */
+ block->next = fl->block;
+ fl->block = block;
+/*
+ * Add the new list of nodes to the free-list.
+ */
+ fl->free_list = fl->block->nodes;
+ };
+/*
+ * Remove and return a node from the front of the free list.
+ */
+ node = fl->free_list;
+ fl->free_list = *(void **)node;
+/*
+ * Record the loss of a node from the free-list.
+ */
+ fl->nbusy++;
+/*
+ * Return the node.
+ */
+ return node;
+}
+
+/*.......................................................................
+ * Return an object to the free-list that it was allocated from.
+ *
+ * Input:
+ * caller const char * The name of the calling function, for use in
+ * error messages, or NULL to not report errors
+ * to stderr.
+ * fl FreeList * The free-list from which the object was taken.
+ * object void * The node to be returned.
+ * Output:
+ * return void * Always NULL.
+ */
+void *_del_FreeListNode(FreeList *fl, void *object)
+{
+/*
+ * Check arguments.
+ */
+ if(!fl)
+ return NULL;
+/*
+ * Return the node to the head of the free list.
+ */
+ if(object) {
+ *(void **)object = fl->free_list;
+ fl->free_list = object;
+/*
+ * Record the return of the node to the free-list.
+ */
+ fl->nbusy--;
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Return a count of the number of nodes that are currently allocated.
+ *
+ * Input:
+ * fl FreeList * The list to count wrt, or NULL.
+ * Output:
+ * return long The number of nodes (or 0 if fl==NULL).
+ */
+long _busy_FreeListNodes(FreeList *fl)
+{
+ return fl ? fl->nbusy : 0;
+}
+
+/*.......................................................................
+ * Allocate a new list of free-list nodes. On return the nodes will
+ * be linked together as a list starting with the node at the lowest
+ * address and ending with a NULL next pointer.
+ *
+ * Input:
+ * fl FreeList * The free-list to allocate the list for.
+ * Output:
+ * return FreeListBlock * The new linked block of free-list nodes,
+ * or NULL on error.
+ */
+static FreeListBlock *_new_FreeListBlock(FreeList *fl)
+{
+ FreeListBlock *block; /* The new block to be returned */
+/*
+ * Allocate the container.
+ */
+ block = (FreeListBlock *) malloc(sizeof(FreeListBlock));
+ if(!block)
+ return NULL;
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to _del_FreeListBlock().
+ */
+ block->next = NULL;
+ block->nodes = NULL;
+/*
+ * Allocate the block of nodes.
+ */
+ block->nodes = (char *) malloc(fl->node_size * fl->blocking_factor);
+ if(!block->nodes)
+ return _del_FreeListBlock(block);
+/*
+ * Initialize the block as a linked list of FreeListNode's.
+ */
+ _thread_FreeListBlock(fl, block);
+ return block;
+}
+
+/*.......................................................................
+ * Link each node of a freelist block to the node that follows it.
+ *
+ * Input:
+ * fl FreeList * The freelist that contains the block.
+ * block FreeListBlock * The block to be threaded.
+ */
+static void _thread_FreeListBlock(FreeList *fl, FreeListBlock *block)
+{
+ char *mem = block->nodes;
+ int i;
+ for(i=0; iblocking_factor - 1; i++, mem += fl->node_size)
+ *(void **)mem = mem + fl->node_size; /* Link to the next node */
+ *(void **)mem = NULL; /* Terminate the list */
+}
+
+/*.......................................................................
+ * Delete a free-list block.
+ *
+ * Input:
+ * fl FreeListBlock * The block to be deleted, or NULL.
+ * Output:
+ * return FreeListBlock * Always NULL.
+ */
+static FreeListBlock *_del_FreeListBlock(FreeListBlock *fl)
+{
+ if(fl) {
+ fl->next = NULL;
+ if(fl->nodes)
+ free(fl->nodes);
+ fl->nodes = NULL;
+ free(fl);
+ };
+ return NULL;
+}
diff --git a/libtecla-1.4.1/freelist.h b/libtecla-1.4.1/freelist.h
new file mode 100644
index 0000000..84e6aef
--- /dev/null
+++ b/libtecla-1.4.1/freelist.h
@@ -0,0 +1,82 @@
+#ifndef freelist_h
+#define freelist_h
+
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * This module provides a memory allocation scheme that helps to
+ * prevent memory fragmentation by allocating large blocks of
+ * fixed sized objects and forming them into a free-list for
+ * subsequent allocations. The free-list is expanded as needed.
+ */
+typedef struct FreeList FreeList;
+
+/*
+ * Allocate a new free-list from blocks of 'blocking_factor' objects of size
+ * node_size. The node_size argument should be determined by applying
+ * the sizeof() operator to the object type that you intend to allocate from
+ * the freelist.
+ */
+FreeList *_new_FreeList(const char *caller, size_t node_size,
+ unsigned blocking_factor);
+
+/*
+ * If it is known that none of the nodes currently allocated from
+ * a freelist are still in use, the following function can be called
+ * to return all nodes to the freelist without the overhead of
+ * having to call del_FreeListNode() for every allocated node. The
+ * nodes of the freelist can then be reused by future callers to
+ * new_FreeListNode().
+ */
+void _rst_FreeList(FreeList *fl);
+
+/*
+ * Delete a free-list.
+ */
+FreeList *_del_FreeList(const char *caller, FreeList *fl, int force);
+
+/*
+ * Determine the number of nodes that are currently allocated.
+ */
+long _busy_FreeListNodes(FreeList *fl);
+
+/*
+ * Allocate a new object from a free-list.
+ */
+void *_new_FreeListNode(FreeList *fl);
+
+/*
+ * Return an object to the free-list that it was allocated from.
+ */
+void *_del_FreeListNode(FreeList *fl, void *object);
+
+#endif
diff --git a/libtecla-1.4.1/getline.c b/libtecla-1.4.1/getline.c
new file mode 100644
index 0000000..242fae3
--- /dev/null
+++ b/libtecla-1.4.1/getline.c
@@ -0,0 +1,8346 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * Standard headers.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * UNIX headers.
+ */
+#include
+#ifdef HAVE_SELECT
+#include
+#include
+#endif
+
+/*
+ * Handle the different sources of terminal control string and size
+ * information. Note that if no terminal information database is available,
+ * ANSI VT100 control sequences are used.
+ */
+#if defined(USE_TERMINFO) || defined(USE_TERMCAP)
+/*
+ * Include curses.h or ncurses/curses.h depending on which is available.
+ */
+#ifdef HAVE_CURSES_H
+#include
+#elif defined(HAVE_NCURSES_CURSES_H)
+#include
+#endif
+/*
+ * Include term.h where available.
+ */
+#if defined(HAVE_TERM_H)
+#include
+#elif defined(HAVE_NCURSES_TERM_H)
+#include
+#endif
+/*
+ * When using termcap, include termcap.h on systems that have it.
+ * Otherwise assume that all prototypes are provided by curses.h.
+ */
+#if defined(USE_TERMCAP) && defined(HAVE_TERMCAP_H)
+#include
+#endif
+/*
+ * Unfortunately both terminfo and termcap require one to use the tputs()
+ * function to output terminal control characters, and this function
+ * doesn't allow one to specify a file stream. As a result, the following
+ * file-scope variable is used to pass the current output file stream.
+ * This is bad, but there doesn't seem to be any alternative.
+ */
+static FILE *tputs_fp = NULL;
+/*
+ * Under Solaris default Curses the output function that tputs takes is
+ * declared to have a char argument. On all other systems and on Solaris
+ * X/Open Curses (Issue 4, Version 2) it expects an int argument (using
+ * c89 or options -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib
+ * selects XPG4v2 Curses on Solaris 2.6 and later).
+ *
+ * Similarly, under Mac OS X, the return value of the tputs output
+ * function is declared as void, whereas it is declared as int on
+ * other systems.
+ */
+#if defined __sun && defined __SVR4 && !defined _XOPEN_CURSES
+static int gl_tputs_putchar(char c) {return putc(c, tputs_fp);}
+#elif defined(__APPLE__) && defined(__MACH__)
+static void gl_tputs_putchar(int c) {(void) putc(c, tputs_fp);}
+#else
+static int gl_tputs_putchar(int c) {return putc(c, tputs_fp);}
+#endif
+#endif
+
+/*
+ * POSIX headers.
+ */
+#include
+#include
+
+/*
+ * Does the system provide the signal and ioctl query facility used
+ * to inform the process of terminal window size changes?
+ */
+#if defined(SIGWINCH) && defined(TIOCGWINSZ)
+#define USE_SIGWINCH 1
+#endif
+
+/*
+ * Provide typedefs for standard POSIX structures.
+ */
+typedef struct sigaction SigAction;
+typedef struct termios Termios;
+
+/*
+ * Local headers.
+ */
+#include "pathutil.h"
+#include "libtecla.h"
+#include "keytab.h"
+#include "history.h"
+#include "freelist.h"
+#include "stringrp.h"
+#include "getline.h"
+
+/*
+ * Enumerate the available editing styles.
+ */
+typedef enum {
+ GL_EMACS_MODE, /* Emacs style editing */
+ GL_VI_MODE, /* Vi style editing */
+ GL_NO_EDITOR /* Fall back to the basic OS-provided editing */
+} GlEditor;
+
+/*
+ * In vi mode, the following datatype is used to implement the
+ * undo command. It records a copy of the input line from before
+ * the command-mode action which edited the input line.
+ */
+typedef struct {
+ char *line; /* A historical copy of the input line */
+ int buff_curpos; /* The historical location of the cursor in */
+ /* line[] when the line was modified. */
+ int ntotal; /* The number of characters in line[] */
+ int saved; /* True once a line has been saved after the */
+ /* last call to gl_interpret_char(). */
+} ViUndo;
+
+/*
+ * In vi mode, the following datatype is used to record information
+ * needed by the vi-repeat-change command.
+ */
+typedef struct {
+ KtKeyFn *fn; /* The last action function that made a */
+ /* change to the line. */
+ int count; /* The repeat count that was passed to the */
+ /* above command. */
+ int input_curpos; /* Whenever vi command mode is entered, the */
+ /* the position at which it was first left */
+ /* is recorded here. */
+ int command_curpos; /* Whenever vi command mode is entered, the */
+ /* the location of the cursor is recorded */
+ /* here. */
+ char input_char; /* Commands that call gl_read_character() */
+ /* record the character here, so that it can */
+ /* used on repeating the function. */
+ int saved; /* True if a function has been saved since the */
+ /* last call to gl_interpret_char(). */
+ int active; /* True while a function is being repeated. */
+} ViRepeat;
+
+/*
+ * The following datatype is used to encapsulate information specific
+ * to vi mode.
+ */
+typedef struct {
+ ViUndo undo; /* Information needed to implement the vi */
+ /* undo command. */
+ ViRepeat repeat; /* Information needed to implement the vi */
+ /* repeat command. */
+ int command; /* True in vi command-mode */
+ int find_forward; /* True if the last character search was in the */
+ /* forward direction. */
+ int find_onto; /* True if the last character search left the */
+ /* on top of the located character, as opposed */
+ /* to just before or after it. */
+ char find_char; /* The last character sought, or '\0' if no */
+ /* searches have been performed yet. */
+} ViMode;
+
+#ifdef HAVE_SELECT
+/*
+ * Define a type for recording a file-descriptor callback and its associated
+ * data.
+ */
+typedef struct {
+ GlFdEventFn *fn; /* The callback function */
+ void *data; /* Anonymous data to pass to the callback function */
+} GlFdHandler;
+
+/*
+ * A list of nodes of the following type is used to record file-activity
+ * event handlers, but only on systems that have the select() system call.
+ */
+typedef struct GlFdNode GlFdNode;
+struct GlFdNode {
+ GlFdNode *next; /* The next in the list of nodes */
+ int fd; /* The file descriptor being watched */
+ GlFdHandler rd; /* The callback to call when fd is readable */
+ GlFdHandler wr; /* The callback to call when fd is writable */
+ GlFdHandler ur; /* The callback to call when fd has urgent data */
+};
+
+/*
+ * Set the number of the above structures to allocate every time that
+ * the freelist of GlFdNode's becomes exhausted.
+ */
+#define GLFD_FREELIST_BLOCKING 10
+
+/*
+ * Listen for and handle file-descriptor events.
+ */
+static int gl_event_handler(GetLine *gl);
+
+static int gl_call_fd_handler(GetLine *gl, GlFdHandler *gfh, int fd,
+ GlFdEvent event);
+#endif
+
+/*
+ * Each signal that gl_get_line() traps is described by a list node
+ * of the following type.
+ */
+typedef struct GlSignalNode GlSignalNode;
+struct GlSignalNode {
+ GlSignalNode *next; /* The next signal in the list */
+ int signo; /* The number of the signal */
+ sigset_t proc_mask; /* A process mask which only includes signo */
+ SigAction original; /* The signal disposition of the calling program */
+ /* for this signal. */
+ unsigned flags; /* A bitwise union of GlSignalFlags enumerators */
+ GlAfterSignal after; /* What to do after the signal has been handled */
+ int errno_value; /* What to set errno to */
+};
+
+/*
+ * Set the number of the above structures to allocate every time that
+ * the freelist of GlSignalNode's becomes exhausted.
+ */
+#define GLS_FREELIST_BLOCKING 30
+
+/*
+ * Define the contents of the GetLine object.
+ * Note that the typedef for this object can be found in libtecla.h.
+ */
+struct GetLine {
+ GlHistory *glh; /* The line-history buffer */
+ WordCompletion *cpl; /* String completion resource object */
+ CplMatchFn(*cpl_fn); /* The tab completion callback function */
+ void *cpl_data; /* Callback data to pass to cpl_fn() */
+ ExpandFile *ef; /* ~user/, $envvar and wildcard expansion */
+ /* resource object. */
+ StringGroup *capmem; /* Memory for recording terminal capability */
+ /* strings. */
+ int input_fd; /* The file descriptor to read on */
+ int output_fd; /* The file descriptor to write to */
+ FILE *input_fp; /* A stream wrapper around input_fd */
+ FILE *output_fp; /* A stream wrapper around output_fd */
+ FILE *file_fp; /* When input is being temporarily taken from */
+ /* a file, this is its file-pointer. Otherwise */
+ /* it is NULL. */
+ char *term; /* The terminal type specified on the last call */
+ /* to gl_change_terminal(). */
+ int is_term; /* True if stdin is a terminal */
+ size_t linelen; /* The max number of characters per line */
+ char *line; /* A line-input buffer of allocated size */
+ /* linelen+2. The extra 2 characters are */
+ /* reserved for "\n\0". */
+ char *cutbuf; /* A cut-buffer of the same size as line[] */
+ const char *prompt; /* The current prompt string */
+ int prompt_len; /* The length of the prompt string */
+ int prompt_changed; /* True after a callback changes the prompt */
+ int prompt_style; /* How the prompt string is displayed */
+ FreeList *sig_mem; /* Memory for nodes of the signal list */
+ GlSignalNode *sigs; /* The head of the list of signals */
+ sigset_t old_signal_set; /* The signal set on entry to gl_get_line() */
+ sigset_t new_signal_set; /* The set of signals that we are trapping */
+ Termios oldattr; /* Saved terminal attributes. */
+ KeyTab *bindings; /* A table of key-bindings */
+ int ntotal; /* The number of characters in gl->line[] */
+ int buff_curpos; /* The cursor position within gl->line[] */
+ int term_curpos; /* The cursor position on the terminal */
+ int buff_mark; /* A marker location in the buffer */
+ int insert_curpos; /* The cursor position at start of insert */
+ int insert; /* True in insert mode */
+ int number; /* If >= 0, a numeric argument is being read */
+ int endline; /* True to tell gl_get_input_line() to return */
+ /* the current contents of gl->line[] */
+ KtKeyFn *current_fn; /* The action function that is currently being */
+ /* invoked. */
+ int current_count; /* The repeat count passed to current_fn() */
+ GlhLineID preload_id; /* When not zero, this should be the ID of a */
+ /* line in the history buffer for potential */
+ /* recall. */
+ int preload_history; /* If true, preload the above history line when */
+ /* gl_get_input_line() is next called. */
+ long keyseq_count; /* The number of key sequences entered by the */
+ /* the user since new_GetLine() was called. */
+ long last_search; /* The value of oper_count during the last */
+ /* history search operation. */
+ GlEditor editor; /* The style of editing, (eg. vi or emacs) */
+ int silence_bell; /* True if gl_ring_bell() should do nothing. */
+ ViMode vi; /* Parameters used when editing in vi mode */
+ const char *left; /* The string that moves the cursor 1 character */
+ /* left. */
+ const char *right; /* The string that moves the cursor 1 character */
+ /* right. */
+ const char *up; /* The string that moves the cursor 1 character */
+ /* up. */
+ const char *down; /* The string that moves the cursor 1 character */
+ /* down. */
+ const char *home; /* The string that moves the cursor home */
+ const char *bol; /* Move cursor to beginning of line */
+ const char *clear_eol; /* The string that clears from the cursor to */
+ /* the end of the line. */
+ const char *clear_eod; /* The string that clears from the cursor to */
+ /* the end of the display. */
+ const char *u_arrow; /* The string returned by the up-arrow key */
+ const char *d_arrow; /* The string returned by the down-arrow key */
+ const char *l_arrow; /* The string returned by the left-arrow key */
+ const char *r_arrow; /* The string returned by the right-arrow key */
+ const char *sound_bell; /* The string needed to ring the terminal bell */
+ const char *bold; /* Switch to the bold font */
+ const char *underline; /* Underline subsequent characters */
+ const char *standout; /* Turn on standout mode */
+ const char *dim; /* Switch to a dim font */
+ const char *reverse; /* Turn on reverse video */
+ const char *blink; /* Switch to a blinking font */
+ const char *text_attr_off; /* Turn off all text attributes */
+ int nline; /* The height of the terminal in lines */
+ int ncolumn; /* The width of the terminal in columns */
+#ifdef USE_TERMCAP
+ char *tgetent_buf; /* The buffer that is used by tgetent() to */
+ /* store a terminal description. */
+ char *tgetstr_buf; /* The buffer that is used by tgetstr() to */
+ /* store terminal capabilities. */
+#endif
+#ifdef USE_TERMINFO
+ const char *left_n; /* The parameter string that moves the cursor */
+ /* n characters left. */
+ const char *right_n; /* The parameter string that moves the cursor */
+ /* n characters right. */
+#endif
+ char *app_file; /* The pathname of the application-specific */
+ /* .teclarc configuration file, or NULL. */
+ char *user_file; /* The pathname of the user-specific */
+ /* .teclarc configuration file, or NULL. */
+ int configured; /* True as soon as any teclarc configuration */
+ /* file has been read. */
+ int echo; /* True to display the line as it is being */
+ /* entered. If 0, only the prompt will be */
+ /* displayed, and the line will not be */
+ /* archived in the history list. */
+ int last_signal; /* The last signal that was caught by */
+ /* the last call to gl_get_line(), or -1 */
+ /* if no signal has been caught yet. */
+#ifdef HAVE_SELECT
+ FreeList *fd_node_mem; /* A freelist of GlFdNode structures */
+ GlFdNode *fd_nodes; /* The list of fd event descriptions */
+ fd_set rfds; /* The set of fds to watch for readability */
+ fd_set wfds; /* The set of fds to watch for writability */
+ fd_set ufds; /* The set of fds to watch for urgent data */
+ int max_fd; /* The maximum file-descriptor being watched */
+#endif
+};
+
+/*
+ * Define the max amount of space needed to store a termcap terminal
+ * description. Unfortunately this has to be done by guesswork, so
+ * there is the potential for buffer overflows if we guess too small.
+ * Fortunately termcap has been replaced by terminfo on most
+ * platforms, and with terminfo this isn't an issue. The value that I
+ * am using here is the conventional value, as recommended by certain
+ * web references.
+ */
+#ifdef USE_TERMCAP
+#define TERMCAP_BUF_SIZE 2048
+#endif
+
+/*
+ * Set the size of the string segments used to store terminal capability
+ * strings.
+ */
+#define CAPMEM_SEGMENT_SIZE 512
+
+/*
+ * If no terminal size information is available, substitute the
+ * following vt100 default sizes.
+ */
+#define GL_DEF_NLINE 24
+#define GL_DEF_NCOLUMN 80
+
+/*
+ * List the signals that we need to catch. In general these are
+ * those that by default terminate or suspend the process, since
+ * in such cases we need to restore terminal settings.
+ */
+static const struct GlDefSignal {
+ int signo; /* The number of the signal */
+ unsigned flags; /* A bitwise union of GlSignalFlags enumerators */
+ GlAfterSignal after; /* What to do after the signal has been delivered */
+ int errno_value; /* What to set errno to */
+} gl_signal_list[] = {
+ {SIGABRT, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+ {SIGINT, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+ {SIGTERM, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+ {SIGALRM, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+ {SIGCONT, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#if defined(SIGHUP)
+#ifdef ENOTTY
+ {SIGHUP, GLS_SUSPEND_INPUT, GLS_ABORT, ENOTTY},
+#else
+ {SIGHUP, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+#endif
+#endif
+#if defined(SIGPIPE)
+#ifdef EPIPE
+ {SIGPIPE, GLS_SUSPEND_INPUT, GLS_ABORT, EPIPE},
+#else
+ {SIGPIPE, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+#endif
+#endif
+#ifdef SIGPWR
+ {SIGPWR, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGQUIT
+ {SIGQUIT, GLS_SUSPEND_INPUT, GLS_ABORT, EINTR},
+#endif
+#ifdef SIGTSTP
+ {SIGTSTP, GLS_SUSPEND_INPUT, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGTTIN
+ {SIGTTIN, GLS_SUSPEND_INPUT, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGTTOU
+ {SIGTTOU, GLS_SUSPEND_INPUT, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGUSR1
+ {SIGUSR1, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGUSR2
+ {SIGUSR2, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGVTALRM
+ {SIGVTALRM, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGWINCH
+ {SIGWINCH, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+#ifdef SIGXCPU
+ {SIGXCPU, GLS_RESTORE_ENV, GLS_CONTINUE, 0},
+#endif
+};
+
+/*
+ * Define file-scope variables for use in signal handlers.
+ */
+static volatile sig_atomic_t gl_pending_signal = -1;
+static sigjmp_buf gl_setjmp_buffer;
+
+static void gl_signal_handler(int signo);
+
+static int gl_check_caught_signal(GetLine *gl);
+
+/*
+ * Define a tab to be a string of 8 spaces.
+ */
+#define TAB_WIDTH 8
+
+/*
+ * Does the system send us SIGWINCH signals when the terminal size
+ * changes?
+ */
+#ifdef USE_SIGWINCH
+static int gl_resize_terminal(GetLine *gl, int redisplay);
+#endif
+
+/*
+ * Getline calls this to temporarily override certain signal handlers
+ * of the calling program.
+ */
+static int gl_override_signal_handlers(GetLine *gl);
+
+/*
+ * Getline calls this to restore the signal handlers of the calling
+ * program.
+ */
+static int gl_restore_signal_handlers(GetLine *gl);
+
+/*
+ * Put the terminal into raw input mode, after saving the original
+ * terminal attributes in gl->oldattr.
+ */
+static int gl_raw_terminal_mode(GetLine *gl);
+
+/*
+ * Restore the terminal attributes from gl->oldattr.
+ */
+static int gl_restore_terminal_attributes(GetLine *gl);
+
+/*
+ * Read a line from the user in raw mode.
+ */
+static int gl_get_input_line(GetLine *gl, const char *start_line,
+ int start_pos);
+
+/*
+ * Set the largest key-sequence that can be handled.
+ */
+#define GL_KEY_MAX 64
+
+/*
+ * Handle the receipt of the potential start of a new key-sequence from
+ * the user.
+ */
+static int gl_interpret_char(GetLine *gl, char c);
+
+/*
+ * Bind a single control or meta character to an action.
+ */
+static int gl_bind_control_char(GetLine *gl, KtBinder binder,
+ char c, const char *action);
+
+/*
+ * Set up terminal-specific key bindings.
+ */
+static int gl_bind_terminal_keys(GetLine *gl);
+
+/*
+ * Lookup terminal control string and size information.
+ */
+static int gl_control_strings(GetLine *gl, const char *term);
+
+/*
+ * Wrappers around the terminfo and termcap functions that lookup
+ * strings in the terminal information databases.
+ */
+#ifdef USE_TERMINFO
+static const char *gl_tigetstr(GetLine *gl, const char *name);
+#elif defined(USE_TERMCAP)
+static const char *gl_tgetstr(GetLine *gl, const char *name, char **bufptr);
+#endif
+
+/*
+ * Output a binary string directly to the terminal.
+ */
+static int gl_output_raw_string(GetLine *gl, const char *string);
+
+/*
+ * Output a terminal control sequence.
+ */
+static int gl_output_control_sequence(GetLine *gl, int nline,
+ const char *string);
+
+/*
+ * Output a character or string to the terminal after converting tabs
+ * to spaces and control characters to a caret followed by the modified
+ * character.
+ */
+static int gl_output_char(GetLine *gl, char c, char pad);
+static int gl_output_string(GetLine *gl, const char *string, char pad);
+
+/*
+ * Delete nc characters starting from the one under the cursor.
+ * Optionally copy the deleted characters to the cut buffer.
+ */
+static int gl_delete_chars(GetLine *gl, int nc, int cut);
+
+/*
+ * Add a character to the line buffer at the current cursor position,
+ * inserting or overwriting according the current mode.
+ */
+static int gl_add_char_to_line(GetLine *gl, char c);
+
+/*
+ * Insert/append a string to the line buffer and terminal at the current
+ * cursor position.
+ */
+static int gl_add_string_to_line(GetLine *gl, const char *s);
+
+/*
+ * Read a single character from the terminal.
+ */
+static int gl_read_character(GetLine *gl, char *c);
+
+
+/*
+ * Move the terminal cursor n positions to the left or right.
+ */
+static int gl_terminal_move_cursor(GetLine *gl, int n);
+
+/*
+ * Move the terminal cursor to a given position.
+ */
+static int gl_set_term_curpos(GetLine *gl, int term_curpos);
+
+/*
+ * Set the position of the cursor both in the line input buffer and on the
+ * terminal.
+ */
+static int gl_place_cursor(GetLine *gl, int buff_curpos);
+
+/*
+ * Return the terminal cursor position that corresponds to a given
+ * line buffer cursor position.
+ */
+static int gl_buff_curpos_to_term_curpos(GetLine *gl, int buff_curpos);
+
+/*
+ * Return the number of terminal characters needed to display a
+ * given raw character.
+ */
+static int gl_displayed_char_width(GetLine *gl, char c, int term_curpos);
+
+/*
+ * Return the number of terminal characters needed to display a
+ * given substring.
+ */
+static int gl_displayed_string_width(GetLine *gl, const char *string, int nc,
+ int term_curpos);
+/*
+ * Return non-zero if 'c' is to be considered part of a word.
+ */
+static int gl_is_word_char(int c);
+
+/*
+ * Read a tecla configuration file.
+ */
+static int _gl_read_config_file(GetLine *gl, const char *filename, KtBinder who);
+
+/*
+ * Read a tecla configuration string.
+ */
+static int _gl_read_config_string(GetLine *gl, const char *buffer, KtBinder who);
+
+/*
+ * Define the callback function used by _gl_parse_config_line() to
+ * read the next character of a configuration stream.
+ */
+#define GLC_GETC_FN(fn) int (fn)(void *stream)
+typedef GLC_GETC_FN(GlcGetcFn);
+
+static GLC_GETC_FN(glc_file_getc); /* Read from a file */
+static GLC_GETC_FN(glc_buff_getc); /* Read from a string */
+
+/*
+ * Parse a single configuration command line.
+ */
+static int _gl_parse_config_line(GetLine *gl, void *stream, GlcGetcFn *getc_fn,
+ const char *origin, KtBinder who, int *lineno);
+
+/*
+ * Bind the actual arrow key bindings to match those of the symbolic
+ * arrow-key bindings.
+ */
+static int _gl_bind_arrow_keys(GetLine *gl);
+
+/*
+ * Copy the binding of the specified symbolic arrow-key binding to
+ * the terminal specific, and default arrow-key key-sequences.
+ */
+static int _gl_rebind_arrow_key(KeyTab *bindings, const char *name,
+ const char *term_seq,
+ const char *def_seq1,
+ const char *def_seq2);
+
+/*
+ * After the gl_read_from_file() action has been used to tell gl_get_line()
+ * to temporarily read input from a file, gl_revert_input() arranges
+ * for input to be reverted to the input stream last registered with
+ * gl_change_terminal().
+ */
+static void gl_revert_input(GetLine *gl);
+
+/*
+ * Flush unwritten characters to the terminal.
+ */
+static int gl_flush_output(GetLine *gl);
+
+/*
+ * Change the editor style being emulated.
+ */
+static int gl_change_editor(GetLine *gl, GlEditor editor);
+
+/*
+ * Searching in a given direction, return the index of a given (or
+ * read) character in the input line, or the character that precedes
+ * it in the specified search direction. Return -1 if not found.
+ */
+static int gl_find_char(GetLine *gl, int count, int forward, int onto, char c);
+
+/*
+ * Return the buffer index of the nth word ending after the cursor.
+ */
+static int gl_nth_word_end_forward(GetLine *gl, int n);
+
+/*
+ * Return the buffer index of the nth word start after the cursor.
+ */
+static int gl_nth_word_start_forward(GetLine *gl, int n);
+
+/*
+ * Return the buffer index of the nth word start before the cursor.
+ */
+static int gl_nth_word_start_backward(GetLine *gl, int n);
+
+/*
+ * When called when vi command mode is enabled, this function saves the
+ * current line and cursor position for potential restoration later
+ * by the vi undo command.
+ */
+static void gl_save_for_undo(GetLine *gl);
+
+/*
+ * If in vi mode, switch to vi command mode.
+ */
+static void gl_vi_command_mode(GetLine *gl);
+
+/*
+ * In vi mode this is used to delete up to or onto a given or read
+ * character in the input line. Also switch to insert mode if requested
+ * after the deletion.
+ */
+static int gl_delete_find(GetLine *gl, int count, char c, int forward,
+ int onto, int change);
+
+/*
+ * Copy the characters between the cursor and the count'th instance of
+ * a specified (or read) character in the input line, into the cut buffer.
+ */
+static int gl_copy_find(GetLine *gl, int count, char c, int forward, int onto);
+
+/*
+ * Return the line index of the parenthesis that either matches the one under
+ * the cursor, or not over a parenthesis character, the index of the next
+ * close parenthesis. Return -1 if not found.
+ */
+static int gl_index_of_matching_paren(GetLine *gl);
+
+/*
+ * Replace a malloc'd string (or NULL), with another malloc'd copy of
+ * a string (or NULL).
+ */
+static int gl_record_string(char **sptr, const char *string);
+
+/*
+ * Enumerate text display attributes as powers of two, suitable for
+ * use in a bit-mask.
+ */
+typedef enum {
+ GL_TXT_STANDOUT=1, /* Display text highlighted */
+ GL_TXT_UNDERLINE=2, /* Display text underlined */
+ GL_TXT_REVERSE=4, /* Display text with reverse video */
+ GL_TXT_BLINK=8, /* Display blinking text */
+ GL_TXT_DIM=16, /* Display text in a dim font */
+ GL_TXT_BOLD=32 /* Display text using a bold font */
+} GlTextAttr;
+
+/*
+ * Display the prompt regardless of the current visibility mode.
+ */
+static int gl_display_prompt(GetLine *gl);
+
+/*
+ * Return the number of characters used by the prompt on the terminal.
+ */
+static int gl_displayed_prompt_width(GetLine *gl);
+
+/*
+ * Prepare the return the current input line to the caller of gl_get_line().
+ */
+static int gl_line_ended(GetLine *gl, int newline_char, int archive);
+
+/*
+ * Set the maximum length of a line in a user's tecla configuration
+ * file (not counting comments).
+ */
+#define GL_CONF_BUFLEN 100
+
+/*
+ * Set the maximum number of arguments supported by individual commands
+ * in tecla configuration files.
+ */
+#define GL_CONF_MAXARG 10
+
+/*
+ * Prototype the available action functions.
+ */
+static KT_KEY_FN(gl_user_interrupt);
+static KT_KEY_FN(gl_abort);
+static KT_KEY_FN(gl_suspend);
+static KT_KEY_FN(gl_stop_output);
+static KT_KEY_FN(gl_start_output);
+static KT_KEY_FN(gl_literal_next);
+static KT_KEY_FN(gl_cursor_left);
+static KT_KEY_FN(gl_cursor_right);
+static KT_KEY_FN(gl_insert_mode);
+static KT_KEY_FN(gl_beginning_of_line);
+static KT_KEY_FN(gl_end_of_line);
+static KT_KEY_FN(gl_delete_line);
+static KT_KEY_FN(gl_kill_line);
+static KT_KEY_FN(gl_forward_word);
+static KT_KEY_FN(gl_backward_word);
+static KT_KEY_FN(gl_forward_delete_char);
+static KT_KEY_FN(gl_backward_delete_char);
+static KT_KEY_FN(gl_forward_delete_word);
+static KT_KEY_FN(gl_backward_delete_word);
+static KT_KEY_FN(gl_delete_refind);
+static KT_KEY_FN(gl_delete_invert_refind);
+static KT_KEY_FN(gl_delete_to_column);
+static KT_KEY_FN(gl_delete_to_parenthesis);
+static KT_KEY_FN(gl_forward_delete_find);
+static KT_KEY_FN(gl_backward_delete_find);
+static KT_KEY_FN(gl_forward_delete_to);
+static KT_KEY_FN(gl_backward_delete_to);
+static KT_KEY_FN(gl_upcase_word);
+static KT_KEY_FN(gl_downcase_word);
+static KT_KEY_FN(gl_capitalize_word);
+static KT_KEY_FN(gl_redisplay);
+static KT_KEY_FN(gl_clear_screen);
+static KT_KEY_FN(gl_transpose_chars);
+static KT_KEY_FN(gl_set_mark);
+static KT_KEY_FN(gl_exchange_point_and_mark);
+static KT_KEY_FN(gl_kill_region);
+static KT_KEY_FN(gl_copy_region_as_kill);
+static KT_KEY_FN(gl_yank);
+static KT_KEY_FN(gl_up_history);
+static KT_KEY_FN(gl_down_history);
+static KT_KEY_FN(gl_history_search_backward);
+static KT_KEY_FN(gl_history_re_search_backward);
+static KT_KEY_FN(gl_history_search_forward);
+static KT_KEY_FN(gl_history_re_search_forward);
+static KT_KEY_FN(gl_complete_word);
+static KT_KEY_FN(gl_expand_filename);
+static KT_KEY_FN(gl_del_char_or_list_or_eof);
+static KT_KEY_FN(gl_list_or_eof);
+static KT_KEY_FN(gl_read_from_file);
+static KT_KEY_FN(gl_beginning_of_history);
+static KT_KEY_FN(gl_end_of_history);
+static KT_KEY_FN(gl_digit_argument);
+static KT_KEY_FN(gl_newline);
+static KT_KEY_FN(gl_repeat_history);
+static KT_KEY_FN(gl_vi_insert);
+static KT_KEY_FN(gl_vi_overwrite);
+static KT_KEY_FN(gl_change_case);
+static KT_KEY_FN(gl_vi_insert_at_bol);
+static KT_KEY_FN(gl_vi_append_at_eol);
+static KT_KEY_FN(gl_vi_append);
+static KT_KEY_FN(gl_list_glob);
+static KT_KEY_FN(gl_backward_kill_line);
+static KT_KEY_FN(gl_goto_column);
+static KT_KEY_FN(gl_forward_to_word);
+static KT_KEY_FN(gl_vi_replace_char);
+static KT_KEY_FN(gl_vi_change_rest_of_line);
+static KT_KEY_FN(gl_vi_change_line);
+static KT_KEY_FN(gl_vi_change_to_bol);
+static KT_KEY_FN(gl_vi_change_refind);
+static KT_KEY_FN(gl_vi_change_invert_refind);
+static KT_KEY_FN(gl_vi_change_to_column);
+static KT_KEY_FN(gl_vi_change_to_parenthesis);
+static KT_KEY_FN(gl_vi_forward_change_word);
+static KT_KEY_FN(gl_vi_backward_change_word);
+static KT_KEY_FN(gl_vi_forward_change_find);
+static KT_KEY_FN(gl_vi_backward_change_find);
+static KT_KEY_FN(gl_vi_forward_change_to);
+static KT_KEY_FN(gl_vi_backward_change_to);
+static KT_KEY_FN(gl_vi_forward_change_char);
+static KT_KEY_FN(gl_vi_backward_change_char);
+static KT_KEY_FN(gl_forward_copy_char);
+static KT_KEY_FN(gl_backward_copy_char);
+static KT_KEY_FN(gl_forward_find_char);
+static KT_KEY_FN(gl_backward_find_char);
+static KT_KEY_FN(gl_forward_to_char);
+static KT_KEY_FN(gl_backward_to_char);
+static KT_KEY_FN(gl_repeat_find_char);
+static KT_KEY_FN(gl_invert_refind_char);
+static KT_KEY_FN(gl_append_yank);
+static KT_KEY_FN(gl_backward_copy_word);
+static KT_KEY_FN(gl_forward_copy_word);
+static KT_KEY_FN(gl_copy_to_bol);
+static KT_KEY_FN(gl_copy_refind);
+static KT_KEY_FN(gl_copy_invert_refind);
+static KT_KEY_FN(gl_copy_to_column);
+static KT_KEY_FN(gl_copy_to_parenthesis);
+static KT_KEY_FN(gl_copy_rest_of_line);
+static KT_KEY_FN(gl_copy_line);
+static KT_KEY_FN(gl_backward_copy_find);
+static KT_KEY_FN(gl_forward_copy_find);
+static KT_KEY_FN(gl_backward_copy_to);
+static KT_KEY_FN(gl_forward_copy_to);
+static KT_KEY_FN(gl_vi_undo);
+static KT_KEY_FN(gl_emacs_editing_mode);
+static KT_KEY_FN(gl_vi_editing_mode);
+static KT_KEY_FN(gl_ring_bell);
+static KT_KEY_FN(gl_vi_repeat_change);
+static KT_KEY_FN(gl_find_parenthesis);
+static KT_KEY_FN(gl_read_init_files);
+static KT_KEY_FN(gl_list_history);
+
+/*
+ * Name the available action functions.
+ */
+static const struct {const char *name; KT_KEY_FN(*fn);} gl_actions[] = {
+ {"user-interrupt", gl_user_interrupt},
+ {"abort", gl_abort},
+ {"suspend", gl_suspend},
+ {"stop-output", gl_stop_output},
+ {"start-output", gl_start_output},
+ {"literal-next", gl_literal_next},
+ {"cursor-right", gl_cursor_right},
+ {"cursor-left", gl_cursor_left},
+ {"insert-mode", gl_insert_mode},
+ {"beginning-of-line", gl_beginning_of_line},
+ {"end-of-line", gl_end_of_line},
+ {"delete-line", gl_delete_line},
+ {"kill-line", gl_kill_line},
+ {"forward-word", gl_forward_word},
+ {"backward-word", gl_backward_word},
+ {"forward-delete-char", gl_forward_delete_char},
+ {"backward-delete-char", gl_backward_delete_char},
+ {"forward-delete-word", gl_forward_delete_word},
+ {"backward-delete-word", gl_backward_delete_word},
+ {"delete-refind", gl_delete_refind},
+ {"delete-invert-refind", gl_delete_invert_refind},
+ {"delete-to-column", gl_delete_to_column},
+ {"delete-to-parenthesis", gl_delete_to_parenthesis},
+ {"forward-delete-find", gl_forward_delete_find},
+ {"backward-delete-find", gl_backward_delete_find},
+ {"forward-delete-to", gl_forward_delete_to},
+ {"backward-delete-to", gl_backward_delete_to},
+ {"upcase-word", gl_upcase_word},
+ {"downcase-word", gl_downcase_word},
+ {"capitalize-word", gl_capitalize_word},
+ {"redisplay", gl_redisplay},
+ {"clear-screen", gl_clear_screen},
+ {"transpose-chars", gl_transpose_chars},
+ {"set-mark", gl_set_mark},
+ {"exchange-point-and-mark", gl_exchange_point_and_mark},
+ {"kill-region", gl_kill_region},
+ {"copy-region-as-kill", gl_copy_region_as_kill},
+ {"yank", gl_yank},
+ {"up-history", gl_up_history},
+ {"down-history", gl_down_history},
+ {"history-search-backward", gl_history_search_backward},
+ {"history-re-search-backward", gl_history_re_search_backward},
+ {"history-search-forward", gl_history_search_forward},
+ {"history-re-search-forward", gl_history_re_search_forward},
+ {"complete-word", gl_complete_word},
+ {"expand-filename", gl_expand_filename},
+ {"del-char-or-list-or-eof", gl_del_char_or_list_or_eof},
+ {"read-from-file", gl_read_from_file},
+ {"beginning-of-history", gl_beginning_of_history},
+ {"end-of-history", gl_end_of_history},
+ {"digit-argument", gl_digit_argument},
+ {"newline", gl_newline},
+ {"repeat-history", gl_repeat_history},
+ {"vi-insert", gl_vi_insert},
+ {"vi-overwrite", gl_vi_overwrite},
+ {"vi-insert-at-bol", gl_vi_insert_at_bol},
+ {"vi-append-at-eol", gl_vi_append_at_eol},
+ {"vi-append", gl_vi_append},
+ {"change-case", gl_change_case},
+ {"list-glob", gl_list_glob},
+ {"backward-kill-line", gl_backward_kill_line},
+ {"goto-column", gl_goto_column},
+ {"forward-to-word", gl_forward_to_word},
+ {"vi-replace-char", gl_vi_replace_char},
+ {"vi-change-rest-of-line", gl_vi_change_rest_of_line},
+ {"vi-change-line", gl_vi_change_line},
+ {"vi-change-to-bol", gl_vi_change_to_bol},
+ {"vi-change-refind", gl_vi_change_refind},
+ {"vi-change-invert-refind", gl_vi_change_invert_refind},
+ {"vi-change-to-column", gl_vi_change_to_column},
+ {"vi-change-to-parenthesis", gl_vi_change_to_parenthesis},
+ {"forward-copy-char", gl_forward_copy_char},
+ {"backward-copy-char", gl_backward_copy_char},
+ {"forward-find-char", gl_forward_find_char},
+ {"backward-find-char", gl_backward_find_char},
+ {"forward-to-char", gl_forward_to_char},
+ {"backward-to-char", gl_backward_to_char},
+ {"repeat-find-char", gl_repeat_find_char},
+ {"invert-refind-char", gl_invert_refind_char},
+ {"append-yank", gl_append_yank},
+ {"backward-copy-word", gl_backward_copy_word},
+ {"forward-copy-word", gl_forward_copy_word},
+ {"copy-to-bol", gl_copy_to_bol},
+ {"copy-refind", gl_copy_refind},
+ {"copy-invert-refind", gl_copy_invert_refind},
+ {"copy-to-column", gl_copy_to_column},
+ {"copy-to-parenthesis", gl_copy_to_parenthesis},
+ {"copy-rest-of-line", gl_copy_rest_of_line},
+ {"copy-line", gl_copy_line},
+ {"backward-copy-find", gl_backward_copy_find},
+ {"forward-copy-find", gl_forward_copy_find},
+ {"backward-copy-to", gl_backward_copy_to},
+ {"forward-copy-to", gl_forward_copy_to},
+ {"list-or-eof", gl_list_or_eof},
+ {"vi-undo", gl_vi_undo},
+ {"vi-backward-change-word", gl_vi_backward_change_word},
+ {"vi-forward-change-word", gl_vi_forward_change_word},
+ {"vi-backward-change-find", gl_vi_backward_change_find},
+ {"vi-forward-change-find", gl_vi_forward_change_find},
+ {"vi-backward-change-to", gl_vi_backward_change_to},
+ {"vi-forward-change-to", gl_vi_forward_change_to},
+ {"vi-backward-change-char", gl_vi_backward_change_char},
+ {"vi-forward-change-char", gl_vi_forward_change_char},
+ {"emacs-mode", gl_emacs_editing_mode},
+ {"vi-mode", gl_vi_editing_mode},
+ {"ring-bell", gl_ring_bell},
+ {"vi-repeat-change", gl_vi_repeat_change},
+ {"find-parenthesis", gl_find_parenthesis},
+ {"read-init-files", gl_read_init_files},
+ {"list-history", gl_list_history},
+};
+
+/*
+ * Define the default key-bindings in emacs mode.
+ */
+static const KtKeyBinding gl_emacs_bindings[] = {
+ {"right", "cursor-right"},
+ {"^F", "cursor-right"},
+ {"left", "cursor-left"},
+ {"^B", "cursor-left"},
+ {"M-i", "insert-mode"},
+ {"M-I", "insert-mode"},
+ {"^A", "beginning-of-line"},
+ {"^E", "end-of-line"},
+ {"^U", "delete-line"},
+ {"^K", "kill-line"},
+ {"M-f", "forward-word"},
+ {"M-F", "forward-word"},
+ {"M-b", "backward-word"},
+ {"M-B", "backward-word"},
+ {"^D", "del-char-or-list-or-eof"},
+ {"^H", "backward-delete-char"},
+ {"^?", "backward-delete-char"},
+ {"M-d", "forward-delete-word"},
+ {"M-D", "forward-delete-word"},
+ {"M-^H", "backward-delete-word"},
+ {"M-^?", "backward-delete-word"},
+ {"M-u", "upcase-word"},
+ {"M-U", "upcase-word"},
+ {"M-l", "downcase-word"},
+ {"M-L", "downcase-word"},
+ {"M-c", "capitalize-word"},
+ {"M-C", "capitalize-word"},
+ {"^R", "redisplay"},
+ {"^L", "clear-screen"},
+ {"^T", "transpose-chars"},
+ {"^@", "set-mark"},
+ {"^X^X", "exchange-point-and-mark"},
+ {"^W", "kill-region"},
+ {"M-w", "copy-region-as-kill"},
+ {"M-W", "copy-region-as-kill"},
+ {"^Y", "yank"},
+ {"^P", "up-history"},
+ {"up", "up-history"},
+ {"^N", "down-history"},
+ {"down", "down-history"},
+ {"M-p", "history-search-backward"},
+ {"M-P", "history-search-backward"},
+ {"M-n", "history-search-forward"},
+ {"M-N", "history-search-forward"},
+ {"\t", "complete-word"},
+ {"^X*", "expand-filename"},
+ {"^X^F", "read-from-file"},
+ {"^X^R", "read-init-files"},
+ {"^Xg", "list-glob"},
+ {"^XG", "list-glob"},
+ {"^Xh", "list-history"},
+ {"^XH", "list-history"},
+ {"M-<", "beginning-of-history"},
+ {"M->", "end-of-history"},
+ {"M-0", "digit-argument"},
+ {"M-1", "digit-argument"},
+ {"M-2", "digit-argument"},
+ {"M-3", "digit-argument"},
+ {"M-4", "digit-argument"},
+ {"M-5", "digit-argument"},
+ {"M-6", "digit-argument"},
+ {"M-7", "digit-argument"},
+ {"M-8", "digit-argument"},
+ {"M-9", "digit-argument"},
+ {"\r", "newline"},
+ {"\n", "newline"},
+ {"M-o", "repeat-history"},
+ {"M-C-v", "vi-mode"},
+};
+
+/*
+ * Define the default key-bindings in vi mode. Note that in vi-mode
+ * meta-key bindings are command-mode bindings. For example M-i first
+ * switches to command mode if not already in that mode, then moves
+ * the cursor one position right, as in vi.
+ */
+static const KtKeyBinding gl_vi_bindings[] = {
+ {"^D", "list-or-eof"},
+ {"^G", "list-glob"},
+ {"^H", "backward-delete-char"},
+ {"\t", "complete-word"},
+ {"\r", "newline"},
+ {"\n", "newline"},
+ {"^L", "clear-screen"},
+ {"^N", "down-history"},
+ {"^P", "up-history"},
+ {"^R", "redisplay"},
+ {"^U", "backward-kill-line"},
+ {"^W", "backward-delete-word"},
+ {"^X^F", "read-from-file"},
+ {"^X^R", "read-init-files"},
+ {"^X*", "expand-filename"},
+ {"^?", "backward-delete-char"},
+ {"M- ", "cursor-right"},
+ {"M-$", "end-of-line"},
+ {"M-*", "expand-filename"},
+ {"M-+", "down-history"},
+ {"M--", "up-history"},
+ {"M-<", "beginning-of-history"},
+ {"M->", "end-of-history"},
+ {"M-^", "beginning-of-line"},
+ {"M-;", "repeat-find-char"},
+ {"M-,", "invert-refind-char"},
+ {"M-|", "goto-column"},
+ {"M-~", "change-case"},
+ {"M-.", "vi-repeat-change"},
+ {"M-%", "find-parenthesis"},
+ {"M-0", "digit-argument"},
+ {"M-1", "digit-argument"},
+ {"M-2", "digit-argument"},
+ {"M-3", "digit-argument"},
+ {"M-4", "digit-argument"},
+ {"M-5", "digit-argument"},
+ {"M-6", "digit-argument"},
+ {"M-7", "digit-argument"},
+ {"M-8", "digit-argument"},
+ {"M-9", "digit-argument"},
+ {"M-a", "vi-append"},
+ {"M-A", "vi-append-at-eol"},
+ {"M-b", "backward-word"},
+ {"M-B", "backward-word"},
+ {"M-C", "vi-change-rest-of-line"},
+ {"M-cb", "vi-backward-change-word"},
+ {"M-cB", "vi-backward-change-word"},
+ {"M-cc", "vi-change-line"},
+ {"M-ce", "vi-forward-change-word"},
+ {"M-cE", "vi-forward-change-word"},
+ {"M-cw", "vi-forward-change-word"},
+ {"M-cW", "vi-forward-change-word"},
+ {"M-cF", "vi-backward-change-find"},
+ {"M-cf", "vi-forward-change-find"},
+ {"M-cT", "vi-backward-change-to"},
+ {"M-ct", "vi-forward-change-to"},
+ {"M-c;", "vi-change-refind"},
+ {"M-c,", "vi-change-invert-refind"},
+ {"M-ch", "vi-backward-change-char"},
+ {"M-c^H", "vi-backward-change-char"},
+ {"M-c^?", "vi-backward-change-char"},
+ {"M-cl", "vi-forward-change-char"},
+ {"M-c ", "vi-forward-change-char"},
+ {"M-c^", "vi-change-to-bol"},
+ {"M-c0", "vi-change-to-bol"},
+ {"M-c$", "vi-change-rest-of-line"},
+ {"M-c|", "vi-change-to-column"},
+ {"M-c%", "vi-change-to-parenthesis"},
+ {"M-dh", "backward-delete-char"},
+ {"M-d^H", "backward-delete-char"},
+ {"M-d^?", "backward-delete-char"},
+ {"M-dl", "forward-delete-char"},
+ {"M-d ", "forward-delete-char"},
+ {"M-dd", "delete-line"},
+ {"M-db", "backward-delete-word"},
+ {"M-dB", "backward-delete-word"},
+ {"M-de", "forward-delete-word"},
+ {"M-dE", "forward-delete-word"},
+ {"M-dw", "forward-delete-word"},
+ {"M-dW", "forward-delete-word"},
+ {"M-dF", "backward-delete-find"},
+ {"M-df", "forward-delete-find"},
+ {"M-dT", "backward-delete-to"},
+ {"M-dt", "forward-delete-to"},
+ {"M-d;", "delete-refind"},
+ {"M-d,", "delete-invert-refind"},
+ {"M-d^", "backward-kill-line"},
+ {"M-d0", "backward-kill-line"},
+ {"M-d$", "kill-line"},
+ {"M-D", "kill-line"},
+ {"M-d|", "delete-to-column"},
+ {"M-d%", "delete-to-parenthesis"},
+ {"M-e", "forward-word"},
+ {"M-E", "forward-word"},
+ {"M-f", "forward-find-char"},
+ {"M-F", "backward-find-char"},
+ {"M--", "up-history"},
+ {"M-h", "cursor-left"},
+ {"M-H", "beginning-of-history"},
+ {"M-i", "vi-insert"},
+ {"M-I", "vi-insert-at-bol"},
+ {"M-j", "down-history"},
+ {"M-J", "history-search-forward"},
+ {"M-k", "up-history"},
+ {"M-K", "history-search-backward"},
+ {"M-l", "cursor-right"},
+ {"M-L", "end-of-history"},
+ {"M-n", "history-re-search-forward"},
+ {"M-N", "history-re-search-backward"},
+ {"M-p", "append-yank"},
+ {"M-P", "yank"},
+ {"M-r", "vi-replace-char"},
+ {"M-R", "vi-overwrite"},
+ {"M-s", "vi-forward-change-char"},
+ {"M-S", "vi-change-line"},
+ {"M-t", "forward-to-char"},
+ {"M-T", "backward-to-char"},
+ {"M-u", "vi-undo"},
+ {"M-w", "forward-to-word"},
+ {"M-W", "forward-to-word"},
+ {"M-x", "forward-delete-char"},
+ {"M-X", "backward-delete-char"},
+ {"M-yh", "backward-copy-char"},
+ {"M-y^H", "backward-copy-char"},
+ {"M-y^?", "backward-copy-char"},
+ {"M-yl", "forward-copy-char"},
+ {"M-y ", "forward-copy-char"},
+ {"M-ye", "forward-copy-word"},
+ {"M-yE", "forward-copy-word"},
+ {"M-yw", "forward-copy-word"},
+ {"M-yW", "forward-copy-word"},
+ {"M-yb", "backward-copy-word"},
+ {"M-yB", "backward-copy-word"},
+ {"M-yf", "forward-copy-find"},
+ {"M-yF", "backward-copy-find"},
+ {"M-yt", "forward-copy-to"},
+ {"M-yT", "backward-copy-to"},
+ {"M-y;", "copy-refind"},
+ {"M-y,", "copy-invert-refind"},
+ {"M-y^", "copy-to-bol"},
+ {"M-y0", "copy-to-bol"},
+ {"M-y$", "copy-rest-of-line"},
+ {"M-yy", "copy-line"},
+ {"M-Y", "copy-line"},
+ {"M-y|", "copy-to-column"},
+ {"M-y%", "copy-to-parenthesis"},
+ {"M-^E", "emacs-mode"},
+ {"M-^H", "cursor-left"},
+ {"M-^?", "cursor-left"},
+ {"M-^L", "clear-screen"},
+ {"M-^N", "down-history"},
+ {"M-^P", "up-history"},
+ {"M-^R", "redisplay"},
+ {"M-^D", "list-or-eof"},
+ {"M-\r", "newline"},
+ {"M-\t", "complete-word"},
+ {"M-\n", "newline"},
+ {"M-^X^R", "read-init-files"},
+ {"M-^Xh", "list-history"},
+ {"M-^XH", "list-history"},
+ {"down", "down-history"},
+ {"up", "up-history"},
+ {"left", "cursor-left"},
+ {"right", "cursor-right"},
+};
+
+/*.......................................................................
+ * Create a new GetLine object.
+ *
+ * Input:
+ * linelen size_t The maximum line length to allow for.
+ * histlen size_t The number of bytes to allocate for recording
+ * a circular buffer of history lines.
+ * Output:
+ * return GetLine * The new object, or NULL on error.
+ */
+GetLine *new_GetLine(size_t linelen, size_t histlen)
+{
+ GetLine *gl; /* The object to be returned */
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(linelen < 10) {
+ fprintf(stderr, "new_GetLine: Line length too small.\n");
+ return NULL;
+ };
+/*
+ * Allocate the container.
+ */
+ gl = (GetLine *) malloc(sizeof(GetLine));
+ if(!gl) {
+ fprintf(stderr, "new_GetLine: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to del_GetLine().
+ */
+ gl->glh = NULL;
+ gl->cpl = NULL;
+ gl->cpl_fn = cpl_file_completions;
+ gl->cpl_data = NULL;
+ gl->ef = NULL;
+ gl->capmem = NULL;
+ gl->term = NULL;
+ gl->is_term = 0;
+ gl->input_fd = -1;
+ gl->output_fd = -1;
+ gl->input_fp = NULL;
+ gl->output_fp = NULL;
+ gl->file_fp = NULL;
+ gl->linelen = linelen;
+ gl->line = NULL;
+ gl->cutbuf = NULL;
+ gl->linelen = linelen;
+ gl->prompt = "";
+ gl->prompt_len = 0;
+ gl->prompt_changed = 0;
+ gl->prompt_style = GL_LITERAL_PROMPT;
+ gl->vi.undo.line = NULL;
+ gl->vi.undo.buff_curpos = 0;
+ gl->vi.undo.ntotal = 0;
+ gl->vi.undo.saved = 0;
+ gl->vi.repeat.fn = 0;
+ gl->vi.repeat.count = 0;
+ gl->vi.repeat.input_curpos = 0;
+ gl->vi.repeat.command_curpos = 0;
+ gl->vi.repeat.input_char = '\0';
+ gl->vi.repeat.saved = 0;
+ gl->vi.repeat.active = 0;
+ gl->sig_mem = NULL;
+ gl->sigs = NULL;
+ sigemptyset(&gl->old_signal_set);
+ sigemptyset(&gl->new_signal_set);
+ gl->bindings = NULL;
+ gl->ntotal = 0;
+ gl->buff_curpos = 0;
+ gl->term_curpos = 0;
+ gl->buff_mark = 0;
+ gl->insert_curpos = 0;
+ gl->insert = 1;
+ gl->number = -1;
+ gl->endline = 0;
+ gl->current_fn = 0;
+ gl->current_count = 0;
+ gl->preload_id = 0;
+ gl->preload_history = 0;
+ gl->keyseq_count = 0;
+ gl->last_search = -1;
+ gl->editor = GL_EMACS_MODE;
+ gl->silence_bell = 0;
+ gl->vi.command = 0;
+ gl->vi.find_forward = 0;
+ gl->vi.find_onto = 0;
+ gl->vi.find_char = '\0';
+ gl->left = NULL;
+ gl->right = NULL;
+ gl->up = NULL;
+ gl->down = NULL;
+ gl->home = NULL;
+ gl->bol = 0;
+ gl->clear_eol = NULL;
+ gl->clear_eod = NULL;
+ gl->u_arrow = NULL;
+ gl->d_arrow = NULL;
+ gl->l_arrow = NULL;
+ gl->r_arrow = NULL;
+ gl->sound_bell = NULL;
+ gl->bold = NULL;
+ gl->underline = NULL;
+ gl->standout = NULL;
+ gl->dim = NULL;
+ gl->reverse = NULL;
+ gl->blink = NULL;
+ gl->text_attr_off = NULL;
+ gl->nline = 0;
+ gl->ncolumn = 0;
+#ifdef USE_TERMINFO
+ gl->left_n = NULL;
+ gl->right_n = NULL;
+#elif defined(USE_TERMCAP)
+ gl->tgetent_buf = NULL;
+ gl->tgetstr_buf = NULL;
+#endif
+ gl->app_file = NULL;
+ gl->user_file = NULL;
+ gl->configured = 0;
+ gl->echo = 1;
+ gl->last_signal = -1;
+#ifdef HAVE_SELECT
+ gl->fd_node_mem = NULL;
+ gl->fd_nodes = NULL;
+ FD_ZERO(&gl->rfds);
+ FD_ZERO(&gl->wfds);
+ FD_ZERO(&gl->ufds);
+ gl->max_fd = 0;
+#endif
+/*
+ * Allocate the history buffer.
+ */
+ gl->glh = _new_GlHistory(histlen);
+ if(!gl->glh)
+ return del_GetLine(gl);
+/*
+ * Allocate the resource object for file-completion.
+ */
+ gl->cpl = new_WordCompletion();
+ if(!gl->cpl)
+ return del_GetLine(gl);
+/*
+ * Allocate the resource object for file-completion.
+ */
+ gl->ef = new_ExpandFile();
+ if(!gl->ef)
+ return del_GetLine(gl);
+/*
+ * Allocate a string-segment memory allocator for use in storing terminal
+ * capablity strings.
+ */
+ gl->capmem = _new_StringGroup(CAPMEM_SEGMENT_SIZE);
+ if(!gl->capmem)
+ return del_GetLine(gl);
+/*
+ * Allocate a line buffer, leaving 2 extra characters for the terminating
+ * '\n' and '\0' characters
+ */
+ gl->line = (char *) malloc(linelen + 2);
+ if(!gl->line) {
+ fprintf(stderr,
+ "new_GetLine: Insufficient memory to allocate line buffer.\n");
+ return del_GetLine(gl);
+ };
+ gl->line[0] = '\0';
+/*
+ * Allocate a cut buffer.
+ */
+ gl->cutbuf = (char *) malloc(linelen + 2);
+ if(!gl->cutbuf) {
+ fprintf(stderr,
+ "new_GetLine: Insufficient memory to allocate cut buffer.\n");
+ return del_GetLine(gl);
+ };
+ gl->cutbuf[0] = '\0';
+/*
+ * Allocate a vi undo buffer.
+ */
+ gl->vi.undo.line = (char *) malloc(linelen + 2);
+ if(!gl->vi.undo.line) {
+ fprintf(stderr,
+ "new_GetLine: Insufficient memory to allocate undo buffer.\n");
+ return del_GetLine(gl);
+ };
+ gl->vi.undo.line[0] = '\0';
+/*
+ * Allocate a freelist from which to allocate nodes for the list
+ * of signals.
+ */
+ gl->sig_mem = _new_FreeList("new_GetLine", sizeof(GlSignalNode),
+ GLS_FREELIST_BLOCKING);
+ if(!gl->sig_mem)
+ return del_GetLine(gl);
+/*
+ * Install dispositions for the default list of signals that gl_get_line()
+ * traps.
+ */
+ for(i=0; isigno, sig->flags, sig->after,
+ sig->errno_value))
+ return del_GetLine(gl);
+ };
+/*
+ * Allocate an empty table of key bindings.
+ */
+ gl->bindings = _new_KeyTab();
+ if(!gl->bindings)
+ return del_GetLine(gl);
+/*
+ * Define the available actions that can be bound to key sequences.
+ */
+ for(i=0; ibindings, gl_actions[i].name, gl_actions[i].fn))
+ return del_GetLine(gl);
+ };
+/*
+ * Set up the default bindings.
+ */
+ if(gl_change_editor(gl, gl->editor))
+ return del_GetLine(gl);
+/*
+ * Allocate termcap buffers.
+ */
+#ifdef USE_TERMCAP
+ gl->tgetent_buf = (char *) malloc(TERMCAP_BUF_SIZE);
+ gl->tgetstr_buf = (char *) malloc(TERMCAP_BUF_SIZE);
+ if(!gl->tgetent_buf || !gl->tgetstr_buf) {
+ fprintf(stderr, "new_GetLine: Insufficient memory for termcap buffers.\n");
+ return del_GetLine(gl);
+ };
+#endif
+/*
+ * Set up for I/O assuming stdin and stdout.
+ */
+ if(gl_change_terminal(gl, stdin, stdout, getenv("TERM")))
+ return del_GetLine(gl);
+/*
+ * Create a freelist for use in allocating GlFdNode list nodes.
+ */
+#ifdef HAVE_SELECT
+ gl->fd_node_mem = _new_FreeList("new_GetLine", sizeof(GlFdNode),
+ GLFD_FREELIST_BLOCKING);
+ if(!gl->fd_node_mem)
+ return del_GetLine(gl);
+#endif
+/*
+ * We are done for now.
+ */
+ return gl;
+}
+
+/*.......................................................................
+ * Delete a GetLine object.
+ *
+ * Input:
+ * gl GetLine * The object to be deleted.
+ * Output:
+ * return GetLine * The deleted object (always NULL).
+ */
+GetLine *del_GetLine(GetLine *gl)
+{
+ if(gl) {
+ gl->glh = _del_GlHistory(gl->glh);
+ gl->cpl = del_WordCompletion(gl->cpl);
+ gl->ef = del_ExpandFile(gl->ef);
+ gl->capmem = _del_StringGroup(gl->capmem);
+ if(gl->line)
+ free(gl->line);
+ if(gl->cutbuf)
+ free(gl->cutbuf);
+ if(gl->vi.undo.line)
+ free(gl->vi.undo.line);
+ gl->sig_mem = _del_FreeList(NULL, gl->sig_mem, 1);
+ gl->sigs = NULL; /* Already freed by freeing sig_mem */
+ gl->bindings = _del_KeyTab(gl->bindings);
+#ifdef USE_TERMCAP
+ if(gl->tgetent_buf)
+ free(gl->tgetent_buf);
+ if(gl->tgetstr_buf)
+ free(gl->tgetstr_buf);
+#endif
+ if(gl->file_fp)
+ fclose(gl->file_fp);
+ if(gl->term)
+ free(gl->term);
+#ifdef HAVE_SELECT
+ gl->fd_node_mem = _del_FreeList(NULL, gl->fd_node_mem, 1);
+#endif
+ free(gl);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Bind a control or meta character to an action.
+ *
+ * Input:
+ * gl GetLine * The resource object of this program.
+ * binder KtBinder The source of the binding.
+ * c char The control or meta character.
+ * If this is '\0', the call is ignored.
+ * action const char * The action name to bind the key to.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_bind_control_char(GetLine *gl, KtBinder binder, char c,
+ const char *action)
+{
+ char keyseq[2];
+/*
+ * Quietly reject binding to the NUL control character, since this
+ * is an ambiguous prefix of all bindings.
+ */
+ if(c == '\0')
+ return 0;
+/*
+ * Making sure not to bind characters which aren't either control or
+ * meta characters.
+ */
+ if(IS_CTRL_CHAR(c) || IS_META_CHAR(c)) {
+ keyseq[0] = c;
+ keyseq[1] = '\0';
+ } else {
+ return 0;
+ };
+/*
+ * Install the binding.
+ */
+ return _kt_set_keybinding(gl->bindings, binder, keyseq, action);
+}
+
+/*.......................................................................
+ * Read a line from the user.
+ *
+ * Input:
+ * gl GetLine * A resource object returned by new_GetLine().
+ * prompt char * The prompt to prefix the line with.
+ * start_line char * The initial contents of the input line, or NULL
+ * if it should start out empty.
+ * start_pos int If start_line isn't NULL, this specifies the
+ * index of the character over which the cursor
+ * should initially be positioned within the line.
+ * If you just want it to follow the last character
+ * of the line, send -1.
+ * Output:
+ * return char * An internal buffer containing the input line, or
+ * NULL at the end of input. If the line fitted in
+ * the buffer there will be a '\n' newline character
+ * before the terminating '\0'. If it was truncated
+ * there will be no newline character, and the remains
+ * of the line should be retrieved via further calls
+ * to this function.
+ */
+char *gl_get_line(GetLine *gl, const char *prompt,
+ const char *start_line, int start_pos)
+{
+ int waserr = 0; /* True if an error occurs */
+/*
+ * Check the arguments.
+ */
+ if(!gl || !prompt) {
+ fprintf(stderr, "gl_get_line: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * If this is the first call to this function since new_GetLine(),
+ * complete any postponed configuration.
+ */
+ if(!gl->configured) {
+ (void) gl_configure_getline(gl, NULL, NULL, TECLA_CONFIG_FILE);
+ gl->configured = 1;
+ };
+/*
+ * If input is temporarily being taken from a file, return lines
+ * from the file until the file is exhausted, then revert to
+ * the normal input stream.
+ */
+ if(gl->file_fp) {
+ if(fgets(gl->line, gl->linelen, gl->file_fp))
+ return gl->line;
+ gl_revert_input(gl);
+ };
+/*
+ * Is input coming from a non-interactive source?
+ */
+ if(!gl->is_term)
+ return fgets(gl->line, gl->linelen, gl->input_fp);
+/*
+ * Record the new prompt and its displayed width.
+ */
+ gl_replace_prompt(gl, prompt);
+/*
+ * Before installing our signal handler functions, record the fact
+ * that there are no pending signals.
+ */
+ gl_pending_signal = -1;
+/*
+ * Temporarily override the signal handlers of the calling program,
+ * so that we can intercept signals that would leave the terminal
+ * in a bad state.
+ */
+ waserr = gl_override_signal_handlers(gl);
+/*
+ * After recording the current terminal settings, switch the terminal
+ * into raw input mode.
+ */
+ waserr = waserr || gl_raw_terminal_mode(gl);
+/*
+ * Attempt to read the line.
+ */
+ waserr = waserr || gl_get_input_line(gl, start_line, start_pos);
+/*
+ * Restore terminal settings.
+ */
+ gl_restore_terminal_attributes(gl);
+/*
+ * Restore the signal handlers.
+ */
+ gl_restore_signal_handlers(gl);
+/*
+ * Having restored the program terminal and signal environment,
+ * re-submit any signals that were received.
+ */
+ if(gl_pending_signal != -1) {
+ raise(gl_pending_signal);
+ waserr = 1;
+ };
+/*
+ * If gl_get_input_line() aborted input due to the user asking to
+ * temporarily read lines from a file, read the first line from
+ * this file.
+ */
+ if(!waserr && gl->file_fp)
+ return gl_get_line(gl, prompt, NULL, 0);
+/*
+ * Return the new input line.
+ */
+ return waserr ? NULL : gl->line;
+}
+
+/*.......................................................................
+ * Record of the signal handlers of the calling program, so that they
+ * can be restored later.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_override_signal_handlers(GetLine *gl)
+{
+ GlSignalNode *sig; /* A node in the list of signals to be caught */
+/*
+ * Set up our signal handler.
+ */
+ SigAction act;
+ act.sa_handler = gl_signal_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+/*
+ * Get the process signal mask so that we can see which signals the
+ * calling program currently has blocked, and so that we can restore this
+ * mask before returning to the calling program.
+ */
+ if(sigprocmask(SIG_SETMASK, NULL, &gl->old_signal_set) == -1) {
+ fprintf(stderr, "gl_get_line(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+/*
+ * Form a new process signal mask from the list of signals that we have
+ * been asked to trap.
+ */
+ sigemptyset(&gl->new_signal_set);
+ for(sig=gl->sigs; sig; sig=sig->next) {
+/*
+ * Trap this signal? If it is blocked by the calling program and we
+ * haven't been told to unblock it, don't arrange to trap this signal.
+ */
+ if(sig->flags & GLS_UNBLOCK_SIG ||
+ !sigismember(&gl->old_signal_set, sig->signo)) {
+ if(sigaddset(&gl->new_signal_set, sig->signo) == -1) {
+ fprintf(stderr, "gl_get_line(): sigaddset error: %s\n",
+ strerror(errno));
+ return 1;
+ };
+ };
+ };
+/*
+ * Before installing our signal handlers, block all of the signals
+ * that we are going to be trapping.
+ */
+ if(sigprocmask(SIG_BLOCK, &gl->new_signal_set, NULL) == -1) {
+ fprintf(stderr, "gl_get_line(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+/*
+ * Override the actions of the signals that we are trapping.
+ */
+ for(sig=gl->sigs; sig; sig=sig->next) {
+ if(sigismember(&gl->new_signal_set, sig->signo) &&
+ sigaction(sig->signo, &act, &sig->original)) {
+ fprintf(stderr, "gl_get_line(): sigaction error: %s\n", strerror(errno));
+ return 1;
+ };
+ };
+/*
+ * Just in case a SIGWINCH signal was sent to the process while our
+ * SIGWINCH signal handler wasn't in place, check to see if the terminal
+ * size needs updating.
+ */
+#ifdef USE_SIGWINCH
+ if(gl_resize_terminal(gl, 0))
+ return 1;
+#endif
+ return 0;
+}
+
+/*.......................................................................
+ * Restore the signal handlers of the calling program.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_restore_signal_handlers(GetLine *gl)
+{
+ GlSignalNode *sig; /* A node in the list of signals to be caught */
+/*
+ * Restore application signal handlers that were overriden
+ * by gl_override_signal_handlers().
+ */
+ for(sig=gl->sigs; sig; sig=sig->next) {
+ if(sigismember(&gl->new_signal_set, sig->signo) &&
+ sigaction(sig->signo, &sig->original, NULL)) {
+ fprintf(stderr, "gl_get_line(): sigaction error: %s\n", strerror(errno));
+ return 1;
+ };
+ };
+/*
+ * Restore the original signal mask.
+ */
+ if(sigprocmask(SIG_SETMASK, &gl->old_signal_set, NULL) == -1) {
+ fprintf(stderr, "gl_get_line(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This signal handler simply records the fact that a given signal was
+ * caught in the file-scope gl_pending_signal variable.
+ */
+static void gl_signal_handler(int signo)
+{
+ gl_pending_signal = signo;
+ siglongjmp(gl_setjmp_buffer, 1);
+}
+
+/*.......................................................................
+ * Switch the terminal into raw mode after storing the previous terminal
+ * settings in gl->attributes.
+ *
+ * Input:
+ * gl GetLine * The resource object of this program.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_raw_terminal_mode(GetLine *gl)
+{
+ Termios newattr; /* The new terminal attributes */
+/*
+ * Record the current terminal attributes.
+ */
+ if(tcgetattr(gl->input_fd, &gl->oldattr)) {
+ fprintf(stderr, "getline(): tcgetattr error: %s\n", strerror(errno));
+ return 1;
+ };
+/*
+ * This function shouldn't do anything but record the current terminal
+ * attritubes if editing has been disabled.
+ */
+ if(gl->editor == GL_NO_EDITOR)
+ return 0;
+/*
+ * Modify the existing attributes.
+ */
+ newattr = gl->oldattr;
+/*
+ * Turn off local echo, canonical input mode and extended input processing.
+ */
+ newattr.c_lflag &= ~(ECHO | ICANON | IEXTEN);
+/*
+ * Don't translate carriage return to newline, turn off input parity
+ * checking, don't strip off 8th bit, turn off output flow control.
+ */
+ newattr.c_iflag &= ~(ICRNL | INPCK | ISTRIP);
+/*
+ * Clear size bits, turn off parity checking, and allow 8-bit characters.
+ */
+ newattr.c_cflag &= ~(CSIZE | PARENB);
+ newattr.c_cflag |= CS8;
+/*
+ * Turn off output processing.
+ */
+ newattr.c_oflag &= ~(OPOST);
+/*
+ * Request one byte at a time, without waiting.
+ */
+ newattr.c_cc[VMIN] = 1;
+ newattr.c_cc[VTIME] = 0;
+/*
+ * Install the new terminal modes.
+ */
+ while(tcsetattr(gl->input_fd, TCSADRAIN, &newattr)) {
+ if (errno != EINTR) {
+ fprintf(stderr, "getline(): tcsetattr error: %s\n", strerror(errno));
+ return 1;
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Restore the terminal attributes recorded in gl->oldattr.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_restore_terminal_attributes(GetLine *gl)
+{
+ int waserr = 0;
+/*
+ * Before changing the terminal attributes, make sure that all output
+ * has been passed to the terminal.
+ */
+ if(gl_flush_output(gl))
+ waserr = 1;
+/*
+ * Reset the terminal attributes to the values that they had on
+ * entry to gl_get_line().
+ */
+ while(tcsetattr(gl->input_fd, TCSADRAIN, &gl->oldattr)) {
+ if(errno != EINTR) {
+ fprintf(stderr, "gl_get_line(): tcsetattr error: %s\n", strerror(errno));
+ waserr = 1;
+ break;
+ };
+ };
+ return waserr;
+}
+
+/*.......................................................................
+ * Read a new input line from the user.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * start_line char * The initial contents of the input line, or NULL
+ * if it should start out empty.
+ * start_pos int If start_line isn't NULL, this specifies the
+ * index of the character over which the cursor
+ * should initially be positioned within the line.
+ * If you just want it to follow the last character
+ * of the line, send -1.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_get_input_line(GetLine *gl, const char *start_line, int start_pos)
+{
+ char c; /* The character being read */
+/*
+ * Reset the properties of the line.
+ */
+ gl->ntotal = 0;
+ gl->buff_curpos = 0;
+ gl->term_curpos = 0;
+ gl->insert_curpos = 0;
+ gl->number = -1;
+ gl->endline = 0;
+ gl->vi.command = 0;
+ gl->vi.undo.line[0] = '\0';
+ gl->vi.undo.ntotal = 0;
+ gl->vi.undo.buff_curpos = 0;
+ gl->vi.repeat.fn = 0;
+ gl->last_signal = -1;
+/*
+ * Reset the history search pointers.
+ */
+ if(_glh_cancel_search(gl->glh))
+ return 1;
+/*
+ * Draw the prompt at the start of the line.
+ */
+ if(gl_display_prompt(gl))
+ return 1;
+/*
+ * Present an initial line?
+ */
+ if(start_line) {
+ char *cptr; /* A pointer into gl->line[] */
+/*
+ * Load the line into the buffer, and display it.
+ */
+ if(start_line != gl->line)
+ strncpy(gl->line, start_line, gl->linelen);
+ gl->line[gl->linelen] = '\0';
+ gl->ntotal = strlen(gl->line);
+/*
+ * Strip off any trailing newline and carriage return characters.
+ */
+ for(cptr=gl->line + gl->ntotal - 1; cptr >= gl->line &&
+ (*cptr=='\n' || *cptr=='\r'); cptr--,gl->ntotal--)
+ ;
+ if(gl->ntotal < 0)
+ gl->ntotal = 0;
+ gl->line[gl->ntotal] = '\0';
+/*
+ * Display the string that remains.
+ */
+ if(gl_output_string(gl, gl->line, '\0'))
+ return 1;
+/*
+ * Where should the cursor be placed within the line?
+ */
+ if(start_pos < 0 || start_pos > gl->ntotal) {
+ if(gl_place_cursor(gl, gl->ntotal))
+ return 1;
+ } else {
+ if(gl_place_cursor(gl, start_pos))
+ return 1;
+ };
+ } else {
+ gl->line[0] = '\0';
+ };
+/*
+ * Preload a history line?
+ */
+ if(gl->preload_history) {
+ gl->preload_history = 0;
+ if(gl->preload_id) {
+ if(_glh_recall_line(gl->glh, gl->preload_id, gl->line, gl->linelen)) {
+ gl->ntotal = strlen(gl->line);
+ gl->buff_curpos = strlen(gl->line);
+ };
+ gl->preload_id = 0;
+ };
+ gl_redisplay(gl, 1);
+ };
+/*
+ * Read one character at a time.
+ */
+ while(gl_read_character(gl, &c) == 0) {
+/*
+ * Increment the count of the number of key sequences entered.
+ */
+ gl->keyseq_count++;
+/*
+ * Interpret the character either as the start of a new key-sequence,
+ * as a continuation of a repeat count, or as a printable character
+ * to be added to the line.
+ */
+ if(gl_interpret_char(gl, c))
+ break;
+/*
+ * If we just ran an action function which temporarily asked for
+ * input to be taken from a file, abort this call.
+ */
+ if(gl->file_fp)
+ return 0;
+/*
+ * Has the line been completed?
+ */
+ if(gl->endline)
+ return gl_line_ended(gl, isprint((int)(unsigned char) c) ? c : '\n',
+ gl->echo && (c=='\n' || c=='\r'));
+ };
+/*
+ * To get here, gl_read_character() must have returned non-zero. See
+ * if this was because a signal was caught that requested that the
+ * current line be returned.
+ */
+ if(gl->endline)
+ return gl_line_ended(gl, '\n', gl->echo);
+ return 1;
+}
+
+/*.......................................................................
+ * Add a character to the line buffer at the current cursor position,
+ * inserting or overwriting according the current mode.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * c char The character to be added.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Insufficient room.
+ */
+static int gl_add_char_to_line(GetLine *gl, char c)
+{
+/*
+ * Keep a record of the current cursor position.
+ */
+ int buff_curpos = gl->buff_curpos;
+ int term_curpos = gl->term_curpos;
+/*
+ * Work out the displayed width of the new character.
+ */
+ int width = gl_displayed_char_width(gl, c, term_curpos);
+/*
+ * If we are in insert mode, or at the end of the line,
+ * check that we can accomodate a new character in the buffer.
+ * If not, simply return, leaving it up to the calling program
+ * to check for the absence of a newline character.
+ */
+ if((gl->insert || buff_curpos >= gl->ntotal) && gl->ntotal >= gl->linelen)
+ return 0;
+/*
+ * Are we adding characters to the line (ie. inserting or appending)?
+ */
+ if(gl->insert || buff_curpos >= gl->ntotal) {
+/*
+ * If inserting, make room for the new character.
+ */
+ if(buff_curpos < gl->ntotal) {
+ memmove(gl->line + buff_curpos + 1, gl->line + buff_curpos,
+ gl->ntotal - buff_curpos);
+ };
+/*
+ * Copy the character into the buffer.
+ */
+ gl->line[buff_curpos] = c;
+ gl->buff_curpos++;
+/*
+ * If the line was extended, update the record of the string length
+ * and terminate the extended string.
+ */
+ gl->ntotal++;
+ gl->line[gl->ntotal] = '\0';
+/*
+ * Redraw the line from the cursor position to the end of the line,
+ * and move the cursor to just after the added character.
+ */
+ if(gl_output_string(gl, gl->line + buff_curpos, '\0') ||
+ gl_set_term_curpos(gl, term_curpos + width))
+ return 1;
+/*
+ * Are we overwriting an existing character?
+ */
+ } else {
+/*
+ * Get the widths of the character to be overwritten and the character
+ * that is going to replace it.
+ */
+ int old_width = gl_displayed_char_width(gl, gl->line[buff_curpos],
+ term_curpos);
+/*
+ * Overwrite the character in the buffer.
+ */
+ gl->line[buff_curpos] = c;
+/*
+ * If we are replacing with a narrower character, we need to
+ * redraw the terminal string to the end of the line, then
+ * overwrite the trailing old_width - width characters
+ * with spaces.
+ */
+ if(old_width > width) {
+ if(gl_output_string(gl, gl->line + buff_curpos, '\0'))
+ return 1;
+/*
+ * Clear to the end of the terminal.
+ */
+ if(gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+/*
+ * Move the cursor to the end of the new character.
+ */
+ if(gl_set_term_curpos(gl, term_curpos + width))
+ return 1;
+ gl->buff_curpos++;
+/*
+ * If we are replacing with a wider character, then we will be
+ * inserting new characters, and thus extending the line.
+ */
+ } else if(width > old_width) {
+/*
+ * Redraw the line from the cursor position to the end of the line,
+ * and move the cursor to just after the added character.
+ */
+ if(gl_output_string(gl, gl->line + buff_curpos, '\0') ||
+ gl_set_term_curpos(gl, term_curpos + width))
+ return 1;
+ gl->buff_curpos++;
+/*
+ * The original and replacement characters have the same width,
+ * so simply overwrite.
+ */
+ } else {
+/*
+ * Copy the character into the buffer.
+ */
+ gl->line[buff_curpos] = c;
+ gl->buff_curpos++;
+/*
+ * Overwrite the original character.
+ */
+ if(gl_output_char(gl, c, gl->line[gl->buff_curpos]))
+ return 1;
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Insert/append a string to the line buffer and terminal at the current
+ * cursor position.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * s char * The string to be added.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Insufficient room.
+ */
+static int gl_add_string_to_line(GetLine *gl, const char *s)
+{
+ int buff_slen; /* The length of the string being added to line[] */
+ int term_slen; /* The length of the string being written to the terminal */
+ int buff_curpos; /* The original value of gl->buff_curpos */
+ int term_curpos; /* The original value of gl->term_curpos */
+/*
+ * Keep a record of the current cursor position.
+ */
+ buff_curpos = gl->buff_curpos;
+ term_curpos = gl->term_curpos;
+/*
+ * How long is the string to be added?
+ */
+ buff_slen = strlen(s);
+ term_slen = gl_displayed_string_width(gl, s, buff_slen, term_curpos);
+/*
+ * Check that we can accomodate the string in the buffer.
+ * If not, simply return, leaving it up to the calling program
+ * to check for the absence of a newline character.
+ */
+ if(gl->ntotal + buff_slen > gl->linelen)
+ return 0;
+/*
+ * Move the characters that follow the cursor in the buffer by
+ * buff_slen characters to the right.
+ */
+ if(gl->ntotal > gl->buff_curpos) {
+ memmove(gl->line + gl->buff_curpos + buff_slen, gl->line + gl->buff_curpos,
+ gl->ntotal - gl->buff_curpos);
+ };
+/*
+ * Copy the string into the buffer.
+ */
+ memcpy(gl->line + gl->buff_curpos, s, buff_slen);
+ gl->ntotal += buff_slen;
+ gl->buff_curpos += buff_slen;
+/*
+ * Maintain the buffer properly terminated.
+ */
+ gl->line[gl->ntotal] = '\0';
+/*
+ * Write the modified part of the line to the terminal, then move
+ * the terminal cursor to the end of the displayed input string.
+ */
+ if(gl_output_string(gl, gl->line + buff_curpos, '\0') ||
+ gl_set_term_curpos(gl, term_curpos + term_slen))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * Read a single character from the terminal.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Either an I/O error occurred, or a signal was
+ * caught who's disposition is to abort gl_get_line()
+ * or to have gl_get_line() return the current line
+ * as though the user had pressed return. In the
+ * latter case gl->endline will be non-zero.
+ */
+static int gl_read_character(GetLine *gl, char *c)
+{
+/*
+ * Before waiting for a new character to be input, flush unwritten
+ * characters to the terminal.
+ */
+ if(gl_flush_output(gl))
+ return 1;
+/*
+ * We may have to repeat the read if window change signals are received.
+ */
+ for(;;) {
+/*
+ * If the endline flag becomes set, don't wait for another character.
+ */
+ if(gl->endline)
+ return 1;
+/*
+ * Since the code in this function can block, trap signals.
+ */
+ if(sigsetjmp(gl_setjmp_buffer, 1)==0) {
+/*
+ * Unblock the signals that we are trapping.
+ */
+ if(sigprocmask(SIG_UNBLOCK, &gl->new_signal_set, NULL) == -1) {
+ fprintf(stderr, "getline(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+/*
+ * If select() is available, watch for activity on any file descriptors
+ * that the user has registered, and for data available on the terminal
+ * file descriptor.
+ */
+#ifdef HAVE_SELECT
+ if(gl_event_handler(gl))
+ return 1;
+#endif
+/*
+ * Read one character from the terminal. This could take more
+ * than one call if an interrupt that we aren't trapping is
+ * received.
+ */
+ while(read(gl->input_fd, (void *)c, 1) != 1) {
+ if(errno != EINTR) {
+#ifdef EAGAIN
+ if(!errno) /* This can happen with SysV O_NDELAY */
+ errno = EAGAIN;
+#endif
+ return 1;
+ };
+ };
+/*
+ * Block all of the signals that we are trapping.
+ */
+ if(sigprocmask(SIG_BLOCK, &gl->new_signal_set, NULL) == -1) {
+ fprintf(stderr, "getline(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+ return 0;
+ };
+/*
+ * To get here, one of the signals that we are trapping must have
+ * been received. Note that by using sigsetjmp() instead of setjmp()
+ * the signal mask that was blocking these signals will have been
+ * reinstated, so we can be sure that no more of these signals will
+ * be received until we explicitly unblock them again.
+ */
+ if(gl_check_caught_signal(gl))
+ return 1;
+ };
+}
+
+/*.......................................................................
+ * This function is called to handle signals caught between calls to
+ * sigsetjmp() and siglongjmp().
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int 0 - Signal handled internally.
+ * 1 - Signal requires gl_get_line() to abort.
+ */
+static int gl_check_caught_signal(GetLine *gl)
+{
+ GlSignalNode *sig; /* The signal disposition */
+ SigAction keep_action; /* The signal disposition of tecla signal handlers */
+/*
+ * Was no signal caught?
+ */
+ if(gl_pending_signal == -1)
+ return 0;
+/*
+ * Record the signal that was caught, so that the user can query it later.
+ */
+ gl->last_signal = gl_pending_signal;
+/*
+ * Did we receive a terminal size signal?
+ */
+#ifdef USE_SIGWINCH
+ if(gl_pending_signal == SIGWINCH && gl_resize_terminal(gl, 1))
+ return 1;
+#endif
+/*
+ * Lookup the requested disposition of this signal.
+ */
+ for(sig=gl->sigs; sig && sig->signo != gl_pending_signal; sig=sig->next)
+ ;
+ if(!sig)
+ return 0;
+/*
+ * Start a fresh line?
+ */
+ if(sig->flags & GLS_RESTORE_LINE) {
+ if(gl_set_term_curpos(gl, gl_buff_curpos_to_term_curpos(gl, gl->ntotal)) ||
+ gl_output_raw_string(gl, "\r\n"))
+ return 1;
+ };
+/*
+ * Restore terminal settings to how they were before gl_get_line() was
+ * called?
+ */
+ if(sig->flags & GLS_RESTORE_TTY)
+ gl_restore_terminal_attributes(gl);
+/*
+ * Restore signal handlers to how they were before gl_get_line() was
+ * called? If this hasn't been requested, only reinstate the signal
+ * handler of the signal that we are handling.
+ */
+ if(sig->flags & GLS_RESTORE_SIG) {
+ gl_restore_signal_handlers(gl);
+ } else {
+ (void) sigaction(sig->signo, &sig->original, &keep_action);
+ (void) sigprocmask(SIG_UNBLOCK, &sig->proc_mask, NULL);
+ };
+/*
+ * Forward the signal to the application's signal handler.
+ */
+ if(!(sig->flags & GLS_DONT_FORWARD))
+ raise(gl_pending_signal);
+ gl_pending_signal = -1;
+/*
+ * Reinstate our signal handlers.
+ */
+ if(sig->flags & GLS_RESTORE_SIG) {
+ gl_override_signal_handlers(gl);
+ } else {
+ (void) sigaction(sig->signo, &keep_action, NULL);
+ (void) sigprocmask(SIG_BLOCK, &sig->proc_mask, NULL);
+ };
+/*
+ * Do we need to reinstate our terminal settings?
+ */
+ if(sig->flags & GLS_RESTORE_TTY)
+ gl_raw_terminal_mode(gl);
+/*
+ * Redraw the line?
+ */
+ if(sig->flags & GLS_REDRAW_LINE && gl_redisplay(gl, 1))
+ return 1;
+/*
+ * Set errno.
+ */
+ errno = sig->errno_value;
+/*
+ * What next?
+ */
+ switch(sig->after) {
+ case GLS_RETURN:
+ return gl_newline(gl, 1);
+ break;
+ case GLS_ABORT:
+ return 1;
+ break;
+ case GLS_CONTINUE:
+ return 0;
+ break;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Get pertinent terminal control strings and the initial terminal size.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * term char * The type of the terminal.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_control_strings(GetLine *gl, const char *term)
+{
+ int bad_term = 0; /* True if term is unusable */
+/*
+ * Discard any existing control strings from a previous terminal.
+ */
+ gl->left = NULL;
+ gl->right = NULL;
+ gl->up = NULL;
+ gl->down = NULL;
+ gl->home = NULL;
+ gl->bol = 0;
+ gl->clear_eol = NULL;
+ gl->clear_eod = NULL;
+ gl->u_arrow = NULL;
+ gl->d_arrow = NULL;
+ gl->l_arrow = NULL;
+ gl->r_arrow = NULL;
+ gl->sound_bell = NULL;
+ gl->bold = NULL;
+ gl->underline = NULL;
+ gl->standout = NULL;
+ gl->dim = NULL;
+ gl->reverse = NULL;
+ gl->blink = NULL;
+ gl->text_attr_off = NULL;
+ gl->nline = 0;
+ gl->ncolumn = 0;
+#ifdef USE_TERMINFO
+ gl->left_n = NULL;
+ gl->right_n = NULL;
+#endif
+/*
+ * If possible lookup the information in a terminal information
+ * database.
+ */
+#ifdef USE_TERMINFO
+ if(!term || setupterm((char *)term, gl->input_fd, NULL) == ERR) {
+ bad_term = 1;
+ } else {
+ _clr_StringGroup(gl->capmem);
+ gl->left = gl_tigetstr(gl, "cub1");
+ gl->right = gl_tigetstr(gl, "cuf1");
+ gl->up = gl_tigetstr(gl, "cuu1");
+ gl->down = gl_tigetstr(gl, "cud1");
+ gl->home = gl_tigetstr(gl, "home");
+ gl->clear_eol = gl_tigetstr(gl, "el");
+ gl->clear_eod = gl_tigetstr(gl, "ed");
+ gl->u_arrow = gl_tigetstr(gl, "kcuu1");
+ gl->d_arrow = gl_tigetstr(gl, "kcud1");
+ gl->l_arrow = gl_tigetstr(gl, "kcub1");
+ gl->r_arrow = gl_tigetstr(gl, "kcuf1");
+ gl->left_n = gl_tigetstr(gl, "cub");
+ gl->right_n = gl_tigetstr(gl, "cuf");
+ gl->sound_bell = gl_tigetstr(gl, "bel");
+ gl->bold = gl_tigetstr(gl, "bold");
+ gl->underline = gl_tigetstr(gl, "smul");
+ gl->standout = gl_tigetstr(gl, "smso");
+ gl->dim = gl_tigetstr(gl, "dim");
+ gl->reverse = gl_tigetstr(gl, "rev");
+ gl->blink = gl_tigetstr(gl, "blink");
+ gl->text_attr_off = gl_tigetstr(gl, "sgr0");
+ };
+#elif defined(USE_TERMCAP)
+ if(!term || tgetent(gl->tgetent_buf, (char *)term) < 0) {
+ bad_term = 1;
+ } else {
+ char *tgetstr_buf_ptr = gl->tgetstr_buf;
+ _clr_StringGroup(gl->capmem);
+ gl->left = gl_tgetstr(gl, "le", &tgetstr_buf_ptr);
+ gl->right = gl_tgetstr(gl, "nd", &tgetstr_buf_ptr);
+ gl->up = gl_tgetstr(gl, "up", &tgetstr_buf_ptr);
+ gl->down = gl_tgetstr(gl, "do", &tgetstr_buf_ptr);
+ gl->home = gl_tgetstr(gl, "ho", &tgetstr_buf_ptr);
+ gl->clear_eol = gl_tgetstr(gl, "ce", &tgetstr_buf_ptr);
+ gl->clear_eod = gl_tgetstr(gl, "cd", &tgetstr_buf_ptr);
+ gl->u_arrow = gl_tgetstr(gl, "ku", &tgetstr_buf_ptr);
+ gl->d_arrow = gl_tgetstr(gl, "kd", &tgetstr_buf_ptr);
+ gl->l_arrow = gl_tgetstr(gl, "kl", &tgetstr_buf_ptr);
+ gl->r_arrow = gl_tgetstr(gl, "kr", &tgetstr_buf_ptr);
+ gl->sound_bell = gl_tgetstr(gl, "bl", &tgetstr_buf_ptr);
+ gl->bold = gl_tgetstr(gl, "md", &tgetstr_buf_ptr);
+ gl->underline = gl_tgetstr(gl, "us", &tgetstr_buf_ptr);
+ gl->standout = gl_tgetstr(gl, "so", &tgetstr_buf_ptr);
+ gl->dim = gl_tgetstr(gl, "mh", &tgetstr_buf_ptr);
+ gl->reverse = gl_tgetstr(gl, "mr", &tgetstr_buf_ptr);
+ gl->blink = gl_tgetstr(gl, "mb", &tgetstr_buf_ptr);
+ gl->text_attr_off = gl_tgetstr(gl, "me", &tgetstr_buf_ptr);
+ };
+#endif
+/*
+ * Report term being unusable.
+ */
+ if(bad_term) {
+ fprintf(stderr, "Bad terminal type: \"%s\". Will assume vt100.\n",
+ term ? term : "(null)");
+ };
+/*
+ * Fill in missing information with ANSI VT100 strings.
+ */
+ if(!gl->left)
+ gl->left = "\b"; /* ^H */
+ if(!gl->right)
+ gl->right = GL_ESC_STR "[C";
+ if(!gl->up)
+ gl->up = GL_ESC_STR "[A";
+ if(!gl->down)
+ gl->down = "\n";
+ if(!gl->home)
+ gl->home = GL_ESC_STR "[H";
+ if(!gl->bol)
+ gl->bol = "\r";
+ if(!gl->clear_eol)
+ gl->clear_eol = GL_ESC_STR "[K";
+ if(!gl->clear_eod)
+ gl->clear_eod = GL_ESC_STR "[J";
+ if(!gl->u_arrow)
+ gl->u_arrow = GL_ESC_STR "[A";
+ if(!gl->d_arrow)
+ gl->d_arrow = GL_ESC_STR "[B";
+ if(!gl->l_arrow)
+ gl->l_arrow = GL_ESC_STR "[D";
+ if(!gl->r_arrow)
+ gl->r_arrow = GL_ESC_STR "[C";
+ if(!gl->sound_bell)
+ gl->sound_bell = "\a";
+ if(!gl->bold)
+ gl->bold = GL_ESC_STR "[1m";
+ if(!gl->underline)
+ gl->underline = GL_ESC_STR "[4m";
+ if(!gl->standout)
+ gl->standout = GL_ESC_STR "[1;7m";
+ if(!gl->dim)
+ gl->dim = ""; /* Not available */
+ if(!gl->reverse)
+ gl->reverse = GL_ESC_STR "[7m";
+ if(!gl->blink)
+ gl->blink = GL_ESC_STR "[5m";
+ if(!gl->text_attr_off)
+ gl->text_attr_off = GL_ESC_STR "[m";
+/*
+ * Find out the current terminal size.
+ */
+ (void) gl_terminal_size(gl, GL_DEF_NCOLUMN, GL_DEF_NLINE);
+ return 0;
+}
+
+#ifdef USE_TERMINFO
+/*.......................................................................
+ * This is a private function of gl_control_strings() used to look up
+ * a termninal capability string from the terminfo database and make
+ * a private copy of it.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * name const char * The name of the terminfo string to look up.
+ * Output:
+ * return const char * The local copy of the capability, or NULL
+ * if not available.
+ */
+static const char *gl_tigetstr(GetLine *gl, const char *name)
+{
+ const char *value = tigetstr((char *)name);
+ if(!value || value == (char *) -1)
+ return NULL;
+ return _sg_store_string(gl->capmem, value, 0);
+}
+#elif defined(USE_TERMCAP)
+/*.......................................................................
+ * This is a private function of gl_control_strings() used to look up
+ * a termninal capability string from the termcap database and make
+ * a private copy of it. Note that some emulations of tgetstr(), such
+ * as that used by Solaris, ignores the buffer pointer that is past to
+ * it, so we can't assume that a private copy has been made that won't
+ * be trashed by another call to gl_control_strings() by another
+ * GetLine object. So we make what may be a redundant private copy
+ * of the string in gl->capmem.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * name const char * The name of the terminfo string to look up.
+ * Input/Output:
+ * bufptr char ** On input *bufptr points to the location in
+ * gl->tgetstr_buf at which to record the
+ * capability string. On output *bufptr is
+ * incremented over the stored string.
+ * Output:
+ * return const char * The local copy of the capability, or NULL
+ * on error.
+ */
+static const char *gl_tgetstr(GetLine *gl, const char *name, char **bufptr)
+{
+ const char *value = tgetstr((char *)name, bufptr);
+ if(!value || value == (char *) -1)
+ return NULL;
+ return _sg_store_string(gl->capmem, value, 0);
+}
+#endif
+
+/*.......................................................................
+ * This is an action function that implements a user interrupt (eg. ^C).
+ */
+static KT_KEY_FN(gl_user_interrupt)
+{
+ raise(SIGINT);
+ return 1;
+}
+
+/*.......................................................................
+ * This is an action function that implements the abort signal.
+ */
+static KT_KEY_FN(gl_abort)
+{
+ raise(SIGABRT);
+ return 1;
+}
+
+/*.......................................................................
+ * This is an action function that sends a suspend signal (eg. ^Z) to the
+ * the parent process.
+ */
+static KT_KEY_FN(gl_suspend)
+{
+ raise(SIGTSTP);
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function that halts output to the terminal.
+ */
+static KT_KEY_FN(gl_stop_output)
+{
+ tcflow(gl->output_fd, TCOOFF);
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function that resumes halted terminal output.
+ */
+static KT_KEY_FN(gl_start_output)
+{
+ tcflow(gl->output_fd, TCOON);
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function that allows the next character to be accepted
+ * without any interpretation as a special character.
+ */
+static KT_KEY_FN(gl_literal_next)
+{
+ char c; /* The character to be added to the line */
+ int i;
+/*
+ * Get the character to be inserted literally.
+ */
+ if(gl_read_character(gl, &c))
+ return 1;
+/*
+ * Add the character to the line 'count' times.
+ */
+ for(i=0; incolumn) % TAB_WIDTH);
+ if(IS_CTRL_CHAR(c))
+ return 2;
+ if(!isprint((int)(unsigned char) c)) {
+ char string[TAB_WIDTH + 4];
+ sprintf(string, "\\%o", (int)(unsigned char)c);
+ return strlen(string);
+ };
+ return 1;
+}
+
+/*.......................................................................
+ * Work out the length of given string of characters on the terminal.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * string char * The string to be measured.
+ * nc int The number of characters to be measured, or -1
+ * to measure the whole string.
+ * term_curpos int The destination terminal location of the character.
+ * This is needed because the width of tab characters
+ * depends on where they are, relative to the
+ * preceding tab stops.
+ * Output:
+ * return int The number of displayed characters.
+ */
+static int gl_displayed_string_width(GetLine *gl, const char *string, int nc,
+ int term_curpos)
+{
+ int slen=0; /* The displayed number of characters */
+ int i;
+/*
+ * How many characters are to be measured?
+ */
+ if(nc < 0)
+ nc = strlen(string);
+/*
+ * Add up the length of the displayed string.
+ */
+ for(i=0; iecho) {
+ int ndone = 0; /* The number of characters written so far */
+/*
+ * How long is the string to be written?
+ */
+ int slen = strlen(string);
+/*
+ * Attempt to write the string to the terminal, restarting the
+ * write if a signal is caught.
+ */
+ while(ndone < slen) {
+ int nnew = fwrite(string + ndone, sizeof(char), slen-ndone,
+ gl->output_fp);
+ if(nnew > 0)
+ ndone += nnew;
+ else if(errno != EINTR)
+ return 1;
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Output a terminal control sequence. When using terminfo,
+ * this must be a sequence returned by tgetstr() or tigetstr()
+ * respectively.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * nline int The number of lines affected by the operation,
+ * or 1 if not relevant.
+ * string char * The control sequence to be sent.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_output_control_sequence(GetLine *gl, int nline,
+ const char *string)
+{
+ if(gl->echo) {
+#if defined(USE_TERMINFO) || defined(USE_TERMCAP)
+ tputs_fp = gl->output_fp;
+ errno = 0;
+ tputs((char *)string, nline, gl_tputs_putchar);
+ return errno != 0;
+#else
+ return gl_output_raw_string(gl, string);
+#endif
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Move the terminal cursor n characters to the left or right.
+ *
+ * Input:
+ * gl GetLine * The resource object of this program.
+ * n int number of positions to the right (> 0) or left (< 0).
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_terminal_move_cursor(GetLine *gl, int n)
+{
+ int cur_row, cur_col; /* The current terminal row and column index of */
+ /* the cursor wrt the start of the input line. */
+ int new_row, new_col; /* The target terminal row and column index of */
+ /* the cursor wrt the start of the input line. */
+/*
+ * How far can we move left?
+ */
+ if(gl->term_curpos + n < 0)
+ n = gl->term_curpos;
+/*
+ * Break down the current and target cursor locations into rows and columns.
+ */
+ cur_row = gl->term_curpos / gl->ncolumn;
+ cur_col = gl->term_curpos % gl->ncolumn;
+ new_row = (gl->term_curpos + n) / gl->ncolumn;
+ new_col = (gl->term_curpos + n) % gl->ncolumn;
+/*
+ * Move down to the next line.
+ */
+ for(; cur_row < new_row; cur_row++) {
+ if(gl_output_control_sequence(gl, 1, gl->down))
+ return 1;
+ };
+/*
+ * Move up to the previous line.
+ */
+ for(; cur_row > new_row; cur_row--) {
+ if(gl_output_control_sequence(gl, 1, gl->up))
+ return 1;
+ };
+/*
+ * Move to the right within the target line?
+ */
+ if(cur_col < new_col) {
+#ifdef USE_TERMINFO
+/*
+ * Use a parameterized control sequence if it generates less control
+ * characters (guess based on ANSI terminal termcap entry).
+ */
+ if(gl->right_n != NULL && new_col - cur_col > 1) {
+ if(gl_output_control_sequence(gl, 1, tparm((char *)gl->right_n,
+ (long)(new_col - cur_col), 0l, 0l, 0l, 0l, 0l, 0l, 0l, 0l)))
+ return 1;
+ } else
+#endif
+ {
+ for(; cur_col < new_col; cur_col++) {
+ if(gl_output_control_sequence(gl, 1, gl->right))
+ return 1;
+ };
+ };
+/*
+ * Move to the left within the target line?
+ */
+ } else if(cur_col > new_col) {
+#ifdef USE_TERMINFO
+/*
+ * Use a parameterized control sequence if it generates less control
+ * characters (guess based on ANSI terminal termcap entry).
+ */
+ if(gl->left_n != NULL && cur_col - new_col > 3) {
+ if(gl_output_control_sequence(gl, 1, tparm((char *)gl->left_n,
+ (long)(cur_col - new_col), 0l, 0l, 0l, 0l, 0l, 0l, 0l, 0l)))
+ return 1;
+ } else
+#endif
+ {
+ for(; cur_col > new_col; cur_col--) {
+ if(gl_output_control_sequence(gl, 1, gl->left))
+ return 1;
+ };
+ };
+ }
+/*
+ * Update the recorded position of the terminal cursor.
+ */
+ gl->term_curpos += n;
+ return 0;
+}
+
+/*.......................................................................
+ * Write a character to the terminal after expanding tabs and control
+ * characters to their multi-character representations.
+ *
+ * Input:
+ * gl GetLine * The resource object of this program.
+ * c char The character to be output.
+ * pad char Many terminals have the irritating feature that
+ * when one writes a character in the last column of
+ * of the terminal, the cursor isn't wrapped to the
+ * start of the next line until one more character
+ * is written. Some terminals don't do this, so
+ * after such a write, we don't know where the
+ * terminal is unless we output an extra character.
+ * This argument specifies the character to write.
+ * If at the end of the input line send '\0' or a
+ * space, and a space will be written. Otherwise,
+ * pass the next character in the input line
+ * following the one being written.
+ * Output:
+ * return int 0 - OK.
+ */
+static int gl_output_char(GetLine *gl, char c, char pad)
+{
+ char string[TAB_WIDTH + 4]; /* A work area for composing compound strings */
+ int nchar; /* The number of terminal characters */
+ int i;
+/*
+ * Check for special characters.
+ */
+ if(c == '\t') {
+/*
+ * How many spaces do we need to represent a tab at the current terminal
+ * column?
+ */
+ nchar = gl_displayed_char_width(gl, '\t', gl->term_curpos);
+/*
+ * Compose the tab string.
+ */
+ for(i=0; iterm_curpos += nchar;
+/*
+ * If the new character ended exactly at the end of a line,
+ * most terminals won't move the cursor onto the next line until we
+ * have written a character on the next line, so append an extra
+ * space then move the cursor back.
+ */
+ if(gl->term_curpos % gl->ncolumn == 0) {
+ int term_curpos = gl->term_curpos;
+ if(gl_output_char(gl, pad ? pad : ' ', ' ') ||
+ gl_set_term_curpos(gl, term_curpos))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Write a string to the terminal after expanding tabs and control
+ * characters to their multi-character representations.
+ *
+ * Input:
+ * gl GetLine * The resource object of this program.
+ * string char * The string to be output.
+ * pad char Many terminals have the irritating feature that
+ * when one writes a character in the last column of
+ * of the terminal, the cursor isn't wrapped to the
+ * start of the next line until one more character
+ * is written. Some terminals don't do this, so
+ * after such a write, we don't know where the
+ * terminal is unless we output an extra character.
+ * This argument specifies the character to write.
+ * If at the end of the input line send '\0' or a
+ * space, and a space will be written. Otherwise,
+ * pass the next character in the input line
+ * following the one being written.
+ * Output:
+ * return int 0 - OK.
+ */
+static int gl_output_string(GetLine *gl, const char *string, char pad)
+{
+ const char *cptr; /* A pointer into string[] */
+ for(cptr=string; *cptr; cptr++) {
+ char nextc = cptr[1];
+ if(gl_output_char(gl, *cptr, nextc ? nextc : pad))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Given a character position within gl->line[], work out the
+ * corresponding gl->term_curpos position on the terminal.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * buff_curpos int The position within gl->line[].
+ *
+ * Output:
+ * return int The gl->term_curpos position on the terminal.
+ */
+static int gl_buff_curpos_to_term_curpos(GetLine *gl, int buff_curpos)
+{
+ return gl->prompt_len + gl_displayed_string_width(gl, gl->line, buff_curpos,
+ gl->prompt_len);
+}
+
+/*.......................................................................
+ * Move the terminal cursor position.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * term_curpos int The destination terminal cursor position.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_set_term_curpos(GetLine *gl, int term_curpos)
+{
+ return gl_terminal_move_cursor(gl, term_curpos - gl->term_curpos);
+}
+
+/*.......................................................................
+ * This is an action function that moves the buffer cursor one character
+ * left, and updates the terminal cursor to match.
+ */
+static KT_KEY_FN(gl_cursor_left)
+{
+ return gl_place_cursor(gl, gl->buff_curpos - count);
+}
+
+/*.......................................................................
+ * This is an action function that moves the buffer cursor one character
+ * right, and updates the terminal cursor to match.
+ */
+static KT_KEY_FN(gl_cursor_right)
+{
+ return gl_place_cursor(gl, gl->buff_curpos + count);
+}
+
+/*.......................................................................
+ * This is an action function that toggles between overwrite and insert
+ * mode.
+ */
+static KT_KEY_FN(gl_insert_mode)
+{
+ gl->insert = !gl->insert;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which moves the cursor to the beginning of
+ * the line.
+ */
+static KT_KEY_FN(gl_beginning_of_line)
+{
+ return gl_place_cursor(gl, 0);
+}
+
+/*.......................................................................
+ * This is an action function which moves the cursor to the end of
+ * the line.
+ */
+static KT_KEY_FN(gl_end_of_line)
+{
+ return gl_place_cursor(gl, gl->ntotal);
+}
+
+/*.......................................................................
+ * This is an action function which deletes the entire contents of the
+ * current line.
+ */
+static KT_KEY_FN(gl_delete_line)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Copy the contents of the line to the cut buffer.
+ */
+ strcpy(gl->cutbuf, gl->line);
+/*
+ * Clear the buffer.
+ */
+ gl->ntotal = 0;
+ gl->line[0] = '\0';
+/*
+ * Move the terminal cursor to just after the prompt.
+ */
+ if(gl_place_cursor(gl, 0))
+ return 1;
+/*
+ * Clear from the end of the prompt to the end of the terminal.
+ */
+ if(gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which deletes all characters between the
+ * current cursor position and the end of the line.
+ */
+static KT_KEY_FN(gl_kill_line)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Copy the part of the line that is about to be deleted to the cut buffer.
+ */
+ strcpy(gl->cutbuf, gl->line + gl->buff_curpos);
+/*
+ * Terminate the buffered line at the current cursor position.
+ */
+ gl->ntotal = gl->buff_curpos;
+ gl->line[gl->ntotal] = '\0';
+/*
+ * Clear the part of the line that follows the cursor.
+ */
+ if(gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+/*
+ * Explicitly reset the cursor position to allow vi command mode
+ * constraints on its position to be set.
+ */
+ return gl_place_cursor(gl, gl->buff_curpos);
+}
+
+/*.......................................................................
+ * This is an action function which deletes all characters between the
+ * start of the line and the current cursor position.
+ */
+static KT_KEY_FN(gl_backward_kill_line)
+{
+/*
+ * How many characters are to be deleted from before the cursor?
+ */
+ int nc = gl->buff_curpos - gl->insert_curpos;
+ if (!nc)
+ return 0;
+/*
+ * Move the cursor to the start of the line, or in vi input mode,
+ * the start of the sub-line at which insertion started, and delete
+ * up to the old cursor position.
+ */
+ return gl_place_cursor(gl, gl->insert_curpos) ||
+ gl_delete_chars(gl, nc, gl->editor == GL_EMACS_MODE || gl->vi.command);
+}
+
+/*.......................................................................
+ * This is an action function which moves the cursor forward by a word.
+ */
+static KT_KEY_FN(gl_forward_word)
+{
+ return gl_place_cursor(gl, gl_nth_word_end_forward(gl, count) +
+ (gl->editor==GL_EMACS_MODE));
+}
+
+/*.......................................................................
+ * This is an action function which moves the cursor forward to the start
+ * of the next word.
+ */
+static KT_KEY_FN(gl_forward_to_word)
+{
+ return gl_place_cursor(gl, gl_nth_word_start_forward(gl, count));
+}
+
+/*.......................................................................
+ * This is an action function which moves the cursor backward by a word.
+ */
+static KT_KEY_FN(gl_backward_word)
+{
+ return gl_place_cursor(gl, gl_nth_word_start_backward(gl, count));
+}
+
+/*.......................................................................
+ * Delete one or more characters, starting with the one under the cursor.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * nc int The number of characters to delete.
+ * cut int If true, copy the characters to the cut buffer.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_delete_chars(GetLine *gl, int nc, int cut)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * If there are fewer than nc characters following the cursor, limit
+ * nc to the number available.
+ */
+ if(gl->buff_curpos + nc > gl->ntotal)
+ nc = gl->ntotal - gl->buff_curpos;
+/*
+ * Copy the about to be deleted region to the cut buffer.
+ */
+ if(cut) {
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, nc);
+ gl->cutbuf[nc] = '\0';
+ }
+/*
+ * Nothing to delete?
+ */
+ if(nc <= 0)
+ return 0;
+/*
+ * In vi overwrite mode, restore any previously overwritten characters
+ * from the undo buffer.
+ */
+ if(gl->editor == GL_VI_MODE && !gl->vi.command && !gl->insert) {
+/*
+ * How many of the characters being deleted can be restored from the
+ * undo buffer?
+ */
+ int nrestore = gl->buff_curpos + nc <= gl->vi.undo.ntotal ?
+ nc : gl->vi.undo.ntotal - gl->buff_curpos;
+/*
+ * Restore any available characters.
+ */
+ if(nrestore > 0)
+ memcpy(gl->line + gl->buff_curpos, gl->vi.undo.line + gl->buff_curpos,
+ nrestore);
+/*
+ * If their were insufficient characters in the undo buffer, then this
+ * implies that we are deleting from the end of the line, so we need
+ * to terminate the line either where the undo buffer ran out, or if
+ * we are deleting from beyond the end of the undo buffer, at the current
+ * cursor position.
+ */
+ if(nc != nrestore) {
+ gl->ntotal = gl->vi.undo.ntotal > gl->buff_curpos ? gl->vi.undo.ntotal :
+ gl->buff_curpos;
+ gl->line[gl->ntotal] = '\0';
+ };
+ } else {
+/*
+ * Copy the remaining part of the line back over the deleted characters.
+ */
+ memmove(gl->line + gl->buff_curpos, gl->line + gl->buff_curpos + nc,
+ gl->ntotal - gl->buff_curpos - nc + 1);
+ gl->ntotal -= nc;
+ };
+/*
+ * Redraw the remaining characters following the cursor.
+ */
+ if(gl_output_string(gl, gl->line + gl->buff_curpos, '\0'))
+ return 1;
+/*
+ * Clear to the end of the terminal.
+ */
+ if(gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+/*
+ * Place the cursor at the start of where the deletion was performed.
+ */
+ return gl_place_cursor(gl, gl->buff_curpos);
+}
+
+/*.......................................................................
+ * This is an action function which deletes character(s) under the
+ * cursor without moving the cursor.
+ */
+static KT_KEY_FN(gl_forward_delete_char)
+{
+/*
+ * Delete 'count' characters.
+ */
+ return gl_delete_chars(gl, count, gl->vi.command);
+}
+
+/*.......................................................................
+ * This is an action function which deletes character(s) under the
+ * cursor and moves the cursor back one character.
+ */
+static KT_KEY_FN(gl_backward_delete_char)
+{
+/*
+ * Restrict the deletion count to the number of characters that
+ * precede the insertion point.
+ */
+ if(count > gl->buff_curpos - gl->insert_curpos)
+ count = gl->buff_curpos - gl->insert_curpos;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+ return gl_cursor_left(gl, count) ||
+ gl_delete_chars(gl, count, gl->vi.command);
+}
+
+/*.......................................................................
+ * Starting from the cursor position delete to the specified column.
+ */
+static KT_KEY_FN(gl_delete_to_column)
+{
+ if (--count >= gl->buff_curpos)
+ return gl_forward_delete_char(gl, count - gl->buff_curpos);
+ else
+ return gl_backward_delete_char(gl, gl->buff_curpos - count);
+}
+
+/*.......................................................................
+ * Starting from the cursor position delete characters to a matching
+ * parenthesis.
+ */
+static KT_KEY_FN(gl_delete_to_parenthesis)
+{
+ int curpos = gl_index_of_matching_paren(gl);
+ if(curpos >= 0) {
+ gl_save_for_undo(gl);
+ if(curpos >= gl->buff_curpos)
+ return gl_forward_delete_char(gl, curpos - gl->buff_curpos + 1);
+ else
+ return gl_backward_delete_char(gl, ++gl->buff_curpos - curpos + 1);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which deletes from the cursor to the end
+ * of the word that the cursor is either in or precedes.
+ */
+static KT_KEY_FN(gl_forward_delete_word)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * In emacs mode delete to the end of the word. In vi mode delete to the
+ * start of the net word.
+ */
+ if(gl->editor == GL_EMACS_MODE) {
+ return gl_delete_chars(gl,
+ gl_nth_word_end_forward(gl,count) - gl->buff_curpos + 1, 1);
+ } else {
+ return gl_delete_chars(gl,
+ gl_nth_word_start_forward(gl,count) - gl->buff_curpos,
+ gl->vi.command);
+ };
+}
+
+/*.......................................................................
+ * This is an action function which deletes the word that precedes the
+ * cursor.
+ */
+static KT_KEY_FN(gl_backward_delete_word)
+{
+/*
+ * Keep a record of the current cursor position.
+ */
+ int buff_curpos = gl->buff_curpos;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Move back 'count' words.
+ */
+ if(gl_backward_word(gl, count))
+ return 1;
+/*
+ * Delete from the new cursor position to the original one.
+ */
+ return gl_delete_chars(gl, buff_curpos - gl->buff_curpos,
+ gl->editor == GL_EMACS_MODE || gl->vi.command);
+}
+
+/*.......................................................................
+ * Searching in a given direction, delete to the count'th
+ * instance of a specified or queried character, in the input line.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * count int The number of times to search.
+ * c char The character to be searched for, or '\0' if
+ * the character should be read from the user.
+ * forward int True if searching forward.
+ * onto int True if the search should end on top of the
+ * character, false if the search should stop
+ * one character before the character in the
+ * specified search direction.
+ * change int If true, this function is being called upon
+ * to do a vi change command, in which case the
+ * user will be left in insert mode after the
+ * deletion.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_delete_find(GetLine *gl, int count, char c, int forward,
+ int onto, int change)
+{
+/*
+ * Search for the character, and abort the deletion if not found.
+ */
+ int pos = gl_find_char(gl, count, forward, onto, c);
+ if(pos < 0)
+ return 0;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Allow the cursor to be at the end of the line if this is a change
+ * command.
+ */
+ if(change)
+ gl->vi.command = 0;
+/*
+ * Delete the appropriate span of characters.
+ */
+ if(forward) {
+ if(gl_delete_chars(gl, pos - gl->buff_curpos + 1, 1))
+ return 1;
+ } else {
+ int buff_curpos = gl->buff_curpos;
+ if(gl_place_cursor(gl, pos) ||
+ gl_delete_chars(gl, buff_curpos - gl->buff_curpos, 1))
+ return 1;
+ };
+/*
+ * If this is a change operation, switch the insert mode.
+ */
+ if(change && gl_vi_insert(gl, 0))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which deletes forward from the cursor up to and
+ * including a specified character.
+ */
+static KT_KEY_FN(gl_forward_delete_find)
+{
+ return gl_delete_find(gl, count, '\0', 1, 1, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes backward from the cursor back to
+ * and including a specified character.
+ */
+static KT_KEY_FN(gl_backward_delete_find)
+{
+ return gl_delete_find(gl, count, '\0', 0, 1, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes forward from the cursor up to but
+ * not including a specified character.
+ */
+static KT_KEY_FN(gl_forward_delete_to)
+{
+ return gl_delete_find(gl, count, '\0', 1, 0, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes backward from the cursor back to
+ * but not including a specified character.
+ */
+static KT_KEY_FN(gl_backward_delete_to)
+{
+ return gl_delete_find(gl, count, '\0', 0, 0, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes to a character specified by a
+ * previous search.
+ */
+static KT_KEY_FN(gl_delete_refind)
+{
+ return gl_delete_find(gl, count, gl->vi.find_char, gl->vi.find_forward,
+ gl->vi.find_onto, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes to a character specified by a
+ * previous search, but in the opposite direction.
+ */
+static KT_KEY_FN(gl_delete_invert_refind)
+{
+ return gl_delete_find(gl, count, gl->vi.find_char,
+ !gl->vi.find_forward, gl->vi.find_onto, 0);
+}
+
+/*.......................................................................
+ * This is an action function which converts the characters in the word
+ * following the cursor to upper case.
+ */
+static KT_KEY_FN(gl_upcase_word)
+{
+/*
+ * Locate the count'th word ending after the cursor.
+ */
+ int last = gl_nth_word_end_forward(gl, count);
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Upcase characters from the current cursor position to 'last'.
+ */
+ while(gl->buff_curpos <= last) {
+ char *cptr = gl->line + gl->buff_curpos++;
+/*
+ * Convert the character to upper case?
+ */
+ if(islower((int)(unsigned char) *cptr))
+ *cptr = toupper((int) *cptr);
+/*
+ * Write the possibly modified character back. Note that for non-modified
+ * characters we want to do this as well, so as to advance the cursor.
+ */
+ if(gl_output_char(gl, *cptr, cptr[1]))
+ return 1;
+ };
+ return gl_place_cursor(gl, gl->buff_curpos); /* bounds check */
+}
+
+/*.......................................................................
+ * This is an action function which converts the characters in the word
+ * following the cursor to lower case.
+ */
+static KT_KEY_FN(gl_downcase_word)
+{
+/*
+ * Locate the count'th word ending after the cursor.
+ */
+ int last = gl_nth_word_end_forward(gl, count);
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Upcase characters from the current cursor position to 'last'.
+ */
+ while(gl->buff_curpos <= last) {
+ char *cptr = gl->line + gl->buff_curpos++;
+/*
+ * Convert the character to upper case?
+ */
+ if(isupper((int)(unsigned char) *cptr))
+ *cptr = tolower((int) *cptr);
+/*
+ * Write the possibly modified character back. Note that for non-modified
+ * characters we want to do this as well, so as to advance the cursor.
+ */
+ if(gl_output_char(gl, *cptr, cptr[1]))
+ return 1;
+ };
+ return gl_place_cursor(gl, gl->buff_curpos); /* bounds check */
+}
+
+/*.......................................................................
+ * This is an action function which converts the first character of the
+ * following word to upper case, in order to capitalize the word, and
+ * leaves the cursor at the end of the word.
+ */
+static KT_KEY_FN(gl_capitalize_word)
+{
+ char *cptr; /* &gl->line[gl->buff_curpos] */
+ int first; /* True for the first letter of the word */
+ int i;
+/*
+ * Keep a record of the current insert mode and the cursor position.
+ */
+ int insert = gl->insert;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * We want to overwrite the modified word.
+ */
+ gl->insert = 0;
+/*
+ * Capitalize 'count' words.
+ */
+ for(i=0; ibuff_curpos < gl->ntotal; i++) {
+ int pos = gl->buff_curpos;
+/*
+ * If we are not already within a word, skip to the start of the word.
+ */
+ for(cptr = gl->line + pos ; posntotal && !gl_is_word_char((int) *cptr);
+ pos++, cptr++)
+ ;
+/*
+ * Move the cursor to the new position.
+ */
+ if(gl_place_cursor(gl, pos))
+ return 1;
+/*
+ * While searching for the end of the word, change lower case letters
+ * to upper case.
+ */
+ for(first=1; gl->buff_curposntotal && gl_is_word_char((int) *cptr);
+ gl->buff_curpos++, cptr++) {
+/*
+ * Convert the character to upper case?
+ */
+ if(first) {
+ if(islower((int)(unsigned char) *cptr))
+ *cptr = toupper((int) *cptr);
+ } else {
+ if(isupper((int)(unsigned char) *cptr))
+ *cptr = tolower((int) *cptr);
+ };
+ first = 0;
+/*
+ * Write the possibly modified character back. Note that for non-modified
+ * characters we want to do this as well, so as to advance the cursor.
+ */
+ if(gl_output_char(gl, *cptr, cptr[1]))
+ return 1;
+ };
+ };
+/*
+ * Restore the insertion mode.
+ */
+ gl->insert = insert;
+ return gl_place_cursor(gl, gl->buff_curpos); /* bounds check */
+}
+
+/*.......................................................................
+ * This is an action function which redraws the current line.
+ */
+static KT_KEY_FN(gl_redisplay)
+{
+/*
+ * Keep a record of the current cursor position.
+ */
+ int buff_curpos = gl->buff_curpos;
+/*
+ * Move the cursor to the start of the terminal line, and clear from there
+ * to the end of the display.
+ */
+ if(gl_set_term_curpos(gl, 0) ||
+ gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+/*
+ * Display the current prompt.
+ */
+ if(gl_display_prompt(gl))
+ return 1;
+/*
+ * Render the part of the line that the user has typed in so far.
+ */
+ if(gl_output_string(gl, gl->line, '\0'))
+ return 1;
+/*
+ * Restore the cursor position.
+ */
+ if(gl_place_cursor(gl, buff_curpos))
+ return 1;
+/*
+ * Flush the redisplayed line to the terminal.
+ */
+ return gl_flush_output(gl);
+}
+
+/*.......................................................................
+ * This is an action function which clears the display and redraws the
+ * input line from the home position.
+ */
+static KT_KEY_FN(gl_clear_screen)
+{
+/*
+ * Record the current cursor position.
+ */
+ int buff_curpos = gl->buff_curpos;
+/*
+ * Home the cursor and clear from there to the end of the display.
+ */
+ if(gl_output_control_sequence(gl, gl->nline, gl->home) ||
+ gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+/*
+ * Redisplay the line.
+ */
+ gl->term_curpos = 0;
+ gl->buff_curpos = 0;
+ if(gl_redisplay(gl,1))
+ return 1;
+/*
+ * Restore the cursor position.
+ */
+ return gl_place_cursor(gl, buff_curpos);
+}
+
+/*.......................................................................
+ * This is an action function which swaps the character under the cursor
+ * with the character to the left of the cursor.
+ */
+static KT_KEY_FN(gl_transpose_chars)
+{
+ char from[3]; /* The original string of 2 characters */
+ char swap[3]; /* The swapped string of two characters */
+/*
+ * If we are at the beginning or end of the line, there aren't two
+ * characters to swap.
+ */
+ if(gl->buff_curpos < 1 || gl->buff_curpos >= gl->ntotal)
+ return 0;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Get the original and swapped strings of the two characters.
+ */
+ from[0] = gl->line[gl->buff_curpos - 1];
+ from[1] = gl->line[gl->buff_curpos];
+ from[2] = '\0';
+ swap[0] = gl->line[gl->buff_curpos];
+ swap[1] = gl->line[gl->buff_curpos - 1];
+ swap[2] = '\0';
+/*
+ * Move the cursor to the start of the two characters.
+ */
+ if(gl_place_cursor(gl, gl->buff_curpos-1))
+ return 1;
+/*
+ * Swap the two characters in the buffer.
+ */
+ gl->line[gl->buff_curpos] = swap[0];
+ gl->line[gl->buff_curpos+1] = swap[1];
+/*
+ * If the sum of the displayed width of the two characters
+ * in their current and final positions is the same, swapping can
+ * be done by just overwriting with the two swapped characters.
+ */
+ if(gl_displayed_string_width(gl, from, -1, gl->term_curpos) ==
+ gl_displayed_string_width(gl, swap, -1, gl->term_curpos)) {
+ int insert = gl->insert;
+ gl->insert = 0;
+ if(gl_output_char(gl, swap[0], swap[1]) ||
+ gl_output_char(gl, swap[1], gl->line[gl->buff_curpos+2]))
+ return 1;
+ gl->insert = insert;
+/*
+ * If the swapped substring has a different displayed size, we need to
+ * redraw everything after the first of the characters.
+ */
+ } else {
+ if(gl_output_string(gl, gl->line + gl->buff_curpos, '\0') ||
+ gl_output_control_sequence(gl, gl->nline, gl->clear_eod))
+ return 1;
+ };
+/*
+ * Advance the cursor to the character after the swapped pair.
+ */
+ return gl_place_cursor(gl, gl->buff_curpos + 2);
+}
+
+/*.......................................................................
+ * This is an action function which sets a mark at the current cursor
+ * location.
+ */
+static KT_KEY_FN(gl_set_mark)
+{
+ gl->buff_mark = gl->buff_curpos;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which swaps the mark location for the
+ * cursor location.
+ */
+static KT_KEY_FN(gl_exchange_point_and_mark)
+{
+/*
+ * Get the old mark position, and limit to the extent of the input
+ * line.
+ */
+ int old_mark = gl->buff_mark <= gl->ntotal ? gl->buff_mark : gl->ntotal;
+/*
+ * Make the current cursor position the new mark.
+ */
+ gl->buff_mark = gl->buff_curpos;
+/*
+ * Move the cursor to the old mark position.
+ */
+ return gl_place_cursor(gl, old_mark);
+}
+
+/*.......................................................................
+ * This is an action function which deletes the characters between the
+ * mark and the cursor, recording them in gl->cutbuf for later pasting.
+ */
+static KT_KEY_FN(gl_kill_region)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Limit the mark to be within the line.
+ */
+ if(gl->buff_mark > gl->ntotal)
+ gl->buff_mark = gl->ntotal;
+/*
+ * If there are no characters between the cursor and the mark, simply clear
+ * the cut buffer.
+ */
+ if(gl->buff_mark == gl->buff_curpos) {
+ gl->cutbuf[0] = '\0';
+ return 0;
+ };
+/*
+ * If the mark is before the cursor, swap the cursor and the mark.
+ */
+ if(gl->buff_mark < gl->buff_curpos && gl_exchange_point_and_mark(gl,1))
+ return 1;
+/*
+ * Delete the characters.
+ */
+ if(gl_delete_chars(gl, gl->buff_mark - gl->buff_curpos, 1))
+ return 1;
+/*
+ * Make the mark the same as the cursor position.
+ */
+ gl->buff_mark = gl->buff_curpos;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which records the characters between the
+ * mark and the cursor, in gl->cutbuf for later pasting.
+ */
+static KT_KEY_FN(gl_copy_region_as_kill)
+{
+ int ca, cb; /* The indexes of the first and last characters in the region */
+ int mark; /* The position of the mark */
+/*
+ * Get the position of the mark, limiting it to lie within the line.
+ */
+ mark = gl->buff_mark > gl->ntotal ? gl->ntotal : gl->buff_mark;
+/*
+ * If there are no characters between the cursor and the mark, clear
+ * the cut buffer.
+ */
+ if(mark == gl->buff_curpos) {
+ gl->cutbuf[0] = '\0';
+ return 0;
+ };
+/*
+ * Get the line indexes of the first and last characters in the region.
+ */
+ if(mark < gl->buff_curpos) {
+ ca = mark;
+ cb = gl->buff_curpos - 1;
+ } else {
+ ca = gl->buff_curpos;
+ cb = mark - 1;
+ };
+/*
+ * Copy the region to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line + ca, cb + 1 - ca);
+ gl->cutbuf[cb + 1 - ca] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which inserts the contents of the cut
+ * buffer at the current cursor location.
+ */
+static KT_KEY_FN(gl_yank)
+{
+ int i;
+/*
+ * Set the mark at the current location.
+ */
+ gl->buff_mark = gl->buff_curpos;
+/*
+ * Do nothing else if the cut buffer is empty.
+ */
+ if(gl->cutbuf[0] == '\0')
+ return gl_ring_bell(gl, 1);
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Insert the string count times.
+ */
+ for(i=0; icutbuf))
+ return 1;
+ };
+/*
+ * gl_add_string_to_line() leaves the cursor after the last character that
+ * was pasted, whereas vi leaves the cursor over the last character pasted.
+ */
+ if(gl->editor == GL_VI_MODE && gl_cursor_left(gl, 1))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function which inserts the contents of the cut
+ * buffer one character beyond the current cursor location.
+ */
+static KT_KEY_FN(gl_append_yank)
+{
+ int was_command = gl->vi.command;
+ int i;
+/*
+ * If the cut buffer is empty, ring the terminal bell.
+ */
+ if(gl->cutbuf[0] == '\0')
+ return gl_ring_bell(gl, 1);
+/*
+ * Set the mark at the current location + 1.
+ */
+ gl->buff_mark = gl->buff_curpos + 1;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Arrange to paste the text in insert mode after the current character.
+ */
+ if(gl_vi_append(gl, 0))
+ return 1;
+/*
+ * Insert the string count times.
+ */
+ for(i=0; icutbuf))
+ return 1;
+ };
+/*
+ * Switch back to command mode if necessary.
+ */
+ if(was_command)
+ gl_vi_command_mode(gl);
+ return 0;
+}
+
+#ifdef USE_SIGWINCH
+/*.......................................................................
+ * Respond to the receipt of a window change signal.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * redisplay int If true redisplay the current line after
+ * getting the new window size.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_resize_terminal(GetLine *gl, int redisplay)
+{
+ int lines_used; /* The number of lines currently in use */
+ struct winsize size; /* The new size information */
+ int i;
+/*
+ * Record the fact that the sigwinch signal has been noted.
+ */
+ if(gl_pending_signal == SIGWINCH)
+ gl_pending_signal = -1;
+/*
+ * Query the new terminal window size. Ignore invalid responses.
+ */
+ if(ioctl(gl->output_fd, TIOCGWINSZ, &size) == 0 &&
+ size.ws_row > 0 && size.ws_col > 0) {
+/*
+ * Redisplay the input line?
+ */
+ if(redisplay) {
+/*
+ * How many lines are currently displayed.
+ */
+ lines_used = (gl_displayed_string_width(gl,gl->line,-1,gl->prompt_len) +
+ gl->prompt_len + gl->ncolumn - 1) / gl->ncolumn;
+/*
+ * Move to the cursor to the start of the line.
+ */
+ for(i=1; iup))
+ return 1;
+ };
+ if(gl_output_control_sequence(gl, 1, gl->bol))
+ return 1;
+/*
+ * Clear to the end of the terminal.
+ */
+ if(gl_output_control_sequence(gl, size.ws_row, gl->clear_eod))
+ return 1;
+/*
+ * Record the fact that the cursor is now at the beginning of the line.
+ */
+ gl->term_curpos = 0;
+ };
+/*
+ * Update the recorded window size.
+ */
+ gl->nline = size.ws_row;
+ gl->ncolumn = size.ws_col;
+ };
+/*
+ * Redisplay the line?
+ */
+ return redisplay ? gl_redisplay(gl,1) : 0;
+}
+#endif
+
+/*.......................................................................
+ * This is the action function that recalls the previous line in the
+ * history buffer.
+ */
+static KT_KEY_FN(gl_up_history)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * Forget any previous recall session.
+ */
+ gl->preload_id = 0;
+/*
+ * We don't want a search prefix for this function.
+ */
+ if(_glh_search_prefix(gl->glh, gl->line, 0))
+ return 1;
+/*
+ * Recall the count'th next older line in the history list. If the first one
+ * fails we can return since nothing has changed otherwise we must continue
+ * and update the line state.
+ */
+ if(_glh_find_backwards(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+ while(--count && _glh_find_backwards(gl->glh, gl->line, gl->linelen))
+ ;
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange to have the cursor placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * This is the action function that recalls the next line in the
+ * history buffer.
+ */
+static KT_KEY_FN(gl_down_history)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * If no search is currently in progress continue a previous recall
+ * session from a previous entered line if possible.
+ */
+ if(_glh_line_id(gl->glh, 0) == 0 && gl->preload_id) {
+ _glh_recall_line(gl->glh, gl->preload_id, gl->line, gl->linelen);
+ gl->preload_id = 0;
+ } else {
+/*
+ * We don't want a search prefix for this function.
+ */
+ if(_glh_search_prefix(gl->glh, gl->line, 0))
+ return 1;
+/*
+ * Recall the count'th next newer line in the history list. If the first one
+ * fails we can return since nothing has changed otherwise we must continue
+ * and update the line state.
+ */
+ if(_glh_find_forwards(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+ while(--count && _glh_find_forwards(gl->glh, gl->line, gl->linelen))
+ ;
+ };
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange to have the cursor placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * This is the action function that recalls the previous line in the
+ * history buffer whos prefix matches the characters that currently
+ * precede the cursor. By setting count=-1, this can be used internally
+ * to force searching for the prefix used in the last search.
+ */
+static KT_KEY_FN(gl_history_search_backward)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * Forget any previous recall session.
+ */
+ gl->preload_id = 0;
+/*
+ * If the previous thing that the user did wasn't to execute a history
+ * search function, set the search prefix equal to the string that
+ * precedes the cursor. In vi command mode include the character that
+ * is under the cursor in the string. If count<0 force a repeat search
+ * even if the last command wasn't a history command.
+ */
+ if(gl->last_search != gl->keyseq_count - 1 && count>=0 &&
+ _glh_search_prefix(gl->glh, gl->line, gl->buff_curpos +
+ (gl->editor==GL_VI_MODE && gl->ntotal>0)))
+ return 1;
+/*
+ * Record the key sequence number in which this search function is
+ * being executed, so that the next call to this function or
+ * gl_history_search_forward() knows if any other operations
+ * were performed in between.
+ */
+ gl->last_search = gl->keyseq_count;
+/*
+ * Search backwards for a match to the part of the line which precedes the
+ * cursor.
+ */
+ if(_glh_find_backwards(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange to have the cursor placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * This is the action function that recalls the previous line in the
+ * history buffer who's prefix matches that specified in an earlier call
+ * to gl_history_search_backward() or gl_history_search_forward().
+ */
+static KT_KEY_FN(gl_history_re_search_backward)
+{
+ return gl_history_search_backward(gl, -1);
+}
+
+/*.......................................................................
+ * This is the action function that recalls the next line in the
+ * history buffer who's prefix matches that specified in the earlier call
+ * to gl_history_search_backward) which started the history search.
+ * By setting count=-1, this can be used internally to force searching
+ * for the prefix used in the last search.
+ */
+static KT_KEY_FN(gl_history_search_forward)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * If the previous thing that the user did wasn't to execute a history
+ * search function, set the search prefix equal to the string that
+ * precedes the cursor. In vi command mode include the character that
+ * is under the cursor in the string. If count<0 force a repeat search
+ * even if the last command wasn't a history command.
+ */
+ if(gl->last_search != gl->keyseq_count - 1 && count>=0 &&
+ _glh_search_prefix(gl->glh, gl->line, gl->buff_curpos +
+ (gl->editor==GL_VI_MODE && gl->ntotal>0)))
+ return 1;
+/*
+ * Record the key sequence number in which this search function is
+ * being executed, so that the next call to this function or
+ * gl_history_search_backward() knows if any other operations
+ * were performed in between.
+ */
+ gl->last_search = gl->keyseq_count;
+/*
+ * Search forwards for the next matching line.
+ */
+ if(_glh_find_forwards(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange for the cursor to be placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * This is the action function that recalls the next line in the
+ * history buffer who's prefix matches that specified in an earlier call
+ * to gl_history_search_backward() or gl_history_search_forward().
+ */
+static KT_KEY_FN(gl_history_re_search_forward)
+{
+ return gl_history_search_forward(gl, -1);
+}
+
+/*.......................................................................
+ * This is the tab completion function that completes the filename that
+ * precedes the cursor position.
+ */
+static KT_KEY_FN(gl_complete_word)
+{
+ CplMatches *matches; /* The possible completions */
+ int redisplay=0; /* True if the whole line needs to be redrawn */
+ int suffix_len; /* The length of the completion extension */
+ int cont_len; /* The length of any continuation suffix */
+ int nextra; /* The number of characters being added to the */
+ /* total length of the line. */
+ int buff_pos; /* The buffer index at which the completion is */
+ /* to be inserted. */
+/*
+ * In vi command mode, switch to append mode so that the character below
+ * the character is included in the completion (otherwise people can't
+ * complete at the end of the line).
+ */
+ if(gl->vi.command && gl_vi_append(gl, 0))
+ return 1;
+/*
+ * Get the cursor position at which the completion is to be inserted.
+ */
+ buff_pos = gl->buff_curpos;
+/*
+ * Perform the completion.
+ */
+ matches = cpl_complete_word(gl->cpl, gl->line, gl->buff_curpos, gl->cpl_data,
+ gl->cpl_fn);
+ if(!matches) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", cpl_last_error(gl->cpl)) < 0)
+ return 1;
+ gl->term_curpos = 0;
+ redisplay = 1;
+/*
+ * Are there any completions?
+ */
+ } else if(matches->nmatch >= 1) {
+/*
+ * If there any ambiguous matches, report them, starting on a new line.
+ */
+ if(matches->nmatch > 1 && gl->echo) {
+ if(fprintf(gl->output_fp, "\r\n") < 0)
+ return 1;
+ cpl_list_completions(matches, gl->output_fp, gl->ncolumn);
+ redisplay = 1;
+ };
+/*
+ * If the callback called gl_change_prompt(), we will need to redisplay
+ * the whole line.
+ */
+ if(gl->prompt_changed)
+ redisplay = 1;
+/*
+ * Get the length of the suffix and any continuation suffix to add to it.
+ */
+ suffix_len = strlen(matches->suffix);
+ cont_len = strlen(matches->cont_suffix);
+/*
+ * If there is an unambiguous match, and the continuation suffix ends in
+ * a newline, strip that newline and arrange to have getline return
+ * after this action function returns.
+ */
+ if(matches->nmatch==1 && cont_len > 0 &&
+ matches->cont_suffix[cont_len - 1] == '\n') {
+ cont_len--;
+ if(gl_newline(gl, 1))
+ return 1;
+ };
+/*
+ * Work out the number of characters that are to be added.
+ */
+ nextra = suffix_len + cont_len;
+/*
+ * Is there anything to be added?
+ */
+ if(nextra) {
+/*
+ * Will there be space for the expansion in the line buffer?
+ */
+ if(gl->ntotal + nextra < gl->linelen) {
+/*
+ * Make room to insert the filename extension.
+ */
+ memmove(gl->line + gl->buff_curpos + nextra, gl->line + gl->buff_curpos,
+ gl->ntotal - gl->buff_curpos);
+/*
+ * Insert the filename extension.
+ */
+ memcpy(gl->line + gl->buff_curpos, matches->suffix, suffix_len);
+/*
+ * Add the terminating characters.
+ */
+ memcpy(gl->line + gl->buff_curpos + suffix_len, matches->cont_suffix,
+ cont_len);
+/*
+ * Record the increased length of the line.
+ */
+ gl->ntotal += nextra;
+/*
+ * Place the cursor position at the end of the completion.
+ */
+ gl->buff_curpos += nextra;
+/*
+ * Terminate the extended line.
+ */
+ gl->line[gl->ntotal] = '\0';
+/*
+ * If we don't have to redisplay the whole line, redisplay the part
+ * of the line which follows the original cursor position, and place
+ * the cursor at the end of the completion.
+ */
+ if(!redisplay) {
+ if(gl_output_control_sequence(gl, gl->nline, gl->clear_eod) ||
+ gl_output_string(gl, gl->line + buff_pos, '\0') ||
+ gl_place_cursor(gl, gl->buff_curpos))
+ return 1;
+ };
+ } else {
+ fprintf(stderr,
+ "\r\nInsufficient room in line for file completion.\r\n");
+ redisplay = 1;
+ };
+ };
+ };
+/*
+ * Redisplay the whole line?
+ */
+ if(redisplay) {
+ gl->term_curpos = 0;
+ if(gl_redisplay(gl,1))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This is the function that expands the filename that precedes the
+ * cursor position. It expands ~user/ expressions, $envvar expressions,
+ * and wildcards.
+ */
+static KT_KEY_FN(gl_expand_filename)
+{
+ char *start_path; /* The pointer to the start of the pathname in */
+ /* gl->line[]. */
+ FileExpansion *result; /* The results of the filename expansion */
+ int pathlen; /* The length of the pathname being expanded */
+ int redisplay=0; /* True if the whole line needs to be redrawn */
+ int length; /* The number of characters needed to display the */
+ /* expanded files. */
+ int nextra; /* The number of characters to be added */
+ int i,j;
+/*
+ * In vi command mode, switch to append mode so that the character below
+ * the character is included in the completion (otherwise people can't
+ * complete at the end of the line).
+ */
+ if(gl->vi.command && gl_vi_append(gl, 0))
+ return 1;
+/*
+ * Locate the start of the filename that precedes the cursor position.
+ */
+ start_path = _pu_start_of_path(gl->line,
+ gl->buff_curpos > 0 ? gl->buff_curpos : 0);
+ if(!start_path)
+ return 1;
+/*
+ * Get the length of the string that is to be expanded.
+ */
+ pathlen = gl->buff_curpos - (start_path - gl->line);
+/*
+ * Attempt to expand it.
+ */
+ result = ef_expand_file(gl->ef, start_path, pathlen);
+/*
+ * If there was an error, report the error on a new line, then redraw
+ * the original line.
+ */
+ if(!result) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", ef_last_error(gl->ef)) < 0)
+ return 1;
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+ };
+/*
+ * If no files matched, report this as well.
+ */
+ if(result->nfile == 0 || !result->exists) {
+ if(gl->echo && fprintf(gl->output_fp, "\r\nNo files match.\n") < 0)
+ return 1;
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+ };
+/*
+ * If in vi command mode, preserve the current line for potential use by
+ * vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Work out how much space we will need to display all of the matching
+ * filenames, taking account of the space that we need to place between
+ * them, and the number of additional '\' characters needed to escape
+ * spaces, tabs and backslash characters in the individual filenames.
+ */
+ length = 0;
+ for(i=0; infile; i++) {
+ char *file = result->files[i];
+ while(*file) {
+ int c = *file++;
+ switch(c) {
+ case ' ': case '\t': case '\\': case '*': case '?': case '[':
+ length++; /* Count extra backslash characters */
+ };
+ length++; /* Count the character itself */
+ };
+ length++; /* Count the space that follows each filename */
+ };
+/*
+ * Work out the number of characters that are to be added.
+ */
+ nextra = length - pathlen;
+/*
+ * Will there be space for the expansion in the line buffer?
+ */
+ if(gl->ntotal + nextra >= gl->linelen) {
+ fprintf(stderr, "\r\nInsufficient room in line for file expansion.\r\n");
+ redisplay = 1;
+ } else {
+/*
+ * Do we need to move the part of the line that followed the unexpanded
+ * filename?
+ */
+ if(nextra != 0) {
+ memmove(gl->line + gl->buff_curpos + nextra, gl->line + gl->buff_curpos,
+ gl->ntotal - gl->buff_curpos);
+ };
+/*
+ * Insert the filenames, separated by spaces, and with internal spaces,
+ * tabs and backslashes escaped with backslashes.
+ */
+ for(i=0,j=start_path - gl->line; infile; i++) {
+ char *file = result->files[i];
+ while(*file) {
+ int c = *file++;
+ switch(c) {
+ case ' ': case '\t': case '\\': case '*': case '?': case '[':
+ gl->line[j++] = '\\';
+ };
+ gl->line[j++] = c;
+ };
+ gl->line[j++] = ' ';
+ };
+/*
+ * Record the increased length of the line.
+ */
+ gl->ntotal += nextra;
+/*
+ * Place the cursor position at the end of the expansion.
+ */
+ gl->buff_curpos += nextra;
+/*
+ * Terminate the extended line.
+ */
+ gl->line[gl->ntotal] = '\0';
+ };
+/*
+ * Display the whole line on a new line?
+ */
+ if(redisplay) {
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+ };
+/*
+ * Otherwise redisplay the part of the line which follows the start of
+ * the original filename.
+ */
+ if(gl_set_term_curpos(gl, gl_buff_curpos_to_term_curpos(gl, start_path - gl->line)) ||
+ gl_output_control_sequence(gl, gl->nline, gl->clear_eod) ||
+ gl_output_string(gl, start_path, gl->line[gl->buff_curpos]))
+ return 1;
+/*
+ * Restore the cursor position to the end of the expansion.
+ */
+ return gl_place_cursor(gl, gl->buff_curpos);
+}
+
+/*.......................................................................
+ * This is the action function that lists glob expansions of the
+ * filename that precedes the cursor position. It expands ~user/
+ * expressions, $envvar expressions, and wildcards.
+ */
+static KT_KEY_FN(gl_list_glob)
+{
+ char *start_path; /* The pointer to the start of the pathname in */
+ /* gl->line[]. */
+ FileExpansion *result; /* The results of the filename expansion */
+ int pathlen; /* The length of the pathname being expanded */
+/*
+ * Locate the start of the filename that precedes the cursor position.
+ */
+ start_path = _pu_start_of_path(gl->line,
+ gl->buff_curpos > 0 ? gl->buff_curpos : 0);
+ if(!start_path)
+ return 1;
+/*
+ * Get the length of the string that is to be expanded.
+ */
+ pathlen = gl->buff_curpos - (start_path - gl->line);
+/*
+ * Attempt to expand it.
+ */
+ result = ef_expand_file(gl->ef, start_path, pathlen);
+/*
+ * If there was an error, report the error.
+ */
+ if(!result) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", ef_last_error(gl->ef)) < 0)
+ return 1;
+/*
+ * If no files matched, report this as well.
+ */
+ } else if(result->nfile == 0 || !result->exists) {
+ if(gl->echo && fprintf(gl->output_fp, "\r\nNo files match.\n") < 0)
+ return 1;
+/*
+ * List the matching expansions.
+ */
+ } else if(gl->echo) {
+ if(fprintf(gl->output_fp, "\r\n") < 0)
+ return 1;
+ ef_list_expansions(result, gl->output_fp, gl->ncolumn);
+ };
+/*
+ * Redisplay the line being edited.
+ */
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * Return non-zero if a character should be considered a part of a word.
+ *
+ * Input:
+ * c int The character to be tested.
+ * Output:
+ * return int True if the character should be considered part of a word.
+ */
+static int gl_is_word_char(int c)
+{
+ return isalnum((int)(unsigned char)c) || strchr(GL_WORD_CHARS, c) != NULL;
+}
+
+/*.......................................................................
+ * Override the builtin file-completion callback that is bound to the
+ * "complete_word" action function.
+ *
+ * Input:
+ * gl GetLine * The resource object of the command-line input
+ * module.
+ * data void * This is passed to match_fn() whenever it is
+ * called. It could, for example, point to a
+ * symbol table where match_fn() could look
+ * for possible completions.
+ * match_fn CplMatchFn * The function that will identify the prefix
+ * to be completed from the input line, and
+ * report matching symbols.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_customize_completion(GetLine *gl, void *data, CplMatchFn *match_fn)
+{
+/*
+ * Check the arguments.
+ */
+ if(!gl || !match_fn) {
+ fprintf(stderr, "gl_customize_completion: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Record the new completion function and its callback data.
+ */
+ gl->cpl_fn = match_fn;
+ gl->cpl_data = data;
+ return 0;
+}
+
+/*.......................................................................
+ * Change the terminal (or stream) that getline interacts with.
+ *
+ * Input:
+ * gl GetLine * The resource object of the command-line input
+ * module.
+ * input_fp FILE * The stdio stream to read from.
+ * output_fp FILE * The stdio stream to write to.
+ * term char * The terminal type. This can be NULL if
+ * either or both of input_fp and output_fp don't
+ * refer to a terminal. Otherwise it should refer
+ * to an entry in the terminal information database.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_change_terminal(GetLine *gl, FILE *input_fp, FILE *output_fp,
+ const char *term)
+{
+ int is_term = 0; /* True if both input_fd and output_fd are associated */
+ /* with a terminal. */
+/*
+ * Require that input_fp and output_fp both be valid.
+ */
+ if(!input_fp || !output_fp) {
+ fprintf(stderr, "\r\ngl_change_terminal: Bad input/output stream(s).\n");
+ return 1;
+ };
+/*
+ * If we are displacing a previous terminal, remove it from the list
+ * of fds being watched.
+ */
+#ifdef HAVE_SELECT
+ if(gl->input_fd >= 0)
+ FD_CLR(gl->input_fd, &gl->rfds);
+#endif
+/*
+ * Record the file descriptors and streams.
+ */
+ gl->input_fp = input_fp;
+ gl->input_fd = fileno(input_fp);
+ gl->output_fp = output_fp;
+ gl->output_fd = fileno(output_fp);
+/*
+ * Make sure that the file descriptor will be visible in the set to
+ * be watched.
+ */
+#ifdef HAVE_SELECT
+ FD_SET(gl->input_fd, &gl->rfds);
+ if(gl->input_fd > gl->max_fd)
+ gl->max_fd = gl->input_fd;
+#endif
+/*
+ * Disable terminal interaction until we have enough info to interact
+ * with the terminal.
+ */
+ gl->is_term = 0;
+/*
+ * For terminal editing, we need both output_fd and input_fd to refer to
+ * a terminal. While we can't verify that they both point to the same
+ * terminal, we can verify that they point to terminals.
+ */
+ is_term = isatty(gl->input_fd) && isatty(gl->output_fd);
+/*
+ * If we are interacting with a terminal and no terminal type has been
+ * specified, treat it as a generic ANSI terminal.
+ */
+ if(is_term && !term)
+ term = "ansi";
+/*
+ * Make a copy of the terminal type string.
+ */
+ if(term != gl->term) {
+/*
+ * Delete any old terminal type string.
+ */
+ if(gl->term) {
+ free(gl->term);
+ gl->term = NULL;
+ };
+/*
+ * Make a copy of the new terminal-type string, if any.
+ */
+ if(term) {
+ gl->term = (char *) malloc(strlen(term)+1);
+ if(gl->term)
+ strcpy(gl->term, term);
+ };
+ };
+/*
+ * Clear any terminal-specific key bindings that were taken from the
+ * settings of the last terminal.
+ */
+ _kt_clear_bindings(gl->bindings, KTB_TERM);
+/*
+ * If we have a terminal install new bindings for it.
+ */
+ if(is_term) {
+/*
+ * Get the current settings of the terminal.
+ */
+ if(tcgetattr(gl->input_fd, &gl->oldattr)) {
+ fprintf(stderr, "\r\ngl_change_terminal: tcgetattr error: %s\n",
+ strerror(errno));
+ return 1;
+ };
+/*
+ * Lookup the terminal control string and size information.
+ */
+ if(gl_control_strings(gl, term))
+ return 1;
+/*
+ * We now have enough info to interact with the terminal.
+ */
+ gl->is_term = 1;
+/*
+ * Bind terminal-specific keys.
+ */
+ if(gl_bind_terminal_keys(gl))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Set up terminal-specific key bindings.
+ *
+ * Input:
+ * gl GetLine * The resource object of the command-line input
+ * module.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_bind_terminal_keys(GetLine *gl)
+{
+/*
+ * Install key-bindings for the special terminal characters.
+ */
+ if(gl_bind_control_char(gl, KTB_TERM, gl->oldattr.c_cc[VINTR],
+ "user-interrupt") ||
+ gl_bind_control_char(gl, KTB_TERM, gl->oldattr.c_cc[VQUIT], "abort") ||
+ gl_bind_control_char(gl, KTB_TERM, gl->oldattr.c_cc[VSUSP], "suspend"))
+ return 1;
+/*
+ * In vi-mode, arrange for the above characters to be seen in command
+ * mode.
+ */
+ if(gl->editor == GL_VI_MODE) {
+ if(gl_bind_control_char(gl, KTB_TERM, MAKE_META(gl->oldattr.c_cc[VINTR]),
+ "user-interrupt") ||
+ gl_bind_control_char(gl, KTB_TERM, MAKE_META(gl->oldattr.c_cc[VQUIT]),
+ "abort") ||
+ gl_bind_control_char(gl, KTB_TERM, MAKE_META(gl->oldattr.c_cc[VSUSP]),
+ "suspend"))
+ return 1;
+ };
+/*
+ * Non-universal special keys.
+ */
+#ifdef VLNEXT
+ if(gl_bind_control_char(gl, KTB_TERM, gl->oldattr.c_cc[VLNEXT],
+ "literal-next"))
+ return 1;
+#else
+ if(_kt_set_keybinding(gl->bindings, KTB_TERM, "^V", "literal-next"))
+ return 1;
+#endif
+/*
+ * Bind action functions to the terminal-specific arrow keys
+ * looked up by gl_control_strings().
+ */
+ if(_gl_bind_arrow_keys(gl))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * This function is normally bound to control-D. When it is invoked within
+ * a line it deletes the character which follows the cursor. When invoked
+ * at the end of the line it lists possible file completions, and when
+ * invoked on an empty line it causes gl_get_line() to return EOF. This
+ * function emulates the one that is normally bound to control-D by tcsh.
+ */
+static KT_KEY_FN(gl_del_char_or_list_or_eof)
+{
+/*
+ * If we have an empty line arrange to return EOF.
+ */
+ if(gl->ntotal < 1) {
+ return 1;
+/*
+ * If we are at the end of the line list possible completions.
+ */
+ } else if(gl->buff_curpos >= gl->ntotal) {
+/*
+ * Get the list of possible completions.
+ */
+ CplMatches *matches = cpl_complete_word(gl->cpl, gl->line, gl->buff_curpos,
+ gl->cpl_data, gl->cpl_fn);
+ if(!matches) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", cpl_last_error(gl->cpl)) < 0)
+ return 1;
+ gl->term_curpos = 0;
+/*
+ * List the matches.
+ */
+ } else if(matches->nmatch > 0 && gl->echo) {
+ if(fprintf(gl->output_fp, "\r\n") < 0)
+ return 1;
+ cpl_list_completions(matches, gl->output_fp, gl->ncolumn);
+ };
+/*
+ * Redisplay the line unchanged.
+ */
+ return gl_redisplay(gl,1);
+/*
+ * Within the line delete the character that follows the cursor.
+ */
+ } else {
+/*
+ * If in vi command mode, first preserve the current line for potential use
+ * by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Delete 'count' characters.
+ */
+ return gl_forward_delete_char(gl, count);
+ };
+}
+
+/*.......................................................................
+ * This function is normally bound to control-D in vi mode. When it is
+ * invoked within a line it lists possible file completions, and when
+ * invoked on an empty line it causes gl_get_line() to return EOF. This
+ * function emulates the one that is normally bound to control-D by tcsh.
+ */
+static KT_KEY_FN(gl_list_or_eof)
+{
+/*
+ * If we have an empty line arrange to return EOF.
+ */
+ if(gl->ntotal < 1) {
+ return 1;
+/*
+ * Otherwise list possible completions.
+ */
+ } else {
+/*
+ * Get the list of possible completions.
+ */
+ CplMatches *matches = cpl_complete_word(gl->cpl, gl->line, gl->buff_curpos,
+ gl->cpl_data, gl->cpl_fn);
+ if(!matches) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", cpl_last_error(gl->cpl)) < 0)
+ return 1;
+ gl->term_curpos = 0;
+/*
+ * List the matches.
+ */
+ } else if(matches->nmatch > 0 && gl->echo) {
+ if(fprintf(gl->output_fp, "\r\n") < 0)
+ return 1;
+ cpl_list_completions(matches, gl->output_fp, gl->ncolumn);
+ };
+/*
+ * Redisplay the line unchanged.
+ */
+ return gl_redisplay(gl,1);
+ };
+}
+
+/*.......................................................................
+ * Where the user has used the symbolic arrow-key names to specify
+ * arrow key bindings, bind the specified action functions to the default
+ * and terminal specific arrow key sequences.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int _gl_bind_arrow_keys(GetLine *gl)
+{
+/*
+ * Process each of the arrow keys.
+ */
+ if(_gl_rebind_arrow_key(gl->bindings, "up", gl->u_arrow, "^[[A", "^[OA") ||
+ _gl_rebind_arrow_key(gl->bindings, "down", gl->d_arrow, "^[[B", "^[OB") ||
+ _gl_rebind_arrow_key(gl->bindings, "left", gl->l_arrow, "^[[D", "^[OD") ||
+ _gl_rebind_arrow_key(gl->bindings, "right", gl->r_arrow, "^[[C", "^[OC"))
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * Lookup the action function of a symbolic arrow-key binding, and bind
+ * it to the terminal-specific and default arrow-key sequences. Note that
+ * we don't trust the terminal-specified key sequences to be correct.
+ * The main reason for this is that on some machines the xterm terminfo
+ * entry is for hardware X-terminals, rather than xterm terminal emulators
+ * and the two terminal types emit different character sequences when the
+ * their cursor keys are pressed. As a result we also supply a couple
+ * of default key sequences.
+ *
+ * Input:
+ * bindings KeyTab * The table of key bindings.
+ * name char * The symbolic name of the arrow key.
+ * term_seq char * The terminal-specific arrow-key sequence.
+ * def_seq1 char * The first default arrow-key sequence.
+ * def_seq2 char * The second arrow-key sequence.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int _gl_rebind_arrow_key(KeyTab *bindings, const char *name,
+ const char *term_seq, const char *def_seq1,
+ const char *def_seq2)
+{
+ int first,last; /* The indexes of the first and last matching entries */
+/*
+ * Lookup the key binding for the symbolic name of the arrow key. This
+ * will either be the default action, or a user provided one.
+ */
+ if(_kt_lookup_keybinding(bindings, name, strlen(name), &first, &last)
+ == KT_EXACT_MATCH) {
+/*
+ * Get the action function.
+ */
+ KtKeyFn *key_fn = bindings->table[first].keyfn;
+/*
+ * Bind this to each of the specified key sequences.
+ */
+ if((term_seq && _kt_set_keyfn(bindings, KTB_TERM, term_seq, key_fn)) ||
+ (def_seq1 && _kt_set_keyfn(bindings, KTB_NORM, def_seq1, key_fn)) ||
+ (def_seq2 && _kt_set_keyfn(bindings, KTB_NORM, def_seq2, key_fn)))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Read getline configuration information from a given file.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * filename const char * The name of the file to read configuration
+ * information from. The contents of this file
+ * are as described in the gl_get_line(3) man
+ * page for the default ~/.teclarc configuration
+ * file.
+ * who KtBinder Who bindings are to be installed for.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Irrecoverable error.
+ */
+static int _gl_read_config_file(GetLine *gl, const char *filename, KtBinder who)
+{
+ FileExpansion *expansion; /* The expansion of the filename */
+ FILE *fp; /* The opened file */
+ int waserr = 0; /* True if an error occurred while reading */
+ int lineno = 1; /* The line number being processed */
+/*
+ * Check the arguments.
+ */
+ if(!gl || !filename) {
+ fprintf(stderr, "_gl_read_config_file: Invalid arguments.\n");
+ return 1;
+ };
+/*
+ * Expand the filename.
+ */
+ expansion = ef_expand_file(gl->ef, filename, -1);
+ if(!expansion) {
+ fprintf(stderr, "Unable to expand %s (%s).\n", filename,
+ ef_last_error(gl->ef));
+ return 1;
+ };
+/*
+ * Attempt to open the file.
+ */
+ fp = fopen(expansion->files[0], "r");
+/*
+ * It isn't an error for there to be no configuration file.
+ */
+ if(!fp)
+ return 0;
+/*
+ * Parse the contents of the file.
+ */
+ while(!waserr && !feof(fp))
+ waserr = _gl_parse_config_line(gl, fp, glc_file_getc, filename, who,
+ &lineno);
+/*
+ * Bind action functions to the terminal-specific arrow keys.
+ */
+ if(_gl_bind_arrow_keys(gl))
+ return 1;
+/*
+ * Clean up.
+ */
+ (void) fclose(fp);
+ return waserr;
+}
+
+/*.......................................................................
+ * Read GetLine configuration information from a string. The contents of
+ * the string are the same as those described in the gl_get_line(3)
+ * man page for the contents of the ~/.teclarc configuration file.
+ */
+static int _gl_read_config_string(GetLine *gl, const char *buffer, KtBinder who)
+{
+ const char *bptr; /* A pointer into buffer[] */
+ int waserr = 0; /* True if an error occurred while reading */
+ int lineno = 1; /* The line number being processed */
+/*
+ * Check the arguments.
+ */
+ if(!gl || !buffer) {
+ fprintf(stderr, "_gl_read_config_string: Invalid arguments.\n");
+ return 1;
+ };
+/*
+ * Get a pointer to the start of the buffer.
+ */
+ bptr = buffer;
+/*
+ * Parse the contents of the buffer.
+ */
+ while(!waserr && *bptr)
+ waserr = _gl_parse_config_line(gl, &bptr, glc_buff_getc, "", who, &lineno);
+/*
+ * Bind action functions to the terminal-specific arrow keys.
+ */
+ if(_gl_bind_arrow_keys(gl))
+ return 1;
+ return waserr;
+}
+
+/*.......................................................................
+ * Parse the next line of a getline configuration file.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * stream void * The pointer representing the stream to be read
+ * by getc_fn().
+ * getc_fn GlcGetcFn * A callback function which when called with
+ * 'stream' as its argument, returns the next
+ * unread character from the stream.
+ * origin const char * The name of the entity being read (eg. a
+ * file name).
+ * who KtBinder Who bindings are to be installed for.
+ * Input/Output:
+ * lineno int * The line number being processed is to be
+ * maintained in *lineno.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Irrecoverable error.
+ */
+static int _gl_parse_config_line(GetLine *gl, void *stream, GlcGetcFn *getc_fn,
+ const char *origin, KtBinder who, int *lineno)
+{
+ char buffer[GL_CONF_BUFLEN+1]; /* The input line buffer */
+ char *argv[GL_CONF_MAXARG]; /* The argument list */
+ int argc = 0; /* The number of arguments in argv[] */
+ int c; /* A character from the file */
+ int escaped = 0; /* True if the next character is escaped */
+ int i;
+/*
+ * Skip spaces and tabs.
+ */
+ do c = getc_fn(stream); while(c==' ' || c=='\t');
+/*
+ * Comments extend to the end of the line.
+ */
+ if(c=='#')
+ do c = getc_fn(stream); while(c != '\n' && c != EOF);
+/*
+ * Ignore empty lines.
+ */
+ if(c=='\n' || c==EOF) {
+ (*lineno)++;
+ return 0;
+ };
+/*
+ * Record the buffer location of the start of the first argument.
+ */
+ argv[argc] = buffer;
+/*
+ * Read the rest of the line, stopping early if a comment is seen, or
+ * the buffer overflows, and replacing sequences of spaces with a
+ * '\0', and recording the thus terminated string as an argument.
+ */
+ i = 0;
+ while(i= GL_CONF_MAXARG) {
+ fprintf(stderr, "%s:%d: Too many arguments.\n", origin, *lineno);
+ do c = getc_fn(stream); while(c != '\n' && c != EOF); /* Skip past eol */
+ return 0;
+ };
+ argv[argc] = buffer + i;
+/*
+ * The next character was preceded by spaces, so it isn't escaped.
+ */
+ escaped = 0;
+ } else {
+/*
+ * If we hit an unescaped backslash, this means that we should arrange
+ * to treat the next character like a simple alphabetical character.
+ */
+ if(c=='\\' && !escaped) {
+ escaped = 1;
+/*
+ * Splice lines where the newline is escaped.
+ */
+ } else if(c=='\n' && escaped) {
+ (*lineno)++;
+/*
+ * Record a normal character, preserving any preceding backslash.
+ */
+ } else {
+ if(escaped)
+ buffer[i++] = '\\';
+ if(i>=GL_CONF_BUFLEN)
+ break;
+ escaped = 0;
+ buffer[i++] = c;
+ };
+/*
+ * Get the next character.
+ */
+ c = getc_fn(stream);
+ };
+ };
+/*
+ * Did the buffer overflow?
+ */
+ if(i>=GL_CONF_BUFLEN) {
+ fprintf(stderr, "%s:%d: Line too long.\n", origin, *lineno);
+ return 0;
+ };
+/*
+ * The first argument should be a command name.
+ */
+ if(strcmp(argv[0], "bind") == 0) {
+ const char *action = NULL; /* A NULL action removes a keybinding */
+ const char *keyseq = NULL;
+ switch(argc) {
+ case 3:
+ action = argv[2];
+ case 2: /* Note the intentional fallthrough */
+ keyseq = argv[1];
+/*
+ * Attempt to record the new keybinding.
+ */
+ if(_kt_set_keybinding(gl->bindings, who, keyseq, action)) {
+ fprintf(stderr, "The error occurred at line %d of %s.\n", *lineno,
+ origin);
+ };
+ break;
+ default:
+ fprintf(stderr, "%s:%d: Wrong number of arguments.\n", origin, *lineno);
+ };
+ } else if(strcmp(argv[0], "edit-mode") == 0) {
+ if(argc == 2 && strcmp(argv[1], "emacs") == 0) {
+ gl_change_editor(gl, GL_EMACS_MODE);
+ } else if(argc == 2 && strcmp(argv[1], "vi") == 0) {
+ gl_change_editor(gl, GL_VI_MODE);
+ } else if(argc == 2 && strcmp(argv[1], "none") == 0) {
+ gl_change_editor(gl, GL_NO_EDITOR);
+ } else {
+ fprintf(stderr, "%s:%d: The argument of editor should be vi or emacs.\n",
+ origin, *lineno);
+ };
+ } else if(strcmp(argv[0], "nobeep") == 0) {
+ gl->silence_bell = 1;
+ } else {
+ fprintf(stderr, "%s:%d: Unknown command name '%s'.\n", origin, *lineno,
+ argv[0]);
+ };
+/*
+ * Skip any trailing comment.
+ */
+ while(c != '\n' && c != EOF)
+ c = getc_fn(stream);
+ (*lineno)++;
+ return 0;
+}
+
+/*.......................................................................
+ * This is the _gl_parse_config_line() callback function which reads the
+ * next character from a configuration file.
+ */
+static GLC_GETC_FN(glc_file_getc)
+{
+ return fgetc((FILE *) stream);
+}
+
+/*.......................................................................
+ * This is the _gl_parse_config_line() callback function which reads the
+ * next character from a buffer. Its stream argument is a pointer to a
+ * variable which is, in turn, a pointer into the buffer being read from.
+ */
+static GLC_GETC_FN(glc_buff_getc)
+{
+ const char **lptr = (char const **) stream;
+ return **lptr ? *(*lptr)++ : EOF;
+}
+
+/*.......................................................................
+ * When this action is triggered, it arranges to temporarily read command
+ * lines from the regular file whos name precedes the cursor.
+ * The current line is first discarded.
+ */
+static KT_KEY_FN(gl_read_from_file)
+{
+ char *start_path; /* The pointer to the start of the pathname in */
+ /* gl->line[]. */
+ FileExpansion *result; /* The results of the filename expansion */
+ int pathlen; /* The length of the pathname being expanded */
+ int error_reported = 0; /* True after an error has been reported */
+/*
+ * Locate the start of the filename that precedes the cursor position.
+ */
+ start_path = _pu_start_of_path(gl->line,
+ gl->buff_curpos > 0 ? gl->buff_curpos : 0);
+ if(!start_path)
+ return 1;
+/*
+ * Get the length of the pathname string.
+ */
+ pathlen = gl->buff_curpos - (start_path - gl->line);
+/*
+ * Attempt to expand the pathname.
+ */
+ result = ef_expand_file(gl->ef, start_path, pathlen);
+/*
+ * If there was an error, report the error on a new line, then redraw
+ * the original line.
+ */
+ if(!result) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\n%s\n", ef_last_error(gl->ef)) < 0)
+ return 1;
+ error_reported = 1;
+/*
+ * If no files matched, report this as well.
+ */
+ } else if(result->nfile == 0 || !result->exists) {
+ if(gl->echo && fprintf(gl->output_fp, "\r\nNo files match.\n") < 0)
+ return 1;
+ error_reported = 1;
+/*
+ * Complain if more than one file matches.
+ */
+ } else if(result->nfile > 1) {
+ if(gl->echo &&
+ fprintf(gl->output_fp, "\r\nMore than one file matches.\n") < 0)
+ return 1;
+ error_reported = 1;
+/*
+ * Disallow input from anything but normal files. In principle we could
+ * also support input from named pipes. Terminal files would be a problem
+ * since we wouldn't know the terminal type, and other types of files
+ * might cause the library to lock up.
+ */
+ } else if(!_pu_path_is_file(result->files[0])) {
+ if(gl->echo && fprintf(gl->output_fp, "\r\nNot a normal file.\n") < 0)
+ return 1;
+ error_reported = 1;
+ } else {
+/*
+ * Attempt to open and install the specified file for reading.
+ */
+ gl->file_fp = fopen(result->files[0], "r");
+ if(!gl->file_fp) {
+ if(gl->echo && fprintf(gl->output_fp, "\r\nUnable to open: %s\n",
+ result->files[0]) < 0)
+ return 1;
+ error_reported = 1;
+ };
+/*
+ * Inform the user what is happening.
+ */
+ if(gl->echo && fprintf(gl->output_fp, "\r\n\n",
+ result->files[0]) < 0)
+ return 1;
+ };
+/*
+ * If an error was reported, redisplay the current line.
+ */
+ if(error_reported) {
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Close any temporary file that is being used for input.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ */
+static void gl_revert_input(GetLine *gl)
+{
+ if(gl->file_fp)
+ fclose(gl->file_fp);
+ gl->file_fp = NULL;
+}
+
+/*.......................................................................
+ * This is the action function that recalls the oldest line in the
+ * history buffer.
+ */
+static KT_KEY_FN(gl_beginning_of_history)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * Forget any previous recall session.
+ */
+ gl->preload_id = 0;
+/*
+ * Recall the next oldest line in the history list.
+ */
+ if(_glh_oldest_line(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange to have the cursor placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * If a history session is currently in progress, this action function
+ * recalls the line that was being edited when the session started. If
+ * no history session is in progress, it does nothing.
+ */
+static KT_KEY_FN(gl_end_of_history)
+{
+/*
+ * In vi mode, switch to command mode, since the user is very
+ * likely to want to move around newly recalled lines.
+ */
+ gl_vi_command_mode(gl);
+/*
+ * Forget any previous recall session.
+ */
+ gl->preload_id = 0;
+/*
+ * Recall the next oldest line in the history list.
+ */
+ if(_glh_current_line(gl->glh, gl->line, gl->linelen) == NULL)
+ return 0;
+/*
+ * Record the number of characters in the new string.
+ */
+ gl->ntotal = strlen(gl->line);
+/*
+ * Arrange to have the cursor placed at the end of the new line.
+ */
+ gl->buff_curpos = strlen(gl->line);
+/*
+ * Erase and display the new line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * This action function is treated specially, in that its count argument
+ * is set to the end keystroke of the keysequence that activated it.
+ * It accumulates a numeric argument, adding one digit on each call in
+ * which the last keystroke was a numeric digit.
+ */
+static KT_KEY_FN(gl_digit_argument)
+{
+/*
+ * Was the last keystroke a digit?
+ */
+ int is_digit = isdigit((int)(unsigned char) count);
+/*
+ * In vi command mode, a lone '0' means goto-start-of-line.
+ */
+ if(gl->vi.command && gl->number < 0 && count == '0')
+ return gl_beginning_of_line(gl, count);
+/*
+ * Are we starting to accumulate a new number?
+ */
+ if(gl->number < 0 || !is_digit)
+ gl->number = 0;
+/*
+ * Was the last keystroke a digit?
+ */
+ if(is_digit) {
+/*
+ * Read the numeric value of the digit, without assuming ASCII.
+ */
+ int n;
+ char s[2]; s[0] = count; s[1] = '\0';
+ n = atoi(s);
+/*
+ * Append the new digit.
+ */
+ gl->number = gl->number * 10 + n;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * The newline action function sets gl->endline to tell
+ * gl_get_input_line() that the line is now complete.
+ */
+static KT_KEY_FN(gl_newline)
+{
+ GlhLineID id; /* The last history line recalled while entering this line */
+/*
+ * Flag the line as ended.
+ */
+ gl->endline = 1;
+/*
+ * Record the next position in the history buffer, for potential
+ * recall by an action function on the next call to gl_get_line().
+ */
+ id = _glh_line_id(gl->glh, 1);
+ if(id)
+ gl->preload_id = id;
+ return 0;
+}
+
+/*.......................................................................
+ * The 'repeat' action function sets gl->endline to tell
+ * gl_get_input_line() that the line is now complete, and records the
+ * ID of the next history line in gl->preload_id so that the next call
+ * to gl_get_input_line() will preload the line with that history line.
+ */
+static KT_KEY_FN(gl_repeat_history)
+{
+ gl->endline = 1;
+ gl->preload_id = _glh_line_id(gl->glh, 1);
+ gl->preload_history = 1;
+ return 0;
+}
+
+/*.......................................................................
+ * Flush unwritten characters to the terminal.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_flush_output(GetLine *gl)
+{
+/*
+ * Attempt to flush output to the terminal, restarting the output
+ * if a signal is caught.
+ */
+ while(fflush(gl->output_fp) != 0) {
+ if(errno!=EINTR)
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Change the style of editing to emulate a given editor.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * editor GlEditor The type of editor to emulate.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_change_editor(GetLine *gl, GlEditor editor)
+{
+/*
+ * Install the default key-bindings of the requested editor.
+ */
+ switch(editor) {
+ case GL_EMACS_MODE:
+ _kt_clear_bindings(gl->bindings, KTB_NORM);
+ _kt_clear_bindings(gl->bindings, KTB_TERM);
+ (void) _kt_add_bindings(gl->bindings, KTB_NORM, gl_emacs_bindings,
+ sizeof(gl_emacs_bindings)/sizeof(gl_emacs_bindings[0]));
+ break;
+ case GL_VI_MODE:
+ _kt_clear_bindings(gl->bindings, KTB_NORM);
+ _kt_clear_bindings(gl->bindings, KTB_TERM);
+ (void) _kt_add_bindings(gl->bindings, KTB_NORM, gl_vi_bindings,
+ sizeof(gl_vi_bindings)/sizeof(gl_vi_bindings[0]));
+ break;
+ case GL_NO_EDITOR:
+ break;
+ default:
+ fprintf(stderr, "gl_change_editor: Unknown editor.\n");
+ return 1;
+ };
+/*
+ * Record the new editing mode.
+ */
+ gl->editor = editor;
+ gl->vi.command = 0; /* Start in input mode */
+ gl->insert_curpos = 0;
+/*
+ * Reinstate terminal-specific bindings.
+ */
+ if(gl->editor != GL_NO_EDITOR && gl->input_fp)
+ (void) gl_bind_terminal_keys(gl);
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function that switches to editing using emacs bindings
+ */
+static KT_KEY_FN(gl_emacs_editing_mode)
+{
+ return gl_change_editor(gl, GL_EMACS_MODE);
+}
+
+/*.......................................................................
+ * This is an action function that switches to editing using vi bindings
+ */
+static KT_KEY_FN(gl_vi_editing_mode)
+{
+ return gl_change_editor(gl, GL_VI_MODE);
+}
+
+/*.......................................................................
+ * This is the action function that switches to insert mode.
+ */
+static KT_KEY_FN(gl_vi_insert)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Switch to vi insert mode.
+ */
+ gl->insert = 1;
+ gl->vi.command = 0;
+ gl->insert_curpos = gl->buff_curpos;
+ return 0;
+}
+
+/*.......................................................................
+ * This is an action function that switches to overwrite mode.
+ */
+static KT_KEY_FN(gl_vi_overwrite)
+{
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Switch to vi overwrite mode.
+ */
+ gl->insert = 0;
+ gl->vi.command = 0;
+ gl->insert_curpos = gl->buff_curpos;
+ return 0;
+}
+
+/*.......................................................................
+ * This action function toggles the case of the character under the
+ * cursor.
+ */
+static KT_KEY_FN(gl_change_case)
+{
+ int i;
+/*
+ * Keep a record of the current insert mode and the cursor position.
+ */
+ int insert = gl->insert;
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * We want to overwrite the modified word.
+ */
+ gl->insert = 0;
+/*
+ * Toggle the case of 'count' characters.
+ */
+ for(i=0; ibuff_curpos < gl->ntotal; i++) {
+ char *cptr = gl->line + gl->buff_curpos++;
+/*
+ * Convert the character to upper case?
+ */
+ if(islower((int)(unsigned char) *cptr))
+ *cptr = toupper((int) *cptr);
+ else if(isupper((int)(unsigned char) *cptr))
+ *cptr = tolower((int) *cptr);
+/*
+ * Write the possibly modified character back. Note that for non-modified
+ * characters we want to do this as well, so as to advance the cursor.
+ */
+ if(gl_output_char(gl, *cptr, cptr[1]))
+ return 1;
+ };
+/*
+ * Restore the insertion mode.
+ */
+ gl->insert = insert;
+ return gl_place_cursor(gl, gl->buff_curpos); /* bounds check */
+}
+
+/*.......................................................................
+ * This is the action function which implements the vi-style action which
+ * moves the cursor to the start of the line, then switches to insert mode.
+ */
+static KT_KEY_FN(gl_vi_insert_at_bol)
+{
+ gl_save_for_undo(gl);
+ return gl_beginning_of_line(gl, 0) ||
+ gl_vi_insert(gl, 0);
+
+}
+
+/*.......................................................................
+ * This is the action function which implements the vi-style action which
+ * moves the cursor to the end of the line, then switches to insert mode
+ * to allow text to be appended to the line.
+ */
+static KT_KEY_FN(gl_vi_append_at_eol)
+{
+ gl_save_for_undo(gl);
+ gl->vi.command = 0; /* Allow cursor at EOL */
+ return gl_end_of_line(gl, 0) ||
+ gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * This is the action function which implements the vi-style action which
+ * moves the cursor to right one then switches to insert mode, thus
+ * allowing text to be appended after the next character.
+ */
+static KT_KEY_FN(gl_vi_append)
+{
+ gl_save_for_undo(gl);
+ gl->vi.command = 0; /* Allow cursor at EOL */
+ return gl_cursor_right(gl, 1) ||
+ gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * This action function moves the cursor to the column specified by the
+ * numeric argument. Column indexes start at 1.
+ */
+static KT_KEY_FN(gl_goto_column)
+{
+ return gl_place_cursor(gl, count - 1);
+}
+
+/*.......................................................................
+ * Starting with the character under the cursor, replace 'count'
+ * characters with the next character that the user types.
+ */
+static KT_KEY_FN(gl_vi_replace_char)
+{
+ char c; /* The replacement character */
+ int i;
+/*
+ * Keep a record of the current insert mode.
+ */
+ int insert = gl->insert;
+/*
+ * Get the replacement character.
+ */
+ if(gl->vi.repeat.active) {
+ c = gl->vi.repeat.input_char;
+ } else {
+ if(gl_read_character(gl, &c))
+ return 1;
+ gl->vi.repeat.input_char = c;
+ };
+/*
+ * Are there 'count' characters to be replaced?
+ */
+ if(gl->ntotal - gl->buff_curpos >= count) {
+/*
+ * If in vi command mode, preserve the current line for potential
+ * use by vi-undo.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Temporarily switch to overwrite mode.
+ */
+ gl->insert = 0;
+/*
+ * Overwrite the current character plus count-1 subsequent characters
+ * with the replacement character.
+ */
+ for(i=0; iinsert = insert;
+ };
+ return gl_place_cursor(gl, gl->buff_curpos); /* bounds check */
+}
+
+/*.......................................................................
+ * This is an action function which changes all characters between the
+ * current cursor position and the end of the line.
+ */
+static KT_KEY_FN(gl_vi_change_rest_of_line)
+{
+ gl_save_for_undo(gl);
+ gl->vi.command = 0; /* Allow cursor at EOL */
+ return gl_kill_line(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * This is an action function which changes all characters between the
+ * start of the line and the current cursor position.
+ */
+static KT_KEY_FN(gl_vi_change_to_bol)
+{
+ return gl_backward_kill_line(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * This is an action function which deletes the entire contents of the
+ * current line and switches to insert mode.
+ */
+static KT_KEY_FN(gl_vi_change_line)
+{
+ return gl_delete_line(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * Starting from the cursor position and looking towards the end of the
+ * line, copy 'count' characters to the cut buffer.
+ */
+static KT_KEY_FN(gl_forward_copy_char)
+{
+/*
+ * Limit the count to the number of characters available.
+ */
+ if(gl->buff_curpos + count >= gl->ntotal)
+ count = gl->ntotal - gl->buff_curpos;
+ if(count < 0)
+ count = 0;
+/*
+ * Copy the characters to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, count);
+ gl->cutbuf[count] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Starting from the character before the cursor position and looking
+ * backwards towards the start of the line, copy 'count' characters to
+ * the cut buffer.
+ */
+static KT_KEY_FN(gl_backward_copy_char)
+{
+/*
+ * Limit the count to the number of characters available.
+ */
+ if(count > gl->buff_curpos)
+ count = gl->buff_curpos;
+ if(count < 0)
+ count = 0;
+ gl_place_cursor(gl, gl->buff_curpos - count);
+/*
+ * Copy the characters to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, count);
+ gl->cutbuf[count] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Starting from the cursor position copy to the specified column into the
+ * cut buffer.
+ */
+static KT_KEY_FN(gl_copy_to_column)
+{
+ if (--count >= gl->buff_curpos)
+ return gl_forward_copy_char(gl, count - gl->buff_curpos);
+ else
+ return gl_backward_copy_char(gl, gl->buff_curpos - count);
+}
+
+/*.......................................................................
+ * Starting from the cursor position copy characters up to a matching
+ * parenthesis into the cut buffer.
+ */
+static KT_KEY_FN(gl_copy_to_parenthesis)
+{
+ int curpos = gl_index_of_matching_paren(gl);
+ if(curpos >= 0) {
+ gl_save_for_undo(gl);
+ if(curpos >= gl->buff_curpos)
+ return gl_forward_copy_char(gl, curpos - gl->buff_curpos + 1);
+ else
+ return gl_backward_copy_char(gl, ++gl->buff_curpos - curpos + 1);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Starting from the cursor position copy the rest of the line into the
+ * cut buffer.
+ */
+static KT_KEY_FN(gl_copy_rest_of_line)
+{
+/*
+ * Copy the characters to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, gl->ntotal - gl->buff_curpos);
+ gl->cutbuf[gl->ntotal - gl->buff_curpos] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Copy from the beginning of the line to the cursor position into the
+ * cut buffer.
+ */
+static KT_KEY_FN(gl_copy_to_bol)
+{
+/*
+ * Copy the characters to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line, gl->buff_curpos);
+ gl->cutbuf[gl->buff_curpos] = '\0';
+ gl_place_cursor(gl, 0);
+ return 0;
+}
+
+/*.......................................................................
+ * Copy the entire line into the cut buffer.
+ */
+static KT_KEY_FN(gl_copy_line)
+{
+/*
+ * Copy the characters to the cut buffer.
+ */
+ memcpy(gl->cutbuf, gl->line, gl->ntotal);
+ gl->cutbuf[gl->ntotal] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Search forwards for the next character that the user enters.
+ */
+static KT_KEY_FN(gl_forward_find_char)
+{
+ int pos = gl_find_char(gl, count, 1, 1, '\0');
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Search backwards for the next character that the user enters.
+ */
+static KT_KEY_FN(gl_backward_find_char)
+{
+ int pos = gl_find_char(gl, count, 0, 1, '\0');
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Search forwards for the next character that the user enters. Move up to,
+ * but not onto, the found character.
+ */
+static KT_KEY_FN(gl_forward_to_char)
+{
+ int pos = gl_find_char(gl, count, 1, 0, '\0');
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Search backwards for the next character that the user enters. Move back to,
+ * but not onto, the found character.
+ */
+static KT_KEY_FN(gl_backward_to_char)
+{
+ int pos = gl_find_char(gl, count, 0, 0, '\0');
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Searching in a given direction, return the index of a given (or
+ * read) character in the input line, or the character that precedes
+ * it in the specified search direction. Return -1 if not found.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * count int The number of times to search.
+ * forward int True if searching forward.
+ * onto int True if the search should end on top of the
+ * character, false if the search should stop
+ * one character before the character in the
+ * specified search direction.
+ * c char The character to be sought, or '\0' if the
+ * character should be read from the user.
+ * Output:
+ * return int The index of the character in gl->line[], or
+ * -1 if not found.
+ */
+static int gl_find_char(GetLine *gl, int count, int forward, int onto, char c)
+{
+ int pos; /* The index reached in searching the input line */
+ int i;
+/*
+ * Get a character from the user?
+ */
+ if(!c) {
+/*
+ * If we are in the process of repeating a previous change command, substitute
+ * the last find character.
+ */
+ if(gl->vi.repeat.active) {
+ c = gl->vi.find_char;
+ } else {
+ if(gl_read_character(gl, &c))
+ return -1;
+/*
+ * Record the details of the new search, for use by repeat finds.
+ */
+ gl->vi.find_forward = forward;
+ gl->vi.find_onto = onto;
+ gl->vi.find_char = c;
+ };
+ };
+/*
+ * Which direction should we search?
+ */
+ if(forward) {
+/*
+ * Search forwards 'count' times for the character, starting with the
+ * character that follows the cursor.
+ */
+ for(i=0, pos=gl->buff_curpos; intotal; i++) {
+/*
+ * Advance past the last match (or past the current cursor position
+ * on the first search).
+ */
+ pos++;
+/*
+ * Search for the next instance of c.
+ */
+ for( ; posntotal && c!=gl->line[pos]; pos++)
+ ;
+ };
+/*
+ * If the character was found and we have been requested to return the
+ * position of the character that precedes the desired character, then
+ * we have gone one character too far.
+ */
+ if(!onto && posntotal)
+ pos--;
+ } else {
+/*
+ * Search backwards 'count' times for the character, starting with the
+ * character that precedes the cursor.
+ */
+ for(i=0, pos=gl->buff_curpos; i= gl->insert_curpos; i++) {
+/*
+ * Step back one from the last match (or from the current cursor
+ * position on the first search).
+ */
+ pos--;
+/*
+ * Search for the next instance of c.
+ */
+ for( ; pos>=gl->insert_curpos && c!=gl->line[pos]; pos--)
+ ;
+ };
+/*
+ * If the character was found and we have been requested to return the
+ * position of the character that precedes the desired character, then
+ * we have gone one character too far.
+ */
+ if(!onto && pos>=gl->insert_curpos)
+ pos++;
+ };
+/*
+ * If found, return the cursor position of the count'th match.
+ * Otherwise ring the terminal bell.
+ */
+ if(pos >= gl->insert_curpos && pos < gl->ntotal) {
+ return pos;
+ } else {
+ (void) gl_ring_bell(gl, 1);
+ return -1;
+ }
+}
+
+/*.......................................................................
+ * Repeat the last character search in the same direction as the last
+ * search.
+ */
+static KT_KEY_FN(gl_repeat_find_char)
+{
+ int pos = gl->vi.find_char ?
+ gl_find_char(gl, count, gl->vi.find_forward, gl->vi.find_onto,
+ gl->vi.find_char) : -1;
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Repeat the last character search in the opposite direction as the last
+ * search.
+ */
+static KT_KEY_FN(gl_invert_refind_char)
+{
+ int pos = gl->vi.find_char ?
+ gl_find_char(gl, count, !gl->vi.find_forward, gl->vi.find_onto,
+ gl->vi.find_char) : -1;
+ return pos >= 0 && gl_place_cursor(gl, pos);
+}
+
+/*.......................................................................
+ * Search forward from the current position of the cursor for 'count'
+ * word endings, returning the index of the last one found, or the end of
+ * the line if there were less than 'count' words.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * n int The number of word boundaries to search for.
+ * Output:
+ * return int The buffer index of the located position.
+ */
+static int gl_nth_word_end_forward(GetLine *gl, int n)
+{
+ int bufpos; /* The buffer index being checked. */
+ int i;
+/*
+ * In order to guarantee forward motion to the next word ending,
+ * we need to start from one position to the right of the cursor
+ * position, since this may already be at the end of a word.
+ */
+ bufpos = gl->buff_curpos + 1;
+/*
+ * If we are at the end of the line, return the index of the last
+ * real character on the line. Note that this will be -1 if the line
+ * is empty.
+ */
+ if(bufpos >= gl->ntotal)
+ return gl->ntotal - 1;
+/*
+ * Search 'n' times, unless the end of the input line is reached first.
+ */
+ for(i=0; intotal; i++) {
+/*
+ * If we are not already within a word, skip to the start of the next word.
+ */
+ for( ; bufposntotal && !gl_is_word_char((int)gl->line[bufpos]);
+ bufpos++)
+ ;
+/*
+ * Find the end of the next word.
+ */
+ for( ; bufposntotal && gl_is_word_char((int)gl->line[bufpos]);
+ bufpos++)
+ ;
+ };
+/*
+ * We will have overshot.
+ */
+ return bufpos > 0 ? bufpos-1 : bufpos;
+}
+
+/*.......................................................................
+ * Search forward from the current position of the cursor for 'count'
+ * word starts, returning the index of the last one found, or the end of
+ * the line if there were less than 'count' words.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * n int The number of word boundaries to search for.
+ * Output:
+ * return int The buffer index of the located position.
+ */
+static int gl_nth_word_start_forward(GetLine *gl, int n)
+{
+ int bufpos; /* The buffer index being checked. */
+ int i;
+/*
+ * Get the current cursor position.
+ */
+ bufpos = gl->buff_curpos;
+/*
+ * Search 'n' times, unless the end of the input line is reached first.
+ */
+ for(i=0; intotal; i++) {
+/*
+ * Find the end of the current word.
+ */
+ for( ; bufposntotal && gl_is_word_char((int)gl->line[bufpos]);
+ bufpos++)
+ ;
+/*
+ * Skip to the start of the next word.
+ */
+ for( ; bufposntotal && !gl_is_word_char((int)gl->line[bufpos]);
+ bufpos++)
+ ;
+ };
+ return bufpos;
+}
+
+/*.......................................................................
+ * Search backward from the current position of the cursor for 'count'
+ * word starts, returning the index of the last one found, or the start
+ * of the line if there were less than 'count' words.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * n int The number of word boundaries to search for.
+ * Output:
+ * return int The buffer index of the located position.
+ */
+static int gl_nth_word_start_backward(GetLine *gl, int n)
+{
+ int bufpos; /* The buffer index being checked. */
+ int i;
+/*
+ * Get the current cursor position.
+ */
+ bufpos = gl->buff_curpos;
+/*
+ * Search 'n' times, unless the beginning of the input line (or vi insertion
+ * point) is reached first.
+ */
+ for(i=0; i gl->insert_curpos; i++) {
+/*
+ * Starting one character back from the last search, so as not to keep
+ * settling on the same word-start, search backwards until finding a
+ * word character.
+ */
+ while(--bufpos >= gl->insert_curpos &&
+ !gl_is_word_char((int)gl->line[bufpos]))
+ ;
+/*
+ * Find the start of the word.
+ */
+ while(--bufpos >= gl->insert_curpos &&
+ gl_is_word_char((int)gl->line[bufpos]))
+ ;
+/*
+ * We will have gone one character too far.
+ */
+ bufpos++;
+ };
+ return bufpos >= gl->insert_curpos ? bufpos : gl->insert_curpos;
+}
+
+/*.......................................................................
+ * Copy one or more words into the cut buffer without moving the cursor
+ * or deleting text.
+ */
+static KT_KEY_FN(gl_forward_copy_word)
+{
+/*
+ * Find the location of the count'th start or end of a word
+ * after the cursor, depending on whether in emacs or vi mode.
+ */
+ int next = gl->editor == GL_EMACS_MODE ?
+ gl_nth_word_end_forward(gl, count) :
+ gl_nth_word_start_forward(gl, count);
+/*
+ * How many characters are to be copied into the cut buffer?
+ */
+ int n = next - gl->buff_curpos;
+/*
+ * Copy the specified segment and terminate the string.
+ */
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, n);
+ gl->cutbuf[n] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Copy one or more words preceding the cursor into the cut buffer,
+ * without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_backward_copy_word)
+{
+/*
+ * Find the location of the count'th start of word before the cursor.
+ */
+ int next = gl_nth_word_start_backward(gl, count);
+/*
+ * How many characters are to be copied into the cut buffer?
+ */
+ int n = gl->buff_curpos - next;
+ gl_place_cursor(gl, next);
+/*
+ * Copy the specified segment and terminate the string.
+ */
+ memcpy(gl->cutbuf, gl->line + next, n);
+ gl->cutbuf[n] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Copy the characters between the cursor and the count'th instance of
+ * a specified character in the input line, into the cut buffer.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * count int The number of times to search.
+ * c char The character to be searched for, or '\0' if
+ * the character should be read from the user.
+ * forward int True if searching forward.
+ * onto int True if the search should end on top of the
+ * character, false if the search should stop
+ * one character before the character in the
+ * specified search direction.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ *
+ */
+static int gl_copy_find(GetLine *gl, int count, char c, int forward, int onto)
+{
+ int n; /* The number of characters in the cut buffer */
+/*
+ * Search for the character, and abort the operation if not found.
+ */
+ int pos = gl_find_char(gl, count, forward, onto, c);
+ if(pos < 0)
+ return 0;
+/*
+ * Copy the specified segment.
+ */
+ if(forward) {
+ n = pos + 1 - gl->buff_curpos;
+ memcpy(gl->cutbuf, gl->line + gl->buff_curpos, n);
+ } else {
+ n = gl->buff_curpos - pos;
+ memcpy(gl->cutbuf, gl->line + pos, n);
+ if(gl->editor == GL_VI_MODE)
+ gl_place_cursor(gl, pos);
+ }
+/*
+ * Terminate the copy.
+ */
+ gl->cutbuf[n] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Copy a section up to and including a specified character into the cut
+ * buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_forward_copy_find)
+{
+ return gl_copy_find(gl, count, '\0', 1, 1);
+}
+
+/*.......................................................................
+ * Copy a section back to and including a specified character into the cut
+ * buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_backward_copy_find)
+{
+ return gl_copy_find(gl, count, '\0', 0, 1);
+}
+
+/*.......................................................................
+ * Copy a section up to and not including a specified character into the cut
+ * buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_forward_copy_to)
+{
+ return gl_copy_find(gl, count, '\0', 1, 0);
+}
+
+/*.......................................................................
+ * Copy a section back to and not including a specified character into the cut
+ * buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_backward_copy_to)
+{
+ return gl_copy_find(gl, count, '\0', 0, 0);
+}
+
+/*.......................................................................
+ * Copy to a character specified in a previous search into the cut
+ * buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_copy_refind)
+{
+ return gl_copy_find(gl, count, gl->vi.find_char, gl->vi.find_forward,
+ gl->vi.find_onto);
+}
+
+/*.......................................................................
+ * Copy to a character specified in a previous search, but in the opposite
+ * direction, into the cut buffer without moving the cursor or deleting text.
+ */
+static KT_KEY_FN(gl_copy_invert_refind)
+{
+ return gl_copy_find(gl, count, gl->vi.find_char, !gl->vi.find_forward,
+ gl->vi.find_onto);
+}
+
+/*.......................................................................
+ * Set the position of the cursor in the line input buffer and the
+ * terminal.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * buff_curpos int The new buffer cursor position.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_place_cursor(GetLine *gl, int buff_curpos)
+{
+/*
+ * Don't allow the cursor position to go out of the bounds of the input
+ * line.
+ */
+ if(buff_curpos >= gl->ntotal)
+ buff_curpos = gl->vi.command ? gl->ntotal-1 : gl->ntotal;
+ if(buff_curpos < 0)
+ buff_curpos = 0;
+/*
+ * Record the new buffer position.
+ */
+ gl->buff_curpos = buff_curpos;
+/*
+ * Move the terminal cursor to the corresponding character.
+ */
+ return gl_set_term_curpos(gl, gl_buff_curpos_to_term_curpos(gl, buff_curpos));
+}
+
+/*.......................................................................
+ * In vi command mode, this function saves the current line to the
+ * historical buffer needed by the undo command. In emacs mode it does
+ * nothing. In order to allow action functions to call other action
+ * functions, gl_interpret_char() sets gl->vi.undo.saved to 0 before
+ * invoking an action, and thereafter once any call to this function
+ * has set it to 1, further calls are ignored.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ */
+static void gl_save_for_undo(GetLine *gl)
+{
+ if(gl->vi.command && !gl->vi.undo.saved) {
+ strcpy(gl->vi.undo.line, gl->line);
+ gl->vi.undo.buff_curpos = gl->buff_curpos;
+ gl->vi.undo.ntotal = gl->ntotal;
+ gl->vi.undo.saved = 1;
+ };
+ if(gl->vi.command && !gl->vi.repeat.saved &&
+ gl->current_fn != gl_vi_repeat_change) {
+ gl->vi.repeat.fn = gl->current_fn;
+ gl->vi.repeat.count = gl->current_count;
+ gl->vi.repeat.saved = 1;
+ };
+ return;
+}
+
+/*.......................................................................
+ * In vi mode, restore the line to the way it was before the last command
+ * mode operation, storing the current line in the buffer so that the
+ * undo operation itself can subsequently be undone.
+ */
+static KT_KEY_FN(gl_vi_undo)
+{
+/*
+ * Get pointers into the two lines.
+ */
+ char *undo_ptr = gl->vi.undo.line;
+ char *line_ptr = gl->line;
+/*
+ * Swap the characters of the two buffers up to the length of the shortest
+ * line.
+ */
+ while(*undo_ptr && *line_ptr) {
+ char c = *undo_ptr;
+ *undo_ptr++ = *line_ptr;
+ *line_ptr++ = c;
+ };
+/*
+ * Copy the rest directly.
+ */
+ if(gl->ntotal > gl->vi.undo.ntotal) {
+ strcpy(undo_ptr, line_ptr);
+ *line_ptr = '\0';
+ } else {
+ strcpy(line_ptr, undo_ptr);
+ *undo_ptr = '\0';
+ };
+/*
+ * Swap the length information.
+ */
+ {
+ int ntotal = gl->ntotal;
+ gl->ntotal = gl->vi.undo.ntotal;
+ gl->vi.undo.ntotal = ntotal;
+ };
+/*
+ * Set both cursor positions to the leftmost of the saved and current
+ * cursor positions to emulate what vi does.
+ */
+ if(gl->buff_curpos < gl->vi.undo.buff_curpos)
+ gl->vi.undo.buff_curpos = gl->buff_curpos;
+ else
+ gl->buff_curpos = gl->vi.undo.buff_curpos;
+/*
+ * Since we have bipassed calling gl_save_for_undo(), record repeat
+ * information inline.
+ */
+ gl->vi.repeat.fn = gl_vi_undo;
+ gl->vi.repeat.count = 1;
+/*
+ * Display the restored line.
+ */
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * Delete the following word and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_forward_change_word)
+{
+ gl_save_for_undo(gl);
+ gl->vi.command = 0; /* Allow cursor at EOL */
+ return gl_forward_delete_word(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * Delete the preceding word and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_backward_change_word)
+{
+ return gl_backward_delete_word(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * Delete the following section and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_forward_change_find)
+{
+ return gl_delete_find(gl, count, '\0', 1, 1, 1);
+}
+
+/*.......................................................................
+ * Delete the preceding section and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_backward_change_find)
+{
+ return gl_delete_find(gl, count, '\0', 0, 1, 1);
+}
+
+/*.......................................................................
+ * Delete the following section and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_forward_change_to)
+{
+ return gl_delete_find(gl, count, '\0', 1, 0, 1);
+}
+
+/*.......................................................................
+ * Delete the preceding section and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_backward_change_to)
+{
+ return gl_delete_find(gl, count, '\0', 0, 0, 1);
+}
+
+/*.......................................................................
+ * Delete to a character specified by a previous search and leave the user
+ * in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_change_refind)
+{
+ return gl_delete_find(gl, count, gl->vi.find_char, gl->vi.find_forward,
+ gl->vi.find_onto, 1);
+}
+
+/*.......................................................................
+ * Delete to a character specified by a previous search, but in the opposite
+ * direction, and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_change_invert_refind)
+{
+ return gl_delete_find(gl, count, gl->vi.find_char, !gl->vi.find_forward,
+ gl->vi.find_onto, 1);
+}
+
+/*.......................................................................
+ * Delete the following character and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_forward_change_char)
+{
+ gl_save_for_undo(gl);
+ gl->vi.command = 0; /* Allow cursor at EOL */
+ return gl_delete_chars(gl, count, 1) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * Delete the preceding character and leave the user in vi insert mode.
+ */
+static KT_KEY_FN(gl_vi_backward_change_char)
+{
+ return gl_backward_delete_char(gl, count) || gl_vi_insert(gl, 0);
+}
+
+/*.......................................................................
+ * Starting from the cursor position change characters to the specified column.
+ */
+static KT_KEY_FN(gl_vi_change_to_column)
+{
+ if (--count >= gl->buff_curpos)
+ return gl_vi_forward_change_char(gl, count - gl->buff_curpos);
+ else
+ return gl_vi_backward_change_char(gl, gl->buff_curpos - count);
+}
+
+/*.......................................................................
+ * Starting from the cursor position change characters to a matching
+ * parenthesis.
+ */
+static KT_KEY_FN(gl_vi_change_to_parenthesis)
+{
+ int curpos = gl_index_of_matching_paren(gl);
+ if(curpos >= 0) {
+ gl_save_for_undo(gl);
+ if(curpos >= gl->buff_curpos)
+ return gl_vi_forward_change_char(gl, curpos - gl->buff_curpos + 1);
+ else
+ return gl_vi_backward_change_char(gl, ++gl->buff_curpos - curpos + 1);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * If in vi mode, switch to vi command mode.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ */
+static void gl_vi_command_mode(GetLine *gl)
+{
+ if(gl->editor == GL_VI_MODE && !gl->vi.command) {
+ gl->insert = 1;
+ gl->vi.command = 1;
+ gl->vi.repeat.input_curpos = gl->insert_curpos;
+ gl->vi.repeat.command_curpos = gl->buff_curpos;
+ gl->insert_curpos = 0; /* unrestrict left motion boundary */
+ gl_cursor_left(gl, 1); /* Vi moves left one on entering command mode */
+ };
+}
+
+/*.......................................................................
+ * This is an action function which rings the terminal bell.
+ */
+static KT_KEY_FN(gl_ring_bell)
+{
+ return gl->silence_bell ? 0 :
+ gl_output_control_sequence(gl, 1, gl->sound_bell);
+}
+
+/*.......................................................................
+ * This is the action function which implements the vi-repeat-change
+ * action.
+ */
+static KT_KEY_FN(gl_vi_repeat_change)
+{
+ int status; /* The return status of the repeated action function */
+ int i;
+/*
+ * Nothing to repeat?
+ */
+ if(!gl->vi.repeat.fn)
+ return gl_ring_bell(gl, 1);
+/*
+ * Provide a way for action functions to know whether they are being
+ * called by us.
+ */
+ gl->vi.repeat.active = 1;
+/*
+ * Re-run the recorded function.
+ */
+ status = gl->vi.repeat.fn(gl, gl->vi.repeat.count);
+/*
+ * Mark the repeat as completed.
+ */
+ gl->vi.repeat.active = 0;
+/*
+ * Is we are repeating a function that has just switched to input
+ * mode to allow the user to type, re-enter the text that the user
+ * previously entered.
+ */
+ if(status==0 && !gl->vi.command) {
+/*
+ * Make sure that the current line has been saved.
+ */
+ gl_save_for_undo(gl);
+/*
+ * Repeat a previous insertion or overwrite?
+ */
+ if(gl->vi.repeat.input_curpos >= 0 &&
+ gl->vi.repeat.input_curpos <= gl->vi.repeat.command_curpos &&
+ gl->vi.repeat.command_curpos <= gl->vi.undo.ntotal) {
+/*
+ * Using the current line which is saved in the undo buffer, plus
+ * the range of characters therein, as recorded by gl_vi_command_mode(),
+ * add the characters that the user previously entered, to the input
+ * line.
+ */
+ for(i=gl->vi.repeat.input_curpos; ivi.repeat.command_curpos; i++) {
+ if(gl_add_char_to_line(gl, gl->vi.undo.line[i]))
+ return 1;
+ };
+ };
+/*
+ * Switch back to command mode, now that the insertion has been repeated.
+ */
+ gl_vi_command_mode(gl);
+ };
+ return status;
+}
+
+/*.......................................................................
+ * If the cursor is currently over a parenthesis character, return the
+ * index of its matching parenthesis. If not currently over a parenthesis
+ * character, return the next close parenthesis character to the right of
+ * the cursor. If the respective parenthesis character isn't found,
+ * ring the terminal bell and return -1.
+ *
+ * Input:
+ * gl GetLine * The getline resource object.
+ * Output:
+ * return int Either the index of the matching parenthesis,
+ * or -1 if not found.
+ */
+static int gl_index_of_matching_paren(GetLine *gl)
+{
+ int i;
+/*
+ * List the recognized parentheses, and their matches.
+ */
+ const char *o_paren = "([{";
+ const char *c_paren = ")]}";
+ const char *cptr;
+/*
+ * Get the character that is currently under the cursor.
+ */
+ char c = gl->line[gl->buff_curpos];
+/*
+ * If the character under the cursor is an open parenthesis, look forward
+ * for the matching close parenthesis.
+ */
+ if((cptr=strchr(o_paren, c))) {
+ char match = c_paren[cptr - o_paren];
+ int matches_needed = 1;
+ for(i=gl->buff_curpos+1; intotal; i++) {
+ if(gl->line[i] == c)
+ matches_needed++;
+ else if(gl->line[i] == match && --matches_needed==0)
+ return i;
+ };
+/*
+ * If the character under the cursor is an close parenthesis, look forward
+ * for the matching open parenthesis.
+ */
+ } else if((cptr=strchr(c_paren, c))) {
+ char match = o_paren[cptr - c_paren];
+ int matches_needed = 1;
+ for(i=gl->buff_curpos-1; i>=0; i--) {
+ if(gl->line[i] == c)
+ matches_needed++;
+ else if(gl->line[i] == match && --matches_needed==0)
+ return i;
+ };
+/*
+ * If not currently over a parenthesis character, search forwards for
+ * the first close parenthesis (this is what the vi % binding does).
+ */
+ } else {
+ for(i=gl->buff_curpos+1; intotal; i++)
+ if(strchr(c_paren, gl->line[i]) != NULL)
+ return i;
+ };
+/*
+ * Not found.
+ */
+ (void) gl_ring_bell(gl, 1);
+ return -1;
+}
+
+/*.......................................................................
+ * If the cursor is currently over a parenthesis character, this action
+ * function moves the cursor to its matching parenthesis.
+ */
+static KT_KEY_FN(gl_find_parenthesis)
+{
+ int curpos = gl_index_of_matching_paren(gl);
+ if(curpos >= 0)
+ return gl_place_cursor(gl, curpos);
+ return 0;
+}
+
+/*.......................................................................
+ * Handle the receipt of the potential start of a new key-sequence from
+ * the user.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * first_char char The first character of the sequence.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_interpret_char(GetLine *gl, char first_char)
+{
+ KtKeyFn *keyfn; /* An action function */
+ char keyseq[GL_KEY_MAX+1]; /* A special key sequence being read */
+ int nkey=0; /* The number of characters in the key sequence */
+ int count; /* The repeat count of an action function */
+ int ret; /* The return value of an action function */
+ int i;
+/*
+ * Get the first character.
+ */
+ char c = first_char;
+/*
+ * If editting is disabled, just add newly entered characters to the
+ * input line buffer, and watch for the end of the line.
+ */
+ if(gl->editor == GL_NO_EDITOR) {
+ if(gl->ntotal >= gl->linelen)
+ return 0;
+ if(c == '\n' || c == '\r')
+ return gl_newline(gl, 1);
+ gl->line[gl->ntotal++] = c;
+ return 0;
+ };
+/*
+ * If the user is in the process of specifying a repeat count and the
+ * new character is a digit, increment the repeat count accordingly.
+ */
+ if(gl->number >= 0 && isdigit((int)(unsigned char) c))
+ return gl_digit_argument(gl, c);
+/*
+ * In vi command mode, all key-sequences entered need to be
+ * either implicitly or explicitly prefixed with an escape character.
+ */
+ else if(gl->vi.command && c != GL_ESC_CHAR)
+ keyseq[nkey++] = GL_ESC_CHAR;
+/*
+ * If the first character of the sequence is a printable character,
+ * then to avoid confusion with the special "up", "down", "left"
+ * or "right" cursor key bindings, we need to prefix the
+ * printable character with a backslash escape before looking it up.
+ */
+ else if(!IS_META_CHAR(c) && !IS_CTRL_CHAR(c))
+ keyseq[nkey++] = '\\';
+/*
+ * Compose a potentially multiple key-sequence in gl->keyseq.
+ */
+ while(nkey < GL_KEY_MAX) {
+ int first, last; /* The matching entries in gl->keys */
+/*
+ * If the character is an unprintable meta character, split it
+ * into two characters, an escape character and the character
+ * that was modified by the meta key.
+ */
+ if(IS_META_CHAR(c)) {
+ keyseq[nkey++] = GL_ESC_CHAR;
+ c = META_TO_CHAR(c);
+ continue;
+ };
+/*
+ * Append the latest character to the key sequence.
+ */
+ keyseq[nkey++] = c;
+/*
+ * When doing vi-style editing, an escape at the beginning of any binding
+ * switches to command mode.
+ */
+ if(keyseq[0] == GL_ESC_CHAR && !gl->vi.command)
+ gl_vi_command_mode(gl);
+/*
+ * Lookup the key sequence.
+ */
+ switch(_kt_lookup_keybinding(gl->bindings, keyseq, nkey, &first, &last)) {
+ case KT_EXACT_MATCH:
+/*
+ * Get the matching action function.
+ */
+ keyfn = gl->bindings->table[first].keyfn;
+/*
+ * Get the repeat count, passing the last keystroke if executing the
+ * digit-argument action.
+ */
+ if(keyfn == gl_digit_argument) {
+ count = c;
+ } else {
+ count = gl->number >= 0 ? gl->number : 1;
+ };
+/*
+ * Record the function that is being invoked.
+ */
+ gl->current_fn = keyfn;
+ gl->current_count = count;
+/*
+ * Mark the current line as not yet preserved for use by the vi undo command.
+ */
+ gl->vi.undo.saved = 0;
+ gl->vi.repeat.saved = 0;
+/*
+ * Execute the action function. Note the action function can tell
+ * whether the provided repeat count was defaulted or specified
+ * explicitly by looking at whether gl->number is -1 or not. If
+ * it is negative, then no repeat count was specified by the user.
+ */
+ ret = keyfn(gl, count);
+/*
+ * Reset the repeat count after running action functions (other
+ * than digit-argument).
+ */
+ if(keyfn != gl_digit_argument)
+ gl->number = -1;
+ if(ret)
+ return 1;
+ return 0;
+ break;
+ case KT_AMBIG_MATCH: /* Ambiguous match - so look ahead */
+ if(gl_read_character(gl, &c)) /* Get the next character */
+ return 1;
+ break;
+ case KT_NO_MATCH:
+/*
+ * If the first character looked like it might be a prefix of a key-sequence
+ * but it turned out not to be, ring the bell to tell the user that it
+ * wasn't recognised.
+ */
+ if(keyseq[0] != '\\' && keyseq[0] != '\t') {
+ gl_ring_bell(gl, 0);
+ } else {
+/*
+ * The user typed a single printable character that doesn't match
+ * the start of any keysequence, so add it to the line in accordance
+ * with the current repeat count.
+ */
+ count = gl->number >= 0 ? gl->number : 1;
+ for(i=0; inumber = -1;
+ };
+ return 0;
+ break;
+ case KT_BAD_MATCH:
+ return 1;
+ break;
+ };
+ };
+/*
+ * Key sequence too long to match.
+ */
+ return 0;
+}
+
+/*.......................................................................
+ * Configure the application and/or user-specific behavior of
+ * gl_get_line().
+ *
+ * Note that calling this function between calling new_GetLine() and
+ * the first call to new_GetLine(), disables the otherwise automatic
+ * reading of ~/.teclarc on the first call to gl_get_line().
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * app_string const char * Either NULL, or a string containing one
+ * or more .teclarc command lines, separated
+ * by newline characters. This can be used to
+ * establish an application-specific
+ * configuration, without the need for an external
+ * file. This is particularly useful in embedded
+ * environments where there is no filesystem.
+ * app_file const char * Either NULL, or the pathname of an
+ * application-specific .teclarc file. The
+ * contents of this file, if provided, are
+ * read after the contents of app_string[].
+ * user_file const char * Either NULL, or the pathname of a
+ * user-specific .teclarc file. Except in
+ * embedded applications, this should
+ * usually be "~/.teclarc".
+ * Output:
+ * return int 0 - OK.
+ * 1 - Bad argument(s).
+ */
+int gl_configure_getline(GetLine *gl, const char *app_string,
+ const char *app_file, const char *user_file)
+{
+/*
+ * Check the arguments.
+ */
+ if(!gl) {
+ fprintf(stderr, "gl_configure_getline: NULL gl argument.\n");
+ return 1;
+ };
+/*
+ * Mark getline as having been explicitly configured.
+ */
+ gl->configured = 1;
+/*
+ * Start by parsing the configuration string, if provided.
+ */
+ if(app_string)
+ (void) _gl_read_config_string(gl, app_string, KTB_NORM);
+/*
+ * Now parse the application-specific configuration file, if provided.
+ */
+ if(app_file)
+ (void) _gl_read_config_file(gl, app_file, KTB_NORM);
+/*
+ * Finally, parse the user-specific configuration file, if provided.
+ */
+ if(user_file)
+ (void) _gl_read_config_file(gl, user_file, KTB_USER);
+/*
+ * Record the names of the configuration files to allow them to
+ * be re-read if requested at a later time.
+ */
+ if(gl_record_string(&gl->app_file, app_file) ||
+ gl_record_string(&gl->user_file, user_file)) {
+ fprintf(stderr,
+ "Insufficient memory to record tecla configuration file names.\n");
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Replace a malloc'd string (or NULL), with another malloc'd copy of
+ * a string (or NULL).
+ *
+ * Input:
+ * sptr char ** On input if *sptr!=NULL, *sptr will be
+ * free'd and *sptr will be set to NULL. Then,
+ * on output, if string!=NULL a malloc'd copy
+ * of this string will be assigned to *sptr.
+ * string const char * The string to be copied, or NULL to simply
+ * discard any existing string.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Malloc failure (no error message is generated).
+ */
+static int gl_record_string(char **sptr, const char *string)
+{
+/*
+ * If the original string is the same string, don't do anything.
+ */
+ if(*sptr == string || (*sptr && string && strcmp(*sptr, string)==0))
+ return 0;
+/*
+ * Discard any existing cached string.
+ */
+ if(*sptr) {
+ free(*sptr);
+ *sptr = NULL;
+ };
+/*
+ * Allocate memory for a copy of the specified string.
+ */
+ if(string) {
+ *sptr = (char *) malloc(strlen(string) + 1);
+ if(!*sptr)
+ return 1;
+/*
+ * Copy the string.
+ */
+ strcpy(*sptr, string);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Re-read any application-specific and user-specific files previously
+ * specified via the gl_configure_getline() function.
+ */
+static KT_KEY_FN(gl_read_init_files)
+{
+ return gl_configure_getline(gl, NULL, gl->app_file, gl->user_file);
+}
+
+/*.......................................................................
+ * Save the contents of the history buffer to a given new file.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * filename const char * The name of the new file to write to.
+ * comment const char * Extra information such as timestamps will
+ * be recorded on a line started with this
+ * string, the idea being that the file can
+ * double as a command file. Specify "" if
+ * you don't care.
+ * max_lines int The maximum number of lines to save, or -1
+ * to save all of the lines in the history
+ * list.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_save_history(GetLine *gl, const char *filename, const char *comment,
+ int max_lines)
+{
+ FileExpansion *expansion; /* The expansion of the filename */
+/*
+ * Check the arguments.
+ */
+ if(!gl || !filename || !comment) {
+ fprintf(stderr, "gl_save_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Expand the filename.
+ */
+ expansion = ef_expand_file(gl->ef, filename, -1);
+ if(!expansion) {
+ fprintf(stderr, "Unable to expand %s (%s).\n", filename,
+ ef_last_error(gl->ef));
+ return 1;
+ };
+/*
+ * Attempt to save to the specified file.
+ */
+ return _glh_save_history(gl->glh, expansion->files[0], comment, max_lines);
+}
+
+/*.......................................................................
+ * Restore the contents of the history buffer from a given new file.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * filename const char * The name of the new file to write to.
+ * comment const char * This must be the same string that was
+ * passed to gl_save_history() when the file
+ * was written.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_load_history(GetLine *gl, const char *filename, const char *comment)
+{
+ FileExpansion *expansion; /* The expansion of the filename */
+/*
+ * Check the arguments.
+ */
+ if(!gl || !filename || !comment) {
+ fprintf(stderr, "gl_load_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Expand the filename.
+ */
+ expansion = ef_expand_file(gl->ef, filename, -1);
+ if(!expansion) {
+ fprintf(stderr, "Unable to expand %s (%s).\n", filename,
+ ef_last_error(gl->ef));
+ return 1;
+ };
+/*
+ * Attempt to load from the specified file.
+ */
+ if(_glh_load_history(gl->glh, expansion->files[0], comment,
+ gl->cutbuf, gl->linelen)) {
+ gl->cutbuf[0] = '\0';
+ return 1;
+ };
+ gl->cutbuf[0] = '\0';
+ return 0;
+}
+
+/*.......................................................................
+ * Where possible, register a function and associated data to be called
+ * whenever a specified event is seen on a file descriptor.
+ *
+ * Input:
+ * gl GetLine * The resource object of the command-line input
+ * module.
+ * fd int The file descriptor to watch.
+ * event GlFdEvent The type of activity to watch for.
+ * callback GlFdEventFn * The function to call when the specified
+ * event occurs. Setting this to 0 removes
+ * any existing callback.
+ * data void * A pointer to arbitrary data to pass to the
+ * callback function.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Either gl==NULL, or this facility isn't
+ * available on the the host system
+ * (ie. select() isn't available). No
+ * error message is generated in the latter
+ * case.
+ */
+int gl_watch_fd(GetLine *gl, int fd, GlFdEvent event,
+ GlFdEventFn *callback, void *data)
+#if !defined(HAVE_SELECT)
+{return 1;} /* The facility isn't supported on this system */
+#else
+{
+ GlFdNode *prev; /* The node that precedes 'node' in gl->fd_nodes */
+ GlFdNode *node; /* The file-descriptor node being checked */
+/*
+ * Check the arguments.
+ */
+ if(!gl) {
+ fprintf(stderr, "gl_watch_fd: NULL gl argument.\n");
+ return 1;
+ };
+ if(fd < 0) {
+ fprintf(stderr, "gl_watch_fd: Error fd < 0.\n");
+ return 1;
+ };
+/*
+ * Search the list of already registered fd activity nodes for the specified
+ * file descriptor.
+ */
+ for(prev=NULL,node=gl->fd_nodes; node && node->fd != fd;
+ prev=node, node=node->next)
+ ;
+/*
+ * Hasn't a node been allocated for this fd yet?
+ */
+ if(!node) {
+/*
+ * If there is no callback to record, just ignore the call.
+ */
+ if(!callback)
+ return 0;
+/*
+ * Allocate the new node.
+ */
+ node = (GlFdNode *) _new_FreeListNode(gl->fd_node_mem);
+ if(!node) {
+ fprintf(stderr, "gl_watch_fd: Insufficient memory.\n");
+ return 1;
+ };
+/*
+ * Prepend the node to the list.
+ */
+ node->next = gl->fd_nodes;
+ gl->fd_nodes = node;
+/*
+ * Initialize the node.
+ */
+ node->fd = fd;
+ node->rd.fn = 0;
+ node->rd.data = NULL;
+ node->ur = node->wr = node->rd;
+ };
+/*
+ * Record the new callback.
+ */
+ switch(event) {
+ case GLFD_READ:
+ node->rd.fn = callback;
+ node->rd.data = data;
+ if(callback)
+ FD_SET(fd, &gl->rfds);
+ else
+ FD_CLR(fd, &gl->rfds);
+ break;
+ case GLFD_WRITE:
+ node->wr.fn = callback;
+ node->wr.data = data;
+ if(callback)
+ FD_SET(fd, &gl->wfds);
+ else
+ FD_CLR(fd, &gl->wfds);
+ break;
+ case GLFD_URGENT:
+ node->ur.fn = callback;
+ node->ur.data = data;
+ if(callback)
+ FD_SET(fd, &gl->ufds);
+ else
+ FD_CLR(fd, &gl->ufds);
+ break;
+ };
+/*
+ * Keep a record of the largest file descriptor being watched.
+ */
+ if(fd > gl->max_fd)
+ gl->max_fd = fd;
+/*
+ * If we are deleting an existing callback, also delete the parent
+ * activity node if no callbacks are registered to the fd anymore.
+ */
+ if(!callback) {
+ if(!node->rd.fn && !node->wr.fn && !node->ur.fn) {
+ if(prev)
+ prev->next = node->next;
+ else
+ gl->fd_nodes = node->next;
+ node = (GlFdNode *) _del_FreeListNode(gl->fd_node_mem, node);
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * When select() is available, this function is called by
+ * gl_read_character() to respond to file-descriptor events registered by
+ * the caller.
+ *
+ * Input:
+ * gl GetLine * The resource object of this module.
+ * Output:
+ * return int 0 - A character is waiting to be read from the
+ * terminal.
+ * 1 - An error occurred.
+ */
+static int gl_event_handler(GetLine *gl)
+{
+/*
+ * If at any time no external callbacks remain, quit the loop return,
+ * so that we can simply wait in read(). This is designed as an
+ * optimization for when no callbacks have been registered on entry to
+ * this function, but since callbacks can delete themselves, it can
+ * also help later.
+ */
+ while(gl->fd_nodes) {
+/*
+ * Get the set of descriptors to be watched.
+ */
+ fd_set rfds = gl->rfds;
+ fd_set wfds = gl->wfds;
+ fd_set ufds = gl->ufds;
+/*
+ * Wait for activity on any of the file descriptors.
+ */
+ int nready = select(gl->max_fd+1, &rfds, &wfds, &ufds, NULL);
+/*
+ * If select() returns but none of the file descriptors are reported
+ * to have activity, then select() timed out.
+ */
+ if(nready == 0) {
+ fprintf(stdout, "\r\nUnexpected select() timeout\r\n");
+ return 1;
+/*
+ * If nready < 0, this means an error occurred.
+ */
+ } else if(nready < 0) {
+ if(errno != EINTR) {
+#ifdef EAGAIN
+ if(!errno) /* This can happen with SysV O_NDELAY */
+ errno = EAGAIN;
+#endif
+ return 1;
+ };
+/*
+ * If the terminal input file descriptor has data available, return.
+ */
+ } else if(FD_ISSET(gl->input_fd, &rfds)) {
+ return 0;
+/*
+ * Check for activity on any of the file descriptors registered by the
+ * calling application, and call the associated callback functions.
+ */
+ } else {
+ GlFdNode *node; /* The fd event node being checked */
+/*
+ * Search the list for the file descriptor that caused select() to return.
+ */
+ for(node=gl->fd_nodes; node; node=node->next) {
+/*
+ * Is there urgent out of band data waiting to be read on fd?
+ */
+ if(node->ur.fn && FD_ISSET(node->fd, &ufds)) {
+ if(gl_call_fd_handler(gl, &node->ur, node->fd, GLFD_URGENT))
+ return 1;
+ break; /* The callback may have changed the list of nodes */
+/*
+ * Is the fd readable?
+ */
+ } else if(node->rd.fn && FD_ISSET(node->fd, &rfds)) {
+ if(gl_call_fd_handler(gl, &node->rd, node->fd, GLFD_READ))
+ return 1;
+ break; /* The callback may have changed the list of nodes */
+/*
+ * Is the fd writable?
+ */
+ } else if(node->wr.fn && FD_ISSET(node->fd, &rfds)) {
+ if(gl_call_fd_handler(gl, &node->wr, node->fd, GLFD_WRITE))
+ return 1;
+ break; /* The callback may have changed the list of nodes */
+ };
+ };
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This is a private function of gl_event_handler(), used to call a
+ * file-descriptor callback.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * gfh GlFdHandler * The I/O handler.
+ * fd int The file-descriptor being reported.
+ * event GlFdEvent The I/O event being reported.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_call_fd_handler(GetLine *gl, GlFdHandler *gfh, int fd,
+ GlFdEvent event)
+{
+ Termios attr; /* The terminal attributes */
+ int redisplay = 0; /* True to have the input line redisplayed */
+ int waserr = 0; /* True after any error */
+/*
+ * We don't want to do a longjmp in the middle of a callback that
+ * might be modifying global or heap data, so block all the signals
+ * that we are trapping.
+ */
+ if(sigprocmask(SIG_BLOCK, &gl->new_signal_set, NULL) == -1) {
+ fprintf(stderr, "getline(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+/*
+ * Re-enable conversion of newline characters to carriage-return/linefeed,
+ * so that the callback can write to the terminal without having to do
+ * anything special.
+ */
+ if(tcgetattr(gl->input_fd, &attr)) {
+ fprintf(stderr, "\r\ngetline(): tcgetattr error: %s\r\n", strerror(errno));
+ return 1;
+ };
+ attr.c_oflag |= OPOST;
+ while(tcsetattr(gl->input_fd, TCSADRAIN, &attr)) {
+ if (errno != EINTR) {
+ fprintf(stderr, "\r\ngetline(): tcsetattr error: %s\r\n",
+ strerror(errno));
+ return 1;
+ };
+ };
+/*
+ * Invoke the application's callback function.
+ */
+ switch(gfh->fn(gl, gfh->data, fd, event)) {
+ default:
+ case GLFD_ABORT:
+ waserr = 1;
+ break;
+ case GLFD_REFRESH:
+ redisplay = 1;
+ break;
+ case GLFD_CONTINUE:
+ redisplay = gl->prompt_changed;
+ break;
+ };
+/*
+ * Disable conversion of newline characters to carriage-return/linefeed.
+ */
+ attr.c_oflag &= ~(OPOST);
+ while(tcsetattr(gl->input_fd, TCSADRAIN, &attr)) {
+ if(errno != EINTR) {
+ fprintf(stderr, "\ngetline(): tcsetattr error: %s\n", strerror(errno));
+ return 1;
+ };
+ };
+/*
+ * If requested, redisplay the input line.
+ */
+ if(redisplay && gl_redisplay(gl, 1))
+ return 1;
+/*
+ * Unblock the signals that we were trapping before this function
+ * was called.
+ */
+ if(sigprocmask(SIG_UNBLOCK, &gl->new_signal_set, NULL) == -1) {
+ fprintf(stderr, "getline(): sigprocmask error: %s\n", strerror(errno));
+ return 1;
+ };
+ return waserr;
+}
+#endif /* HAVE_SELECT */
+
+/*.......................................................................
+ * Switch history groups. History groups represent separate history
+ * lists recorded within a single history buffer. Different groups
+ * are distinguished by integer identifiers chosen by the calling
+ * appplicaton. Initially new_GetLine() sets the group identifier to
+ * 0. Whenever a new line is appended to the history list, the current
+ * group identifier is recorded with it, and history lookups only
+ * consider lines marked with the current group identifier.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * id unsigned The new history group identifier.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_group_history(GetLine *gl, unsigned id)
+{
+/*
+ * Check the arguments.
+ */
+ if(!gl) {
+ fprintf(stderr, "gl_group_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * If the group isn't being changed, do nothing.
+ */
+ if(_glh_get_group(gl->glh) == id)
+ return 0;
+/*
+ * Establish the new group.
+ */
+ if(_glh_set_group(gl->glh, id))
+ return 1;
+/*
+ * Prevent history information from the previous group being
+ * inappropriately used by the next call to gl_get_line().
+ */
+ gl->preload_history = 0;
+ gl->last_search = -1;
+ return 0;
+}
+
+/*.......................................................................
+ * Display the contents of the history list.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * fp FILE * The stdio output stream to write to.
+ * fmt const char * A format string. This containing characters to be
+ * written verbatim, plus any of the following
+ * format directives:
+ * %D - The date, formatted like 2001-11-20
+ * %T - The time of day, formatted like 23:59:59
+ * %N - The sequential entry number of the
+ * line in the history buffer.
+ * %G - The number of the history group that
+ * the line belongs to.
+ * %% - A literal % character.
+ * %H - The history line itself.
+ * Note that a '\n' newline character is not
+ * appended by default.
+ * all_groups int If true, display history lines from all
+ * history groups. Otherwise only display
+ * those of the current history group.
+ * max_lines int If max_lines is < 0, all available lines
+ * are displayed. Otherwise only the most
+ * recent max_lines lines will be displayed.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_show_history(GetLine *gl, FILE *fp, const char *fmt, int all_groups,
+ int max_lines)
+{
+/*
+ * Check the arguments.
+ */
+ if(!gl || !fp || !fmt) {
+ fprintf(stderr, "gl_show_history: NULL argument(s).\n");
+ return 1;
+ };
+ return _glh_show_history(gl->glh, fp, fmt, all_groups, max_lines);
+}
+
+/*.......................................................................
+ * Update if necessary, and return the current size of the terminal.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * def_ncolumn int If the number of columns in the terminal
+ * can't be determined, substitute this number.
+ * def_nline int If the number of lines in the terminal can't
+ * be determined, substitute this number.
+ * Output:
+ * return GlTerminalSize The current terminal size.
+ */
+GlTerminalSize gl_terminal_size(GetLine *gl, int def_ncolumn, int def_nline)
+{
+ GlTerminalSize size; /* The return value */
+ const char *env; /* The value of an environment variable */
+ int n; /* A number read from env[] */
+/*
+ * Set the number of lines and columns to non-sensical values so that
+ * we know later if they have been set.
+ */
+ gl->nline = 0;
+ gl->ncolumn = 0;
+/*
+ * Are we reading from a terminal?
+ */
+ if(gl->is_term) {
+/*
+ * Ask the terminal directly if possible.
+ */
+#ifdef USE_SIGWINCH
+ (void) gl_resize_terminal(gl, 0);
+#endif
+/*
+ * If gl_resize_terminal() couldn't be used, or it returned non-sensical
+ * values for the number of lines, see if the LINES environment variable
+ * exists and specifies a believable number. If this doesn't work,
+ * look up the default size in the terminal information database,
+ * where available.
+ */
+ if(gl->nline < 1) {
+ if((env = getenv("LINES")) && (n=atoi(env)) > 0)
+ gl->nline = n;
+#ifdef USE_TERMINFO
+ else
+ gl->nline = tigetnum((char *)"lines");
+#elif defined(USE_TERMCAP)
+ else
+ gl->nline = tgetnum("li");
+#endif
+ };
+/*
+ * If gl_resize_terminal() couldn't be used, or it returned non-sensical
+ * values for the number of columns, see if the COLUMNS environment variable
+ * exists and specifies a believable number. If this doesn't work, fall
+ * lookup the default size in the terminal information database,
+ * where available.
+ */
+ if(gl->ncolumn < 1) {
+ if((env = getenv("COLUMNS")) && (n=atoi(env)) > 0)
+ gl->ncolumn = n;
+#ifdef USE_TERMINFO
+ else
+ gl->ncolumn = tigetnum((char *)"cols");
+#elif defined(USE_TERMCAP)
+ else
+ gl->ncolumn = tgetnum("co");
+#endif
+ };
+ };
+/*
+ * If we still haven't been able to acquire reasonable values, substitute
+ * the default values specified by the caller.
+ */
+ if(gl->nline <= 0)
+ gl->nline = def_nline;
+ if(gl->ncolumn <= 0)
+ gl->ncolumn = def_ncolumn;
+/*
+ * Copy the new size into the return value.
+ */
+ size.nline = gl->nline;
+ size.ncolumn = gl->ncolumn;
+ return size;
+}
+
+/*.......................................................................
+ * Resize or delete the history buffer.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * bufsize size_t The number of bytes in the history buffer, or 0
+ * to delete the buffer completely.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Insufficient memory (the previous buffer
+ * will have been retained). No error message
+ * will be displayed.
+ */
+int gl_resize_history(GetLine *gl, size_t bufsize)
+{
+ return gl ? _glh_resize_history(gl->glh, bufsize) : 1;
+}
+
+/*.......................................................................
+ * Set an upper limit to the number of lines that can be recorded in the
+ * history list, or remove a previously specified limit.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * max_lines int The maximum number of lines to allow, or -1 to
+ * cancel a previous limit and allow as many lines
+ * as will fit in the current history buffer size.
+ */
+void gl_limit_history(GetLine *gl, int max_lines)
+{
+ if(gl)
+ _glh_limit_history(gl->glh, max_lines);
+}
+
+/*.......................................................................
+ * Discard either all historical lines, or just those associated with the
+ * current history group.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * all_groups int If true, clear all of the history. If false,
+ * clear only the stored lines associated with the
+ * currently selected history group.
+ */
+void gl_clear_history(GetLine *gl, int all_groups)
+{
+ if(gl)
+ _glh_clear_history(gl->glh, all_groups);
+}
+
+/*.......................................................................
+ * Temporarily enable or disable the gl_get_line() history mechanism.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * enable int If true, turn on the history mechanism. If
+ * false, disable it.
+ */
+void gl_toggle_history(GetLine *gl, int enable)
+{
+ if(gl)
+ _glh_toggle_history(gl->glh, enable);
+}
+
+/*.......................................................................
+ * Lookup a history line by its sequential number of entry in the
+ * history buffer.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * id unsigned long The identification number of the line to
+ * be returned, where 0 denotes the first line
+ * that was entered in the history list, and
+ * each subsequently added line has a number
+ * one greater than the previous one. For
+ * the range of lines currently in the list,
+ * see the gl_range_of_history() function.
+ * Input/Output:
+ * line GlHistoryLine * A pointer to the variable in which to
+ * return the details of the line.
+ * Output:
+ * return int 0 - The line is no longer in the history
+ * list, and *line has not been changed.
+ * 1 - The requested line can be found in
+ * *line. Note that line->line is part
+ * of the history buffer, so a
+ * private copy should be made if you
+ * wish to use it after subsequent calls
+ * to any functions that take *gl as an
+ * argument.
+ */
+int gl_lookup_history(GetLine *gl, unsigned long id, GlHistoryLine *line)
+{
+ return gl ? _glh_lookup_history(gl->glh, (GlhLineID) id, &line->line,
+ &line->group, &line->timestamp) : 0;
+}
+
+/*.......................................................................
+ * Query the state of the history list. Note that any of the input/output
+ * pointers can be specified as NULL.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * Input/Output:
+ * state GlHistoryState * A pointer to the variable in which to record
+ * the return values.
+ */
+void gl_state_of_history(GetLine *gl, GlHistoryState *state)
+{
+ if(gl && state)
+ _glh_state_of_history(gl->glh, &state->enabled, &state->group,
+ &state->max_lines);
+}
+
+/*.......................................................................
+ * Query the number and range of lines in the history buffer.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * range GlHistoryRange * A pointer to the variable in which to record
+ * the return values. If range->nline=0, the
+ * range of lines will be given as 0-0.
+ */
+void gl_range_of_history(GetLine *gl, GlHistoryRange *range)
+{
+ if(gl && range)
+ _glh_range_of_history(gl->glh, &range->oldest, &range->newest,
+ &range->nlines);
+}
+
+/*.......................................................................
+ * Return the size of the history buffer and the amount of the
+ * buffer that is currently in use.
+ *
+ * Input:
+ * gl GetLine * The gl_get_line() resource object.
+ * Input/Output:
+ * GlHistorySize size * A pointer to the variable in which to return
+ * the results.
+ */
+void gl_size_of_history(GetLine *gl, GlHistorySize *size)
+{
+ if(gl && size)
+ _glh_size_of_history(gl->glh, &size->size, &size->used);
+}
+
+/*.......................................................................
+ * This is the action function that lists the contents of the history
+ * list.
+ */
+static KT_KEY_FN(gl_list_history)
+{
+/*
+ * Start a new line.
+ */
+ if(fprintf(gl->output_fp, "\r\n") < 0)
+ return 1;
+/*
+ * List history lines that belong to the current group.
+ */
+ _glh_show_history(gl->glh, gl->output_fp, "%N %T %H\r\n", 0,
+ count<=1 ? -1 : count);
+/*
+ * Redisplay the line being edited.
+ */
+ gl->term_curpos = 0;
+ return gl_redisplay(gl,1);
+}
+
+/*.......................................................................
+ * Specify whether text that users type should be displayed or hidden.
+ * In the latter case, only the prompt is displayed, and the final
+ * input line is not archived in the history list.
+ *
+ * Input:
+ * gl GetLine * The gl_get_line() resource object.
+ * enable int 0 - Disable echoing.
+ * 1 - Enable echoing.
+ * -1 - Just query the mode without changing it.
+ * Output:
+ * return int The echoing disposition that was in effect
+ * before this function was called:
+ * 0 - Echoing was disabled.
+ * 1 - Echoing was enabled.
+ */
+int gl_echo_mode(GetLine *gl, int enable)
+{
+ if(gl) {
+ int was_echoing = gl->echo;
+ if(enable >= 0)
+ gl->echo = enable;
+ return was_echoing;
+ };
+ return 1;
+}
+
+/*.......................................................................
+ * Display the prompt.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_display_prompt(GetLine *gl)
+{
+ const char *pptr; /* A pointer into gl->prompt[] */
+ unsigned old_attr=0; /* The current text display attributes */
+ unsigned new_attr=0; /* The requested text display attributes */
+/*
+ * Temporarily switch to echoing output characters.
+ */
+ int kept_echo = gl->echo;
+ gl->echo = 1;
+/*
+ * In case the screen got messed up, send a carriage return to
+ * put the cursor at the beginning of the current terminal line.
+ */
+ if(gl_output_control_sequence(gl, 1, gl->bol))
+ return 1;
+/*
+ * Write the prompt, using the currently selected prompt style.
+ */
+ switch(gl->prompt_style) {
+ case GL_LITERAL_PROMPT:
+ if(gl_output_string(gl, gl->prompt, '\0'))
+ return 1;
+ break;
+ case GL_FORMAT_PROMPT:
+ for(pptr=gl->prompt; *pptr; pptr++) {
+/*
+ * Does the latest character appear to be the start of a directive?
+ */
+ if(*pptr == '%') {
+/*
+ * Check for and act on attribute changing directives.
+ */
+ switch(pptr[1]) {
+/*
+ * Add or remove a text attribute from the new set of attributes.
+ */
+ case 'B': case 'U': case 'S': case 'P': case 'F': case 'V':
+ case 'b': case 'u': case 's': case 'p': case 'f': case 'v':
+ switch(*++pptr) {
+ case 'B': /* Switch to a bold font */
+ new_attr |= GL_TXT_BOLD;
+ break;
+ case 'b': /* Switch to a non-bold font */
+ new_attr &= ~GL_TXT_BOLD;
+ break;
+ case 'U': /* Start underlining */
+ new_attr |= GL_TXT_UNDERLINE;
+ break;
+ case 'u': /* Stop underlining */
+ new_attr &= ~GL_TXT_UNDERLINE;
+ break;
+ case 'S': /* Start highlighting */
+ new_attr |= GL_TXT_STANDOUT;
+ break;
+ case 's': /* Stop highlighting */
+ new_attr &= ~GL_TXT_STANDOUT;
+ break;
+ case 'P': /* Switch to a pale font */
+ new_attr |= GL_TXT_DIM;
+ break;
+ case 'p': /* Switch to a non-pale font */
+ new_attr &= ~GL_TXT_DIM;
+ break;
+ case 'F': /* Switch to a flashing font */
+ new_attr |= GL_TXT_BLINK;
+ break;
+ case 'f': /* Switch to a steady font */
+ new_attr &= ~GL_TXT_BLINK;
+ break;
+ case 'V': /* Switch to reverse video */
+ new_attr |= GL_TXT_REVERSE;
+ break;
+ case 'v': /* Switch out of reverse video */
+ new_attr &= ~GL_TXT_REVERSE;
+ break;
+ };
+ continue;
+/*
+ * A literal % is represented by %%. Skip the leading %.
+ */
+ case '%':
+ pptr++;
+ break;
+ };
+ };
+/*
+ * Many terminals, when asked to turn off a single text attribute, turn
+ * them all off, so the portable way to turn one off individually is to
+ * explicitly turn them all off, then specify those that we want from
+ * scratch.
+ */
+ if(old_attr & ~new_attr) {
+ if(gl_output_control_sequence(gl, 1, gl->text_attr_off))
+ return 1;
+ old_attr = 0;
+ };
+/*
+ * Install new text attributes?
+ */
+ if(new_attr != old_attr) {
+ if(new_attr & GL_TXT_BOLD && !(old_attr & GL_TXT_BOLD) &&
+ gl_output_control_sequence(gl, 1, gl->bold))
+ return 1;
+ if(new_attr & GL_TXT_UNDERLINE && !(old_attr & GL_TXT_UNDERLINE) &&
+ gl_output_control_sequence(gl, 1, gl->underline))
+ return 1;
+ if(new_attr & GL_TXT_STANDOUT && !(old_attr & GL_TXT_STANDOUT) &&
+ gl_output_control_sequence(gl, 1, gl->standout))
+ return 1;
+ if(new_attr & GL_TXT_DIM && !(old_attr & GL_TXT_DIM) &&
+ gl_output_control_sequence(gl, 1, gl->dim))
+ return 1;
+ if(new_attr & GL_TXT_REVERSE && !(old_attr & GL_TXT_REVERSE) &&
+ gl_output_control_sequence(gl, 1, gl->reverse))
+ return 1;
+ if(new_attr & GL_TXT_BLINK && !(old_attr & GL_TXT_BLINK) &&
+ gl_output_control_sequence(gl, 1, gl->blink))
+ return 1;
+ old_attr = new_attr;
+ };
+/*
+ * Display the latest character.
+ */
+ if(gl_output_char(gl, *pptr, pptr[1]))
+ return 1;
+ };
+/*
+ * Turn off all text attributes now that we have finished drawing
+ * the prompt.
+ */
+ if(gl_output_control_sequence(gl, 1, gl->text_attr_off))
+ return 1;
+ break;
+ };
+/*
+ * Restore the original echo mode.
+ */
+ gl->echo = kept_echo;
+/*
+ * The prompt has now been displayed at least once.
+ */
+ gl->prompt_changed = 0;
+ return 0;
+}
+
+/*.......................................................................
+ * This function can be called from gl_get_line() callbacks to have
+ * the prompt changed when they return. It has no effect if gl_get_line()
+ * is not currently being invoked.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * prompt const char * The new prompt.
+ */
+void gl_replace_prompt(GetLine *gl, const char *prompt)
+{
+ if(gl) {
+ gl->prompt = prompt ? prompt : "";
+ gl->prompt_len = gl_displayed_prompt_width(gl);
+ gl->prompt_changed = 1;
+ };
+}
+
+/*.......................................................................
+ * Work out the length of the current prompt on the terminal, according
+ * to the current prompt formatting style.
+ *
+ * Input:
+ * gl GetLine * The resource object of this library.
+ * Output:
+ * return int The number of displayed characters.
+ */
+static int gl_displayed_prompt_width(GetLine *gl)
+{
+ int slen=0; /* The displayed number of characters */
+ const char *pptr; /* A pointer into prompt[] */
+/*
+ * The length differs according to the prompt display style.
+ */
+ switch(gl->prompt_style) {
+ case GL_LITERAL_PROMPT:
+ return gl_displayed_string_width(gl, gl->prompt, -1, 0);
+ break;
+ case GL_FORMAT_PROMPT:
+/*
+ * Add up the length of the displayed string, while filtering out
+ * attribute directives.
+ */
+ for(pptr=gl->prompt; *pptr; pptr++) {
+/*
+ * Does the latest character appear to be the start of a directive?
+ */
+ if(*pptr == '%') {
+/*
+ * Check for and skip attribute changing directives.
+ */
+ switch(pptr[1]) {
+ case 'B': case 'b': case 'U': case 'u': case 'S': case 's':
+ pptr++;
+ continue;
+/*
+ * A literal % is represented by %%. Skip the leading %.
+ */
+ case '%':
+ pptr++;
+ break;
+ };
+ };
+ slen += gl_displayed_char_width(gl, *pptr, slen);
+ };
+ break;
+ };
+ return slen;
+}
+
+/*.......................................................................
+ * Specify whether to heed text attribute directives within prompt
+ * strings.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * style GlPromptStyle The style of prompt (see the definition of
+ * GlPromptStyle in libtecla.h for details).
+ */
+void gl_prompt_style(GetLine *gl, GlPromptStyle style)
+{
+ if(gl) {
+ if(style != gl->prompt_style) {
+ gl->prompt_style = style;
+ gl->prompt_len = gl_displayed_prompt_width(gl);
+ gl->prompt_changed = 1;
+ };
+ };
+}
+
+/*.......................................................................
+ * Tell gl_get_line() how to respond to a given signal. This can be used
+ * both to override the default responses to signals that gl_get_line()
+ * normally catches and to add new signals to the list that are to be
+ * caught.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * signo int The number of the signal to be caught.
+ * flags unsigned A bitwise union of GlSignalFlags enumerators.
+ * after GlAfterSignal What to do after the application's signal
+ * handler has been called.
+ * errno_value int The value to set errno to.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_trap_signal(GetLine *gl, int signo, unsigned flags,
+ GlAfterSignal after, int errno_value)
+{
+ GlSignalNode *sig;
+/*
+ * Check the arguments.
+ */
+ if(!gl) {
+ fprintf(stderr, "gl_trap_signal: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * See if the signal has already been registered.
+ */
+ for(sig=gl->sigs; sig && sig->signo != signo; sig = sig->next)
+ ;
+/*
+ * If the signal hasn't already been registered, allocate a node for
+ * it.
+ */
+ if(!sig) {
+ sig = (GlSignalNode *) _new_FreeListNode(gl->sig_mem);
+ if(!sig)
+ return 1;
+/*
+ * Add the new node to the head of the list.
+ */
+ sig->next = gl->sigs;
+ gl->sigs = sig;
+/*
+ * Record the signal number.
+ */
+ sig->signo = signo;
+/*
+ * Create a signal set that includes just this signal.
+ */
+ sigemptyset(&sig->proc_mask);
+ if(sigaddset(&sig->proc_mask, signo) == -1) {
+ fprintf(stderr, "gl_trap_signal: sigaddset error: %s\n",
+ strerror(errno));
+ sig = (GlSignalNode *) _del_FreeListNode(gl->sig_mem, sig);
+ return 1;
+ };
+ };
+/*
+ * Record the new signal attributes.
+ */
+ sig->flags = flags;
+ sig->after = after;
+ sig->errno_value = errno_value;
+ return 0;
+}
+
+/*.......................................................................
+ * Remove a signal from the list of signals that gl_get_line() traps.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * signo int The number of the signal to be ignored.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int gl_ignore_signal(GetLine *gl, int signo)
+{
+ GlSignalNode *sig; /* The gl->sigs list node of the specified signal */
+ GlSignalNode *prev; /* The node that precedes sig in the list */
+/*
+ * Check the arguments.
+ */
+ if(!gl) {
+ fprintf(stderr, "gl_ignore_signal: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Find the node of the gl->sigs list which records the disposition
+ * of the specified signal.
+ */
+ for(prev=NULL,sig=gl->sigs; sig && sig->signo != signo;
+ prev=sig,sig=sig->next)
+ ;
+ if(sig) {
+/*
+ * Remove the node from the list.
+ */
+ if(prev)
+ prev->next = sig->next;
+ else
+ gl->sigs = sig->next;
+/*
+ * Return the node to the freelist.
+ */
+ sig = (GlSignalNode *) _del_FreeListNode(gl->sig_mem, sig);
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * This function is called when an input line has been completed. It
+ * appends the specified newline character, terminates the line,
+ * records the line in the history buffer if appropriate, and positions
+ * the terminal cursor at the start of the next line.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * newline_char int The newline character to add to the end
+ * of the line.
+ * archive int True to have the line archived in the
+ * history buffer.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int gl_line_ended(GetLine *gl, int newline_char, int archive)
+{
+/*
+ * If the newline character is printable, display it.
+ */
+ if(isprint((int)(unsigned char) newline_char)) {
+ if(gl_end_of_line(gl, 1) || gl_add_char_to_line(gl, newline_char))
+ return 1;
+ } else {
+/*
+ * Otherwise just append it to the input line buffer.
+ */
+ gl->line[gl->ntotal++] = newline_char;
+ gl->line[gl->ntotal] = '\0';
+ };
+/*
+ * Add the line to the history buffer if it was entered with a
+ * newline or carriage return character.
+ */
+ if(archive)
+ (void) _glh_add_history(gl->glh, gl->line, 0);
+/*
+ * Unless depending on the system-provided line editing, start a new
+ * line after the end of the line that has just been entered.
+ */
+ if(gl->editor != GL_NO_EDITOR) {
+ if(gl_end_of_line(gl, 1) ||
+ gl_output_raw_string(gl, "\r\n"))
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Return the last signal that was caught by the most recent call to
+ * gl_get_line(), or -1 if no signals were caught. This is useful if
+ * gl_get_line() returns errno=EINTR and you need to find out what signal
+ * caused it to abort.
+ *
+ * Input:
+ * gl GetLine * The resource object of gl_get_line().
+ * Output:
+ * return int The last signal caught by the most recent
+ * call to gl_get_line(), or -1 if no signals
+ * were caught.
+ */
+int gl_last_signal(const GetLine *gl)
+{
+ return gl ? gl->last_signal : -1;
+}
diff --git a/libtecla-1.4.1/getline.h b/libtecla-1.4.1/getline.h
new file mode 100644
index 0000000..24b0875
--- /dev/null
+++ b/libtecla-1.4.1/getline.h
@@ -0,0 +1,88 @@
+#ifndef getline_h
+#define getline_h
+
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * Set the name of the getline configuration file.
+ */
+#define TECLA_CONFIG_FILE "~/.teclarc"
+
+/*
+ * The following macro returns non-zero if a character is
+ * a control character.
+ */
+#define IS_CTRL_CHAR(c) ((unsigned char)(c) < ' ' || (unsigned char)(c)=='\177')
+
+/*
+ * The following macro returns non-zero if a character is
+ * a meta character.
+ */
+#define IS_META_CHAR(c) (((unsigned char)(c) & 0x80) && !isprint((int)(unsigned char)(c)))
+
+/*
+ * Return the character that would be produced by pressing the
+ * specified key plus the control key.
+ */
+#define MAKE_CTRL(c) ((c)=='?' ? '\177' : ((unsigned char)toupper(c) & ~0x40))
+
+/*
+ * Return the character that would be produced by pressing the
+ * specified key plus the meta key.
+ */
+#define MAKE_META(c) ((unsigned char)(c) | 0x80)
+
+/*
+ * Given a binary control character, return the character that
+ * had to be pressed at the same time as the control key.
+ */
+#define CTRL_TO_CHAR(c) (toupper((unsigned char)(c) | 0x40))
+
+/*
+ * Given a meta character, return the character that was pressed
+ * at the same time as the meta key.
+ */
+#define META_TO_CHAR(c) ((unsigned char)(c) & ~0x80)
+
+/*
+ * Specify the string of characters other than the alphanumeric characters,
+ * that are to be considered parts of words.
+ */
+#define GL_WORD_CHARS "_*\?\\[]"
+
+/*
+ * Define the escape character, both as a string and as a character.
+ */
+#define GL_ESC_STR "\033"
+#define GL_ESC_CHAR '\033'
+
+#endif
diff --git a/libtecla-1.4.1/hash.c b/libtecla-1.4.1/hash.c
new file mode 100644
index 0000000..89f8245
--- /dev/null
+++ b/libtecla-1.4.1/hash.c
@@ -0,0 +1,748 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "hash.h"
+#include "strngmem.h"
+#include "freelist.h"
+
+/*
+ * The following container object contains free-lists to be used
+ * for allocation of HashTable containers and nodes.
+ */
+struct HashMemory {
+ FreeList *hash_memory; /* HashTable free-list */
+ FreeList *node_memory; /* HashNode free-list */
+ StringMem *string_memory; /* Memory used to allocate hash strings */
+};
+
+/*
+ * Define a hash symbol-table entry.
+ * See symbol.h for the definition of the Symbol container type.
+ */
+typedef struct HashNode HashNode;
+struct HashNode {
+ Symbol symbol; /* The symbol stored in the hash-entry */
+ HashNode *next; /* The next hash-table entry in a bucket list */
+};
+
+/*
+ * Each hash-table bucket contains a linked list of entries that
+ * hash to the same bucket.
+ */
+typedef struct {
+ HashNode *head; /* The head of the bucket hash-node list */
+ int count; /* The number of entries in the list */
+} HashBucket;
+
+/*
+ * Set the max length of the error-reporting string. There is no point
+ * in this being longer than the width of a typical terminal window.
+ * In composing error messages, I have assumed that this number is
+ * at least 80, so you don't decrease it below this number.
+ */
+#define ERRLEN 200
+
+/*
+ * A hash-table consists of 'size' hash buckets.
+ * Note that the HashTable typedef for this struct is contained in hash.h.
+ */
+struct HashTable {
+ char errmsg[ERRLEN+1];/* Error-report buffer */
+ HashMemory *mem; /* HashTable free-list */
+ int internal_mem; /* True if 'mem' was allocated by _new_HashTable() */
+ int case_sensitive; /* True if case is significant in lookup keys */
+ int size; /* The number of hash buckets */
+ HashBucket *bucket; /* An array of 'size' hash buckets */
+ int (*keycmp)(const char *, const char *); /* Key comparison function */
+ void *app_data; /* Application-provided data */
+ HASH_DEL_FN(*del_fn); /* Application-provided 'app_data' destructor */
+};
+
+static HashNode *_del_HashNode(HashTable *hash, HashNode *node);
+static HashNode *_new_HashNode(HashTable *hash, const char *name, int code,
+ void (*fn)(void), void *data, SYM_DEL_FN(*del_fn));
+static HashNode *_find_HashNode(HashTable *hash, HashBucket *bucket,
+ const char *name, HashNode **prev);
+static HashBucket *_find_HashBucket(HashTable *hash, const char *name);
+static int _ht_lower_strcmp(const char *node_key, const char *look_key);
+static int _ht_strcmp(const char *node_key, const char *look_key);
+
+/*.......................................................................
+ * Allocate a free-list for use in allocating hash tables and their nodes.
+ *
+ * Input:
+ * list_count int The number of HashTable containers per free-list
+ * block.
+ * node_count int The number of HashTable nodes per free-list block.
+ * Output:
+ * return HashMemory * The new free-list for use in allocating hash tables
+ * and their nodes.
+ */
+HashMemory *_new_HashMemory(int hash_count, int node_count)
+{
+ HashMemory *mem;
+/*
+ * Allocate the free-list container.
+ */
+ mem = (HashMemory *) malloc(sizeof(HashMemory));
+ if(!mem) {
+ fprintf(stderr, "_new_HashMemory: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Initialize the container at least up to the point at which it can
+ * safely be passed to _del_HashMemory().
+ */
+ mem->hash_memory = NULL;
+ mem->node_memory = NULL;
+ mem->string_memory = NULL;
+/*
+ * Allocate the two free-lists.
+ */
+ mem->hash_memory = _new_FreeList("_new_HashMemory", sizeof(HashTable),
+ hash_count);
+ if(!mem->hash_memory)
+ return _del_HashMemory(mem, 1);
+ mem->node_memory = _new_FreeList("_new_HashMemory", sizeof(HashNode),
+ node_count);
+ if(!mem->node_memory)
+ return _del_HashMemory(mem, 1);
+ mem->string_memory = _new_StringMem("_new_HashMemory", 64);
+ if(!mem->string_memory)
+ return _del_HashMemory(mem, 1);
+/*
+ * Return the free-list container.
+ */
+ return mem;
+}
+
+/*.......................................................................
+ * Delete a HashTable free-list. An error will be displayed if the list is
+ * still in use and the deletion will be aborted.
+ *
+ * Input:
+ * mem HashMemory * The free-list container to be deleted.
+ * force int If force==0 then _del_HashMemory() will complain
+ * and refuse to delete the free-list if any
+ * of nodes have not been returned to the free-list.
+ * If force!=0 then _del_HashMemory() will not check
+ * whether any nodes are still in use and will
+ * always delete the list.
+ * Output:
+ * return HashMemory * Always NULL (even if the memory could not be
+ * deleted).
+ */
+HashMemory *_del_HashMemory(HashMemory *mem, int force)
+{
+ const char *caller = "_del_HashMemory";
+ if(mem) {
+ if(!force && (_busy_FreeListNodes(mem->hash_memory) > 0 ||
+ _busy_FreeListNodes(mem->node_memory) > 0)) {
+ fprintf(stderr, "%s: Free-list in use.\n", caller);
+ return NULL;
+ };
+ mem->hash_memory = _del_FreeList(caller, mem->hash_memory, force);
+ mem->node_memory = _del_FreeList(caller, mem->node_memory, force);
+ mem->string_memory = _del_StringMem(caller, mem->string_memory, force);
+ free(mem);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Create a new hash table.
+ *
+ * Input:
+ * mem HashMemory * An optional free-list for use in allocating
+ * HashTable containers and nodes. See explanation
+ * in hash.h. If you are going to allocate more
+ * than one hash table, then it will be more
+ * efficient to allocate a single free-list for
+ * all of them than to force each hash table
+ * to allocate its own private free-list.
+ * size int The size of the hash table. Best performance
+ * will be acheived if this is a prime number.
+ * hcase HashCase Specify how symbol case is considered when
+ * looking up symbols, from:
+ * IGNORE_CASE - Upper and lower case versions
+ * of a letter are treated as
+ * being identical.
+ * HONOUR_CASE - Upper and lower case versions
+ * of a letter are treated as
+ * being distinct.
+ * characters in a lookup name is significant.
+ * app_data void * Optional application data to be registered
+ * to the table. This is presented to user
+ * provided SYM_DEL_FN() symbol destructors along
+ * with the symbol data.
+ * del_fn() HASH_DEL_FN(*) If you want app_data to be free'd when the
+ * hash-table is destroyed, register a suitable
+ * destructor function here.
+ * Output:
+ * return HashTable * The new hash table, or NULL on error.
+ */
+HashTable *_new_HashTable(HashMemory *mem, int size, HashCase hcase,
+ void *app_data, HASH_DEL_FN(*del_fn))
+{
+ HashTable *hash; /* The table to be returned */
+ int allocate_mem = !mem; /* True if mem should be internally allocated */
+ int i;
+/*
+ * Check arguments.
+ */
+ if(size <= 0) {
+ fprintf(stderr, "_new_HashTable: Illegal table size (%d).\n", size);
+ return NULL;
+ };
+/*
+ * Allocate an internal free-list?
+ */
+ if(allocate_mem) {
+ mem = _new_HashMemory(1, 100);
+ if(!mem)
+ return NULL;
+ };
+/*
+ * Allocate the container.
+ */
+ hash = (HashTable *) _new_FreeListNode(mem->hash_memory);
+ if(!hash) {
+ fprintf(stderr, "_new_HashTable: Insufficient memory.\n");
+ if(allocate_mem)
+ mem = _del_HashMemory(mem, 1);
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize
+ * the container at least up to the point at which it can safely
+ * be passed to _del_HashTable().
+ */
+ hash->errmsg[0] = '\0';
+ hash->mem = mem;
+ hash->internal_mem = allocate_mem;
+ hash->case_sensitive = hcase==HONOUR_CASE;
+ hash->size = size;
+ hash->bucket = NULL;
+ hash->keycmp = hash->case_sensitive ? _ht_strcmp : _ht_lower_strcmp;
+ hash->app_data = app_data;
+ hash->del_fn = del_fn;
+/*
+ * Allocate the array of 'size' hash buckets.
+ */
+ hash->bucket = (HashBucket *) malloc(sizeof(HashBucket) * size);
+ if(!hash->bucket) {
+ fprintf(stderr, "_new_HashTable: Insufficient memory for %d buckets.\n",
+ size);
+ return _del_HashTable(hash);
+ };
+/*
+ * Initialize the bucket array.
+ */
+ for(i=0; ibucket + i;
+ b->head = NULL;
+ b->count = 0;
+ };
+/*
+ * The table is ready for use - albeit currently empty.
+ */
+ return hash;
+}
+
+/*.......................................................................
+ * Delete a hash-table.
+ *
+ * Input:
+ * hash HashTable * The hash table to be deleted.
+ * Output:
+ * return HashTable * The deleted hash table (always NULL).
+ */
+HashTable *_del_HashTable(HashTable *hash)
+{
+ if(hash) {
+/*
+ * Clear and delete the bucket array.
+ */
+ if(hash->bucket) {
+ _clear_HashTable(hash);
+ free(hash->bucket);
+ hash->bucket = NULL;
+ };
+/*
+ * Delete application data.
+ */
+ if(hash->del_fn)
+ hash->del_fn(hash->app_data);
+/*
+ * If the hash table was allocated from an internal free-list, delete
+ * it and the hash table by deleting the free-list. Otherwise just
+ * return the hash-table to the external free-list.
+ */
+ if(hash->internal_mem)
+ _del_HashMemory(hash->mem, 1);
+ else
+ hash = (HashTable *) _del_FreeListNode(hash->mem->hash_memory, hash);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Create and install a new entry in a hash table. If an entry with the
+ * same name already exists, replace its contents with the new data.
+ *
+ * Input:
+ * hash HashTable * The hash table to insert the symbol into.
+ * name const char * The name to tag the entry with.
+ * code int An application-specific code to be stored in
+ * the entry.
+ * fn void (*)(void) An application-specific function to be stored
+ * in the entry.
+ * data void * An application-specific pointer to data to be
+ * associated with the entry, or NULL if not
+ * relevant.
+ * del_fn SYM_DEL_FN(*) An optional destructor function. When the
+ * symbol is deleted this function will be called
+ * with the 'code' and 'data' arguments given
+ * above. Any application data that was registered
+ * to the table via the app_data argument of
+ * _new_HashTable() will also be passed.
+ * Output:
+ * return HashNode * The new entry, or NULL if there was insufficient
+ * memory or the arguments were invalid.
+ */
+Symbol *_new_HashSymbol(HashTable *hash, const char *name, int code,
+ void (*fn)(void), void *data, SYM_DEL_FN(*del_fn))
+{
+ HashBucket *bucket; /* The hash-bucket associated with the name */
+ HashNode *node; /* The new node */
+/*
+ * Check arguments.
+ */
+ if(!hash || !name)
+ return NULL;
+/*
+ * Get the hash bucket of the specified name.
+ */
+ bucket = _find_HashBucket(hash, name);
+/*
+ * See if a node with the same name already exists.
+ */
+ node = _find_HashNode(hash, bucket, name, NULL);
+/*
+ * If found, delete its contents by calling the user-supplied
+ * destructor function, if provided.
+ */
+ if(node) {
+ if(node->symbol.data && node->symbol.del_fn) {
+ node->symbol.data = node->symbol.del_fn(hash->app_data, node->symbol.code,
+ node->symbol.data);
+ };
+/*
+ * Allocate a new node if necessary.
+ */
+ } else {
+ node = _new_HashNode(hash, name, code, fn, data, del_fn);
+ if(!node)
+ return NULL;
+ };
+/*
+ * Install the node at the head of the hash-bucket list.
+ */
+ node->next = bucket->head;
+ bucket->head = node;
+ bucket->count++;
+ return &node->symbol;
+}
+
+/*.......................................................................
+ * Remove and delete a given hash-table entry.
+ *
+ * Input:
+ * hash HashTable * The hash table to find the symbol in.
+ * name const char * The name of the entry.
+ * Output:
+ * return HashNode * The deleted hash node (always NULL).
+ */
+Symbol *_del_HashSymbol(HashTable *hash, const char *name)
+{
+ if(hash && name) {
+ HashBucket *bucket = _find_HashBucket(hash, name);
+ HashNode *prev; /* The node preceding the located node */
+ HashNode *node = _find_HashNode(hash, bucket, name, &prev);
+/*
+ * Node found?
+ */
+ if(node) {
+/*
+ * Remove the node from the bucket list.
+ */
+ if(prev) {
+ prev->next = node->next;
+ } else {
+ bucket->head = node->next;
+ };
+/*
+ * Record the loss of a node.
+ */
+ bucket->count--;
+/*
+ * Delete the node.
+ */
+ (void) _del_HashNode(hash, node);
+ };
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Look up a symbol in the hash table.
+ *
+ * Input:
+ * hash HashTable * The table to look up the string in.
+ * name const char * The name of the symbol to look up.
+ * Output:
+ * return Symbol * The located hash-table symbol, or NULL if not
+ * found.
+ */
+Symbol *_find_HashSymbol(HashTable *hash, const char *name)
+{
+ HashBucket *bucket; /* The hash-table bucket associated with name[] */
+ HashNode *node; /* The hash-table node of the requested symbol */
+/*
+ * Check arguments.
+ */
+ if(!hash)
+ return NULL;
+/*
+ * Nothing to lookup?
+ */
+ if(!name)
+ return NULL;
+/*
+ * Hash the name to a hash-table bucket.
+ */
+ bucket = _find_HashBucket(hash, name);
+/*
+ * Find the bucket entry that exactly matches the name.
+ */
+ node = _find_HashNode(hash, bucket, name, NULL);
+ if(!node)
+ return NULL;
+ return &node->symbol;
+}
+
+/*.......................................................................
+ * Private function used to allocate a hash-table node.
+ * The caller is responsible for checking that the specified symbol
+ * is unique and for installing the returned entry in the table.
+ *
+ * Input:
+ * hash HashTable * The table to allocate the node for.
+ * name const char * The name of the new entry.
+ * code int A user-supplied context code.
+ * fn void (*)(void) A user-supplied function pointer.
+ * data void * A user-supplied data pointer.
+ * del_fn SYM_DEL_FN(*) An optional 'data' destructor function.
+ * Output:
+ * return HashNode * The new node, or NULL on error.
+ */
+static HashNode *_new_HashNode(HashTable *hash, const char *name, int code,
+ void (*fn)(void), void *data, SYM_DEL_FN(*del_fn))
+{
+ HashNode *node; /* The new node */
+/*
+ * Allocate the new node from the free list.
+ */
+ node = (HashNode *) _new_FreeListNode(hash->mem->node_memory);
+ if(!node)
+ return NULL;
+/*
+ * Before attempting any operation that might fail, initialize the
+ * contents of 'node' at least up to the point at which it can be
+ * safely passed to _del_HashNode().
+ */
+ node->symbol.name = NULL;
+ node->symbol.code = code;
+ node->symbol.fn = fn;
+ node->symbol.data = data;
+ node->symbol.del_fn = del_fn;
+ node->next = NULL;
+/*
+ * Allocate a copy of 'name'.
+ */
+ node->symbol.name = _new_StringMemString(hash->mem->string_memory,
+ strlen(name) + 1);
+ if(!node->symbol.name)
+ return _del_HashNode(hash, node);
+/*
+ * If character-case is insignificant in the current table, convert the
+ * name to lower case while copying it.
+ */
+ if(hash->case_sensitive) {
+ strcpy(node->symbol.name, name);
+ } else {
+ const char *src = name;
+ char *dst = node->symbol.name;
+ for( ; *src; src++,dst++)
+ *dst = tolower(*src);
+ *dst = '\0';
+ };
+ return node;
+}
+
+/*.......................................................................
+ * Private function used to delete a hash-table node.
+ * The node must have been removed from its list before calling this
+ * function.
+ *
+ * Input:
+ * hash HashTable * The table for which the node was originally
+ * allocated.
+ * node HashNode * The node to be deleted.
+ * Output:
+ * return HashNode * The deleted node (always NULL).
+ */
+static HashNode *_del_HashNode(HashTable *hash, HashNode *node)
+{
+ if(node) {
+ node->symbol.name = _del_StringMemString(hash->mem->string_memory,
+ node->symbol.name);
+/*
+ * Call the user-supplied data-destructor if provided.
+ */
+ if(node->symbol.data && node->symbol.del_fn)
+ node->symbol.data = node->symbol.del_fn(hash->app_data,
+ node->symbol.code,
+ node->symbol.data);
+/*
+ * Return the node to the free-list.
+ */
+ node->next = NULL;
+ node = (HashNode *) _del_FreeListNode(hash->mem->node_memory, node);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Private function to locate the hash bucket associated with a given
+ * name.
+ *
+ * This uses a hash-function described in the dragon-book
+ * ("Compilers - Principles, Techniques and Tools", by Aho, Sethi and
+ * Ullman; pub. Adison Wesley) page 435.
+ *
+ * Input:
+ * hash HashTable * The table to look up the string in.
+ * name const char * The name of the symbol to look up.
+ * Output:
+ * return HashBucket * The located hash-bucket.
+ */
+static HashBucket *_find_HashBucket(HashTable *hash, const char *name)
+{
+ unsigned const char *kp;
+ unsigned long h = 0L;
+ if(hash->case_sensitive) {
+ for(kp=(unsigned const char *) name; *kp; kp++)
+ h = 65599UL * h + *kp; /* 65599 is a prime close to 2^16 */
+ } else {
+ for(kp=(unsigned const char *) name; *kp; kp++)
+ h = 65599UL * h + tolower((int)*kp); /* 65599 is a prime close to 2^16 */
+ };
+ return hash->bucket + (h % hash->size);
+}
+
+/*.......................................................................
+ * Search for a given name in the entries of a given bucket.
+ *
+ * Input:
+ * hash HashTable * The hash-table being searched.
+ * bucket HashBucket * The bucket to search (use _find_HashBucket()).
+ * name const char * The name to search for.
+ * Output:
+ * prev HashNode ** If prev!=NULL then the pointer to the node
+ * preceding the located node in the list will
+ * be recorded in *prev. This will be NULL either
+ * if the name is not found or the located node is
+ * at the head of the list of entries.
+ * return HashNode * The located hash-table node, or NULL if not
+ * found.
+ */
+static HashNode *_find_HashNode(HashTable *hash, HashBucket *bucket,
+ const char *name, HashNode **prev)
+{
+ HashNode *last; /* The previously searched node */
+ HashNode *node; /* The node that is being searched */
+/*
+ * Search the list for a node containing the specified name.
+ */
+ for(last=NULL, node=bucket->head;
+ node && hash->keycmp(node->symbol.name, name)!=0;
+ last = node, node=node->next)
+ ;
+ if(prev)
+ *prev = node ? last : NULL;
+ return node;
+}
+
+/*.......................................................................
+ * When hash->case_sensitive is zero this function is called
+ * in place of strcmp(). In such cases the hash-table names are stored
+ * as lower-case versions of the original strings so this function
+ * performs the comparison against lower-case copies of the characters
+ * of the string being compared.
+ *
+ * Input:
+ * node_key const char * The lower-case hash-node key being compared
+ * against.
+ * look_key const char * The lookup key.
+ * Output:
+ * return int <0 if node_key < look_key.
+ * 0 if node_key == look_key.
+ * >0 if node_key > look_key.
+ */
+static int _ht_lower_strcmp(const char *node_key, const char *look_key)
+{
+ int cn; /* The latest character from node_key[] */
+ int cl; /* The latest character from look_key[] */
+ do {
+ cn = *node_key++;
+ cl = *look_key++;
+ } while(cn && cn==tolower(cl));
+ return cn - tolower(cl);
+}
+
+/*.......................................................................
+ * This is a wrapper around strcmp for comparing hash-keys in a case
+ * sensitive manner. The reason for having this wrapper, instead of using
+ * strcmp() directly, is to make some C++ compilers happy. The problem
+ * is that when the library is compiled with a C++ compiler, the
+ * declaration of the comparison function is a C++ declaration, whereas
+ * strcmp() is a pure C function and thus although it appears to have the
+ * same declaration, the compiler disagrees.
+ *
+ * Input:
+ * node_key char * The lower-case hash-node key being compared against.
+ * look_key char * The lookup key.
+ * Output:
+ * return int <0 if node_key < look_key.
+ * 0 if node_key == look_key.
+ * >0 if node_key > look_key.
+ */
+static int _ht_strcmp(const char *node_key, const char *look_key)
+{
+ return strcmp(node_key, look_key);
+}
+
+/*.......................................................................
+ * Empty a hash-table by deleting all of its entries.
+ *
+ * Input:
+ * hash HashTable * The hash table to clear.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Invalid arguments.
+ */
+int _clear_HashTable(HashTable *hash)
+{
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(!hash)
+ return 1;
+/*
+ * Clear the contents of the bucket array.
+ */
+ for(i=0; isize; i++) {
+ HashBucket *bucket = hash->bucket + i;
+/*
+ * Delete the list of active hash nodes from the bucket.
+ */
+ HashNode *node = bucket->head;
+ while(node) {
+ HashNode *next = node->next;
+ (void) _del_HashNode(hash, node);
+ node = next;
+ };
+/*
+ * Mark the bucket as empty.
+ */
+ bucket->head = NULL;
+ bucket->count = 0;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Execute a given function on each entry of a hash table, returning
+ * before completion if the the specified function returns non-zero.
+ *
+ * Input:
+ * hash HashTable * The table to traverse.
+ * scan_fn HASH_SCAN_FN(*) The function to call.
+ * context void * Optional caller-specific context data
+ * to be passed to scan_fn().
+ * Output:
+ * return int 0 - OK.
+ * 1 - Either the arguments were invalid, or
+ * scan_fn() returned non-zero at some
+ * point.
+ */
+int _scan_HashTable(HashTable *hash, HASH_SCAN_FN(*scan_fn), void *context)
+{
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(!hash || !scan_fn)
+ return 1;
+/*
+ * Iterate through the buckets of the table.
+ */
+ for(i=0; isize; i++) {
+ HashBucket *bucket = hash->bucket + i;
+ HashNode *node;
+/*
+ * Iterate through the list of symbols that fall into bucket i,
+ * passing each one to the caller-specified function.
+ */
+ for(node=bucket->head; node; node=node->next) {
+ if(scan_fn(&node->symbol, context))
+ return 1;
+ };
+ };
+ return 0;
+}
diff --git a/libtecla-1.4.1/hash.h b/libtecla-1.4.1/hash.h
new file mode 100644
index 0000000..13c0a2b
--- /dev/null
+++ b/libtecla-1.4.1/hash.h
@@ -0,0 +1,157 @@
+#ifndef hash_h
+#define hash_h
+
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/*
+ * The following macro can be used to prototype or define a
+ * function that deletes the data of a symbol-table entry.
+ *
+ * Input:
+ * app_data void * The _new_HashTable() app_data argument.
+ * code int The Symbol::code argument.
+ * sym_data void * The Symbol::data argument to be deleted.
+ * Output:
+ * return void * The deleted data (always return NULL).
+ */
+#define SYM_DEL_FN(fn) void *(fn)(void *app_data, int code, void *sym_data)
+
+/*
+ * The following macro can be used to prototype or define a
+ * function that deletes the application-data of a hash-table.
+ *
+ * Input:
+ * data void * The _new_HashTable() 'app_data' argument to be
+ * deleted.
+ * Output:
+ * return void * The deleted data (always return NULL).
+ */
+#define HASH_DEL_FN(fn) void *(fn)(void *app_data)
+
+/*
+ * The following is a container for recording the context
+ * of a symbol in a manner that is independant of the particular
+ * symbol-table implementation. Each hash-table entry contains
+ * the following user supplied parameters:
+ *
+ * 1. An optional integral parameter 'code'. This is useful for
+ * enumerating a symbol or for describing what type of data
+ * or function is stored in the symbol.
+ *
+ * 2. An optional generic function pointer. This is useful for
+ * associating functions with names. The user is responsible
+ * for casting between the generic function type and the
+ * actual function type. The code field could be used to
+ * enumerate what type of function to cast to.
+ *
+ * 3. An optional generic pointer to a static or heap-allocated
+ * object. It is up to the user to cast this back to the
+ * appropriate object type. Again, the code field could be used
+ * to describe what type of object is stored there.
+ * If the object is dynamically allocated and should be discarded
+ * when the symbol is deleted from the symbol table, send a
+ * destructor function to have it deleted automatically.
+ */
+typedef struct {
+ char *name; /* The name of the symbol */
+ int code; /* Application supplied integral code */
+ void (*fn)(void); /* Application supplied generic function */
+ void *data; /* Application supplied context data */
+ SYM_DEL_FN(*del_fn); /* Data destructor function */
+} Symbol;
+
+/*
+ * HashNode's and HashTable's are small objects. Separately allocating
+ * many such objects would normally cause memory fragmentation. To
+ * counter this, HashMemory objects are used. These contain
+ * dedicated free-lists formed from large dynamically allocated arrays
+ * of objects. One HashMemory object can be shared between multiple hash
+ * tables (within a single thread).
+ */
+typedef struct HashMemory HashMemory;
+
+ /* Create a free-list for allocation of hash tables and their nodes */
+
+HashMemory *_new_HashMemory(int hash_count, int node_count);
+
+ /* Delete a redundant free-list if not being used */
+
+HashMemory *_del_HashMemory(HashMemory *mem, int force);
+
+/*
+ * Declare an alias for the private HashTable structure defined in
+ * hash.c.
+ */
+typedef struct HashTable HashTable;
+
+/*
+ * Enumerate case-sensitivity options.
+ */
+typedef enum {
+ IGNORE_CASE, /* Ignore case when looking up symbols */
+ HONOUR_CASE /* Honor case when looking up symbols */
+} HashCase;
+
+ /* Create a new hash-table */
+
+HashTable *_new_HashTable(HashMemory *mem, int size, HashCase hcase,
+ void *app_data, HASH_DEL_FN(*del_fn));
+
+ /* Delete a reference to a hash-table */
+
+HashTable *_del_HashTable(HashTable *hash);
+
+ /* Add an entry to a hash table */
+
+Symbol *_new_HashSymbol(HashTable *hash, const char *key, int code,
+ void (*fn)(void), void *data, SYM_DEL_FN(*del_fn));
+
+ /* Remove and delete all the entries in a given hash table */
+
+int _clear_HashTable(HashTable *hash);
+
+ /* Remove and delete a given hash-table entry */
+
+Symbol *_del_HashSymbol(HashTable *hash, const char *key);
+
+ /* Lookup a given hash-table entry */
+
+Symbol *_find_HashSymbol(HashTable *hash, const char *key);
+
+ /* Execute a given function on each entry of a hash table, returning */
+ /* before completion if the specified function returns non-zero. */
+
+#define HASH_SCAN_FN(fn) int (fn)(Symbol *sym, void *context)
+
+int _scan_HashTable(HashTable *hash, HASH_SCAN_FN(*scan_fn), void *context);
+
+#endif
diff --git a/libtecla-1.4.1/history.c b/libtecla-1.4.1/history.c
new file mode 100644
index 0000000..5a8d94f
--- /dev/null
+++ b/libtecla-1.4.1/history.c
@@ -0,0 +1,2003 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "history.h"
+#include "freelist.h"
+
+/*
+ * GlLineNode's record the location and length of historical lines in
+ * a buffer array.
+ */
+typedef struct GlLineNode GlLineNode;
+struct GlLineNode {
+ long id; /* The unique identifier of this history line */
+ time_t timestamp; /* The time at which the line was archived */
+ unsigned group; /* The identifier of the history group to which the */
+ /* the line belongs. */
+ GlLineNode *next; /* The next youngest line in the list */
+ GlLineNode *prev; /* The next oldest line in the list */
+ int start; /* The start index of the line in the buffer */
+ int nchar; /* The total length of the line, including the '\0' */
+};
+
+/*
+ * The number of GlLineNode elements per freelist block.
+ */
+#define LINE_NODE_BLK 100
+
+/*
+ * Lines are organised in the buffer from oldest to newest. The
+ * positions of the lines are recorded in a doubly linked list
+ * of GlLineNode objects.
+ */
+typedef struct {
+ FreeList *node_mem; /* A freelist of GlLineNode objects */
+ GlLineNode *head; /* The head of the list of lines */
+ GlLineNode *tail; /* The tail of the list of lines */
+} GlLineList;
+
+/*
+ * All elements of the history mechanism are recorded in an object of
+ * the following type.
+ */
+struct GlHistory {
+ char *buffer; /* A circular buffer used to record historical input */
+ /* lines. */
+ size_t buflen; /* The length of the buffer array */
+ GlLineList list; /* A list of the start of lines in buffer[] */
+ GlLineNode *recall; /* The last line recalled, or NULL if no recall */
+ /* session is currently active. */
+ GlLineNode *id_node;/* The node at which the last ID search terminated */
+ const char *prefix; /* A pointer to the line containing the prefix that */
+ /* is being searched for. */
+ int prefix_len; /* The length of the prefix */
+ unsigned long seq; /* The next ID to assign to a line node */
+ unsigned group; /* The identifier of the current history group */
+ int nline; /* The number of lines currently in the history list */
+ int max_lines; /* Either -1 or a ceiling on the number of lines */
+ int enable; /* If false, ignore history additions and lookups */
+};
+
+static char *_glh_restore_line(GlHistory *glh, char *line, size_t dim);
+static int _glh_cant_load_history(GlHistory *glh, const char *filename,
+ int lineno, const char *message, FILE *fp);
+static int _glh_write_timestamp(FILE *fp, time_t timestamp);
+static int _glh_decode_timestamp(char *string, char **endp, time_t *t);
+static void _glh_discard_node(GlHistory *glh, GlLineNode *node);
+static GlLineNode *_glh_find_id(GlHistory *glh, GlhLineID id);
+
+/*.......................................................................
+ * Create a line history maintenance object.
+ *
+ * Input:
+ * buflen size_t The number of bytes to allocate to the circular
+ * buffer that is used to record all of the
+ * most recent lines of user input that will fit.
+ * If buflen==0, no buffer will be allocated.
+ * Output:
+ * return GlHistory * The new object, or NULL on error.
+ */
+GlHistory *_new_GlHistory(size_t buflen)
+{
+ GlHistory *glh; /* The object to be returned */
+/*
+ * Allocate the container.
+ */
+ glh = (GlHistory *) malloc(sizeof(GlHistory));
+ if(!glh) {
+ fprintf(stderr, "_new_GlHistory: Insufficient memory.\n");
+ return NULL;
+ };
+/*
+ * Before attempting any operation that might fail, initialize the
+ * container at least up to the point at which it can safely be passed
+ * to _del_GlHistory().
+ */
+ glh->buffer = NULL;
+ glh->buflen = buflen;
+ glh->list.node_mem = NULL;
+ glh->list.head = NULL;
+ glh->list.tail = NULL;
+ glh->recall = NULL;
+ glh->id_node = NULL;
+ glh->prefix = NULL;
+ glh->prefix_len = 0;
+ glh->seq = 0;
+ glh->group = 0;
+ glh->nline = 0;
+ glh->max_lines = -1;
+ glh->enable = 1;
+/*
+ * Allocate the buffer, if required.
+ */
+ if(buflen > 0) {
+ glh->buffer = (char *) malloc(sizeof(char) * buflen);
+ if(!glh->buffer) {
+ fprintf(stderr, "_new_GlHistory: Insufficient memory.\n");
+ return _del_GlHistory(glh);
+ };
+ };
+/*
+ * Allocate the GlLineNode freelist.
+ */
+ glh->list.node_mem = _new_FreeList("_new_GlHistory", sizeof(GlLineNode),
+ LINE_NODE_BLK);
+ if(!glh->list.node_mem)
+ return _del_GlHistory(glh);
+ return glh;
+}
+
+/*.......................................................................
+ * Delete a GlHistory object.
+ *
+ * Input:
+ * glh GlHistory * The object to be deleted.
+ * Output:
+ * return GlHistory * The deleted object (always NULL).
+ */
+GlHistory *_del_GlHistory(GlHistory *glh)
+{
+ if(glh) {
+/*
+ * Delete the buffer.
+ */
+ if(glh->buffer) {
+ free(glh->buffer);
+ glh->buffer = NULL;
+ };
+/*
+ * Delete the freelist of GlLineNode's.
+ */
+ glh->list.node_mem = _del_FreeList("_del_GlHistory", glh->list.node_mem, 1);
+/*
+ * The contents of the list were deleted by deleting the freelist.
+ */
+ glh->list.head = NULL;
+ glh->list.tail = NULL;
+/*
+ * Delete the container.
+ */
+ free(glh);
+ };
+ return NULL;
+}
+
+/*.......................................................................
+ * Add a new line to the end of the history buffer, wrapping round to the
+ * start of the buffer if needed.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The line to be archived.
+ * force int Unless this flag is non-zero, empty lines and
+ * lines which match the previous line in the history
+ * buffer, aren't archived. This flag requests that
+ * the line be archived regardless.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_add_history(GlHistory *glh, const char *line, int force)
+{
+ GlLineList *list; /* The line location list */
+ int nchar; /* The number of characters needed to record the line */
+ GlLineNode *node; /* The new line location list node */
+ int empty; /* True if the string is empty */
+ const char *nlptr;/* A pointer to a newline character in line[] */
+ int i;
+/*
+ * Check the arguments.
+ */
+ if(!glh || !line)
+ return 1;
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return 0;
+/*
+ * Get the line location list.
+ */
+ list = &glh->list;
+/*
+ * Cancel any ongoing search.
+ */
+ if(_glh_cancel_search(glh))
+ return 1;
+/*
+ * See how much buffer space will be needed to record the line?
+ *
+ * If the string contains a terminating newline character, arrange to
+ * have the archived line NUL terminated at this point.
+ */
+ nlptr = strchr(line, '\n');
+ if(nlptr)
+ nchar = (nlptr - line) + 1;
+ else
+ nchar = strlen(line) + 1;
+/*
+ * If the line is too big to fit in the buffer, truncate it.
+ */
+ if(nchar > glh->buflen)
+ nchar = glh->buflen;
+/*
+ * Is the line empty?
+ */
+ empty = 1;
+ for(i=0; itail && strlen(glh->buffer + list->tail->start) == nchar-1 &&
+ strncmp(line, glh->buffer + list->tail->start, nchar-1)==0)
+ return 0;
+/*
+ * Allocate the list node that will record the line location.
+ */
+ node = (GlLineNode *) _new_FreeListNode(list->node_mem);
+ if(!node)
+ return 1;
+/*
+ * Is the buffer empty?
+ */
+ if(!list->head) {
+/*
+ * Place the line at the beginning of the buffer.
+ */
+ strncpy(glh->buffer, line, nchar);
+ glh->buffer[nchar-1] = '\0';
+/*
+ * Record the location of the line.
+ */
+ node->start = 0;
+/*
+ * The buffer has one or more lines in it.
+ */
+ } else {
+/*
+ * Place the start of the new line just after the most recently
+ * added line.
+ */
+ int start = list->tail->start + list->tail->nchar;
+/*
+ * If there is insufficient room between the end of the most
+ * recently added line and the end of the buffer, we place the
+ * line at the beginning of the buffer. To make as much space
+ * as possible for this line, we first delete any old lines
+ * at the end of the buffer, then shift the remaining contents
+ * of the buffer to the end of the buffer.
+ */
+ if(start + nchar >= glh->buflen) {
+ GlLineNode *last; /* The last line in the buffer */
+ GlLineNode *ln; /* A member of the list of line locations */
+ int shift; /* The shift needed to move the contents of the */
+ /* buffer to its end. */
+/*
+ * Delete any old lines between the most recent line and the end of the
+ * buffer.
+ */
+ while(list->head && list->head->start > list->tail->start)
+ _glh_discard_node(glh, list->head);
+/*
+ * Find the line that is nearest the end of the buffer.
+ */
+ last = NULL;
+ for(ln=list->head; ln; ln=ln->next) {
+ if(!last || ln->start > last->start)
+ last = ln;
+ };
+/*
+ * How big a shift is needed to move the existing contents of the
+ * buffer to the end of the buffer?
+ */
+ shift = last ? (glh->buflen - (last->start + last->nchar)) : 0;
+/*
+ * Is any shift needed?
+ */
+ if(shift > 0) {
+/*
+ * Move the buffer contents to the end of the buffer.
+ */
+ memmove(glh->buffer + shift, glh->buffer, glh->buflen - shift);
+/*
+ * Update the listed locations to reflect the shift.
+ */
+ for(ln=list->head; ln; ln=ln->next)
+ ln->start += shift;
+ };
+/*
+ * The new line should now be located at the start of the buffer.
+ */
+ start = 0;
+ };
+/*
+ * Make space for the new line at the beginning of the buffer by
+ * deleting the oldest lines. This just involves removing them
+ * from the list of used locations. Also enforce the current
+ * maximum number of lines.
+ */
+ while(list->head &&
+ ((list->head->start >= start && list->head->start - start < nchar) ||
+ (glh->max_lines >= 0 && glh->nline>=glh->max_lines))) {
+ _glh_discard_node(glh, list->head);
+ };
+/*
+ * Copy the new line into the buffer.
+ */
+ memcpy(glh->buffer + start, line, nchar);
+ glh->buffer[start + nchar - 1] = '\0';
+/*
+ * Record its location.
+ */
+ node->start = start;
+ };
+/*
+ * Append the line location node to the end of the list.
+ */
+ node->id = glh->seq++;
+ node->timestamp = time(NULL);
+ node->group = glh->group;
+ node->nchar = nchar;
+ node->next = NULL;
+ node->prev = list->tail;
+ if(list->tail)
+ list->tail->next = node;
+ else
+ list->head = node;
+ list->tail = node;
+ glh->nline++;
+ return 0;
+}
+
+/*.......................................................................
+ * Recall the next oldest line that has the search prefix last recorded
+ * by _glh_search_prefix().
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, if anything
+ * was found, its contents will have been replaced
+ * with the matching line.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * A pointer to line[0], or NULL if not found.
+ */
+char *_glh_find_backwards(GlHistory *glh, char *line, size_t dim)
+{
+ GlLineNode *node; /* The line location node being checked */
+ int first; /* True if this is the start of a new search */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !line) {
+ fprintf(stderr, "_glh_find_backwards: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return NULL;
+/*
+ * Check the line dimensions.
+ */
+ if(dim < strlen(line) + 1) {
+ fprintf(stderr,
+ "_glh_find_backwards: 'dim' inconsistent with strlen(line) contents.\n");
+ return NULL;
+ };
+/*
+ * Is this the start of a new search?
+ */
+ first = glh->recall==NULL;
+/*
+ * If this is the first search backwards, save the current line
+ * for potential recall later, and mark it as the last line
+ * recalled.
+ */
+ if(first) {
+ if(_glh_add_history(glh, line, 1))
+ return NULL;
+ glh->recall = glh->list.tail;
+ };
+/*
+ * If there is no search prefix, the prefix last set by glh_search_prefix()
+ * doesn't exist in the history buffer.
+ */
+ if(!glh->prefix)
+ return NULL;
+/*
+ * From where should we start the search?
+ */
+ if(glh->recall)
+ node = glh->recall->prev;
+ else
+ node = glh->list.tail;
+/*
+ * Search backwards through the list for the first match with the
+ * prefix string.
+ */
+ for( ; node &&
+ (node->group != glh->group ||
+ strncmp(glh->buffer + node->start, glh->prefix, glh->prefix_len) != 0);
+ node = node->prev)
+ ;
+/*
+ * Was a matching line found?
+ */
+ if(node) {
+/*
+ * Recall the found node as the starting point for subsequent
+ * searches.
+ */
+ glh->recall = node;
+/*
+ * Copy the matching line into the provided line buffer.
+ */
+ strncpy(line, glh->buffer + node->start, dim);
+ line[dim-1] = '\0';
+ return line;
+ };
+/*
+ * No match was found.
+ */
+ return NULL;
+}
+
+/*.......................................................................
+ * Recall the next newest line that has the search prefix last recorded
+ * by _glh_search_prefix().
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, if anything
+ * was found, its contents will have been replaced
+ * with the matching line.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * The line requested, or NULL if no matching line
+ * was found.
+ */
+char *_glh_find_forwards(GlHistory *glh, char *line, size_t dim)
+{
+ GlLineNode *node; /* The line location node being checked */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !line) {
+ fprintf(stderr, "_glh_find_forwards: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return NULL;
+/*
+ * Check the line dimensions.
+ */
+ if(dim < strlen(line) + 1) {
+ fprintf(stderr,
+ "_glh_find_forwards: 'dim' inconsistent with strlen(line) contents.\n");
+ return NULL;
+ };
+/*
+ * From where should we start the search?
+ */
+ if(glh->recall)
+ node = glh->recall->next;
+ else
+ return NULL;
+/*
+ * If there is no search prefix, the prefix last set by glh_search_prefix()
+ * doesn't exist in the history buffer.
+ */
+ if(!glh->prefix)
+ return NULL;
+/*
+ * Search forwards through the list for the first match with the
+ * prefix string.
+ */
+ for( ; node &&
+ (node->group != glh->group ||
+ strncmp(glh->buffer + node->start, glh->prefix, glh->prefix_len) != 0);
+ node = node->next)
+ ;
+/*
+ * Was a matching line found?
+ */
+ if(node) {
+/*
+ * Did we hit the line that was originally being edited when the
+ * current history traversal started?
+ */
+ if(node == glh->list.tail)
+ return _glh_restore_line(glh, line, dim);
+/*
+ * Copy the matching line into the provided line buffer.
+ */
+ strncpy(line, glh->buffer + node->start, dim);
+ line[dim-1] = '\0';
+/*
+ * Record the starting point of the next search.
+ */
+ glh->recall = node;
+/*
+ * Return the matching line to the user.
+ */
+ return line;
+ };
+/*
+ * No match was found.
+ */
+ return NULL;
+}
+
+/*.......................................................................
+ * If a search is in progress, cancel it.
+ *
+ * This involves discarding the line that was temporarily saved by
+ * _glh_find_backwards() when the search was originally started,
+ * and reseting the search iteration pointer to NULL.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_cancel_search(GlHistory *glh)
+{
+/*
+ * Check the arguments.
+ */
+ if(!glh) {
+ fprintf(stderr, "_glh_cancel_search: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * If there wasn't a search in progress, do nothing.
+ */
+ if(!glh->recall)
+ return 0;
+/*
+ * Delete the node of the preserved line.
+ */
+ _glh_discard_node(glh, glh->list.tail);
+/*
+ * Reset the search pointers.
+ */
+ glh->recall = NULL;
+ glh->prefix = "";
+ glh->prefix_len = 0;
+ return 0;
+}
+
+/*.......................................................................
+ * Set the prefix of subsequent history searches.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The command line who's prefix is to be used.
+ * prefix_len int The length of the prefix.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_search_prefix(GlHistory *glh, const char *line, int prefix_len)
+{
+ GlLineNode *node; /* The line location node being checked */
+/*
+ * Check the arguments.
+ */
+ if(!glh) {
+ fprintf(stderr, "_glh_search_prefix: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return 0;
+/*
+ * Record a zero length search prefix?
+ */
+ if(prefix_len <= 0) {
+ glh->prefix_len = 0;
+ glh->prefix = "";
+ return 0;
+ };
+/*
+ * Record the length of the new search prefix.
+ */
+ glh->prefix_len = prefix_len;
+/*
+ * If any history line starts with the specified prefix, record a
+ * pointer to it for comparison in subsequent searches. If the prefix
+ * doesn't match any of the lines, then simply record NULL to indicate
+ * that there is no point in searching. Note that _glh_add_history()
+ * clears this pointer by calling _glh_cancel_search(), so there is
+ * no danger of it being used after the buffer has been modified.
+ */
+ for(node = glh->list.tail ; node &&
+ (node->group != glh->group ||
+ strncmp(glh->buffer + node->start, line, prefix_len) != 0);
+ node = node->prev)
+ ;
+/*
+ * If a matching line was found record it for use as the search
+ * prefix.
+ */
+ glh->prefix = node ? glh->buffer + node->start : NULL;
+ return 0;
+}
+
+/*.......................................................................
+ * Recall the oldest recorded line.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, its contents
+ * will have been replaced with the oldest line.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * A pointer to line[0], or NULL if not found.
+ */
+char *_glh_oldest_line(GlHistory *glh, char *line, size_t dim)
+{
+ GlLineNode *node; /* The line location node being checked */
+ int first; /* True if this is the start of a new search */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !line) {
+ fprintf(stderr, "_glh_oldest_line: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return NULL;
+/*
+ * Check the line dimensions.
+ */
+ if(dim < strlen(line) + 1) {
+ fprintf(stderr,
+ "_glh_oldest_line: 'dim' inconsistent with strlen(line) contents.\n");
+ return NULL;
+ };
+/*
+ * Is this the start of a new search?
+ */
+ first = glh->recall==NULL;
+/*
+ * If this is the first search backwards, save the current line
+ * for potential recall later, and mark it as the last line
+ * recalled.
+ */
+ if(first) {
+ if(_glh_add_history(glh, line, 1))
+ return NULL;
+ glh->recall = glh->list.tail;
+ };
+/*
+ * Locate the oldest line that belongs to the current group.
+ */
+ for(node=glh->list.head; node && node->group != glh->group;
+ node = node->next)
+ ;
+/*
+ * No line found?
+ */
+ if(!node)
+ return NULL;
+/*
+ * Record the above node as the starting point for subsequent
+ * searches.
+ */
+ glh->recall = node;
+/*
+ * Copy the recalled line into the provided line buffer.
+ */
+ strncpy(line, glh->buffer + node->start, dim);
+ line[dim-1] = '\0';
+ return line;
+}
+
+/*.......................................................................
+ * Recall the line that was being entered when the search started.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, its contents
+ * will have been replaced with the line that was
+ * being entered when the search was started.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * A pointer to line[0], or NULL if not found.
+ */
+char *_glh_current_line(GlHistory *glh, char *line, size_t dim)
+{
+/*
+ * Check the arguments.
+ */
+ if(!glh || !line) {
+ fprintf(stderr, "_glh_current_line: NULL argument(s).\n");
+ return NULL;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return NULL;
+/*
+ * Check the line dimensions.
+ */
+ if(dim < strlen(line) + 1) {
+ fprintf(stderr,
+ "_glh_current_line: 'dim' inconsistent with strlen(line) contents.\n");
+ return NULL;
+ };
+/*
+ * Restore the original line.
+ */
+ return _glh_restore_line(glh, line, dim);
+}
+
+/*.......................................................................
+ * Remove the line that was originally being edited when the history
+ * traversal was started, from its saved position in the history list,
+ * and place it in the provided line buffer.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, its contents
+ * will have been replaced with the saved line.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * A pointer to line[0], or NULL if not found.
+ */
+static char *_glh_restore_line(GlHistory *glh, char *line, size_t dim)
+{
+ GlLineNode *tail; /* The tail node to be discarded */
+/*
+ * If there wasn't a search in progress, do nothing.
+ */
+ if(!glh->recall)
+ return NULL;
+/*
+ * Get the list node that is to be removed.
+ */
+ tail = glh->list.tail;
+/*
+ * If a pointer to the saved line is being used to record the
+ * current search prefix, reestablish the search prefix, to
+ * have it recorded by another history line if possible.
+ */
+ if(glh->prefix == glh->buffer + tail->start)
+ (void) _glh_search_prefix(glh, glh->buffer + tail->start, glh->prefix_len);
+/*
+ * Copy the recalled line into the input-line buffer.
+ */
+ strncpy(line, glh->buffer + tail->start, dim);
+ line[dim-1] = '\0';
+/*
+ * Discard the line-location node.
+ */
+ _glh_discard_node(glh, tail);
+/*
+ * Mark the search as ended.
+ */
+ glh->recall = NULL;
+ return line;
+}
+
+/*.......................................................................
+ * Query the id of a history line offset by a given number of lines from
+ * the one that is currently being recalled. If a recall session isn't
+ * in progress, or the offset points outside the history list, 0 is
+ * returned.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * offset int The line offset (0 for the current line, < 0
+ * for an older line, > 0 for a newer line.
+ * Output:
+ * return GlhLineID The identifier of the line that is currently
+ * being recalled, or 0 if no recall session is
+ * currently in progress.
+ */
+GlhLineID _glh_line_id(GlHistory *glh, int offset)
+{
+ GlLineNode *node; /* The line location node being checked */
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return 0;
+/*
+ * Search forward 'offset' lines to find the required line.
+ */
+ if(offset >= 0) {
+ for(node=glh->recall; node && offset != 0; node=node->next) {
+ if(node->group == glh->group)
+ offset--;
+ };
+ } else {
+ for(node=glh->recall; node && offset != 0; node=node->prev) {
+ if(node->group == glh->group)
+ offset++;
+ };
+ };
+ return node ? node->id : 0;
+}
+
+/*.......................................................................
+ * Recall a line by its history buffer ID. If the line is no longer
+ * in the buffer, or the id is zero, NULL is returned.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * id GlhLineID The ID of the line to be returned.
+ * line char * The input line buffer. On input this should contain
+ * the current input line, and on output, its contents
+ * will have been replaced with the saved line.
+ * dim size_t The allocated dimensions of the line buffer.
+ * Output:
+ * return char * A pointer to line[0], or NULL if not found.
+ */
+char *_glh_recall_line(GlHistory *glh, GlhLineID id, char *line, size_t dim)
+{
+ GlLineNode *node; /* The line location node being checked */
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->buffer || glh->max_lines == 0)
+ return NULL;
+/*
+ * If we are starting a new recall session, save the current line
+ * for potential recall later.
+ */
+ if(!glh->recall && _glh_add_history(glh, line, 1))
+ return NULL;
+/*
+ * Search for the specified line.
+ */
+ node = _glh_find_id(glh, id);
+/*
+ * Not found?
+ */
+ if(!node || node->group != glh->group)
+ return NULL;
+/*
+ * Record the node of the matching line as the starting point
+ * for subsequent searches.
+ */
+ glh->recall = node;
+/*
+ * Copy the recalled line into the provided line buffer.
+ */
+ strncpy(line, glh->buffer + node->start, dim);
+ line[dim-1] = '\0';
+ return line;
+}
+
+/*.......................................................................
+ * Save the current history in a specified file.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * filename const char * The name of the new file to record the
+ * history in.
+ * comment const char * Extra information such as timestamps will
+ * be recorded on a line started with this
+ * string, the idea being that the file can
+ * double as a command file. Specify "" if
+ * you don't care.
+ * max_lines int The maximum number of lines to save, or -1
+ * to save all of the lines in the history
+ * list.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_save_history(GlHistory *glh, const char *filename, const char *comment,
+ int max_lines)
+{
+ FILE *fp; /* The output file */
+ GlLineNode *node; /* The line being saved */
+ GlLineNode *head; /* The head of the list of lines to be saved */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !filename || !comment) {
+ fprintf(stderr, "_glh_save_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Attempt to open the specified file.
+ */
+ fp = fopen(filename, "w");
+ if(!fp) {
+ fprintf(stderr, "_glh_save_history: Can't open %s (%s).\n",
+ filename, strerror(errno));
+ return 1;
+ };
+/*
+ * If a ceiling on the number of lines to save was specified, count
+ * that number of lines backwards, to find the first line to be saved.
+ */
+ head = NULL;
+ if(max_lines >= 0) {
+ for(head=glh->list.tail; head && --max_lines > 0; head=head->prev)
+ ;
+ };
+ if(!head)
+ head = glh->list.head;
+/*
+ * Write the contents of the history buffer to the history file, writing
+ * associated data such as timestamps, to a line starting with the
+ * specified comment string.
+ */
+ for(node=head; node; node=node->next) {
+/*
+ * Write peripheral information associated with the line, as a comment.
+ */
+ if(fprintf(fp, "%s ", comment) < 0 ||
+ _glh_write_timestamp(fp, node->timestamp) ||
+ fprintf(fp, " %u\n", node->group) < 0) {
+ fprintf(stderr, "Error writing %s (%s).\n", filename, strerror(errno));
+ (void) fclose(fp);
+ return 1;
+ };
+/*
+ * Write the history line.
+ */
+ if(fprintf(fp, "%s\n", glh->buffer + node->start) < 0) {
+ fprintf(stderr, "Error writing %s (%s).\n", filename, strerror(errno));
+ (void) fclose(fp);
+ return 1;
+ };
+ };
+/*
+ * Close the history file.
+ */
+ if(fclose(fp) == EOF) {
+ fprintf(stderr, "Error writing %s (%s).\n", filename, strerror(errno));
+ return 1;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Restore previous history lines from a given file.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * filename const char * The name of the file to read from.
+ * comment const char * The same comment string that was passed to
+ * _glh_save_history() when this file was
+ * written.
+ * line char * A buffer into which lines can be read.
+ * dim size_t The allocated dimension of line[].
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_load_history(GlHistory *glh, const char *filename, const char *comment,
+ char *line, size_t dim)
+{
+ FILE *fp; /* The output file */
+ size_t comment_len; /* The length of the comment string */
+ time_t timestamp; /* The timestamp of the history line */
+ unsigned group; /* The identifier of the history group to which */
+ /* the line belongs. */
+ int lineno; /* The line number being read */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !filename || !comment || !line) {
+ fprintf(stderr, "_glh_load_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Measure the length of the comment string.
+ */
+ comment_len = strlen(comment);
+/*
+ * Clear the history list.
+ */
+ _glh_clear_history(glh, 1);
+/*
+ * Attempt to open the specified file. Don't treat it as an error
+ * if the file doesn't exist.
+ */
+ fp = fopen(filename, "r");
+ if(!fp)
+ return 0;
+/*
+ * Attempt to read each line and preceding peripheral info, and add these
+ * to the history list.
+ */
+ for(lineno=1; fgets(line, dim, fp) != NULL; lineno++) {
+ char *lptr; /* A pointer into the input line */
+/*
+ * Check that the line starts with the comment string.
+ */
+ if(strncmp(line, comment, comment_len) != 0) {
+ return _glh_cant_load_history(glh, filename, lineno,
+ "Corrupt history parameter line", fp);
+ };
+/*
+ * Skip spaces and tabs after the comment.
+ */
+ for(lptr=line+comment_len; *lptr && (*lptr==' ' || *lptr=='\t'); lptr++)
+ ;
+/*
+ * The next word must be a timestamp.
+ */
+ if(_glh_decode_timestamp(lptr, &lptr, ×tamp)) {
+ return _glh_cant_load_history(glh, filename, lineno,
+ "Corrupt timestamp", fp);
+ };
+/*
+ * Skip spaces and tabs.
+ */
+ while(*lptr==' ' || *lptr=='\t')
+ lptr++;
+/*
+ * The next word must be an unsigned integer group number.
+ */
+ group = (int) strtoul(lptr, &lptr, 10);
+ if(*lptr != ' ' && *lptr != '\n') {
+ return _glh_cant_load_history(glh, filename, lineno,
+ "Corrupt group id", fp);
+ };
+/*
+ * Skip spaces and tabs.
+ */
+ while(*lptr==' ' || *lptr=='\t')
+ lptr++;
+/*
+ * There shouldn't be anything left on the line.
+ */
+ if(*lptr != '\n') {
+ return _glh_cant_load_history(glh, filename, lineno,
+ "Corrupt parameter line", fp);
+ };
+/*
+ * Now read the history line itself.
+ */
+ lineno++;
+ if(fgets(line, dim, fp) == NULL)
+ return _glh_cant_load_history(glh, filename, lineno, "Read error", fp);
+/*
+ * Append the line to the history buffer.
+ */
+ if(_glh_add_history(glh, line, 1)) {
+ return _glh_cant_load_history(glh, filename, lineno,
+ "Insufficient memory to record line", fp);
+ };
+/*
+ * Record the group and timestamp information along with the line.
+ */
+ if(glh->list.tail) {
+ glh->list.tail->timestamp = timestamp;
+ glh->list.tail->group = group;
+ };
+ };
+/*
+ * Close the file.
+ */
+ (void) fclose(fp);
+ return 0;
+}
+
+/*.......................................................................
+ * This is a private error return function of _glh_load_history().
+ */
+static int _glh_cant_load_history(GlHistory *glh, const char *filename,
+ int lineno, const char *message, FILE *fp)
+{
+ fprintf(stderr, "%s:%d: %s.\n", filename, lineno, message);
+ (void) fclose(fp);
+ return 1;
+}
+
+/*.......................................................................
+ * Switch history groups.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * group unsigned The new group identifier. This will be recorded
+ * with subsequent history lines, and subsequent
+ * history searches will only return lines with
+ * this group identifier. This allows multiple
+ * separate history lists to exist within
+ * a single GlHistory object. Note that the
+ * default group identifier is 0.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_set_group(GlHistory *glh, unsigned group)
+{
+/*
+ * Check the arguments.
+ */
+ if(!glh) {
+ fprintf(stderr, "_glh_set_group: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Is the group being changed?
+ */
+ if(group != glh->group) {
+/*
+ * Cancel any ongoing search.
+ */
+ if(_glh_cancel_search(glh))
+ return 1;
+/*
+ * Record the new group.
+ */
+ glh->group = group;
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Query the current history group.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * Output:
+ * return unsigned The group identifier.
+ */
+int _glh_get_group(GlHistory *glh)
+{
+ return glh ? glh->group : 0;
+}
+
+/*.......................................................................
+ * Write a timestamp to a given stdio stream, in the format
+ * yyyymmddhhmmss
+ *
+ * Input:
+ * fp FILE * The stream to write to.
+ * timestamp time_t The timestamp to be written.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int _glh_write_timestamp(FILE *fp, time_t timestamp)
+{
+ struct tm *t; /* THe broken-down calendar time */
+/*
+ * Get the calendar components corresponding to the given timestamp.
+ */
+ if(timestamp < 0 || (t = localtime(×tamp)) == NULL) {
+ if(fprintf(fp, "?") < 0)
+ return 1;
+ return 0;
+ };
+/*
+ * Write the calendar time as yyyymmddhhmmss.
+ */
+ if(fprintf(fp, "%04d%02d%02d%02d%02d%02d", t->tm_year + 1900, t->tm_mon + 1,
+ t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec) < 0)
+ return 1;
+ return 0;
+}
+
+/*.......................................................................
+ * Read a timestamp from a string.
+ *
+ * Input:
+ * string char * The string to read from.
+ * Input/Output:
+ * endp char ** On output *endp will point to the next unprocessed
+ * character in string[].
+ * timestamp time_t * The timestamp will be assigned to *t.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+static int _glh_decode_timestamp(char *string, char **endp, time_t *timestamp)
+{
+ unsigned year,month,day,hour,min,sec; /* Calendar time components */
+ struct tm t;
+/*
+ * There are 14 characters in the date format yyyymmddhhmmss.
+ */
+ enum {TSLEN=14};
+ char timestr[TSLEN+1]; /* The timestamp part of the string */
+/*
+ * If the time wasn't available at the time that the line was recorded
+ * it will have been written as "?". Check for this before trying
+ * to read the timestamp.
+ */
+ if(string[0] == '\?') {
+ *endp = string+1;
+ *timestamp = -1;
+ return 0;
+ };
+/*
+ * The timestamp is expected to be written in the form yyyymmddhhmmss.
+ */
+ if(strlen(string) < TSLEN) {
+ *endp = string;
+ return 1;
+ };
+/*
+ * Copy the timestamp out of the string.
+ */
+ strncpy(timestr, string, TSLEN);
+ timestr[TSLEN] = '\0';
+/*
+ * Decode the timestamp.
+ */
+ if(sscanf(timestr, "%4u%2u%2u%2u%2u%2u", &year, &month, &day, &hour, &min,
+ &sec) != 6) {
+ *endp = string;
+ return 1;
+ };
+/*
+ * Advance the string pointer over the successfully read timestamp.
+ */
+ *endp = string + TSLEN;
+/*
+ * Copy the read values into a struct tm.
+ */
+ t.tm_sec = sec;
+ t.tm_min = min;
+ t.tm_hour = hour;
+ t.tm_mday = day;
+ t.tm_wday = 0;
+ t.tm_yday = 0;
+ t.tm_mon = month - 1;
+ t.tm_year = year - 1900;
+ t.tm_isdst = -1;
+/*
+ * Convert the contents of the struct tm to a time_t.
+ */
+ *timestamp = mktime(&t);
+ return 0;
+}
+
+/*.......................................................................
+ * Display the contents of the history list.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * fp FILE * The stdio stream to write to.
+ * fmt const char * A format string. This can contain arbitrary
+ * characters, which are written verbatim, plus
+ * any of the following format directives:
+ * %D - The date, like 2001-11-20
+ * %T - The time of day, like 23:59:59
+ * %N - The sequential entry number of the
+ * line in the history buffer.
+ * %G - The history group number of the line.
+ * %% - A literal % character.
+ * %H - The history line.
+ * all_groups int If true, display history lines from all
+ * history groups. Otherwise only display
+ * those of the current history group.
+ * max_lines int If max_lines is < 0, all available lines
+ * are displayed. Otherwise only the most
+ * recent max_lines lines will be displayed.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Error.
+ */
+int _glh_show_history(GlHistory *glh, FILE *fp, const char *fmt,
+ int all_groups, int max_lines)
+{
+ GlLineNode *node; /* The line being displayed */
+ GlLineNode *oldest; /* The oldest line to display */
+ enum {TSMAX=32}; /* The maximum length of the date and time string */
+ char buffer[TSMAX+1]; /* The buffer in which to write the date and time */
+ int idlen; /* The length of displayed ID strings */
+ unsigned grpmax; /* The maximum group number in the buffer */
+ int grplen; /* The number of characters needed to print grpmax */
+/*
+ * Check the arguments.
+ */
+ if(!glh || !fp || !fmt) {
+ fprintf(stderr, "_glh_show_history: NULL argument(s).\n");
+ return 1;
+ };
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->list.head)
+ return 0;
+/*
+ * Work out the length to display ID numbers, choosing the length of
+ * the biggest number in the buffer. Smaller numbers will be padded
+ * with leading zeroes if needed.
+ */
+ sprintf(buffer, "%lu", (unsigned long) glh->list.tail->id);
+ idlen = strlen(buffer);
+/*
+ * Find the largest group number.
+ */
+ grpmax = 0;
+ for(node=glh->list.head; node; node=node->next) {
+ if(node->group > grpmax)
+ grpmax = node->group;
+ };
+/*
+ * Find out how many characters are needed to display the group number.
+ */
+ sprintf(buffer, "%u", (unsigned) grpmax);
+ grplen = strlen(buffer);
+/*
+ * Find the node that follows the oldest line to be displayed.
+ */
+ if(max_lines < 0) {
+ oldest = glh->list.head;
+ } else if(max_lines==0) {
+ return 0;
+ } else {
+ for(oldest=glh->list.tail; oldest; oldest=oldest->prev) {
+ if((all_groups || oldest->group == glh->group) && --max_lines <= 0)
+ break;
+ };
+/*
+ * If the number of lines in the buffer doesn't exceed the specified
+ * maximum, start from the oldest line in the buffer.
+ */
+ if(!oldest)
+ oldest = glh->list.head;
+ };
+/*
+ * List the history lines in increasing time order.
+ */
+ for(node=oldest; node; node=node->next) {
+/*
+ * Only display lines from the current history group, unless
+ * told otherwise.
+ */
+ if(all_groups || node->group == glh->group) {
+ const char *fptr; /* A pointer into the format string */
+ struct tm *t = NULL; /* The broken time version of the timestamp */
+/*
+ * Work out the calendar representation of the node timestamp.
+ */
+ if(node->timestamp != (time_t) -1)
+ t = localtime(&node->timestamp);
+/*
+ * Parse the format string.
+ */
+ fptr = fmt;
+ while(*fptr) {
+/*
+ * Search for the start of the next format directive or the end of the string.
+ */
+ const char *start = fptr;
+ while(*fptr && *fptr != '%')
+ fptr++;
+/*
+ * Display any literal characters that precede the located directive.
+ */
+ if(fptr > start && fprintf(fp, "%.*s", (int) (fptr - start), start) < 0)
+ return 1;
+/*
+ * Did we hit a new directive before the end of the line?
+ */
+ if(*fptr) {
+/*
+ * Obey the directive. Ignore unknown directives.
+ */
+ switch(*++fptr) {
+ case 'D': /* Display the date */
+ if(t && strftime(buffer, TSMAX, "%Y-%m-%d", t) != 0 &&
+ fprintf(fp, "%s", buffer) < 0)
+ return 1;
+ break;
+ case 'T': /* Display the time of day */
+ if(t && strftime(buffer, TSMAX, "%H:%M:%S", t) != 0 &&
+ fprintf(fp, "%s", buffer) < 0)
+ return 1;
+ break;
+ case 'N': /* Display the sequential entry number */
+ if(fprintf(fp, "%*lu", idlen, (unsigned long) node->id) < 0)
+ return 1;
+ break;
+ case 'G':
+ if(fprintf(fp, "%*u", grplen, (unsigned) node->group) < 0)
+ return 1;
+ break;
+ case 'H': /* Display the history line */
+ if(fprintf(fp, "%s", glh->buffer + node->start) < 0)
+ return 1;
+ break;
+ case '%': /* A literal % symbol */
+ if(fputc('%', fp) == EOF)
+ return 1;
+ break;
+ };
+/*
+ * Skip the directive.
+ */
+ if(*fptr)
+ fptr++;
+ };
+ };
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Change the size of the history buffer.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * bufsize size_t The number of bytes in the history buffer, or 0
+ * to delete the buffer completely.
+ * Output:
+ * return int 0 - OK.
+ * 1 - Insufficient memory (the previous buffer
+ * will have been retained). No error message
+ * will be displayed.
+ */
+int _glh_resize_history(GlHistory *glh, size_t bufsize)
+{
+ GlLineNode *node; /* A line location node in the list of lines */
+ GlLineNode *prev; /* The line location node preceding 'node' */
+/*
+ * Check the arguments.
+ */
+ if(!glh)
+ return bufsize > 0;
+/*
+ * If the new size doesn't differ from the existing size, do nothing.
+ */
+ if(glh->buflen == bufsize)
+ return 0;
+/*
+ * Cancel any ongoing search.
+ */
+ (void) _glh_cancel_search(glh);
+/*
+ * Create a wholly new buffer?
+ */
+ if(glh->buflen == 0) {
+ glh->buffer = (char *) malloc(bufsize);
+ if(!glh->buffer)
+ return 1;
+ glh->buflen = bufsize;
+/*
+ * Delete an existing buffer?
+ */
+ } else if(bufsize == 0) {
+ _glh_clear_history(glh, 1);
+ free(glh->buffer);
+ glh->buffer = NULL;
+ glh->buflen = 0;
+/*
+ * To get here, we must be shrinking or expanding from one
+ * finite size to another.
+ */
+ } else {
+/*
+ * If we are shrinking the size of the buffer, then we first need
+ * to discard the oldest lines that won't fit in the new buffer.
+ */
+ if(bufsize < glh->buflen) {
+ size_t nbytes = 0; /* The number of bytes used in the new buffer */
+ GlLineNode *oldest; /* The oldest node to be kept */
+/*
+ * Searching backwards from the youngest line, find the oldest
+ * line for which there will be sufficient room in the new buffer.
+ */
+ for(oldest = glh->list.tail;
+ oldest && (nbytes += oldest->nchar) <= bufsize;
+ oldest = oldest->prev)
+ ;
+/*
+ * We will have gone one node too far, unless we reached the oldest line
+ * without exceeding the target length.
+ */
+ if(oldest) {
+ nbytes -= oldest->nchar;
+ oldest = oldest->next;
+ };
+/*
+ * Discard the nodes that can't be retained.
+ */
+ while(glh->list.head && glh->list.head != oldest)
+ _glh_discard_node(glh, glh->list.head);
+/*
+ * If we are increasing the size of the buffer, we need to reallocate
+ * the buffer before shifting the lines into their new positions.
+ */
+ } else {
+ char *new_buffer = (char *) realloc(glh->buffer, bufsize);
+ if(!new_buffer)
+ return 1;
+ glh->buffer = new_buffer;
+ glh->buflen = bufsize;
+ };
+/*
+ * If there are any lines to be preserved, copy the block of lines
+ * that precedes the end of the existing buffer to what will be
+ * the end of the new buffer.
+ */
+ if(glh->list.head) {
+ int shift; /* The number of bytes to shift lines in the buffer */
+/*
+ * Get the oldest line to be kept.
+ */
+ GlLineNode *oldest = glh->list.head;
+/*
+ * Count the number of characters that are used in the lines that
+ * precede the end of the current buffer (ie. not including those
+ * lines that have been wrapped to the start of the buffer).
+ */
+ int n = 0;
+ for(node=oldest,prev=oldest->prev; node && node->start >= oldest->start;
+ prev=node, node=node->next)
+ n += node->nchar;
+/*
+ * Move these bytes to the end of the resized buffer.
+ */
+ memmove(glh->buffer + bufsize - n, glh->buffer + oldest->start, n);
+/*
+ * Adjust the buffer pointers to reflect the new locations of the moved
+ * lines.
+ */
+ shift = bufsize - n - oldest->start;
+ for(node=prev; node && node->start >= oldest->start; node=node->prev)
+ node->start += shift;
+ };
+/*
+ * Shrink the buffer?
+ */
+ if(bufsize < glh->buflen) {
+ char *new_buffer = (char *) realloc(glh->buffer, bufsize);
+ if(new_buffer)
+ glh->buffer = new_buffer;
+ glh->buflen = bufsize; /* Mark it as shrunk, regardless of success */
+ };
+ };
+ return 0;
+}
+
+/*.......................................................................
+ * Set an upper limit to the number of lines that can be recorded in the
+ * history list, or remove a previously specified limit.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * max_lines int The maximum number of lines to allow, or -1 to
+ * cancel a previous limit and allow as many lines
+ * as will fit in the current history buffer size.
+ */
+void _glh_limit_history(GlHistory *glh, int max_lines)
+{
+ if(!glh)
+ return;
+/*
+ * Apply a new limit?
+ */
+ if(max_lines >= 0 && max_lines != glh->max_lines) {
+/*
+ * Count successively older lines until we reach the start of the
+ * list, or until we have seen max_lines lines (at which point 'node'
+ * will be line number max_lines+1).
+ */
+ int nline = 0;
+ GlLineNode *node;
+ for(node=glh->list.tail; node && ++nline <= max_lines; node=node->prev)
+ ;
+/*
+ * Discard any lines that exceed the limit.
+ */
+ if(node) {
+ GlLineNode *oldest = node->next; /* The oldest line to be kept */
+/*
+ * Delete nodes from the head of the list until we reach the node that
+ * is to be kept.
+ */
+ while(glh->list.head && glh->list.head != oldest)
+ _glh_discard_node(glh, glh->list.head);
+ };
+ };
+/*
+ * Record the new limit.
+ */
+ glh->max_lines = max_lines;
+ return;
+}
+
+/*.......................................................................
+ * Discard either all history, or the history associated with the current
+ * history group.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * all_groups int If true, clear all of the history. If false,
+ * clear only the stored lines associated with the
+ * currently selected history group.
+ */
+void _glh_clear_history(GlHistory *glh, int all_groups)
+{
+/*
+ * Check the arguments.
+ */
+ if(!glh)
+ return;
+/*
+ * Cancel any ongoing search.
+ */
+ (void) _glh_cancel_search(glh);
+/*
+ * Delete all history lines regardless of group?
+ */
+ if(all_groups) {
+ _rst_FreeList(glh->list.node_mem);
+ glh->list.head = glh->list.tail = NULL;
+ glh->nline = 0;
+ glh->id_node = NULL;
+/*
+ * Just delete lines of the current group?
+ */
+ } else {
+ GlLineNode *node; /* The line node being checked */
+ GlLineNode *prev; /* The line node that precedes 'node' */
+ GlLineNode *next; /* The line node that follows 'node' */
+/*
+ * Search out and delete the line nodes of the current group.
+ */
+ for(node=glh->list.head; node; node=next) {
+/*
+ * Keep a record of the following node before we delete the current
+ * node.
+ */
+ next = node->next;
+/*
+ * Discard this node?
+ */
+ if(node->group == glh->group)
+ _glh_discard_node(glh, node);
+ };
+/*
+ * If there are any lines left, and we deleted any lines, there will
+ * be gaps in the buffer. These need to be removed.
+ */
+ if(glh->list.head) {
+ int epos; /* The index of the last used element in the buffer */
+/*
+ * Find the line nearest the end of the buffer.
+ */
+ GlLineNode *enode;
+ for(node=glh->list.head, prev=NULL;
+ node && node->start >= glh->list.head->start;
+ prev=node, node = node->next)
+ ;
+ enode = prev;
+/*
+ * Move the end line to abutt the end of the buffer, and remove gaps
+ * between the lines that precede it.
+ */
+ epos = glh->buflen;
+ for(node=enode; node; node=node->prev) {
+ int shift = epos - (node->start + node->nchar);
+ if(shift) {
+ memmove(glh->buffer + node->start + shift,
+ glh->buffer + node->start, node->nchar);
+ node->start += shift;
+ };
+ epos = node->start;
+ };
+/*
+ * Move the first line in the buffer to the start of the buffer, and
+ * remove gaps between the lines that follow it.
+ */
+ epos = 0;
+ for(node=enode ? enode->next : NULL; node; node=node->next) {
+ int shift = epos - node->start;
+ if(shift) {
+ memmove(glh->buffer + node->start + shift,
+ glh->buffer + node->start, node->nchar);
+ node->start += shift;
+ };
+ epos = node->start + node->nchar;
+ };
+ };
+ };
+ return;
+}
+
+/*.......................................................................
+ * Temporarily enable or disable the history list.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * enable int If true, turn on the history mechanism. If
+ * false, disable it.
+ */
+void _glh_toggle_history(GlHistory *glh, int enable)
+{
+ if(glh)
+ glh->enable = enable;
+}
+
+/*.......................................................................
+ * Remove a given line location node from the history list, and return
+ * it to the freelist.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * node GlLineNode * The node to be removed. This must be currently
+ * in the list who's head is glh->list.head, or
+ * be NULL.
+ */
+static void _glh_discard_node(GlHistory *glh, GlLineNode *node)
+{
+ if(node) {
+/*
+ * Make the node that precedes the node being removed point
+ * to the one that follows it.
+ */
+ if(node->prev)
+ node->prev->next = node->next;
+ else
+ glh->list.head = node->next;
+/*
+ * Make the node that follows the node being removed point
+ * to the one that precedes it.
+ */
+ if(node->next)
+ node->next->prev = node->prev;
+ else
+ glh->list.tail = node->prev;
+/*
+ * If we are deleting the node that is marked as the start point of the
+ * last ID search, remove the cached starting point.
+ */
+ if(node == glh->id_node)
+ glh->id_node = NULL;
+/*
+ * Return the node to the free list.
+ */
+ node = (GlLineNode *) _del_FreeListNode(glh->list.node_mem, node);
+/*
+ * Decrement the count of the number of lines in the buffer.
+ */
+ glh->nline--;
+ };
+}
+
+/*.......................................................................
+ * Lookup the details of a given history line, given its id.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * id GlLineID The sequential number of the line.
+ * Input/Output:
+ * line const char ** A pointer to the history line will be assigned
+ * to *line.
+ * group unsigned * The group membership of the line will be assigned
+ * to *group.
+ * timestamp time_t * The timestamp of the line will be assigned to
+ * *timestamp.
+ * Output:
+ * return int 0 - The requested line wasn't found.
+ * 1 - The line was found.
+ */
+int _glh_lookup_history(GlHistory *glh, GlhLineID id, const char **line,
+ unsigned *group, time_t *timestamp)
+{
+ GlLineNode *node; /* The located line location node */
+/*
+ * Check the arguments.
+ */
+ if(!glh)
+ return 0;
+/*
+ * Search for the line that has the specified ID.
+ */
+ node = _glh_find_id(glh, (GlhLineID) id);
+/*
+ * Not found?
+ */
+ if(!node)
+ return 0;
+/*
+ * Return the details of the line.
+ */
+ if(line)
+ *line = glh->buffer + node->start;
+ if(group)
+ *group = node->group;
+ if(timestamp)
+ *timestamp = node->timestamp;
+ return 1;
+}
+
+/*.......................................................................
+ * Lookup a node in the history list by its ID.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * id GlhLineID The ID of the line to be returned.
+ * Output:
+ * return GlLIneNode * The located node, or NULL if not found.
+ */
+static GlLineNode *_glh_find_id(GlHistory *glh, GlhLineID id)
+{
+ GlLineNode *node; /* The node being checked */
+/*
+ * Is history enabled?
+ */
+ if(!glh->enable || !glh->list.head)
+ return NULL;
+/*
+ * If possible, start at the end point of the last ID search.
+ * Otherwise start from the head of the list.
+ */
+ node = glh->id_node;
+ if(!node)
+ node = glh->list.head;
+/*
+ * Search forwards from 'node'?
+ */
+ if(node->id < id) {
+ while(node && node->id != id)
+ node = node->next;
+ glh->id_node = node ? node : glh->list.tail;
+/*
+ * Search backwards from 'node'?
+ */
+ } else {
+ while(node && node->id != id)
+ node = node->prev;
+ glh->id_node = node ? node : glh->list.head;
+ };
+/*
+ * Return the located node (this will be NULL if the ID wasn't found).
+ */
+ return node;
+}
+
+/*.......................................................................
+ * Query the state of the history list. Note that any of the input/output
+ * pointers can be specified as NULL.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * Input/Output:
+ * enabled int * If history is enabled, *enabled will be
+ * set to 1. Otherwise it will be assigned 0.
+ * group unsigned * The current history group ID will be assigned
+ * to *group.
+ * max_lines int * The currently requested limit on the number
+ * of history lines in the list, or -1 if
+ * unlimited.
+ */
+void _glh_state_of_history(GlHistory *glh, int *enabled, unsigned *group,
+ int *max_lines)
+{
+ if(glh) {
+ if(enabled)
+ *enabled = glh->enable;
+ if(group)
+ *group = glh->group;
+ if(max_lines)
+ *max_lines = glh->max_lines;
+ };
+}
+
+/*.......................................................................
+ * Get the range of lines in the history buffer.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * Input/Output:
+ * oldest unsigned long * The sequential entry number of the oldest
+ * line in the history list will be assigned
+ * to *oldest, unless there are no lines, in
+ * which case 0 will be assigned.
+ * newest unsigned long * The sequential entry number of the newest
+ * line in the history list will be assigned
+ * to *newest, unless there are no lines, in
+ * which case 0 will be assigned.
+ * nlines int * The number of lines currently in the history
+ * list.
+ */
+void _glh_range_of_history(GlHistory *glh, unsigned long *oldest,
+ unsigned long *newest, int *nlines)
+{
+ if(glh) {
+ if(oldest)
+ *oldest = glh->list.head ? glh->list.head->id : 0;
+ if(newest)
+ *newest = glh->list.tail ? glh->list.tail->id : 0;
+ if(nlines)
+ *nlines = glh->nline;
+ };
+}
+
+/*.......................................................................
+ * Return the size of the history buffer and the amount of the
+ * buffer that is currently in use.
+ *
+ * Input:
+ * glh GlHistory * The input-line history maintenance object.
+ * Input/Output:
+ * buff_size size_t * The size of the history buffer (bytes).
+ * buff_used size_t * The amount of the history buffer that
+ * is currently occupied (bytes).
+ */
+void _glh_size_of_history(GlHistory *glh, size_t *buff_size, size_t *buff_used)
+{
+ if(glh) {
+ if(buff_size)
+ *buff_size = glh->buflen;
+/*
+ * Determine the amount of buffer space that is currently occupied.
+ */
+ if(buff_used) {
+ size_t used = 0;
+ GlLineNode *node;
+ for(node=glh->list.head; node; node=node->next)
+ used += node->nchar;
+ *buff_used = used;
+ };
+ };
+}
diff --git a/libtecla-1.4.1/history.h b/libtecla-1.4.1/history.h
new file mode 100644
index 0000000..49671a4
--- /dev/null
+++ b/libtecla-1.4.1/history.h
@@ -0,0 +1,159 @@
+#ifndef history_h
+#define history_h
+
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include /* FILE * */
+
+/*-----------------------------------------------------------------------
+ * This module is used to record and traverse historical lines of user input.
+ */
+
+typedef struct GlHistory GlHistory;
+
+/*
+ * Create a new history maintenance object.
+ */
+GlHistory *_new_GlHistory(size_t buflen);
+
+/*
+ * Delete a history maintenance object.
+ */
+GlHistory *_del_GlHistory(GlHistory *glh);
+
+int _glh_add_history(GlHistory *glh, const char *line, int force);
+
+int _glh_search_prefix(GlHistory *glh, const char *line, int prefix_len);
+
+char *_glh_find_backwards(GlHistory *glh, char *line, size_t dim);
+char *_glh_find_forwards(GlHistory *glh, char *line, size_t dim);
+
+int _glh_cancel_search(GlHistory *glh);
+
+char *_glh_oldest_line(GlHistory *glh, char *line, size_t dim);
+char *_glh_current_line(GlHistory *glh, char *line, size_t dim);
+
+/*
+ * Whenever a new line is added to the history buffer, it is given
+ * a unique ID, recorded in an object of the following type.
+ */
+typedef unsigned long GlhLineID;
+
+/*
+ * Query the id of a history line offset by a given number of lines from
+ * the one that is currently being recalled. If a recall session isn't
+ * in progress, or the offset points outside the history list, 0 is
+ * returned.
+ */
+GlhLineID _glh_line_id(GlHistory *glh, int offset);
+
+/*
+ * Recall a line by its history buffer ID. If the line is no longer
+ * in the buffer, or the specified id is zero, NULL is returned.
+ */
+char *_glh_recall_line(GlHistory *glh, GlhLineID id, char *line, size_t dim);
+
+/*
+ * Write the contents of the history buffer to a given file. Note that
+ * ~ and $ expansion are not performed on the filename.
+ */
+int _glh_save_history(GlHistory *glh, const char *filename,
+ const char *comment, int max_lines);
+
+/*
+ * Restore the contents of the history buffer from a given file.
+ * Note that ~ and $ expansion are not performed on the filename.
+ */
+int _glh_load_history(GlHistory *glh, const char *filename, const char *comment,
+ char *line, size_t dim);
+
+/*
+ * Set and query the current history group.
+ */
+int _glh_set_group(GlHistory *glh, unsigned group);
+int _glh_get_group(GlHistory *glh);
+
+/*
+ * Display the contents of the history list to the specified stdio
+ * output group.
+ */
+int _glh_show_history(GlHistory *glh, FILE *fp, const char *fmt,
+ int all_groups, int max_lines);
+
+/*
+ * Change the size of the history buffer.
+ */
+int _glh_resize_history(GlHistory *glh, size_t bufsize);
+
+/*
+ * Set an upper limit to the number of lines that can be recorded in the
+ * history list, or remove a previously specified limit.
+ */
+void _glh_limit_history(GlHistory *glh, int max_lines);
+
+/*
+ * Discard either all history, or the history associated with the current
+ * history group.
+ */
+void _glh_clear_history(GlHistory *glh, int all_groups);
+
+/*
+ * Temporarily enable or disable the history facility.
+ */
+void _glh_toggle_history(GlHistory *glh, int enable);
+
+/*
+ * Lookup a history line by its sequential number of entry in the
+ * history buffer.
+ */
+int _glh_lookup_history(GlHistory *glh, GlhLineID id, const char **line,
+ unsigned *group, time_t *timestamp);
+
+/*
+ * Query the state of the history list.
+ */
+void _glh_state_of_history(GlHistory *glh, int *enabled, unsigned *group,
+ int *max_lines);
+
+/*
+ * Get the range of lines in the history buffer.
+ */
+void _glh_range_of_history(GlHistory *glh, unsigned long *oldest,
+ unsigned long *newest, int *nlines);
+
+/*
+ * Return the size of the history buffer and the amount of the
+ * buffer that is currently in use.
+ */
+void _glh_size_of_history(GlHistory *glh, size_t *buff_size, size_t *buff_used);
+
+#endif
diff --git a/libtecla-1.4.1/homedir.c b/libtecla-1.4.1/homedir.c
new file mode 100644
index 0000000..f2029b7
--- /dev/null
+++ b/libtecla-1.4.1/homedir.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2000, 2001 by Martin C. Shepherd.
+ *
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#include