From 6181f4622a00a9de81df01cecb5fa73ffdb697bc Mon Sep 17 00:00:00 2001 From: Rong-En Fan Date: Sun, 9 Nov 2008 14:08:54 +0000 Subject: [PATCH] - Import ncurses 5.7-20081102 (5.7 release) onto vendor branch --- ANNOUNCE | 408 +-- INSTALL | 148 +- MANIFEST | 5 + NEWS | 238 +- TO-DO | 15 +- aclocal.m4 | 546 +++- announce.html.in | 418 ++- config.guess | 156 +- config.sub | 47 +- configure | 4172 ++++++++++++++++++------------ configure.in | 170 +- dist.mk | 11 +- doc/html/announce.html | 422 ++- form/form.priv.h | 6 +- form/frm_def.c | 16 +- form/frm_driver.c | 35 +- form/frm_req_name.c | 6 +- include/MKterm.h.awk.in | 10 +- include/capdefaults.c | 14 +- include/curses.h.in | 5 +- include/curses.tail | 14 +- include/nc_alloc.h | 8 +- include/nc_panel.h | 11 +- include/ncurses_defs | 9 +- include/term_entry.h | 8 +- man/curs_getcchar.3x | 15 +- man/curs_memleaks.3x | 75 + man/curs_terminfo.3x | 38 +- man/curs_util.3x | 44 +- man/form.3x | 16 +- man/form_driver.3x | 31 +- man/form_field_buffer.3x | 54 +- man/man_db.renames | 3 +- man/menu_attributes.3x | 6 +- man/menu_driver.3x | 32 +- man/menu_pattern.3x | 6 +- man/ncurses.3x | 35 +- menu/m_driver.c | 10 +- menu/m_req_name.c | 6 +- misc/ncu-indent | 6 +- misc/ncurses.supp | 205 ++ misc/terminfo.src | 150 +- ncurses/Makefile.in | 14 +- ncurses/base/MKkeyname.awk | 15 +- ncurses/base/MKlib_gen.sh | 15 +- ncurses/base/MKunctrl.awk | 27 +- ncurses/base/lib_addch.c | 13 +- ncurses/base/lib_delwin.c | 9 +- ncurses/base/lib_freeall.c | 33 +- ncurses/base/lib_getch.c | 101 +- ncurses/base/lib_getstr.c | 23 +- ncurses/base/lib_initscr.c | 8 +- ncurses/base/lib_mouse.c | 546 ++-- ncurses/base/lib_newterm.c | 26 +- ncurses/base/lib_newwin.c | 30 +- ncurses/base/lib_overlay.c | 17 +- ncurses/base/lib_restart.c | 4 +- ncurses/base/lib_screen.c | 16 +- ncurses/base/lib_set_term.c | 52 +- ncurses/base/lib_slk.c | 32 +- ncurses/base/lib_slkrefr.c | 28 +- ncurses/base/lib_ungetch.c | 8 +- ncurses/base/lib_window.c | 6 +- ncurses/base/resizeterm.c | 12 +- ncurses/base/tries.c | 8 +- ncurses/base/use_window.c | 36 +- ncurses/base/wresize.c | 6 +- ncurses/curses.priv.h | 116 +- ncurses/fifo_defs.h | 4 +- ncurses/llib-lncurses | 101 +- ncurses/llib-lncursest | 280 +- ncurses/llib-lncursesw | 101 +- ncurses/tinfo/MKcodes.awk | 7 +- ncurses/tinfo/MKnames.awk | 9 +- ncurses/tinfo/alloc_entry.c | 70 +- ncurses/tinfo/alloc_ttype.c | 15 +- ncurses/tinfo/captoinfo.c | 17 +- ncurses/tinfo/comp_expand.c | 12 +- ncurses/tinfo/comp_hash.c | 18 +- ncurses/tinfo/comp_parse.c | 7 +- ncurses/tinfo/comp_scan.c | 99 +- ncurses/tinfo/entries.c | 11 +- ncurses/tinfo/home_terminfo.c | 12 +- ncurses/tinfo/init_keytry.c | 9 +- ncurses/tinfo/lib_acs.c | 9 +- ncurses/tinfo/lib_baudrate.c | 21 +- ncurses/tinfo/lib_cur_term.c | 47 +- ncurses/tinfo/lib_data.c | 72 +- ncurses/tinfo/lib_options.c | 185 +- ncurses/tinfo/lib_setup.c | 93 +- ncurses/tinfo/lib_termcap.c | 7 +- ncurses/tinfo/lib_tgoto.c | 6 +- ncurses/tinfo/lib_tparm.c | 14 +- ncurses/tinfo/lib_tputs.c | 23 +- ncurses/tinfo/lib_ttyflags.c | 56 +- ncurses/tinfo/make_keys.c | 18 +- ncurses/tinfo/name_match.c | 27 +- ncurses/tinfo/parse_entry.c | 30 +- ncurses/tinfo/read_entry.c | 8 +- ncurses/tinfo/use_screen.c | 8 +- ncurses/tinfo/write_entry.c | 24 +- ncurses/trace/lib_trace.c | 16 +- ncurses/trace/lib_traceatr.c | 268 +- ncurses/trace/lib_tracebits.c | 81 +- ncurses/trace/lib_tracechr.c | 22 +- ncurses/trace/lib_tracedmp.c | 28 +- ncurses/trace/lib_tracemse.c | 16 +- ncurses/trace/trace_buf.c | 51 +- ncurses/trace/trace_tries.c | 6 +- ncurses/trace/varargs.c | 6 +- ncurses/trace/visbuf.c | 186 +- ncurses/tty/hardscroll.c | 19 +- ncurses/tty/lib_mvcur.c | 14 +- ncurses/tty/lib_twait.c | 8 +- ncurses/tty/tty_update.c | 6 +- ncurses/widechar/charable.c | 6 +- ncurses/widechar/lib_get_wch.c | 79 +- ncurses/widechar/lib_get_wstr.c | 27 +- ncurses/widechar/lib_key_name.c | 4 +- ncurses/widechar/lib_unget_wch.c | 6 +- panel/p_new.c | 9 +- panel/panel.priv.h | 12 +- progs/MKtermsort.sh | 22 +- progs/Makefile.in | 2 +- progs/dump_entry.c | 77 +- progs/dump_entry.h | 6 +- progs/infocmp.c | 89 +- progs/progs.priv.h | 5 +- progs/tic.c | 86 +- progs/toe.c | 25 +- progs/tput.c | 5 +- progs/tset.c | 90 +- 132 files changed, 7167 insertions(+), 4361 deletions(-) create mode 100644 man/curs_memleaks.3x create mode 100644 misc/ncurses.supp diff --git a/ANNOUNCE b/ANNOUNCE index bbeeb8922d47..e09e73177a45 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ - Announcing ncurses 5.6 + Announcing ncurses 5.7 The ncurses (new curses) library is a free software emulation of curses in System V Release 4.0, and more. It uses terminfo format, @@ -27,205 +27,217 @@ Release Notes This release is designed to be upward compatible from ncurses 5.0 - through 5.5; very few applications will require recompilation, + through 5.6; very few applications will require recompilation, depending on the platform. These are the highlights from the - change-log since ncurses 5.5 release. + change-log since ncurses 5.6 release. Interface changes: * generate linkable stubs for some macros: - getbegx, getbegy, getcurx, getcury, getmaxx, getmaxy, getparx, - getpary, getpary, - and (for libncursesw) - wgetbkgrnd + getattrs New features and improvements: * library - + support hashed databases for the terminal descriptions. This - uses the Berkeley database, has been tested for several - versions on different platforms. - + add use_legacy_coding() function to support lynx's - font-switching feature. - + add extension nofilter(), to cancel a prior filter() call. - + add/install a package config script, e.g., ncurses5-config or - ncursesw5-config, according to configuration options. - + provide ifdef for NCURSES_NOMACROS which suppresses most - macro definitions from curses.h, i.e., where a macro is - defined to override a function to improve performance. - + make ifdef's consistent in curses.h for the extended colors - so the header file can be used for the normal curses library. - The header file installed for extended colors is a variation - of the wide-character configuration. - + improve tgetstr() by making the return value point into the - user's buffer, if provided. - + add ifdef's allowing ncurses to be built with tparm() using - either varargs (the existing status), or using a - fixed-parameter list (to match X/Open). - + widen the test for xterm kmous a little to allow for other - strings than "\E[M", e.g., for xterm-sco functionality in - xterm. - + modify wgetnstr() to return KEY_RESIZE if a sigwinch occurs. - + move prototypes for wide-character trace functions from - curses.tail to curses.wide to avoid accidental reference to - those if _XOPEN_SOURCE_EXTENDED is defined without ensuring - that is included. - + change the way shared libraries (other than libtool) are - installed. Rather than copying the build-tree's libraries, - link the shared objects into the install directory. This - makes the --with-rpath option work except with $(DESTDIR). - + several improvements for rendering in hpterm. These are only - available if the library is configured using - --enable-xmc-glitch. - + Add NCURSES_NO_HARD_TABS and NCURSES_NO_MAGIC_COOKIE - environment variables to allow runtime suppression of the - related hard-tabs and xmc-glitch features. + + new flavor of the ncurses library provides rudimentary + support for POSIX threads. Several functions are reentrant, + but most require either a window-level or screen-level mutex. + (This is API-compatible, but not ABI-compatible with the + normal library). + + add NCURSES_OPAQUE symbol to curses.h, will use to make + structs opaque in selected configurations. + + add NCURSES_EXT_FUNCS and NCURSES_EXT_COLORS symbols to + curses.h to make it simpler to tell if the extended functions + and/or colors are declared. + + add wresize() to C++ binding + + eliminate fixed-buffer vsprintf() calls in C++ binding. + + add several functions to C++ binding which wrap C functions + that pass a WINDOW* parameter. + + adapt mouse-handling code from menu library in form-library + + improve tracing for form library, showing created forms, + fields, etc. + + make $NCURSES_NO_PADDING feature work for termcap interface . + + add check to trace-file open, if the given name is a + directory, add ".log" to the name and try again. + + several new manpages: curs_legacy.3x, curs_memleaks.3x, + curs_opaque.3x and curs_threads.3x * programs: - + add new test programs: chgat.c, demo_altkeys.c, echochar.c, - foldkeys.c, movewindow.c, redraw.c, (noting that existing - test programs also were modified to test additional - features). - + modify tack to test extended capability function-key strings. - + modify toe to access termcap data, e.g., via cgetent() - functions, or as a text file if those are not available. - + improve infocmp/tic -f option formatting. - + add toe -a option, to show all databases. This uses new - private interfaces in the ncurses library for iterating - through the list of databases. - + modify MKfallback.sh to use tic -x when constructing fallback - tables to allow extended capabilities to be retrieved from a - fallback entry. + + modified three test-programs to demonstrate the threading + support in this version: ditto, rain, worm. + + several new test-programs: demo_panels, dots_mvcur, + inch_wide, inchs, key_name, key_names, savescreen, + savescreen.sh test_arrays, test_get_wstr, test_getstr, + test_instr, test_inwstr and test_opaque. + + add adacurses-config to the Ada95 install. + + modify tic -f option to format spaces as \s to prevent them + from being lost when that is read back in unformatted + strings. + + The tack program is now distributed separately from ncurses. * terminal database - + add terminfo entries for xfce terminal (xfce) and multi gnome - terminal (mgt) - + add nsterm-16color entry - + updated mlterm terminfo entry - + add kon, kon2 and jfbterm terminfo entry - + remove invis capability from klone+sgr, mainly used by linux - entry, since it does not really do this - + add ka2, kb1, kb3, kc2 to vt220-keypad as an extension - + add shifted up/down arrow codes to xterm-new as kind/kri - strings - + add hpterm-color terminfo entry - + add 256color variants of terminfo entries for programs which - are reported to implement this feature - + correct order of use-clauses in rxvt-basic entry which made - codes for f1-f4 vt100-style rather than vt220-style. + + added entries: + o Eterm-256color, Eterm-88color and rxvt-88color + o aterm + o konsole-256color + o mrxvt + o screen.mlterm + o screen.rxvt + o teraterm4.59 is now the primary primary teraterm entry, + renamed original to teraterm2.3 + o 9term terminal + o Newbury Data entries + + updated/improved entries: + o gnome to version 2.22.3 + o h19, z100 + o konsole to version 1.6.6 + o mlterm, mlterm+pcfkeys + o xterm, and building-blocks for function-keys to [3]xterm + patch #230. Major bug fixes: - * correct a typo in configure --with-bool option for the case where - --without-cxx is used. - * move assignment from environment variable ESCDELAY from initscr() - down to newterm() so the environment variable affects timeouts for - terminals opened with newterm() as well. - * modify werase to clear multicolumn characters that extend into a - derived window. - * modify wchgat() to mark updated cells as changed so a refresh will - repaint those cells. - * correct logic in wadd_wch() and wecho_wch(), which did not guard - against passing the multi-column attribute into a call on - waddch(), e.g., using data returned by win_wch() - * fix redrawing of windows other than stdscr using wredrawln() by - touching the corresponding rows in curscr. - * reduce memory leaks in repeated calls to tgetent() by remembering - the last TERMINAL* value allocated to hold the corresponding data - and freeing that if the tgetent() result buffer is the same as the - previous call. - * modify read_termtype() so the term_names data is always allocated - as part of the str_table, a better fix for a memory leak. - * fix wins_nwstr(), which did not handle single-column non-8bit - codes. - * modify wbkgrnd() to avoid clearing the A_CHARTEXT attribute bits - since those record the state of multicolumn characters. - * improve SIGWINCH handling by postponing its effect during - newterm(), etc., when allocating screens. - * remove 970913 feature for copying subwindows as they are moved in - mvwin(). - * add checks in waddchnstr() and wadd_wchnstr() to stop copying when - a null character is found. - * add some checks to ensure current position is within scrolling - region before scrolling on a new line. - * add a workaround to ACS mapping to allow applications such as - test/blue.c to use the "PC ROM" characters by masking them with - A_ALTCHARSET. This worked up til 5.5, but was lost in the revision - of legacy coding. + * add logic to tic for cancelling strings in user-defined + capabilities (this is needed for current konsole terminfo entry). + * modify mk-1st.awk so the generated makefile rules for linking or + installing shared libraries do not first remove the library, in + case it is in use, e.g., libncurses.so by /bin/sh. + * correct check for notimeout() in wgetch(). + * fix a sign-extension bug in infocmp's repair_acsc() function. + * change winnstr() to stop at the end of the line. + * make Ada95 demo_panels() example work. + * fix for adding a non-spacing character at the beginning of a line. + * fill in extended-color pair to make colors work for + wide-characters using extended-colors. + * improve refresh of window on top of multi-column characters, + taking into account split characters on left/right window + boundaries. + * modify win_wchnstr() to ensure that only a base cell is returned + for each multi-column character. + * improve waddch() and winsch() handling of EILSEQ from mbrtowc() by + using unctrl() to display illegal bytes rather than trying to + append further bytes to make up a valid sequence. + * restore curs_set() state after endwin()/refresh() + * modify keyname() to use "^X" form only if meta() has been called, + or if keyname() is called without initializing curses, e.g., via + initscr() or newterm(). + * modify unctrl() to check codes in 128-255 range versus isprint(). + If they are not printable, and locale was set, use a "M-" or "~" + sequence. + * improve resizeterm() by moving ripped-off lines, and repainting + the soft-keys. + * modify form library to accept control characters such as newline + in set_field_buffer(), which is compatible with Solaris. + * use NCURSES_MOUSE_MASK() in definition of BUTTON_RELEASE(), etc., + to make those work properly with the --enable-ext-mouse + configuration + * correct some functions in Ada95 binding which were using return + value from C where none was returned. + * reviewed/fixed issues reported by Coverity and Klocwork tools. Portability: * configure script: + new options: - --with-hashed-db - Use Berkeley hashed database for storing terminfo - data rather than storing each compiled entry in a - separate binary file within a directory tree. + --disable-big-strings + control whether static string tables are generated + as single large strings (to improve startup + performance), or as array of individual strings. - --without-dlsym - Do not use dlsym() to load GPM dynamically. + --disable-relink + control whether shared libraries are relinked + (during install) when rpath is enabled. - --with-valgrind - Simplify building for testing with valgrind. + --disable-tic-depends + make explicit whether tic library depends on + ncurses/ncursesw library. - --enable-wgetch-events - Compile with experimental wgetch-events code. + --enable-mixed-case + override the configure script's check if the + filesystem supports mixed-case filenames. This + allows one to control how the terminal database + maps to the filesystem. For filesystems that do not + support mixed-case, the library uses generate + 2-character (hexadecimal) codes for the lower-level + of the filesystem terminfo database - --enable-signed-char - Store booleans in "signed char" rather than "char". + --enable-reentrant + builds a different flavor of the ncurses library + (ncursest) which improves reentrant use of the + library by reducing global and static variables + (see the "--with-pthread" option for the threaded + support). + + --enable-weak-symbols + use weak-symbols for linking to the POSIX thread + library, and use the same soname for the ncurses + shared library as the normal library (caveat: the + ABI is for the threaded library, which makes global + data accessed via functions). + + --with-pthread + build with the POSIX thread library (tested with + AIX, Linux, FreeBSD, OpenBSD, HPUX, IRIX64, + Solaris, Tru64). + + --with-ticlib + build/install the tic-support functions in a + separate library + improved options: - --disable-largefile - make the option work both ways. + --enable-ext-colors + requires the wide-character configuration. - --with-gpm - The option now accepts a parameter, i.e., the name - of the dynamic GPM library to load via dlopen() + --with-chtype + ignore option value "unsigned" is always added to + the type in curses.h; do the same for + --with-mmask-t. - --disable-symlinks - The option now allows one to disable symlink() in - tic even when link() does not work. + --with-dmalloc + build-fix for redefinition of strndup. + + --with-hashed-db + accepts a parameter which is the install-prefix of + a given Berkeley Database. + + --with-hashed-db + the $LIBS environment variable overrides the search + for the db library. + + --without-hashed-db + assumed when "--disable-database" is used. * other configure/build issues: - + remove special case for Darwin in CF_XOPEN_SOURCE configure - macro. - + add configure check to ensure that SIGWINCH is defined on - platforms such as OS X which exclude that when _XOPEN_SOURCE, - etc., are defined - + use ld's -search_paths_first option on Darwin to work around - odd search rules on that platform. - + improve ifdef's for _POSIX_VDISABLE in tset to work with Mac - OS X. - + modify configure script to ensure that if the C compiler is - used rather than the loader in making shared libraries, the - $(CFLAGS) variable is also used. - + use ${CC} rather than ${LD} in shared library rules for - IRIX64, Solaris to help ensure that initialization sections - are provided for extra linkage requirements, e.g., of C++ - applications. - + improve some shared-library configure scripting for Linux, - FreeBSD and NetBSD to make --with-shlib-version work. - + split up dependency of names.c and codes.c in - ncurses/Makefile to work with parallel make. - + modify MKlib_gen.sh to change preprocessor-expanded _Bool - back to bool. - + modify progs/Makefile.in to make tput init work properly with - cygwin, i.e., do not pass a .exe in the reference string used - in check_aliases. + + build-fixes for LynxOS + + modify shared-library rules to allow FreeBSD 3.x to use + rpath. + + build-fix for FreeBSD "contemporary" TTY interface. + + build-fixes for AIX with libtool. + + build-fixes for Darwin and libtool. + + modify BeOS-specific ifdef's to build on Haiku. + + corrected gcc options for building shared libraries on + Solaris and IRIX64. + + change shared-library configuration for OpenBSD, make rpath + work. + + build-fixes for using libutf8, e.g., on OpenBSD 3.7 + + add "-e" option in ncurses/Makefile.in when generating + source-files to force earlier exit if the build environment + fails unexpectedly. + + add support for shared libraries for QNX. + + change delimiter in MKlib_gen.sh from '%' to '@', to avoid + substitution by IBM xlc to '#' as part of its extensions to + digraphs. * library: - + ignore wide-acs line-drawing characters that wcwidth() claims - are not one-column. This is a workaround for Solaris' broken - locale support. - + reduce name-pollution in term.h by removing #define's for - HAVE_xxx symbols. - + fix #ifdef in c++/internal.h for QNX 6.1 + + rewrite wrapper for wcrtomb(), making it work on Solaris. + This is used in the form library to determine the length of + the buffer needed by field_buffer. + + add/use configure script macro CF_SIG_ATOMIC_T, use the + corresponding type for data manipulated by signal handlers. + + set locale in misc/ncurses-config.in since it uses a range + + disable GPM mouse support when $TERM does not happen to + contain "linux", since Gpm_Open() no longer limits its + assertion to terminals that it might handle, e.g., within + "screen" in xterm. + + reset mouse file-descriptor when unloading GPM library. * test programs: - + modify test/configure script to allow building test programs - with PDCurses/X11. - + modified test programs to allow some to work with NetBSD - curses. Several do not because NetBSD curses implements a - subset of X/Open curses, and also lacks much of SVr4 - additions. But it is enough for comparison. - + improved test/configure to build test/ncurses on HPUX 11 - using the vendor curses. - + change configure script to produce test/Makefile from data - file. + + update test programs to build/work with various UNIX curses + for comparisons. Features of Ncurses @@ -271,6 +283,8 @@ the use of function keys, e.g., disabling the ncurses KEY_MOUSE, or by defining more than one control sequence to map to a given key code. + * Support for 256-color terminals, such as modern xterm, when + configured using the --enable-ext-colors option. * Support for 16-color terminals, such as aixterm and modern xterm. * Better cursor-movement optimization. The package now features a cursor-local-movement computation more efficient than either BSD's @@ -342,49 +356,45 @@ cdk Curses Development Kit - [3]http://invisible-island.net/cdk/ - [4]http://www.vexus.ca/products/CDK/ + [4]http://invisible-island.net/cdk/ + [5]http://www.vexus.ca/products/CDK/ ded directory-editor - [5]http://invisible-island.net/ded/ + [6]http://invisible-island.net/ded/ dialog the underlying application used in Slackware's setup, and the basis for similar applications on GNU/Linux. - [6]http://invisible-island.net/dialog/ + [7]http://invisible-island.net/dialog/ lynx the character-screen WWW browser - [7]http://lynx.isc.org/release/ + [8]http://lynx.isc.org/release/ Midnight Commander file manager - [8]http://www.ibiblio.org/mc/ + [9]http://www.ibiblio.org/mc/ mutt mail utility - [9]http://www.mutt.org/ + [10]http://www.mutt.org/ ncftp file-transfer utility - [10]http://www.ncftp.com/ + [11]http://www.ncftp.com/ nvi New vi versions 1.50 are able to use ncurses versions 1.9.7 and later. - [11]http://www.bostic.com/vi/ + [12]http://www.bostic.com/vi/ pinfo Lynx-like info browser. - [12]http://dione.ids.pl/~pborys/software/pinfo/ + [13]https://alioth.debian.org/projects/pinfo/ tin - newsreader, supporting color, MIME [13]http://www.tin.org/ - - vh-1.6 - Volks-Hypertext browser for the Jargon File - [14]http://www.debian.org/Packages/unstable/text/vh.html + newsreader, supporting color, MIME [14]http://www.tin.org/ as well as some that use ncurses for the terminfo support alone: @@ -402,7 +412,7 @@ Who's Who and What's What Zeyd Ben-Halim started it from a previous package pcurses, written by - Pavel Curtis. Eric S. Raymond continued development. Juergen Pfeifer + Pavel Curtis. Eric S. Raymond continued development. Jürgen Pfeifer wrote most of the form and menu libraries. Ongoing work is being done by [17]Thomas Dickey. Thomas Dickey acts as the maintainer for the Free Software Foundation, which holds the copyright on ncurses. @@ -442,18 +452,18 @@ References 1. ftp://ftp.gnu.org/gnu/ncurses/ 2. ftp://invisible-island.net/ncurses/ - 3. http://invisible-island.net/cdk/ - 4. http://www.vexus.ca/products/CDK/ - 5. http://invisible-island.net/ded/ - 6. http://invisible-island.net/dialog/ - 7. http://lynx.isc.org/release/ - 8. http://www.ibiblio.org/mc/ - 9. http://www.mutt.org/ - 10. http://www.ncftp.com/ - 11. http://www.bostic.com/vi/ - 12. http://dione.ids.pl/~pborys/software/pinfo/ - 13. http://www.tin.org/ - 14. http://www.debian.org/Packages/unstable/text/vh.html + 3. http://invisible-island.net/xterm/xterm.log.html#xterm_230 + 4. http://invisible-island.net/cdk/ + 5. http://www.vexus.ca/products/CDK/ + 6. http://invisible-island.net/ded/ + 7. http://invisible-island.net/dialog/ + 8. http://lynx.isc.org/release/ + 9. http://www.ibiblio.org/mc/ + 10. http://www.mutt.org/ + 11. http://www.ncftp.com/ + 12. http://www.bostic.com/vi/ + 13. https://alioth.debian.org/projects/pinfo/ + 14. http://www.tin.org/ 15. http://alioth.debian.org/projects/minicom/ 16. http://invisible-island.net/vile/ 17. mailto:dickey@invisible-island.net diff --git a/INSTALL b/INSTALL index 7917e299abae..ab7dcd829959 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------- --- Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. -- +-- Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: INSTALL,v 1.124 2008/03/29 18:07:32 tom Exp $ +-- $Id: INSTALL,v 1.135 2008/11/02 21:13:51 tom Exp $ --------------------------------------------------------------------- How to install Ncurses/Terminfo on your system --------------------------------------------------------------------- @@ -393,6 +393,18 @@ SUMMARY OF CONFIGURE OPTIONS: Compile without scroll-hints code. This option is ignored when hashmap scrolling is configured, which is the default. + --disable-tic-depends + When building shared libraries, normally the tic library is linked to + depend upon the ncurses library (and in turn, on the term-library if + the --with-termlib option was given). The tic- and term-libraries + ABI does not depend on the --enable-widec option. Some packagers have + used this to reduce the number of library files which are packaged + by using only one copy of those libraries. To make this work properly, + the tic library must be built without an explicit dependency on the + ncurses (or ncursesw) library. Use this configure option to do that. + For example + configure --with-ticlib --with-shared --disable-tic-depends + --disable-tparm-varargs Portable programs should call tparm() using the fixed-length parameter list documented in X/Open. ncurses provides varargs support for this @@ -572,6 +584,13 @@ SUMMARY OF CONFIGURE OPTIONS: --enable-warnings Turn on GCC compiler warnings. There should be only a few. + --enable-weak-symbols + If the --with-pthread option is set, check if the compiler supports + weak-symbols. If it does, then name the thread-capable library without + the "t" (libncurses rather than libncursest), and provide for + dynamically loading the pthreads entrypoints at runtime. This allows + one to reduce the number of library files for ncurses. + --enable-wgetch-events Compile with experimental wgetch-events code. See ncurses/README.IZ @@ -598,6 +617,9 @@ SUMMARY OF CONFIGURE OPTIONS: Normally this is the same as the release version; some ports have special requirements for compatibility. + This option does not affect linking with libtool, which uses the + release major/minor numbers. + --with-ada-compiler=CMD Specify the Ada95 compiler command (default "gnatmake") @@ -625,20 +647,32 @@ SUMMARY OF CONFIGURE OPTIONS: to do this if the target compiler has unusual flags which confuse the host compiler. + You can also set the environment variable $BUILD_CFLAGS rather than + use this option. + --with-build-cppflags=XXX If cross-compiling, specify the host C preprocessor-flags. You might need to do this if the target compiler has unusual flags which confuse the host compiler. + You can also set the environment variable $BUILD_CPPFLAGS rather than + use this option. + --with-build-ldflags=XXX If cross-compiling, specify the host linker-flags. You might need to do this if the target linker has unusual flags which confuse the host compiler. + You can also set the environment variable $BUILD_LDFLAGS rather than + use this option. + --with-build-libs=XXX If cross-compiling, the host libraries. You might need to do this if the target environment requires unusual libraries. + You can also set the environment variable $BUILD_LIBS rather than + use this option. + --with-caps=XXX Specify an alternate terminfo capabilities file, which makes the configure script look for "include/Caps.XXX". A few systems, e.g., @@ -795,6 +829,14 @@ SUMMARY OF CONFIGURE OPTIONS: may be unsigned. Use this option if you need to preserve compatibility with 64-bit executables. + --with-normal + Generate normal (i.e., static) libraries (default). + + Note: on Linux, the configure script will attempt to use the GPM + library via the dlsym() function call. Use --without-dlsym to disable + this feature, or --without-gpm, depending on whether you wish to use + GPM. + --with-ospeed=TYPE Override type of ospeed variable, which is part of the termcap compatibility interface. In termcap, this is a 'short', which works @@ -808,14 +850,6 @@ SUMMARY OF CONFIGURE OPTIONS: those using termcap, do not use the higher speeds. Your application (or system, in general) may or may not. - --with-normal - Generate normal (i.e., static) libraries (default). - - Note: on Linux, the configure script will attempt to use the GPM - library via the dlsym() function call. Use --without-dlsym to disable - this feature, or --without-gpm, depending on whether you wish to use - GPM. - --with-profile Generate profile-libraries These are named by adding "_p" to the root, e.g., libncurses_p.a @@ -898,6 +932,12 @@ SUMMARY OF CONFIGURE OPTIONS: library. As in termlib, there is no ABI difference between the "wide" libticw.so and libtic.so + NOTE: Overriding the name of the tic library may be useful if you are + also using the --with-termlib option to rename libtinfo. If you are + not doing that, renaming the tic library can result in conflicting + library dependencies for tic and other programs built with the tic + library. + --with-trace Configure the trace() function as part of the all models of the ncurses library. Normally it is part of the debug (libncurses_g) library only. @@ -961,6 +1001,94 @@ COMPATIBILITY WITH OLDER VERSIONS OF NCURSES: you may encounter when building a system with different versions of ncurses: + 5.7 (November 2, 2008) + Interface changes: + + + generate linkable stubs for some macros: + getattrs + + + Add new library configuration for tic-library (the non-curses portion + of the ncurses library used for the tic program as well as some + others such as tack. There is no API change, but makefiles would be + changed to use the tic-library built separately. + + tack, distributed separately from ncurses, uses some of the internal + _nc_XXX functions, which are declared in the tic.h header file. + + The reason for providing this separate library is that none of the + functions in it are suitable for threaded applications. + + + Add new library configuration (ncursest, ncurseswt) which provides + rudimentary support for POSIX threads. This introduces opaque + access functions to the WINDOW structure and adds a parameter to + several internal functions. + + + move most internal variables (except tic-library) into data blocks + _nc_globals and _nc_prescreen to simplify analysis. Those were + globally accessible, but since they were not part of the documented + API, there is no ABI change. + + + changed static tables of strings to be indices into long strings, to + improve startup performance. This changes parameter lists for some + of the internal functions. + + Added extensions: + + + add NCURSES_OPAQUE definition in curses.h to control whether internal + details of the WINDOW structure are visible to an application. This + is always defined when the threaded library is built, and is optional + otherwise. New functions for this: is_cleared, is_idcok, is_idlok, + is_immedok, is_keypad, is_leaveok, is_nodelay, is_notimeout, + is_scrollok, is_syncok, wgetparent and wgetscrreg. + + + the threaded library (ncursest) also disallows direct updating of + global curses-level variables, providing functions (via macros) for + obtaining their value. A few of those variables can be modified by + the application, using new functions: set_escdelay, set_tabsize + + + added functions use_window() and use_screen() which wrap a mutex + (if threading is configured) around a call to a user-supplied + function. + + Added internal functions: + _nc_get_alias_table + _nc_get_screensize + _nc_keyname + _nc_screen_of + _nc_set_no_padding + _nc_tracechar + _nc_tracemouse + _nc_unctrl + _nc_ungetch + + These are used for leak-testing, and are stubs for + ABI compatibility when ncurses is not configured for that + using the --disable-leaks configure script option: + + _nc_free_and_exit + _nc_leaks_tinfo + + Removed internal functions: + none + + Modified internal functions: + _nc_fifo_dump + _nc_find_entry + _nc_handle_sigwinch + _nc_init_keytry + _nc_keypad + _nc_locale_breaks_acs + _nc_timed_wait + _nc_update_screensize + + Use new typedef TRIES to replace "struct tries": + + _nc_add_to_try + _nc_expand_try + _nc_remove_key + _nc_remove_string + _nc_trace_tries + 5.6 (December 17, 2006) Interface changes: diff --git a/MANIFEST b/MANIFEST index 62f052ff1801..db3871f2e11e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -349,8 +349,10 @@ ./doc/html/man/curs_instr.3x.html ./doc/html/man/curs_inwstr.3x.html ./doc/html/man/curs_kernel.3x.html +./doc/html/man/curs_legacy.3x.html ./doc/html/man/curs_mouse.3x.html ./doc/html/man/curs_move.3x.html +./doc/html/man/curs_opaque.3x.html ./doc/html/man/curs_outopts.3x.html ./doc/html/man/curs_overlay.3x.html ./doc/html/man/curs_pad.3x.html @@ -364,6 +366,7 @@ ./doc/html/man/curs_termattrs.3x.html ./doc/html/man/curs_termcap.3x.html ./doc/html/man/curs_terminfo.3x.html +./doc/html/man/curs_threads.3x.html ./doc/html/man/curs_touch.3x.html ./doc/html/man/curs_trace.3x.html ./doc/html/man/curs_util.3x.html @@ -555,6 +558,7 @@ ./man/curs_inwstr.3x ./man/curs_kernel.3x ./man/curs_legacy.3x +./man/curs_memleaks.3x ./man/curs_mouse.3x ./man/curs_move.3x ./man/curs_opaque.3x @@ -700,6 +704,7 @@ ./misc/ncurses-config.in ./misc/ncurses.def ./misc/ncurses.ref +./misc/ncurses.supp ./misc/panel.def ./misc/panel.ref ./misc/run_tic.in diff --git a/NEWS b/NEWS index c5126da03699..a64450b30228 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1233 2008/05/03 23:14:39 tom Exp $ +-- $Id: NEWS,v 1.1320 2008/11/02 00:56:22 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,238 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20081102 5.7 release for upload to ftp.gnu.org + +20081025 + + add a manpage to discuss memory leaks. + + add support for shared libraries for QNX (other than libtool, which + does not work well on that platform). + + build-fix for QNX C++ binding. + +20081018 + + build-fixes for OS/2 EMX. + + modify form library to accept control characters such as newline + in set_field_buffer(), which is compatible with Solaris (report by + Nit Khair). + + modify configure script to assume --without-hashed-db when + --disable-database is used. + + add "-e" option in ncurses/Makefile.in when generating source-files + to force earlier exit if the build environment fails unexpectedly + (prompted by patch by Adrian Bunk). + + change configure script to use CF_UTF8_LIB, improved variant of + CF_LIBUTF8. + +20081012 + + add teraterm4.59 terminfo entry, use that as primary teraterm entry, rename + original to teraterm2.3 -TD + + update "gnome" terminfo to 2.22.3 -TD + + update "konsole" terminfo to 1.6.6, needs today's fix for tic -TD + + add "aterm" terminfo -TD + + add "linux2.6.26" terminfo -TD + + add logic to tic for cancelling strings in user-defined capabilities, + overlooked til now. + +20081011 + + update html documentation. + + add -m and -s options to test/keynames.c and test/key_names.c to test + the meta() function with keyname() or key_name(), respectively. + + correct return value of key_name() on error; it is null. + + document some unresolved issues for rpath and pthreads in TO-DO. + + fix a missing prototype for ioctl() on OpenBSD in tset.c + + add configure option --disable-tic-depends to make explicit whether + tic library depends on ncurses/ncursesw library, amends change from + 20080823 (prompted by Debian #501421). + +20081004 + + some build-fixes for configure --disable-ext-funcs (incomplete, but + works for C/C++ parts). + + improve configure-check for awks unable to handle large strings, e.g. + AIX 5.1 whose awk silently gives up on large printf's. + +20080927 + + fix build for --with-dmalloc by workaround for redefinition of + strndup between string.h and dmalloc.h + + fix build for --disable-sigwinch + + add environment variable NCURSES_GPM_TERMS to allow override to use + GPM on terminals other than "linux", etc. + + disable GPM mouse support when $TERM does not happen to contain + "linux", since Gpm_Open() no longer limits its assertion to terminals + that it might handle, e.g., within "screen" in xterm. + + reset mouse file-descriptor when unloading GPM library (report by + Miroslav Lichvar). + + fix build for --disable-leaks --enable-widec --with-termlib + > patch by Juergen Pfeifer: + + use improved initialization for soft-label keys in Ada95 sample code. + + discard internal symbol _nc_slk_format (unused since 20080112). + + move call of slk_paint_info() from _nc_slk_initialize() to + slk_intern_refresh(), improving initialization. + +20080925 + + fix bug in mouse code for GPM from 20080920 changes (reported in + Debian #500103, also Miroslav Lichvar). + +20080920 + + fix shared-library rules for cygwin with tic- and tinfo-libraries. + + fix a memory leak when failure to connect to GPM. + + correct check for notimeout() in wgetch() (report on linux.redhat + newsgroup by FurtiveBertie). + + add an example warning-suppression file for valgrind, + misc/ncurses.supp (based on example from Reuben Thomas) + +20080913 + + change shared-library configuration for OpenBSD, make rpath work. + + build-fixes for using libutf8, e.g., on OpenBSD 3.7 + +20080907 + + corrected fix for --enable-weak-symbols (report by Frederic L W + Meunier). + +20080906 + + corrected gcc options for building shared libraries on IRIX64. + + add configure check for awk programs unable to handle big-strings, + use that to improve the default for --enable-big-strings option. + + makefile-fixes for --enable-weak-symbols (report by Frederic L W + Meunier). + + update test/configure script. + + adapt ifdef's from library to make test/view.c build when mbrtowc() + is unavailable, e.g., with HPUX 10.20. + + add configure check for wcsrtombs, mbsrtowcs, which are used in + test/ncurses.c, and use wcstombs, mbstowcs instead if available, + fixing build of ncursew for HPUX 11.00 + +20080830 + + fixes to make Ada95 demo_panels() example work. + + modify Ada95 'rain' test program to accept keyboard commands like the + C-version. + + modify BeOS-specific ifdef's to build on Haiku (patch by Scott + Mccreary). + + add configure-check to see if the std namespace is legal for cerr + and endl, to fix a build issue with Tru64. + + consistently use NCURSES_BOOL in lib_gen.c + + filter #line's from lib_gen.c + + change delimiter in MKlib_gen.sh from '%' to '@', to avoid + substitution by IBM xlc to '#' as part of its extensions to digraphs. + + update config.guess, config.sub from + http://savannah.gnu.org/projects/config + (caveat - its maintainer removed support for older Linux systems). + +20080823 + + modify configure check for pthread library to work with OSF/1 5.1, + which uses #define's to associate its header and library. + + use pthread_mutexattr_init() for initializing pthread_mutexattr_t, + makes threaded code work on HPUX 11.23 + + fix a bug in demo_menus in freeing menus (cf: 20080804). + + modify configure script for the case where tic library is used (and + possibly renamed) to remove its dependency upon ncurses/ncursew + library (patch by Dr Werner Fink). + + correct manpage for menu_fore() which gave wrong default for + the attribute used to display a selected entry (report by Mike Gran). + + add Eterm-256color, Eterm-88color and rxvt-88color (prompted by + Debian #495815) -TD + +20080816 + + add configure option --enable-weak-symbols to turn on new feature. + + add configure-check for availability of weak symbols. + + modify linkage with pthread library to use weak symbols so that + applications not linked to that library will not use the mutexes, + etc. This relies on gcc, and may be platform-specific (patch by Dr + Werner Fink). + + add note to INSTALL to document limitation of renaming of tic library + using the --with-ticlib configure option (report by Dr Werner Fink). + + document (in manpage) why tputs does not detect I/O errors (prompted + by comments by Samuel Thibault). + + fix remaining warnings from Klocwork report. + +20080804 + + modify _nc_panelhook() data to account for a permanent memory leak. + + fix memory leaks in test/demo_menus + + fix most warnings from Klocwork tool (report by Larry Zhou). + + modify configure script CF_XOPEN_SOURCE macro to add case for + "dragonfly" from xterm #236 changes. + + modify configure script --with-hashed-db to let $LIBS override the + search for the db library (prompted by report by Samson Pierre). + +20080726 + + build-fixes for gcc 4.3.1 (changes to gnat "warnings", and C inlining + thresholds). + +20080713 + + build-fix (reports by Christian Ebert, Funda Wang). + +20080712 + + compiler-warning fixes for Solaris. + +20080705 + + use NCURSES_MOUSE_MASK() in definition of BUTTON_RELEASE(), etc., to + make those work properly with the "--enable-ext-mouse" configuration + (cf: 20050205). + + improve documentation of build-cc options in INSTALL. + + work-around a bug in gcc 4.2.4 on AIX, which does not pass the + -static/-dynamic flags properly to linker, causing test/bs to + not link. + +20080628 + + correct some ifdef's needed for the broken-linker configuration. + + make debugging library's $BAUDRATE feature work for termcap + interface. + + make $NCURSES_NO_PADDING feature work for termcap interface (prompted + by comment on FreeBSD mailing list). + + add screen.mlterm terminfo entry -TD + + improve mlterm and mlterm+pcfkeys terminfo entries -TD + +20080621 + + regenerated html documentation. + + expand manpage description of parameters for form_driver() and + menu_driver() (prompted by discussion with Adam Spragg). + + add null-pointer checks for cur_term in baudrate() and + def_shell_mode(), def_prog_mode() + + fix some memory leaks in delscreen() and wide acs. + +20080614 + + modify test/ditto.c to illustrate multi-threaded use_screen(). + + change CC_SHARED_OPTS from -KPIC to -xcode=pic32 for Solaris. + + add "-shared" option to MK_SHARED_LIB for gcc on Solaris (report + by Poor Yorick). + +20080607 + + finish changes to wgetch(), making it switch as needed to the + window's actual screen when calling wrefresh() and wgetnstr(). That + allows wgetch() to get used concurrently in different threads with + some minor restrictions, e.g., the application should not delete a + window which is being used in a wgetch(). + + simplify mutex's, combining the window- and screen-mutex's. + +20080531 + + modify wgetch() to use the screen which corresponds to its window + parameter rather than relying on SP; some dependent functions still + use SP internally. + + factor out most use of SP in lib_mouse.c, using parameter. + + add internal _nc_keyname(), replacing keyname() to associate with a + particular SCREEN rather than the global SP. + + add internal _nc_unctrl(), replacing unctrl() to associate with a + particular SCREEN rather than the global SP. + + add internal _nc_tracemouse(), replacing _tracemouse() to eliminate + its associated global buffer _nc_globals.tracemse_buf now in SCREEN. + + add internal _nc_tracechar(), replacing _tracechar() to use SCREEN in + preference to the global _nc_globals.tracechr_buf buffer. + +20080524 + + modify _nc_keypad() to make it switch temporarily as needed to the + screen which must be updated. + + wrap cur_term variable to help make _nc_keymap() thread-safe, and + always set the screen's copy of this variable in set_curterm(). + + restore curs_set() state after endwin()/refresh() (report/patch + Miroslav Lichvar) + +20080517 + + modify configure script to note that --enable-ext-colors and + --enable-ext-mouse are not experimental, but extensions from + the ncurses ABI 5. + + corrected manpage description of setcchar() (discussion with + Emanuele Giaquinta). + + fix for adding a non-spacing character at the beginning of a line + (report/patch by Miroslav Lichvar). + 20080503 + modify screen.* terminfo entries using new screen+fkeys to fix overridden keys in screen.rxvt (Debian #478094) -TD @@ -375,7 +607,7 @@ it is not possible to add this information. 20070609 + add test/key_name.c - + add stdscr cases to test/inchs.c and test_inch_wide.c + + add stdscr cases to test/inchs.c and test/inch_wide.c + update test/configure + correct formatting of DEL (0x7f) in _nc_vischar(). + null-terminate result of wunctrl(). @@ -596,7 +828,7 @@ it is not possible to add this information. shared libraries on Darwin (report by Michail Vidiassov). 20070210 - + add test/inchs.c, test_inch_wide.c, to test win_wchnstr(). + + add test/inchs.c, test/inch_wide.c, to test win_wchnstr(). + remove libdl from library list for termlib (report by Miroslav Lichvar). + fix configure.in to allow --without-progs --with-termlib (patch by diff --git a/TO-DO b/TO-DO index 22acd0f1f3c6..ca47d02d0ec8 100644 --- a/TO-DO +++ b/TO-DO @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------- --- Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. -- +-- Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: TO-DO,v 1.49 2007/02/03 16:29:17 tom Exp $ +-- $Id: TO-DO,v 1.51 2008/10/11 19:22:27 tom Exp $ ------------------------------------------------------------------------------- SHORT-TERM TO-DO ITEMS: @@ -61,6 +61,17 @@ Known Problems: + vid_attr() should support the set_a_attributes (sgr1) string, but does not. There appear to be no terminals that require that functionality. ++ the configure --disable-ext-funcs option does not work for Ada95 tree. + ++ the --with-pthread configuration builds for Cygwin, but does not work + properly (test/worm.c shows all of the worms in the same location). + ++ the --enable-rpath configure option builds for the corresponding platforms; + however combining it with --with-ticlib and --with-termlib does not always + produce libraries that can be run without setting environment variables. + Building those with libtool does not work either. (This is a problem with + the BSD platforms). + Portability (or lack thereof): + Users of older System V UNIXes (but not Solaris, and probably not SVr4) may diff --git a/aclocal.m4 b/aclocal.m4 index faba48922c24..4c8e818f2403 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -28,7 +28,7 @@ dnl*************************************************************************** dnl dnl Author: Thomas E. Dickey 1995-on dnl -dnl $Id: aclocal.m4,v 1.447 2008/04/12 23:49:55 tom Exp $ +dnl $Id: aclocal.m4,v 1.470 2008/10/25 22:15:32 tom Exp $ dnl Macros used in NCURSES auto-configuration script. dnl dnl These macros are maintained separately from NCURSES. The copyright on @@ -261,6 +261,28 @@ if test -n "$1" ; then fi ])dnl dnl --------------------------------------------------------------------------- +dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59 +dnl ------------------ +dnl Append to a search-list for a nonstandard header/lib-file +dnl $1 = the variable to return as result +dnl $2 = the package name +dnl $3 = the subdirectory, e.g., bin, include or lib +dnl $4 = the directory under which we will test for subdirectories +dnl $5 = a directory that we do not want $4 to match +AC_DEFUN([CF_ADD_SUBDIR_PATH], +[ +test "$4" != "$5" && \ +test -d "$4" && \ +ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) { + test -n "$verbose" && echo " ... testing for $3-directories under $4" + test -d $4/$3 && $1="[$]$1 $4/$3" + test -d $4/$3/$2 && $1="[$]$1 $4/$3/$2" + test -d $4/$3/$2/$3 && $1="[$]$1 $4/$3/$2/$3" + test -d $4/$2/$3 && $1="[$]$1 $4/$2/$3" + test -d $4/$2/$3/$2 && $1="[$]$1 $4/$2/$3/$2" +} +])dnl +dnl --------------------------------------------------------------------------- dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34 dnl ---------------- dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' @@ -331,6 +353,30 @@ You have the following choices: fi ])dnl dnl --------------------------------------------------------------------------- +dnl CF_AWK_BIG_PRINTF version: 2 updated: 2008/10/04 17:16:18 +dnl ----------------- +dnl Check if awk can handle big strings using printf. Some older versions of +dnl awk choke on large strings passed via "%s". +dnl +dnl $1 = desired string size +dnl $2 = variable to set with result +AC_DEFUN([CF_AWK_BIG_PRINTF], +[ + case x$AWK in #(vi + x) + eval $2=no + ;; + *) #(vi + if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' \ + | $AWK '{ printf "%d\n", length([$]0); }' | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then + eval $2=yes + else + eval $2=no + fi + ;; + esac +])dnl +dnl --------------------------------------------------------------------------- dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18 dnl ------------ dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some @@ -649,13 +695,14 @@ if test ".$system_name" != ".$cf_cv_system_name" ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CHECK_ERRNO version: 9 updated: 2001/12/30 18:03:23 +dnl CF_CHECK_ERRNO version: 10 updated: 2008/08/22 16:33:22 dnl -------------- dnl Check for data that is usually declared in or , e.g., dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it dnl ourselves. dnl dnl $1 = the name to check +dnl $2 = the assumed type AC_DEFUN([CF_CHECK_ERRNO], [ AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[ @@ -666,7 +713,7 @@ AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[ #include #include #include ], - [long x = (long) $1], + ifelse($2,,int,$2) x = (ifelse($2,,int,$2)) $1, [cf_cv_dcl_$1=yes], [cf_cv_dcl_$1=no]) ]) @@ -677,7 +724,7 @@ if test "$cf_cv_dcl_$1" = no ; then fi # It's possible (for near-UNIX clones) that the data doesn't exist -CF_CHECK_EXTERN_DATA($1,int) +CF_CHECK_EXTERN_DATA($1,ifelse($2,,int,$2)) ])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23 @@ -920,6 +967,20 @@ if test "$with_no_leaks" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- +dnl CF_ENABLE_RPATH version: 1 updated: 2008/09/13 10:22:30 +dnl --------------- +dnl Check if the rpath option should be used, setting cache variable +dnl cf_cv_ld_rpath if so. +AC_DEFUN([CF_ENABLE_RPATH], +[ +AC_MSG_CHECKING(if rpath option should be used) +AC_ARG_ENABLE(rpath, +[ --enable-rpath use rpath option when generating shared libraries], +[cf_cv_ld_rpath=$enableval], +[cf_cv_ld_rpath=no]) +AC_MSG_RESULT($cf_cv_ld_rpath) +])dnl +dnl --------------------------------------------------------------------------- dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39 dnl -------- dnl Check if 'errno' is declared in @@ -958,6 +1019,118 @@ AC_MSG_RESULT($cf_result) CXXFLAGS="$cf_save_CXXFLAGS" ]) dnl --------------------------------------------------------------------------- +dnl CF_FIND_LINKAGE version: 12 updated: 2007/07/29 20:13:53 +dnl --------------- +dnl Find a library (specifically the linkage used in the code fragment), +dnl searching for it if it is not already in the library path. +dnl See also CF_ADD_SEARCHPATH. +dnl +dnl Parameters (4-on are optional): +dnl $1 = headers for library entrypoint +dnl $2 = code fragment for library entrypoint +dnl $3 = the library name without the "-l" option or ".so" suffix. +dnl $4 = action to perform if successful (default: update CPPFLAGS, etc) +dnl $5 = action to perform if not successful +dnl $6 = module name, if not the same as the library name +dnl $7 = extra libraries +dnl +dnl Sets these variables: +dnl $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found +dnl $cf_cv_header_path_$3 - include-directory if needed +dnl $cf_cv_library_path_$3 - library-directory if needed +dnl $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3 +AC_DEFUN([CF_FIND_LINKAGE],[ + +# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these +# will be set on completion of the AC_TRY_LINK below. +cf_cv_header_path_$3= +cf_cv_library_path_$3= + +CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)]) + +AC_TRY_LINK([$1],[$2], + cf_cv_find_linkage_$3=yes,[ + cf_cv_find_linkage_$3=no + + CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)]) + + cf_save_CPPFLAGS="$CPPFLAGS" + cf_test_CPPFLAGS="$CPPFLAGS" + + CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6])) + for cf_cv_header_path_$3 in $cf_search + do + if test -d $cf_cv_header_path_$3 ; then + CF_VERBOSE(... testing $cf_cv_header_path_$3) + CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3" + AC_TRY_COMPILE([$1],[$2],[ + CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3) + cf_cv_find_linkage_$3=maybe + cf_test_CPPFLAGS="$CPPFLAGS" + break],[ + CPPFLAGS="$cf_save_CPPFLAGS" + ]) + fi + done + + if test "$cf_cv_find_linkage_$3" = maybe ; then + + CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)]) + + cf_save_LIBS="$LIBS" + cf_save_LDFLAGS="$LDFLAGS" + + ifelse([$6],,,[ + CPPFLAGS="$cf_test_CPPFLAGS" + LIBS="-l$3 $7 $cf_save_LIBS" + AC_TRY_LINK([$1],[$2],[ + CF_VERBOSE(... found $3 library in system) + cf_cv_find_linkage_$3=yes]) + CPPFLAGS="$cf_save_CPPFLAGS" + LIBS="$cf_save_LIBS" + ]) + + if test "$cf_cv_find_linkage_$3" != yes ; then + CF_LIBRARY_PATH(cf_search,$3) + for cf_cv_library_path_$3 in $cf_search + do + if test -d $cf_cv_library_path_$3 ; then + CF_VERBOSE(... testing $cf_cv_library_path_$3) + CPPFLAGS="$cf_test_CPPFLAGS" + LIBS="-l$3 $7 $cf_save_LIBS" + LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3" + AC_TRY_LINK([$1],[$2],[ + CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3) + cf_cv_find_linkage_$3=yes + cf_cv_library_file_$3="-l$3" + break],[ + CPPFLAGS="$cf_save_CPPFLAGS" + LIBS="$cf_save_LIBS" + LDFLAGS="$cf_save_LDFLAGS" + ]) + fi + done + LIBS="$cf_save_LIBS" + CPPFLAGS="$cf_save_CPPFLAGS" + LDFLAGS="$cf_save_LDFLAGS" + fi + + else + cf_cv_find_linkage_$3=no + fi + ],$7) + +if test "$cf_cv_find_linkage_$3" = yes ; then +ifelse([$4],,[ + CF_ADD_INCDIR($cf_cv_header_path_$3) + CF_ADD_LIBDIR($cf_cv_library_path_$3) + LIBS="-l$3 $LIBS" +],[$4]) +else +ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5]) +fi +])dnl +dnl --------------------------------------------------------------------------- dnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45 dnl ------------- dnl Test for dlsym() and related functions, as well as libdl. @@ -1278,7 +1451,7 @@ if test "$GCC" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_GCC_WARNINGS version: 22 updated: 2007/07/29 09:55:12 +dnl CF_GCC_WARNINGS version: 23 updated: 2008/07/26 17:54:02 dnl --------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: @@ -1373,7 +1546,7 @@ then ;; Winline) #(vi case $GCC_VERSION in - 3.3*) + [[34]].*) CF_VERBOSE(feature is broken in gcc $GCC_VERSION) continue;; esac @@ -1715,7 +1888,7 @@ fi ]) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_HASHED_DB_LIBS version: 7 updated: 2007/12/01 15:01:37 +dnl CF_HASHED_DB_LIBS version: 8 updated: 2008/08/04 06:18:06 dnl ----------------- dnl Given that we have the header and version for hashed database, find the dnl library information. @@ -1723,7 +1896,7 @@ AC_DEFUN([CF_HASHED_DB_LIBS], [ AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[ cf_cv_hashed_db_libs=unknown -for cf_db_libs in db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db '' +for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db '' do cf_save_libs="$LIBS" if test -n "$cf_db_libs"; then @@ -1823,6 +1996,27 @@ $ac_includes_default ]) done ]) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59 +dnl -------------- +dnl Construct a search-list for a nonstandard header-file +AC_DEFUN([CF_HEADER_PATH], +[CF_SUBDIR_PATH($1,$2,include) +test "$includedir" != NONE && \ +test "$includedir" != "/usr/include" && \ +test -d "$includedir" && { + test -d $includedir && $1="[$]$1 $includedir" + test -d $includedir/$2 && $1="[$]$1 $includedir/$2" +} + +test "$oldincludedir" != NONE && \ +test "$oldincludedir" != "/usr/include" && \ +test -d "$oldincludedir" && { + test -d $oldincludedir && $1="[$]$1 $oldincludedir" + test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2" +} + ])dnl dnl --------------------------------------------------------------------------- dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23 @@ -1949,7 +2143,7 @@ ifdef([AC_FUNC_FSEEKO],[ ]) ]) dnl --------------------------------------------------------------------------- -dnl CF_LDFLAGS_STATIC version: 2 updated: 2007/04/28 15:25:27 +dnl CF_LDFLAGS_STATIC version: 4 updated: 2008/10/18 17:58:20 dnl ----------------- dnl Check for compiler/linker flags used to temporarily force usage of static dnl libraries. This depends on the compiler and platform. Use this to help @@ -1958,8 +2152,16 @@ dnl the list of linker options and libraries. AC_DEFUN([CF_LDFLAGS_STATIC],[ if test "$GCC" = yes ; then - LDFLAGS_STATIC=-static - LDFLAGS_SHARED=-dynamic + case $cf_cv_system_name in #( + OS/2*|os2*|aix[[45]]*) #( vi + LDFLAGS_STATIC= + LDFLAGS_SHARED= + ;; + *) #( normally, except when broken + LDFLAGS_STATIC=-static + LDFLAGS_SHARED=-dynamic + ;; + esac else case $cf_cv_system_name in #( aix[[45]]*) #( from ld manpage @@ -1991,43 +2193,30 @@ AC_SUBST(LDFLAGS_STATIC) AC_SUBST(LDFLAGS_SHARED) ]) dnl --------------------------------------------------------------------------- -dnl CF_LIBUTF8 version: 2 updated: 2002/01/19 22:51:32 -dnl ---------- -dnl Check for libutf8 -AC_DEFUN([CF_LIBUTF8], -[ -AC_CACHE_CHECK(for putwc in libutf8,cf_cv_libutf8,[ - cf_save_LIBS="$LIBS" - LIBS="-lutf8 $LIBS" -AC_TRY_LINK([ -#include ],[putwc(0,0);], - [cf_cv_libutf8=yes], - [cf_cv_libutf8=no]) - LIBS="$cf_save_LIBS" -]) - -if test "$cf_cv_libutf8" = yes ; then - AC_DEFINE(HAVE_LIBUTF8_H) - LIBS="-lutf8 $LIBS" -fi -])dnl +dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59 +dnl --------------- +dnl Construct a search-list for a nonstandard library-file +AC_DEFUN([CF_LIBRARY_PATH], +[CF_SUBDIR_PATH($1,$2,lib)])dnl dnl --------------------------------------------------------------------------- -dnl CF_LIB_PREFIX version: 7 updated: 2001/01/12 01:23:48 +dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16 dnl ------------- dnl Compute the library-prefix for the given host system dnl $1 = variable to set AC_DEFUN([CF_LIB_PREFIX], [ - case $cf_cv_system_name in - OS/2*) LIB_PREFIX='' ;; - os2*) LIB_PREFIX='' ;; - *) LIB_PREFIX='lib' ;; + case $cf_cv_system_name in #(vi + OS/2*|os2*) #(vi + LIB_PREFIX='' + ;; + *) LIB_PREFIX='lib' + ;; esac ifelse($1,,,[$1=$LIB_PREFIX]) AC_SUBST(LIB_PREFIX) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_LIB_RULES version: 50 updated: 2007/03/24 18:26:59 +dnl CF_LIB_RULES version: 53 updated: 2008/09/20 19:51:59 dnl ------------ dnl Append definitions and rules for the given models to the subdirectory dnl Makefiles, and the recursion rule for the top-level Makefile. If the @@ -2044,6 +2233,12 @@ AC_DEFUN([CF_LIB_RULES], [ CF_LIB_PREFIX(cf_prefix) AC_REQUIRE([CF_SUBST_NCURSES_VERSION]) + +if test $cf_cv_shlib_version = cygdll ; then + TINFO_NAME=$TINFO_ARG_SUFFIX + TINFO_SUFFIX=.dll +fi + for cf_dir in $SRC_SUBDIRS do if test ! -d $srcdir/$cf_dir ; then @@ -2054,7 +2249,7 @@ do LIBS_TO_MAKE= for cf_item in $cf_LIST_MODELS do - CF_LIB_SUFFIX($cf_item,cf_suffix) + CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf) if test $cf_item = shared ; then if test "$cf_cv_do_symlinks" = yes ; then case "$cf_cv_shlib_version" in #(vi @@ -2096,7 +2291,8 @@ do # use autodetected ${cf_prefix} for import lib and static lib, but # use 'cyg' prefix for shared lib. if test $cf_cv_shlib_version = cygdll ; then - LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}\${ABI_VERSION}.dll" + cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'` + LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}${cf_cygsuf}" continue fi fi @@ -2106,24 +2302,28 @@ do if test $cf_dir = ncurses ; then cf_subsets="$LIB_SUBSETS" cf_r_parts="$cf_subsets" + cf_liblist="$LIBS_TO_MAKE" while test -n "$cf_r_parts" do cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'` cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'` if test "$cf_l_parts" != "$cf_r_parts" ; then + cf_item= case $cf_l_parts in #(vi *termlib*) #(vi - cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g` + cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g` ;; *ticlib*) - cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g` + cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g` ;; *) break ;; esac - LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE" + if test -n "$cf_item"; then + LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE" + fi else break fi @@ -2148,7 +2348,7 @@ do do echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})" CF_UPPER(cf_ITEM,$cf_item) - CF_LIB_SUFFIX($cf_item,cf_suffix) + CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf) CF_OBJ_SUBDIR($cf_item,cf_subdir) # Test for case where we build libtinfo with a different name. @@ -2156,22 +2356,21 @@ do if test $cf_dir = ncurses ; then case $cf_subset in *base*) + cf_libname=${cf_libname}$LIB_SUFFIX ;; *termlib*) cf_libname=$TINFO_LIB_SUFFIX - if test -n "${DFT_ARG_SUFFIX}" ; then - # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX - cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"` - fi ;; ticlib*) cf_libname=$TICS_LIB_SUFFIX - if test -n "${DFT_ARG_SUFFIX}" ; then - # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX - cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"` - fi ;; esac + else + cf_libname=${cf_libname}$LIB_SUFFIX + fi + if test -n "${DFT_ARG_SUFFIX}" ; then + # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX + cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"` fi # These dependencies really are for development, not @@ -2480,34 +2679,62 @@ fi ]) ]) dnl --------------------------------------------------------------------------- -dnl CF_LIB_SUFFIX version: 13 updated: 2003/11/01 16:09:07 +dnl CF_LIB_SUFFIX version: 15 updated: 2008/09/13 11:54:48 dnl ------------- dnl Compute the library file-suffix from the given model name dnl $1 = model name -dnl $2 = variable to set +dnl $2 = variable to set (the nominal library suffix) +dnl $3 = dependency variable to set (actual filename) dnl The variable $LIB_SUFFIX, if set, prepends the variable to set. AC_DEFUN([CF_LIB_SUFFIX], [ AC_REQUIRE([CF_SUBST_NCURSES_VERSION]) case $1 in - libtool) $2='.la' ;; - normal) $2='.a' ;; - debug) $2='_g.a' ;; - profile) $2='_p.a' ;; + libtool) + $2='.la' + $3=[$]$2 + ;; + normal) + $2='.a' + $3=[$]$2 + ;; + debug) + $2='_g.a' + $3=[$]$2 + ;; + profile) + $2='_p.a' + $3=[$]$2 + ;; shared) case $cf_cv_system_name in - cygwin*) $2='.dll' ;; - darwin*) $2='.dylib' ;; + cygwin*) + $2='.dll' + $3='.dll.a' + ;; + darwin*) + $2='.dylib' + $3=[$]$2 + ;; hpux*) case $target in - ia64*) $2='.so' ;; - *) $2='.sl' ;; + ia64*) + $2='.so' + $3=[$]$2 + ;; + *) + $2='.sl' + $3=[$]$2 + ;; esac ;; - *) $2='.so' ;; + *) $2='.so' + $3=[$]$2 + ;; esac esac test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}" + test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}" ])dnl dnl --------------------------------------------------------------------------- dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49 @@ -3869,7 +4096,7 @@ define([CF_REMOVE_LIB], $1=`echo "$2" | sed -e 's/-l$3[[ ]]//g' -e 's/-l$3[$]//'` ])dnl dnl --------------------------------------------------------------------------- -dnl CF_RPATH_HACK version: 3 updated: 2007/12/01 11:14:13 +dnl CF_RPATH_HACK version: 4 updated: 2008/09/13 12:53:26 dnl ------------- AC_DEFUN([CF_RPATH_HACK], [ @@ -3881,48 +4108,46 @@ CF_VERBOSE(...checking LDFLAGS $LDFLAGS) CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS) case "$EXTRA_LDFLAGS" in #(vi -Wl,-rpath,*) #(vi - cf_rpath_hack="-Wl,-rpath," - ;; + cf_rpath_hack="-Wl,-rpath," + ;; -R\ *) - cf_rpath_hack="-R " - ;; + cf_rpath_hack="-R " + ;; -R*) - cf_rpath_hack="-R" - ;; + cf_rpath_hack="-R" + ;; *) - cf_rpath_hack= - ;; + cf_rpath_hack= + ;; esac if test -n "$cf_rpath_hack" ; then - cf_rpath_dst= - for cf_rpath_src in $LDFLAGS - do - CF_VERBOSE(Filtering $cf_rpath_src) - case $cf_rpath_src in #(vi - -L*) #(vi - if test "$cf_rpath_hack" = "-R " ; then - cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e 's%-L%-R %'` - else - cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e s%-L%$cf_rpath_hack%` - fi - CF_VERBOSE(...Filter $cf_rpath_tmp) - EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS" - ;; - *) - cf_rpath_dst="$cf_rpath_dst $cf_rpath_src" - ;; - esac - done - LDFLAGS=$cf_rpath_dst - CF_VERBOSE(...checked LDFLAGS $LDFLAGS) - CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS) + cf_rpath_dst= + for cf_rpath_src in $LDFLAGS + do + CF_VERBOSE(Filtering $cf_rpath_src) + case $cf_rpath_src in #(vi + -L*) #(vi + if test "$cf_rpath_hack" = "-R " ; then + cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e 's%-L%-R %'` + else + cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e s%-L%$cf_rpath_hack%` + fi + CF_VERBOSE(...Filter $cf_rpath_tmp) + EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS" + ;; + esac + cf_rpath_dst="$cf_rpath_dst $cf_rpath_src" + done + LDFLAGS=$cf_rpath_dst + CF_VERBOSE(...checked LDFLAGS $LDFLAGS) + CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS) fi else AC_MSG_RESULT(no) fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_SHARED_OPTS version: 47 updated: 2008/03/23 14:48:54 +dnl CF_SHARED_OPTS version: 53 updated: 2008/10/25 18:14:20 dnl -------------- dnl -------------- dnl Attempt to determine the appropriate CC/LD options for creating a shared @@ -4057,8 +4282,10 @@ CF_EOF # tested with IRIX 5.2 and 'cc'. if test "$GCC" != yes; then CC_SHARED_OPTS='-KPIC' + MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]' + else + MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]' fi - MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]' cf_cv_rm_so_locs=yes ;; linux*|gnu*|k*bsd*-gnu) @@ -4071,13 +4298,22 @@ CF_EOF EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS" fi CF_SHARED_SONAME - MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname',-stats,-lc -o $[@]' + MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]' ;; openbsd[[2-9]].*) + if test "$DFT_LWR_MODEL" = "shared" ; then + LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)" + LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" + fi + if test "$cf_cv_ld_rpath" = yes ; then + cf_ld_rpath_opt="-Wl,-rpath," + EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS" + fi CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC" - MK_SHARED_LIB='${LD} -Bshareable -soname,`basename $[@].${ABI_VERSION}` -o $[@]' + CF_SHARED_SONAME + MK_SHARED_LIB='${CC} ${CFLAGS} -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]' ;; - openbsd*|freebsd[[12]].*) + nto-qnx*|openbsd*|freebsd[[12]].*) CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC" MK_SHARED_LIB='${LD} -Bshareable -o $[@]' test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel @@ -4108,7 +4344,7 @@ CF_EOF fi fi CF_SHARED_SONAME - MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname' -o $[@]' + MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]' else MK_SHARED_LIB='${LD} -Bshareable -o $[@]' fi @@ -4158,9 +4394,7 @@ CF_EOF ;; solaris2*) # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2 - if test "$GCC" != yes; then - CC_SHARED_OPTS='-KPIC' - fi + # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3 if test "$DFT_LWR_MODEL" = "shared" ; then LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}" LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" @@ -4170,7 +4404,12 @@ CF_EOF EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS" fi CF_SHARED_SONAME - MK_SHARED_LIB='${CC} -dy -G -h '$cf_shared_soname' -o $[@]' + if test "$GCC" != yes; then + CC_SHARED_OPTS='-xcode=pic32' + MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]' + else + MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]' + fi ;; sysv5uw7*|unix_sv*) # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc) @@ -4221,9 +4460,9 @@ CF_EOF AC_SUBST(INSTALL_LIB) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_SHARED_SONAME version: 2 updated: 2006/10/21 12:33:41 +dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43 dnl ---------------- -dnl utility macro for CF_SHARED_OPTS, constructs "$cf_shared_soname" for +dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar) dnl option. dnl @@ -4233,9 +4472,9 @@ define([CF_SHARED_SONAME], [ test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1) if test "$cf_cv_shlib_version" = rel; then - cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}' + cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}' else - cf_shared_soname='`basename $[@]`' + cf_cv_shared_soname='`basename $[@]`' fi ]) dnl --------------------------------------------------------------------------- @@ -4607,6 +4846,22 @@ if test "$ac_cv_header_termios_h" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- +dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12 +dnl -------------- +dnl Construct a search-list for a nonstandard header/lib-file +dnl $1 = the variable to return as result +dnl $2 = the package name +dnl $3 = the subdirectory, e.g., bin, include or lib +AC_DEFUN([CF_SUBDIR_PATH], +[$1="" + +CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix) +CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE) +CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix) +CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix) +CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix) +])dnl +dnl --------------------------------------------------------------------------- dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03 dnl -------- dnl Shorthand macro for substituting things that the user may override @@ -4793,6 +5048,32 @@ AC_DEFUN([CF_UPPER], $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` ])dnl dnl --------------------------------------------------------------------------- +dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52 +dnl ----------- +dnl Check for multibyte support, and if not found, utf8 compatibility library +AC_DEFUN([CF_UTF8_LIB], +[ +AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[ + cf_save_LIBS="$LIBS" + AC_TRY_LINK([ +#include ],[putwc(0,0);], + [cf_cv_utf8_lib=yes], + [CF_FIND_LINKAGE([ +#include ],[putwc(0,0);],utf8, + [cf_cv_utf8_lib=add-on], + [cf_cv_utf8_lib=no]) +])]) + +# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between +# ncurses/ncursesw: +if test "$cf_cv_utf8_lib" = "add-on" ; then + AC_DEFINE(HAVE_LIBUTF8_H) + CF_ADD_INCDIR($cf_cv_header_path_utf8) + CF_ADD_LIBDIR($cf_cv_library_path_utf8) + LIBS="-lutf8 $LIBS" +fi +])dnl +dnl --------------------------------------------------------------------------- dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12 dnl ---------- dnl Use AC_VERBOSE w/o the warnings @@ -4851,6 +5132,32 @@ fi ]) ])dnl dnl --------------------------------------------------------------------------- +dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06 +dnl --------------- +dnl Check for compiler-support for weak symbols. +dnl This works with "recent" gcc. +AC_DEFUN([CF_WEAK_SYMBOLS],[ +AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[ + +AC_TRY_COMPILE([ +#include ], +[ +#if defined(__GNUC__) +# if defined __USE_ISOC99 +# define _cat_pragma(exp) _Pragma(#exp) +# define _weak_pragma(exp) _cat_pragma(weak name) +# else +# define _weak_pragma(exp) +# endif +# define _declare(name) __extension__ extern __typeof__(name) name +# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak)) +#endif + +weak_symbol(fopen); +],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no]) +]) +])dnl +dnl --------------------------------------------------------------------------- dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49 dnl ------------------- dnl Allow library's ABI to be overridden. Generally this happens when a @@ -5128,7 +5435,7 @@ AC_SUBST($3)dnl ])dnl dnl --------------------------------------------------------------------------- -dnl CF_WITH_PTHREAD version: 1 updated: 2008/03/29 13:42:21 +dnl CF_WITH_PTHREAD version: 2 updated: 2008/08/23 18:26:05 dnl --------------- dnl Check for POSIX thread library. AC_DEFUN([CF_WITH_PTHREAD], @@ -5143,13 +5450,24 @@ AC_MSG_RESULT($with_pthread) if test "$with_pthread" != no ; then AC_CHECK_HEADER(pthread.h,[ AC_DEFINE(HAVE_PTHREADS_H) - AC_CHECK_LIB(pthread,pthread_create,[ + + AC_MSG_CHECKING(if we can link with the pthread library) + cf_save_LIBS="$LIBS" + LIBS="-lpthread $LIBS" + AC_TRY_LINK([ +#include +],[ + int rc = pthread_create(0,0,0,0); +],[with_pthread=yes],[with_pthread=no]) + LIBS="$cf_save_LIBS" + AC_MSG_RESULT($with_pthread) + + if test "$with_pthread" = yes ; then LIBS="-lpthread $LIBS" AC_DEFINE(HAVE_LIBPTHREADS) - with_pthread=yes - ],[ + else AC_MSG_ERROR(Cannot link with pthread library) - ]) + fi ]) fi ]) @@ -5217,7 +5535,7 @@ CF_NO_LEAKS_OPTION(valgrind, [USE_VALGRIND]) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_XOPEN_SOURCE version: 25 updated: 2007/01/29 18:36:38 +dnl CF_XOPEN_SOURCE version: 26 updated: 2008/07/27 11:26:57 dnl --------------- dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, dnl or adapt to the vendor's definitions to get equivalent functionality, @@ -5237,7 +5555,7 @@ case $host_os in #(vi aix[[45]]*) #(vi CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" ;; -freebsd*) #(vi +freebsd*|dragonfly*) #(vi # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L diff --git a/announce.html.in b/announce.html.in index 84d5bbe127c7..1d4121ee4ff1 100644 --- a/announce.html.in +++ b/announce.html.in @@ -1,8 +1,8 @@ -Announcing ncurses 5.6 +Announcing ncurses 5.7 -

Announcing ncurses 5.6

+

Announcing ncurses 5.7

The ncurses (new curses) library is a free software emulation of curses in System V Release 4.0, and more. It uses terminfo format, @@ -69,185 +69,170 @@ the GNU distribution site

Release Notes

-This release is designed to be upward compatible from ncurses 5.0 through 5.5; +This release is designed to be upward compatible from ncurses 5.0 through 5.6; very few applications will require recompilation, depending on the platform. -These are the highlights from the change-log since ncurses 5.5 release. +These are the highlights from the change-log since ncurses 5.6 release.

Interface changes:

  • generate linkable stubs for some macros:
    - getbegx, getbegy, getcurx, getcury, getmaxx, getmaxy, getparx, - getpary, getpary, -
    - and (for libncursesw) -
    - wgetbkgrnd + getattrs
New features and improvements:
  • library
      -
    • support hashed databases for the terminal descriptions. - This uses the Berkeley database, has been tested for - several versions on different platforms. +
    • new flavor of the ncurses library provides rudimentary + support for POSIX threads. Several functions are + reentrant, but most require either a window-level or + screen-level mutex.
      + (This is API-compatible, + but not ABI-compatible with the normal library). -
    • add use_legacy_coding() function to support - lynx's font-switching feature. +
    • add NCURSES_OPAQUE symbol to curses.h, will + use to make structs opaque in selected configurations. -
    • add extension nofilter(), to cancel a prior - filter() call. +
    • add NCURSES_EXT_FUNCS and + NCURSES_EXT_COLORS symbols to curses.h to make + it simpler to tell if the extended functions and/or colors + are declared. -
    • add/install a package config script, e.g., - ncurses5-config or - ncursesw5-config, according to - configuration options. +
    • add wresize() to C++ binding -
    • provide ifdef for NCURSES_NOMACROS which - suppresses most macro definitions from curses.h, i.e., - where a macro is defined to override a function to improve - performance. +
    • eliminate fixed-buffer vsprintf() calls in C++ binding. -
    • make ifdef's consistent in curses.h for the - extended colors so the header file can be used for the - normal curses library. The header file installed for - extended colors is a variation of the wide-character - configuration. +
    • add several functions to C++ binding which wrap C functions + that pass a WINDOW* parameter. -
    • improve tgetstr() by making the return value - point into the user's buffer, if provided. +
    • adapt mouse-handling code from menu library in form-library -
    • add ifdef's allowing ncurses to be built with - tparm() using either varargs (the existing - status), or using a fixed-parameter list (to match X/Open). +
    • improve tracing for form library, showing created forms, + fields, etc. -
    • widen the test for xterm kmous a little to - allow for other - strings than "\E[M", e.g., for xterm-sco - functionality in xterm. +
    • make $NCURSES_NO_PADDING feature work for termcap interface . -
    • modify wgetnstr() to return - KEY_RESIZE if a sigwinch occurs. +
    • add check to trace-file open, if the given name is a + directory, add ".log" to the name and try again. -
    • move prototypes for wide-character trace functions from - curses.tail to curses.wide to avoid accidental reference to - those if _XOPEN_SOURCE_EXTENDED is defined - without ensuring that <wchar.h> is included. - -
    • change the way shared libraries (other than libtool) are - installed. Rather than copying the build-tree's libraries, - link the shared objects into the install directory. This - makes the --with-rpath option work except with - $(DESTDIR). - -
    • several improvements for rendering in hpterm. These are - only available if the library is configured using - --enable-xmc-glitch. - -
    • Add NCURSES_NO_HARD_TABS and - NCURSES_NO_MAGIC_COOKIE environment variables - to allow runtime suppression of the related hard-tabs and - xmc-glitch features. +
    • several new manpages: curs_legacy.3x, curs_memleaks.3x, + curs_opaque.3x and curs_threads.3x
  • programs:
      -
    • add new test programs: chgat.c, demo_altkeys.c, - echochar.c, foldkeys.c, movewindow.c, redraw.c, (noting - that existing test programs also were modified to test - additional features). +
    • modified three test-programs to demonstrate the threading + support in this version: ditto, rain, worm. -
    • modify tack to test extended capability function-key - strings. +
    • several new test-programs: demo_panels, dots_mvcur, + inch_wide, inchs, key_name, key_names, savescreen, + savescreen.sh test_arrays, test_get_wstr, test_getstr, + test_instr, test_inwstr and test_opaque. -
    • modify toe to access termcap data, e.g., via cgetent() - functions, or as a text file if those are not available. +
    • add adacurses-config to the Ada95 install. -
    • improve infocmp/tic -f option formatting. +
    • modify tic -f option to format spaces as + \s to prevent them from being lost when that + is read back in unformatted strings. -
    • add toe -a option, to show all databases. - This uses new private interfaces in the ncurses library for - iterating through the list of databases. - -
    • modify MKfallback.sh to use - tic -x when constructing fallback tables to - allow extended capabilities to be retrieved from a fallback entry. +
    • The tack program is now distributed separately + from ncurses.
  • terminal database
      -
    • add terminfo entries for xfce terminal (xfce) and multi gnome terminal (mgt) -
    • add nsterm-16color entry -
    • updated mlterm terminfo entry -
    • add kon, kon2 and jfbterm terminfo entry -
    • remove invis capability from klone+sgr, mainly used by linux entry, since it does not really do this -
    • add ka2, kb1, kb3, kc2 to vt220-keypad as an extension -
    • add shifted up/down arrow codes to xterm-new as kind/kri strings -
    • add hpterm-color terminfo entry -
    • add 256color variants of terminfo entries for programs which are reported to implement this feature -
    • correct order of use-clauses in rxvt-basic entry which made codes for f1-f4 vt100-style rather than vt220-style. +
    • added entries: +
        +
      • Eterm-256color, + Eterm-88color and + rxvt-88color +
      • aterm +
      • konsole-256color +
      • mrxvt +
      • screen.mlterm +
      • screen.rxvt +
      • teraterm4.59 is now the primary primary + teraterm entry, renamed original to + teraterm2.3 +
      • 9term terminal +
      • Newbury Data entries +
      +
    • updated/improved entries: +
        +
      • gnome to version 2.22.3 +
      • h19, z100 +
      • konsole to version 1.6.6 +
      • mlterm, mlterm+pcfkeys +
      • xterm, and building-blocks for function-keys + to xterm patch #230. +
Major bug fixes:
    -
  • correct a typo in configure --with-bool option for the - case where --without-cxx is used. +
  • add logic to tic for cancelling strings in user-defined + capabilities + (this is needed for + current konsole terminfo entry). -
  • move assignment from environment variable ESCDELAY - from initscr() down to newterm() so the - environment variable affects timeouts for terminals opened with - newterm() as well. +
  • modify mk-1st.awk so the generated makefile rules for + linking or installing shared libraries do not first remove the + library, in case it is in use, e.g., libncurses.so by + /bin/sh. -
  • modify werase to clear multicolumn characters that - extend into a derived window. +
  • correct check for notimeout() in wgetch(). -
  • modify wchgat() to mark updated cells as changed so a - refresh will repaint those cells. +
  • fix a sign-extension bug in infocmp's repair_acsc() function. -
  • correct logic in wadd_wch() and - wecho_wch(), which did not guard against passing the - multi-column attribute into a call on waddch(), e.g., - using data returned by win_wch() +
  • change winnstr() to stop at the end of the line. -
  • fix redrawing of windows other than stdscr using - wredrawln() by touching the corresponding rows in - curscr. +
  • make Ada95 demo_panels() example work. -
  • reduce memory leaks in repeated calls to tgetent() by - remembering the last TERMINAL* value allocated to hold - the corresponding data and freeing that if the - tgetent() result buffer is the same as the previous - call. +
  • fix for adding a non-spacing character at the beginning of a line. -
  • modify read_termtype() so the term_names - data is always allocated as part of the str_table, a - better fix for a memory leak. +
  • fill in extended-color pair to make colors work + for wide-characters using extended-colors. -
  • fix wins_nwstr(), which did not handle single-column - non-8bit codes. +
  • improve refresh of window on top of multi-column characters, + taking into account split characters on left/right window + boundaries. -
  • modify wbkgrnd() to avoid clearing the - A_CHARTEXT attribute bits since those record the state - of multicolumn characters. +
  • modify win_wchnstr() to ensure that only a base cell + is returned for each multi-column character. -
  • improve SIGWINCH handling by postponing its effect - during newterm(), etc., when allocating screens. +
  • improve waddch() and winsch() handling of + EILSEQ from mbrtowc() by using unctrl() + to display illegal bytes rather than trying to append further bytes + to make up a valid sequence. -
  • remove 970913 feature for copying subwindows as they are moved in - mvwin(). +
  • restore curs_set() state after + endwin()/refresh() -
  • add checks in waddchnstr() and - wadd_wchnstr() to stop copying when a null character - is found. +
  • modify keyname() to use "^X" form only if + meta() has been called, or if keyname() + is called without initializing curses, e.g., via + initscr() or newterm(). -
  • add some checks to ensure current position is within scrolling - region before scrolling on a new line. +
  • modify unctrl() to check codes in 128-255 range versus + isprint(). + If they are not printable, and locale was set, use a "M-" or "~" + sequence. -
  • add a workaround to ACS mapping to allow applications such as - test/blue.c to use the "PC ROM" characters by masking them with - A_ALTCHARSET. This worked up til 5.5, but was lost in the revision - of legacy coding. +
  • improve resizeterm() by moving ripped-off lines, and + repainting the soft-keys. + +
  • modify form library to accept control characters such as newline + in set_field_buffer(), which is compatible with Solaris. + +
  • use NCURSES_MOUSE_MASK() in definition of + BUTTON_RELEASE(), etc., to make those work properly + with the --enable-ext-mouse configuration + +
  • correct some functions in Ada95 binding which were using return + value from C where none was returned. + +
  • reviewed/fixed issues reported by Coverity and Klocwork tools.
Portability: @@ -257,110 +242,115 @@ Portability:
  • new options:
    -
    --with-hashed-db -
    Use Berkeley hashed database for storing terminfo data rather than storing - each compiled entry in a separate binary file within a directory - tree. +
    --disable-big-strings +
    control whether static string tables are generated as single + large strings (to improve startup performance), or as array + of individual strings. -
    --without-dlsym -
    Do not use dlsym() to load GPM dynamically. +
    --disable-relink +
    control whether shared libraries are relinked (during install) + when rpath is enabled. -
    --with-valgrind -
    Simplify building for testing with valgrind. +
    --disable-tic-depends +
    make explicit whether tic library depends on ncurses/ncursesw + library. -
    --enable-wgetch-events -
    Compile with experimental wgetch-events code. +
    --enable-mixed-case +
    override the configure script's check if the filesystem + supports mixed-case filenames. + This allows one to control how the terminal database + maps to the filesystem. + For filesystems that do not support mixed-case, the library + uses generate 2-character (hexadecimal) codes for the + lower-level of the filesystem terminfo database -
    --enable-signed-char -
    Store booleans in "signed char" rather than "char". +
    --enable-reentrant +
    builds a different flavor of the ncurses library (ncursest) + which improves reentrant use of the + library by reducing global and static variables + (see the "--with-pthread" option for the threaded support). + +
    --enable-weak-symbols +
    use weak-symbols for linking to the POSIX thread library, + and use the same soname for the ncurses shared library + as the normal library (caveat: the ABI is for the threaded + library, which makes global data accessed via functions). + +
    --with-pthread +
    build with the POSIX thread library (tested with AIX, + Linux, FreeBSD, OpenBSD, HPUX, IRIX64, Solaris, Tru64). + +
    --with-ticlib +
    build/install the tic-support functions in a separate library
  • improved options:
    -
    --disable-largefile -
    make the option work both ways. +
    --enable-ext-colors +
    requires the wide-character configuration. -
    --with-gpm -
    The option now accepts a parameter, - i.e., the name of the dynamic GPM library to load via - dlopen() +
    --with-chtype +
    ignore option value "unsigned" is always added to + the type in curses.h; do the same for --with-mmask-t. -
    --disable-symlinks -
    The option now allows one to - disable symlink() in tic even when - link() does not work. +
    --with-dmalloc +
    build-fix for redefinition of strndup. + +
    --with-hashed-db +
    accepts a parameter which is the install-prefix of a given + Berkeley Database. + +
    --with-hashed-db +
    the $LIBS environment variable overrides the search for the db + library. + +
    --without-hashed-db +
    assumed when "--disable-database" is used.
    -
  • other configure/build issues:
    • remove special case for - Darwin in CF_XOPEN_SOURCE configure macro. - -
    • add configure check to ensure that SIGWINCH is - defined on platforms such as OS X which exclude that when - _XOPEN_SOURCE, etc., are defined - -
    • use ld's -search_paths_first option on Darwin - to work around odd search rules on that platform. - -
    • improve ifdef's for _POSIX_VDISABLE in tset to - work with Mac OS X. - -
    • modify configure script to ensure that if the C compiler is - used rather than the loader in making shared libraries, the - $(CFLAGS) variable is also used. - -
    • use ${CC} rather than ${LD} in - shared library rules for IRIX64, Solaris to help ensure - that initialization sections are provided for extra linkage - requirements, e.g., of C++ applications. - -
    • improve some shared-library configure scripting for Linux, - FreeBSD and NetBSD to make - --with-shlib-version work. - -
    • split up dependency of names.c and - codes.c in ncurses/Makefile to - work with parallel make. - -
    • modify MKlib_gen.sh to change - preprocessor-expanded _Bool back to bool. - -
    • modify progs/Makefile.in to make - tput init work properly with cygwin, - i.e., do not pass a .exe in the reference - string used in check_aliases. +
    • other configure/build issues: +
        +
      • build-fixes for LynxOS +
      • modify shared-library rules to allow FreeBSD 3.x to use rpath. +
      • build-fix for FreeBSD "contemporary" TTY interface. +
      • build-fixes for AIX with libtool. +
      • build-fixes for Darwin and libtool. +
      • modify BeOS-specific ifdef's to build on Haiku. +
      • corrected gcc options for building shared libraries on Solaris + and IRIX64. +
      • change shared-library configuration for OpenBSD, make rpath work. +
      • build-fixes for using libutf8, e.g., on OpenBSD 3.7 +
      • add "-e" option in ncurses/Makefile.in when generating source-files + to force earlier exit if the build environment fails unexpectedly. +
      • add support for shared libraries for QNX. +
      • change delimiter in MKlib_gen.sh from '%' to '@', to + avoid substitution by IBM xlc to '#' as part of its extensions to + digraphs.
    • library:
        -
      • ignore wide-acs line-drawing characters that - wcwidth() claims are not one-column. This is - a workaround for Solaris' broken locale support. - -
      • reduce name-pollution in term.h by removing - #define's for HAVE_xxx symbols. - -
      • fix #ifdef in c++/internal.h for - QNX 6.1 +
      • rewrite wrapper for wcrtomb(), making it work on + Solaris. This is used in the form library to determine the length + of the buffer needed by field_buffer. +
      • add/use configure script macro CF_SIG_ATOMIC_T, use the corresponding + type for data manipulated by signal handlers. +
      • set locale in misc/ncurses-config.in since it uses a range +
      • disable GPM mouse support when $TERM does not happen to contain + "linux", since Gpm_Open() no longer limits its assertion to terminals + that it might handle, e.g., within "screen" in xterm. +
      • reset mouse file-descriptor when unloading GPM library.
      -
    • test programs:
      • modify test/configure script - to allow building test programs with PDCurses/X11. - -
      • modified test programs to allow some to work with NetBSD - curses. Several do not because NetBSD curses implements a - subset of X/Open curses, and also lacks much of SVr4 - additions. But it is enough for comparison. - -
      • improved test/configure to build test/ncurses - on HPUX 11 using the vendor curses. - -
      • change configure script to produce - test/Makefile from data file. +
      • test programs: +
          +
        • update test programs to build/work with various UNIX curses for + comparisons.
      @@ -410,6 +400,8 @@ and define_key() allow you to better control the use of function keys, e.g., disabling the ncurses KEY_MOUSE, or by defining more than one control sequence to map to a given key code. +
    • Support for 256-color terminals, such as modern xterm, when configured +using the --enable-ext-colors option.
    • Support for 16-color terminals, such as aixterm and modern xterm.
    • Better cursor-movement optimization. The package now features a cursor-local-movement computation more efficient than either BSD's @@ -513,14 +505,10 @@ for similar applications on GNU/Linux.
      pinfo
      Lynx-like info browser. -http://dione.ids.pl/~pborys/software/pinfo/ +https://alioth.debian.org/projects/pinfo/
      tin
      newsreader, supporting color, MIME http://www.tin.org/ -
      vh-1.6 -
      Volks-Hypertext browser for the Jargon File -
      -http://www.debian.org/Packages/unstable/text/vh.html as well as some that use ncurses for the terminfo support alone:
      diff --git a/form/form.priv.h b/form/form.priv.h index e8617f1d5747..fea627d30d7d 100644 --- a/form/form.priv.h +++ b/form/form.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -30,7 +30,7 @@ * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ -/* $Id: form.priv.h,v 0.26 2006/12/17 19:47:09 tom Exp $ */ +/* $Id: form.priv.h,v 0.27 2008/09/08 20:29:05 tom Exp $ */ #ifndef FORM_PRIV_H #define FORM_PRIV_H 1 @@ -39,8 +39,6 @@ #include "mf_common.h" #if USE_WIDEC_SUPPORT -#include - #if HAVE_WCTYPE_H #include #endif diff --git a/form/frm_def.c b/form/frm_def.c index c2044a39dccd..e6897514ffdd 100644 --- a/form/frm_def.c +++ b/form/frm_def.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -32,7 +32,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_def.c,v 1.22 2007/10/13 19:31:17 tom Exp $") +MODULE_ID("$Id: frm_def.c,v 1.23 2008/08/04 00:07:55 tom Exp $") /* this can't be readonly */ static FORM default_form = @@ -234,8 +234,16 @@ Connect_Fields(FORM *form, FIELD **fields) fields[j]->page = page_nr; fld = Insert_Field_By_Position(fields[j], fld); } - form->page[page_nr].smin = fld->index; - form->page[page_nr].smax = fld->sprev->index; + if (fld) + { + form->page[page_nr].smin = fld->index; + form->page[page_nr].smax = fld->sprev->index; + } + else + { + form->page[page_nr].smin = 0; + form->page[page_nr].smax = 0; + } } RETURN(E_OK); } diff --git a/form/frm_driver.c b/form/frm_driver.c index 0c0912576dbb..94323ed27788 100644 --- a/form/frm_driver.c +++ b/form/frm_driver.c @@ -32,7 +32,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_driver.c,v 1.86 2008/01/19 20:11:03 tom Exp $") +MODULE_ID("$Id: frm_driver.c,v 1.88 2008/10/18 16:25:00 tom Exp $") /*---------------------------------------------------------------------------- This is the core module of the form library. It contains the majority @@ -4176,7 +4176,7 @@ form_driver(FORM *form, int c) NULL /* Choice Request is generic */ }; size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0])); - size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff; + size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */ if ((method >= nMethods) || !(BI->cmd)) res = E_SYSTEM_ERROR; @@ -4333,15 +4333,6 @@ set_field_buffer(FIELD *field, int buffer, const char *value) len = Buffer_Length(field); - if (buffer == 0) - { - for (i = 0; (value[i] != '\0') && (i < len); ++i) - { - if (iscntrl(UChar(value[i]))) - RETURN(E_BAD_ARGUMENT); - } - } - if (Growable(field)) { /* for a growable field we must assume zero terminated strings, because @@ -4356,14 +4347,6 @@ set_field_buffer(FIELD *field, int buffer, const char *value) * field->cols)))) RETURN(E_SYSTEM_ERROR); - /* in this case we also have to check, whether or not the remaining - characters in value are also printable for buffer 0. */ - if (buffer == 0) - { - for (i = len; i < vlen; i++) - if (iscntrl(UChar(value[i]))) - RETURN(E_BAD_ARGUMENT); - } len = vlen; } } @@ -4376,6 +4359,13 @@ set_field_buffer(FIELD *field, int buffer, const char *value) * There should be a better way, but this handles nonspacing characters * and other special cases that we really do not want to handle here. */ +#if NCURSES_EXT_FUNCS + if (wresize(field->working, field->drows, field->dcols) == ERR) +#endif + { + delwin(field->working); + field->working = newpad(field->drows, field->dcols); + } wclear(field->working); mvwaddstr(field->working, 0, 0, value); @@ -4385,7 +4375,12 @@ set_field_buffer(FIELD *field, int buffer, const char *value) } else { - mvwin_wchnstr(field->working, 0, 0, widevalue, (int)len); + for (i = 0; i < (unsigned)field->drows; ++i) + { + mvwin_wchnstr(field->working, i, 0, + widevalue + (i * field->dcols), + field->dcols); + } for (i = 0; i < len; ++i) { if (CharEq(myZEROS, widevalue[i])) diff --git a/form/frm_req_name.c b/form/frm_req_name.c index e4d5c335d8ec..7ac9abe6e299 100644 --- a/form/frm_req_name.c +++ b/form/frm_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +37,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_req_name.c,v 1.15 2005/04/16 16:59:27 tom Exp $") +MODULE_ID("$Id: frm_req_name.c,v 1.16 2008/07/05 23:22:08 tom Exp $") static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = { @@ -154,7 +154,7 @@ form_request_by_name(const char *str) strncpy(buf, str, sizeof(buf)); while ((i < sizeof(buf)) && (buf[i] != '\0')) { - buf[i] = toupper(buf[i]); + buf[i] = toupper(UChar(buf[i])); i++; } diff --git a/include/MKterm.h.awk.in b/include/MKterm.h.awk.in index 6f0fca33c7c8..5fc20529b11b 100644 --- a/include/MKterm.h.awk.in +++ b/include/MKterm.h.awk.in @@ -1,7 +1,7 @@ # vile:awkmode BEGIN { print "/****************************************************************************" - print " * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *" + print " * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *" print " * *" print " * Permission is hereby granted, free of charge, to any person obtaining a *" print " * copy of this software and associated documentation files (the *" @@ -34,7 +34,7 @@ BEGIN { print "/* and: Thomas E. Dickey 1995-on */" print "/****************************************************************************/" print "" - print "/* $Id: MKterm.h.awk.in,v 1.49 2007/08/18 11:44:26 tom Exp $ */" + print "/* $Id: MKterm.h.awk.in,v 1.50 2008/05/24 23:13:59 tom Exp $ */" print "" print "/*" print "** term.h -- Definition of struct term" @@ -228,9 +228,8 @@ END { print " char * _termname; /* used for termname() */" print "} TERMINAL;" print "" - print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" - print "" print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@" + print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);" @@ -241,6 +240,7 @@ END { print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);" print "" + print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())" print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())" print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())" print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())" @@ -253,6 +253,8 @@ END { print "" print "#else" print "" + print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" + print "" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];" diff --git a/include/capdefaults.c b/include/capdefaults.c index 071f9e17cdbb..33f2fe8f0299 100644 --- a/include/capdefaults.c +++ b/include/capdefaults.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,9 +29,10 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ -/* $Id: capdefaults.c,v 1.12 2000/01/02 02:34:56 tom Exp $ */ +/* $Id: capdefaults.c,v 1.13 2008/08/04 12:33:42 tom Exp $ */ /* * Compute obsolete capabilities. The reason this is an include file is @@ -44,9 +45,10 @@ */ { char *sp; - int capval; + short capval; -#define EXTRACT_DELAY(str) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0) +#define EXTRACT_DELAY(str) \ + (short) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0) /* current (4.4BSD) capabilities marked obsolete */ if (VALID_STRING(carriage_return) @@ -73,8 +75,8 @@ magic_cookie_glitch_ul = magic_cookie_glitch; /* totally obsolete capabilities */ - linefeed_is_newline = VALID_STRING(newline) - && (strcmp("\n", newline) == 0); + linefeed_is_newline = (char) (VALID_STRING(newline) + && (strcmp("\n", newline) == 0)); if (VALID_STRING(cursor_left) && (capval = EXTRACT_DELAY(cursor_left))) backspace_delay = capval; diff --git a/include/curses.h.in b/include/curses.h.in index deb63e3d735e..53da9a564fe5 100644 --- a/include/curses.h.in +++ b/include/curses.h.in @@ -32,7 +32,7 @@ * and: Thomas E. Dickey 1996-on * ****************************************************************************/ -/* $Id: curses.h.in,v 1.186 2008/04/05 15:30:28 tom Exp $ */ +/* $Id: curses.h.in,v 1.187 2008/08/30 20:11:29 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -423,7 +423,8 @@ struct _win_st */ #if @NCURSES_EXT_FUNCS@ #ifdef NCURSES_WGETCH_EVENTS -#if !defined(__BEOS__) /* Fix _nc_timed_wait() on BEOS... */ +#if !defined(__BEOS__) || defined(__HAIKU__) + /* Fix _nc_timed_wait() on BEOS... */ # define NCURSES_EVENT_VERSION 1 #endif /* !defined(__BEOS__) */ diff --git a/include/curses.tail b/include/curses.tail index dd38ed4ea9e9..aef7c378d5d5 100644 --- a/include/curses.tail +++ b/include/curses.tail @@ -1,4 +1,4 @@ -/* $Id: curses.tail,v 1.15 2007/03/10 17:51:24 tom Exp $ */ +/* $Id: curses.tail,v 1.16 2008/07/05 20:20:38 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in @@ -79,12 +79,12 @@ #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ -#define BUTTON_RELEASE(e, x) ((e) & (001 << (6 * ((x) - 1)))) -#define BUTTON_PRESS(e, x) ((e) & (002 << (6 * ((x) - 1)))) -#define BUTTON_CLICK(e, x) ((e) & (004 << (6 * ((x) - 1)))) -#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1)))) -#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1)))) -#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1)))) +#define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) +#define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) +#define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) +#define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) +#define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) +#define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { diff --git a/include/nc_alloc.h b/include/nc_alloc.h index 9b5751de8c1f..f521bffe9f0a 100644 --- a/include/nc_alloc.h +++ b/include/nc_alloc.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,9 +27,9 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1996,1997 * + * Author: Thomas E. Dickey 1996-on * ****************************************************************************/ -/* $Id: nc_alloc.h,v 1.15 2007/02/03 18:40:23 tom Exp $ */ +/* $Id: nc_alloc.h,v 1.16 2008/09/27 22:30:33 tom Exp $ */ #ifndef NC_ALLOC_included #define NC_ALLOC_included 1 @@ -39,6 +39,8 @@ extern "C" { #endif #if HAVE_LIBDMALLOC +#include +#undef strndup /* workaround for #define in GLIBC 2.7 */ #include /* Gray Watson's library */ #else #undef HAVE_LIBDMALLOC diff --git a/include/nc_panel.h b/include/nc_panel.h index bb1f6745ac0c..6578577ee988 100644 --- a/include/nc_panel.h +++ b/include/nc_panel.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,13 +27,13 @@ ****************************************************************************/ /**************************************************************************** - * Author: Zeyd M. Ben-Halim 1992,1995 * - * and: Eric S. Raymond * + * Author: Juergen Pfeifer 1997 * + * and: Thomas E. Dickey * ****************************************************************************/ /* - * $Id: nc_panel.h,v 1.3 2000/12/10 02:04:35 tom Exp $ + * $Id: nc_panel.h,v 1.5 2008/08/04 18:26:46 tom Exp $ * * nc_panel.h * @@ -54,6 +54,9 @@ struct panelhook { struct panel* top_panel; struct panel* bottom_panel; struct panel* stdscr_pseudo_panel; +#if NO_LEAKS + int (*destroy)(struct panel *); +#endif }; /* Retrieve the panelhook of the current screen */ diff --git a/include/ncurses_defs b/include/ncurses_defs index 924c75eb8890..97a377dc5270 100644 --- a/include/ncurses_defs +++ b/include/ncurses_defs @@ -1,4 +1,4 @@ -# $Id: ncurses_defs,v 1.38 2008/02/10 00:12:03 tom Exp $ +# $Id: ncurses_defs,v 1.40 2008/09/06 15:57:41 tom Exp $ ############################################################################## # Copyright (c) 2000-2007,2008 Free Software Foundation, Inc. # # # @@ -60,8 +60,8 @@ HAVE_GETEGID HAVE_GETEUID HAVE_GETMAXX 1 HAVE_GETNSTR -HAVE_GETPARX 1 HAVE_GETOPT_H +HAVE_GETPARX 1 HAVE_GETTIMEOFDAY HAVE_GETTTYNAM HAVE_GETWIN 1 @@ -88,6 +88,8 @@ HAVE_LONG_FILE_NAMES HAVE_MBLEN HAVE_MBRLEN HAVE_MBRTOWC +HAVE_MBSRTOWCS +HAVE_MBSTOWCS HAVE_MBTOWC HAVE_MENU_H HAVE_MKSTEMP @@ -153,6 +155,8 @@ HAVE_USE_DEFAULT_COLORS HAVE_VFSCANF HAVE_VSNPRINTF HAVE_VSSCANF +HAVE_WCSRTOMBS +HAVE_WCSTOMBS HAVE_WCTOB HAVE_WCTOMB HAVE_WCTYPE_H @@ -199,5 +203,6 @@ USE_SIGWINCH USE_SYMLINKS USE_SYSMOUSE USE_TERMCAP +USE_WEAK_SYMBOLS USE_WIDEC_SUPPORT USE_XMC_SUPPORT diff --git a/include/term_entry.h b/include/term_entry.h index c880c3a72175..fb875407276f 100644 --- a/include/term_entry.h +++ b/include/term_entry.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,10 +29,10 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * - * and: Thomas E. Dickey 1998-2004 * + * and: Thomas E. Dickey 1998-on * ****************************************************************************/ -/* $Id: term_entry.h,v 1.34 2005/07/16 21:15:07 tom Exp $ */ +/* $Id: term_entry.h,v 1.35 2008/08/16 16:16:03 tom Exp $ */ /* * term_entry.h -- interface to entry-manipulation code @@ -52,7 +52,7 @@ extern "C" { typedef struct entry { TERMTYPE tterm; - int nuses; + unsigned nuses; struct { char *name; diff --git a/man/curs_getcchar.3x b/man/curs_getcchar.3x index b811a37db8f7..cb02f5d2aef3 100644 --- a/man/curs_getcchar.3x +++ b/man/curs_getcchar.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 2001-2003,2006 Free Software Foundation, Inc. * +.\" Copyright (c) 2001-2006,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_getcchar.3x,v 1.10 2006/12/24 16:00:02 tom Exp $ +.\" $Id: curs_getcchar.3x,v 1.11 2008/05/17 19:37:05 tom Exp $ .TH curs_getcchar 3X "" .SH NAME \fBgetcchar\fP, @@ -106,9 +106,14 @@ The color pair in - The wide-character string pointed to by \fIwch\fP. The string must be L'\\0' terminated, -contain at most one character with strictly positive width, -which must be the first, -and contain no characters of negative width. +contain at most one spacing character, +which must be the first. +.IP +Up to \fBCCHARW_MAX\fP-1 nonspacing characters may follow. +Additional nonspacing characters are ignored. +.IP +The string may contain a single control character instead. +In that case, no nonspacing characters are allowed. .SH NOTES .PP The \fIopts\fP argument is reserved for future use. diff --git a/man/curs_memleaks.3x b/man/curs_memleaks.3x new file mode 100644 index 000000000000..a8a455257f2d --- /dev/null +++ b/man/curs_memleaks.3x @@ -0,0 +1,75 @@ +.\"*************************************************************************** +.\" Copyright (c) 2008 Free Software Foundation, Inc. * +.\" * +.\" Permission is hereby granted, free of charge, to any person obtaining a * +.\" copy of this software and associated documentation files (the * +.\" "Software"), to deal in the Software without restriction, including * +.\" without limitation the rights to use, copy, modify, merge, publish, * +.\" distribute, distribute with modifications, sublicense, and/or sell * +.\" copies of the Software, and to permit persons to whom the Software is * +.\" furnished to do so, subject to the following conditions: * +.\" * +.\" The above copyright notice and this permission notice shall be included * +.\" in all copies or substantial portions of the Software. * +.\" * +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * +.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * +.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * +.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * +.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * +.\" * +.\" Except as contained in this notice, the name(s) of the above copyright * +.\" holders shall not be used in advertising or otherwise to promote the * +.\" sale, use or other dealings in this Software without prior written * +.\" authorization. * +.\"*************************************************************************** +.\" +.\" $Id: curs_memleaks.3x,v 1.1 2008/10/25 23:38:13 tom Exp $ +.TH curs_memleaks 3X "" +.na +.hy 0 +.SH NAME +\fB_nc_freeall\fP +\fB_nc_free_and_exit\fP - \fBcurses\fR memory-leak checking +.ad +.hy +.SH SYNOPSIS +\fB#include \fR +.sp +\fBvoid _nc_freeall(void);\fR +.br +\fBvoid _nc_free_and_exit(int);\fR +.SH DESCRIPTION +These functions are used to simplify analysis of memory leaks in the ncurses +library. +They are normally not available; they must be configured into the library +at build time using the \fB--disable-leaks\fP option. +That compiles-in code that frees memory that normally would not be freed. +.PP +Any implementation of curses must not free the memory associated with +a screen, since (even after calling \fBendwin\fP), it must be available +for use in the next call to \fBrefresh\fP. +There are also chunks of memory held for performance reasons. +That makes it hard to analyze curses applications for memory leaks. +To work around this, one can build a debugging version of the ncurses +library which frees those chunks which it can, and provides these +functions to free all of the memory allocated by the ncurses library. +.PP +The \fP_nc_free_and_exit\fP function is the preferred one since +some of the memory which is freed may be required for the application +to continue running. +Its parameter is the code to pass to the \fPexit\fP routine. +.SH RETURN VALUE +These functions do not return a value. +.SH PORTABILITY +These functions are not part of the XSI interface. +.SH SEE ALSO +\fBcurses\fR(3X). +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/man/curs_terminfo.3x b/man/curs_terminfo.3x index 5af0b8fbe27c..4412a6a69c35 100644 --- a/man/curs_terminfo.3x +++ b/man/curs_terminfo.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. * +.\" Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_terminfo.3x,v 1.28 2007/05/26 20:09:06 tom Exp $ +.\" $Id: curs_terminfo.3x,v 1.30 2008/08/16 20:53:27 tom Exp $ .TH curs_terminfo 3X "" .ds n 5 .na @@ -274,6 +274,9 @@ In this implementation returns an error if its terminal parameter is null. .TP 5 +\fBputp\fP +calls \fBtputs\fP, returning the same error-codes. +.TP 5 \fBrestartterm\fP returns an error if the associated call to \fBsetupterm\fP returns an error. @@ -283,6 +286,12 @@ returns an error if it cannot allocate enough memory, or create the initial windows (stdscr, curscr, newscr). Other error conditions are documented above. +.TP 5 +\fBtputs\fP +returns an error if the string parameter is null. +It does not detect I/O errors: +X/Open states that \fBtputs\fP ignores the return value +of the output function \fIputc\fP. .RE .SH NOTES The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR. @@ -291,27 +300,30 @@ committing to the allocation of storage involved in \fBinitscr\fR. .PP Note that \fBvidattr\fR and \fBvidputs\fR may be macros. .SH PORTABILITY -The function \fBsetterm\fR is not described in the XSI Curses standard and must -be considered non-portable. All other functions are as described in the XSI -curses standard. +The function \fBsetterm\fR is not described by X/Open and must +be considered non-portable. All other functions are as described by X/Open. .PP \fBsetupterm\fP copies the terminal name to the array \fBttytype\fP. This is not part of X/Open Curses, but is assumed by some applications. .PP In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and -returns \fBOK\fR or \fBERR\fR. We have chosen to implement the XSI Curses +returns \fBOK\fR or \fBERR\fR. We have chosen to implement the X/Open Curses semantics. .PP In System V Release 4, the third argument of \fBtputs\fR has the type \fBint (*putc)(char)\fR. .PP -The XSI Curses standard prototypes \fBtparm\fR with a fixed number of parameters, +At least one implementation of X/Open Curses (Solaris) returns a value +other than OK/ERR from \fBtputs\fP. +That returns the length of the string, and does no error-checking. +.PP +X/Open Curses prototypes \fBtparm\fR with a fixed number of parameters, rather than a variable argument list. This implementation uses a variable argument list. Portable applications should provide 9 parameters after the format; zeroes are fine for this purpose. .PP -XSI notes that after calling \fBmvcur\fR, the curses state may not match the +X/Open notes that after calling \fBmvcur\fR, the curses state may not match the actual terminal state, and that an application should touch and refresh the window before resuming normal curses calls. Both ncurses and System V Release 4 curses implement \fBmvcur\fR using @@ -319,15 +331,19 @@ the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR. So though it is documented as a terminfo function, \fBmvcur\fR is really a curses function which is not well specified. .PP -XSI states that the old location must be given for \fBmvcur\fP. +X/Open states that the old location must be given for \fBmvcur\fP. This implementation allows the caller to use -1's for the old ordinates. In that case, the old location is unknown. .PP Extended terminal capability names, e.g., as defined by \fBtic\ -x\fP, are not stored in the arrays described in this section. .SH SEE ALSO -\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_kernel\fR(3X), \fBcurs_termcap\fR(3X), -\fBputc\fR(3), \fBterminfo\fR(\*n) +\fBcurses\fR(3X), +\fBcurs_initscr\fR(3X), +\fBcurs_kernel\fR(3X), +\fBcurs_termcap\fR(3X), +\fBputc\fR(3), +\fBterminfo\fR(\*n) .\"# .\"# The following sets edit modes for GNU EMACS .\"# Local Variables: diff --git a/man/curs_util.3x b/man/curs_util.3x index 4c8929abfce7..18e2b320cac1 100644 --- a/man/curs_util.3x +++ b/man/curs_util.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_util.3x,v 1.25 2007/05/26 21:44:42 tom Exp $ +.\" $Id: curs_util.3x,v 1.27 2008/10/25 23:45:41 tom Exp $ .TH curs_util 3X "" .na .hy 0 @@ -77,10 +77,37 @@ Printing characters are displayed as is. The corresponding \fBwunctrl\fR returns a printable representation of a wide-character. .PP -The \fBkeyname\fR routine returns a character string corresponding to the key \fIc\fR. +The \fBkeyname\fR routine returns a character string corresponding to the key \fIc\fR: +.RS 3 +.TP 3 +- +Printable characters are displayed as themselves, e.g., a one-character string containing the key. +.TP 3 +- Control characters are displayed in the \fB^\fR\fIX\fR notation. -Values above 128 are either meta characters, shown in the \fBM-\fR\fIX\fR notation, -or the names of function keys, or null. +.TP 3 +- +DEL (character 127) is displayed as \fB^?\fP. +.TP 3 +- +Values above 128 are either meta characters +(if the screen has not been initialized, +or if \fBmeta\fP has been called with a TRUE parameter), +shown in the \fBM-\fR\fIX\fR notation, +or are displayed as themselves. +In the latter case, the values may not be printable; +this follows the X/Open specification. +.TP 3 +- +Values above 256 may be the names of the names of function keys. +.TP 3 +- +Otherwise (if there is no corresponding name) the function returns null, +to denote an error. +X/Open also lists an "UNKNOWN KEY" return value, which some implementations +return rather than null. +.RE +.LP The corresponding \fBkey_name\fR returns a character string corresponding to the wide-character value \fIw\fR. The two functions do not return the same set of strings; @@ -134,11 +161,14 @@ Routines that return pointers return \fBNULL\fR on error. .PP X/Open does not define any error conditions. In this implementation -.RS +.RS 3 .TP 5 \fBflushinp\fR returns an error if the terminal was not initialized. .TP 5 +\fBmeta\fR +returns an error if the terminal was not initialized. +.TP 5 \fBputwin\fP returns an error if the associated \fBfwrite\fP calls return an error. .RE @@ -206,6 +236,8 @@ user-defined strings which begin with "k". The keycodes start at KEY_MAX, but are not guaranteed to be the same value for different runs because user-defined codes are merged from all terminal descriptions which have been loaded. +The \fBuse_extended_names\fP function controls whether this data is +loaded when the terminal description is read by the library. .PP The \fBnofilter\fP routine is specific to ncurses. It was not supported on Version 7, BSD or System V implementations. diff --git a/man/form.3x b/man/form.3x index 75fc78aee2d4..dcba19b3353e 100644 --- a/man/form.3x +++ b/man/form.3x @@ -27,7 +27,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: form.3x,v 1.21 2008/04/26 17:11:52 tom Exp $ +.\" $Id: form.3x,v 1.22 2008/10/11 20:48:11 tom Exp $ .TH form 3X "" .SH NAME \fBform\fR - curses extension for programming forms @@ -41,10 +41,18 @@ routines, which create and modify form fields; and form routines, which group fields into forms, display forms on the screen, and handle interaction with the user. .PP -The \fBform\fR library uses the \fBcurses\fR libraries, and a curses -initialization routine such as \fBinitscr\fR must be called before using any of -these functions. To use the \fBform\fR library, link with the options +The \fBform\fR library uses the \fBcurses\fR libraries. +To use the \fBform\fR library, link with the options \fB-lform -lcurses\fR. +.PP +Your program should set up the locale, e.g., +.sp + \fBsetlocale(LC_ALL, "");\fP +.sp +so that input/output processing will work. +.PP +A curses initialization routine such as \fBinitscr\fR must be called +before using any of these functions. . .SS Current Default Values for Field Attributes . diff --git a/man/form_driver.3x b/man/form_driver.3x index 85b1df8277d6..4b0576f042e0 100644 --- a/man/form_driver.3x +++ b/man/form_driver.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: form_driver.3x,v 1.15 2007/06/02 22:56:49 tom Exp $ +.\" $Id: form_driver.3x,v 1.16 2008/06/21 21:55:39 tom Exp $ .TH form_driver 3X "" .SH NAME \fBform_driver\fR - command-processing loop of the form system @@ -37,8 +37,21 @@ int form_driver(FORM *form, int c); .br .SH DESCRIPTION Once a form has been posted (displayed), you should funnel input events to it -through \fBform_driver\fR. This routine has two major input cases; either -the input is a form navigation request or it is a printable ASCII character. +through \fBform_driver\fR. This routine has three major input cases: +.TP 3 +- +The input is a form navigation request. +Navigation request codes are constants defined in \fB\fP, +which are distinct from the key- and character codes returned by \fBwgetch\fP. +.TP 3 +- +The input is a printable character. +Printable characters (which must be positive, less than 256) are +checked according to the program's locale settings. +.TP 3 +- +The input is the KEY_MOUSE special key associated with an mouse event. +.PP The form driver requests are as follows: .TP 5 REQ_NEXT_PAGE @@ -218,7 +231,7 @@ Display next field choice. REQ_PREV_CHOICE Display previous field choice. .PP -If the second argument is a printable ASCII character, the driver places it +If the second argument is a printable character, the driver places it in the current position in the current field. If it is one of the forms requests listed above, that request is executed. .SS MOUSE HANDLING @@ -269,11 +282,11 @@ If a translation into a request was done, \fBform_driver\fR returns the result of this request. .RE .PP -If you clicked outside the user window or the mouse event couldn't be translated +If you clicked outside the user window or the mouse event could not be translated into a form request an \fBE_REQUEST_DENIED\fR is returned. .SS APPLICATION-DEFINED COMMANDS .PP -If the second argument is neither printable ASCII nor one of the above +If the second argument is neither printable nor one of the above pre-defined form requests, the driver assumes it is an application-specific command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these @@ -306,7 +319,9 @@ System error occurred (see \fBerrno\fR). The form driver code saw an unknown request code. . .SH SEE ALSO -\fBcurses\fR(3X), \fBform\fR(3X). +\fBcurses\fR(3X), +\fBform\fR(3X), +\fBwgetch\fR(3X). .SH NOTES The header file \fB\fR automatically includes the header files \fB\fR. diff --git a/man/form_field_buffer.3x b/man/form_field_buffer.3x index cac6a088e5ed..566072f55ddb 100644 --- a/man/form_field_buffer.3x +++ b/man/form_field_buffer.3x @@ -1,6 +1,6 @@ '\" t .\"*************************************************************************** -.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: form_field_buffer.3x,v 1.14 2006/11/04 17:12:00 tom Exp $ +.\" $Id: form_field_buffer.3x,v 1.15 2008/10/18 18:35:17 tom Exp $ .TH form_field_buffer 3X "" .SH NAME \fBform_field_buffer\fR - field buffer control @@ -46,17 +46,47 @@ int set_max_field(FIELD *field, int max); .br .SH DESCRIPTION The function \fBset_field_buffer\fR sets the numbered buffer of the given field -to contain a given string. Buffer 0 is the displayed value of the field; other -numbered buffers may be allocated by applications through the \fBnbuf\fR -argument of (see \fBform_field_new\fR(3X)) but are not manipulated by the forms -library. The function \fBfield_buffer\fR returns the address of the buffer. -Please note that this buffer has always the length of the buffer, that means -that it may typically contain trailing spaces. If you entered leading spaces -the buffer may also contain them. If you want the raw data, you must write your +to contain a given string: +.RS 3 +.TP 3 +- +Buffer 0 is the displayed value of the field. +.TP 3 +- +Other numbered buffers may be allocated by applications through the \fBnbuf\fR +argument of (see \fBform_field_new\fR(3X)) +but are not manipulated by the forms library. +.RE +.PP +The function \fBfield_buffer\fR returns a pointer to +the contents of the given numbered buffer: +.RS 3 +.TP 3 +- +The buffer contents always have the same length, +and are padded with trailing spaces +as needed to ensure this length is the same. +.TP 3 +- +The buffer may contain leading spaces, depending on how it was set. +.TP 3 +- +The buffer contents are set with \fBset_field_buffer\fP, +or as a side effect of any editing operations on the corresponding field. +.TP 3 +- +Editing operations are based on the \fIwindow\fP which displays the field, +rather than a \fIstring\fP. +The window contains only printable characters, and is filled with blanks. +If you want the raw data, you must write your own routine that copies the value out of the buffer and removes the leading -and trailing spaces. Please note also, that subsequent operations on the form -will probably change the content of the buffer. So do not use it for long term -storage of the entered form data. +and trailing spaces. +.TP 3 +- +Because editing operations change the content of the buffer to +correspond to the window, you should not rely on using buffers +for long-term storage of form data. +.RE .PP The function \fBset_field_status\fR sets the associated status flag of \fIfield\fR; \fBfield_status\fR gets the current value. The status flag diff --git a/man/man_db.renames b/man/man_db.renames index 5a09a03598b8..ff91eecc4e22 100644 --- a/man/man_db.renames +++ b/man/man_db.renames @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: man_db.renames,v 0.40 2008/01/19 18:28:50 tom Exp $ +# $Id: man_db.renames,v 0.41 2008/10/25 23:24:03 tom Exp $ # Manual-page renamings for the man_db program # # Files: @@ -68,6 +68,7 @@ curs_instr.3x instr.3ncurses curs_inwstr.3x inwstr.3ncurses curs_kernel.3x kernel.3ncurses curs_legacy.3x legacy.3ncurses +curs_memleaks.3x memleaks.3ncurses curs_mouse.3x mouse.3ncurses curs_move.3x move.3ncurses curs_opaque.3x opaque.3ncurses diff --git a/man/menu_attributes.3x b/man/menu_attributes.3x index d96ea234fd84..505edbcd4dc0 100644 --- a/man/menu_attributes.3x +++ b/man/menu_attributes.3x @@ -1,6 +1,6 @@ '\" t .\"*************************************************************************** -.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: menu_attributes.3x,v 1.9 2006/11/04 17:12:00 tom Exp $ +.\" $Id: menu_attributes.3x,v 1.10 2008/08/23 18:24:23 tom Exp $ .TH menu_attributes 3X "" .SH NAME \fBmenu_attributes\fR - color and attribute control for menus @@ -54,7 +54,7 @@ int menu_pad(const MENU *menu); The function \fBset_menu_fore\fR sets the foreground attribute of \fImenu\fR. This is the highlight used for selected menu items. \fBmenu_fore\fR returns the foreground attribute. The default -is \fBA_STANDOUT\fR. +is \fBA_REVERSE\fR. .PP The function \fBset_menu_back\fR sets the background attribute of \fImenu\fR. This is the highlight used for selectable (but not currently diff --git a/man/menu_driver.3x b/man/menu_driver.3x index bf7d8770a449..5366040c18af 100644 --- a/man/menu_driver.3x +++ b/man/menu_driver.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: menu_driver.3x,v 1.14 2007/06/02 22:50:09 tom Exp $ +.\" $Id: menu_driver.3x,v 1.15 2008/06/21 21:55:30 tom Exp $ .TH menu_driver 3X "" .SH NAME \fBmenu_driver\fR - command-processing loop of the menu system @@ -37,9 +37,21 @@ int menu_driver(MENU *menu, int c); .br .SH DESCRIPTION Once a menu has been posted (displayed), you should funnel input events to it -through \fBmenu_driver\fR. This routine has three major input cases; either -the input is a menu navigation request, it is a printable ASCII character or it -is the KEY_MOUSE special key associated with an mouse event. +through \fBmenu_driver\fR. This routine has three major input cases: +.TP 3 +- +The input is a form navigation request. +Navigation request codes are constants defined in \fB\fP, +which are distinct from the key- and character codes returned by \fBwgetch\fP. +.TP 3 +- +The input is a printable character. +Printable characters (which must be positive, less than 256) are +checked according to the program's locale settings. +.TP 3 +- +The input is the KEY_MOUSE special key associated with an mouse event. +.PP The menu driver requests are as follows: .TP 5 REQ_LEFT_ITEM @@ -93,7 +105,7 @@ Move to the next item matching the pattern match. REQ_PREV_MATCH Move to the previous item matching the pattern match. .PP -If the second argument is a printable ASCII character, the code appends +If the second argument is a printable character, the code appends it to the pattern buffer and attempts to move to the next item matching the new pattern. If there is no such match, \fBmenu_driver\fR returns \fBE_NO_MATCH\fR and deletes the appended character from the buffer. @@ -147,11 +159,11 @@ If a translation into a request was done, \fBmenu_driver\fR returns the result of this request. .RE .PP -If you clicked outside the user window or the mouse event couldn't be translated +If you clicked outside the user window or the mouse event could not be translated into a menu request an \fBE_REQUEST_DENIED\fR is returned. .SS APPLICATION-DEFINED COMMANDS .PP -If the second argument is neither printable ASCII nor one of the above +If the second argument is neither printable nor one of the above pre-defined menu requests or KEY_MOUSE, the drive assumes it is an application-specific command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these @@ -183,7 +195,9 @@ Character failed to match. .B E_REQUEST_DENIED The menu driver could not process the request. .SH SEE ALSO -\fBcurses\fR(3X), \fBmenu\fR(3X). +\fBcurses\fR(3X), +\fBmenu\fR(3X), +\fBwgetch\fR(3X). .SH NOTES The header file \fB\fR automatically includes the header files \fB\fR. diff --git a/man/menu_pattern.3x b/man/menu_pattern.3x index 50dee87a1e84..3cde165b78c5 100644 --- a/man/menu_pattern.3x +++ b/man/menu_pattern.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: menu_pattern.3x,v 1.10 2006/11/04 18:25:24 tom Exp $ +.\" $Id: menu_pattern.3x,v 1.11 2008/06/21 21:58:20 tom Exp $ .TH menu_pattern 3X "" .SH NAME \fBmenu_pattern\fR - get and set a menu's pattern buffer @@ -39,7 +39,7 @@ char *menu_pattern(const MENU *menu); .br .SH DESCRIPTION Every menu has an associated pattern match buffer. As input events that are -printable ASCII characters come in, they are appended to this match buffer +printable characters come in, they are appended to this match buffer and tested for a match, as described in \fBmenu_driver\fR(3X). .PP The function \fBset_menu_pattern\fR sets the pattern buffer for the given menu diff --git a/man/ncurses.3x b/man/ncurses.3x index ac3d049528c2..703a239abfde 100644 --- a/man/ncurses.3x +++ b/man/ncurses.3x @@ -1,6 +1,6 @@ '\" t .\"*************************************************************************** -.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: ncurses.3x,v 1.89 2007/09/01 18:57:29 tom Exp $ +.\" $Id: ncurses.3x,v 1.92 2008/10/25 23:31:45 tom Exp $ .hy 0 .TH ncurses 3X "" .ds n 5 @@ -74,10 +74,23 @@ terminal and \fBcurses\fR input and output options; environment query routines; color manipulation; use of soft label keys; terminfo capabilities; and access to low-level terminal-manipulation routines. .PP -To initialize the routines, the routine \fBinitscr\fR or \fBnewterm\fR -must be called before any of the other routines that deal with windows +The library uses the locale which the calling program has initialized. +That is normally done with \fBsetlocale\fP: +.sp + \fBsetlocale(LC_ALL, "");\fP +.sp +If the locale is not initialized, +the library assumes that characters are printable as in ISO-8859-1, +to work with certain legacy programs. +You should initialize the locale and not rely on specific details of +the library when the locale has not been setup. +.PP +The function \fBinitscr\fR or \fBnewterm\fR +must be called to initialize the library +before any of the other routines that deal with windows and screens are used. The routine \fBendwin\fR must be called before exiting. +.PP To get character-at-a-time input without echoing (most interactive, screen oriented programs want this), the following sequence should be used: @@ -280,6 +293,8 @@ l l . = COLOR_PAIR/\fBcurs_color\fR(3X) PAIR_NUMBER/\fBcurs_attr\fR(3X) +_nc_free_and_exit/\fBcurs_memleaks\fR(3X)* +_nc_freeall/\fBcurs_memleaks\fR(3X)* _nc_tracebits/\fBcurs_trace\fR(3X)* _traceattr/\fBcurs_trace\fR(3X)* _traceattr2/\fBcurs_trace\fR(3X)* @@ -830,6 +845,18 @@ about the colors, set this to "-1,-1". To make it green-on-black, set it to "2,0". Any positive value from zero to the terminfo \fBmax_colors\fR value is allowed. .TP 5 +NCURSES_GPM_TERMS +This applies only to ncurses configured to use the GPM interface. +.IP +If present, +the environment variable is a list of one or more terminal names +against which the TERM environment variable is matched. +Setting it to an empty value disables the GPM interface; +using the built-in support for xterm, etc. +.IP +If the environment variable is absent, +ncurses will attempt to open GPM if TERM contains "linux". +.TP 5 NCURSES_NO_HARD_TABS \fBNcurses\fP may use tabs as part of the cursor movement optimization. In some cases, diff --git a/menu/m_driver.c b/menu/m_driver.c index d29c6024a7e3..d418e6a22557 100644 --- a/menu/m_driver.c +++ b/menu/m_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +37,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_driver.c,v 1.25 2005/11/26 20:46:59 tom Exp $") +MODULE_ID("$Id: m_driver.c,v 1.27 2008/08/03 22:08:22 tom Exp $") /* Macros */ @@ -74,7 +74,7 @@ Is_Sub_String( { while (*string && *part) { - if (toupper(*string++) != toupper(*part)) + if (toupper(UChar(*string++)) != toupper(UChar(*part))) break; part++; } @@ -303,7 +303,7 @@ menu_driver(MENU * menu, int c) else { my_top_row += rdiff; - while (rdiff-- > 0 && item != (ITEM *) 0) + while (rdiff-- > 0 && item != 0 && item->down != 0) item = item->down; } break; @@ -316,7 +316,7 @@ menu_driver(MENU * menu, int c) else { my_top_row -= rdiff; - while (rdiff-- && item != (ITEM *) 0) + while (rdiff-- > 0 && item != 0 && item->up != 0) item = item->up; } break; diff --git a/menu/m_req_name.c b/menu/m_req_name.c index 01fe79e3be84..6fd51b1c361e 100644 --- a/menu/m_req_name.c +++ b/menu/m_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +37,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_req_name.c,v 1.19 2005/04/16 16:59:52 tom Exp $") +MODULE_ID("$Id: m_req_name.c,v 1.20 2008/09/13 18:59:17 tom Exp $") static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] = { @@ -109,7 +109,7 @@ menu_request_by_name(const char *str) strncpy(buf, str, sizeof(buf)); while ((i < sizeof(buf)) && (buf[i] != '\0')) { - buf[i] = toupper(buf[i]); + buf[i] = toupper(UChar(buf[i])); i++; } diff --git a/misc/ncu-indent b/misc/ncu-indent index 1e1c7fffaeb2..862a108a3b31 100755 --- a/misc/ncu-indent +++ b/misc/ncu-indent @@ -1,6 +1,6 @@ #!/bin/sh #**************************************************************************** -#* Copyright (c) 2001-2005,2006 Thomas E. Dickey * +#* Copyright (c) 2001-2006,2008 Thomas E. Dickey * #* * #* Permission is hereby granted, free of charge, to any person obtaining a * #* copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ #* sale, use or other dealings in this Software without prior written * #* authorization. * #****************************************************************************/ -# $Id: ncu-indent,v 1.16 2006/02/18 17:02:22 tom Exp $ +# $Id: ncu-indent,v 1.17 2008/08/03 15:46:44 tom Exp $ NOOP=no OPTS=' --blank-lines-after-procedures @@ -87,6 +87,7 @@ do rm -f "$save" "$test" mv "$name" "$save" sed \ + -e '/EMPTY_MODULE(/s/)$/);/' \ -e '/MODULE_ID(/s/)$/);/' \ -e 's,\, - kbs=\177, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, - kdch1=\E[3~, kend=\EOF, kent=\EOM, kfnd=\E[1~, khome=\EOH, - kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, - mc0=\E[i, nel=\EE, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, + kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, + kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM, kfnd=\E[1~, + khome=\EOH, kich1=\E[2~, kind=\EO1;2B, kmous=\E[M, + knp=\E[6~, kpp=\E[5~, kri=\EO1;2A, kslt=\E[4~, mc0=\E[i, + nel=\EE, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l, @@ -3706,11 +3785,14 @@ mlterm|multi lingual terminal emulator, # (when available), it could use the extended names introduced for xterm. mlterm+pcfkeys|fragment for PC-style fkeys, kLFT=\EO1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\EO1;2C, - kDN=\EO1;2B, kDN5=\EO1;5B, kDN6=\EO1;6B, kIC5=\E[2;5~, - kIC6=\E[2;6~, kLFT5=\EO1;5D, kLFT6=\EO1;6D, - kNXT5=\E[6;5~, kNXT6=\E[6;6~, kPRV5=\E[5;5~, - kPRV6=\E[5;6~, kRIT5=\EO1;5C, kRIT6=\EO1;6C, kUP=\EO1;2A, - kUP5=\EO1;5A, kUP6=\EO1;6A, + kDN=\EO1;2B, kDN3=\EO1;3B, kDN4=\EO1;4B, kDN5=\EO1;5B, + kDN6=\EO1;6B, kDN7=\EO1;7B, kIC5=\E[2;5~, kIC6=\E[2;6~, + kLFT3=\EO1;3D, kLFT4=\EO1;4D, kLFT5=\EO1;5D, + kLFT6=\EO1;6D, kLFT7=\EO1;7D, kNXT5=\E[6;5~, + kNXT6=\E[6;6~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, + kRIT3=\EO1;3C, kRIT4=\EO1;4C, kRIT5=\EO1;5C, + kRIT6=\EO1;6C, kRIT7=\EO1;7C, kUP=\EO1;2A, kUP3=\EO1;3A, + kUP4=\EO1;4A, kUP5=\EO1;5A, kUP6=\EO1;6A, kUP7=\EO1;7A, # From: Thomas Dickey 04 Oct 1997 # Updated: Oezguer Kesim 02 Nov 1997 @@ -3867,6 +3949,8 @@ rxvt-color|rxvt terminal emulator (X Window System), use=rxvt, rxvt-256color|rxvt 2.7.9 with xterm 256-colors, use=xterm+256color, use=rxvt, +rxvt-88color|rxvt 2.7.9 with xterm 88-colors, + use=xterm+88color, use=rxvt, rxvt-xpm|rxvt terminal emulator (X Window System), use=rxvt, rxvt-cygwin|rxvt terminal emulator (X Window System) on cygwin, @@ -3927,6 +4011,16 @@ Eterm|Eterm-color|Eterm with xterm-style color support (X Window System), vpa=\E[%i%p1%dd, use=vt100+enq, use=rxvt+pcfkeys, use=ecma+color, +Eterm-256color|Eterm with xterm 256-colors, + use=xterm+256color, use=Eterm, + +Eterm-88color|Eterm with 88 colors, + use=xterm+88color, use=Eterm, + +# Based on rxvt 2.4.8, it has a few differences in key bindings +aterm|AfterStep terminal, + kbs=\177, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, use=rxvt, + # xiterm 0.5-5.2 # This is not based on xterm's source... # vttest shows several problems with keyboard, cursor-movements. @@ -4407,6 +4501,8 @@ screen.rxvt|screen in rxvt, screen.linux|screen in linux console, bw, kbs=\177, kcbt@, use=screen+fkeys, use=screen, +screen.mlterm|screen in mlterm, + use=screen+fkeys, use=mlterm, screen-w|VT 100/ANSI X3.64 virtual terminal with 132 cols, cols#132, use=screen, @@ -21679,6 +21775,22 @@ v3220|LANPAR Vision II model 3220/3221/3222, # 2008-04-28 # * add screen+fkeys (prompted by Debian # 478094) -TD # +# 2008-06-28 +# * add screen.mlterm -TD +# * improve mlterm and mlterm+pcfkeys -TD +# +# 2008-08-23 +# * add Eterm-256color, Eterm-88color -TD +# * add rxvt-88color -TD +# +# 2008-10-12 +# * add teraterm4.59 entry, use that as primary teraterm entry, rename +# original to teraterm2.3 -TD +# * update "gnome" to 2.22.3 -TD +# * update "konsole" to 1.6.6 -TD +# * add "aterm" -TD +# * add "linux2.6.26" -TD +# # The following sets edit modes for GNU EMACS. # Local Variables: # fill-prefix:"\t" diff --git a/ncurses/Makefile.in b/ncurses/Makefile.in index 39826e3a4782..558f79f0bbf3 100644 --- a/ncurses/Makefile.in +++ b/ncurses/Makefile.in @@ -1,6 +1,6 @@ -# $Id: Makefile.in,v 1.112 2007/09/01 20:45:53 tom Exp $ +# $Id: Makefile.in,v 1.113 2008/10/18 14:11:54 tom Exp $ ############################################################################## -# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # +# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -183,10 +183,10 @@ $(DESTDIR)$(libdir) : ../lib : ; mkdir $@ ./fallback.c : $(tinfo)/MKfallback.sh - sh $(tinfo)/MKfallback.sh @TERMINFO@ @TERMINFO_SRC@ $(FALLBACK_LIST) >$@ + sh -e $(tinfo)/MKfallback.sh @TERMINFO@ @TERMINFO_SRC@ $(FALLBACK_LIST) >$@ ./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h - sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@ + sh -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@ init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list ./make_keys$(BUILD_EXEEXT) keys.list > $@ @@ -205,14 +205,14 @@ make_hash$(BUILD_EXEEXT) : \ $(BUILD_CC) -o $@ $(BUILD_CCFLAGS) -DMAIN_PROGRAM $(tinfo)/comp_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS) ./expanded.c : $(serial)/MKexpanded.sh - sh $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@ + sh -e $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@ ./comp_captab.c: \ make_hash$(BUILD_EXEEXT) \ ../include/hashsize.h \ $(tinfo)/MKcaptab.sh \ $(tinfo)/MKcaptab.awk - sh $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@ + sh -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@ ./lib_keyname.c: keys.list $(base)/MKkeyname.awk $(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@ @@ -257,7 +257,7 @@ realclean :: distclean test_progs : $(TEST_PROGS) ./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h - sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@ + sh -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@ captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS) @ECHO_LINK@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS) diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk index c1d9475045d0..b35ba2a98027 100644 --- a/ncurses/base/MKkeyname.awk +++ b/ncurses/base/MKkeyname.awk @@ -1,6 +1,6 @@ -# $Id: MKkeyname.awk,v 1.38 2007/08/18 18:41:18 tom Exp $ +# $Id: MKkeyname.awk,v 1.40 2008/07/12 18:40:00 tom Exp $ ############################################################################## -# Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. # +# Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -67,7 +67,7 @@ END { print "#define SIZEOF_TABLE 256" print "#define MyTable _nc_globals.keyname_table" print "" - print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)" + print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)" print "{" print " int i;" print " char name[20];" @@ -100,7 +100,7 @@ END { print " if (MyTable[c] == 0) {" print " int cc = c;" print " p = name;" - print " if (cc >= 128 && (SP == 0 || SP->_use_meta)) {" + print " if (cc >= 128 && (sp == 0 || sp->_use_meta)) {" print " strcpy(p, \"M-\");" print " p += 2;" print " cc -= 128;" @@ -124,7 +124,7 @@ END { print "" print " _nc_tracing = 0; /* prevent recursion via keybound() */" print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {" - print " for(k = STRCOUNT; k < NUM_STRINGS(tp); k++) {" + print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {" print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {" print " result = ExtStrname(tp, k, strnames);" print " break;" @@ -141,6 +141,11 @@ END { print " return result;" print "}" print "" + print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)" + print "{" + print "\treturn _nc_keyname(SP, c);" + print "}" + print "" print "#if NO_LEAKS" print "void _nc_keyname_leaks(void)" print "{" diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh index 09857834e7e0..a984e8545eff 100755 --- a/ncurses/base/MKlib_gen.sh +++ b/ncurses/base/MKlib_gen.sh @@ -2,7 +2,7 @@ # # MKlib_gen.sh -- generate sources from curses.h macro definitions # -# ($Id: MKlib_gen.sh,v 1.30 2008/01/05 23:21:10 tom Exp $) +# ($Id: MKlib_gen.sh,v 1.34 2008/08/30 19:20:50 tom Exp $) # ############################################################################## # Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. # @@ -152,7 +152,7 @@ cat >$ED3 </dev/null \ | sed \ -e 's/ / /g' \ -e 's/^ //' \ - -e 's/^_Bool/bool/' \ + -e 's/_Bool/NCURSES_BOOL/g' \ | $AWK -f $AW2 \ | sed -f $ED3 \ | sed \ -e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \ -e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \ -e 's/gen_//' \ + -e 's/^[ ]*#/#/' \ + -e '/#ident/d' \ + -e '/#line/d' \ | sed -f $ED4 diff --git a/ncurses/base/MKunctrl.awk b/ncurses/base/MKunctrl.awk index 1ba511d72323..36fbeecb2e76 100644 --- a/ncurses/base/MKunctrl.awk +++ b/ncurses/base/MKunctrl.awk @@ -1,4 +1,4 @@ -# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $ +# $Id: MKunctrl.awk,v 1.23 2008/10/04 21:40:24 tom Exp $ ############################################################################## # Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. # # # @@ -46,7 +46,7 @@ BEGIN { print "" } END { - print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)" + print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *sp, chtype ch)" print "{" blob="" @@ -101,6 +101,7 @@ END { blob = blob "\""; print "" + printf "#if NCURSES_EXT_FUNCS\n"; if (bigstrings) { blob = blob "\n/* printable values in 128-255 range */" printf "static const short unctrl_c1[] = {" @@ -135,6 +136,7 @@ END { } } print "};" + print "#endif /* NCURSES_EXT_FUNCS */" blob = blob "\"\n" print "" @@ -150,8 +152,8 @@ END { print "" print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {" print "#if NCURSES_EXT_FUNCS" - print "\t\tif ((SP != 0)" - print "\t\t && (SP->_legacy_coding > 1)" + print "\t\tif ((sp != 0)" + print "\t\t && (sp->_legacy_coding > 1)" print "\t\t && (check >= 128)" print "\t\t && (check < 160))" printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; @@ -159,18 +161,18 @@ END { print "#if USE_WIDEC_SUPPORT" print "\t\tif ((check >= 160)" print "\t\t && (check < 256)" - print "\t\t && ((SP != 0)" - print "\t\t && ((SP->_legacy_coding > 0)" - print "\t\t || (SP->_legacy_coding == 0" + print "\t\t && ((sp != 0)" + print "\t\t && ((sp->_legacy_coding > 0)" + print "\t\t || (sp->_legacy_coding == 0" print "\t\t && (isprint(check) || iswprint(check))))))" printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; print "\t\telse" print "#else" print "\t\tif ((check >= 160)" print "\t\t && (check < 256)" - print "\t\t && ((SP != 0)" - print "\t\t && ((SP->_legacy_coding > 0)" - print "\t\t || (SP->_legacy_coding == 0" + print "\t\t && ((sp != 0)" + print "\t\t && ((sp->_legacy_coding > 0)" + print "\t\t || (sp->_legacy_coding == 0" print "\t\t && isprint(check)))))" printf "\t\t\tresult = %s_c1[check - 128];\n", stringname; print "\t\telse" @@ -182,4 +184,9 @@ END { print "\t}" print "\treturn (NCURSES_CONST char *)result;" print "}" + print "" + print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)" + print "{" + print "\treturn _nc_unctrl(SP, ch);" + print "}" } diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c index 17ba6e2bcd6c..20a97a01a011 100644 --- a/ncurses/base/lib_addch.c +++ b/ncurses/base/lib_addch.c @@ -36,7 +36,7 @@ #include #include -MODULE_ID("$Id: lib_addch.c,v 1.111 2008/03/29 18:48:02 tom Exp $") +MODULE_ID("$Id: lib_addch.c,v 1.113 2008/08/16 19:20:04 tom Exp $") static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); @@ -210,7 +210,7 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch) WINDOW_EXT(win, addch_y) = y; init_mb(state); - buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch)); + buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch)); WINDOW_EXT(win, addch_used) += 1; buffer[WINDOW_EXT(win, addch_used)] = '\0'; if ((len = mbrtowc(&result, @@ -290,12 +290,15 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch) int len = wcwidth(CharOf(ch)); int i; int j; + wchar_t *chars; if (len == 0) { /* non-spacing */ if ((x > 0 && y >= 0) - || ((y = win->_cury - 1) >= 0 && - (x = win->_maxx) > 0)) { - wchar_t *chars = (win->_line[y].text[x - 1].chars); + || (win->_maxx >= 0 && win->_cury >= 1)) { + if (x > 0 && y >= 0) + chars = (win->_line[y].text[x - 1].chars); + else + chars = (win->_line[y - 1].text[win->_maxx].chars); for (i = 0; i < CCHARW_MAX; ++i) { if (chars[i] == 0) { TR(TRACE_VIRTPUT, diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c index ba5f180d5f3c..b92c40335958 100644 --- a/ncurses/base/lib_delwin.c +++ b/ncurses/base/lib_delwin.c @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_delwin.c,v 1.16 2008/05/03 14:13:51 tom Exp $") +MODULE_ID("$Id: lib_delwin.c,v 1.17 2008/06/07 14:10:56 tom Exp $") static bool cannot_delete(WINDOW *win) @@ -67,12 +67,10 @@ delwin(WINDOW *win) T((T_CALLED("delwin(%p)"), win)); - if (_nc_try_global(windowlist) == 0) { - _nc_lock_window(win); + if (_nc_try_global(curses) == 0) { if (win == 0 || cannot_delete(win)) { result = ERR; - _nc_unlock_window(win); } else { if (win->_flags & _SUBWIN) @@ -80,10 +78,9 @@ delwin(WINDOW *win) else if (curscr != 0) touchwin(curscr); - _nc_unlock_window(win); result = _nc_freewin(win); } - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); } returnCode(result); } diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index 4bb7ccc79995..564026582911 100644 --- a/ncurses/base/lib_freeall.c +++ b/ncurses/base/lib_freeall.c @@ -40,7 +40,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.46 2008/05/03 14:13:51 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.54 2008/09/27 13:09:57 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -58,10 +58,13 @@ _nc_freeall(void) if (SP->_oldnum_list != 0) { FreeAndNull(SP->_oldnum_list); } + if (SP->_panelHook.destroy != 0) { + SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel); + } } #endif if (SP != 0) { - _nc_lock_global(windowlist); + _nc_lock_global(curses); while (_nc_windows != 0) { bool deleted = FALSE; @@ -93,23 +96,18 @@ _nc_freeall(void) break; } delscreen(SP); - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); } if (cur_term != 0) del_curterm(cur_term); -#if USE_WIDEC_SUPPORT - FreeIfNeeded(_nc_wacs); -#endif (void) _nc_printf_string(0, empty_va); #ifdef TRACE (void) _nc_trace_buf(-1, 0); #endif - -#if BROKEN_LINKER || USE_REENTRANT - FreeIfNeeded(_nc_prescreen.real_acs_map); +#if USE_WIDEC_SUPPORT + FreeIfNeeded(_nc_wacs); #endif - _nc_leaks_tinfo(); #if HAVE_LIBDBMALLOC @@ -131,7 +129,10 @@ _nc_free_and_exit(int code) _nc_freeall(); #ifdef TRACE trace(0); /* close trace file, freeing its setbuf */ - free(_nc_varargs("?", 0)); + { + static va_list fake; + free(_nc_varargs("?", fake)); + } #endif fclose(stdout); FreeIfNeeded(last_setbuf); @@ -143,4 +144,14 @@ NCURSES_EXPORT(void) _nc_freeall(void) { } + +NCURSES_EXPORT(void) +_nc_free_and_exit(int code) +{ + if (SP) + delscreen(SP); + if (cur_term != 0) + del_curterm(cur_term); + exit(code); +} #endif diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c index d9f6b1795c77..a3812bee76e8 100644 --- a/ncurses/base/lib_getch.c +++ b/ncurses/base/lib_getch.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_getch.c,v 1.87 2008/05/03 22:42:10 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.99 2008/09/20 19:46:13 tom Exp $") #include @@ -76,6 +76,13 @@ set_escdelay(int value) } #endif +static int +_nc_use_meta(WINDOW *win) +{ + SCREEN *sp = _nc_screen_of(win); + return (sp ? sp->_use_meta : 0); +} + #ifdef NCURSES_WGETCH_EVENTS #define TWAIT_MASK 7 #else @@ -123,7 +130,7 @@ fifo_pull(SCREEN *sp) { int ch; ch = sp->_fifo[head]; - TR(TRACE_IEVENT, ("pulling %s from %d", _tracechar(ch), head)); + TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head)); if (peek == head) { h_inc(); @@ -228,7 +235,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) if (head == -1) head = peek = tail; t_inc(); - TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail)); + TR(TRACE_IEVENT, ("pushed %s at %d", _nc_tracechar(sp, ch), tail)); #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { _nc_fifo_dump(sp); @@ -248,9 +255,59 @@ fifo_clear(SCREEN *sp) static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl)); -#define wgetch_should_refresh(win) (\ - (is_wintouched(win) || (win->_flags & _HASMOVED)) \ - && !(win->_flags & _ISPAD)) +static void +recur_wrefresh(WINDOW *win) +{ +#ifdef USE_PTHREADS + SCREEN *sp = _nc_screen_of(win); + if (_nc_use_pthreads && sp != SP) { + SCREEN *save_SP; + + /* temporarily switch to the window's screen to check/refresh */ + _nc_lock_global(curses); + save_SP = SP; + _nc_set_screen(sp); + recur_wrefresh(win); + _nc_set_screen(save_SP); + _nc_unlock_global(curses); + } else +#endif + if ((is_wintouched(win) || (win->_flags & _HASMOVED)) + && !(win->_flags & _ISPAD)) { + wrefresh(win); + } +} + +static int +recur_wgetnstr(WINDOW *win, char *buf) +{ + SCREEN *sp = _nc_screen_of(win); + int rc; + + if (sp != 0) { +#ifdef USE_PTHREADS + if (_nc_use_pthreads && sp != SP) { + SCREEN *save_SP; + + /* temporarily switch to the window's screen to get cooked input */ + _nc_lock_global(curses); + save_SP = SP; + _nc_set_screen(sp); + rc = recur_wgetnstr(win, buf); + _nc_set_screen(save_SP); + _nc_unlock_global(curses); + } else +#endif + { + sp->_called_wgetch = TRUE; + rc = wgetnstr(win, buf, MAXCOLUMNS); + sp->_called_wgetch = FALSE; + } + } else { + rc = ERR; + } + return rc; +} NCURSES_EXPORT(int) _nc_wgetch(WINDOW *win, @@ -258,7 +315,7 @@ _nc_wgetch(WINDOW *win, int use_meta EVENTLIST_2nd(_nc_eventlist * evl)) { - SCREEN *sp = SP; + SCREEN *sp; int ch; #ifdef NCURSES_WGETCH_EVENTS long event_delay = -1; @@ -267,14 +324,14 @@ _nc_wgetch(WINDOW *win, T((T_CALLED("_nc_wgetch(%p)"), win)); *result = 0; + + sp = _nc_screen_of(win); if (win == 0 || sp == 0) { returnCode(ERR); } if (cooked_key_in_fifo()) { - if (wgetch_should_refresh(win)) - wrefresh(win); - + recur_wrefresh(win); *result = fifo_pull(sp); returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); } @@ -299,9 +356,7 @@ _nc_wgetch(WINDOW *win, TR(TRACE_IEVENT, ("filling queue in cooked mode")); - sp->_called_wgetch = TRUE; - rc = wgetnstr(win, buf, MAXCOLUMNS); - sp->_called_wgetch = FALSE; + rc = recur_wgetnstr(win, buf); /* ungetch in reverse order */ #ifdef NCURSES_WGETCH_EVENTS @@ -324,10 +379,9 @@ _nc_wgetch(WINDOW *win, if (win->_use_keypad != sp->_keypad_on) _nc_keypad(sp, win->_use_keypad); - if (wgetch_should_refresh(win)) - wrefresh(win); + recur_wrefresh(win); - if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) { + if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) { if (head == -1) { /* fifo is empty */ int delay; int rc; @@ -353,8 +407,9 @@ _nc_wgetch(WINDOW *win, returnCode(KEY_CODE_YES); } #endif - if (!rc) + if (!rc) { returnCode(ERR); + } } /* else go on to read data available */ } @@ -388,7 +443,7 @@ _nc_wgetch(WINDOW *win, && (((rc = check_mouse_activity(sp, sp->_maxclick EVENTLIST_2nd(evl))) != 0 && !(rc & 4)) - || !sp->_mouse_parse(runcount))); + || !sp->_mouse_parse(sp, runcount))); #ifdef NCURSES_WGETCH_EVENTS if ((rc & 4) && !ch == KEY_EVENT) { _nc_ungetch(sp, ch); @@ -467,7 +522,7 @@ _nc_wgetch(WINDOW *win, if ((ch < KEY_MIN) && (ch & 0x80)) ch &= 0x7f; - T(("wgetch returning : %s", _tracechar(ch))); + T(("wgetch returning : %s", _nc_tracechar(sp, ch))); *result = ch; returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK); @@ -477,14 +532,13 @@ _nc_wgetch(WINDOW *win, NCURSES_EXPORT(int) wgetch_events(WINDOW *win, _nc_eventlist * evl) { - SCREEN *sp = SP; int code; unsigned long value; T((T_CALLED("wgetch_events(%p,%p)"), win, evl)); code = _nc_wgetch(win, &value, - sp->_use_meta + _nc_use_meta(win) EVENTLIST_2nd(evl)); if (code != ERR) code = value; @@ -495,14 +549,13 @@ wgetch_events(WINDOW *win, _nc_eventlist * evl) NCURSES_EXPORT(int) wgetch(WINDOW *win) { - SCREEN *sp = SP; int code; unsigned long value; T((T_CALLED("wgetch(%p)"), win)); code = _nc_wgetch(win, &value, - (sp ? sp->_use_meta : 0) + _nc_use_meta(win) EVENTLIST_2nd((_nc_eventlist *) 0)); if (code != ERR) code = value; @@ -564,7 +617,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) return ch; } - TR(TRACE_IEVENT, ("ch: %s", _tracechar((unsigned char) ch))); + TR(TRACE_IEVENT, ("ch: %s", _nc_tracechar(sp, (unsigned char) ch))); while ((ptr != NULL) && (ptr->ch != (unsigned char) ch)) ptr = ptr->sibling; diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c index 274e87887371..b17df03d2a41 100644 --- a/ncurses/base/lib_getstr.c +++ b/ncurses/base/lib_getstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -41,7 +41,7 @@ #include #include -MODULE_ID("$Id: lib_getstr.c,v 1.25 2006/01/12 00:33:52 tom Exp $") +MODULE_ID("$Id: lib_getstr.c,v 1.27 2008/08/16 19:20:04 tom Exp $") /* * This wipes out the last character, no matter whether it was a tab, control @@ -75,6 +75,7 @@ wgetnstr_events(WINDOW *win, int maxlen, EVENTLIST_1st(_nc_eventlist * evl)) { + SCREEN *sp = _nc_screen_of(win); TTY buf; bool oldnl, oldecho, oldraw, oldcbreak; char erasec; @@ -90,10 +91,10 @@ wgetnstr_events(WINDOW *win, _nc_get_tty_mode(&buf); - oldnl = SP->_nl; - oldecho = SP->_echo; - oldraw = SP->_raw; - oldcbreak = SP->_cbreak; + oldnl = sp->_nl; + oldecho = sp->_echo; + oldraw = sp->_raw; + oldcbreak = sp->_cbreak; nl(); noecho(); noraw(); @@ -145,7 +146,7 @@ wgetnstr_events(WINDOW *win, || (maxlen >= 0 && str - oldstr >= maxlen)) { beep(); } else { - *str++ = ch; + *str++ = (char) ch; if (oldecho == TRUE) { int oldy = win->_cury; if (waddch(win, (chtype) ch) == ERR) { @@ -187,10 +188,10 @@ wgetnstr_events(WINDOW *win, /* Restore with a single I/O call, to fix minor asymmetry between * raw/noraw, etc. */ - SP->_nl = oldnl; - SP->_echo = oldecho; - SP->_raw = oldraw; - SP->_cbreak = oldcbreak; + sp->_nl = oldnl; + sp->_echo = oldecho; + sp->_raw = oldraw; + sp->_cbreak = oldcbreak; _nc_set_tty_mode(&buf); diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c index ef360c03b642..b2fef0c1d085 100644 --- a/ncurses/base/lib_initscr.c +++ b/ncurses/base/lib_initscr.c @@ -45,7 +45,7 @@ #include /* needed for ISC */ #endif -MODULE_ID("$Id: lib_initscr.c,v 1.36 2008/04/12 18:11:36 tom Exp $") +MODULE_ID("$Id: lib_initscr.c,v 1.38 2008/08/16 21:20:48 Werner.Fink Exp $") NCURSES_EXPORT(WINDOW *) initscr(void) @@ -57,7 +57,9 @@ initscr(void) START_TRACE(); T((T_CALLED("initscr()"))); - _nc_lock_global(set_SP); + _nc_init_pthreads(); + _nc_lock_global(curses); + /* Portable applications must not call initscr() more than once */ if (!_nc_globals.init_screen) { _nc_globals.init_screen = TRUE; @@ -91,7 +93,7 @@ initscr(void) def_prog_mode(); } result = stdscr; - _nc_unlock_global(set_SP); + _nc_unlock_global(curses); returnWin(result); } diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index aace7deb4c7f..95f29aa69111 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -79,7 +79,7 @@ #include -MODULE_ID("$Id: lib_mouse.c,v 1.88 2007/09/29 21:50:04 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.102 2008/10/18 21:48:55 tom Exp $") #include #include @@ -150,38 +150,47 @@ make an error #define LIBGPM_SONAME "libgpm.so" #endif -#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name)) +#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(SP->_dlopen_gpm, #name)) #endif /* USE_GPM_SUPPORT */ -static bool _nc_mouse_parse(int); +static bool _nc_mouse_parse(SCREEN *, int); static void _nc_mouse_resume(SCREEN *); static void _nc_mouse_wrap(SCREEN *); /* maintain a circular list of mouse events */ +#define FirstEV(sp) ((sp)->_mouse_events) +#define LastEV(sp) ((sp)->_mouse_events + EV_MAX - 1) + #undef NEXT -#define NEXT(ep) ((ep == SP->_mouse_events + EV_MAX - 1) \ - ? SP->_mouse_events \ +#define NEXT(ep) ((ep >= LastEV(sp)) \ + ? FirstEV(sp) \ : ep + 1) #undef PREV -#define PREV(ep) ((ep == SP->_mouse_events) \ - ? SP->_mouse_events + EV_MAX - 1 \ +#define PREV(ep) ((ep <= FirstEV(sp)) \ + ? LastEV(sp) \ : ep - 1) +#define IndexEV(sp, ep) (ep - FirstEV(sp)) + +#define RunParams(sp, eventp, runp) \ + (long) IndexEV(sp, runp), \ + (long) (IndexEV(sp, eventp) + (EV_MAX - 1)) % EV_MAX + #ifdef TRACE static void -_trace_slot(const char *tag) +_trace_slot(SCREEN *sp, const char *tag) { MEVENT *ep; _tracef(tag); - for (ep = SP->_mouse_events; ep < SP->_mouse_events + EV_MAX; ep++) + for (ep = FirstEV(sp); ep <= LastEV(sp); ep++) _tracef("mouse event queue slot %ld = %s", - (long) (ep - SP->_mouse_events), - _tracemouse(ep)); + (long) IndexEV(sp, ep), + _nc_tracemouse(sp, ep)); } #endif @@ -193,7 +202,7 @@ _trace_slot(const char *tag) # define M_FD(sp) sp->_mouse_fd static void -write_event(int down, int button, int x, int y) +write_event(SCREEN *sp, int down, int button, int x, int y) { char buf[6]; unsigned long ignore; @@ -202,12 +211,13 @@ write_event(int down, int button, int x, int y) buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40); buf[4] = ' ' + x - LEFT_COL + 1; buf[5] = ' ' + y - TOP_ROW + 1; - DosWrite(SP->_emxmouse_wfd, buf, 6, &ignore); + DosWrite(sp->_emxmouse_wfd, buf, 6, &ignore); } static void -mouse_server(unsigned long ignored GCC_UNUSED) +mouse_server(unsigned long param) { + SCREEN *sp = (SCREEN *) param; unsigned short fWait = MOU_WAIT; /* NOPTRRECT mourt = { 0,0,24,79 }; */ MOUEVENTINFO mouev; @@ -234,7 +244,7 @@ mouse_server(unsigned long ignored GCC_UNUSED) sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc); break; } - if (!SP->_emxmouse_activated) + if (!sp->_emxmouse_activated) goto finish; /* @@ -245,14 +255,14 @@ mouse_server(unsigned long ignored GCC_UNUSED) * 3 = middle. */ if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN) - write_event(mouev.fs & MOUSE_BN1_DOWN, - SP->_emxmouse_buttons[1], mouev.col, mouev.row); + write_event(sp, mouev.fs & MOUSE_BN1_DOWN, + sp->_emxmouse_buttons[1], mouev.col, mouev.row); if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN) - write_event(mouev.fs & MOUSE_BN2_DOWN, - SP->_emxmouse_buttons[3], mouev.col, mouev.row); + write_event(sp, mouev.fs & MOUSE_BN2_DOWN, + sp->_emxmouse_buttons[3], mouev.col, mouev.row); if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN) - write_event(mouev.fs & MOUSE_BN3_DOWN, - SP->_emxmouse_buttons[2], mouev.col, mouev.row); + write_event(sp, mouev.fs & MOUSE_BN3_DOWN, + sp->_emxmouse_buttons[2], mouev.col, mouev.row); finish: oldstate = mouev.fs; @@ -271,134 +281,199 @@ mouse_server(unsigned long ignored GCC_UNUSED) #if USE_SYSMOUSE static void -handle_sysmouse(int sig GCC_UNUSED) +sysmouse_server(SCREEN *sp) { struct mouse_info the_mouse; MEVENT *work; the_mouse.operation = MOUSE_GETINFO; - if (SP != 0 - && SP->_mouse_fd >= 0 - && SP->_sysmouse_tail < FIFO_SIZE - && ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) { + if (sp != 0 + && sp->_mouse_fd >= 0 + && sp->_sysmouse_tail < FIFO_SIZE + && ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) { - if (SP->_sysmouse_head > SP->_sysmouse_tail) { - SP->_sysmouse_tail = 0; - SP->_sysmouse_head = 0; + if (sp->_sysmouse_head > sp->_sysmouse_tail) { + sp->_sysmouse_tail = 0; + sp->_sysmouse_head = 0; } - work = &(SP->_sysmouse_fifo[SP->_sysmouse_tail]); + work = &(sp->_sysmouse_fifo[sp->_sysmouse_tail]); memset(work, 0, sizeof(*work)); work->id = NORMAL_EVENT; /* there's only one mouse... */ - SP->_sysmouse_old_buttons = SP->_sysmouse_new_buttons; - SP->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7; + sp->_sysmouse_old_buttons = sp->_sysmouse_new_buttons; + sp->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7; - if (SP->_sysmouse_new_buttons) { - if (SP->_sysmouse_new_buttons & 1) + if (sp->_sysmouse_new_buttons) { + if (sp->_sysmouse_new_buttons & 1) work->bstate |= BUTTON1_PRESSED; - if (SP->_sysmouse_new_buttons & 2) + if (sp->_sysmouse_new_buttons & 2) work->bstate |= BUTTON2_PRESSED; - if (SP->_sysmouse_new_buttons & 4) + if (sp->_sysmouse_new_buttons & 4) work->bstate |= BUTTON3_PRESSED; } else { - if (SP->_sysmouse_old_buttons & 1) + if (sp->_sysmouse_old_buttons & 1) work->bstate |= BUTTON1_RELEASED; - if (SP->_sysmouse_old_buttons & 2) + if (sp->_sysmouse_old_buttons & 2) work->bstate |= BUTTON2_RELEASED; - if (SP->_sysmouse_old_buttons & 4) + if (sp->_sysmouse_old_buttons & 4) work->bstate |= BUTTON3_RELEASED; } /* for cosmetic bug in syscons.c on FreeBSD 3.[34] */ the_mouse.operation = MOUSE_HIDE; - ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse); + ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse); the_mouse.operation = MOUSE_SHOW; - ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse); + ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse); /* * We're only interested if the button is pressed or released. * FIXME: implement continuous event-tracking. */ - if (SP->_sysmouse_new_buttons != SP->_sysmouse_old_buttons) { - SP->_sysmouse_tail += 1; + if (sp->_sysmouse_new_buttons != sp->_sysmouse_old_buttons) { + sp->_sysmouse_tail += 1; } - work->x = the_mouse.u.data.x / SP->_sysmouse_char_width; - work->y = the_mouse.u.data.y / SP->_sysmouse_char_height; + work->x = the_mouse.u.data.x / sp->_sysmouse_char_width; + work->y = the_mouse.u.data.y / sp->_sysmouse_char_height; } } + +static void +handle_sysmouse(int sig GCC_UNUSED) +{ + sysmouse_server(SP); +} #endif /* USE_SYSMOUSE */ static void -init_xterm_mouse(void) +init_xterm_mouse(SCREEN *sp) { - SP->_mouse_type = M_XTERM; - SP->_mouse_xtermcap = tigetstr("XM"); - if (!VALID_STRING(SP->_mouse_xtermcap)) - SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; + sp->_mouse_type = M_XTERM; + sp->_mouse_xtermcap = tigetstr("XM"); + if (!VALID_STRING(sp->_mouse_xtermcap)) + sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; } static void -enable_xterm_mouse(int enable) +enable_xterm_mouse(SCREEN *sp, int enable) { #if USE_EMX_MOUSE - SP->_emxmouse_activated = enable; + sp->_emxmouse_activated = enable; #else - putp(TPARM_1(SP->_mouse_xtermcap, enable)); + putp(TPARM_1(sp->_mouse_xtermcap, enable)); #endif - SP->_mouse_active = enable; + sp->_mouse_active = enable; } #if USE_GPM_SUPPORT -static int +static bool allow_gpm_mouse(void) { + bool result = FALSE; + /* GPM does printf's without checking if stdout is a terminal */ if (isatty(fileno(stdout))) { + char *list = getenv("NCURSES_GPM_TERMS"); char *env = getenv("TERM"); - /* GPM checks the beginning of the $TERM variable to decide if - * it should pass xterm events through. There is no real advantage - * in allowing GPM to do this. - */ - if (env == 0 || strncmp(env, "xterm", 5)) - return TRUE; + if (list != 0) { + if (env != 0) { + result = _nc_name_match(list, env, "|:"); + } + } else { + /* GPM checks the beginning of the $TERM variable to decide if it + * should pass xterm events through. There is no real advantage in + * allowing GPM to do this. Recent versions relax that check, and + * pretend that GPM can work with any terminal having the kmous + * capability. Perhaps that works for someone. If so, they can + * set the environment variable (above). + */ + if (env != 0 && strstr(env, "linux") != 0) { + result = TRUE; + } + } } - return FALSE; + return result; } +#ifdef HAVE_LIBDL +static void +unload_gpm_library(SCREEN *sp) +{ + if (SP->_dlopen_gpm != 0) { + T(("unload GPM library")); + sp->_mouse_gpm_loaded = FALSE; + sp->_mouse_fd = -1; + dlclose(sp->_dlopen_gpm); + sp->_dlopen_gpm = 0; + } +} + +static void +load_gpm_library(SCREEN *sp) +{ + sp->_mouse_gpm_found = FALSE; + if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { + if (GET_DLSYM(gpm_fd) == 0 || + GET_DLSYM(Gpm_Open) == 0 || + GET_DLSYM(Gpm_Close) == 0 || + GET_DLSYM(Gpm_GetEvent) == 0) { + T(("GPM initialization failed: %s", dlerror())); + unload_gpm_library(sp); + } else { + sp->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_loaded = TRUE; + } + } +} +#endif + static bool -enable_gpm_mouse(int enable) +enable_gpm_mouse(SCREEN *sp, bool enable) { bool result; T((T_CALLED("enable_gpm_mouse(%d)"), enable)); - if (enable && !SP->_mouse_active) { - /* GPM: initialize connection to gpm server */ - SP->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP; - SP->_mouse_gpm_connect.defaultMask = - ~(SP->_mouse_gpm_connect.eventMask | GPM_HARD); - SP->_mouse_gpm_connect.minMod = 0; - SP->_mouse_gpm_connect.maxMod = - (unsigned short) (~((1 << KG_SHIFT) | - (1 << KG_SHIFTL) | - (1 << KG_SHIFTR))); - /* - * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open. - * The former is recognized by wscons (SunOS), and the latter by - * xterm. Those will not show up in ncurses' traces. - */ - result = (my_Gpm_Open(&SP->_mouse_gpm_connect, 0) >= 0); - SP->_mouse_active = result; + if (enable && !sp->_mouse_active) { +#ifdef HAVE_LIBDL + if (sp->_mouse_gpm_found && !sp->_mouse_gpm_loaded) { + load_gpm_library(sp); + } +#endif + if (sp->_mouse_gpm_loaded) { + /* GPM: initialize connection to gpm server */ + sp->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP; + sp->_mouse_gpm_connect.defaultMask = + (unsigned short) (~(sp->_mouse_gpm_connect.eventMask | GPM_HARD)); + sp->_mouse_gpm_connect.minMod = 0; + sp->_mouse_gpm_connect.maxMod = + (unsigned short) (~((1 << KG_SHIFT) | + (1 << KG_SHIFTL) | + (1 << KG_SHIFTR))); + /* + * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open. + * The former is recognized by wscons (SunOS), and the latter by + * xterm. Those will not show up in ncurses' traces. + */ + result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0); + } else { + result = FALSE; + } + sp->_mouse_active = result; T(("GPM open %s", result ? "succeeded" : "failed")); } else { - if (!enable && SP->_mouse_active) { + if (!enable && sp->_mouse_active) { /* GPM: close connection to gpm server */ my_Gpm_Close(); - SP->_mouse_active = FALSE; + sp->_mouse_active = FALSE; T(("GPM closed")); } - result = FALSE; + result = enable; } +#ifdef HAVE_LIBDL + if (!result) { + unload_gpm_library(sp); + } +#endif returnBool(result); } #endif /* USE_GPM_SUPPORT */ @@ -406,32 +481,20 @@ enable_gpm_mouse(int enable) #define xterm_kmous "\033[M" static void -initialize_mousetype(void) +initialize_mousetype(SCREEN *sp) { T((T_CALLED("initialize_mousetype()"))); /* Try gpm first, because gpm may be configured to run in xterm */ #if USE_GPM_SUPPORT if (allow_gpm_mouse()) { - if (!SP->_mouse_gpm_loaded) { + if (!sp->_mouse_gpm_loaded) { #ifdef HAVE_LIBDL - void *obj; - - if ((obj = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { - if (GET_DLSYM(gpm_fd) == 0 || - GET_DLSYM(Gpm_Open) == 0 || - GET_DLSYM(Gpm_Close) == 0 || - GET_DLSYM(Gpm_GetEvent) == 0) { - T(("GPM initialization failed: %s", dlerror())); - dlclose(obj); - } else { - SP->_mouse_gpm_found = TRUE; - } - } + load_gpm_library(sp); #else /* !HAVE_LIBDL */ - SP->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_loaded = TRUE; #endif - SP->_mouse_gpm_loaded = TRUE; } /* @@ -439,10 +502,10 @@ initialize_mousetype(void) * maintain our notion of whether the mouse connection is active * without testing the file-descriptor. */ - if (SP->_mouse_gpm_found && enable_gpm_mouse(TRUE)) { - SP->_mouse_type = M_GPM; - SP->_mouse_fd = *(my_gpm_fd); - T(("GPM mouse_fd %d", SP->_mouse_fd)); + if (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) { + sp->_mouse_type = M_GPM; + sp->_mouse_fd = *(my_gpm_fd); + T(("GPM mouse_fd %d", sp->_mouse_fd)); returnVoid; } } @@ -450,7 +513,7 @@ initialize_mousetype(void) /* OS/2 VIO */ #if USE_EMX_MOUSE - if (!SP->_emxmouse_thread + if (!sp->_emxmouse_thread && strstr(cur_term->type.term_names, "xterm") == 0 && key_mouse) { int handles[2]; @@ -461,32 +524,32 @@ initialize_mousetype(void) } else { int rc; - if (!SP->_emxmouse_buttons[0]) { + if (!sp->_emxmouse_buttons[0]) { char *s = getenv("MOUSE_BUTTONS_123"); - SP->_emxmouse_buttons[0] = 1; + sp->_emxmouse_buttons[0] = 1; if (s && strlen(s) >= 3) { - SP->_emxmouse_buttons[1] = s[0] - '0'; - SP->_emxmouse_buttons[2] = s[1] - '0'; - SP->_emxmouse_buttons[3] = s[2] - '0'; + sp->_emxmouse_buttons[1] = s[0] - '0'; + sp->_emxmouse_buttons[2] = s[1] - '0'; + sp->_emxmouse_buttons[3] = s[2] - '0'; } else { - SP->_emxmouse_buttons[1] = 1; - SP->_emxmouse_buttons[2] = 3; - SP->_emxmouse_buttons[3] = 2; + sp->_emxmouse_buttons[1] = 1; + sp->_emxmouse_buttons[2] = 3; + sp->_emxmouse_buttons[3] = 2; } } - SP->_emxmouse_wfd = handles[1]; - M_FD(SP) = handles[0]; + sp->_emxmouse_wfd = handles[1]; + M_FD(sp) = handles[0]; /* Needed? */ setmode(handles[0], O_BINARY); setmode(handles[1], O_BINARY); /* Do not use CRT functions, we may single-threaded. */ - rc = DosCreateThread((unsigned long *) &SP->_emxmouse_thread, - mouse_server, 0, 0, 8192); + rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread, + mouse_server, (long) sp, 0, 8192); if (rc) { printf("mouse thread error %d=%#x", rc, rc); } else { - SP->_mouse_type = M_XTERM; + sp->_mouse_type = M_XTERM; } returnVoid; } @@ -498,14 +561,14 @@ initialize_mousetype(void) struct mouse_info the_mouse; char *the_device = 0; - if (isatty(SP->_ifd)) - the_device = ttyname(SP->_ifd); + if (isatty(sp->_ifd)) + the_device = ttyname(sp->_ifd); if (the_device == 0) the_device = "/dev/tty"; - SP->_mouse_fd = open(the_device, O_RDWR); + sp->_mouse_fd = open(the_device, O_RDWR); - if (SP->_mouse_fd >= 0) { + if (sp->_mouse_fd >= 0) { /* * sysmouse does not have a usable user interface for obtaining * mouse events. The logical way to proceed (reading data on a @@ -522,10 +585,10 @@ initialize_mousetype(void) the_mouse.operation = MOUSE_MODE; the_mouse.u.mode.mode = 0; the_mouse.u.mode.signal = SIGUSR2; - if (ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) { + if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) { signal(SIGUSR2, handle_sysmouse); the_mouse.operation = MOUSE_SHOW; - ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse); + ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse); #if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */ { @@ -535,23 +598,23 @@ initialize_mousetype(void) #endif /* FBIO_GETMODE */ video_info_t the_video; - if (ioctl(SP->_mouse_fd, + if (ioctl(sp->_mouse_fd, FBIO_GETMODE, &the_video.vi_mode) != -1 - && ioctl(SP->_mouse_fd, + && ioctl(sp->_mouse_fd, FBIO_MODEINFO, &the_video) != -1) { - SP->_sysmouse_char_width = the_video.vi_cwidth; - SP->_sysmouse_char_height = the_video.vi_cheight; + sp->_sysmouse_char_width = the_video.vi_cwidth; + sp->_sysmouse_char_height = the_video.vi_cheight; } } #endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */ - if (SP->_sysmouse_char_width <= 0) - SP->_sysmouse_char_width = 8; - if (SP->_sysmouse_char_height <= 0) - SP->_sysmouse_char_height = 16; - SP->_mouse_type = M_SYSMOUSE; + if (sp->_sysmouse_char_width <= 0) + sp->_sysmouse_char_width = 8; + if (sp->_sysmouse_char_height <= 0) + sp->_sysmouse_char_height = 16; + sp->_mouse_type = M_SYSMOUSE; returnVoid; } } @@ -562,37 +625,37 @@ initialize_mousetype(void) if (key_mouse != 0) { if (!strcmp(key_mouse, xterm_kmous) || strstr(cur_term->type.term_names, "xterm") != 0) { - init_xterm_mouse(); + init_xterm_mouse(sp); } } else if (strstr(cur_term->type.term_names, "xterm") != 0) { - if (_nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE) == OK) - init_xterm_mouse(); + if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK) + init_xterm_mouse(sp); } returnVoid; } static bool -_nc_mouse_init(void) +_nc_mouse_init(SCREEN *sp) /* initialize the mouse */ { bool result = FALSE; int i; - if (SP != 0) { - if (!SP->_mouse_initialized) { - SP->_mouse_initialized = TRUE; + if (sp != 0) { + if (!sp->_mouse_initialized) { + sp->_mouse_initialized = TRUE; TR(MY_TRACE, ("_nc_mouse_init() called")); - SP->_mouse_eventp = SP->_mouse_events; + sp->_mouse_eventp = FirstEV(sp); for (i = 0; i < EV_MAX; i++) - SP->_mouse_events[i].id = INVALID_EVENT; + sp->_mouse_events[i].id = INVALID_EVENT; - initialize_mousetype(); + initialize_mousetype(sp); - T(("_nc_mouse_init() set mousetype to %d", SP->_mouse_type)); + T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type)); } - result = SP->_mouse_initialized; + result = sp->_mouse_initialized; } return result; } @@ -604,12 +667,12 @@ _nc_mouse_init(void) static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED) { - MEVENT *eventp = SP->_mouse_eventp; + MEVENT *eventp = sp->_mouse_eventp; bool result = FALSE; (void) eventp; - switch (SP->_mouse_type) { + switch (sp->_mouse_type) { case M_XTERM: /* xterm: never have to query, mouse events are in the keyboard stream */ #if USE_EMX_MOUSE @@ -666,7 +729,7 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED) eventp->z = 0; /* bump the next-free pointer into the circular list */ - SP->_mouse_eventp = eventp = NEXT(eventp); + sp->_mouse_eventp = eventp = NEXT(eventp); result = TRUE; } } @@ -675,22 +738,22 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED) #if USE_SYSMOUSE case M_SYSMOUSE: - if (SP->_sysmouse_head < SP->_sysmouse_tail) { - *eventp = SP->_sysmouse_fifo[SP->_sysmouse_head]; + if (sp->_sysmouse_head < sp->_sysmouse_tail) { + *eventp = sp->_sysmouse_fifo[sp->_sysmouse_head]; /* * Point the fifo-head to the next possible location. If there * are none, reset the indices. This may be interrupted by the * signal handler, doing essentially the same reset. */ - SP->_sysmouse_head += 1; - if (SP->_sysmouse_head == SP->_sysmouse_tail) { - SP->_sysmouse_tail = 0; - SP->_sysmouse_head = 0; + sp->_sysmouse_head += 1; + if (sp->_sysmouse_head == sp->_sysmouse_tail) { + sp->_sysmouse_tail = 0; + sp->_sysmouse_head = 0; } /* bump the next-free pointer into the circular list */ - SP->_mouse_eventp = eventp = NEXT(eventp); + sp->_mouse_eventp = eventp = NEXT(eventp); result = TRUE; } break; @@ -709,11 +772,11 @@ _nc_mouse_inline(SCREEN *sp) { int b; bool result = FALSE; - MEVENT *eventp = SP->_mouse_eventp; + MEVENT *eventp = sp->_mouse_eventp; TR(MY_TRACE, ("_nc_mouse_inline() called")); - if (SP->_mouse_type == M_XTERM) { + if (sp->_mouse_type == M_XTERM) { unsigned char kbuf[4]; mmask_t prev; size_t grabbed; @@ -751,7 +814,7 @@ _nc_mouse_inline(SCREEN *sp) * Wheel mice may return buttons 4 and 5 when the wheel is turned. * We encode those as button presses. */ - for (grabbed = 0; grabbed < 3; grabbed += res) { + for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) { /* For VIO mouse we add extra bit 64 to disambiguate button-up. */ #if USE_EMX_MOUSE @@ -781,9 +844,9 @@ _nc_mouse_inline(SCREEN *sp) eventp->bstate = MASK_RELEASE(n) #else #define PRESS_POSITION(n) \ - eventp->bstate = (prev & MASK_PRESS(n) \ - ? REPORT_MOUSE_POSITION \ - : MASK_PRESS(n)) + eventp->bstate = (mmask_t) (prev & MASK_PRESS(n) \ + ? REPORT_MOUSE_POSITION \ + : MASK_PRESS(n)) #endif switch (kbuf[0] & 0x3) { @@ -847,11 +910,11 @@ _nc_mouse_inline(SCREEN *sp) eventp->y = (kbuf[2] - ' ') - 1; TR(MY_TRACE, ("_nc_mouse_inline: primitive mouse-event %s has slot %ld", - _tracemouse(eventp), - (long) (eventp - SP->_mouse_events))); + _nc_tracemouse(sp, eventp), + (long) IndexEV(sp, eventp))); /* bump the next-free pointer into the circular list */ - SP->_mouse_eventp = NEXT(eventp); + sp->_mouse_eventp = NEXT(eventp); #if 0 /* this return would be needed for QNX's mods to lib_getch.c */ return (TRUE); #endif @@ -861,36 +924,36 @@ _nc_mouse_inline(SCREEN *sp) } static void -mouse_activate(bool on) +mouse_activate(SCREEN *sp, bool on) { - if (!on && !SP->_mouse_initialized) + if (!on && !sp->_mouse_initialized) return; - if (!_nc_mouse_init()) + if (!_nc_mouse_init(sp)) return; if (on) { - switch (SP->_mouse_type) { + switch (sp->_mouse_type) { case M_XTERM: #if NCURSES_EXT_FUNCS keyok(KEY_MOUSE, on); #endif TPUTS_TRACE("xterm mouse initialization"); - enable_xterm_mouse(1); + enable_xterm_mouse(sp, 1); break; #if USE_GPM_SUPPORT case M_GPM: - if (enable_gpm_mouse(1)) { - SP->_mouse_fd = *(my_gpm_fd); - T(("GPM mouse_fd %d", SP->_mouse_fd)); + if (enable_gpm_mouse(sp, TRUE)) { + sp->_mouse_fd = *(my_gpm_fd); + T(("GPM mouse_fd %d", sp->_mouse_fd)); } break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: signal(SIGUSR2, handle_sysmouse); - SP->_mouse_active = TRUE; + sp->_mouse_active = TRUE; break; #endif case M_NONE: @@ -899,27 +962,27 @@ mouse_activate(bool on) /* Make runtime binding to cut down on object size of applications that * do not use the mouse (e.g., 'clear'). */ - SP->_mouse_event = _nc_mouse_event; - SP->_mouse_inline = _nc_mouse_inline; - SP->_mouse_parse = _nc_mouse_parse; - SP->_mouse_resume = _nc_mouse_resume; - SP->_mouse_wrap = _nc_mouse_wrap; + sp->_mouse_event = _nc_mouse_event; + sp->_mouse_inline = _nc_mouse_inline; + sp->_mouse_parse = _nc_mouse_parse; + sp->_mouse_resume = _nc_mouse_resume; + sp->_mouse_wrap = _nc_mouse_wrap; } else { - switch (SP->_mouse_type) { + switch (sp->_mouse_type) { case M_XTERM: TPUTS_TRACE("xterm mouse deinitialization"); - enable_xterm_mouse(0); + enable_xterm_mouse(sp, 0); break; #if USE_GPM_SUPPORT case M_GPM: - enable_gpm_mouse(0); + enable_gpm_mouse(sp, FALSE); break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: signal(SIGUSR2, SIG_IGN); - SP->_mouse_active = FALSE; + sp->_mouse_active = FALSE; break; #endif case M_NONE: @@ -936,10 +999,10 @@ mouse_activate(bool on) **************************************************************************/ static bool -_nc_mouse_parse(int runcount) +_nc_mouse_parse(SCREEN *sp, int runcount) /* parse a run of atomic mouse events into a gesture */ { - MEVENT *eventp = SP->_mouse_eventp; + MEVENT *eventp = sp->_mouse_eventp; MEVENT *ep, *runp, *next, *prev = PREV(eventp); int n; int b; @@ -971,10 +1034,10 @@ _nc_mouse_parse(int runcount) if (runcount == 1) { TR(MY_TRACE, ("_nc_mouse_parse: returning simple mouse event %s at slot %ld", - _tracemouse(prev), - (long) (prev - SP->_mouse_events))); + _nc_tracemouse(sp, prev), + (long) IndexEV(sp, prev))); return (prev->id >= NORMAL_EVENT) - ? ((prev->bstate & SP->_mouse_mask) ? TRUE : FALSE) + ? ((prev->bstate & sp->_mouse_mask) ? TRUE : FALSE) : FALSE; } @@ -986,10 +1049,9 @@ _nc_mouse_parse(int runcount) #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _trace_slot("before mouse press/release merge:"); + _trace_slot(sp, "before mouse press/release merge:"); _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d", - (long) (runp - SP->_mouse_events), - (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX, + RunParams(sp, eventp, runp), runcount); _nc_unlock_global(tracef); } @@ -1014,7 +1076,7 @@ _nc_mouse_parse(int runcount) #endif ) { for (b = 1; b <= MAX_BUTTONS; ++b) { - if ((SP->_mouse_mask & MASK_CLICK(b)) + if ((sp->_mouse_mask & MASK_CLICK(b)) && (ep->bstate & MASK_PRESS(b))) { ep->bstate &= ~MASK_PRESS(b); ep->bstate |= MASK_CLICK(b); @@ -1030,10 +1092,9 @@ _nc_mouse_parse(int runcount) #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _trace_slot("before mouse click merge:"); + _trace_slot(sp, "before mouse click merge:"); _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d", - (long) (runp - SP->_mouse_events), - (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX, + RunParams(sp, eventp, runp), runcount); _nc_unlock_global(tracef); } @@ -1071,7 +1132,7 @@ _nc_mouse_parse(int runcount) if ((ep->bstate & BUTTON_CLICKED) && (follower->bstate & BUTTON_CLICKED)) { for (b = 1; b <= MAX_BUTTONS; ++b) { - if ((SP->_mouse_mask & MASK_DOUBLE_CLICK(b)) + if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b)) && (follower->bstate & MASK_CLICK(b))) { follower->bstate &= ~MASK_CLICK(b); follower->bstate |= MASK_DOUBLE_CLICK(b); @@ -1086,7 +1147,7 @@ _nc_mouse_parse(int runcount) if ((ep->bstate & BUTTON_DOUBLE_CLICKED) && (follower->bstate & BUTTON_CLICKED)) { for (b = 1; b <= MAX_BUTTONS; ++b) { - if ((SP->_mouse_mask & MASK_TRIPLE_CLICK(b)) + if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b)) && (follower->bstate & MASK_CLICK(b))) { follower->bstate &= ~MASK_CLICK(b); follower->bstate |= MASK_TRIPLE_CLICK(b); @@ -1102,10 +1163,9 @@ _nc_mouse_parse(int runcount) #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _trace_slot("before mouse event queue compaction:"); + _trace_slot(sp, "before mouse event queue compaction:"); _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d", - (long) (runp - SP->_mouse_events), - (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX, + RunParams(sp, eventp, runp), runcount); _nc_unlock_global(tracef); } @@ -1116,15 +1176,14 @@ _nc_mouse_parse(int runcount) * don't match the current event mask. */ for (; runcount; prev = PREV(eventp), runcount--) - if (prev->id == INVALID_EVENT || !(prev->bstate & SP->_mouse_mask)) { - SP->_mouse_eventp = eventp = prev; + if (prev->id == INVALID_EVENT || !(prev->bstate & sp->_mouse_mask)) { + sp->_mouse_eventp = eventp = prev; } #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { - _trace_slot("after mouse event queue compaction:"); + _trace_slot(sp, "after mouse event queue compaction:"); _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d", - (long) (runp - SP->_mouse_events), - (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX, + RunParams(sp, eventp, runp), runcount); _nc_unlock_global(tracef); } @@ -1132,8 +1191,8 @@ _nc_mouse_parse(int runcount) if (ep->id != INVALID_EVENT) TR(MY_TRACE, ("_nc_mouse_parse: returning composite mouse event %s at slot %ld", - _tracemouse(ep), - (long) (ep - SP->_mouse_events))); + _nc_tracemouse(sp, ep), + (long) IndexEV(sp, ep))); #endif /* TRACE */ /* after all this, do we have a valid event? */ @@ -1141,26 +1200,26 @@ _nc_mouse_parse(int runcount) } static void -_nc_mouse_wrap(SCREEN *sp GCC_UNUSED) +_nc_mouse_wrap(SCREEN *sp) /* release mouse -- called by endwin() before shellout/exit */ { TR(MY_TRACE, ("_nc_mouse_wrap() called")); - switch (SP->_mouse_type) { + switch (sp->_mouse_type) { case M_XTERM: - if (SP->_mouse_mask) - mouse_activate(FALSE); + if (sp->_mouse_mask) + mouse_activate(sp, FALSE); break; #if USE_GPM_SUPPORT /* GPM: pass all mouse events to next client */ case M_GPM: - if (SP->_mouse_mask) - mouse_activate(FALSE); + if (sp->_mouse_mask) + mouse_activate(sp, FALSE); break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: - mouse_activate(FALSE); + mouse_activate(sp, FALSE); break; #endif case M_NONE: @@ -1169,29 +1228,29 @@ _nc_mouse_wrap(SCREEN *sp GCC_UNUSED) } static void -_nc_mouse_resume(SCREEN *sp GCC_UNUSED) +_nc_mouse_resume(SCREEN *sp) /* re-connect to mouse -- called by doupdate() after shellout */ { TR(MY_TRACE, ("_nc_mouse_resume() called")); - switch (SP->_mouse_type) { + switch (sp->_mouse_type) { case M_XTERM: /* xterm: re-enable reporting */ - if (SP->_mouse_mask) - mouse_activate(TRUE); + if (sp->_mouse_mask) + mouse_activate(sp, TRUE); break; #if USE_GPM_SUPPORT case M_GPM: /* GPM: reclaim our event set */ - if (SP->_mouse_mask) - mouse_activate(TRUE); + if (sp->_mouse_mask) + mouse_activate(sp, TRUE); break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: - mouse_activate(TRUE); + mouse_activate(sp, TRUE); break; #endif case M_NONE: @@ -1205,14 +1264,13 @@ _nc_mouse_resume(SCREEN *sp GCC_UNUSED) * **************************************************************************/ -NCURSES_EXPORT(int) -getmouse(MEVENT * aevent) -/* grab a copy of the current mouse event */ +static int +_nc_getmouse(SCREEN *sp, MEVENT * aevent) { T((T_CALLED("getmouse(%p)"), aevent)); - if ((aevent != 0) && (SP != 0) && (SP->_mouse_type != M_NONE)) { - MEVENT *eventp = SP->_mouse_eventp; + if ((aevent != 0) && (sp != 0) && (sp->_mouse_type != M_NONE)) { + MEVENT *eventp = sp->_mouse_eventp; /* compute the current-event pointer */ MEVENT *prev = PREV(eventp); @@ -1220,8 +1278,8 @@ getmouse(MEVENT * aevent) *aevent = *prev; TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld", - _tracemouse(prev), - (long) (prev - SP->_mouse_events))); + _nc_tracemouse(sp, prev), + (long) IndexEV(sp, prev))); prev->id = INVALID_EVENT; /* so the queue slot becomes free */ returnCode(OK); @@ -1229,29 +1287,42 @@ getmouse(MEVENT * aevent) returnCode(ERR); } +/* grab a copy of the current mouse event */ NCURSES_EXPORT(int) -ungetmouse(MEVENT * aevent) -/* enqueue a synthesized mouse event to be seen by the next wgetch() */ +getmouse(MEVENT * aevent) +{ + return _nc_getmouse(SP, aevent); +} + +static int +_nc_ungetmouse(SCREEN *sp, MEVENT * aevent) { int result = ERR; T((T_CALLED("ungetmouse(%p)"), aevent)); - if (aevent != 0 && SP != 0) { - MEVENT *eventp = SP->_mouse_eventp; + if (aevent != 0 && sp != 0) { + MEVENT *eventp = sp->_mouse_eventp; /* stick the given event in the next-free slot */ *eventp = *aevent; /* bump the next-free pointer into the circular list */ - SP->_mouse_eventp = NEXT(eventp); + sp->_mouse_eventp = NEXT(eventp); /* push back the notification event on the keyboard queue */ - result = ungetch(KEY_MOUSE); + result = _nc_ungetch(sp, KEY_MOUSE); } returnCode(result); } +/* enqueue a synthesized mouse event to be seen by the next wgetch() */ +NCURSES_EXPORT(int) +ungetmouse(MEVENT * aevent) +{ + return _nc_ungetmouse(SP, aevent); +} + NCURSES_EXPORT(mmask_t) mousemask(mmask_t newmask, mmask_t * oldmask) /* set the mouse event mask */ @@ -1265,7 +1336,7 @@ mousemask(mmask_t newmask, mmask_t * oldmask) *oldmask = SP->_mouse_mask; if (newmask || SP->_mouse_initialized) { - _nc_mouse_init(); + _nc_mouse_init(SP); if (SP->_mouse_type != M_NONE) { result = newmask & (REPORT_MOUSE_POSITION @@ -1278,14 +1349,11 @@ mousemask(mmask_t newmask, mmask_t * oldmask) | BUTTON_DOUBLE_CLICKED | BUTTON_TRIPLE_CLICKED); - mouse_activate((bool) (result != 0)); + mouse_activate(SP, (bool) (result != 0)); SP->_mouse_mask = result; } } - } else { - if (oldmask) - *oldmask = SP->_mouse_mask; } returnBits(result); } diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c index 3620a3fdbf2b..05982b84cee4 100644 --- a/ncurses/base/lib_newterm.c +++ b/ncurses/base/lib_newterm.c @@ -48,7 +48,7 @@ #include /* clear_screen, cup & friends, cur_term */ #include -MODULE_ID("$Id: lib_newterm.c,v 1.69 2008/04/12 18:15:04 tom Exp $") +MODULE_ID("$Id: lib_newterm.c,v 1.73 2008/08/16 21:20:48 Werner.Fink Exp $") #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 @@ -125,11 +125,17 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) int errret; SCREEN *current; SCREEN *result = 0; + TERMINAL *its_term; START_TRACE(); T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp)); - _nc_lock_global(set_SP); + _nc_init_pthreads(); + _nc_lock_global(curses); + + current = SP; + its_term = (SP ? SP->_term : 0); + /* this loads the capability entry, then sets LINES and COLS */ if (setupterm(name, fileno(ofp), &errret) != ERR) { int slk_format = _nc_globals.slk_format; @@ -138,7 +144,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) * This actually allocates the screen structure, and saves the original * terminal settings. */ - current = SP; _nc_set_screen(0); /* allow user to set maximum escape delay from the environment */ @@ -154,6 +159,19 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) _nc_set_screen(current); result = 0; } else { + assert(SP != 0); + /* + * In setupterm() we did a set_curterm(), but it was before we set + * SP. So the "current" screen's terminal pointer was overwritten + * with a different terminal. Later, in _nc_setupscreen(), we set + * SP and the terminal pointer in the new screen. + * + * Restore the terminal-pointer for the pre-existing screen, if + * any. + */ + if (current) + current->_term = its_term; + /* if the terminal type has real soft labels, set those up */ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format)) _nc_slk_initialize(stdscr, COLS); @@ -212,6 +230,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) result = SP; } } - _nc_unlock_global(set_SP); + _nc_unlock_global(curses); returnSP(result); } diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c index 7f7aa3e04f1e..587e83a92009 100644 --- a/ncurses/base/lib_newwin.c +++ b/ncurses/base/lib_newwin.c @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: lib_newwin.c,v 1.50 2008/05/03 16:36:39 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.52 2008/06/07 13:58:09 tom Exp $") #define window_is(name) ((sp)->_##name == win) @@ -85,7 +85,7 @@ _nc_freewin(WINDOW *win) T((T_CALLED("_nc_freewin(%p)"), win)); if (win != 0) { - if (_nc_try_global(windowlist) == 0) { + if (_nc_try_global(curses) == 0) { q = 0; for (each_window(p)) { if (&(p->win) == win) { @@ -108,7 +108,7 @@ _nc_freewin(WINDOW *win) } q = p; } - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); } } returnCode(result); @@ -229,8 +229,6 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) if ((wp = typeCalloc(WINDOWLIST, 1)) == 0) returnWin(0); - _nc_mutex_init(&(wp->mutex_use_window)); - win = &(wp->win); if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) { @@ -238,7 +236,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) returnWin(0); } - _nc_lock_global(windowlist); + _nc_lock_global(curses); win->_curx = 0; win->_cury = 0; @@ -313,10 +311,28 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) } wp->next = _nc_windows; + wp->screen = SP; _nc_windows = wp; T((T_CREATE("window %p"), win)); - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); returnWin(win); } + +/* + * wgetch() and other functions with a WINDOW* parameter may use a SCREEN* + * internally, and it is useful to allow those to be invoked without switching + * SCREEN's, e.g., for multi-threaded applications. + */ +NCURSES_EXPORT(SCREEN *) +_nc_screen_of(WINDOW *win) +{ + SCREEN *sp = 0; + + if (win != 0) { + WINDOWLIST *wp = (WINDOWLIST *) win; + sp = wp->screen; + } + return (sp); +} diff --git a/ncurses/base/lib_overlay.c b/ncurses/base/lib_overlay.c index 26314de5e5fb..669e8e72c07f 100644 --- a/ncurses/base/lib_overlay.c +++ b/ncurses/base/lib_overlay.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_overlay.c,v 1.25 2008/04/12 17:21:59 tom Exp $") +MODULE_ID("$Id: lib_overlay.c,v 1.27 2008/06/07 23:30:34 tom Exp $") static int overlap(const WINDOW *const src, WINDOW *const dst, int const flag) @@ -55,8 +55,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag) T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag)); if (src != 0 && dst != 0) { - _nc_lock_window(src); - _nc_lock_window(dst); + _nc_lock_global(curses); T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld", (long) src->_begy, @@ -93,8 +92,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag) dmaxrow, dmaxcol, flag); } - _nc_unlock_window(dst); - _nc_unlock_window(src); + _nc_unlock_global(curses); } returnCode(rc); } @@ -150,9 +148,7 @@ copywin(const WINDOW *src, WINDOW *dst, src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over)); if (src && dst) { - - _nc_lock_window(src); - _nc_lock_window(dst); + _nc_lock_global(curses); bk = AttrOf(dst->_nc_bkgd); mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0); @@ -204,8 +200,7 @@ copywin(const WINDOW *src, WINDOW *dst, rc = OK; } } - _nc_unlock_window(dst); - _nc_unlock_window(src); + _nc_unlock_global(curses); } returnCode(rc); } diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c index 9742ff629fbd..da770d4e7c92 100644 --- a/ncurses/base/lib_restart.c +++ b/ncurses/base/lib_restart.c @@ -36,8 +36,6 @@ * Terminfo-only terminal setup routines: * * int restartterm(const char *, int, int *) - * TERMINAL *set_curterm(TERMINAL *) - * int del_curterm(TERMINAL *) */ #include @@ -48,7 +46,7 @@ #include /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_restart.c,v 1.9 2008/05/03 22:43:52 tom Exp $") +MODULE_ID("$Id: lib_restart.c,v 1.10 2008/06/21 17:31:22 tom Exp $") NCURSES_EXPORT(int) restartterm(NCURSES_CONST char *termp, int filenum, int *errret) diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c index e6aecbdaab47..4aa58ea2a19c 100644 --- a/ncurses/base/lib_screen.c +++ b/ncurses/base/lib_screen.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,12 +29,14 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * - * and: Thomas E. Dickey 1996 on * + * and: Thomas E. Dickey 1996 on * ****************************************************************************/ #include -MODULE_ID("$Id: lib_screen.c,v 1.30 2007/03/10 23:20:41 tom Exp $") +MODULE_ID("$Id: lib_screen.c,v 1.31 2008/08/16 19:05:37 tom Exp $") + +#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ NCURSES_EXPORT(WINDOW *) getwin(FILE *filep) @@ -46,7 +48,11 @@ getwin(FILE *filep) clearerr(filep); (void) fread(&tmp, sizeof(WINDOW), 1, filep); - if (ferror(filep)) + if (ferror(filep) + || tmp._maxy == 0 + || tmp._maxy > MAX_SIZE + || tmp._maxx == 0 + || tmp._maxx > MAX_SIZE) returnWin(0); if (tmp._flags & _ISPAD) { @@ -115,7 +121,7 @@ putwin(WINDOW *win, FILE *filep) T((T_CALLED("putwin(%p,%p)"), win, filep)); if (win != 0) { - size_t len = (win->_maxx + 1); + size_t len = (size_t) (win->_maxx + 1); clearerr(filep); if (fwrite(win, sizeof(WINDOW), 1, filep) != 1 diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index eee1cfc7b259..aff432bb9fd1 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -44,28 +44,30 @@ #include /* cur_term */ #include -MODULE_ID("$Id: lib_set_term.c,v 1.108 2008/05/03 22:42:43 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.117 2008/08/04 18:11:12 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN *screenp) { SCREEN *oldSP; + SCREEN *newSP; T((T_CALLED("set_term(%p)"), screenp)); - _nc_lock_global(set_SP); + _nc_lock_global(curses); oldSP = SP; _nc_set_screen(screenp); + newSP = SP; - if (SP != 0) { - set_curterm(SP->_term); + if (newSP != 0) { + set_curterm(newSP->_term); #if !USE_REENTRANT - curscr = SP->_curscr; - newscr = SP->_newscr; - stdscr = SP->_stdscr; - COLORS = SP->_color_count; - COLOR_PAIRS = SP->_pair_count; + curscr = newSP->_curscr; + newscr = newSP->_newscr; + stdscr = newSP->_stdscr; + COLORS = newSP->_color_count; + COLOR_PAIRS = newSP->_pair_count; #endif } else { set_curterm(0); @@ -78,7 +80,7 @@ set_term(SCREEN *screenp) #endif } - _nc_unlock_global(set_SP); + _nc_unlock_global(curses); T((T_RETURN("%p"), oldSP)); return (oldSP); @@ -125,7 +127,7 @@ delscreen(SCREEN *sp) T((T_CALLED("delscreen(%p)"), sp)); - _nc_lock_global(set_SP); + _nc_lock_global(curses); if (delink_screen(sp)) { (void) _nc_freewin(sp->_curscr); @@ -162,8 +164,6 @@ delscreen(SCREEN *sp) FreeIfNeeded(sp->_acs_map); FreeIfNeeded(sp->_screen_acs_map); - del_curterm(sp->_term); - /* * If the associated output stream has been closed, we can discard the * set-buffer. Limit the error check to EBADF, since fflush may fail @@ -176,6 +176,7 @@ delscreen(SCREEN *sp) free(sp->_setbuf); } + del_curterm(sp->_term); free(sp); /* @@ -194,7 +195,7 @@ delscreen(SCREEN *sp) _nc_set_screen(0); } } - _nc_unlock_global(set_SP); + _nc_unlock_global(curses); returnVoid; } @@ -212,7 +213,7 @@ no_mouse_inline(SCREEN *sp GCC_UNUSED) } static bool -no_mouse_parse(int code GCC_UNUSED) +no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED) { return TRUE; } @@ -321,11 +322,7 @@ _nc_setupscreen(int slines GCC_UNUSED, SP->_ofp = output; SP->_cursor = -1; /* cannot know real cursor shape */ -#if NCURSES_NO_PADDING - SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0; - TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used", - SP->_no_padding ? " not" : "")); -#endif + SetNoPadding(SP); #if NCURSES_EXT_FUNCS SP->_default_color = FALSE; @@ -362,11 +359,10 @@ _nc_setupscreen(int slines GCC_UNUSED, * Allow those assumed/default color assumptions to be overridden at * runtime: */ - if (getenv("NCURSES_ASSUMED_COLORS") != 0) { - char *p = getenv("NCURSES_ASSUMED_COLORS"); + if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) { int fg, bg; char sep1, sep2; - int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &sep2); + int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2); if (count >= 1) { SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK; if (count >= 3) { @@ -422,11 +418,6 @@ _nc_setupscreen(int slines GCC_UNUSED, SP->_mouse_wrap = no_mouse_wrap; SP->_mouse_fd = -1; - /* initialize the panel hooks */ - SP->_panelHook.top_panel = (struct panel *) 0; - SP->_panelHook.bottom_panel = (struct panel *) 0; - SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0; - /* * If we've no magic cookie support, we suppress attributes that xmc would * affect, i.e., the attributes that affect the rendition of a space. @@ -515,7 +506,7 @@ _nc_setupscreen(int slines GCC_UNUSED, /* initialize normal acs before wide, since we use mapping in the latter */ #if !USE_WIDEC_SUPPORT - if (_nc_unicode_locale() && _nc_locale_breaks_acs()) { + if (_nc_unicode_locale() && _nc_locale_breaks_acs(cur_term)) { acs_chars = NULL; ena_acs = NULL; enter_alt_charset_mode = NULL; @@ -527,7 +518,8 @@ _nc_setupscreen(int slines GCC_UNUSED, #if USE_WIDEC_SUPPORT _nc_init_wacs(); - SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs()); + SP->_screen_acs_fix = (_nc_unicode_locale() + && _nc_locale_breaks_acs(cur_term)); #endif env = _nc_get_locale(); SP->_legacy_coding = ((env == 0) diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c index 27b21b08d718..662f7e45b116 100644 --- a/ncurses/base/lib_slk.c +++ b/ncurses/base/lib_slk.c @@ -45,32 +45,7 @@ #include #include /* num_labels, label_*, plab_norm */ -MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $") - -/* - * We'd like to move these into the screen context structure, but cannot, - * because slk_init() is called before initscr()/newterm(). - */ -NCURSES_EXPORT_VAR(int) -_nc_slk_format = 0; /* one more than format specified in slk_init() */ - -/* - * Paint the info line for the PC style SLK emulation. - */ -static void -slk_paint_info(WINDOW *win) -{ - if (win && SP->slk_format == 4) { - int i; - - mvwhline(win, 0, 0, 0, getmaxx(win)); - wmove(win, 0, 0); - - for (i = 0; i < SP->_slk->maxlab; i++) { - mvwprintw(win, 0, SP->_slk->ent[i].ent_x, "F%d", i + 1); - } - } -} +MODULE_ID("$Id: lib_slk.c,v 1.35 2008/09/27 14:07:33 juergen Exp $") /* * Free any memory related to soft labels, return an error. @@ -145,7 +120,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols) memset(SP->_slk->ent[i].form_text, 0, used); memset(SP->_slk->ent[i].form_text, ' ', max_length); - SP->_slk->ent[i].visible = (i < SP->_slk->maxlab); + SP->_slk->ent[i].visible = (char) (i < SP->_slk->maxlab); } if (_nc_globals.slk_format >= 3) { /* PC style */ int gap = (cols - 3 * (3 + 4 * max_length)) / 2; @@ -158,7 +133,6 @@ _nc_slk_initialize(WINDOW *stwin, int cols) x += max_length; x += (i == 3 || i == 7) ? gap : 1; } - slk_paint_info(stwin); } else { if (_nc_globals.slk_format == 2) { /* 4-4 */ int gap = cols - (SP->_slk->maxlab * max_length) - 6; @@ -212,8 +186,6 @@ slk_restore(void) return (ERR); SP->_slk->hidden = FALSE; SP->_slk->dirty = TRUE; - /* we have to repaint info line eventually */ - slk_paint_info(SP->_slk->win); returnCode(slk_refresh()); } diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c index c8ca28b9dd84..cb1beba0e2a1 100644 --- a/ncurses/base/lib_slkrefr.c +++ b/ncurses/base/lib_slkrefr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +40,27 @@ #include #include /* num_labels, label_*, plab_norm */ -MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $") +MODULE_ID("$Id: lib_slkrefr.c,v 1.17 2008/09/27 14:07:53 juergen Exp $") + +/* + * Paint the info line for the PC style SLK emulation. + */ +static void +slk_paint_info(WINDOW *win) +{ + SCREEN *sp = _nc_screen_of(win); + + if (win && sp && (sp->slk_format == 4)) { + int i; + + mvwhline(win, 0, 0, 0, getmaxx(win)); + wmove(win, 0, 0); + + for (i = 0; i < sp->_slk->maxlab; i++) { + mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1); + } + } +} /* * Write the soft labels to the soft-key window. @@ -60,8 +80,10 @@ slk_intern_refresh(SLK * slk) putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); } } else { + if (fmt == 4) + slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); - if (SP && SP->_slk) { + if (SP->_slk) { wattrset(slk->win, AttrOf(SP->_slk->attr)); } waddstr(slk->win, slk->ent[i].form_text); diff --git a/ncurses/base/lib_ungetch.c b/ncurses/base/lib_ungetch.c index 2eda99017bed..8742f867fa94 100644 --- a/ncurses/base/lib_ungetch.c +++ b/ncurses/base/lib_ungetch.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_ungetch.c,v 1.10 2008/05/03 20:20:58 tom Exp $") +MODULE_ID("$Id: lib_ungetch.c,v 1.11 2008/05/31 16:44:54 tom Exp $") #include @@ -52,7 +52,7 @@ _nc_fifo_dump(SCREEN *sp) int i; T(("head = %d, tail = %d, peek = %d", head, tail, peek)); for (i = 0; i < 10; i++) - T(("char %d = %s", i, _tracechar(sp->_fifo[i]))); + T(("char %d = %s", i, _nc_tracechar(sp, sp->_fifo[i]))); } #endif /* TRACE */ @@ -70,7 +70,7 @@ _nc_ungetch(SCREEN *sp, int ch) h_dec(); sp->_fifo[head] = ch; - T(("ungetch %s ok", _tracechar(ch))); + T(("ungetch %s ok", _nc_tracechar(sp, ch))); #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { _nc_fifo_dump(sp); @@ -85,6 +85,6 @@ _nc_ungetch(SCREEN *sp, int ch) NCURSES_EXPORT(int) ungetch(int ch) { - T((T_CALLED("ungetch(%s)"), _tracechar(ch))); + T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP, ch))); returnCode(_nc_ungetch(SP, ch)); } diff --git a/ncurses/base/lib_window.c b/ncurses/base/lib_window.c index ac61cb01da99..a3236e206a37 100644 --- a/ncurses/base/lib_window.c +++ b/ncurses/base/lib_window.c @@ -39,7 +39,7 @@ #include -MODULE_ID("$Id: lib_window.c,v 1.24 2008/04/12 22:40:21 tom Exp $") +MODULE_ID("$Id: lib_window.c,v 1.25 2008/06/07 14:12:56 tom Exp $") NCURSES_EXPORT(void) _nc_synchook(WINDOW *win) @@ -186,7 +186,7 @@ dupwin(WINDOW *win) if (win != 0) { - _nc_lock_window(win); + _nc_lock_global(curses); if (win->_flags & _ISPAD) { nwin = newpad(win->_maxy + 1, win->_maxx + 1); @@ -244,7 +244,7 @@ dupwin(WINDOW *win) nwin->_line[i].lastchar = win->_line[i].lastchar; } } - _nc_unlock_window(win); + _nc_unlock_global(curses); } returnWin(nwin); } diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c index cf2c998e239f..a94cfc3aaaa8 100644 --- a/ncurses/base/resizeterm.c +++ b/ncurses/base/resizeterm.c @@ -41,7 +41,7 @@ #include #include -MODULE_ID("$Id: resizeterm.c,v 1.32 2008/05/03 14:28:55 tom Exp $") +MODULE_ID("$Id: resizeterm.c,v 1.34 2008/06/07 13:58:40 tom Exp $") #define stolen_lines (screen_lines - SP->_lines_avail) @@ -66,7 +66,7 @@ show_window_sizes(const char *name) { WINDOWLIST *wp; - _nc_lock_global(windowlist); + _nc_lock_global(curses); _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS, screen_lines, screen_columns); for (each_window(wp)) { @@ -77,7 +77,7 @@ show_window_sizes(const char *name) (long) wp->win._begy, (long) wp->win._begx); } - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); } #endif @@ -320,7 +320,7 @@ resize_term(int ToLines, int ToCols) returnCode(ERR); } - _nc_lock_global(windowlist); + _nc_lock_global(curses); was_stolen = (screen_lines - SP->_lines_avail); if (is_term_resized(ToLines, ToCols)) { @@ -378,7 +378,7 @@ resize_term(int ToLines, int ToCols) SET_LINES(ToLines - was_stolen); SET_COLS(ToCols); - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); returnCode(result); } @@ -418,7 +418,7 @@ resizeterm(int ToLines, int ToCols) result = resize_term(ToLines, ToCols); #if USE_SIGWINCH - ungetch(KEY_RESIZE); /* so application can know this */ + _nc_ungetch(SP, KEY_RESIZE); /* so application can know this */ clearok(curscr, TRUE); /* screen contents are unknown */ /* ripped-off lines are a special case: if we did not lengthen diff --git a/ncurses/base/tries.c b/ncurses/base/tries.c index 983a75ae7882..c4263c7e50eb 100644 --- a/ncurses/base/tries.c +++ b/ncurses/base/tries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include -MODULE_ID("$Id: tries.c,v 1.25 2007/09/29 20:37:13 tom Exp $") +MODULE_ID("$Id: tries.c,v 1.27 2008/08/16 19:22:55 tom Exp $") /* * Expand a keycode into the string that it corresponds to, returning null if @@ -68,11 +68,11 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len) } } if (result != 0) { - if (ptr != 0 && (result[len] = ptr->ch) == 0) + if (ptr != 0 && (result[len] = (char) ptr->ch) == 0) *((unsigned char *) (result + len)) = 128; #ifdef TRACE if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) { - _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result)); + _tracef("expand_key %s %s", _nc_tracechar(SP, code), _nc_visbuf(result)); _nc_unlock_global(tracef); } #endif diff --git a/ncurses/base/use_window.c b/ncurses/base/use_window.c index 4d0fdf6705be..f6408c37928e 100644 --- a/ncurses/base/use_window.c +++ b/ncurses/base/use_window.c @@ -32,37 +32,7 @@ #include -MODULE_ID("$Id: use_window.c,v 1.7 2008/05/03 14:09:38 tom Exp $") - -#ifdef USE_PTHREADS -NCURSES_EXPORT(void) -_nc_lock_window(const WINDOW *win) -{ - WINDOWLIST *p; - - _nc_lock_global(windowlist); - for (each_window(p)) { - if (&(p->win) == win) { - _nc_mutex_lock(&(p->mutex_use_window)); - break; - } - } -} - -NCURSES_EXPORT(void) -_nc_unlock_window(const WINDOW *win) -{ - WINDOWLIST *p; - - for (each_window(p)) { - if (&(p->win) == win) { - _nc_mutex_unlock(&(p->mutex_use_window)); - break; - } - } - _nc_unlock_global(windowlist); -} -#endif +MODULE_ID("$Id: use_window.c,v 1.8 2008/06/07 14:13:46 tom Exp $") NCURSES_EXPORT(int) use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data) @@ -70,9 +40,9 @@ use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data) int code = OK; T((T_CALLED("use_window(%p,%p,%p)"), win, func, data)); - _nc_lock_window(win); + _nc_lock_global(curses); code = func(win, data); - _nc_unlock_window(win); + _nc_unlock_global(curses); returnCode(code); } diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c index ac808c4d2884..f46085af59fa 100644 --- a/ncurses/base/wresize.c +++ b/ncurses/base/wresize.c @@ -32,7 +32,7 @@ #include -MODULE_ID("$Id: wresize.c,v 1.28 2008/05/03 14:13:51 tom Exp $") +MODULE_ID("$Id: wresize.c,v 1.29 2008/06/07 13:59:01 tom Exp $") static int cleanup_lines(struct ldat *data, int length) @@ -54,7 +54,7 @@ repair_subwindows(WINDOW *cmp) struct ldat *pline = cmp->_line; int row; - _nc_lock_global(windowlist); + _nc_lock_global(curses); for (each_window(wp)) { WINDOW *tst = &(wp->win); @@ -77,7 +77,7 @@ repair_subwindows(WINDOW *cmp) repair_subwindows(tst); } } - _nc_unlock_global(windowlist); + _nc_unlock_global(curses); } /* diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 422c74cb2a3f..29e131953415 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ /* - * $Id: curses.priv.h,v 1.373 2008/05/03 23:30:35 tom Exp $ + * $Id: curses.priv.h,v 1.394 2008/10/04 21:37:45 tom Exp $ * * curses.priv.h * @@ -147,7 +147,7 @@ extern int errno; #define HAVE_SIZECHANGE 0 #endif -#if HAVE_SIZECHANGE && defined(SIGWINCH) +#if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH) #define USE_SIZECHANGE 1 #else #define USE_SIZECHANGE 0 @@ -286,6 +286,15 @@ color_t; #define VIDATTR(attr, pair) vidattr(attr) #endif +#if NCURSES_NO_PADDING +#define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding) +#define SetNoPadding(sp) _nc_set_no_padding(sp) +extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *); +#else +#define GetNoPadding(sp) FALSE +#define SetNoPadding(sp) /*nothing*/ +#endif + #define WINDOW_ATTRS(w) ((w)->_attrs) #define SCREEN_ATTRS(s) (*((s)->_current_attr)) @@ -293,9 +302,15 @@ color_t; #define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p) #if USE_REENTRANT -#define SET_LINES(value) SP->_LINES = value -#define SET_COLS(value) SP->_COLS = value +NCURSES_EXPORT(int *) _nc_ptr_Lines (void); +NCURSES_EXPORT(int *) _nc_ptr_Cols (void); +#define ptrLines() (SP ? &(SP->_LINES) : &(_nc_prescreen._LINES)) +#define ptrCols() (SP ? &(SP->_COLS) : &(_nc_prescreen._COLS)) +#define SET_LINES(value) *_nc_ptr_Lines() = value +#define SET_COLS(value) *_nc_ptr_Cols() = value #else +#define ptrLines() &LINES +#define ptrCols() &COLS #define SET_LINES(value) LINES = value #define SET_COLS(value) COLS = value #endif @@ -315,6 +330,7 @@ color_t; #if USE_REENTRANT #include +extern NCURSES_EXPORT(void) _nc_init_pthreads(void); extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *); extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *); extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *); @@ -323,13 +339,40 @@ extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *); #define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name) #define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name) -extern NCURSES_EXPORT(void) _nc_lock_window(const WINDOW *); -extern NCURSES_EXPORT(void) _nc_unlock_window(const WINDOW *); - #else #error POSIX threads requires --enable-reentrant option #endif +#if USE_WEAK_SYMBOLS +#if defined(__GNUC__) +# if defined __USE_ISOC99 +# define _cat_pragma(exp) _Pragma(#exp) +# define _weak_pragma(exp) _cat_pragma(weak name) +# else +# define _weak_pragma(exp) +# endif +# define _declare(name) __extension__ extern __typeof__(name) name +# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak)) +#endif +#endif + +#ifdef USE_PTHREADS +# if USE_WEAK_SYMBOLS +weak_symbol(pthread_sigmask); +weak_symbol(pthread_self); +weak_symbol(pthread_equal); +weak_symbol(pthread_mutex_init); +weak_symbol(pthread_mutex_lock); +weak_symbol(pthread_mutex_unlock); +weak_symbol(pthread_mutex_trylock); +weak_symbol(pthread_mutexattr_settype); +weak_symbol(pthread_mutexattr_init); +extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); +# undef sigprocmask +# define sigprocmask _nc_sigprocmask +# endif +#endif + #if HAVE_NANOSLEEP #undef HAVE_NANOSLEEP #define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */ @@ -337,15 +380,13 @@ extern NCURSES_EXPORT(void) _nc_unlock_window(const WINDOW *); #else /* !USE_PTHREADS */ +#define _nc_init_pthreads() /* nothing */ #define _nc_mutex_init(obj) /* nothing */ #define _nc_lock_global(name) /* nothing */ #define _nc_try_global(name) 0 #define _nc_unlock_global(name) /* nothing */ -#define _nc_lock_window(name) (void) TRUE -#define _nc_unlock_window(name) /* nothing */ - #endif /* USE_PTHREADS */ #if HAVE_GETTIMEOFDAY @@ -597,8 +638,6 @@ typedef struct { char *tracedmp_buf; size_t tracedmp_used; - char tracemse_buf[TRACEMSE_MAX]; - unsigned char *tracetry_buf; size_t tracetry_used; @@ -609,13 +648,12 @@ typedef struct { #endif /* TRACE */ #ifdef USE_PTHREADS - pthread_mutex_t mutex_set_SP; - pthread_mutex_t mutex_use_screen; - pthread_mutex_t mutex_use_window; - pthread_mutex_t mutex_windowlist; - pthread_mutex_t mutex_tst_tracef; - pthread_mutex_t mutex_tracef; - int nested_tracef; + pthread_mutex_t mutex_curses; + pthread_mutex_t mutex_tst_tracef; + pthread_mutex_t mutex_tracef; + int nested_tracef; + int use_pthreads; +#define _nc_use_pthreads _nc_globals.use_pthreads #endif } NCURSES_GLOBALS; @@ -635,10 +673,14 @@ typedef struct { ripoff_t *rsp; TPARM_STATE tparm_state; TTY *saved_tty; /* savetty/resetty information */ +#if NCURSES_NO_PADDING + bool _no_padding; /* flag to set if padding disabled */ +#endif #if BROKEN_LINKER || USE_REENTRANT chtype *real_acs_map; int _LINES; int _COLS; + TERMINAL *_cur_term; #ifdef TRACE long _outchars; const char *_tputs_trace; @@ -704,7 +746,7 @@ struct screen { int slk_format; /* selected format for this screen */ /* cursor movement costs; units are 10ths of milliseconds */ #if NCURSES_NO_PADDING - int _no_padding; /* flag to set if padding disabled */ + bool _no_padding; /* flag to set if padding disabled */ #endif int _char_padding; /* cost of character put */ int _cr_cost; /* cost of (carriage_return) */ @@ -789,7 +831,7 @@ struct screen { int _maxclick; bool (*_mouse_event) (SCREEN *); bool (*_mouse_inline)(SCREEN *); - bool (*_mouse_parse) (int); + bool (*_mouse_parse) (SCREEN *, int); void (*_mouse_resume)(SCREEN *); void (*_mouse_wrap) (SCREEN *); int _mouse_fd; /* file-descriptor, if any */ @@ -803,6 +845,7 @@ struct screen { bool _mouse_gpm_loaded; bool _mouse_gpm_found; #ifdef HAVE_LIBDL + void *_dlopen_gpm; TYPE_gpm_fd _mouse_gpm_fd; TYPE_Gpm_Open _mouse_Gpm_Open; TYPE_Gpm_Close _mouse_Gpm_Close; @@ -866,6 +909,11 @@ struct screen { long _outchars; const char *_tputs_trace; #endif +#endif + +#ifdef TRACE + char tracechr_buf[40]; + char tracemse_buf[TRACEMSE_MAX]; #endif /* * ncurses/ncursesw are the same up to this point. @@ -882,17 +930,15 @@ extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; WINDOWLIST { - WINDOW win; /* first, so WINDOW_EXT() works */ + WINDOW win; /* first, so WINDOW_EXT() works */ WINDOWLIST *next; + SCREEN *screen; /* screen containing the window */ #ifdef _XOPEN_SOURCE_EXTENDED char addch_work[(MB_LEN_MAX * 9) + 1]; unsigned addch_used; /* number of bytes in addch_work[] */ int addch_x; /* x-position for addch_work[] */ int addch_y; /* y-position for addch_work[] */ #endif -#ifdef USE_PTHREADS - pthread_mutex_t mutex_use_window; -#endif }; #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field) @@ -1296,7 +1342,7 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int); extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int); -#define empty_module(name) \ +#define EMPTY_MODULE(name) \ extern NCURSES_EXPORT(void) name (void); \ NCURSES_EXPORT(void) name (void) { } @@ -1396,6 +1442,10 @@ extern NCURSES_EXPORT(void) _nc_expanded (void); #endif +#if !NCURSES_EXT_FUNCS +#define set_escdelay(value) ESCDELAY = value +#endif + #if !HAVE_GETCWD #define getcwd(buf,len) getwd(buf) #endif @@ -1478,7 +1528,7 @@ extern NCURSES_EXPORT(int) _nc_has_mouse (void); /* lib_setup.c */ extern NCURSES_EXPORT(char *) _nc_get_locale(void); extern NCURSES_EXPORT(int) _nc_unicode_locale(void); -extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void); +extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool); extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); @@ -1526,10 +1576,15 @@ extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned); extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); /* elsewhere ... */ -extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry(ENTRY *, TERMTYPE *); +extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *); +extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int); +extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype); +extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *); extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t); extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *); +extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int); +extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *); extern NCURSES_EXPORT(int) _nc_access (const char *, int); extern NCURSES_EXPORT(int) _nc_baudrate (int); extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *); @@ -1539,10 +1594,11 @@ extern NCURSES_EXPORT(int) _nc_ospeed (int); extern NCURSES_EXPORT(int) _nc_outch (int); extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const); extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int); -extern NCURSES_EXPORT(int) _nc_timed_wait(SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); +extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int)); extern NCURSES_EXPORT(void) _nc_flush (void); -extern NCURSES_EXPORT(void) _nc_free_entry(ENTRY *, TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_and_exit (int); +extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *); extern NCURSES_EXPORT(void) _nc_freeall (void); extern NCURSES_EXPORT(void) _nc_hash_map (void); extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *); diff --git a/ncurses/fifo_defs.h b/ncurses/fifo_defs.h index 9655b417d6e7..fa9ae2264635 100644 --- a/ncurses/fifo_defs.h +++ b/ncurses/fifo_defs.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2002 Free Software Foundation, Inc. * + * Copyright (c) 1998-2002,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -34,7 +34,7 @@ /* * Common macros for lib_getch.c, lib_ungetch.c * - * $Id: fifo_defs.h,v 1.5 2008/05/03 20:08:16 tom Exp $ + * $Id: fifo_defs.h,v 1.6 2008/06/28 15:52:32 tom Exp $ */ #ifndef FIFO_DEFS_H diff --git a/ncurses/llib-lncurses b/ncurses/llib-lncurses index bca3288b9df8..cc0e3667e681 100644 --- a/ncurses/llib-lncurses +++ b/ncurses/llib-lncurses @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1996-2007 * + * Author: Thomas E. Dickey 1996-2008 * ****************************************************************************/ /* LINTLIBRARY */ @@ -1128,7 +1128,7 @@ int wgetscrreg( NCURSES_BOOL mouse_trafo( int *a1, int *a2, - NCURSES_BOOL z) + NCURSES_BOOL z) { return(*(NCURSES_BOOL *)0); } /* ./base/lib_getch.c */ @@ -1138,6 +1138,11 @@ NCURSES_BOOL mouse_trafo( #undef ESCDELAY int ESCDELAY; +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + #undef _nc_wgetch int _nc_wgetch( WINDOW *win, @@ -1395,6 +1400,11 @@ WINDOW *_nc_makenew( int flags) { return(*(WINDOW **)0); } +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + /* ./base/lib_nl.c */ #undef nl @@ -1691,9 +1701,6 @@ int ripoffline( /* ./base/lib_slk.c */ -#undef _nc_slk_format -int _nc_slk_format; - #undef _nc_slk_initialize int _nc_slk_initialize( WINDOW *stwin, @@ -1823,6 +1830,12 @@ void _tracedump( /* ./trace/lib_tracemse.c */ +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + #undef _tracemouse char *_tracemouse( MEVENT const *ep) @@ -1840,9 +1853,16 @@ void _nc_signal_handler( /* ./base/lib_ungetch.c */ #undef _nc_fifo_dump -void _nc_fifo_dump(void) +void _nc_fifo_dump( + SCREEN *sp) { /* void */ } +#undef _nc_ungetch +int _nc_ungetch( + SCREEN *sp, + int ch) + { return(*(int *)0); } + #undef ungetch int ungetch( int ch) @@ -2020,6 +2040,11 @@ void _nc_vsscanf(void) void _nc_freeall(void) { /* void */ } +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + /* ./expanded.c */ #undef _nc_toggle_attr_on @@ -2103,6 +2128,24 @@ void _nc_trace_xnames( TERMTYPE *tp) { /* void */ } +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + /* ./base/wresize.c */ #undef wresize @@ -2345,7 +2388,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0}; #endif #undef _nc_init_keytry -void _nc_init_keytry(void) +void _nc_init_keytry( + SCREEN *sp) { /* void */ } /* ./tinfo/lib_acs.c */ @@ -2440,6 +2484,12 @@ int flushinp(void) struct kn { short offset; int code; }; +#undef _nc_keyname +char *_nc_keyname( + SCREEN *sp, + int c) + { return(*(char **)0); } + #undef keyname char *keyname( int c) @@ -2526,6 +2576,7 @@ int has_key( #undef _nc_keypad int _nc_keypad( + SCREEN *sp, NCURSES_BOOL flag) { return(*(int *)0); } @@ -2576,9 +2627,14 @@ int COLS; #undef TABSIZE int TABSIZE; +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + #undef _nc_handle_sigwinch int _nc_handle_sigwinch( - int update) + SCREEN *sp) { return(*(int *)0); } #undef use_env @@ -2588,12 +2644,14 @@ void use_env( #undef _nc_get_screensize void _nc_get_screensize( + SCREEN *sp, int *linep, int *colp) { /* void */ } #undef _nc_update_screensize -void _nc_update_screensize(void) +void _nc_update_screensize( + SCREEN *sp) { /* void */ } #undef _nc_get_locale @@ -2605,7 +2663,8 @@ int _nc_unicode_locale(void) { return(*(int *)0); } #undef _nc_locale_breaks_acs -int _nc_locale_breaks_acs(void) +int _nc_locale_breaks_acs( + TERMINAL *termp) { return(*(int *)0); } #undef _nc_setupterm @@ -2717,6 +2776,11 @@ NCURSES_OSPEED ospeed; #undef _nc_nulls_sent int _nc_nulls_sent; +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + #undef delay_output int delay_output( int ms) @@ -2867,6 +2931,12 @@ char *_nc_tracebits(void) /* ./trace/lib_tracechr.c */ +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + #undef _tracechar char *_tracechar( int ch) @@ -2912,6 +2982,7 @@ int resetty(void) #undef _nc_timed_wait int _nc_timed_wait( + SCREEN *sp, int mode, int milliseconds, int *timeleft) @@ -3073,9 +3144,15 @@ char *_nc_trim_sgr0( /* ./unctrl.c */ +#undef _nc_unctrl +char *_nc_unctrl( + SCREEN *sp, + chtype ch) + { return(*(char **)0); } + #undef unctrl char *unctrl( - chtype ch) + chtype ch) { return(*(char **)0); } /* ./trace/visbuf.c */ diff --git a/ncurses/llib-lncursest b/ncurses/llib-lncursest index 48acb8c51fa4..d29ef60d561b 100644 --- a/ncurses/llib-lncursest +++ b/ncurses/llib-lncursest @@ -926,7 +926,7 @@ int vw_printw( #undef vw_scanw int vw_scanw( WINDOW *a1, - const char *a2, + char *a2, va_list z) { return(*(int *)0); } @@ -1131,7 +1131,7 @@ int wgetscrreg( NCURSES_BOOL mouse_trafo( int *a1, int *a2, - NCURSES_BOOL z) + NCURSES_BOOL z) { return(*(NCURSES_BOOL *)0); } /* ./base/lib_getch.c */ @@ -1357,7 +1357,7 @@ void nofilter(void) #undef newterm SCREEN *newterm( - const char *name, + char *name, FILE *ofp, FILE *ifp) { return(*(SCREEN **)0); } @@ -1404,6 +1404,11 @@ WINDOW *_nc_makenew( int flags) { return(*(WINDOW **)0); } +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + /* ./base/lib_nl.c */ #undef nl @@ -1550,7 +1555,7 @@ int wnoutrefresh( #undef restartterm int restartterm( - const char *termp, + char *termp, int filenum, int *errret) { return(*(int *)0); } @@ -1560,20 +1565,20 @@ int restartterm( #undef vwscanw int vwscanw( WINDOW *win, - const char *fmt, + char *fmt, va_list argp) { return(*(int *)0); } #undef scanw int scanw( - const char *fmt, + char *fmt, ...) { return(*(int *)0); } #undef wscanw int wscanw( WINDOW *win, - const char *fmt, + char *fmt, ...) { return(*(int *)0); } @@ -1581,7 +1586,7 @@ int wscanw( int mvscanw( int y, int x, - const char *fmt, + char *fmt, ...) { return(*(int *)0); } @@ -1590,7 +1595,7 @@ int mvwscanw( WINDOW *win, int y, int x, - const char *fmt, + char *fmt, ...) { return(*(int *)0); } @@ -1700,9 +1705,6 @@ int ripoffline( /* ./base/lib_slk.c */ -#undef _nc_slk_format -int _nc_slk_format; - #undef _nc_slk_initialize int _nc_slk_initialize( WINDOW *stwin, @@ -1832,6 +1834,12 @@ void _tracedump( /* ./trace/lib_tracemse.c */ +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + #undef _tracemouse char *_tracemouse( MEVENT const *ep) @@ -1849,9 +1857,16 @@ void _nc_signal_handler( /* ./base/lib_ungetch.c */ #undef _nc_fifo_dump -void _nc_fifo_dump(void) +void _nc_fifo_dump( + SCREEN *sp) { /* void */ } +#undef _nc_ungetch +int _nc_ungetch( + SCREEN *sp, + int ch) + { return(*(int *)0); } + #undef ungetch int ungetch( int ch) @@ -1992,6 +2007,11 @@ void _nc_screen_init(void) void _nc_screen_wrap(void) { /* void */ } +#undef _nc_do_xmc_glitch +void _nc_do_xmc_glitch( + attr_t previous) + { /* void */ } + /* ./trace/varargs.c */ typedef enum { @@ -2031,8 +2051,31 @@ void _nc_free_and_exit( /* ./expanded.c */ -#undef _nc_expanded -void _nc_expanded(void) +#undef _nc_toggle_attr_on +void _nc_toggle_attr_on( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_toggle_attr_off +void _nc_toggle_attr_off( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_DelCharCost +int _nc_DelCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost +int _nc_InsCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs +void _nc_UpdateAttrs( + chtype c) { /* void */ } /* ./base/legacy_coding.c */ @@ -2094,26 +2137,16 @@ void _nc_trace_xnames( #undef use_screen int use_screen( SCREEN *screen, - NCURSES_CALLBACK func, + NCURSES_SCREEN_CB func, void *data) { return(*(int *)0); } /* ./base/use_window.c */ -#undef _nc_lock_window -void _nc_lock_window( - WINDOW *win) - { /* void */ } - -#undef _nc_unlock_window -void _nc_unlock_window( - WINDOW *win) - { /* void */ } - #undef use_window int use_window( WINDOW *win, - NCURSES_CALLBACK func, + NCURSES_WINDOW_CB func, void *data) { return(*(int *)0); } @@ -2167,6 +2200,10 @@ NCURSES_BOOL _nc_is_file_path( const char *path) { return(*(NCURSES_BOOL *)0); } +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + /* ./tinfo/add_tries.c */ #undef _nc_add_to_try @@ -2193,20 +2230,16 @@ void _nc_copy_termtype( /* ./codes.c */ #undef _nc_boolcodes -const char *const *_nc_boolcodes(void) - { return(*(const char **)0); } +char *const *_nc_boolcodes(void) + { return(*(char **)0); } #undef _nc_numcodes -const char *const *_nc_numcodes(void) - { return(*(const char **)0); } +char *const *_nc_numcodes(void) + { return(*(char **)0); } #undef _nc_strcodes -const char *const *_nc_strcodes(void) - { return(*(const char **)0); } - -#undef _nc_codes_leaks -void _nc_codes_leaks(void) - { /* void */ } +char *const *_nc_strcodes(void) + { return(*(char **)0); } /* ./tinfo/comp_error.c */ @@ -2318,11 +2351,6 @@ ENTRY *_nc_delink_entry( void _nc_leaks_tinfo(void) { /* void */ } -#undef _nc_free_tinfo -void _nc_free_tinfo( - int code) - { /* void */ } - /* ./fallback.c */ #undef _nc_fallback @@ -2370,7 +2398,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0}; #endif #undef _nc_init_keytry -void _nc_init_keytry(void) +void _nc_init_keytry( + SCREEN *sp) { /* void */ } /* ./tinfo/lib_acs.c */ @@ -2408,8 +2437,9 @@ int baudrate(void) /* ./tinfo/lib_cur_term.c */ -#undef cur_term -TERMINAL *cur_term; +#undef _nc_cur_term +TERMINAL *_nc_cur_term(void) + { return(*(TERMINAL **)0); } #undef set_curterm TERMINAL *set_curterm( @@ -2444,6 +2474,15 @@ NCURSES_GLOBALS _nc_globals; #undef _nc_prescreen NCURSES_PRESCREEN _nc_prescreen; +#undef _nc_init_pthreads +void _nc_init_pthreads(void) + { /* void */ } + +#undef _nc_mutex_init +void _nc_mutex_init( + pthread_mutex_t *obj) + { /* void */ } + #undef _nc_mutex_lock int _nc_mutex_lock( pthread_mutex_t *obj) @@ -2487,14 +2526,16 @@ int flushinp(void) struct kn { short offset; int code; }; -#undef keyname -const char *keyname( +#undef _nc_keyname +char *_nc_keyname( + SCREEN *sp, int c) - { return(*(const char **)0); } + { return(*(char **)0); } -#undef _nc_keyname_leaks -void _nc_keyname_leaks(void) - { /* void */ } +#undef keyname +char *keyname( + int c) + { return(*(char **)0); } /* ./tinfo/lib_longname.c */ @@ -2504,8 +2545,6 @@ char *longname(void) /* ./tinfo/lib_napms.c */ -#include - #undef napms int napms( int ms) @@ -2577,6 +2616,7 @@ int has_key( #undef _nc_keypad int _nc_keypad( + SCREEN *sp, NCURSES_BOOL flag) { return(*(int *)0); } @@ -2622,10 +2662,18 @@ int intrflush( char *_nc_ttytype(void) { return(*(char **)0); } +#undef _nc_ptr_Lines +int *_nc_ptr_Lines(void) + { return(*(int **)0); } + #undef _nc_LINES int _nc_LINES(void) { return(*(int *)0); } +#undef _nc_ptr_Cols +int *_nc_ptr_Cols(void) + { return(*(int **)0); } + #undef _nc_COLS int _nc_COLS(void) { return(*(int *)0); } @@ -2641,7 +2689,7 @@ int set_tabsize( #undef _nc_handle_sigwinch int _nc_handle_sigwinch( - int update) + SCREEN *sp) { return(*(int *)0); } #undef use_env @@ -2651,12 +2699,14 @@ void use_env( #undef _nc_get_screensize void _nc_get_screensize( + SCREEN *sp, int *linep, int *colp) { /* void */ } #undef _nc_update_screensize -void _nc_update_screensize(void) +void _nc_update_screensize( + SCREEN *sp) { /* void */ } #undef _nc_get_locale @@ -2668,12 +2718,13 @@ int _nc_unicode_locale(void) { return(*(int *)0); } #undef _nc_locale_breaks_acs -int _nc_locale_breaks_acs(void) +int _nc_locale_breaks_acs( + TERMINAL *termp) { return(*(int *)0); } #undef _nc_setupterm int _nc_setupterm( - const char *tname, + char *tname, int Filedes, int *errret, NCURSES_BOOL reuse) @@ -2681,7 +2732,7 @@ int _nc_setupterm( #undef setupterm int setupterm( - const char *tname, + char *tname, int Filedes, int *errret) { return(*(int *)0); } @@ -2707,24 +2758,20 @@ int tgetent( #undef tgetflag int tgetflag( - const char *id) + char *id) { return(*(int *)0); } #undef tgetnum int tgetnum( - const char *id) + char *id) { return(*(int *)0); } #undef tgetstr char *tgetstr( - const char *id, + char *id, char **area) { return(*(char **)0); } -#undef _nc_tgetent_leaks -void _nc_tgetent_leaks(void) - { /* void */ } - /* ./tinfo/lib_termname.c */ #undef termname @@ -2744,17 +2791,17 @@ char *tgoto( #undef tigetflag int tigetflag( - const char *str) + char *str) { return(*(int *)0); } #undef tigetnum int tigetnum( - const char *str) + char *str) { return(*(int *)0); } #undef tigetstr char *tigetstr( - const char *str) + char *str) { return(*(char **)0); } /* ./tinfo/lib_tparm.c */ @@ -2762,10 +2809,6 @@ char *tigetstr( #undef _nc_tparm_err int _nc_tparm_err; -#undef _nc_free_tparm -void _nc_free_tparm(void) - { /* void */ } - #undef _nc_tparm_analyze int _nc_tparm_analyze( const char *string, @@ -2775,7 +2818,7 @@ int _nc_tparm_analyze( #undef tparm char *tparm( - const char *string, + char *string, ...) { return(*(char **)0); } @@ -2788,6 +2831,11 @@ NCURSES_OSPEED ospeed; #undef _nc_nulls_sent int _nc_nulls_sent; +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + #undef delay_output int delay_output( int ms) @@ -2875,9 +2923,9 @@ const char *_nc_retrace_cptr( { return(*(const char **)0); } #undef _nc_retrace_cvoid_ptr -const void *_nc_retrace_cvoid_ptr( - const void *code) - { return(*(const void **)0); } +void *_nc_retrace_cvoid_ptr( + void *code) + { return(*(void **)0); } #undef _nc_retrace_void_ptr void *_nc_retrace_void_ptr( @@ -2963,6 +3011,12 @@ char *_nc_tracebits(void) /* ./trace/lib_tracechr.c */ +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + #undef _tracechar char *_tracechar( int ch) @@ -3008,6 +3062,7 @@ int resetty(void) #undef _nc_timed_wait int _nc_timed_wait( + SCREEN *sp, int mode, int milliseconds, int *timeleft) @@ -3030,32 +3085,28 @@ int _nc_name_match( /* ./names.c */ #undef _nc_boolnames -const char *const *_nc_boolnames(void) - { return(*(const char **)0); } +char *const *_nc_boolnames(void) + { return(*(char **)0); } #undef _nc_boolfnames -const char *const *_nc_boolfnames(void) - { return(*(const char **)0); } +char *const *_nc_boolfnames(void) + { return(*(char **)0); } #undef _nc_numnames -const char *const *_nc_numnames(void) - { return(*(const char **)0); } +char *const *_nc_numnames(void) + { return(*(char **)0); } #undef _nc_numfnames -const char *const *_nc_numfnames(void) - { return(*(const char **)0); } +char *const *_nc_numfnames(void) + { return(*(char **)0); } #undef _nc_strnames -const char *const *_nc_strnames(void) - { return(*(const char **)0); } +char *const *_nc_strnames(void) + { return(*(char **)0); } #undef _nc_strfnames -const char *const *_nc_strfnames(void) - { return(*(const char **)0); } - -#undef _nc_names_leaks -void _nc_names_leaks(void) - { /* void */ } +char *const *_nc_strfnames(void) + { return(*(char **)0); } /* ./tinfo/read_entry.c */ @@ -3085,9 +3136,11 @@ int _nc_read_entry( #include -#undef _nc_read_termcap -void _nc_read_termcap(void) - { /* void */ } +#undef _nc_read_termcap_entry +int _nc_read_termcap_entry( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } /* ./tinfo/setbuf.c */ @@ -3182,10 +3235,16 @@ char *_nc_trim_sgr0( /* ./unctrl.c */ +#undef _nc_unctrl +char *_nc_unctrl( + SCREEN *sp, + chtype ch) + { return(*(char **)0); } + #undef unctrl -const char *unctrl( - chtype ch) - { return(*(const char **)0); } +char *unctrl( + chtype ch) + { return(*(char **)0); } /* ./trace/visbuf.c */ @@ -3248,10 +3307,6 @@ void _nc_merge_entry( TERMTYPE *const from) { /* void */ } -#undef _nc_alloc_entry_leaks -void _nc_alloc_entry_leaks(void) - { /* void */ } - /* ./tinfo/captoinfo.c */ #undef _nc_captoinfo @@ -3268,10 +3323,6 @@ char *_nc_infotocap( int const parameterized) { return(*(char **)0); } -#undef _nc_captoinfo_leaks -void _nc_captoinfo_leaks(void) - { /* void */ } - /* ./comp_captab.c */ #include @@ -3291,10 +3342,6 @@ const struct alias *_nc_get_alias_table( NCURSES_BOOL termcap) { return(*(const struct alias **)0); } -#undef _nc_comp_captab_leaks -void _nc_comp_captab_leaks(void) - { /* void */ } - /* ./tinfo/comp_expand.c */ #undef _nc_tic_expand @@ -3356,15 +3403,6 @@ int _nc_resolve_uses( NCURSES_BOOL fullresolve) { return(*(int *)0); } -#undef _nc_leaks_tic -void _nc_leaks_tic(void) - { /* void */ } - -#undef _nc_free_tic -void _nc_free_tic( - int code) - { /* void */ } - /* ./tinfo/comp_scan.c */ #undef _nc_syntax @@ -3409,10 +3447,6 @@ void _nc_panic_mode( char ch) { /* void */ } -#undef _nc_comp_scan_leaks -void _nc_comp_scan_leaks(void) - { /* void */ } - /* ./tinfo/parse_entry.c */ #undef _nc_parse_entry diff --git a/ncurses/llib-lncursesw b/ncurses/llib-lncursesw index 12522e123c59..96e7257691d8 100644 --- a/ncurses/llib-lncursesw +++ b/ncurses/llib-lncursesw @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2001-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 2001-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 2001-2006 * + * Author: Thomas E. Dickey 2001-2008 * ****************************************************************************/ /* LINTLIBRARY */ @@ -1636,7 +1636,7 @@ int wins_wstr( NCURSES_BOOL mouse_trafo( int *a1, int *a2, - NCURSES_BOOL z) + NCURSES_BOOL z) { return(*(NCURSES_BOOL *)0); } /* ./base/lib_getch.c */ @@ -1646,6 +1646,11 @@ NCURSES_BOOL mouse_trafo( #undef ESCDELAY int ESCDELAY; +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + #undef _nc_wgetch int _nc_wgetch( WINDOW *win, @@ -1903,6 +1908,11 @@ WINDOW *_nc_makenew( int flags) { return(*(WINDOW **)0); } +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + /* ./base/lib_nl.c */ #undef nl @@ -2199,9 +2209,6 @@ int ripoffline( /* ./base/lib_slk.c */ -#undef _nc_slk_format -int _nc_slk_format; - #undef _nc_slk_initialize int _nc_slk_initialize( WINDOW *stwin, @@ -2333,6 +2340,12 @@ void _tracedump( /* ./trace/lib_tracemse.c */ +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + #undef _tracemouse char *_tracemouse( MEVENT const *ep) @@ -2350,9 +2363,16 @@ void _nc_signal_handler( /* ./base/lib_ungetch.c */ #undef _nc_fifo_dump -void _nc_fifo_dump(void) +void _nc_fifo_dump( + SCREEN *sp) { /* void */ } +#undef _nc_ungetch +int _nc_ungetch( + SCREEN *sp, + int ch) + { return(*(int *)0); } + #undef ungetch int ungetch( int ch) @@ -2530,6 +2550,11 @@ void _nc_vsscanf(void) void _nc_freeall(void) { /* void */ } +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + /* ./widechar/charable.c */ #undef _nc_is_charable @@ -2849,6 +2874,24 @@ void _nc_trace_xnames( TERMTYPE *tp) { /* void */ } +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + /* ./base/wresize.c */ #undef wresize @@ -3091,7 +3134,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0}; #endif #undef _nc_init_keytry -void _nc_init_keytry(void) +void _nc_init_keytry( + SCREEN *sp) { /* void */ } /* ./tinfo/lib_acs.c */ @@ -3186,6 +3230,12 @@ int flushinp(void) struct kn { short offset; int code; }; +#undef _nc_keyname +char *_nc_keyname( + SCREEN *sp, + int c) + { return(*(char **)0); } + #undef keyname char *keyname( int c) @@ -3272,6 +3322,7 @@ int has_key( #undef _nc_keypad int _nc_keypad( + SCREEN *sp, NCURSES_BOOL flag) { return(*(int *)0); } @@ -3322,9 +3373,14 @@ int COLS; #undef TABSIZE int TABSIZE; +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + #undef _nc_handle_sigwinch int _nc_handle_sigwinch( - int update) + SCREEN *sp) { return(*(int *)0); } #undef use_env @@ -3334,12 +3390,14 @@ void use_env( #undef _nc_get_screensize void _nc_get_screensize( + SCREEN *sp, int *linep, int *colp) { /* void */ } #undef _nc_update_screensize -void _nc_update_screensize(void) +void _nc_update_screensize( + SCREEN *sp) { /* void */ } #undef _nc_get_locale @@ -3351,7 +3409,8 @@ int _nc_unicode_locale(void) { return(*(int *)0); } #undef _nc_locale_breaks_acs -int _nc_locale_breaks_acs(void) +int _nc_locale_breaks_acs( + TERMINAL *termp) { return(*(int *)0); } #undef _nc_setupterm @@ -3463,6 +3522,11 @@ NCURSES_OSPEED ospeed; #undef _nc_nulls_sent int _nc_nulls_sent; +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + #undef delay_output int delay_output( int ms) @@ -3624,6 +3688,12 @@ char *_nc_tracebits(void) /* ./trace/lib_tracechr.c */ +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + #undef _tracechar char *_tracechar( int ch) @@ -3669,6 +3739,7 @@ int resetty(void) #undef _nc_timed_wait int _nc_timed_wait( + SCREEN *sp, int mode, int milliseconds, int *timeleft) @@ -3830,9 +3901,15 @@ char *_nc_trim_sgr0( /* ./unctrl.c */ +#undef _nc_unctrl +char *_nc_unctrl( + SCREEN *sp, + chtype ch) + { return(*(char **)0); } + #undef unctrl char *unctrl( - chtype ch) + chtype ch) { return(*(char **)0); } /* ./trace/visbuf.c */ diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk index db8ad5541841..b9ba636e0ccd 100644 --- a/ncurses/tinfo/MKcodes.awk +++ b/ncurses/tinfo/MKcodes.awk @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # +# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: MKcodes.awk,v 1.4 2007/11/03 20:24:15 tom Exp $ +# $Id: MKcodes.awk,v 1.5 2008/06/28 23:13:25 tom Exp $ function large_item(value) { result = sprintf("%d,", offset); offset = offset + length(value) + 1; @@ -140,6 +140,7 @@ END { print "" print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }" print "" + print "#if NO_LEAKS" print "NCURSES_EXPORT(void)" print "_nc_codes_leaks(void)" print "{" @@ -149,6 +150,8 @@ END { print "FREE_FIX(strcodes)" } print "}" + print "#endif" + print "" print "#else" print "" print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]" diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk index 93e682c2d28d..7e5074480864 100644 --- a/ncurses/tinfo/MKnames.awk +++ b/ncurses/tinfo/MKnames.awk @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2007 Free Software Foundation, Inc. # +# Copyright (c) 2007,2008 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: MKnames.awk,v 1.18 2007/11/03 20:24:15 tom Exp $ +# $Id: MKnames.awk,v 1.20 2008/10/11 21:07:56 tom Exp $ function large_item(value) { result = sprintf("%d,", offset); offset = offset + length(value) + 1; @@ -126,7 +126,7 @@ END { print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {" print " unsigned n;" print " for (n = 0; n < size; ++n) {" - print " (*value)[n] = _nc_name_blob + offsets[n];" + print " (*value)[n] = (NCURSES_CONST char *) _nc_name_blob + offsets[n];" print " }" print " }" print " }" @@ -156,6 +156,7 @@ END { print "" print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }" print "" + print "#if NO_LEAKS" print "NCURSES_EXPORT(void)" print "_nc_names_leaks(void)" print "{" @@ -168,6 +169,8 @@ END { print "FREE_FIX(strfnames)" } print "}" + print "#endif" + print "" print "#else" print "" print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]" diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c index 1496752f1956..4638e99c4d58 100644 --- a/ncurses/tinfo/alloc_entry.c +++ b/ncurses/tinfo/alloc_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -48,7 +48,7 @@ #include #include -MODULE_ID("$Id: alloc_entry.c,v 1.47 2006/12/16 19:06:58 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.48 2008/08/16 16:25:31 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 @@ -145,7 +145,8 @@ NCURSES_EXPORT(void) _nc_wrap_entry(ENTRY * const ep, bool copy_strings) /* copy the string parts to allocated storage, preserving pointers to it */ { - int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES]; + int offsets[MAX_ENTRY_SIZE / sizeof(short)]; + int useoffsets[MAX_USES]; unsigned i, n; unsigned nuses = ep->nuses; TERMTYPE *tp = &(ep->tterm); @@ -171,14 +172,18 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings) free(tp->str_table); } - n = tp->term_names - stringbuf; + assert(tp->term_names >= stringbuf); + n = (unsigned) (tp->term_names - stringbuf); for_each_string(i, &(ep->tterm)) { - if (tp->Strings[i] == ABSENT_STRING) - offsets[i] = ABSENT_OFFSET; - else if (tp->Strings[i] == CANCELLED_STRING) - offsets[i] = CANCELLED_OFFSET; - else - offsets[i] = tp->Strings[i] - stringbuf; + if (i < SIZEOF(offsets)) { + if (tp->Strings[i] == ABSENT_STRING) { + offsets[i] = ABSENT_OFFSET; + } else if (tp->Strings[i] == CANCELLED_STRING) { + offsets[i] = CANCELLED_OFFSET; + } else { + offsets[i] = tp->Strings[i] - stringbuf; + } + } } for (i = 0; i < nuses; i++) { @@ -194,28 +199,33 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings) tp->term_names = tp->str_table + n; for_each_string(i, &(ep->tterm)) { - if (offsets[i] == ABSENT_OFFSET) - tp->Strings[i] = ABSENT_STRING; - else if (offsets[i] == CANCELLED_OFFSET) - tp->Strings[i] = CANCELLED_STRING; - else - tp->Strings[i] = tp->str_table + offsets[i]; + if (i < SIZEOF(offsets)) { + if (offsets[i] == ABSENT_OFFSET) { + tp->Strings[i] = ABSENT_STRING; + } else if (offsets[i] == CANCELLED_OFFSET) { + tp->Strings[i] = CANCELLED_STRING; + } else { + tp->Strings[i] = tp->str_table + offsets[i]; + } + } } #if NCURSES_XNAMES if (!copy_strings) { - if ((n = NUM_EXT_NAMES(tp)) != 0) { - unsigned length = 0; - for (i = 0; i < n; i++) { - length += strlen(tp->ext_Names[i]) + 1; - offsets[i] = tp->ext_Names[i] - stringbuf; - } - if ((tp->ext_str_table = typeMalloc(char, length)) == 0) - _nc_err_abort(MSG_NO_MEMORY); - for (i = 0, length = 0; i < n; i++) { - tp->ext_Names[i] = tp->ext_str_table + length; - strcpy(tp->ext_Names[i], stringbuf + offsets[i]); - length += strlen(tp->ext_Names[i]) + 1; + if ((n = (unsigned) NUM_EXT_NAMES(tp)) != 0) { + if (n < SIZEOF(offsets)) { + unsigned length = 0; + for (i = 0; i < n; i++) { + length += strlen(tp->ext_Names[i]) + 1; + offsets[i] = tp->ext_Names[i] - stringbuf; + } + if ((tp->ext_str_table = typeMalloc(char, length)) == 0) + _nc_err_abort(MSG_NO_MEMORY); + for (i = 0, length = 0; i < n; i++) { + tp->ext_Names[i] = tp->ext_str_table + length; + strcpy(tp->ext_Names[i], stringbuf + offsets[i]); + length += strlen(tp->ext_Names[i]) + 1; + } } } } @@ -245,13 +255,13 @@ _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from) if (mergebool == CANCELLED_BOOLEAN) to->Booleans[i] = FALSE; else if (mergebool == TRUE) - to->Booleans[i] = mergebool; + to->Booleans[i] = (char) mergebool; } } for_each_number(i, from) { if (to->Numbers[i] != CANCELLED_NUMERIC) { - int mergenum = from->Numbers[i]; + short mergenum = from->Numbers[i]; if (mergenum == CANCELLED_NUMERIC) to->Numbers[i] = ABSENT_NUMERIC; diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c index 9f31ed3ffab7..b2b06d1b79ce 100644 --- a/ncurses/tinfo/alloc_ttype.c +++ b/ncurses/tinfo/alloc_ttype.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2003,2006 Free Software Foundation, Inc. * + * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: alloc_ttype.c,v 1.16 2006/07/08 19:18:38 tom Exp $") +MODULE_ID("$Id: alloc_ttype.c,v 1.17 2008/10/12 16:12:00 tom Exp $") #if NCURSES_XNAMES /* @@ -365,6 +365,17 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from) } else { j++; } + } else if ((k = _nc_find_ext_name(from, to->ext_Names[j], + STRING)) >= 0) { + if (_nc_del_ext_name(to, name, NUMBER) + || _nc_del_ext_name(to, name, BOOLEAN)) { + k = _nc_ins_ext_name(to, name, STRING); + to->Strings[k] = CANCELLED_STRING; + } else { + j++; + } + } else { + j++; } } else { j++; diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c index 0e3baa845693..93300c1be3e4 100644 --- a/ncurses/tinfo/captoinfo.c +++ b/ncurses/tinfo/captoinfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -93,7 +93,7 @@ #include #include -MODULE_ID("$Id: captoinfo.c,v 1.49 2006/12/16 19:16:53 tom Exp $") +MODULE_ID("$Id: captoinfo.c,v 1.52 2008/08/16 19:24:51 tom Exp $") #define MAX_PUSHED 16 /* max # args we can push onto the stack */ @@ -149,7 +149,7 @@ static void push(void) /* push onstack on to the stack */ { - if (stackptr > MAX_PUSHED) + if (stackptr >= MAX_PUSHED) _nc_warning("string too complex to convert"); else stack[stackptr++] = onstack; @@ -183,7 +183,7 @@ cvtchar(register const char *sp) case '$': case '\\': case '%': - c = *sp; + c = (unsigned char) (*sp); len = 2; break; case '\0': @@ -201,7 +201,7 @@ cvtchar(register const char *sp) } break; default: - c = *sp; + c = (unsigned char) (*sp); len = 2; break; } @@ -211,7 +211,7 @@ cvtchar(register const char *sp) len = 2; break; default: - c = *sp; + c = (unsigned char) (*sp); len = 1; } if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') { @@ -788,6 +788,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz } /* endswitch (*str) */ } /* endelse (*str == '%') */ + /* + * 'str' always points to the end of what was scanned in this step, + * but that may not be the end of the string. + */ + assert(str != 0); if (*str == '\0') break; diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c index ef419d84cd2c..6e79a926b5ac 100644 --- a/ncurses/tinfo/comp_expand.c +++ b/ncurses/tinfo/comp_expand.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include #include -MODULE_ID("$Id: comp_expand.c,v 1.18 2006/06/17 19:37:14 tom Exp $") +MODULE_ID("$Id: comp_expand.c,v 1.20 2008/08/16 19:29:42 tom Exp $") static int trailing_spaces(const char *src) @@ -56,7 +56,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers) static size_t length; int bufp; - const char *str = VALID_STRING(srcp) ? srcp : ""; + const char *str = VALID_STRING(srcp) ? srcp : "\0\0"; bool islong = (strlen(str) > 3); size_t need = (2 + strlen(str)) * 4; int ch; @@ -119,7 +119,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers) if (ch == '\\' || ch == S_QUOTE) buffer[bufp++] = '\\'; - buffer[bufp++] = ch; + buffer[bufp++] = (char) ch; buffer[bufp++] = S_QUOTE; str = dst; } else { @@ -148,13 +148,13 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers) buffer[bufp++] = 's'; } else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) { buffer[bufp++] = '\\'; - buffer[bufp++] = ch; + buffer[bufp++] = (char) ch; } else if (REALPRINT(str) && (ch != ',' && ch != ':' && !(ch == '!' && !tic_format) && ch != '^')) - buffer[bufp++] = ch; + buffer[bufp++] = (char) ch; #if 0 /* FIXME: this would be more readable (in fact the whole 'islong' logic should be removed) */ else if (ch == '\b') { buffer[bufp++] = '\\'; diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c index 8b85eee6ced8..b7fbd0616345 100644 --- a/ncurses/tinfo/comp_hash.c +++ b/ncurses/tinfo/comp_hash.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -50,7 +50,7 @@ #define DEBUG(level, params) /*nothing */ #endif -MODULE_ID("$Id: comp_hash.c,v 1.33 2007/08/18 21:42:25 tom Exp $") +MODULE_ID("$Id: comp_hash.c,v 1.36 2008/08/16 17:06:53 tom Exp $") static int hash_function(const char *); @@ -73,7 +73,7 @@ static void _nc_make_hash_table(struct name_table_entry *table, short *hash_table) { - int i; + short i; int hashvalue; int collisions = 0; @@ -215,8 +215,9 @@ parse_columns(char *buffer) if ((s - buffer) > 1 && (*buffer == '"') && (s[-1] == '"')) { /* strip the quotes */ - buffer++; + assert(s > buffer + 1); s[-1] = '\0'; + buffer++; } list[col] = buffer; col++; @@ -258,7 +259,9 @@ main(int argc, char **argv) || (column = atoi(argv[1])) <= 0 || (column >= MAX_COLUMNS) || *(root_name = argv[2]) == 0 - || (bigstring = atoi(argv[3])) < 0) { + || (bigstring = atoi(argv[3])) < 0 + || name_table == 0 + || hash_table == 0) { fprintf(stderr, "usage: make_hash column root_name bigstring\n"); exit(EXIT_FAILURE); } @@ -301,7 +304,7 @@ main(int argc, char **argv) printf("static const char %s_names_text[] = \\\n", root_name); for (n = 0; n < CAPTABSIZE; n++) { - nxt = strlen(name_table[n].nte_name) + 5; + nxt = (int) strlen(name_table[n].nte_name) + 5; if (nxt + len > 72) { printf("\\\n"); len = 0; @@ -322,7 +325,7 @@ main(int argc, char **argv) name_table[n].nte_index, name_table[n].nte_link, n < CAPTABSIZE - 1 ? ',' : ' '); - len += strlen(name_table[n].nte_name) + 1; + len += (int) strlen(name_table[n].nte_name) + 1; } printf("};\n\n"); printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name); @@ -361,6 +364,7 @@ main(int argc, char **argv) printf("#error\t--> numbers of booleans, numbers and/or strings <--\n"); printf("#endif\n\n"); + free(hash_table); return EXIT_SUCCESS; } #endif diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c index aa60047b0aad..3325a0ddae6c 100644 --- a/ncurses/tinfo/comp_parse.c +++ b/ncurses/tinfo/comp_parse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -53,7 +53,7 @@ #include #include -MODULE_ID("$Id: comp_parse.c,v 1.68 2007/11/03 20:41:46 tom Exp $") +MODULE_ID("$Id: comp_parse.c,v 1.69 2008/08/16 21:58:16 tom Exp $") static void sanity_check2(TERMTYPE *, bool); NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2; @@ -183,7 +183,8 @@ _nc_resolve_uses2(bool fullresolve, bool literal) { ENTRY *qp, *rp, *lastread = 0; bool keepgoing; - int i, unresolved, total_unresolved, multiples; + unsigned i; + int unresolved, total_unresolved, multiples; DEBUG(2, ("RESOLUTION BEGINNING")); diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c index e937f7eb5ada..5ad750f930dd 100644 --- a/ncurses/tinfo/comp_scan.c +++ b/ncurses/tinfo/comp_scan.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -51,7 +51,7 @@ #include #include -MODULE_ID("$Id: comp_scan.c,v 1.78 2006/12/16 19:17:01 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.83 2008/08/16 19:22:55 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -203,6 +203,7 @@ next_char(void) result = typeRealloc(char, allocated, result); if (result == 0) return (EOF); + bufstart = result; } if (used == 0) _nc_curr_file_pos = ftell(yyin); @@ -293,6 +294,15 @@ eat_escaped_newline(int ch) return ch; } +#define TOK_BUF_SIZE MAX_ENTRY_SIZE + +#define OkToAdd() \ + ((tok_ptr - tok_buf) < (TOK_BUF_SIZE - 2)) + +#define AddCh(ch) \ + *tok_ptr++ = (char) ch; \ + *tok_ptr = '\0' + /* * int * get_token() @@ -330,12 +340,12 @@ NCURSES_EXPORT(int) _nc_get_token(bool silent) { static const char terminfo_punct[] = "@%&*!#"; - static char *buffer; + static char *tok_buf; char *after_list; char *after_name; char *numchk; - char *ptr; + char *tok_ptr; char *s; char numbuf[80]; int ch; @@ -367,10 +377,10 @@ _nc_get_token(bool silent) if (end_of_stream()) { yyin = 0; next_char(); /* frees its allocated memory */ - if (buffer != 0) { - if (_nc_curr_token.tk_name == buffer) + if (tok_buf != 0) { + if (_nc_curr_token.tk_name == tok_buf) _nc_curr_token.tk_name = 0; - FreeAndNull(buffer); + FreeAndNull(tok_buf); } return (EOF); } @@ -426,15 +436,15 @@ _nc_get_token(bool silent) goto start_token; } - if (buffer == 0) - buffer = typeMalloc(char, MAX_ENTRY_SIZE); + if (tok_buf == 0) + tok_buf = typeMalloc(char, TOK_BUF_SIZE); #ifdef TRACE old_line = _nc_curr_line; old_col = _nc_curr_col; #endif - ptr = buffer; - *(ptr++) = ch; + tok_ptr = tok_buf; + AddCh(ch); if (first_column) { _nc_comment_start = token_start; @@ -448,9 +458,9 @@ _nc_get_token(bool silent) if (ch == EOF) { _nc_err_abort(MSG_NO_INPUTS); } else if (ch == '|') { - after_list = ptr; + after_list = tok_ptr; if (after_name == 0) - after_name = ptr; + after_name = tok_ptr; } else if (ch == ':' && last_char() != ',') { _nc_syntax = SYN_TERMCAP; separator = ':'; @@ -474,9 +484,14 @@ _nc_get_token(bool silent) } else ch = eat_escaped_newline(ch); - *ptr++ = ch; + if (OkToAdd()) { + AddCh(ch); + } else { + ch = EOF; + break; + } } - ptr[0] = '\0'; + *tok_ptr = '\0'; if (_nc_syntax == ERR) { /* * Grrr...what we ought to do here is barf, complaining that @@ -488,9 +503,11 @@ _nc_get_token(bool silent) separator = ':'; } else if (_nc_syntax == SYN_TERMINFO) { /* throw away trailing /, *$/ */ - for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--) + for (--tok_ptr; + iswhite(*tok_ptr) || *tok_ptr == ','; + tok_ptr--) continue; - ptr[1] = '\0'; + tok_ptr[1] = '\0'; } /* @@ -501,8 +518,8 @@ _nc_get_token(bool silent) if (after_name != 0) { ch = *after_name; *after_name = '\0'; - _nc_set_type(buffer); - *after_name = ch; + _nc_set_type(tok_buf); + *after_name = (char) ch; } /* @@ -517,7 +534,7 @@ _nc_get_token(bool silent) _nc_warning("older tic versions may treat the description field as an alias"); } } else { - after_list = buffer + strlen(buffer); + after_list = tok_buf + strlen(tok_buf); DEBUG(1, ("missing description")); } @@ -526,7 +543,7 @@ _nc_get_token(bool silent) * rdist and some termcap tools. Slashes are a no-no. Other * special characters can be dangerous due to shell expansion. */ - for (s = buffer; s < after_list; ++s) { + for (s = tok_buf; s < after_list; ++s) { if (isspace(UChar(*s))) { if (!silent) _nc_warning("whitespace in name or alias field"); @@ -542,7 +559,7 @@ _nc_get_token(bool silent) } } - _nc_curr_token.tk_name = buffer; + _nc_curr_token.tk_name = tok_buf; type = NAMES; } else { if (had_newline && _nc_syntax == SYN_TERMCAP) { @@ -559,30 +576,35 @@ _nc_get_token(bool silent) break; } } - *(ptr++) = ch; + if (OkToAdd()) { + AddCh(ch); + } else { + ch = EOF; + break; + } } - *ptr++ = '\0'; + *tok_ptr++ = '\0'; /* separate name/value in buffer */ switch (ch) { case ',': case ':': if (ch != separator) _nc_err_abort("Separator inconsistent with syntax"); - _nc_curr_token.tk_name = buffer; + _nc_curr_token.tk_name = tok_buf; type = BOOLEAN; break; case '@': if ((ch = next_char()) != separator && !silent) _nc_warning("Missing separator after `%s', have %s", - buffer, unctrl((chtype) ch)); - _nc_curr_token.tk_name = buffer; + tok_buf, unctrl((chtype) ch)); + _nc_curr_token.tk_name = tok_buf; type = CANCEL; break; case '#': found = 0; while (isalnum(ch = next_char())) { - numbuf[found++] = ch; + numbuf[found++] = (char) ch; if (found >= sizeof(numbuf) - 1) break; } @@ -590,21 +612,21 @@ _nc_get_token(bool silent) number = strtol(numbuf, &numchk, 0); if (!silent) { if (numchk == numbuf) - _nc_warning("no value given for `%s'", buffer); + _nc_warning("no value given for `%s'", tok_buf); if ((*numchk != '\0') || (ch != separator)) _nc_warning("Missing separator"); } - _nc_curr_token.tk_name = buffer; + _nc_curr_token.tk_name = tok_buf; _nc_curr_token.tk_valnumber = number; type = NUMBER; break; case '=': - ch = _nc_trans_string(ptr, buffer + MAX_ENTRY_SIZE); + ch = _nc_trans_string(tok_ptr, tok_buf + TOK_BUF_SIZE); if (!silent && ch != separator) _nc_warning("Missing separator"); - _nc_curr_token.tk_name = buffer; - _nc_curr_token.tk_valstring = ptr; + _nc_curr_token.tk_name = tok_buf; + _nc_curr_token.tk_valstring = tok_ptr; type = STRING; break; @@ -713,8 +735,15 @@ _nc_trans_string(char *ptr, char *last) bool long_warning = FALSE; while ((ch = c = next_char()) != (chtype) separator && c != EOF) { - if (ptr == (last - 1)) + if (ptr >= (last - 1)) { + if (c != EOF) { + while ((c = next_char()) != separator && c != EOF) { + ; + } + ch = c; + } break; + } if ((_nc_syntax == SYN_TERMCAP) && c == '\n') break; if (ch == '^' && last_ch != '%') { @@ -839,7 +868,7 @@ _nc_trans_string(char *ptr, char *last) if (!ignored) { if (_nc_curr_col <= 1) { - push_back(ch); + push_back((char) ch); ch = '\n'; break; } diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c index 8b63f0d8965c..cf2a8337b870 100644 --- a/ncurses/tinfo/entries.c +++ b/ncurses/tinfo/entries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 2006-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +37,7 @@ #include #include -MODULE_ID("$Id: entries.c,v 1.4 2007/11/03 21:00:27 tom Exp $") +MODULE_ID("$Id: entries.c,v 1.8 2008/09/27 13:11:10 tom Exp $") /**************************************************************************** * @@ -111,26 +111,27 @@ _nc_delink_entry(ENTRY * headp, TERMTYPE *tterm) NCURSES_EXPORT(void) _nc_leaks_tinfo(void) { +#if NO_LEAKS char *s; +#endif T((T_CALLED("_nc_free_tinfo()"))); #if NO_LEAKS _nc_free_tparm(); _nc_tgetent_leaks(); -#endif _nc_free_entries(_nc_head); _nc_get_type(0); _nc_first_name(0); -#if NO_LEAKS _nc_keyname_leaks(); -#endif #if BROKEN_LINKER || USE_REENTRANT _nc_names_leaks(); _nc_codes_leaks(); + FreeIfNeeded(_nc_prescreen.real_acs_map); #endif if ((s = _nc_home_terminfo()) != 0) free(s); +#endif /* NO_LEAKS */ returnVoid; } diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c index 92c26705a016..4521c4a8da68 100644 --- a/ncurses/tinfo/home_terminfo.c +++ b/ncurses/tinfo/home_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,9 +37,7 @@ #include #include -MODULE_ID("$Id: home_terminfo.c,v 1.10 2007/04/21 23:11:53 tom Exp $") - -#define my_length (strlen(home) + sizeof(PRIVATE_INFO)) +MODULE_ID("$Id: home_terminfo.c,v 1.11 2008/08/03 23:43:11 tom Exp $") /* ncurses extension...fall back on user's private directory */ @@ -54,9 +52,9 @@ _nc_home_terminfo(void) if (use_terminfo_vars()) { if (MyBuffer == 0) { - if ((home = getenv("HOME")) != 0 - && my_length <= PATH_MAX) { - MyBuffer = typeMalloc(char, my_length); + if ((home = getenv("HOME")) != 0) { + unsigned want = (strlen(home) + sizeof(PRIVATE_INFO)); + MyBuffer = typeMalloc(char, want); if (MyBuffer == 0) _nc_err_abort(MSG_NO_MEMORY); (void) sprintf(MyBuffer, PRIVATE_INFO, home); diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c index d30d3ed16a87..2f6fe4f6fad7 100644 --- a/ncurses/tinfo/init_keytry.c +++ b/ncurses/tinfo/init_keytry.c @@ -36,7 +36,7 @@ #include -MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $") +MODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $") /* ** _nc_init_keytry() @@ -45,6 +45,13 @@ MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $") ** */ +/* + * Internal entrypoints use SCREEN* parameter to obtain capabilities rather + * than cur_term. + */ +#undef CUR +#define CUR (sp->_term)->type. + #if BROKEN_LINKER #undef _nc_tinfo_fkeys #endif diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c index 6a24285460b3..919e47287a7b 100644 --- a/ncurses/tinfo/lib_acs.c +++ b/ncurses/tinfo/lib_acs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include #include /* ena_acs, acs_chars */ -MODULE_ID("$Id: lib_acs.c,v 1.34 2007/09/29 20:37:13 tom Exp $") +MODULE_ID("$Id: lib_acs.c,v 1.36 2008/08/16 19:22:55 tom Exp $") #if BROKEN_LINKER || USE_REENTRANT #define MyBuffer _nc_prescreen.real_acs_map @@ -72,7 +72,8 @@ _nc_init_acs(void) for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; fake_map[j] = A_ALTCHARSET | j; - SP->_screen_acs_map[j] = FALSE; + if (SP) + SP->_screen_acs_map[j] = FALSE; } } else { for (j = 1; j < ACS_LEN; ++j) { @@ -172,7 +173,7 @@ _nc_init_acs(void) for (n = 1, m = 0; n < ACS_LEN; n++) { if (real_map[n] != 0) { show[m++] = (char) n; - show[m++] = ChCharOf(real_map[n]); + show[m++] = (char) ChCharOf(real_map[n]); } } show[m] = 0; diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c index 4070160da393..b9cdfda9acce 100644 --- a/ncurses/tinfo/lib_baudrate.c +++ b/ncurses/tinfo/lib_baudrate.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -80,7 +80,7 @@ #undef USE_OLD_TTY #endif /* USE_OLD_TTY */ -MODULE_ID("$Id: lib_baudrate.c,v 1.25 2007/10/20 15:00:41 Rong-En.Fan Exp $") +MODULE_ID("$Id: lib_baudrate.c,v 1.27 2008/06/28 15:19:24 tom Exp $") /* * int @@ -207,7 +207,7 @@ baudrate(void) * that take into account costs that depend on baudrate. */ #ifdef TRACE - if (SP && !isatty(fileno(SP->_ofp)) + if (!isatty(fileno(SP ? SP->_ofp : stdout)) && getenv("BAUDRATE") != 0) { int ret; if ((ret = _nc_getenv_num("BAUDRATE")) <= 0) @@ -217,19 +217,22 @@ baudrate(void) } #endif + if (cur_term != 0) { #ifdef USE_OLD_TTY - result = cfgetospeed(&cur_term->Nttyb); - ospeed = _nc_ospeed(result); + result = cfgetospeed(&cur_term->Nttyb); + ospeed = _nc_ospeed(result); #else /* !USE_OLD_TTY */ #ifdef TERMIOS - ospeed = cfgetospeed(&cur_term->Nttyb); + ospeed = cfgetospeed(&cur_term->Nttyb); #else - ospeed = cur_term->Nttyb.sg_ospeed; + ospeed = cur_term->Nttyb.sg_ospeed; #endif - result = _nc_baudrate(ospeed); + result = _nc_baudrate(ospeed); #endif - if (cur_term != 0) cur_term->_baudrate = result; + } else { + result = ERR; + } returnCode(result); } diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index 8fccc2f88d08..626578d5c08b 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. * + * Copyright (c) 1998-2003,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,21 +40,45 @@ #include /* TTY, cur_term */ #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.13 2003/12/27 18:21:30 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.18 2008/08/16 19:22:55 tom Exp $") +#undef CUR +#define CUR termp->type. + +#if BROKEN_LINKER || USE_REENTRANT +NCURSES_EXPORT(TERMINAL *) +NCURSES_PUBLIC_VAR(cur_term) (void) +{ + return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term; +} +#else NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0; +#endif NCURSES_EXPORT(TERMINAL *) set_curterm(TERMINAL * termp) { - TERMINAL *oldterm = cur_term; + TERMINAL *oldterm; T((T_CALLED("set_curterm(%p)"), termp)); - if ((cur_term = termp) != 0) { - ospeed = _nc_ospeed(cur_term->_baudrate); - PC = (pad_char != NULL) ? pad_char[0] : 0; + _nc_lock_global(curses); + oldterm = cur_term; + if (SP) + SP->_term = termp; +#if BROKEN_LINKER || USE_REENTRANT + _nc_prescreen._cur_term = termp; +#else + cur_term = termp; +#endif + if (termp != 0) { + ospeed = _nc_ospeed(termp->_baudrate); + if (termp->type.Strings) { + PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); + } } + _nc_unlock_global(curses); + T((T_RETURN("%p"), oldterm)); return (oldterm); } @@ -62,15 +86,20 @@ set_curterm(TERMINAL * termp) NCURSES_EXPORT(int) del_curterm(TERMINAL * termp) { + int rc = ERR; + T((T_CALLED("del_curterm(%p)"), termp)); + _nc_lock_global(curses); if (termp != 0) { _nc_free_termtype(&(termp->type)); FreeIfNeeded(termp->_termname); free(termp); if (termp == cur_term) - cur_term = 0; - returnCode(OK); + set_curterm(0); + rc = OK; } - returnCode(ERR); + _nc_unlock_global(curses); + + returnCode(rc); } diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c index ba37e5dc8c49..e84209d4022c 100644 --- a/ncurses/tinfo/lib_data.c +++ b/ncurses/tinfo/lib_data.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_data.c,v 1.43 2008/03/29 21:16:49 tom Exp $") +MODULE_ID("$Id: lib_data.c,v 1.52 2008/08/23 22:16:15 tom Exp $") /* * OS/2's native linker complains if we don't initialize public data when @@ -168,8 +168,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = { NULL, /* tracedmp_buf */ 0, /* tracedmp_used */ - CHARS_0s, /* tracemse_buf */ - NULL, /* tracetry_buf */ 0, /* tracetry_used */ @@ -179,13 +177,11 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = { #endif /* TRACE */ #ifdef USE_PTHREADS - PTHREAD_MUTEX_INITIALIZER, /* mutex_set_SP */ - PTHREAD_MUTEX_INITIALIZER, /* mutex_use_screen */ - PTHREAD_MUTEX_INITIALIZER, /* mutex_use_window */ - PTHREAD_MUTEX_INITIALIZER, /* mutex_windowlist */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */ PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */ PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */ 0, /* nested_tracef */ + 0, /* use_pthreads */ #endif }; @@ -222,10 +218,14 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { NUM_VARS_0s, /* static_vars */ }, NULL, /* saved_tty */ +#if NCURSES_NO_PADDING + FALSE, /* flag to set if padding disabled */ +#endif #if BROKEN_LINKER || USE_REENTRANT NULL, /* real_acs_map */ 0, /* LINES */ 0, /* COLS */ + 0, /* cur_term */ #ifdef TRACE 0L, /* _outchars */ NULL, /* _tputs_trace */ @@ -243,15 +243,33 @@ init_global_mutexes(void) if (!initialized) { initialized = TRUE; - _nc_mutex_init(&_nc_globals.mutex_set_SP); - _nc_mutex_init(&_nc_globals.mutex_use_screen); - _nc_mutex_init(&_nc_globals.mutex_use_window); - _nc_mutex_init(&_nc_globals.mutex_windowlist); + _nc_mutex_init(&_nc_globals.mutex_curses); _nc_mutex_init(&_nc_globals.mutex_tst_tracef); _nc_mutex_init(&_nc_globals.mutex_tracef); } } +NCURSES_EXPORT(void) +_nc_init_pthreads(void) +{ + if (_nc_use_pthreads) + return; +# if USE_WEAK_SYMBOLS + if ((pthread_mutex_init) == 0) + return; + if ((pthread_mutex_lock) == 0) + return; + if ((pthread_mutex_unlock) == 0) + return; + if ((pthread_mutex_trylock) == 0) + return; + if ((pthread_mutexattr_settype) == 0) + return; +# endif + _nc_use_pthreads = 1; + init_global_mutexes(); +} + /* * Use recursive mutexes if we have them - they're part of Unix98. * For the cases where we do not, _nc_mutex_trylock() is used to avoid a @@ -266,29 +284,49 @@ _nc_mutex_init(pthread_mutex_t * obj) { pthread_mutexattr_t recattr; - memset(&recattr, 0, sizeof(recattr)); - pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(obj, &recattr); + if (_nc_use_pthreads) { + pthread_mutexattr_init(&recattr); + pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(obj, &recattr); + } } NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t * obj) { - init_global_mutexes(); + if (_nc_use_pthreads == 0) + return 0; return pthread_mutex_lock(obj); } NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t * obj) { - init_global_mutexes(); + if (_nc_use_pthreads == 0) + return 0; return pthread_mutex_trylock(obj); } NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t * obj) { - init_global_mutexes(); + if (_nc_use_pthreads == 0) + return 0; return pthread_mutex_unlock(obj); } + +#if USE_WEAK_SYMBOLS +/* + * NB: sigprocmask(2) is global but pthread_sigmask(3p) + * only for the calling thread. + */ +NCURSES_EXPORT(int) +_nc_sigprocmask(int how, const sigset_t * newmask, sigset_t * oldmask) +{ + if ((pthread_sigmask)) + return pthread_sigmask(how, newmask, oldmask); + else + return sigprocmask(how, newmask, oldmask); +} +#endif #endif /* USE_PTHREADS */ diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index 98aae24baacb..f3b1485bf111 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -43,7 +43,10 @@ #include -MODULE_ID("$Id: lib_options.c,v 1.52 2008/05/03 23:09:20 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.58 2008/08/16 21:20:48 Werner.Fink Exp $") + +static int _nc_curs_set(SCREEN *, int); +static int _nc_meta(SCREEN *, bool); NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) @@ -134,23 +137,11 @@ keypad(WINDOW *win, bool flag) NCURSES_EXPORT(int) meta(WINDOW *win GCC_UNUSED, bool flag) { - int result = ERR; + int result; /* Ok, we stay relaxed and don't signal an error if win is NULL */ T((T_CALLED("meta(%p,%d)"), win, flag)); - - if (SP != 0) { - SP->_use_meta = flag; - - if (flag && meta_on) { - TPUTS_TRACE("meta_on"); - putp(meta_on); - } else if (!flag && meta_off) { - TPUTS_TRACE("meta_off"); - putp(meta_off); - } - result = OK; - } + result = _nc_meta(SP, flag); returnCode(result); } @@ -159,43 +150,10 @@ meta(WINDOW *win GCC_UNUSED, bool flag) NCURSES_EXPORT(int) curs_set(int vis) { - int result = ERR; + int result; T((T_CALLED("curs_set(%d)"), vis)); - if (SP != 0 && vis >= 0 && vis <= 2) { - int cursor = SP->_cursor; - - if (vis == cursor) { - result = cursor; - } else { - result = (cursor == -1 ? 1 : cursor); - switch (vis) { - case 2: - if (cursor_visible) { - TPUTS_TRACE("cursor_visible"); - putp(cursor_visible); - } else - result = ERR; - break; - case 1: - if (cursor_normal) { - TPUTS_TRACE("cursor_normal"); - putp(cursor_normal); - } else - result = ERR; - break; - case 0: - if (cursor_invisible) { - TPUTS_TRACE("cursor_invisible"); - putp(cursor_invisible); - } else - result = ERR; - break; - } - SP->_cursor = vis; - _nc_flush(); - } - } + result = _nc_curs_set(SP, vis); returnCode(result); } @@ -239,6 +197,35 @@ has_key(int keycode) } #endif /* NCURSES_EXT_FUNCS */ +/* + * Internal entrypoints use SCREEN* parameter to obtain capabilities rather + * than cur_term. + */ +#undef CUR +#define CUR (sp->_term)->type. + +static int +_nc_putp(const char *name GCC_UNUSED, const char *value) +{ + int rc = ERR; + + if (value) { + TPUTS_TRACE(name); + rc = putp(value); + } + return rc; +} + +static int +_nc_putp_flush(const char *name, const char *value) +{ + int rc = _nc_putp(name, value); + if (rc != ERR) { + _nc_flush(); + } + return rc; +} + /* Turn the keypad on/off * * Note: we flush the output because changing this mode causes some terminals @@ -249,22 +236,92 @@ has_key(int keycode) NCURSES_EXPORT(int) _nc_keypad(SCREEN *sp, bool flag) { - if (flag && keypad_xmit) { - TPUTS_TRACE("keypad_xmit"); - putp(keypad_xmit); - _nc_flush(); - } else if (!flag && keypad_local) { - TPUTS_TRACE("keypad_local"); - putp(keypad_local); - _nc_flush(); - } + int rc = ERR; if (sp != 0) { - if (flag && !sp->_tried) { - _nc_init_keytry(sp); - sp->_tried = TRUE; +#ifdef USE_PTHREADS + /* + * We might have this situation in a multithreaded application that + * has wgetch() reading in more than one thread. putp() and below + * may use SP explicitly. + */ + if (_nc_use_pthreads && sp != SP) { + SCREEN *save_sp; + + /* cannot use use_screen(), since that is not in tinfo library */ + _nc_lock_global(curses); + save_sp = SP; + _nc_set_screen(sp); + rc = _nc_keypad(sp, flag); + _nc_set_screen(save_sp); + _nc_unlock_global(curses); + } else +#endif + { + if (flag) { + (void) _nc_putp_flush("keypad_xmit", keypad_xmit); + } else if (!flag && keypad_local) { + (void) _nc_putp_flush("keypad_local", keypad_local); + } + + if (flag && !sp->_tried) { + _nc_init_keytry(sp); + sp->_tried = TRUE; + } + sp->_keypad_on = flag; + rc = OK; } - sp->_keypad_on = flag; } - return (OK); + return (rc); +} + +static int +_nc_curs_set(SCREEN *sp, int vis) +{ + int result = ERR; + + T((T_CALLED("curs_set(%d)"), vis)); + if (sp != 0 && vis >= 0 && vis <= 2) { + int cursor = sp->_cursor; + + if (vis == cursor) { + result = cursor; + } else { + switch (vis) { + case 2: + result = _nc_putp_flush("cursor_visible", cursor_visible); + break; + case 1: + result = _nc_putp_flush("cursor_normal", cursor_normal); + break; + case 0: + result = _nc_putp_flush("cursor_invisible", cursor_invisible); + break; + } + if (result != ERR) + result = (cursor == -1 ? 1 : cursor); + sp->_cursor = vis; + } + } + returnCode(result); +} + +static int +_nc_meta(SCREEN *sp, bool flag) +{ + int result = ERR; + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + + if (SP != 0) { + SP->_use_meta = flag; + + if (flag) { + _nc_putp("meta_on", meta_on); + } else { + _nc_putp("meta_off", meta_off); + } + result = OK; + } + return result; } diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 08cb783c5942..8cfaf12c5348 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -53,7 +53,7 @@ #include /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_setup.c,v 1.105 2008/05/03 22:41:42 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.111 2008/08/03 22:42:33 tom Exp $") /**************************************************************************** * @@ -99,6 +99,12 @@ MODULE_ID("$Id: lib_setup.c,v 1.105 2008/05/03 22:41:42 tom Exp $") # endif #endif +/* + * Reduce explicit use of "cur_term" global variable. + */ +#undef CUR +#define CUR termp->type. + /* * Wrap global variables in this module. */ @@ -109,15 +115,25 @@ NCURSES_PUBLIC_VAR(ttytype) (void) static char empty[] = ""; return cur_term ? cur_term->type.term_names : empty; } +NCURSES_EXPORT(int *) +_nc_ptr_Lines(void) +{ + return ptrLines(); +} NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(LINES) (void) { - return (SP ? SP->_LINES : _nc_prescreen._LINES); + return *_nc_ptr_Lines(); +} +NCURSES_EXPORT(int *) +_nc_ptr_Cols(void) +{ + return ptrCols(); } NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(COLS) (void) { - return SP ? SP->_COLS : _nc_prescreen._COLS; + return *_nc_ptr_Cols(); } NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(TABSIZE) (void) @@ -183,6 +199,7 @@ NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *sp, int *linep, int *colp) /* Obtain lines/columns values from the environment and/or terminfo entry */ { + TERMINAL *termp = cur_term; int my_tabsize; /* figure out the size of the screen */ @@ -287,6 +304,7 @@ _nc_get_screensize(SCREEN *sp, int *linep, int *colp) NCURSES_EXPORT(void) _nc_update_screensize(SCREEN *sp) { + TERMINAL *termp = cur_term; int old_lines = lines; int new_lines; int old_cols = columns; @@ -369,21 +387,23 @@ grab_entry(const char *const tn, TERMTYPE *const tp) ** and substitute it in for the prototype given in 'command_character'. */ static void -do_prototype(void) +do_prototype(TERMINAL * termp) { - int i; + unsigned i; char CC; char proto; char *tmp; - tmp = getenv("CC"); - CC = *tmp; - proto = *command_character; + if ((tmp = getenv("CC")) != 0) { + if ((CC = *tmp) != 0) { + proto = *command_character; - for_each_string(i, &(cur_term->type)) { - for (tmp = cur_term->type.Strings[i]; *tmp; tmp++) { - if (*tmp == proto) - *tmp = CC; + for_each_string(i, &(termp->type)) { + for (tmp = termp->type.Strings[i]; *tmp; tmp++) { + if (*tmp == proto) + *tmp = CC; + } + } } } } @@ -443,7 +463,7 @@ _nc_unicode_locale(void) * character set. */ NCURSES_EXPORT(int) -_nc_locale_breaks_acs(void) +_nc_locale_breaks_acs(TERMINAL * termp) { char *env; @@ -473,6 +493,7 @@ _nc_locale_breaks_acs(void) NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse) { + TERMINAL *termp; int status; START_TRACE(); @@ -517,23 +538,22 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse) * properly with this feature). */ if (reuse - && cur_term != 0 - && cur_term->Filedes == Filedes - && cur_term->_termname != 0 - && !strcmp(cur_term->_termname, tname) - && _nc_name_match(cur_term->type.term_names, tname, "|")) { + && (termp = cur_term) != 0 + && termp->Filedes == Filedes + && termp->_termname != 0 + && !strcmp(termp->_termname, tname) + && _nc_name_match(termp->type.term_names, tname, "|")) { T(("reusing existing terminal information and mode-settings")); } else { - TERMINAL *term_ptr; - term_ptr = typeCalloc(TERMINAL, 1); + termp = typeCalloc(TERMINAL, 1); - if (term_ptr == 0) { + if (termp == 0) { ret_error0(TGETENT_ERR, "Not enough memory to create terminal structure.\n"); } #if USE_DATABASE || USE_TERMCAP - status = grab_entry(tname, &term_ptr->type); + status = grab_entry(tname, &termp->type); #else status = TGETENT_NO; #endif @@ -543,32 +563,31 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse) const TERMTYPE *fallback = _nc_fallback(tname); if (fallback) { - term_ptr->type = *fallback; + termp->type = *fallback; status = TGETENT_YES; } } if (status != TGETENT_YES) { - del_curterm(term_ptr); + del_curterm(termp); if (status == TGETENT_ERR) { ret_error0(status, "terminals database is inaccessible\n"); } else if (status == TGETENT_NO) { ret_error(status, "'%s': unknown terminal type.\n", tname); } } - - set_curterm(term_ptr); - - if (command_character && getenv("CC")) - do_prototype(); - #if !USE_REENTRANT - strncpy(ttytype, cur_term->type.term_names, NAMESIZE - 1); + strncpy(ttytype, termp->type.term_names, NAMESIZE - 1); ttytype[NAMESIZE - 1] = '\0'; #endif - cur_term->Filedes = Filedes; - cur_term->_termname = strdup(tname); + termp->Filedes = Filedes; + termp->_termname = strdup(tname); + + set_curterm(termp); + + if (command_character && getenv("CC")) + do_prototype(termp); /* * If an application calls setupterm() rather than initscr() or @@ -585,13 +604,7 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse) /* * We should always check the screensize, just in case. */ -#if USE_REENTRANT - _nc_get_screensize(SP, - SP ? &(SP->_LINES) : &(_nc_prescreen._LINES), - SP ? &(SP->_COLS) : &(_nc_prescreen._COLS)); -#else - _nc_get_screensize(SP, &LINES, &COLS); -#endif + _nc_get_screensize(SP, ptrLines(), ptrCols()); if (errret) *errret = TGETENT_YES; diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c index ff97eea920f8..2d245ffbb61f 100644 --- a/ncurses/tinfo/lib_termcap.c +++ b/ncurses/tinfo/lib_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -45,7 +45,7 @@ #include -MODULE_ID("$Id: lib_termcap.c,v 1.61 2007/06/02 19:36:03 tom Exp $") +MODULE_ID("$Id: lib_termcap.c,v 1.63 2008/08/16 19:22:55 tom Exp $") NCURSES_EXPORT_VAR(char *) UP = 0; NCURSES_EXPORT_VAR(char *) BC = 0; @@ -142,7 +142,7 @@ tgetent(char *bufp, const char *name) if (errcode == 1) { if (cursor_left) - if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0) + if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0) backspace_if_not_bs = cursor_left; /* we're required to export these */ @@ -164,6 +164,7 @@ tgetent(char *bufp, const char *name) LAST_BUF = bufp; LAST_USE = TRUE; + SetNoPadding(SP); (void) baudrate(); /* sets ospeed as a side-effect */ /* LINT_PREPRO diff --git a/ncurses/tinfo/lib_tgoto.c b/ncurses/tinfo/lib_tgoto.c index 37553f712394..e07f4643138b 100644 --- a/ncurses/tinfo/lib_tgoto.c +++ b/ncurses/tinfo/lib_tgoto.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2000-2003,2006 Free Software Foundation, Inc. * + * Copyright (c) 2000-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include #include -MODULE_ID("$Id: lib_tgoto.c,v 1.12 2006/11/26 00:26:24 tom Exp $") +MODULE_ID("$Id: lib_tgoto.c,v 1.13 2008/08/16 19:29:32 tom Exp $") #if !PURE_TERMINFO static bool @@ -128,7 +128,7 @@ tgoto_internal(const char *string, int x, int y) *value = 0200; /* tputs will treat this as \0 */ } } - result[used++] = *value++; + result[used++] = (char) *value++; break; case '%': result[used++] = *string; diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c index d11fcf80cfbf..ba2a8404030e 100644 --- a/ncurses/tinfo/lib_tparm.c +++ b/ncurses/tinfo/lib_tparm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: lib_tparm.c,v 1.74 2007/09/29 20:37:13 tom Exp $") +MODULE_ID("$Id: lib_tparm.c,v 1.76 2008/08/16 19:22:55 tom Exp $") /* * char * @@ -166,7 +166,7 @@ save_char(int c) if (c == 0) c = 0200; get_space(1); - TPS(out_buff)[TPS(out_used)++] = c; + TPS(out_buff)[TPS(out_used)++] = (char) c; } static NCURSES_INLINE void @@ -504,8 +504,12 @@ tparam_internal(const char *string, va_list ap) TPS(stack_ptr) = 0; if (popcount == 0) { popcount = number; - for (i = number - 1; i >= 0; i--) - npush(param[i]); + for (i = number - 1; i >= 0; i--) { + if (p_is_s[i]) + spush(p_is_s[i]); + else + npush(param[i]); + } } #ifdef TRACE if (USE_TRACEF(TRACE_CALLS)) { diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c index aab3351905ce..a8b7276895a5 100644 --- a/ncurses/tinfo/lib_tputs.c +++ b/ncurses/tinfo/lib_tputs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,6 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* @@ -45,13 +46,29 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.64 2007/09/29 20:37:13 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.66 2008/06/28 13:12:15 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0; /* used by 'tack' program */ +#if NCURSES_NO_PADDING +NCURSES_EXPORT(void) +_nc_set_no_padding(SCREEN *sp) +{ + bool no_padding = (getenv("NCURSES_NO_PADDING") != 0); + + if (sp) + sp->_no_padding = no_padding; + else + _nc_prescreen._no_padding = no_padding; + + TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used", + GetNoPadding(sp) ? " not" : "")); +} +#endif + static int (*my_outch) (int c) = _nc_outch; NCURSES_EXPORT(int) @@ -147,7 +164,7 @@ tputs(const char *string, int affcnt, int (*outc) (int)) !xon_xoff && padding_baud_rate #if NCURSES_NO_PADDING - && (SP == 0 || !(SP->_no_padding)) + && !GetNoPadding(SP) #endif && (_nc_baudrate(ospeed) >= padding_baud_rate); } diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c index 2cb9fd67b4dd..a2b38a3327f1 100644 --- a/ncurses/tinfo/lib_ttyflags.c +++ b/ncurses/tinfo/lib_ttyflags.c @@ -38,7 +38,7 @@ #include #include /* cur_term */ -MODULE_ID("$Id: lib_ttyflags.c,v 1.16 2008/05/03 22:39:03 tom Exp $") +MODULE_ID("$Id: lib_ttyflags.c,v 1.18 2008/08/03 22:10:44 tom Exp $") NCURSES_EXPORT(int) _nc_get_tty_mode(TTY * buf) @@ -65,7 +65,8 @@ _nc_get_tty_mode(TTY * buf) memset(buf, 0, sizeof(*buf)); TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s", - cur_term->Filedes, _nc_trace_ttymode(buf))); + cur_term ? cur_term->Filedes : -1, + _nc_trace_ttymode(buf))); } return (result); } @@ -93,7 +94,8 @@ _nc_set_tty_mode(TTY * buf) } } TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s", - cur_term->Filedes, _nc_trace_ttymode(buf))); + cur_term ? cur_term->Filedes : -1, + _nc_trace_ttymode(buf))); } return (result); } @@ -101,41 +103,49 @@ _nc_set_tty_mode(TTY * buf) NCURSES_EXPORT(int) def_shell_mode(void) { + int rc = ERR; + T((T_CALLED("def_shell_mode()"))); - /* - * If XTABS was on, remove the tab and backtab capabilities. - */ - - if (_nc_get_tty_mode(&cur_term->Ottyb) != OK) - returnCode(ERR); + if (cur_term != 0) { + /* + * If XTABS was on, remove the tab and backtab capabilities. + */ + if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) { #ifdef TERMIOS - if (cur_term->Ottyb.c_oflag & OFLAGS_TABS) - tab = back_tab = NULL; + if (cur_term->Ottyb.c_oflag & OFLAGS_TABS) + tab = back_tab = NULL; #else - if (cur_term->Ottyb.sg_flags & XTABS) - tab = back_tab = NULL; + if (cur_term->Ottyb.sg_flags & XTABS) + tab = back_tab = NULL; #endif - returnCode(OK); + rc = OK; + } + } + returnCode(rc); } NCURSES_EXPORT(int) def_prog_mode(void) { + int rc = ERR; + T((T_CALLED("def_prog_mode()"))); - /* - * Turn off the XTABS bit in the tty structure if it was on. - */ - - if (_nc_get_tty_mode(&cur_term->Nttyb) != OK) - returnCode(ERR); + if (cur_term != 0) { + /* + * Turn off the XTABS bit in the tty structure if it was on. + */ + if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) { #ifdef TERMIOS - cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS; + cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS; #else - cur_term->Nttyb.sg_flags &= ~XTABS; + cur_term->Nttyb.sg_flags &= ~XTABS; #endif - returnCode(OK); + rc = OK; + } + } + returnCode(rc); } NCURSES_EXPORT(int) diff --git a/ncurses/tinfo/make_keys.c b/ncurses/tinfo/make_keys.c index 00367185a45c..c084f87fb943 100644 --- a/ncurses/tinfo/make_keys.c +++ b/ncurses/tinfo/make_keys.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1997 * + * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* @@ -39,7 +39,7 @@ #define USE_TERMLIB 1 #include -MODULE_ID("$Id: make_keys.c,v 1.13 2007/01/07 00:00:14 tom Exp $") +MODULE_ID("$Id: make_keys.c,v 1.14 2008/08/03 21:57:22 tom Exp $") #include @@ -71,14 +71,20 @@ static void make_keys(FILE *ifp, FILE *ofp) { char buffer[BUFSIZ]; - char from[BUFSIZ]; - char to[BUFSIZ]; + char from[256]; + char to[256]; int maxlen = 16; + int scanned; while (fgets(buffer, sizeof(buffer), ifp) != 0) { if (*buffer == '#') continue; - if (sscanf(buffer, "%s %s", to, from) == 2) { + + to[sizeof(to) - 1] = '\0'; + from[sizeof(from) - 1] = '\0'; + + scanned = sscanf(buffer, "%255s %255s", to, from); + if (scanned == 2) { int code = lookup(from); if (code == UNKNOWN) continue; diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c index c8d728faa7c4..d576901fa2e9 100644 --- a/ncurses/tinfo/name_match.c +++ b/ncurses/tinfo/name_match.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,14 +27,14 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1999 * + * Author: Thomas E. Dickey 1999-on * ****************************************************************************/ #include #include #include -MODULE_ID("$Id: name_match.c,v 1.16 2007/04/21 21:28:13 tom Exp $") +MODULE_ID("$Id: name_match.c,v 1.17 2008/08/03 19:49:33 tom Exp $") /* * _nc_first_name(char *names) @@ -53,18 +53,21 @@ _nc_first_name(const char *const sp) if (sp == 0) { if (FirstName != 0) FreeAndNull(FirstName); - return 0; - } + } else #endif + { + if (FirstName == 0) + FirstName = typeMalloc(char, MAX_NAME_SIZE + 1); - if (FirstName == 0) - FirstName = typeMalloc(char, MAX_NAME_SIZE + 1); - for (n = 0; n < MAX_NAME_SIZE; n++) { - if ((FirstName[n] = sp[n]) == '\0' - || (FirstName[n] == '|')) - break; + if (FirstName != 0) { + for (n = 0; n < MAX_NAME_SIZE; n++) { + if ((FirstName[n] = sp[n]) == '\0' + || (FirstName[n] == '|')) + break; + } + FirstName[n] = '\0'; + } } - FirstName[n] = '\0'; return (FirstName); } diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c index 375ce8ff9957..cf7a5f409d7c 100644 --- a/ncurses/tinfo/parse_entry.c +++ b/ncurses/tinfo/parse_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -48,7 +48,7 @@ #include #include -MODULE_ID("$Id: parse_entry.c,v 1.65 2007/08/11 16:19:02 tom Exp $") +MODULE_ID("$Id: parse_entry.c,v 1.69 2008/08/16 21:52:03 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -245,6 +245,9 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr); + if (entryp->tterm.str_table == 0) + return (ERR); + DEBUG(1, ("Starting '%s'", ptr)); /* @@ -372,26 +375,28 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) * type, this will do the job. */ - /* tell max_attributes from arrow_key_map */ if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name)) { + /* tell max_attributes from arrow_key_map */ entry_ptr = _nc_find_type_entry("ma", NUMBER, _nc_get_table(_nc_syntax != 0)); + assert(entry_ptr != 0); - /* map terminfo's string MT to MT */ } else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name)) { + /* map terminfo's string MT to MT */ entry_ptr = _nc_find_type_entry("MT", STRING, _nc_get_table(_nc_syntax != 0)); + assert(entry_ptr != 0); - /* treat strings without following "=" as empty strings */ } else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING) { + /* treat strings without following "=" as empty strings */ token_type = STRING; - /* we couldn't recover; skip this token */ } else { + /* we couldn't recover; skip this token */ if (!silent) { const char *type_name; switch (entry_ptr->nte_type) { @@ -454,7 +459,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) default: if (!silent) _nc_warning("unknown token type"); - _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ','); + _nc_panic_mode((char) ((_nc_syntax == SYN_TERMCAP) ? ':' : ',')); continue; } } /* end else cur_token.name != "use" */ @@ -474,7 +479,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) if (!literal) { if (_nc_syntax == SYN_TERMCAP) { bool has_base_entry = FALSE; - int i; + unsigned i; /* * Don't insert defaults if this is a `+' entry meant only @@ -549,8 +554,8 @@ append_acs0(string_desc * dst, int code, int src) { if (src != 0) { char temp[3]; - temp[0] = code; - temp[1] = src; + temp[0] = (char) code; + temp[1] = (char) src; temp[2] = 0; _nc_safe_strcat(dst, temp); } @@ -785,11 +790,12 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) base = cp + 1) { size_t len = cp - base; - for (ap = ko_xlate; ap->from; ap++) + for (ap = ko_xlate; ap->from; ap++) { if (len == strlen(ap->from) && strncmp(ap->from, base, len) == 0) break; - if (!ap->to) { + } + if (!(ap->from && ap->to)) { _nc_warning("unknown capability `%.*s' in ko string", (int) len, base); continue; diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index 6a050ee78e66..b4ea61ca194e 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: read_entry.c,v 1.100 2007/11/17 23:56:50 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.102 2008/08/03 19:33:04 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -73,7 +73,7 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table) Strings[i] = ABSENT_STRING; } else if (IS_NEG2(buf + 2 * i)) { Strings[i] = CANCELLED_STRING; - } else if (LOW_MSB(buf + 2 * i) > size) { + } else if ((int) LOW_MSB(buf + 2 * i) > size) { Strings[i] = ABSENT_STRING; } else { Strings[i] = (LOW_MSB(buf + 2 * i) + table); @@ -313,6 +313,8 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) } if (need) { + if (ext_str_count >= (MAX_ENTRY_SIZE * 2)) + return (TGETENT_NO); if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) return (TGETENT_NO); TR(TRACE_DATABASE, diff --git a/ncurses/tinfo/use_screen.c b/ncurses/tinfo/use_screen.c index a4f34c0e4520..6c3b12fb9238 100644 --- a/ncurses/tinfo/use_screen.c +++ b/ncurses/tinfo/use_screen.c @@ -32,7 +32,7 @@ #include -MODULE_ID("$Id: use_screen.c,v 1.4 2008/03/29 21:19:58 tom Exp $") +MODULE_ID("$Id: use_screen.c,v 1.6 2008/06/07 19:16:56 tom Exp $") NCURSES_EXPORT(int) use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data) @@ -46,15 +46,13 @@ use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data) * FIXME - add a flag so a given thread can check if _it_ has already * recurred through this point, return an error if so. */ - _nc_lock_global(use_screen); + _nc_lock_global(curses); save_SP = SP; set_term(screen); code = func(screen, data); set_term(save_SP); - _nc_unlock_global(use_screen); + _nc_unlock_global(curses); returnCode(code); - - return 0; } diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 05027e0021a2..b53bb210230d 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -54,7 +54,7 @@ #define TRACE_OUT(p) /*nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.70 2007/11/17 23:38:28 tom Exp $") +MODULE_ID("$Id: write_entry.c,v 1.72 2008/08/03 19:24:00 tom Exp $") static int total_written; @@ -275,6 +275,9 @@ _nc_write_entry(TERMTYPE *const tp) char *first_name, *other_names; char *ptr; + assert(strlen(tp->term_names) != 0); + assert(strlen(tp->term_names) < sizeof(name_list)); + (void) strcpy(name_list, tp->term_names); DEBUG(7, ("Name list = '%s'", name_list)); @@ -354,7 +357,7 @@ _nc_write_entry(TERMTYPE *const tp) start_time = 0; } - if (strlen(first_name) > sizeof(filename) - 3) + if (strlen(first_name) >= sizeof(filename) - 3) _nc_warning("terminal name too long."); sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name); @@ -382,6 +385,7 @@ _nc_write_entry(TERMTYPE *const tp) } while (*other_names != '\0') { ptr = other_names++; + assert(ptr < buffer + sizeof(buffer) - 1); while (*other_names != '|' && *other_names != '\0') other_names++; @@ -502,7 +506,7 @@ compute_offsets(char **Strings, unsigned strmax, short *offsets) offsets[i] = nextfree; nextfree += strlen(Strings[i]) + 1; TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i, - _nc_visbuf(Strings[i]), nextfree)); + _nc_visbuf(Strings[i]), (int) nextfree)); } } return nextfree; @@ -691,9 +695,17 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit) if (even_boundary(nextfree)) return (ERR); - nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets); + nextfree = compute_offsets(tp->Strings + STRCOUNT, + tp->ext_Strings, + offsets); TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree)); - nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings); + + if (tp->ext_Strings >= SIZEOF(offsets)) + return (ERR); + + nextfree += compute_offsets(tp->ext_Names, + extcnt, + offsets + tp->ext_Strings); TRACE_OUT(("after extended capnames, nextfree=%d", nextfree)); strmax = tp->ext_Strings + extcnt; diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c index 03acb16cba91..743b1f64f1ae 100644 --- a/ncurses/trace/lib_trace.c +++ b/ncurses/trace/lib_trace.c @@ -46,7 +46,7 @@ #include -MODULE_ID("$Id: lib_trace.c,v 1.66 2008/03/22 16:56:48 tom Exp $") +MODULE_ID("$Id: lib_trace.c,v 1.71 2008/08/23 18:04:29 tom Exp $") NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */ @@ -95,10 +95,13 @@ trace(const unsigned int tracelevel) const char *mode = _nc_globals.init_trace ? "ab" : "wb"; if (TracePath[0] == '\0') { - if (getcwd(TracePath, sizeof(TracePath) - 12) == 0) { + int size = sizeof(TracePath) - 12; + if (getcwd(TracePath, size) == 0) { perror("curses: Can't get working directory"); exit(EXIT_FAILURE); } + TracePath[size] = '\0'; + assert(strlen(TracePath) <= size); strcat(TracePath, "/trace"); if (_nc_is_dir_path(TracePath)) { strcat(TracePath, ".log"); @@ -177,7 +180,10 @@ _nc_va_tracef(const char *fmt, va_list ap) * Rather than add the complication of a per-thread stack, just * show the thread-id in each line of the trace. */ - fprintf(TraceFP, "%#lx:", (long) pthread_self()); +# if USE_WEAK_SYMBOLS + if ((pthread_self)) +# endif + fprintf(TraceFP, "%#lx:", (long) (void *) pthread_self()); #endif if (before || after) { int n; @@ -292,9 +298,9 @@ _nc_use_tracef(unsigned mask) _nc_lock_global(tst_tracef); if (!_nc_globals.nested_tracef++) { - if ((result = (_nc_tracing & (mask))) != 0) { + if ((result = (_nc_tracing & (mask))) != 0 + && _nc_try_global(tracef) == 0) { /* we will call _nc_locked_tracef(), no nesting so far */ - _nc_lock_global(tracef); } else { /* we will not call _nc_locked_tracef() */ _nc_globals.nested_tracef = 0; diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c index 108eb8b4d335..45a03cea05fe 100644 --- a/ncurses/trace/lib_traceatr.c +++ b/ncurses/trace/lib_traceatr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include #include /* acs_chars */ -MODULE_ID("$Id: lib_traceatr.c,v 1.59 2007/06/09 17:22:10 tom Exp $") +MODULE_ID("$Id: lib_traceatr.c,v 1.63 2008/08/03 16:24:53 tom Exp $") #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name)) @@ -75,8 +75,6 @@ color_of(int c) NCURSES_EXPORT(char *) _traceattr2(int bufnum, chtype newmode) { - char *buf = _nc_trace_buf(bufnum, BUFSIZ); - char temp[80]; static const struct { unsigned int val; const char *name; @@ -117,47 +115,54 @@ _traceattr2(int bufnum, chtype newmode) #endif /* !USE_TERMLIB */ ; size_t n; - unsigned save_nc_tracing = _nc_tracing; - _nc_tracing = 0; + char temp[80]; + char *result = _nc_trace_buf(bufnum, BUFSIZ); - strcpy(buf, l_brace); + if (result != 0) { + unsigned save_nc_tracing = _nc_tracing; - for (n = 0; n < SIZEOF(names); n++) { - if ((newmode & names[n].val) != 0) { - if (buf[1] != '\0') - buf = _nc_trace_bufcat(bufnum, "|"); - buf = _nc_trace_bufcat(bufnum, names[n].name); + _nc_tracing = 0; - if (names[n].val == A_COLOR) { - short pairnum = PAIR_NUMBER(newmode); + strcpy(result, l_brace); + + for (n = 0; n < SIZEOF(names); n++) { + if ((newmode & names[n].val) != 0) { + if (result[1] != '\0') + result = _nc_trace_bufcat(bufnum, "|"); + result = _nc_trace_bufcat(bufnum, names[n].name); + + if (names[n].val == A_COLOR) { + short pairnum = PAIR_NUMBER(newmode); #ifdef USE_TERMLIB - /* pair_content lives in libncurses */ - (void) sprintf(temp, "{%d}", pairnum); -#else - short fg, bg; - - if (pair_content(pairnum, &fg, &bg) == OK) { - (void) sprintf(temp, - "{%d = {%s, %s}}", - pairnum, - COLOR_OF(fg), - COLOR_OF(bg)); - } else { + /* pair_content lives in libncurses */ (void) sprintf(temp, "{%d}", pairnum); - } +#else + short fg, bg; + + if (pair_content(pairnum, &fg, &bg) == OK) { + (void) sprintf(temp, + "{%d = {%s, %s}}", + pairnum, + COLOR_OF(fg), + COLOR_OF(bg)); + } else { + (void) sprintf(temp, "{%d}", pairnum); + } #endif - buf = _nc_trace_bufcat(bufnum, temp); + result = _nc_trace_bufcat(bufnum, temp); + } } } - } - if (ChAttrOf(newmode) == A_NORMAL) { - if (buf[1] != '\0') - (void) _nc_trace_bufcat(bufnum, "|"); - (void) _nc_trace_bufcat(bufnum, "A_NORMAL"); - } + if (ChAttrOf(newmode) == A_NORMAL) { + if (result != 0 && result[1] != '\0') + (void) _nc_trace_bufcat(bufnum, "|"); + (void) _nc_trace_bufcat(bufnum, "A_NORMAL"); + } - _nc_tracing = save_nc_tracing; - return (_nc_trace_bufcat(bufnum, r_brace)); + _nc_tracing = save_nc_tracing; + result = _nc_trace_bufcat(bufnum, r_brace); + } + return result; } NCURSES_EXPORT(char *) @@ -181,50 +186,48 @@ _nc_altcharset_name(attr_t attr, chtype ch) unsigned int val; const char *name; } ALT_NAMES; + static const ALT_NAMES names[] = + { + {'l', "ACS_ULCORNER"}, /* upper left corner */ + {'m', "ACS_LLCORNER"}, /* lower left corner */ + {'k', "ACS_URCORNER"}, /* upper right corner */ + {'j', "ACS_LRCORNER"}, /* lower right corner */ + {'t', "ACS_LTEE"}, /* tee pointing right */ + {'u', "ACS_RTEE"}, /* tee pointing left */ + {'v', "ACS_BTEE"}, /* tee pointing up */ + {'w', "ACS_TTEE"}, /* tee pointing down */ + {'q', "ACS_HLINE"}, /* horizontal line */ + {'x', "ACS_VLINE"}, /* vertical line */ + {'n', "ACS_PLUS"}, /* large plus or crossover */ + {'o', "ACS_S1"}, /* scan line 1 */ + {'s', "ACS_S9"}, /* scan line 9 */ + {'`', "ACS_DIAMOND"}, /* diamond */ + {'a', "ACS_CKBOARD"}, /* checker board (stipple) */ + {'f', "ACS_DEGREE"}, /* degree symbol */ + {'g', "ACS_PLMINUS"}, /* plus/minus */ + {'~', "ACS_BULLET"}, /* bullet */ + {',', "ACS_LARROW"}, /* arrow pointing left */ + {'+', "ACS_RARROW"}, /* arrow pointing right */ + {'.', "ACS_DARROW"}, /* arrow pointing down */ + {'-', "ACS_UARROW"}, /* arrow pointing up */ + {'h', "ACS_BOARD"}, /* board of squares */ + {'i', "ACS_LANTERN"}, /* lantern symbol */ + {'0', "ACS_BLOCK"}, /* solid square block */ + {'p', "ACS_S3"}, /* scan line 3 */ + {'r', "ACS_S7"}, /* scan line 7 */ + {'y', "ACS_LEQUAL"}, /* less/equal */ + {'z', "ACS_GEQUAL"}, /* greater/equal */ + {'{', "ACS_PI"}, /* Pi */ + {'|', "ACS_NEQUAL"}, /* not equal */ + {'}', "ACS_STERLING"}, /* UK pound sign */ + {'\0', (char *) 0} + }; const char *result = 0; if ((attr & A_ALTCHARSET) && (acs_chars != 0)) { char *cp; char *found = 0; - /* *INDENT-OFF* */ - static const ALT_NAMES names[] = - { - { 'l', "ACS_ULCORNER" }, /* upper left corner */ - { 'm', "ACS_LLCORNER" }, /* lower left corner */ - { 'k', "ACS_URCORNER" }, /* upper right corner */ - { 'j', "ACS_LRCORNER" }, /* lower right corner */ - { 't', "ACS_LTEE" }, /* tee pointing right */ - { 'u', "ACS_RTEE" }, /* tee pointing left */ - { 'v', "ACS_BTEE" }, /* tee pointing up */ - { 'w', "ACS_TTEE" }, /* tee pointing down */ - { 'q', "ACS_HLINE" }, /* horizontal line */ - { 'x', "ACS_VLINE" }, /* vertical line */ - { 'n', "ACS_PLUS" }, /* large plus or crossover */ - { 'o', "ACS_S1" }, /* scan line 1 */ - { 's', "ACS_S9" }, /* scan line 9 */ - { '`', "ACS_DIAMOND" }, /* diamond */ - { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */ - { 'f', "ACS_DEGREE" }, /* degree symbol */ - { 'g', "ACS_PLMINUS" }, /* plus/minus */ - { '~', "ACS_BULLET" }, /* bullet */ - { ',', "ACS_LARROW" }, /* arrow pointing left */ - { '+', "ACS_RARROW" }, /* arrow pointing right */ - { '.', "ACS_DARROW" }, /* arrow pointing down */ - { '-', "ACS_UARROW" }, /* arrow pointing up */ - { 'h', "ACS_BOARD" }, /* board of squares */ - { 'i', "ACS_LANTERN" }, /* lantern symbol */ - { '0', "ACS_BLOCK" }, /* solid square block */ - { 'p', "ACS_S3" }, /* scan line 3 */ - { 'r', "ACS_S7" }, /* scan line 7 */ - { 'y', "ACS_LEQUAL" }, /* less/equal */ - { 'z', "ACS_GEQUAL" }, /* greater/equal */ - { '{', "ACS_PI" }, /* Pi */ - { '|', "ACS_NEQUAL" }, /* not equal */ - { '}', "ACS_STERLING" }, /* UK pound sign */ - { '\0', (char *) 0 } - }; - /* *INDENT-OFF* */ const ALT_NAMES *sp; for (cp = acs_chars; cp[0] && cp[1]; cp += 2) { @@ -250,31 +253,35 @@ NCURSES_EXPORT(char *) _tracechtype2(int bufnum, chtype ch) { const char *found; + char *result = _nc_trace_buf(bufnum, BUFSIZ); - strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace); - if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) { - (void) _nc_trace_bufcat(bufnum, found); - } else - (void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch))); + if (result != 0) { + strcpy(result, l_brace); + if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) { + (void) _nc_trace_bufcat(bufnum, found); + } else + (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int) ChCharOf(ch))); - if (ChAttrOf(ch) != A_NORMAL) { - (void) _nc_trace_bufcat(bufnum, " | "); - (void) _nc_trace_bufcat(bufnum, - _traceattr2(bufnum + 20, ChAttrOf(ch))); + if (ChAttrOf(ch) != A_NORMAL) { + (void) _nc_trace_bufcat(bufnum, " | "); + (void) _nc_trace_bufcat(bufnum, + _traceattr2(bufnum + 20, ChAttrOf(ch))); + } + + result = _nc_trace_bufcat(bufnum, r_brace); } - - return (_nc_trace_bufcat(bufnum, r_brace)); + return result; } NCURSES_EXPORT(char *) -_tracechtype (chtype ch) +_tracechtype(chtype ch) { return _tracechtype2(0, ch); } /* Trace 'chtype' return-values */ NCURSES_EXPORT(chtype) -_nc_retrace_chtype (chtype code) +_nc_retrace_chtype(chtype code) { T((T_RETURN("%s"), _tracechtype(code))); return code; @@ -282,63 +289,70 @@ _nc_retrace_chtype (chtype code) #if USE_WIDEC_SUPPORT NCURSES_EXPORT(char *) -_tracecchar_t2 (int bufnum, const cchar_t *ch) +_tracecchar_t2(int bufnum, const cchar_t *ch) { - char *buf = _nc_trace_buf(bufnum, BUFSIZ); + char *result = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; - strcpy(buf, l_brace); - if (ch != 0) { - attr = AttrOfD(ch); - if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { - (void) _nc_trace_bufcat(bufnum, found); - attr &= ~A_ALTCHARSET; - } else if (isWidecExt(CHDEREF(ch))) { - (void) _nc_trace_bufcat(bufnum, "{NAC}"); - attr &= ~A_CHARTEXT; - } else { - PUTC_DATA; - int n; + if (result != 0) { + strcpy(result, l_brace); + if (ch != 0) { + attr = AttrOfD(ch); + if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { + (void) _nc_trace_bufcat(bufnum, found); + attr &= ~A_ALTCHARSET; + } else if (isWidecExt(CHDEREF(ch))) { + (void) _nc_trace_bufcat(bufnum, "{NAC}"); + attr &= ~A_CHARTEXT; + } else { + PUTC_DATA; + int n; - PUTC_INIT; - (void) _nc_trace_bufcat(bufnum, "{ "); - for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { - PUTC_ch = ch->chars[PUTC_i]; - if (PUTC_ch == L'\0') - break; - PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); - if (PUTC_n <= 0) { - if (PUTC_ch != L'\0') { - /* it could not be a multibyte sequence */ - (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i]))); + PUTC_INIT; + (void) _nc_trace_bufcat(bufnum, "{ "); + for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { + PUTC_ch = ch->chars[PUTC_i]; + if (PUTC_ch == L'\0') + break; + PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); + if (PUTC_n <= 0) { + if (PUTC_ch != L'\0') { + /* it could not be a multibyte sequence */ + (void) _nc_trace_bufcat(bufnum, + _nc_tracechar(SP, + UChar(ch->chars[PUTC_i]))); + } + break; + } + for (n = 0; n < PUTC_n; n++) { + if (n) + (void) _nc_trace_bufcat(bufnum, ", "); + (void) _nc_trace_bufcat(bufnum, + _nc_tracechar(SP, + UChar(PUTC_buf[n]))); } - break; - } - for (n = 0; n < PUTC_n; n++) { - if (n) - (void) _nc_trace_bufcat(bufnum, ", "); - (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n]))); } + (void) _nc_trace_bufcat(bufnum, " }"); + } + if (attr != A_NORMAL) { + (void) _nc_trace_bufcat(bufnum, " | "); + (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } - (void) _nc_trace_bufcat(bufnum, " }"); } - if (attr != A_NORMAL) { - (void) _nc_trace_bufcat(bufnum, " | "); - (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); - } - } - return (_nc_trace_bufcat(bufnum, r_brace)); + result = _nc_trace_bufcat(bufnum, r_brace); + } + return result; } NCURSES_EXPORT(char *) -_tracecchar_t (const cchar_t *ch) +_tracecchar_t(const cchar_t *ch) { return _tracecchar_t2(0, ch); } #endif #else -empty_module(_nc_lib_traceatr) +EMPTY_MODULE(_nc_lib_traceatr) #endif /* TRACE */ diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c index de2394c39225..cc441b391e5b 100644 --- a/ncurses/trace/lib_tracebits.c +++ b/ncurses/trace/lib_tracebits.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include #include /* cur_term */ -MODULE_ID("$Id: lib_tracebits.c,v 1.15 2007/06/30 16:14:20 tom Exp $") +MODULE_ID("$Id: lib_tracebits.c,v 1.17 2008/08/03 16:09:26 tom Exp $") #if SVR4_TERMIO && !defined(_POSIX_SOURCE) #define _POSIX_SOURCE @@ -165,58 +165,52 @@ _nc_trace_ttymode(TTY * tty) 8 + sizeof(cflags) + 8 + sizeof(lflags) + 8); + if (buf != 0) { - if (tty->c_iflag & ALLIN) - lookup_bits(buf, iflags, "iflags", tty->c_iflag); + if (tty->c_iflag & ALLIN) + lookup_bits(buf, iflags, "iflags", tty->c_iflag); - if (tty->c_oflag & ALLOUT) - lookup_bits(buf, oflags, "oflags", tty->c_oflag); + if (tty->c_oflag & ALLOUT) + lookup_bits(buf, oflags, "oflags", tty->c_oflag); - if (tty->c_cflag & ALLCTRL) - lookup_bits(buf, cflags, "cflags", tty->c_cflag); + if (tty->c_cflag & ALLCTRL) + lookup_bits(buf, cflags, "cflags", tty->c_cflag); #if defined(CS5) && defined(CS8) - { - static struct { - const char *name; - int value; - } csizes[] = { - { - "CS5 ", CS5 - }, + { + static struct { + int value; + const char *name; + } csizes[] = { +#define CS_DATA(name) { name, #name " " } + CS_DATA(CS5), #ifdef CS6 - { - "CS6 ", CS6 - }, + CS_DATA(CS6), #endif #ifdef CS7 - { - "CS7 ", CS7 - }, + CS_DATA(CS7), #endif - { - "CS8 ", CS8 - }, - }; - const char *result = "CSIZE? "; - int value = (tty->c_cflag & CSIZE); - unsigned n; + CS_DATA(CS8), + }; + const char *result = "CSIZE? "; + int value = (tty->c_cflag & CSIZE); + unsigned n; - if (value != 0) { - for (n = 0; n < SIZEOF(csizes); n++) { - if (csizes[n].value == value) { - result = csizes[n].name; - break; + if (value != 0) { + for (n = 0; n < SIZEOF(csizes); n++) { + if (csizes[n].value == value) { + result = csizes[n].name; + break; + } } } + strcat(buf, result); } - strcat(buf, result); - } #endif - if (tty->c_lflag & ALLLOCAL) - lookup_bits(buf, lflags, "lflags", tty->c_lflag); - + if (tty->c_lflag & ALLLOCAL) + lookup_bits(buf, lflags, "lflags", tty->c_lflag); + } #else /* reference: ttcompat(4M) on SunOS 4.1 */ #ifndef EVENP @@ -253,9 +247,10 @@ _nc_trace_ttymode(TTY * tty) buf = _nc_trace_buf(0, 8 + sizeof(cflags)); - - if (tty->sg_flags & ALLCTRL) { - lookup_bits(buf, cflags, "cflags", tty->sg_flags); + if (buf != 0) { + if (tty->sg_flags & ALLCTRL) { + lookup_bits(buf, cflags, "cflags", tty->sg_flags); + } } #endif return (buf); @@ -267,5 +262,5 @@ _nc_tracebits(void) return _nc_trace_ttymode(&(cur_term->Nttyb)); } #else -empty_module(_nc_tracebits) +EMPTY_MODULE(_nc_tracebits) #endif /* TRACE */ diff --git a/ncurses/trace/lib_tracechr.c b/ncurses/trace/lib_tracechr.c index 479756ac59be..79cf03b4870c 100644 --- a/ncurses/trace/lib_tracechr.c +++ b/ncurses/trace/lib_tracechr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,18 +39,20 @@ #include -MODULE_ID("$Id: lib_tracechr.c,v 1.13 2007/04/21 23:16:37 tom Exp $") +MODULE_ID("$Id: lib_tracechr.c,v 1.19 2008/08/03 15:39:29 tom Exp $") #ifdef TRACE -#define MyBuffer _nc_globals.tracechr_buf NCURSES_EXPORT(char *) -_tracechar(int ch) +_nc_tracechar(SCREEN *sp, int ch) { NCURSES_CONST char *name; + char *MyBuffer = ((sp != 0) + ? sp->tracechr_buf + : _nc_globals.tracechr_buf); if (ch > KEY_MIN || ch < 0) { - name = keyname(ch); + name = _nc_keyname(sp, ch); if (name == 0 || *name == '\0') name = "NULL"; (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch); @@ -62,13 +64,19 @@ _tracechar(int ch) */ (void) sprintf(MyBuffer, "%#03o", ch); } else { - name = unctrl((chtype) ch); + name = _nc_unctrl(sp, (chtype) ch); if (name == 0 || *name == 0) name = "null"; /* shouldn't happen */ (void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch); } return (MyBuffer); } + +NCURSES_EXPORT(char *) +_tracechar(int ch) +{ + return _nc_tracechar(SP, ch); +} #else -empty_module(_nc_lib_tracechr) +EMPTY_MODULE(_nc_lib_tracechr) #endif diff --git a/ncurses/trace/lib_tracedmp.c b/ncurses/trace/lib_tracedmp.c index d56d1a5d48b0..58732a06c246 100644 --- a/ncurses/trace/lib_tracedmp.c +++ b/ncurses/trace/lib_tracedmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include #include -MODULE_ID("$Id: lib_tracedmp.c,v 1.29 2007/06/30 23:01:19 tom Exp $") +MODULE_ID("$Id: lib_tracedmp.c,v 1.31 2008/08/16 19:30:56 tom Exp $") #ifdef TRACE @@ -83,15 +83,15 @@ _tracedump(const char *name, WINDOW *win) */ for (j = 0; j < width; ++j) { chtype test = CharOf(win->_line[n].text[j]); - ep[j] = (UChar(test) == test + ep[j] = (char) ((UChar(test) == test #if USE_WIDEC_SUPPORT - && (win->_line[n].text[j].chars[1] == 0) + && (win->_line[n].text[j].chars[1] == 0) #endif - ) - ? (iscntrl(UChar(test)) - ? '.' - : UChar(test)) - : '?'; + ) + ? (iscntrl(UChar(test)) + ? '.' + : UChar(test)) + : '?'); } ep[j] = '\0'; _tracef("%s[%2d] %3ld%3ld ='%s'", @@ -113,7 +113,7 @@ _tracedump(const char *name, WINDOW *win) for (j = 0; j < width; ++j) { int test = WidecExt(win->_line[n].text[j]); if (test) { - ep[j] = test + '0'; + ep[j] = (char) (test + '0'); } else { ep[j] = ' '; } @@ -138,11 +138,11 @@ _tracedump(const char *name, WINDOW *win) if (pair >= 52) ep[j] = '?'; else if (pair >= 36) - ep[j] = pair + 'A'; + ep[j] = (char) (pair + 'A'); else if (pair >= 10) - ep[j] = pair + 'a'; + ep[j] = (char) (pair + 'a'); else if (pair >= 1) - ep[j] = pair + '0'; + ep[j] = (char) (pair + '0'); else ep[j] = ' '; } @@ -180,5 +180,5 @@ _tracedump(const char *name, WINDOW *win) } #else -empty_module(_nc_lib_tracedmp) +EMPTY_MODULE(_nc_lib_tracedmp) #endif /* TRACE */ diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c index 5edcc13a6ffa..74cc177d51bb 100644 --- a/ncurses/trace/lib_tracemse.c +++ b/ncurses/trace/lib_tracemse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -38,14 +38,14 @@ #include -MODULE_ID("$Id: lib_tracemse.c,v 1.13 2007/04/21 21:23:00 tom Exp $") +MODULE_ID("$Id: lib_tracemse.c,v 1.15 2008/08/03 15:39:29 tom Exp $") #ifdef TRACE -#define my_buffer _nc_globals.tracemse_buf +#define my_buffer sp->tracemse_buf NCURSES_EXPORT(char *) -_tracemouse(MEVENT const *ep) +_nc_tracemouse(SCREEN *sp, MEVENT const *ep) { (void) sprintf(my_buffer, TRACEMSE_FMT, ep->id, @@ -114,6 +114,12 @@ _tracemouse(MEVENT const *ep) return (my_buffer); } +NCURSES_EXPORT(char *) +_tracemouse(MEVENT const *ep) +{ + return _nc_tracemouse(SP, ep); +} + #else /* !TRACE */ -empty_module(_nc_lib_tracemouse) +EMPTY_MODULE(_nc_lib_tracemouse) #endif diff --git a/ncurses/trace/trace_buf.c b/ncurses/trace/trace_buf.c index 7bf91c674df3..6345acc035fc 100644 --- a/ncurses/trace/trace_buf.c +++ b/ncurses/trace/trace_buf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,7 +27,7 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey 1997 * + * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* * trace_buf.c - Tracing/Debugging buffers (attributes) @@ -35,7 +35,7 @@ #include -MODULE_ID("$Id: trace_buf.c,v 1.13 2007/04/21 22:50:08 tom Exp $") +MODULE_ID("$Id: trace_buf.c,v 1.14 2008/08/03 15:13:56 tom Exp $") #define MyList _nc_globals.tracebuf_ptr #define MySize _nc_globals.tracebuf_used @@ -48,29 +48,35 @@ _nc_trace_alloc(int bufnum, size_t want) if (bufnum >= 0) { if ((size_t) (bufnum + 1) > MySize) { size_t need = (bufnum + 1) * 2; - if ((MyList = typeRealloc(TRACEBUF, need, MyList)) == 0) - return (0); - while (need > MySize) - MyList[MySize++].text = 0; + if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) { + while (need > MySize) + MyList[MySize++].text = 0; + } } - if (MyList[bufnum].text == 0 - || want > MyList[bufnum].size) { - MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text); - if (MyList[bufnum].text != 0) - MyList[bufnum].size = want; + if (MyList != 0) { + if (MyList[bufnum].text == 0 + || want > MyList[bufnum].size) { + MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text); + if (MyList[bufnum].text != 0) + MyList[bufnum].size = want; + } + result = MyList[bufnum].text; } - - result = MyList[bufnum].text; } #if NO_LEAKS else { if (MySize) { - while (MySize--) { - if (MyList[MySize].text != 0) - free(MyList[MySize].text); + if (MyList) { + while (MySize--) { + if (MyList[MySize].text != 0) { + free(MyList[MySize].text); + } + } + free(MyList); + MyList = 0; } - free(MyList); + MySize = 0; } } #endif @@ -96,10 +102,13 @@ NCURSES_EXPORT(char *) _nc_trace_bufcat(int bufnum, const char *value) { char *buffer = _nc_trace_alloc(bufnum, 0); - size_t have = strlen(buffer); + if (buffer != 0) { + size_t have = strlen(buffer); - buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value)); - (void) strcpy(buffer + have, value); + buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value)); + if (buffer != 0) + (void) strcpy(buffer + have, value); + } return buffer; } diff --git a/ncurses/trace/trace_tries.c b/ncurses/trace/trace_tries.c index 0aa0b227d7d0..f813aba15825 100644 --- a/ncurses/trace/trace_tries.c +++ b/ncurses/trace/trace_tries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -35,7 +35,7 @@ #include -MODULE_ID("$Id: trace_tries.c,v 1.12 2007/04/21 21:55:41 tom Exp $") +MODULE_ID("$Id: trace_tries.c,v 1.13 2008/08/03 15:43:30 tom Exp $") #ifdef TRACE #define my_buffer _nc_globals.tracetry_buf @@ -74,5 +74,5 @@ _nc_trace_tries(TRIES * tree) } #else -empty_module(_nc_trace_tries) +EMPTY_MODULE(_nc_trace_tries) #endif diff --git a/ncurses/trace/varargs.c b/ncurses/trace/varargs.c index 5e63d21a2cc5..f4ee46710abb 100644 --- a/ncurses/trace/varargs.c +++ b/ncurses/trace/varargs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2001-2003,2007 Free Software Foundation, Inc. * + * Copyright (c) 2001-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -34,7 +34,7 @@ #include -MODULE_ID("$Id: varargs.c,v 1.6 2007/07/14 15:51:27 tom Exp $") +MODULE_ID("$Id: varargs.c,v 1.7 2008/08/03 15:42:49 tom Exp $") #ifdef TRACE @@ -180,5 +180,5 @@ _nc_varargs(const char *fmt, va_list ap) return (MyBuffer); } #else -empty_module(_nc_varargs) +EMPTY_MODULE(_nc_varargs) #endif diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c index 74081efe6442..bf9fb1472003 100644 --- a/ncurses/trace/visbuf.c +++ b/ncurses/trace/visbuf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2001-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 2001-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -42,10 +42,10 @@ #include #include -MODULE_ID("$Id: visbuf.c,v 1.26 2007/06/09 17:21:53 tom Exp $") +MODULE_ID("$Id: visbuf.c,v 1.32 2008/08/04 23:07:39 tom Exp $") -#define NormalLen(len) (unsigned) ((len + 1) * 4) -#define WideLen(len) (unsigned) ((len + 1) * 4 * MB_CUR_MAX) +#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4) +#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX) #ifdef TRACE static const char d_quote[] = StringOf(D_QUOTE); @@ -58,9 +58,9 @@ _nc_vischar(char *tp, unsigned c) { if (c == '"' || c == '\\') { *tp++ = '\\'; - *tp++ = c; + *tp++ = (char) c; } else if (is7bits(c) && (isgraph(c) || c == ' ')) { - *tp++ = c; + *tp++ = (char) c; } else if (c == '\n') { *tp++ = '\\'; *tp++ = 'n'; @@ -80,7 +80,7 @@ _nc_vischar(char *tp, unsigned c) } else if (is7bits(c) && iscntrl(UChar(c))) { *tp++ = '\\'; *tp++ = '^'; - *tp++ = '@' + c; + *tp++ = (char) ('@' + c); } else { sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c)); tp += strlen(tp); @@ -92,7 +92,7 @@ _nc_vischar(char *tp, unsigned c) static const char * _nc_visbuf2n(int bufnum, const char *buf, int len) { - char *vbuf; + const char *vbuf; char *tp; int c; @@ -102,23 +102,27 @@ _nc_visbuf2n(int bufnum, const char *buf, int len) return ("(cancelled)"); if (len < 0) - len = strlen(buf); + len = (int) strlen(buf); #ifdef TRACE - tp = vbuf = _nc_trace_buf(bufnum, NormalLen(len)); + vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len)); #else { static char *mybuf[4]; mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]); - tp = vbuf = mybuf[bufnum]; + vbuf = tp = mybuf[bufnum]; } #endif - *tp++ = D_QUOTE; - while ((--len >= 0) && (c = *buf++) != '\0') { - tp = _nc_vischar(tp, UChar(c)); + if (tp != 0) { + *tp++ = D_QUOTE; + while ((--len >= 0) && (c = *buf++) != '\0') { + tp = _nc_vischar(tp, UChar(c)); + } + *tp++ = D_QUOTE; + *tp++ = '\0'; + } else { + vbuf = ("(_nc_visbuf2n failed)"); } - *tp++ = D_QUOTE; - *tp++ = '\0'; return (vbuf); } @@ -159,7 +163,7 @@ _nc_wchstrlen(const cchar_t *s) static const char * _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len) { - char *vbuf; + const char *vbuf; char *tp; wchar_t c; @@ -167,31 +171,35 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len) return ("(null)"); if (len < 0) - len = wcslen(buf); + len = (int) wcslen(buf); #ifdef TRACE - tp = vbuf = _nc_trace_buf(bufnum, WideLen(len)); + vbuf = tp = _nc_trace_buf(bufnum, WideLen(len)); #else { static char *mybuf[2]; mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]); - tp = vbuf = mybuf[bufnum]; + vbuf = tp = mybuf[bufnum]; } #endif - *tp++ = D_QUOTE; - while ((--len >= 0) && (c = *buf++) != '\0') { - char temp[CCHARW_MAX + 80]; - int j = wctomb(temp, c), k; - if (j <= 0) { - sprintf(temp, "\\u%08X", (wint_t) c); - j = strlen(temp); - } - for (k = 0; k < j; ++k) { - tp = _nc_vischar(tp, UChar(temp[k])); + if (tp != 0) { + *tp++ = D_QUOTE; + while ((--len >= 0) && (c = *buf++) != '\0') { + char temp[CCHARW_MAX + 80]; + int j = wctomb(temp, c), k; + if (j <= 0) { + sprintf(temp, "\\u%08X", (unsigned) c); + j = (int) strlen(temp); + } + for (k = 0; k < j; ++k) { + tp = _nc_vischar(tp, UChar(temp[k])); + } } + *tp++ = D_QUOTE; + *tp++ = '\0'; + } else { + vbuf = ("(_nc_viswbuf2n failed)"); } - *tp++ = D_QUOTE; - *tp++ = '\0'; return (vbuf); } @@ -244,71 +252,73 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len) int first; const char *found; + if (result != 0) { #if USE_WIDEC_SUPPORT - if (len < 0) - len = _nc_wchstrlen(buf); + if (len < 0) + len = _nc_wchstrlen(buf); #endif /* USE_WIDEC_SUPPORT */ - /* - * Display one or more strings followed by attributes. - */ - first = 0; - while (first < len) { - attr_t attr = AttrOf(buf[first]); - int last = len - 1; - int j; + /* + * Display one or more strings followed by attributes. + */ + first = 0; + while (first < len) { + attr_t attr = AttrOf(buf[first]); + int last = len - 1; + int j; - for (j = first + 1; j < len; ++j) { - if (!SameAttrOf(buf[j], buf[first])) { - last = j - 1; - break; - } - } - - result = _nc_trace_bufcat(bufnum, l_brace); - result = _nc_trace_bufcat(bufnum, d_quote); - for (j = first; j <= last; ++j) { - found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j])); - if (found != 0) { - result = _nc_trace_bufcat(bufnum, found); - attr &= ~A_ALTCHARSET; - } else -#if USE_WIDEC_SUPPORT - if (!isWidecExt(buf[j])) { - PUTC_DATA; - - PUTC_INIT; - for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { - int k; - - PUTC_ch = buf[j].chars[PUTC_i]; - if (PUTC_ch == L'\0') - break; - PUTC_n = wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st); - if (PUTC_n <= 0) - break; - for (k = 0; k < PUTC_n; k++) { - char temp[80]; - _nc_vischar(temp, UChar(PUTC_buf[k])); - result = _nc_trace_bufcat(bufnum, temp); - } + for (j = first + 1; j < len; ++j) { + if (!SameAttrOf(buf[j], buf[first])) { + last = j - 1; + break; } } + + result = _nc_trace_bufcat(bufnum, l_brace); + result = _nc_trace_bufcat(bufnum, d_quote); + for (j = first; j <= last; ++j) { + found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j])); + if (found != 0) { + result = _nc_trace_bufcat(bufnum, found); + attr &= ~A_ALTCHARSET; + } else +#if USE_WIDEC_SUPPORT + if (!isWidecExt(buf[j])) { + PUTC_DATA; + + PUTC_INIT; + for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { + int k; + + PUTC_ch = buf[j].chars[PUTC_i]; + if (PUTC_ch == L'\0') + break; + PUTC_n = (int) wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st); + if (PUTC_n <= 0) + break; + for (k = 0; k < PUTC_n; k++) { + char temp[80]; + _nc_vischar(temp, UChar(PUTC_buf[k])); + result = _nc_trace_bufcat(bufnum, temp); + } + } + } #else - { - char temp[80]; - _nc_vischar(temp, UChar(buf[j])); - result = _nc_trace_bufcat(bufnum, temp); - } + { + char temp[80]; + _nc_vischar(temp, UChar(buf[j])); + result = _nc_trace_bufcat(bufnum, temp); + } #endif /* USE_WIDEC_SUPPORT */ + } + result = _nc_trace_bufcat(bufnum, d_quote); + if (attr != A_NORMAL) { + result = _nc_trace_bufcat(bufnum, " | "); + result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); + } + result = _nc_trace_bufcat(bufnum, r_brace); + first = last + 1; } - result = _nc_trace_bufcat(bufnum, d_quote); - if (attr != A_NORMAL) { - result = _nc_trace_bufcat(bufnum, " | "); - result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); - } - result = _nc_trace_bufcat(bufnum, r_brace); - first = last + 1; } return result; } diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c index 7d8979a4f51b..2c40997fb6b1 100644 --- a/ncurses/tty/hardscroll.c +++ b/ncurses/tty/hardscroll.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Alexander V Lukyanov 1997-1998 * ****************************************************************************/ /****************************************************************************** @@ -145,7 +147,7 @@ AUTHOR #include -MODULE_ID("$Id: hardscroll.c,v 1.41 2007/09/29 21:48:36 tom Exp $") +MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $") #if defined(SCROLLDEBUG) || defined(HASHDEBUG) @@ -270,13 +272,14 @@ _nc_linedump(void) char *buf = 0; size_t want = (screen_lines + 1) * 4; - buf = typeMalloc(char, want); + if ((buf = typeMalloc(char, want)) != 0) { - (void) strcpy(buf, "virt"); - for (n = 0; n < screen_lines; n++) - (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n)); - TR(TRACE_UPDATE | TRACE_MOVE, (buf)); - free(buf); + (void) strcpy(buf, "virt"); + for (n = 0; n < screen_lines; n++) + (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n)); + TR(TRACE_UPDATE | TRACE_MOVE, (buf)); + free(buf); + } } #endif /* defined(TRACE) || defined(SCROLLDEBUG) */ diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c index 19984c92333e..8e66fa3bf64c 100644 --- a/ncurses/tty/lib_mvcur.c +++ b/ncurses/tty/lib_mvcur.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -155,7 +155,7 @@ #include #include -MODULE_ID("$Id: lib_mvcur.c,v 1.110 2007/08/11 16:15:57 tom Exp $") +MODULE_ID("$Id: lib_mvcur.c,v 1.113 2008/08/16 19:30:58 tom Exp $") #define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */ #define BAUDRATE cur_term->_baudrate /* bits per second */ @@ -230,7 +230,7 @@ _nc_msec_cost(const char *const cap, int affcnt) } #if NCURSES_NO_PADDING - if (!(SP->_no_padding)) + if (!GetNoPadding(SP)) #endif cum_cost += number * 10; } else @@ -426,8 +426,11 @@ _nc_mvcur_wrap(void) mvcur(-1, -1, screen_lines - 1, 0); /* set cursor to normal mode */ - if (SP->_cursor != -1) + if (SP->_cursor != -1) { + int cursor = SP->_cursor; curs_set(1); + SP->_cursor = cursor; + } if (exit_ca_mode) { TPUTS_TRACE("exit_ca_mode"); @@ -628,7 +631,8 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int int i; for (i = 0; i < n; i++) - *check.s_tail++ = CharOf(WANT_CHAR(to_y, from_x + i)); + *check.s_tail++ = (char) CharOf(WANT_CHAR(to_y, + from_x + i)); *check.s_tail = '\0'; check.s_size -= n; lhcost += n * SP->_char_padding; diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c index 6d46081862fd..16d12edbbe3c 100644 --- a/ncurses/tty/lib_twait.c +++ b/ncurses/tty/lib_twait.c @@ -43,6 +43,10 @@ #include +#if defined __HAIKU__ && defined __BEOS__ +#undef __BEOS__ +#endif + #ifdef __BEOS__ #undef false #undef true @@ -62,7 +66,9 @@ # endif #endif -MODULE_ID("$Id: lib_twait.c,v 1.57 2008/05/03 21:35:57 tom Exp $") +#undef CUR + +MODULE_ID("$Id: lib_twait.c,v 1.59 2008/08/30 20:08:19 tom Exp $") static long _nc_gettime(TimeType * t0, bool first) diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index 16fc17d27236..6a3a0c8e9341 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -44,6 +44,10 @@ #include +#if defined __HAIKU__ && defined __BEOS__ +#undef __BEOS__ +#endif + #ifdef __BEOS__ #undef false #undef true @@ -74,7 +78,7 @@ #include #include -MODULE_ID("$Id: tty_update.c,v 1.245 2008/05/03 22:43:04 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.246 2008/08/30 20:08:19 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c index cf7240780883..91ceb32ff738 100644 --- a/ncurses/widechar/charable.c +++ b/ncurses/widechar/charable.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -32,13 +32,13 @@ #include -MODULE_ID("$Id: charable.c,v 1.4 2005/04/16 18:08:56 tom Exp $") +MODULE_ID("$Id: charable.c,v 1.5 2008/07/05 20:51:41 tom Exp $") NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch) { bool result; #if HAVE_WCTOB - result = (wctob((wint_t) ch) == ch); + result = (wctob((wint_t) ch) == (int) ch); #else result = (_nc_to_char(ch) >= 0); #endif diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c index 7985df2571db..6cf3129f2d18 100644 --- a/ncurses/widechar/lib_get_wch.c +++ b/ncurses/widechar/lib_get_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2002-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +40,7 @@ #include #include -MODULE_ID("$Id: lib_get_wch.c,v 1.14 2007/05/12 19:03:16 tom Exp $") +MODULE_ID("$Id: lib_get_wch.c,v 1.17 2008/08/16 19:22:55 tom Exp $") #if HAVE_MBTOWC && HAVE_MBLEN #define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0) @@ -60,6 +60,7 @@ make an error NCURSES_EXPORT(int) wget_wch(WINDOW *win, wint_t *result) { + SCREEN *sp; int code; char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */ int status; @@ -76,44 +77,52 @@ wget_wch(WINDOW *win, wint_t *result) * We can get a stream of single-byte characters and KEY_xxx codes from * _nc_wgetch(), while we want to return a wide character or KEY_xxx code. */ - for (;;) { - T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer))); - code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist *) 0)); - if (code == ERR) { - break; - } else if (code == KEY_CODE_YES) { - /* - * If we were processing an incomplete multibyte character, return - * an error since we have a KEY_xxx code which interrupts it. For - * some cases, we could improve this by writing a new version of - * lib_getch.c(!), but it is not clear whether the improvement - * would be worth the effort. - */ - if (count != 0) { - ungetch((int) value); - code = ERR; - } - break; - } else if (count + 1 >= sizeof(buffer)) { - ungetch((int) value); - code = ERR; - break; - } else { - buffer[count++] = UChar(value); - reset_mbytes(state); - status = count_mbytes(buffer, count, state); - if (status >= 0) { - reset_mbytes(state); - if (check_mbytes(wch, buffer, count, state) != status) { - code = ERR; /* the two calls should match */ - ungetch((int) value); - } - value = wch; + _nc_lock_global(curses); + sp = _nc_screen_of(win); + if (sp != 0) { + for (;;) { + T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer))); + code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist + *) 0)); + if (code == ERR) { break; + } else if (code == KEY_CODE_YES) { + /* + * If we were processing an incomplete multibyte character, + * return an error since we have a KEY_xxx code which + * interrupts it. For some cases, we could improve this by + * writing a new version of lib_getch.c(!), but it is not clear + * whether the improvement would be worth the effort. + */ + if (count != 0) { + _nc_ungetch(sp, (int) value); + code = ERR; + } + break; + } else if (count + 1 >= sizeof(buffer)) { + _nc_ungetch(sp, (int) value); + code = ERR; + break; + } else { + buffer[count++] = (char) UChar(value); + reset_mbytes(state); + status = count_mbytes(buffer, count, state); + if (status >= 0) { + reset_mbytes(state); + if (check_mbytes(wch, buffer, count, state) != status) { + code = ERR; /* the two calls should match */ + _nc_ungetch(sp, (int) value); + } + value = wch; + break; + } } } + } else { + code = ERR; } *result = value; + _nc_unlock_global(curses); T(("result %#lo", value)); returnCode(code); } diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c index bf39aa1a188b..baa70a5a53f9 100644 --- a/ncurses/widechar/lib_get_wstr.c +++ b/ncurses/widechar/lib_get_wstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2002-2003,2004 Free Software Foundation, Inc. * + * Copyright (c) 2002-2004,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +40,7 @@ #include #include -MODULE_ID("$Id: lib_get_wstr.c,v 1.8 2004/10/16 21:55:36 tom Exp $") +MODULE_ID("$Id: lib_get_wstr.c,v 1.10 2008/08/16 19:25:33 tom Exp $") static int wadd_wint(WINDOW *win, wint_t *src) @@ -48,7 +48,7 @@ wadd_wint(WINDOW *win, wint_t *src) cchar_t tmp; wchar_t wch[2]; - wch[0] = *src; + wch[0] = (wchar_t) (*src); wch[1] = 0; setcchar(&tmp, wch, A_NORMAL, 0, NULL); return wadd_wch(win, &tmp); @@ -86,6 +86,7 @@ WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed) NCURSES_EXPORT(int) wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) { + SCREEN *sp = _nc_screen_of(win); TTY buf; bool oldnl, oldecho, oldraw, oldcbreak; wint_t erasec; @@ -102,17 +103,17 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) _nc_get_tty_mode(&buf); - oldnl = SP->_nl; - oldecho = SP->_echo; - oldraw = SP->_raw; - oldcbreak = SP->_cbreak; + oldnl = sp->_nl; + oldecho = sp->_echo; + oldraw = sp->_raw; + oldcbreak = sp->_cbreak; nl(); noecho(); noraw(); cbreak(); - erasec = erasechar(); - killc = killchar(); + erasec = (wint_t) erasechar(); + killc = (wint_t) killchar(); getyx(win, y, x); @@ -209,10 +210,10 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) /* Restore with a single I/O call, to fix minor asymmetry between * raw/noraw, etc. */ - SP->_nl = oldnl; - SP->_echo = oldecho; - SP->_raw = oldraw; - SP->_cbreak = oldcbreak; + sp->_nl = oldnl; + sp->_echo = oldecho; + sp->_raw = oldraw; + sp->_cbreak = oldcbreak; (void) _nc_set_tty_mode(&buf); diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c index e24c9654d564..da65f219c266 100644 --- a/ncurses/widechar/lib_key_name.c +++ b/ncurses/widechar/lib_key_name.c @@ -35,7 +35,7 @@ #include -MODULE_ID("$Id: lib_key_name.c,v 1.2 2007/06/12 21:01:13 tom Exp $") +MODULE_ID("$Id: lib_key_name.c,v 1.3 2008/10/11 20:15:14 tom Exp $") NCURSES_EXPORT(NCURSES_CONST char *) key_name(wchar_t c) @@ -54,7 +54,7 @@ key_name(wchar_t c) my_wchars = wunctrl(&my_cchar); len = wcstombs(result, my_wchars, sizeof(result) - 1); if (isEILSEQ(len) || (len == 0)) { - return "UNKNOWN KEY"; + return 0; } result[len] = '\0'; diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c index b2dc7ff96f1b..bb2c4a084b15 100644 --- a/ncurses/widechar/lib_unget_wch.c +++ b/ncurses/widechar/lib_unget_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2002-2004,2007 Free Software Foundation, Inc. * + * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,7 +39,7 @@ #include -MODULE_ID("$Id: lib_unget_wch.c,v 1.9 2007/11/25 00:57:00 tom Exp $") +MODULE_ID("$Id: lib_unget_wch.c,v 1.10 2008/06/07 14:50:37 tom Exp $") /* * Wrapper for wcrtomb() which obtains the length needed for the given @@ -86,7 +86,7 @@ unget_wch(const wchar_t wch) wcrtomb(string, wch, &state); for (n = (int) (length - 1); n >= 0; --n) { - if (ungetch(string[n]) != OK) { + if (_nc_ungetch(SP, string[n]) != OK) { result = ERR; break; } diff --git a/panel/p_new.c b/panel/p_new.c index 3e48e3696735..2719316888e0 100644 --- a/panel/p_new.c +++ b/panel/p_new.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1995 * * and: Eric S. Raymond * + * and: Juergen Pfeifer 1997-1999 * + * and: Thomas E. Dickey 2000-on * ****************************************************************************/ /* p_new.c @@ -36,7 +38,7 @@ */ #include "panel.priv.h" -MODULE_ID("$Id: p_new.c,v 1.8 2005/02/19 16:41:03 tom Exp $") +MODULE_ID("$Id: p_new.c,v 1.10 2008/08/04 18:25:48 tom Exp $") #ifdef TRACE static char *stdscr_id; @@ -54,6 +56,9 @@ root_panel(void) { assert(stdscr && !_nc_bottom_panel && !_nc_top_panel); +#if NO_LEAKS + _nc_panelhook()->destroy = del_panel; +#endif _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL)); if (_nc_stdscr_pseudo_panel != 0) { diff --git a/panel/panel.priv.h b/panel/panel.priv.h index 98d741ff6ef0..4fb8144e1b77 100644 --- a/panel/panel.priv.h +++ b/panel/panel.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2001,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ -/* $Id: panel.priv.h,v 1.21 2005/11/26 15:27:00 tom Exp $ */ +/* $Id: panel.priv.h,v 1.22 2008/09/27 22:36:11 tom Exp $ */ #ifndef NCURSES_PANEL_PRIV_H #define NCURSES_PANEL_PRIV_H 1 @@ -39,14 +39,6 @@ #include #include -#if HAVE_LIBDMALLOC -# include /* Gray Watson's library */ -#endif - -#if HAVE_LIBDBMALLOC -# include /* Conor Cahill's library */ -#endif - #include "curses.priv.h" #include "panel.h" #include diff --git a/progs/MKtermsort.sh b/progs/MKtermsort.sh index 18b90ac265d8..2247f14ef2e8 100755 --- a/progs/MKtermsort.sh +++ b/progs/MKtermsort.sh @@ -1,10 +1,10 @@ #!/bin/sh -# $Id: MKtermsort.sh,v 1.9 2003/01/11 22:23:50 tom Exp $ +# $Id: MKtermsort.sh,v 1.10 2008/07/12 20:22:54 tom Exp $ # # MKtermsort.sh -- generate indirection vectors for the various sort methods # ############################################################################## -# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. # +# Copyright (c) 1998-2003,2008 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -56,7 +56,7 @@ echo " *"; echo " * Note: this file is generated using MKtermsort.sh, do not edit by hand."; echo " */"; -echo "static const int bool_terminfo_sort[] = {"; +echo "static const PredIdx bool_terminfo_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -65,7 +65,7 @@ $3 == "bool" {printf("%s\t%d\n", $2, i++);} echo "};"; echo ""; -echo "static const int num_terminfo_sort[] = {"; +echo "static const PredIdx num_terminfo_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -74,7 +74,7 @@ $3 == "num" {printf("%s\t%d\n", $2, i++);} echo "};"; echo ""; -echo "static const int str_terminfo_sort[] = {"; +echo "static const PredIdx str_terminfo_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -83,7 +83,7 @@ $3 == "str" {printf("%s\t%d\n", $2, i++);} echo "};"; echo ""; -echo "static const int bool_variable_sort[] = {"; +echo "static const PredIdx bool_variable_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -92,7 +92,7 @@ $3 == "bool" {printf("%s\t%d\n", $1, i++);} echo "};"; echo ""; -echo "static const int num_variable_sort[] = {"; +echo "static const PredIdx num_variable_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -101,7 +101,7 @@ $3 == "num" {printf("%s\t%d\n", $1, i++);} echo "};"; echo ""; -echo "static const int str_variable_sort[] = {"; +echo "static const PredIdx str_variable_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -110,7 +110,7 @@ $3 == "str" {printf("%s\t%d\n", $1, i++);} echo "};"; echo ""; -echo "static const int bool_termcap_sort[] = {"; +echo "static const PredIdx bool_termcap_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -119,7 +119,7 @@ $3 == "bool" {printf("%s\t%d\n", $4, i++);} echo "};"; echo ""; -echo "static const int num_termcap_sort[] = {"; +echo "static const PredIdx num_termcap_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} @@ -128,7 +128,7 @@ $3 == "num" {printf("%s\t%d\n", $4, i++);} echo "};"; echo ""; -echo "static const int str_termcap_sort[] = {"; +echo "static const PredIdx str_termcap_sort[] = {"; $AWK <$DATA ' BEGIN {i = 0;} /^#/ {next;} diff --git a/progs/Makefile.in b/progs/Makefile.in index 38f4e74fbb8e..886fd5be2465 100644 --- a/progs/Makefile.in +++ b/progs/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.77 2007/10/13 22:25:53 tom Exp $ +# $Id: Makefile.in,v 1.79 2008/09/07 13:58:55 tom Exp $ ############################################################################## # Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. # # # diff --git a/progs/dump_entry.c b/progs/dump_entry.c index eeee5dbb6a04..bd2422008bf7 100644 --- a/progs/dump_entry.c +++ b/progs/dump_entry.c @@ -29,7 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * - * and: Thomas E. Dickey 1996 on * + * and: Thomas E. Dickey 1996 on * ****************************************************************************/ #define __INTERNAL_CAPS_VISIBLE @@ -39,12 +39,14 @@ #include "termsort.c" /* this C file is generated */ #include /* so is this */ -MODULE_ID("$Id: dump_entry.c,v 1.82 2008/04/19 22:27:04 tom Exp $") +MODULE_ID("$Id: dump_entry.c,v 1.88 2008/08/04 12:36:12 tom Exp $") #define INDENT 8 #define DISCARD(string) string = ABSENT_STRING #define PRINTF (void) printf +#define OkIndex(index,array) ((int)(index) >= 0 && (int)(index) < (int) SIZEOF(array)) + typedef struct { char *text; size_t used; @@ -140,6 +142,11 @@ _nc_leaks_dump_entry(void) } #endif +#define NameTrans(check,result) \ + if (OkIndex(np->nte_index, check) \ + && check[np->nte_index]) \ + return (result[np->nte_index]) + NCURSES_CONST char * nametrans(const char *name) /* translate a capability name from termcap to terminfo */ @@ -149,18 +156,15 @@ nametrans(const char *name) if ((np = _nc_find_entry(name, _nc_get_hash_table(0))) != 0) switch (np->nte_type) { case BOOLEAN: - if (bool_from_termcap[np->nte_index]) - return (boolcodes[np->nte_index]); + NameTrans(bool_from_termcap, boolcodes); break; case NUMBER: - if (num_from_termcap[np->nte_index]) - return (numcodes[np->nte_index]); + NameTrans(num_from_termcap, numcodes); break; case STRING: - if (str_from_termcap[np->nte_index]) - return (strcodes[np->nte_index]); + NameTrans(str_from_termcap, strcodes); break; } @@ -293,9 +297,9 @@ static void set_obsolete_termcaps(TERMTYPE *tp); * If we configure with a different Caps file, the offsets into the arrays * will change. So we use an address expression. */ -#define BOOL_IDX(name) (&(name) - &(CUR Booleans[0])) -#define NUM_IDX(name) (&(name) - &(CUR Numbers[0])) -#define STR_IDX(name) (&(name) - &(CUR Strings[0])) +#define BOOL_IDX(name) (PredType) (&(name) - &(CUR Booleans[0])) +#define NUM_IDX(name) (PredType) (&(name) - &(CUR Numbers[0])) +#define STR_IDX(name) (PredType) (&(name) - &(CUR Strings[0])) static bool version_filter(PredType type, PredIdx idx) @@ -352,7 +356,7 @@ version_filter(PredType type, PredIdx idx) } break; -#define is_termcap(type) (idx < (int) sizeof(type##_from_termcap) && \ +#define is_termcap(type) (OkIndex(idx, type##_from_termcap) && \ type##_from_termcap[idx]) case V_BSD: /* BSD */ @@ -389,22 +393,22 @@ force_wrap(void) static void wrap_concat(const char *src) { - int need = strlen(src); - int want = strlen(separator) + need; + unsigned need = strlen(src); + unsigned want = strlen(separator) + need; if (column > INDENT - && column + want > width) { + && column + (int) want > width) { force_wrap(); } strcpy_DYN(&outbuf, src); strcpy_DYN(&outbuf, separator); - column += need; + column += (int) need; } #define IGNORE_SEP_TRAIL(first,last,sep_trail) \ if ((size_t)(last - first) > sizeof(sep_trail)-1 \ && !strncmp(first, sep_trail, sizeof(sep_trail)-1)) \ - first += sizeof(sep_trail)-2 + first += sizeof(sep_trail)-2 /* Returns the nominal length of the buffer assuming it is termcap format, * i.e., the continuation sequence is treated as a single character ":". @@ -448,7 +452,7 @@ static bool has_params(const char *src) { bool result = FALSE; - int len = strlen(src); + int len = (int) strlen(src); int n; bool ifthen = FALSE; bool params = FALSE; @@ -553,6 +557,7 @@ fmt_complex(char *src, int level) } #define SAME_CAP(n,cap) (&tterm->Strings[n] == &cap) +#define EXTRA_CAP 20 int fmt_entry(TERMTYPE *tterm, @@ -563,7 +568,7 @@ fmt_entry(TERMTYPE *tterm, int numbers) { PredIdx i, j; - char buffer[MAX_TERMINFO_LENGTH]; + char buffer[MAX_TERMINFO_LENGTH + EXTRA_CAP]; char *capability; NCURSES_CONST char *name; int predval, len; @@ -589,13 +594,14 @@ fmt_entry(TERMTYPE *tterm, } else { strcpy_DYN(&outbuf, tterm->term_names); strcpy_DYN(&outbuf, separator); - column = outbuf.used; + column = (int) outbuf.used; force_wrap(); } for_each_boolean(j, tterm) { i = BoolIndirect(j); name = ExtBoolname(tterm, i, bool_names); + assert(strlen(name) < sizeof(buffer) - EXTRA_CAP); if (!version_filter(BOOLEAN, i)) continue; @@ -619,6 +625,7 @@ fmt_entry(TERMTYPE *tterm, for_each_number(j, tterm) { i = NumIndirect(j); name = ExtNumname(tterm, i, num_names); + assert(strlen(name) < sizeof(buffer) - EXTRA_CAP); if (!version_filter(NUMBER, i)) continue; @@ -641,9 +648,9 @@ fmt_entry(TERMTYPE *tterm, if (column != INDENT) force_wrap(); - len += num_bools - + num_values * 2 - + strlen(tterm->term_names) + 1; + len += (int) (num_bools + + num_values * 2 + + strlen(tterm->term_names) + 1); if (len & 1) len++; @@ -664,6 +671,8 @@ fmt_entry(TERMTYPE *tterm, for_each_string(j, tterm) { i = StrIndirect(j); name = ExtStrname(tterm, i, str_names); + assert(strlen(name) < sizeof(buffer) - EXTRA_CAP); + capability = tterm->Strings[i]; if (!version_filter(STRING, i)) @@ -762,7 +771,7 @@ fmt_entry(TERMTYPE *tterm, } else { sprintf(buffer, "%s=%s", name, cv); } - len += strlen(capability) + 1; + len += (int) strlen(capability) + 1; WRAP_CONCAT; } else { char *src = _nc_tic_expand(capability, @@ -778,7 +787,7 @@ fmt_entry(TERMTYPE *tterm, } else { strcpy_DYN(&tmpbuf, src); } - len += strlen(capability) + 1; + len += (int) strlen(capability) + 1; wrap_concat(tmpbuf.text); outcount = TRUE; } @@ -787,7 +796,7 @@ fmt_entry(TERMTYPE *tterm, if (capability != tterm->Strings[i]) free(capability); } - len += num_strings * 2; + len += (int) (num_strings * 2); /* * This piece of code should be an effective inverse of the functions @@ -877,7 +886,7 @@ fmt_entry(TERMTYPE *tterm, static bool kill_string(TERMTYPE *tterm, char *cap) { - int n; + unsigned n; for (n = 0; n < NUM_STRINGS(tterm); ++n) { if (cap == tterm->Strings[n]) { tterm->Strings[n] = ABSENT_STRING; @@ -920,7 +929,7 @@ kill_labels(TERMTYPE *tterm, int target) sprintf(name, "lf%d", n); if ((cap = find_string(tterm, name)) != ABSENT_STRING && kill_string(tterm, cap)) { - target -= (strlen(cap) + 5); + target -= (int) (strlen(cap) + 5); ++result; if (target < 0) break; @@ -945,7 +954,7 @@ kill_fkeys(TERMTYPE *tterm, int target) sprintf(name, "kf%d", n); if ((cap = find_string(tterm, name)) != ABSENT_STRING && kill_string(tterm, cap)) { - target -= (strlen(cap) + 5); + target -= (int) (strlen(cap) + 5); ++result; if (target < 0) break; @@ -1053,7 +1062,7 @@ dump_entry(TERMTYPE *tterm, * Extended names are most likely function-key definitions. Drop * those first. */ - int n; + unsigned n; for (n = STRCOUNT; n < NUM_STRINGS(tterm); n++) { const char *name = ExtStrname(tterm, n, strnames); @@ -1145,7 +1154,7 @@ show_entry(void) trim_trailing(); (void) fputs(outbuf.text, stdout); putchar('\n'); - return outbuf.used; + return (int) outbuf.used; } void @@ -1244,15 +1253,15 @@ repair_acsc(TERMTYPE *tp) for (n = 0; acs_chars[n] != 0; n++) { source = UChar(acs_chars[n]); if ((target = (unsigned char) acs_chars[n + 1]) != 0) { - mapped[source] = target; + mapped[source] = (char) target; n++; } else { - extra = source; + extra = (char) source; } } for (n = m = 0; n < sizeof(mapped); n++) { if (mapped[n]) { - acs_chars[m++] = n; + acs_chars[m++] = (char) n; acs_chars[m++] = mapped[n]; } } diff --git a/progs/dump_entry.h b/progs/dump_entry.h index f802ecb783f7..b99a37a74f25 100644 --- a/progs/dump_entry.h +++ b/progs/dump_entry.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2002,2004 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -34,7 +34,7 @@ /* - * $Id: dump_entry.h,v 1.29 2006/08/19 21:11:14 tom Exp $ + * $Id: dump_entry.h,v 1.30 2008/07/12 20:23:03 tom Exp $ * * Dump control definitions and variables */ @@ -63,7 +63,7 @@ #define CMP_USE 3 /* comparison on use capabilities */ typedef unsigned PredType; -typedef int PredIdx; +typedef unsigned PredIdx; typedef int (*PredFunc)(PredType, PredIdx); extern NCURSES_CONST char *nametrans(const char *); diff --git a/progs/infocmp.c b/progs/infocmp.c index 8680df35d34f..84989ffc63d4 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.96 2008/01/19 21:08:07 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.103 2008/08/16 22:04:56 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -221,7 +221,7 @@ static bool useeq(ENTRY * e1, ENTRY * e2) /* are the use references in two entries equivalent? */ { - int i, j; + unsigned i, j; if (e1->nuses != e2->nuses) return (FALSE); @@ -271,7 +271,7 @@ static void print_uses(ENTRY * ep, FILE *fp) /* print an entry's use references */ { - int i; + unsigned i; if (!ep->nuses) fputs("NULL", fp); @@ -568,37 +568,41 @@ same_param(const char *table, const char *param, unsigned length) static char * lookup_params(const assoc * table, char *dst, char *src) { + char *result = 0; const char *ep = strtok(src, ";"); - const assoc *ap; - do { - bool found = FALSE; + if (ep != 0) { + const assoc *ap; - for (ap = table; ap->from; ap++) { - size_t tlen = strlen(ap->from); + do { + bool found = FALSE; - if (same_param(ap->from, ep, tlen)) { - (void) strcat(dst, ap->to); - found = TRUE; - break; + for (ap = table; ap->from; ap++) { + size_t tlen = strlen(ap->from); + + if (same_param(ap->from, ep, tlen)) { + (void) strcat(dst, ap->to); + found = TRUE; + break; + } } - } - if (!found) - (void) strcat(dst, ep); - (void) strcat(dst, ";"); - } while - ((ep = strtok((char *) 0, ";"))); + if (!found) + (void) strcat(dst, ep); + (void) strcat(dst, ";"); + } while + ((ep = strtok((char *) 0, ";"))); - dst[strlen(dst) - 1] = '\0'; + dst[strlen(dst) - 1] = '\0'; - return dst; + result = dst; + } + return result; } static void analyze_string(const char *name, const char *cap, TERMTYPE *tp) { - char buf[MAX_TERMINFO_LENGTH]; char buf2[MAX_TERMINFO_LENGTH]; const char *sp; const assoc *ap; @@ -608,7 +612,6 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) return; (void) printf("%s: ", name); - buf[0] = '\0'; for (sp = cap; *sp; sp++) { int i; int csi; @@ -656,7 +659,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) if (!expansion) { csi = skip_csi(sp); for (ap = std_caps; ap->from; ap++) { - size_t adj = csi ? 2 : 0; + size_t adj = (size_t) (csi ? 2 : 0); len = strlen(ap->from); if (csi && skip_csi(ap->from) != csi) @@ -665,7 +668,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) && strncmp(ap->from + adj, sp + csi, len - adj) == 0) { expansion = ap->to; len -= adj; - len += csi; + len += (size_t) csi; break; } } @@ -675,13 +678,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) if (!expansion && (csi = skip_csi(sp)) != 0 && (len = strspn(sp + csi, "0123456789;")) - && (next = csi + len) + && (len < sizeof(buf3)) + && (next = (size_t) csi + len) && ((sp[next] == 'h') || (sp[next] == 'l'))) { (void) strcpy(buf2, (sp[next] == 'h') ? "ECMA+" : "ECMA-"); (void) strncpy(buf3, sp + csi, len); buf3[len] = '\0'; - len += csi + 1; + len += (size_t) csi + 1; expansion = lookup_params(std_modes, buf2, buf3); } @@ -691,13 +695,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) && (csi = skip_csi(sp)) != 0 && sp[csi] == '?' && (len = strspn(sp + csi + 1, "0123456789;")) - && (next = csi + 1 + len) + && (len < sizeof(buf3)) + && (next = (size_t) csi + 1 + len) && ((sp[next] == 'h') || (sp[next] == 'l'))) { (void) strcpy(buf2, (sp[next] == 'h') ? "DEC+" : "DEC-"); (void) strncpy(buf3, sp + csi + 1, len); buf3[len] = '\0'; - len += csi + 2; + len += (size_t) csi + 2; expansion = lookup_params(private_modes, buf2, buf3); } @@ -706,13 +711,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) if (!expansion && (csi = skip_csi(sp)) != 0 && (len = strspn(sp + csi, "0123456789;")) != 0 - && (next = csi + len) + && (len < sizeof(buf3)) + && (next = (size_t) csi + len) && sp[next] == 'm') { (void) strcpy(buf2, "SGR:"); (void) strncpy(buf3, sp + csi, len); buf3[len] = '\0'; - len += csi + 1; + len += (size_t) csi + 1; expansion = lookup_params(ecma_highlights, buf2, buf3); } @@ -720,7 +726,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) if (!expansion && (csi = skip_csi(sp)) != 0 && sp[csi] == 'm') { - len = csi + 1; + len = (size_t) csi + 1; (void) strcpy(buf2, "SGR:"); strcat(buf2, ecma_highlights[0].to); expansion = buf2; @@ -738,7 +744,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) if (strncmp(buf2, sp + csi, len) == 0) expansion = "RSR"; } - len += csi; + len += (size_t) csi; } /* now check for home-down */ @@ -755,22 +761,21 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) expansion = "LL"; } } - len += csi; + len += (size_t) csi; } /* now look at the expansion we got, if any */ if (expansion) { - (void) sprintf(buf + strlen(buf), "{%s}", expansion); + printf("{%s}", expansion); sp += len - 1; - continue; } else { /* couldn't match anything */ buf2[0] = *sp; buf2[1] = '\0'; - (void) strcat(buf, TIC_EXPAND(buf2)); + fputs(TIC_EXPAND(buf2), stdout); } } - (void) printf("%s\n", buf); + putchar('\n'); } /*************************************************************************** @@ -789,6 +794,7 @@ file_comparison(int argc, char *argv[]) ENTRY *qp, *rp; int i, n; + memset(heads, 0, sizeof(heads)); dump_init((char *) 0, F_LITERAL, S_TERMINFO, 0, itrace, FALSE); for (n = 0; n < argc && n < MAXCOMPARE; n++) { @@ -1059,7 +1065,6 @@ static void dump_initializers(TERMTYPE *term) { unsigned n; - int size; const char *str = 0; printf("\nstatic char %s[] = \"%s\";\n\n", @@ -1138,10 +1143,6 @@ dump_initializers(TERMTYPE *term) } (void) printf("%s;\n", R_CURL); - size = (sizeof(TERMTYPE) - + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0])) - + (NUM_NUMBERS(term) * sizeof(term->Numbers[0]))); - (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL); for_each_string(n, term) { @@ -1283,8 +1284,8 @@ main(int argc, char *argv[]) _nc_progname = _nc_rootname(argv[0]); /* make sure we have enough space to add two terminal entries */ - myargv = typeCalloc(char *, argc + 3); - memcpy(myargv, argv, sizeof(char *) * argc); + myargv = typeCalloc(char *, (size_t) (argc + 3)); + memcpy(myargv, argv, (sizeof(char *) * (size_t) argc)); argv = myargv; while ((c = getopt(argc, diff --git a/progs/progs.priv.h b/progs/progs.priv.h index d445c3366591..f0ea4608227d 100644 --- a/progs/progs.priv.h +++ b/progs/progs.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -30,7 +30,7 @@ * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* - * $Id: progs.priv.h,v 1.33 2007/10/13 20:33:53 tom Exp $ + * $Id: progs.priv.h,v 1.34 2008/08/03 17:43:05 tom Exp $ * * progs.priv.h * @@ -90,6 +90,7 @@ # endif #endif +#include #include #if DECL_ERRNO diff --git a/progs/tic.c b/progs/tic.c index 84781026e51c..82bc3ea0d789 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * - * and: Thomas E. Dickey 1996 on * + * and: Thomas E. Dickey 1996 on * ****************************************************************************/ /* @@ -44,7 +44,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.133 2007/07/21 17:45:59 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.137 2008/09/13 16:59:24 tom Exp $") const char *_nc_progname = "tic"; @@ -85,9 +85,25 @@ x\ ] \ source-file\n"; +#if NO_LEAKS static void -cleanup(void) +free_namelist(char **src) { + if (src != 0) { + int n; + for (n = 0; src[n] != 0; ++n) + free(src[n]); + free(src); + } +} +#endif + +static void +cleanup(char **namelst GCC_UNUSED) +{ +#if NO_LEAKS + free_namelist(namelst); +#endif if (tmp_fp != 0) fclose(tmp_fp); if (to_remove != 0) { @@ -103,7 +119,7 @@ static void failed(const char *msg) { perror(msg); - cleanup(); + cleanup((char **) 0); ExitProgram(EXIT_FAILURE); } @@ -178,7 +194,7 @@ write_it(ENTRY * ep) d = result; t = s; while ((ch = *t++) != 0) { - *d++ = ch; + *d++ = (char) ch; if (ch == '\\') { *d++ = *t++; } else if ((ch == '%') @@ -192,7 +208,7 @@ write_it(ENTRY * ep) && value < 127 && isprint((int) value)) { *d++ = S_QUOTE; - *d++ = (int) value; + *d++ = (char) value; *d++ = S_QUOTE; t = (v + 1); } @@ -280,7 +296,7 @@ put_translate(int c) putchar(c); in_name = FALSE; } else if (c != '>') { - namebuf[used++] = c; + namebuf[used++] = (char) c; } else { /* ah! candidate name! */ char *up; NCURSES_CONST char *tp; @@ -353,19 +369,6 @@ open_input(const char *filename) return fp; } -#if NO_LEAKS -static void -free_namelist(char **src) -{ - if (src != 0) { - int n; - for (n = 0; src[n] != 0; ++n) - free(src[n]); - free(src); - } -} -#endif - /* Parse the "-e" option-value into a list of names */ static char ** make_namelist(char *src) @@ -558,7 +561,8 @@ main(int argc, char *argv[]) break; case 'V': puts(curses_version()); - return EXIT_SUCCESS; + cleanup(namelst); + ExitProgram(EXIT_SUCCESS); case 'c': check_only = TRUE; break; @@ -628,7 +632,7 @@ main(int argc, char *argv[]) if (namelst && (!infodump && !capdump)) { (void) fprintf(stderr, "Sorry, -e can't be used without -I or -C\n"); - cleanup(); + cleanup(namelst); ExitProgram(EXIT_FAILURE); } #endif /* HAVE_BIG_CORE */ @@ -671,7 +675,7 @@ main(int argc, char *argv[]) _nc_progname, _nc_progname, usage_string); - cleanup(); + cleanup(namelst); ExitProgram(EXIT_FAILURE); } } @@ -705,7 +709,7 @@ main(int argc, char *argv[]) /* do use resolution */ if (check_only || (!infodump && !capdump) || forceresolve) { if (!_nc_resolve_uses2(TRUE, literal) && !check_only) { - cleanup(); + cleanup(namelst); ExitProgram(EXIT_FAILURE); } } @@ -755,7 +759,7 @@ main(int argc, char *argv[]) dump_entry(&qp->tterm, suppress_untranslatable, limited, numbers, NULL); - for (j = 0; j < qp->nuses; j++) + for (j = 0; j < (int) qp->nuses; j++) dump_uses(qp->uses[j].name, !capdump); len = show_entry(); if (debug_level != 0 && !limited) @@ -799,10 +803,7 @@ main(int argc, char *argv[]) else fprintf(log_fp, "No entries written\n"); } -#if NO_LEAKS - free_namelist(namelst); -#endif - cleanup(); + cleanup(namelst); ExitProgram(EXIT_SUCCESS); } @@ -835,15 +836,19 @@ check_acs(TERMTYPE *tp) } mapped[UChar(p[0])] = p[1]; } + if (mapped[UChar('I')] && !mapped[UChar('i')]) { _nc_warning("acsc refers to 'I', which is probably an error"); } + for (p = boxes, q = missing; *p != '\0'; ++p) { if (!mapped[UChar(p[0])]) { *q++ = p[0]; } - *q = '\0'; } + *q = '\0'; + + assert(strlen(missing) <= strlen(boxes)); if (*missing != '\0' && strcmp(missing, boxes)) { _nc_warning("acsc is missing some line-drawing mapping: %s", missing); } @@ -887,10 +892,10 @@ check_colors(TERMTYPE *tp) } } -static int +static char keypad_final(const char *string) { - int result = '\0'; + char result = '\0'; if (VALID_STRING(string) && *string++ == '\033' @@ -918,6 +923,7 @@ keypad_index(const char *string) return result; } +#define MAX_KP 5 /* * Do a quick sanity-check for vt100-style keypads to see if the 5-key keypad * is mapped inconsistently. @@ -932,8 +938,8 @@ check_keypad(TERMTYPE *tp) VALID_STRING(key_b2) && VALID_STRING(key_c1) && VALID_STRING(key_c3)) { - char final[6]; - int list[5]; + char final[MAX_KP + 1]; + int list[MAX_KP]; int increase = 0; int j, k, kk; int last; @@ -947,6 +953,7 @@ check_keypad(TERMTYPE *tp) final[5] = '\0'; /* special case: legacy coding using 1,2,3,0,. on the bottom */ + assert(strlen(final) <= MAX_KP); if (!strcmp(final, "qsrpn")) return; @@ -957,22 +964,22 @@ check_keypad(TERMTYPE *tp) list[4] = keypad_index(key_c3); /* check that they're all vt100 keys */ - for (j = 0; j < 5; ++j) { + for (j = 0; j < MAX_KP; ++j) { if (list[j] < 0) { return; } } /* check if they're all in increasing order */ - for (j = 1; j < 5; ++j) { + for (j = 1; j < MAX_KP; ++j) { if (list[j] > list[j - 1]) { ++increase; } } - if (increase != 4) { + if (increase != (MAX_KP - 1)) { show[0] = '\0'; - for (j = 0, last = -1; j < 5; ++j) { + for (j = 0, last = -1; j < MAX_KP; ++j) { for (k = 0, kk = -1, test = 100; k < 5; ++k) { if (list[k] > last && list[k] < test) { @@ -981,6 +988,7 @@ check_keypad(TERMTYPE *tp) } } last = test; + assert(strlen(show) < (MAX_KP * 4)); switch (kk) { case 0: strcat(show, " ka1"); diff --git a/progs/toe.c b/progs/toe.c index 38b85cb362ed..8af6f371b77b 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -44,7 +44,7 @@ #include #endif -MODULE_ID("$Id: toe.c,v 1.48 2008/01/05 20:41:26 tom Exp $") +MODULE_ID("$Id: toe.c,v 1.51 2008/08/16 21:53:25 tom Exp $") #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) @@ -163,6 +163,7 @@ typelist(int eargc, char *eargv[], for (i = 0; i < eargc; i++) { #if USE_DATABASE if (_nc_is_dir_path(eargv[i])) { + char *cwd_buf = 0; DIR *termdir; DIRENT *subdir; @@ -177,20 +178,30 @@ typelist(int eargc, char *eargv[], while ((subdir = readdir(termdir)) != 0) { size_t len = NAMLEN(subdir); - char buf[PATH_MAX]; + size_t cwd_len = len + strlen(eargv[i]) + 3; char name_1[PATH_MAX]; DIR *entrydir; DIRENT *entry; + cwd_buf = typeRealloc(char, cwd_len, cwd_buf); + if (cwd_buf == 0) { + perror("realloc cwd_buf"); + continue; + } + strncpy(name_1, subdir->d_name, len)[len] = '\0'; if (isDotname(name_1)) continue; - (void) sprintf(buf, "%s/%s/", eargv[i], name_1); - if (chdir(buf) != 0) + (void) sprintf(cwd_buf, "%s/%.*s/", eargv[i], (int) len, name_1); + if (chdir(cwd_buf) != 0) continue; entrydir = opendir("."); + if (entrydir == 0) { + perror(cwd_buf); + continue; + } while ((entry = readdir(entrydir)) != 0) { char name_2[PATH_MAX]; TERMTYPE lterm; @@ -222,6 +233,8 @@ typelist(int eargc, char *eargv[], closedir(entrydir); } closedir(termdir); + if (cwd_buf != 0) + free(cwd_buf); } #if USE_HASHED_DB else { @@ -317,7 +330,7 @@ main(int argc, char *argv[]) bool invert_dependencies = FALSE; bool header = FALSE; char *report_file = 0; - int i; + unsigned i; int code; int this_opt, last_opt = '?'; int v_opt = 0; @@ -386,7 +399,7 @@ main(int argc, char *argv[]) for_entry_list(qp) { if (qp->nuses) { - int j; + unsigned j; (void) printf("%s:", _nc_first_name(qp->tterm.term_names)); for (j = 0; j < qp->nuses; j++) diff --git a/progs/tput.c b/progs/tput.c index 8745cc9977ad..022d4940c2a1 100644 --- a/progs/tput.c +++ b/progs/tput.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -42,11 +42,12 @@ #include #if !PURE_TERMINFO +#include #include #endif #include -MODULE_ID("$Id: tput.c,v 1.41 2007/10/13 20:34:16 tom Exp $") +MODULE_ID("$Id: tput.c,v 1.42 2008/07/13 11:05:12 tom Exp $") #define PUTS(s) fputs(s, stdout) #define PUTCHAR(c) putchar(c) diff --git a/progs/tset.c b/progs/tset.c index 3d6091224979..6a4d2d61c3de 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -89,9 +89,12 @@ char *ttyname(int fd); #endif -/* this is just to stifle a missing-prototype warning */ -#ifdef linux -# include +#if HAVE_SIZECHANGE +# if !defined(sun) || !TERMIOS +# if HAVE_SYS_IOCTL_H +# include +# endif +# endif #endif #if NEED_PTEM_H @@ -104,7 +107,27 @@ char *ttyname(int fd); #include #include -MODULE_ID("$Id: tset.c,v 1.70 2007/10/13 22:22:04 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.76 2008/10/11 19:26:19 tom Exp $") + +/* + * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, + * Solaris, IRIX) define TIOCGWINSZ and struct winsize. + */ +#ifdef TIOCGSIZE +# define IOCTL_GET_WINSIZE TIOCGSIZE +# define IOCTL_SET_WINSIZE TIOCSSIZE +# define STRUCT_WINSIZE struct ttysize +# define WINSIZE_ROWS(n) n.ts_lines +# define WINSIZE_COLS(n) n.ts_cols +#else +# ifdef TIOCGWINSZ +# define IOCTL_GET_WINSIZE TIOCGWINSZ +# define IOCTL_SET_WINSIZE TIOCSWINSZ +# define STRUCT_WINSIZE struct winsize +# define WINSIZE_ROWS(n) n.ws_row +# define WINSIZE_COLS(n) n.ws_col +# endif +#endif extern char **environ; @@ -168,7 +191,7 @@ failed(const char *msg) char temp[BUFSIZ]; unsigned len = strlen(_nc_progname) + 2; - if (len < sizeof(temp) - 12) { + if ((int) len < (int) sizeof(temp) - 12) { strcpy(temp, _nc_progname); strcat(temp, ": "); } else { @@ -440,11 +463,15 @@ add_mapping(const char *port, char *arg) mapp->conditional = ~mapp->conditional & (EQ | GT | LT); /* If user specified a port with an option flag, set it. */ - done:if (port) { - if (mapp->porttype) - badmopt:err("illegal -m option format: %s", copy); + done: + if (port) { + if (mapp->porttype) { + badmopt: + err("illegal -m option format: %s", copy); + } mapp->porttype = port; } + free(copy); #ifdef MAPDEBUG (void) printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY"); (void) printf("type: %s\n", mapp->type); @@ -780,16 +807,16 @@ reset_mode(void) #ifdef NLDLY | NLDLY #endif -#ifdef CRDLY +#ifdef CRDLY | CRDLY #endif -#ifdef TABDLY +#ifdef TABDLY | TABDLY #endif -#ifdef BSDLY +#ifdef BSDLY | BSDLY #endif -#ifdef VTDLY +#ifdef VTDLY | VTDLY #endif #ifdef FFDLY @@ -863,13 +890,13 @@ set_control_chars(void) { #ifdef TERMIOS if (DISABLED(mode.c_cc[VERASE]) || terasechar >= 0) - mode.c_cc[VERASE] = terasechar >= 0 ? terasechar : default_erase(); + mode.c_cc[VERASE] = (terasechar >= 0) ? terasechar : default_erase(); if (DISABLED(mode.c_cc[VINTR]) || intrchar >= 0) - mode.c_cc[VINTR] = intrchar >= 0 ? intrchar : CINTR; + mode.c_cc[VINTR] = (intrchar >= 0) ? intrchar : CINTR; if (DISABLED(mode.c_cc[VKILL]) || tkillchar >= 0) - mode.c_cc[VKILL] = tkillchar >= 0 ? tkillchar : CKILL; + mode.c_cc[VKILL] = (tkillchar >= 0) ? tkillchar : CKILL; #endif } @@ -1128,17 +1155,14 @@ usage(void) static char arg_to_char(void) { - return (optarg[0] == '^' && optarg[1] != '\0') - ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1])) - : optarg[0]; + return (char) ((optarg[0] == '^' && optarg[1] != '\0') + ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1])) + : optarg[0]); } int main(int argc, char **argv) { -#if defined(TIOCGWINSZ) && defined(TIOCSWINSZ) - struct winsize win; -#endif int ch, noinit, noset, quiet, Sflag, sflag, showterm; const char *p; const char *ttype; @@ -1218,9 +1242,9 @@ main(int argc, char **argv) can_restore = TRUE; original = oldmode = mode; #ifdef TERMIOS - ospeed = cfgetospeed(&mode); + ospeed = (NCURSES_OSPEED) cfgetospeed(&mode); #else - ospeed = mode.sg_ospeed; + ospeed = (NCURSES_OSPEED) mode.sg_ospeed; #endif if (!strcmp(_nc_progname, PROG_RESET)) { @@ -1234,15 +1258,17 @@ main(int argc, char **argv) tcolumns = columns; tlines = lines; -#if defined(TIOCGWINSZ) && defined(TIOCSWINSZ) +#if HAVE_SIZECHANGE if (opt_w) { - /* Set window size */ - (void) ioctl(STDERR_FILENO, TIOCGWINSZ, &win); - if (win.ws_row == 0 && win.ws_col == 0 && + STRUCT_WINSIZE win; + /* Set window size if not set already */ + (void) ioctl(STDERR_FILENO, IOCTL_GET_WINSIZE, &win); + if (WINSIZE_ROWS(win) == 0 && + WINSIZE_COLS(win) == 0 && tlines > 0 && tcolumns > 0) { - win.ws_row = tlines; - win.ws_col = tcolumns; - (void) ioctl(STDERR_FILENO, TIOCSWINSZ, &win); + WINSIZE_ROWS(win) = tlines; + WINSIZE_COLS(win) = tcolumns; + (void) ioctl(STDERR_FILENO, IOCTL_SET_WINSIZE, &win); } } #endif @@ -1293,7 +1319,7 @@ main(int argc, char **argv) * environmental variable SHELL ending in "csh". */ if ((var = getenv("SHELL")) != 0 - && ((len = strlen(leaf = _nc_basename(var))) >= 3) + && ((len = (int) strlen(leaf = _nc_basename(var))) >= 3) && !strcmp(leaf + len - 3, "csh")) p = "set noglob;\nsetenv TERM %s;\nunset noglob;\n"; else