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. 09/11/2014 mcs@astro.caltech.edu configure.in configure Dominyk Tiller reported that libtecla didn't compile on Mac OS X, due to libgcc.a being cited in the makefile without any path. This turned out to be because Gnu autoconf claims that the clang compiler is gcc, and clang has a -print-libgcc-file-name, but this only prints libgcc.a. I have modified the configure script to check whether the path returned by -print-libgcc-file-name actually exists and only use it if it does. 27/10/2014 Jon Szymaniak (documented here by mcs@astro.caltech.edu) Makefile.rules Use $(AR) instead of plain ar, so that cross-compilation uses the correct ar program when cross-compiling. Add $(TARGETS) dependency to building the demo programs and the enhance program. When using parallel compilation this is needed to ensure that the library is compiled before the demos. 10/04/2013 mcs@astro.caltech.edu Makefile.in Jonathan Niehof reported that libtecla wouldn't compile if there were spaces in LDFLAGS and pointed out that there should be quotes around $(LDFLAGS) in Makefile.in. This also applied to a few other variables cited in the same way. 10/06/2012 mcs@astro.caltech.edu enhance.c configure.in I had incorrectly assumed that system-V pseudo-terminal allocation and system-V streams terminals always went together. However system-V pseudo terminal allocation is now part of UNIX98, and this has been adopted into many BSD style operating systems, without the use of system-V streams. On such systems the lack of system-V streams IOCTL opcodes prevented system-V pseudo-terminal allocation being used. This was hidden under Linux until recently, because it had a stropts.h file, which made it appear as though Linux supported system-V streams terminals. I have now created separate configuration tests and options in the configure script for system-V terminal allocation and system-V streams. On systems that only have the former, the latter won't be used. 16/05/2005 mcs@astro.caltech.edu getline.c When an initial input line was presented to gl_get_line() for editing, the new input line was incorrectly appended to the previous input line, instead of replacing it. 10/01/2004 Derek Jones (documented here by mcs@astro.caltech.edu) getline.c Derek discovered that the function that computes the width of the prompt, was not correctly skipping over 3 of the 6 possible prompt-formatting directives. Thus, when the %f,%p or %v prompt-formatting directives were used, the width of the prompt was incorrectly calculated. The fix was to copy the list of directives from gl_display_prompt(). I have also added a comment to gl_display_prompt(), to warn anybody who adds or removes formatting directives there, to also do the same to gl_displayed_prompt_width(). 31/10/2004 mcs@astro.caltech.edu (problem reported by Godfrey van der Linden) getline.c The gl_event_handler() function had the endif of a conditional compilation clause in the wrong place. This only upset the compiler on unusual systems that don't have select(). The problem was seen under Mac OS X, due to the configuration problem in 1.6.0 that caused the configure script to mistakenly report that select wasn't available. 31/10/2004 mcs@astro.caltech.edu (info provided by Ivan Rayner) configure.in configure Makefile.in Ivan reported that under IRIX 6.5 it is necessary to add -D_XOPEN_SOURCE=500 to the compiler flags, when compiling the reentrant version of the library. Thus, whereas previously I hardwired the value of DEFINES_R in Makefile.in, I have now made this a variable in the configure script, which is augmented with the above addition, within an IRIX-specific switch clause. Also apparently configure leaves the RANLIB variable blank, instead of setting it to ":", so I have now explicitly set this to ":", within the new IRIX clause of the configure script. 31/10/2004 mcs@astro.caltech.edu (info provided by Ivan Rayner) getline.c Under IRIX, the compiler warned that gl_read_unmasked() was returning an int, which was then being assigned to an enumeration type. This is techically fine, but it highlighted the fact that I had meant to declare gl_read_unmasked() to directly return the enumerated type. I have now done so. 26/09/2004 mcs@astro.caltech.edu getline.c Users can now turn off interactive command-line editing by setting the TERM environment variable to the word "dumb". 18/07/2004 mcs@astro.caltech.edu (problem noted by Michael MacFaden) getline.c Calling gl_terminal_size() on a system without support for SIGWINCH caused a divide-by-zero error in an unintended call to gl_erase_line(), because gl_update_size() was incorrectly being called to query the terminal size, instead of gl_query_size(). 18/07/2004 Padraig Brady (documented here by mcs@astro.caltech.edu) getline.c The suspend and termination signal-handlers installed by gl_tty_signals(), were being installed swapped. 03/06/2004 Mike Meaney (documented here by mcs@astro.caltech.edu) getline.c Mike pointed out the fact that the curses setupterm() function is actually documented to exit the application if an error occurs while its optional errret argument is NULL. I hadn't noticed this, and because I didn't need the extra information returned in the errret argument, I was passing it a NULL. As suggested by Mike, I now pass this argument a pointer to a dummy errret variable. 23/05/2004 mcs@astro.caltech.edu (problem noted by John Beck) man/func/cpl_complete_word.in Some of the prototypes of functions and types documented by the cpl_complete_word man page, weren't listed in the Synopsis section of this man page. They are now listed there. 23/05/2004 mcs@astro.caltech.edu getline.c man/func/gl_get_line.in I have now added support for calling gl_normal_io() from any callback functions that the application installs by calling either gl_inactivity_timeout(), or gl_watch_fd(). Previously, if one of these callback functions called gl_normal_io(), then after returning to gl_get_line(), gl_get_line() would incorrectly assume that the terminal was still in raw I/O mode. Now, gl_get_line() checks to see if gl_normal_io() was called by the callback, and if so, calls _gl_raw_io() to reinstate raw I/O mode. 21/05/2004 mcs@astro.caltech.edu configure.in configure On Mac OS X the code that the configure script used to check for select() failed due to missing symbols in sys/select.h. Moving the inclusion of sys/select.h to after the inclusion of sys/time.h, sys/types.h and sys/unistd.h fixed this. 11/05/2004 mcs@astro.caltech.edu getline.c man/func/gl_get_line.in If the line buffer returned by one call to gl_get_line() was passed as the start_line argument of the next call to gl_get_line(), then instead of the just-entered line being presented back to the user for further editing, the start_line argument was effectively ignored, because the line buffer whose pointer was being passed back, was being cleared before the start_line pointer was examined. This appears to have been a case of me incorrectly thinking that I had forgotten to initialize gl->line[] and gl->ntotal in the gl_reset_input_line() function, and then "fixing" this supposed omission. Removing this erroneous fix, restored things to how they were meant to be. To make it unlikely that I will make the same mistake again, I have renamed the function from gl_reset_input_line() to gl_reset_editor(), to stop it looking as though it is meant to reset the contents of the input line (that is what gl_truncate_buffer() is for), explicitly stated that it doesn't clear the input line, in the header comments of the function, and added a prominent warning comment in the body of the function. Also, since support for passing back the returned line pointer via the start_line argument of the next call to gl_get_line(), wasn't documented in the man page, but was meant to be supported, and definitely used to work, I have now amended the man page documentation of gl_get_line() to explicitly state that this feature is officially supported. 2?/04/2004 Released 1.6.0 22/04/2004 mcs@astro.caltech.edu (Fixed a bug reported by John Beck) getline.c When an error, signal, or other abnormal event aborted gl_get_line(), the cleanup code that restored the terminal to a sane state, also overwrote the value of errno that was associated with the aborting event. An I/O error occurring in the cleanup code would have also overwritten the value to be returned by gl_return_status(), and thus remove any possibility of the caller finding out what really caused gl_get_line() to abort. I have now written a new internal function called, gl_record_status(), which records the completion status to be returned by gl_return_status(), and the value to assign to errno just before gl_get_line() returns. This is called wherever code detects conditions that require gl_get_line() to return early. The function ensures that once an abnormal completion status has been recorded for return, subsequent completions statuses aren't recorded. This ensures that the caller sees the original cause of the abnormal return, rather than any error that occurs during cleaning up from this before return. 17/04/2004 mcs@astro.caltech.edu getline.c If an application's callback called gl_read_char() after calling gl_normal_io(), it would inappropriately redisplay the input line, when it called _gl_raw_io() to temporarily switch the terminal back into raw mode. To fix this, _gl_raw_io() now takes a new 'redisplay' argument, which specifies whether or not to queue a redisplay of the input line. I also created a new gl->postpone flag, which is set by gl_normal_io(), and cleared by _gl_raw_io() (when its redisplay argument is true). When this flag is set, gl_flush_output() ignores queued redisplays, as it generally should between calls to gl_normal_io() and gl_raw_io(). Thus its effect is to postpone redisplays while line editing is suspended. 11/04/2004 mcs@astro.caltech.edu history.c man/misc/tecla.in History searches can now include the globbing operators *, ?, []. When a search prefix is found to have at least one of these characters, then only history lines that completely match that pattern are returned. 11/04/2004 mcs@astro.caltech.edu (issue raised by Mark Coiley) getline.c ioutil.c There appears to be a bug in Solaris's terminal I/O. When the terminal file descriptor is placed in non-blocking I/O mode, and the terminal is switched from canonical to raw mode, characters that were previously entered in canonical I/O mode don't become available to be read until the user types one character more. Select() incorrectly says that there are no characters available, and read() returns EAGAIN. This is only a problem for gl_get_line() when gl_get_line() is in non-blocking server I/O mode, so most users won't have experienced any problems with this. The only way that I have found to get read() to return the characters, without the user first having to type another character, is to turn off non-blocking I/O before calling read(). Select() still claims that there are no characters available to be read, but read happily returns them anyway. Fortunately, one can perform non-blocking terminal reads without setting the non-blocking I/O flag of the file descriptor, simply by setting the VTIME terminal attribute to zero (which I already was doing). Thus, when in non-blocking server I/O, I now turn off the non-blocking I/O flag, attempt to read one character and only if this fails, do I then call the select() based event handler to implement any configured non-zero timeout, before attempting the read again. Of course the non-blocking I/O flag is still needed for writing, so I only turn it off temporarily while reading. 25/03/2004 mcs@astro.caltech.edu (bug reported by Gregory Harris) Makefile.in It appears that when in February, I patched Makefile.in to add abolute paths to the install-sh shell-script, I accidentally replaced install-sh with install.sh. I corrected the name in the Makefile. 25/03/2004 Gregory Harris (documented here by mcs) configure.in configure Greg added the configuration parameters needed to build the shared version of the libtecla library under FreeBSD. 25/03/2004 mcs@astro.caltech.edu getline.c libtecla.h libtecla.map man/func/gl_get_line.in man/func/gl_read_char.in I wrote a public function called gl_read_char(). Unlike gl_query_char(), this function neither prompts the user for input, nor displays the character that was entered. In fact it doesn't write anything to the terminal, and takes pains not to disturb any incompletely entered input line, and can safely be called from application callback functions. 21/03/2004 mcs@astro.caltech.edu getline.c libtecla.h libtecla.map man/func/gl_get_line.in man/func/gl_query_char.in I wrote a public function called gl_query_char(), which prompts the user and awaits a single-character reply, without the user having to hit return. 23/02/2004 mcs@astro.caltech.edu (bug reported by Gregory Harris) configure.in configure getline.c enhance.c demo3.c The configure script now checks for the sys/select.h header file, and arranges for a C macro called HAVE_SYS_SELECT_H to be set if it exists. Thus the files that use select() now use this macro to conditionally include sys/select.h where available. Apparently this header is required under FreeBSD 5.1. 23/02/2004 mcs@astro.caltech.edu getline.c libtecla.h man/func/gl_get_line.in I wrote two new public functions, gl_append_history() and gl_automatic_history(). Together these allow the application to take over the responsibility of adding lines to the history list from gl_get_line(). I then documented their functionality in the gl_get_line man page. Version 1.6.0 I incremented the minor version number of the library, to comply with the requirement to do so when additions are made to the public interface. See libtecla.map for details. libtecla.map I added a new 1.6.0 group for the new minor version, and added the above pair of functions to it. 15/02/2004 mcs@astro.caltech.edu (fixes a bug reported by Satya Sahoo) history.c Calling gl_load_history() multiple times, eventually led to a segmentation fault. This was due to the head of the list of unused history string segments not getting reset when the history buffer was cleared. While debugging this problem I also noticed that the history resizing function was way too complicated to verify, so after fixing the above bug, I heavily simplified the history resizing function, trading off a small reduction in memory efficiency, for greatly improved clarity, and thus made it much more verifiable and maintainable. 14/02/2004 mcs@astro.caltech.edu (fixes a bug reported by Tim Burress). getline.c If gl_change_terminal() was first used to tell gl_get_line to read input from a file, then called later to tell it to read subsequent input from a terminal, no prompt would be displayed for the first line of interactive input. The problem was that on reaching the end of the input file, gl_get_line() should have called gl_abandon_line(), to tell the next call to gl_get_line() to start inputting a new line from scratch. I have added this now. 14/02/2004 Krister Walfridsson (documented here by mcs@astro.caltech.edu) Makefile.in Krister noticed that I had failed to put $(srcdir)/ in front of some invokations of install.sh. I have remedied this. config.guess config.sub I hadn't updated these for a long time, so apparently they didn't recognise the BSD system that Krister was using. I have now updated them to the versions that come with autoconf-2.59. 22/01/2004 mcs@astro.caltech.edu keytab.c When parsing key-binding specifications, backslash escaped characters following ^ characters were not being expanded. Thus ^\\ got interpretted as a control-\ character followed by a \ character, rather than simply as a control-\ character. 12/01/2004 mcs@astro.caltech.edu cplfile.c cplmatch.c demo2.c demo3.c demo.c direader.c expand.c getline.c history.c homedir.c pathutil.c pcache.c configure.in configure INSTALL The configuration script now takes a "--without-file-system" argument. This is primarily for intended for embedded systems that either don't have filesystems, or where the file-system code in libtecla is unwanted bloat. It sets the WITHOUT_FILE_SYSTEM macro. This removes all code related to filesystem access, including the entire public file-expansion, file-completion and path-lookup facilities. Note that the general word completion facility is still included, but without the normally bundled file completion callback. Actually the callback is still there, but it reports no completions, regardless of what string you ask it to complete. This option is described in the INSTALL document. 12/01/2004 mcs@astro.caltech.edu getline.c configure.in configure INSTALL The configuration script now takes a "--without-file-actions" argument. This allows an application author/installer to prevent users of gl_get_line() from accessing the filesystem from the builtin actions of gl_get_line(). It defines a macro called HIDE_FILE_SYSTEM. This causes the "expand-filename", "read-from-file", "read-init-files", and "list-glob" action functions to be completely removed. It also changes the default behavior of actions such as "complete-word" and "list-or-eof" to show no completions, instead of the normal default of showing filename completions. This option is described in the INSTALL document. 11/01/2004 mcs@astro.caltech.edu getline.c man/func/gl_get_line.in In case an application's customized completion handler needs to write to the terminal for some unforseen reason, there needs to be a way for the it to cleanly suspend raw line editing, before writing to the terminal, and the caller then needs to be aware that it may need to resurrect the input line when the callback returns. I have now arranged that the completion callback functions can call the gl_normal_io() function for this purpose, and documented this in the gl_get_line() man page. 11/01/2004 mcs@astro.caltech.edu (In response to a bug report by Satya Sahoo) getline.c The gl_configure_getline() function makes a malloc'd copy of the names of the configuration files that it is asked to read. Before the bug fix, if the application made one or more calls to this function, the memory allocated by the final call that it made before calling del_GetLine(), wasn't being freed. Note that memory allocated in all but the final call was being correctly freed, so the maximum extent of the memory leak was the length of the file name(s) passed in the final call to gl_configure_getline(), and an application that didn't call gl_configure_getline() didn't suffer any leak. 20/12/2003 mcs@astro.caltech.edu history.c Ellen tested the history fix that I reported below, and pointed out that it still had a problem. This turned out to be because getline.c was making some incorrect assumptions about the new behavior of history.c. This problem and the previous one both revolved around how search prefixes were stored and discarded, so I have now re-written this part of the code. Previously the search prefix was retained by looking for a line with that prefix, and keeping a pointer to that line. This saved memory, compared to storing a separate copy of the prefix, but it led to all kinds of hairy interdependencies, so I have now changed the code to keep a separate copy of search prefixes. To keep the memory requirements constant, the search prefix is stored in the history buffer, like normal history lines, but not referenced by the time-ordered history list. The prefix can now be kept around indefinitely, until a new search prefix is specified, regardless of changes to the archived lines in the history buffer. This is actually necessary to make the vi-mode re-search actions work correctly. In particular, I no longer discard the search prefix whenever a history search session ends. Also, rather than have getline.c keep its own record of when a history session is in progress, it now consults history.c, so that failed assumptions can't cause the kind of discrepancy that occurred before. For this to work, getline.c now explicitly tells history.c to cancel search sessions whenever it executes any non-history action. 14/12/2003 mcs@astro.caltech.edu (bug reported by Ellen Oschmann) history.c If one searched backwards for a prefix, then returned to the original line, changed that line, then started another backwards prefix search, getline incorrectly discarded the new search prefix in the process of throwing away its cached copy of the previous pre-search input line. In other words getline was belatedly cancelling a previous search, after a new search had already partially begun, and thus messed up the new search. The obvious fix was to arrange for the current search to be cancelled whenever the history pointer returns to its starting point, rather than waiting for the next search to begin from there. 14/12/2003 mcs@astro.caltech.edu history.c _glh_recall_line() was returning the last line in the history buffer instead of the line requested by the caller. This only affected the obscure "repeat-history" action-function, which probably isn't used by anybody. 09/12/2003 Version 1.5.0 released. 28/09/2003 mcs@astro.caltech.edu homedir.c When the home directory of the login user is requested, see if the HOME environment variable exists, and if so return its value, rather than looking up the user's home directory in the password file. This seems to be the convention adopted by other unix programs that perform tilde expansion, and it works around a strange problem, where a third-party libtecla program, statically compiled under an old version of RedHat, unexpectedly complained that getpwd() returned an error when the program was run under RedHat 9. 01/09/2003 mcs@astro.caltech.edu getline.c libtecla.h libtecla.map man/func/gl_get_line.in man/func/gl_register_action.in. It is now possible for an application to register external functions as action functions. These actions are initially bound to specified key-sequences, but if they are registered before the user's configuration file is loaded, they can also be re-bound by the user to different key-sequences. The function used to register a new action, is called gl_register_action(). Action functions are passed a readonly copy of the input line and the cursor position. They can display text to the terminal, or perform other operations on the application environment. Currently, they can't edit the input line or move the cursor. This will require the future addition of functions to queue the invokation of the built-in action functions. 26/08/2003 mcs@astro.caltech.edu getline.c I modified gl_update_buffer() to ensure that the cursor stays within the input line after external line modifications, and to queue a redisplay of the potentially modified input line. 21/07/2003 mcs@astro.caltech.edu configure.in configure Makefile.in Makefile.stub INSTALL By specifying --without-man-pages or --with-man-pages=no as command-line arguments to the configure script, it is now possible to have the configure script skip the man-page preprocessing step, and arrange for the man-page installation targets in the Makefile to do nothing. This option is designed for people who embed libtecla within other packages. It is also used by Makefile.stub when the distclean target is specified. 21/07/2003 mcs@astro.caltech.edu configure.in configure The previous workaround for recent versions of gcc placing /usr/local/include at the start of the system inlcude-file search path, broke something else. The fix placed /usr/include before gcc's include area, which meant that gcc's modified version of stdarg.h was being ignored in deference to the version in /usr/include. I have changed the fix to have gcc report the search path, then have awk add options to CFLAGS to reorder this path, plaing /usr/local/include at the end. Also, under Solaris 9, including term.h without first including curses.h results in complaints about undefined symbols, such as bool. As a result the configure script's test for term.h was failing. I have now modified it to include curses.h in the test code that it uses to check for term.h. In the process I also improved the tests for curses.h and term.h to prevent an ncurses version of term.h from being used with the system-default version of curses.h. 29/06/2003 mcs@astro.caltech.edu Makefile.in direader.c homedir.c On some systems (eg. linux) the _POSIX_C_SOURCE feature-test macro is set by system headers, rather than being an option set by a project's Makefile at compilation time. In software, such as tecla, where the definition of this macro is used as an indication of whether to use the non-reentrant or reentrant versions of system functions, this means that the reentrant functions are always used, regardless of whether this macro is set or not by the project Makefile. Thus, on such systems the reentrant and non-reentrant versions of the tecla library are essentially identical. This has a couple of drawbacks. First, since thread-safe functions for traversing the password file don't exist, the supposedly non-reentrant version of the tecla library can't support ambiguous tab-completion of usernames in ~username/ constructions. Secondly, on some systems the use of reentrant system functions dictates the use of a shared library that isn't needed for the non-reentrant functions, thus making it more difficult to distribute binary versions of the library. To remedy this situation I have modified the DEFINES_R variable in Makefile.in to arrange for the compiler to define a C macro called PREFER_REENTRANT when it is compiling the reentrant version of the tecla library. This macro is now used in the source code to determine when to require reentrant code. Whithin the source code, wherever a potentially non-reentrant interface is used, the existance of both this macro and a suitably valued _POSIX_C_SOURCE macro, are tested for to see if a reentrant alternative to the problem code should be used. 22/06/2003 mcs@astro.caltech.edu getline.c I changed the way that redisplays are requested and performed. Redisplays are now queued by calling gl_queue_redisplay(), and subsequently performed by gl_flush_output(), when the queue of already pending output has been completely dispatched. This was necessary to prevent event handlers from filling up the output queue with redisplays, and it also simplifies a number of things. In the process I removed the gl_queue_display() function. I also wrote a gl_line_erased() function, which is now called by all functions that erase the input line. I also split the gl_abandon_line() function into public and private callable parts, and used the private version internally to arrange to discard the input line after errors. The raw_mode flag was not being initialized by new_GetLine(). It is now initialized to zero. I removed the zapline flag, since using the endline flag to communicate the desire to terminate the line, did the same thing. gl_terminal_move_cursor() now does nothing when the input line isn't displayed. 18/03/2003 mcs@astro.caltech.edu getline.c Fixed bug which was causing newlines not to be output at the end of each newly entered line. I was interpreting the gl->endline flag in conflicting ways in two places. To fix this I have created a gl->displayed flag. This flags whether an input line is currently displayed. 17/03/2003 mcs@astro.caltech.edu getline.c libtecla.h man/func/gl_get_line.in man/func/gl_erase_terminal.in libtecla.map I added a new function that programs can call to clear the terminal between calls to gl_get_line(). 11/03/2003 mcs@astro.caltech.edu configure.in configure Under linux when _POSIX_C_SOURCE is defined, getpwent() and associated functions become undefined, because _SVID_SOURCE and _BSD_SOURCE become undefined. Adding these feature macros back to CFLAGS resolves this. 06/03/2003 mcs@astro.caltech.edu getline.c libtecla.map man/func/gl_get_line.in Following the lead of Edward Chien, I wrote a function called gl_bind_keyseq(), which binds a specified key-sequence to a given action, or unbinds the key-sequence. 24/02/2003 mcs@astro.caltech.edu getline.c libtecla.map man/func/cpl_complete_word.in I implemented a simple function called cpl_recall_matches(). This recalls the return value of the last call to cpl_complete_word(). 19/01/2003 mcs@astro.caltech.edu getline.c The documented signal handling, fd event-handling, inactivity timeout handling, and server-mode non-blocking I/O features are now implemented for non-interactive input streams, such as pipes and files. 19/01/2003 mcs@astro.caltech.edu getline.c libtecla.h man/func/gl_get_line.in demo3.c I added a new return status enumerator to report when an end-of-file condition causes gl_get_line() to return NULL. 13/01/2003 mcs@astro.caltech.edu history.c I rewrote the history facility. The previous circular buffer implementation was a nightmare to change, and it couldn't efficiently support certain newly requested features. The new implementation stores history lines in linked lists of fixed sized string segments, taken from the buffer, with each line being reference counted and recorded in a hash table. If the user enters a line multiple times, only one copy of the line is now stored. Not only does this make better use of the available buffer space, but it also makes it easy to ensure that a line whose prefix matches the current search prefix, isn't returned more than once in sequence, since we can simply see if the latest search result has the same hash-table pointer as the previous one, rather than having to compare strings. Another plus is that due to the use of linked lists of nodes of fixed size line segments, there is no longer any need to continually shuffle the contents of the buffer in order to defragment it. As far as the user is concerned, the visible differences are as follows: 1. If the user enters a given line multiple times in a row, each one will be recorded in the history list, and will thus be listed by gl_show_history(), and saved in the history file. Previously only one line was recorded when consecutive duplicates were entered. This was a kludge to prevent history recall from recalling the same line multiple times in a row. This only achieved the desired result when not recalling by prefix. 2. Not only simple recall, but prefix-based history line recalls now don't return the same line multiple times in a row. As mentioned in (1) above, previously this only worked when performing a simple recall, without a search prefix. 28/12/2002 mcs@astro.caltech.edu getline.c The one-line function, gl_buff_curpos_to_term_curpos() was only being used by gl_place_cursor(), so I inlined it in that function, and removed it. 28/12/2002 mcs@astro.caltech.edu getline.c gl_suspend_process() was calling the application-level gl_normal_io() and gl_raw_io() functions, where it should have been calling the internal versions _gl_normal_io() and _gl_raw_io(). Also gl_handle_signal() was masking and unmasking just the signals of the first element of the gl[] array argument. It now masks and unmasks all trappable signals. 28/12/2002 mcs@astro.caltech.edu getline.c Now that the number of terminal characters used to display the current input line, is recorded, the relative line on which the last character of the input line resides can be determined without having to call gl_buff_curpos_to_term_curpos(). This is now used by gl_normal_io() via gl_start_newline(), so there is now no need for gl_buff_curpos_to_term_curpos() to be async-signal safe. I have thus removed the annoying gl->cwidth[] array, and gl_buff_curpos_to_term_curpos() now calls gl_width_of_char() directly again. There is also now no need for the gl_line_of_char_start() and gl_line_of_char_end() functions, so I have removed them. 28/12/2002 mcs@astro.caltech.edu getline.c Unfortunately it turns out that the terminfo/termcap control sequence which is defined to delete everything from the current position to the end of the terminal, is only defined to work when at the start of a terminal line. In gnome terminals in RedHat 8.0, if it is used within a terminal line, it erases the whole terminal line, rather than just what follows the cursor. Thus to portably truncate the displayed input line it is necessary to first use the control sequence which deletes from the cursor position to the end of the line, then if there are more terminal lines, move to the start of the next line, and use the delete to end-of-terminal control sequence, then restore the cursor position. This requires that one know how many physical terminal lines are used by the current input line, so I now keep a record of the number of characters so far displayed to the terminal following the start of the prompt, and the new gl_truncate_display() function uses this information to truncate the displayed input line from the current cursor position. 28/12/2002 mcs@astro.caltech.edu getline.c gl_start_newline() now moves to an empty line following the input line, rather than just to the next line. It also arranges for the input line to be redisplayed before editing resumes. A major user of this is gl_print_info(), which now need not be followed by an explicit call to gl_redisplay(), since the terminal input loop in gl_get_input_line() ensures that gl_redisplay() is called after any action function that asserts gl->redisplay. Also, all functions that erase the displayed input line can now call the gl_erase_line() function, which is designed to work correctly even when a terminal resize invalidates the horizontal cursor position. Finally, the new gl_queue_display() function is now used by functions that need to arrange for the input line to be displayed from scratch after the displayed line has been erased or invalidated by other text being written to the terminal. All of these changes are aimed at reducing the number of places that directly modify gl->term_curpos and gl->redisplay. 22/12/2002 Markus Gyger (logged here by mcs) Makefile.in update_html In places where echo and sed were being used to extract the base names of files, Markus substituted the basename command. He also replaced explicit cp and chmod commands with invokations of the install-sh script. configure.in Use $target_os and $target_cpu, where appropriate, instead of $target. configure.in The Solaris man function and library man pages should be in sections 3lib and 3tecla respectively, only in Solaris version 2.8 and above. configure.in Markus provided values for the man page configuration variables for HPUX. man/*/*.in I had missed parameterizing man page section numbers in the man page titles, Markus corrected this. man/func/libtecla_version.in Fixed incorrect section number in the link to the libtecla man page. homedir.c When compiled to be reentrant, although one can't use the non-reentrant getpwent() function to scan the password file for username completions, one can at least see if the prefix being completed is a valid username, and if the username of the current user minimally matches the prefix, and if so list them. I simplified Markus' modification by adding a prefix argument to the _hd_scan_user_home_dirs() function, and redefining the function description accordingly, such that now it reports only those password file entries who's usernames minimally match the specified prefix. Without this, it would have been necessary to peak inside the private data argument passed in by cf_complete_username(). Markus also provided code which under Solaris uses the non-reentrant interfaces if the reentrant version of the library isn't linked with the threads library. 19/12/2002 mcs@astro.caltech.edu Makefile.in Markus pointed out that LDFLAGS was being picked up by the configure script, but not then being interpolated into te Makefile. I have thus added the necessary assignment to Makefile.in and arranged for the value of LDFLAGS to be passed on to recursive make's. I also did the same for CPPFLAGS, which had also been omitted. 18/12/2002 mcs@astro.caltech.edu man/* man/*/* configure.in configure Makefile.in update_html It turns out that the assignment of man page sections to topics differs somewhat from system to system, so this is another thing that needs to be configured by the main configuration script, rather than being hardwired. All man pages have now been moved into suitably named topic-specific sub-directories of the top-level man directory, and instead of having a numeric suffix, now have the .in suffix, since they are now preprocessed by the configure script, in the same fashion as Makefile.in. Whithin these *.in versions of the man pages, and within Makefile.in, the installation subdirectory (eg. man1) and the file-name suffix (eg. 1), are written using configuration macros, so that they get expanded to the appropriate tokens when the configure script is run. In principle, the man pages could also take advantage of other configuration macros, such as the one which expands to the library installation directory, to include full path names to installed files in the documentation, so in the future this feature could have more uses than just that of parameterizing man page sections. 18/12/2002 mcs@astro.caltech.edu man3 man3/* Makefile.in html/index.html update_html Markus suggested splitting the gl_get_line(3) man page into user and developer sections, and also pointed out that the enhance man page should be in section 1, not section 3. I have thus created a top-level man directory in which to place the various sections, and moved the man3 directory into it. The enhance.3 man page is now in man/man1/enhance.1. I have extracted all user-oriented sections from the gl_get_line(3) man page and placed them in a new man7/tecla.7 man page. 18/12/2002 mcs@astro.caltech.edu getline.c Terminal resizing was broken in normal mode, due to me forcing the terminal cursor position to zero in the wrong place in gl_check_caught_signal(). 14/12/2002 Markus Gyger (logged here by mcs) configure.in configure Under Solaris, recent versions of gcc search /usr/local/include for header files before the system directories. This caused a problem if ncurses was installed under Solaris, since the termcap.h include file in /usr/local/include ended up being used at compile time, whereas the system default version of the curses library was used at link time. Since the two libraries declare tputs() differently, this evoked a complaint from gcc. Markus came up with a way to force Gnu cpp to move /usr/local/include to the end of the system-include-file search path, where it belongs. 13/12/2002 mcs@astro.caltech.edu man3/gl_io_mode.3 I rewrote the man page which documents the new non-blocking server I/O mode. 12/12/2002 mcs@astro.caltech.edu demo3.c I wrote a new version of demo3.c, using signal handlers that call gl_handle_signal() and gl_abandon_line(), where previously in this demo, these functions were called from the application code. 05/12/2002 mcs@astro.caltech.edu getline.c gl_normal_io(), gl_raw_io() and gl_handle_signal() and gl_abandon_line() are now signal safe, provided that signal handlers that call them are installed with sa_mask's that block all other signals who's handlers call them. This is the case if gl_tty_signals() is used to install signal handlers that call any of these functions. A major stumbling block that had to be overcome was that gl_displayed_char_width() calls isprint(), which can't safely be called from a signal handler (eg. under linux, the is*() functions all use thread-specific data facilities to support per-thread locales, and the thread-specific data facilities aren't signal safe). To work around this, all functions that modify the input-line buffer, now do so via accessor functions which also maintain a parallel array of character widths, for use by gl_buff_curpos_to_term_curpos() in place of gl_displayed_char_width(). Other minor problems were the need to avoid tputs(), who's signal safety isn't defined. 05/12/2002 Eric Norum (logged here by mcs@astro.caltech.edu) configure.in Eric provided the configuration information needed to build shared libraries under Darwin (Max OS X). 05/12/2002 Richard Mlynarik (logged here by mcs@astro.caltech.edu) configure.in AC_PROG_RANLIB gets the wrong version of ranlib when cross compiling, so has now been replaced by an invokation of AC_CHECK_TOOL. In addition, AC_CHECK_TOOL is also now used to find an appropriate version of LD. 05/12/2002 mcs@astro.caltech.edu (based on patch by Pankaj Rathore) getline.c libtecla.h libtecla.map man3/gl_get_line.3 The new gl_set_term_size() function provides a way to tell gl_get_line() about changes in the size of the terminal in cases where the values returned by ioctl(TIOCGWINSZ) isn't correct. 05/12/2002 mcs@astro.caltech.edu getline.c Rather than calling sprintf() to see how much space would be needed to print a given number in octal, I wrote a gl_octal_width() function, for use by gl_displayed_char_width(). This makes the latter function async signal safe. 05/12/2002 mcs@astro.caltech.edu chrqueue.c Whenever the buffer is exhausted, and getting a new buffer node would require a call to malloc(), attempt to flush the buffer to the terminal. In blocking I/O mode this means that the buffer never grows. In non-blocking I/O mode, it just helps keep the buffer size down. 05/12/2002 mcs@astro.caltech.edu freelist.h freelist.c The new _idle_FreeListNodes() function queries the number of nodes in the freelist which aren't currently in use. 05/12/2002 mcs@astro.caltech.edu Makefile.stub This now accepts all of the targets that the configured makefile does, and after configuring the latter makefile, it invokes it with the same options. 03/12/2002 mcs@astro.caltech.edu mans3/gl_io_mode.3 I completed the man page for all of the new functions related to non-blocking I/O. 01/12/2002 mcs@astro.caltech.edu man3/gl_get_line.3 I wrote a long section on reliable signal handling, explaining how gl_get_line() does this, how to make use of this in a program, and how to handle signals reliably when faced with other blocking functions. This basically documents what I have learnt about signal handling while working on this library. 01/12/2002 mcs@astro.caltech.edu getline.c man3/gl_get_line.3 In non-blocking server mode, the gl_replace_prompt() function can now be used between calls to gl_get_line() if the application wants to change the prompt of the line that is being edited. 01/12/2002 mcs@astro.caltech.edu man3/gl_get_line.3 I documented the new gl_return_status() and gl_error_message() functions. 01/12/2002 mcs@astro.caltech.edu getline.c man3/gl_get_line.3 Added SIGPOLL and SIGXFSZ to the list of signals that are trapped by default. These are process termination signals, so the terminal needs to be restored to a usable state before they terminate the process. 27/11/2002 mcs@astro.caltech.edu getline.c libtecla.h Completed the essential changes needed to support non-blocking server-I/O mode. The new gl_io_mode() function allows one to switch to and from non-blocking server-I/O mode. The new gl_raw_io() function is used in non-blocking server-I/O mode to switch the terminal into non-blocking raw I/O mode. The new gl_normal_io() function is used in non-blocking server-I/O mode to switch the restore the terminal to a normal, blocking state. This is used to suspend line input before suspending the process or writing messages to the terminal. The new gl_tty_signals() function installs specified signals handlers for all signals that suspend, terminate or resume processes, and also for signals that indicate that the terminal has been resized. This not only saves the application from having to keep its own ifdef'd list of such signals, of which there are many, but it also makes sure that these signal handlers are registered correctly. This includes using the sa_mask member of each sigaction structure to ensure that only one of these handlers runs at a time. This is essential to avoid the signal handlers all trying to simultaneously modify shared global data. The new gl_handle_signal() function is provided for responding (from application level) to signals caught by the application. It handles process suspension, process termination and terminal resize signals. The new gl_pending_io() function tells the application what direction of I/O gl_get_line() is currently waiting for. In non-blocking server I/O mode, the new gl_abandon_line() function can be called between calls to gl_get_line() to discard an input line and force the next call to gl_get_line() to start the input of a new line. Also, in non-blocking server-I/O gl_get_line() doesn't attempt to do anything but return when one of the signals that it is configured to catch is caught. This is necessary because when in this mode, the application is required to handle these signals when gl_get_line() is running, and the default configuration of most of these signals in gl_get_line() is to restore the terminal then call the application signal handlers. This would be a case of too many cooks spoiling the broth, so in this mode, gl_get_line() always defers to the application's signal handlers. 26/11/2002 mcs@astro.caltech.edu getline.c libtecla.h I implemented a couple of new functions to support reliable signal handling, as now documented (see above) in the gl_get_line(3) man page. The new gl_catch_blocked() function tells gl_get_line() to unblock all configured signals around calls to long-running functions, not only those that aren't blocked when gl_get_line() is called. This allows the caller to implement reliable signal handling, since the unblocking is only done from within code protected by sigsetjmp(), which avoids race conditions. The new gl_list_signals() function fills a provided sigset_t with the set of signals that gl_get_line() is currently configured to catch. This allows callers to block said signals, such that they are only unblocked by gl_get_line() when it is waiting for I/O. When used in conjunction with the gl_catch_blocked() function, this removes the potential for race conditions. Also, when gl_get_line() installs its signal handler, it uses the sa_mask member of the sigaction structure to ensure that only one instance of this signal handler will ever be executing at a time. 25/11/2002 mcs@astro.caltech.edu (bug reported by Pankaj Rathore) getline.c When any history recall action was invoked when the input line buffer was full, an error message would be displayed complaining about the length of the string in the line input buffer being inconsistent with the specified allocated size. This was because instead of sending the allocated size of the input line, I was sending the length excluding the element that is reserved for the '\0' terminator. Sending it the correct size corrected the problem. 24/11/2002 mcs@astro.caltech.edu getline.c All public functions which take GetLine objects as arguments now block signals on entry and restore the signal mask on return. This was an attempt to make it safe to call getline functions from signal handlers, but the fact is that the functions that I really wanted this to apply to, potentially call malloc(), so this currently isn't the case. 23/11/2002 mcs@astro.caltech.edu getline.c libtecla.h The new gl_return_status() function returns an enumerated return status which can be used to query what caused gl_get_line() to return. 22/11/2002 mcs@astro.caltech.edu Most existing .c and .h files, plus errmsg.c errmsg.h Makefile.rules Until now, many library functions would report error messages to stderr. This isn't appropriate for library functions, so in place of this behavior, error messages are now recorded in internal ErrMsg objects, and passed between modules via new module-specific error querying functions. In addition, errno is now set appropriately. Thus when gl_get_line() and related functions return an error, strerror() can be used to look up system errors, and gl_error_message() can be used to recover a higher level error message. Note that error messages that are responses to user actions continue to be reported to the terminal, as before. 21/11/2002 mcs@astro.caltech.edu getline.c keytab.h keytab.c Makefile.rules I wrote a new version of _kt_lookup_binding() that didn't require the caller to have access to the innards of a KeyTab object. This then enabled me to move the definition of KeyTab objects into keytab.c and make the typedef in keytab.h opaque. Many nested includes were also moved from keytab.h into keytab.c. 05/11/2002 mcs@astro.caltech.edu getline.c libtecla.map libtecla.h demo3.c I split the old gl_resize_terminal() function into two parts, gl_query_size() and gl_update_size(), with the latter calling the former to get the new terminal size. 05/11/2002 mcs@astro.caltech.edu getline.c I fixed a long time bug in the terminal resizing code. When the cursor wasn't on the last terminal line of the input line, the resizing code would redisplay the the line one or more lines above where it should be restored. This was due to an error in the calculation of the number of lines above the cursor position. 04/11/2002 mcs@astro.caltech.edu demo.c demo2.c demo3.c I used the new gl_display_text() function to display introductory text at the startup of each of the demo programs. The text is enclosed within a box of asterixes, drawn dynamically to fit within the confines of the available terminal width. 04/11/2002 mcs@astro.caltech.edu libtecla.h getline.c ioutil.c ioutil.h Makefile.rules libtecla.map man3/gl_get_line.3 man3/gl_display_text.3 Needing a way to display introductory text intelligently in the demo programs, I wrote and documented the gl_display_text() function. This justifies arbitrary length text within the bounds of the terminal width, with or without optional indentation, prefixes and suffixes. 03/11/2002 mcs@astro.caltech.edu demo3.c Makefile.rules I wrote a new demonstration program. This program acts exactly like the main demonstration program, except that it uses an external event loop instead of using the gl_get_line() internal event loop. This is thus an example of the new non-blocking server I/O facility. 02/11/2002 mcs@astro.caltech.edu getline.c keytab.c keytab.h libtecla.h man3/gl_get_line.3 man3/gl_completion_action.3 I added the ability to register additional word completion actions via the new function gl_completion_action(). All action functions now take a new (void *data) argument, which is stored with the function in the symbol table of actions. The new gl_completion_action() function uses this feature to record dynamically allocated objects containing the specified completion function and callback data along with either the gl_complete_word() action function, or the gl_list_completions() action function. These two actions continue to use the builtin completion functions when their data pointer is NULL. 20/10/2002 mcs@astro.caltech.edu The following are changes merged from the non-blocking gl_get_line() development branch. getline.c I wrote a gl_start_newline() function, to replace all of the explicit calls to output \r\n to stdout. Informational messages are now written to the terminal using a new variadic function called gl_print_info(). This starts a newline, writes string arguments until a special argument, GL_END_INFO, is seen, then starts another newline. Changed _output_ to _print_ in the following function names gl_output_control_sequence(), gl_output_char(), gl_output_string() and gl_output_raw_string(). gl_print_raw_string() now has a length argument, so that strings that aren't terminated with '\0' can be printed. The display of the initial contents of a new line to be edited has been moved into a new function called gl_present_line(). The gl_get_input_line() function now takes the prompt string as an argument so that gl_replace_prompt() can be called from within this function instead of from gl_get_line(). Keyboard input is now buffered in a persistent buffer in the parent GetLine object. gl_read_character() checks this for unprocessed characters in preference to calling gl_read_terminal() to append characters to it. A new function, gl_discard_chars(), removes processed characters from this buffer. This change is in preparation for a non-blocking version of gl_get_line(), where partially input key-sequences must be stored between calls to gl_get_line(). getline.c getline.h history.c history.h cplmatch.c \ cplmatch.h expand.c expand.h All terminal output from gl_get_line() is now routed through a GL_WRITE_FN() callback function called gl_write_fn. Internal functions in cplmatch.c, expand.c and history.c have been created which take such callbacks to write output. These are used both by functions in getline.c, to display file completions, expansions, history etc, and as the internals of existing public functions in these files that print to stdio streams. In the latter case an internal stdio GL_WRITE_FN() callback is substituted, so that the functions behave as before. getline.c chrqueue.c chrqueue.h The gl_write_fn() callback used by gl_get_line() now writes to a queue, implemented in chrqueue.c. This queue is implemented as a list of blocks of buffer segments, the number of which shrink and grow as needed. The contents of the queue are flushed to the terminal via another GL_WRITE_FN() callback passed to the queue object. Currently gl_get_line() passes an internal function assigned to gl->flush_fn, called gl_flush_terminal(), which writes the contents of the queue to the terminal, and knows how to handle both blocking and non-blocking I/O. The output queue is designed to be flushed to the terminal incrementally, and thereby also facilitates non-blocking I/O. getline.c getline.h gl_get_line() now reads all input via the GL_READ_FN() callback, assigned to gl->read_fn. Currently this is set to an internal function called gl_read_terminal(), which knows how to handle both blocking and non-blocking I/O. getline.c libtecla.h The new gl_set_nonblocking() function can be used to enable or disable non-blocking I/O. The default is still blocking I/O. In non-blocking mode, the terminal is told not to wait when either reading or writing would block. gl_get_line() then returns, with a return value of NULL, but with the terminal left in raw mode, so that the caller's event loop can detect key presses. The caller should call gl_return_status() to check whether the NULL return value was due to an error, lack of input, or inability to write to the terminal without waiting. If either reading or writing was said to have blocked, the user then should check for I/O readiness in the specified direction before calling gl_get_line() again to incrementally build up the input line. 05/08/2002 mcs@astro.caltech.edu man3/gl_get_line.3 man3/gl_inactivity_timeout.3 I documented the new gl_inactivity_timeout() function. 08/07/2002 mcs@astro.caltech.edu libtecla.h getline.c libtecla.map I added a new gl_inactivity_timeout() function. On systems that have the select system call, this provides the option of registering a function that is then called whenever no I/O activity has been seen for more than a specified period of time. Like the gl_watch_fd() facility, timeout callbacks return a code which tells gl_get_line() how to proceed after the timeout has been handled. 04/07/2002 mcs@astro.caltech.edu (based on a bug report from Michael MacFaden) getline.c The internal event handler wasn't responding to write events on client file descriptors, due to a typo which resulted in read events being checked for twice, and writes not checked for at all. pathutil.c The amount of space to allocate for pathnames is supposed to come from PATH_MAX in limits.h, but I had neglected to include limits.h. This went unnoticed because on most systems the equivalent number is deduced by calling pathconf(). Apparently under NetBSD this function doesn't work correctly over NFS mounts. 30/05/2002 Version 1.4.1 released. 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. 07/05/2002 mcs@astro.caltech.edu (async development branch only) getline.c gl_read_character() now caches and reads unprocessed characters from a key-press lookahead buffer. Whenever gl_intepret_char() receives a new character which makes an initially promising key-sequence no longer match the prefix of any binding, it now simply discards the first character from the key-press buffer and resets the buffer pointer so that the next call to gl_read_character() returns the character that followed it, from the buffer. getline.c The part of gl_get_input_line() which preloads, displays and prepares to edit a new input line, has now been moved into a function called gl_present_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/<many-new-files>.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.