diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-02 22:06:52 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-02 22:06:52 +0000 |
commit | d058cd399506bf5b5e3d43742d30cdabda06a8e7 (patch) | |
tree | b17920dcead3b7816d7cd0f534c3aba3ac561c07 /lib/libcurses/tinfo/lib_options.c | |
parent | 4170262b3e51f04453aa1a283175a95e4f9cf41b (diff) |
+ corrected conversion from terminfo rs2 to termcap rs (cf: 980704)
+ make conversion to termcap ug (underline glitch) more consistently applied.
+ modify read_termtype(), fixing 'toe', which could dump core when it
found an incomplete entry such as "dumb" because it did not
initialize its buffer for _nc_read_file_entry().
+ use explicit VALID_NUMERIC() checks in a few places that had been
overlooked, and add a check to ensure that init_tabs is nonzero,
to avoid divide-by-zero (reported by Todd C Miller).
Diffstat (limited to 'lib/libcurses/tinfo/lib_options.c')
-rw-r--r-- | lib/libcurses/tinfo/lib_options.c | 288 |
1 files changed, 141 insertions, 147 deletions
diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c index 5420fa1964f..9cef80e29fb 100644 --- a/lib/libcurses/tinfo/lib_options.c +++ b/lib/libcurses/tinfo/lib_options.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_options.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */ +/* $OpenBSD: lib_options.c,v 1.5 2000/01/02 22:06:51 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000 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 * @@ -33,7 +33,6 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ - /* ** lib_options.c ** @@ -43,168 +42,163 @@ #include <curses.priv.h> -#include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */ - /* cursor_visible,cursor_normal,cursor_invisible */ +#include <term.h> -MODULE_ID("$From: lib_options.c,v 1.36 1999/10/22 21:38:57 tom Exp $") +MODULE_ID("$From: lib_options.c,v 1.37 2000/01/01 16:59:50 tom Exp $") -int idlok(WINDOW *win, bool flag) +int +idlok(WINDOW *win, bool flag) { - T((T_CALLED("idlok(%p,%d)"), win, flag)); + T((T_CALLED("idlok(%p,%d)"), win, flag)); - if (win) { - _nc_idlok = win->_idlok = flag && (has_il() || change_scroll_region); - returnCode(OK); - } - else - returnCode(ERR); + if (win) { + _nc_idlok = win->_idlok = flag && (has_il() || change_scroll_region); + returnCode(OK); + } else + returnCode(ERR); } - -void idcok(WINDOW *win, bool flag) +void +idcok(WINDOW *win, bool flag) { - T((T_CALLED("idcok(%p,%d)"), win, flag)); + T((T_CALLED("idcok(%p,%d)"), win, flag)); - if (win) - _nc_idcok = win->_idcok = flag && has_ic(); + if (win) + _nc_idcok = win->_idcok = flag && has_ic(); - returnVoid; + returnVoid; } -int halfdelay(int t) +int +halfdelay(int t) { - T((T_CALLED("halfdelay(%d)"), t)); + T((T_CALLED("halfdelay(%d)"), t)); - if (t < 1 || t > 255) - returnCode(ERR); + if (t < 1 || t > 255) + returnCode(ERR); - cbreak(); - SP->_cbreak = t+1; - returnCode(OK); + cbreak(); + SP->_cbreak = t + 1; + returnCode(OK); } -int nodelay(WINDOW *win, bool flag) +int +nodelay(WINDOW *win, bool flag) { - T((T_CALLED("nodelay(%p,%d)"), win, flag)); + T((T_CALLED("nodelay(%p,%d)"), win, flag)); - if (win) { - if (flag == TRUE) + if (win) { + if (flag == TRUE) win->_delay = 0; - else win->_delay = -1; - returnCode(OK); - } else - returnCode(ERR); + win->_delay = -1; + returnCode(OK); + } else + returnCode(ERR); } -int notimeout(WINDOW *win, bool f) +int +notimeout(WINDOW *win, bool f) { - T((T_CALLED("notimout(%p,%d)"), win, f)); + T((T_CALLED("notimout(%p,%d)"), win, f)); - if (win) { - win->_notimeout = f; - returnCode(OK); - } - else - returnCode(ERR); + if (win) { + win->_notimeout = f; + returnCode(OK); + } else + returnCode(ERR); } -void wtimeout(WINDOW *win, int delay) +void +wtimeout(WINDOW *win, int delay) { - T((T_CALLED("wtimeout(%p,%d)"), win, delay)); + T((T_CALLED("wtimeout(%p,%d)"), win, delay)); - if (win) { - win->_delay = delay; - } + if (win) { + win->_delay = delay; + } } -int keypad(WINDOW *win, bool flag) +int +keypad(WINDOW *win, bool flag) { - T((T_CALLED("keypad(%p,%d)"), win, flag)); + T((T_CALLED("keypad(%p,%d)"), win, flag)); - if (win) { - win->_use_keypad = flag; - returnCode(_nc_keypad(flag)); - } - else - returnCode(ERR); + if (win) { + win->_use_keypad = flag; + returnCode(_nc_keypad(flag)); + } else + returnCode(ERR); } - -int meta(WINDOW *win GCC_UNUSED, bool flag) +int +meta(WINDOW *win GCC_UNUSED, bool flag) { - /* Ok, we stay relaxed and don't signal an error if win is NULL */ - T((T_CALLED("meta(%p,%d)"), win, flag)); - - 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); - } - returnCode(OK); + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + T((T_CALLED("meta(%p,%d)"), win, flag)); + + 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); + } + returnCode(OK); } /* curs_set() moved here to narrow the kernel interface */ -int curs_set(int vis) +int +curs_set(int vis) { -int cursor = SP->_cursor; - - T((T_CALLED("curs_set(%d)"), vis)); - - if (vis < 0 || vis > 2) - returnCode(ERR); - - if (vis == cursor) - returnCode(cursor); - - switch(vis) { - case 2: - if (cursor_visible) - { - TPUTS_TRACE("cursor_visible"); - putp(cursor_visible); - } - else - returnCode(ERR); - break; - case 1: - if (cursor_normal) - { - TPUTS_TRACE("cursor_normal"); - putp(cursor_normal); - } - else - returnCode(ERR); - break; - case 0: - if (cursor_invisible) - { - TPUTS_TRACE("cursor_invisible"); - putp(cursor_invisible); - } - else - returnCode(ERR); - break; - } - SP->_cursor = vis; - _nc_flush(); - - returnCode(cursor==-1 ? 1 : cursor); + int cursor = SP->_cursor; + + T((T_CALLED("curs_set(%d)"), vis)); + + if (vis < 0 || vis > 2) + returnCode(ERR); + + if (vis == cursor) + returnCode(cursor); + + switch (vis) { + case 2: + if (cursor_visible) { + TPUTS_TRACE("cursor_visible"); + putp(cursor_visible); + } else + returnCode(ERR); + break; + case 1: + if (cursor_normal) { + TPUTS_TRACE("cursor_normal"); + putp(cursor_normal); + } else + returnCode(ERR); + break; + case 0: + if (cursor_invisible) { + TPUTS_TRACE("cursor_invisible"); + putp(cursor_invisible); + } else + returnCode(ERR); + break; + } + SP->_cursor = vis; + _nc_flush(); + + returnCode(cursor == -1 ? 1 : cursor); } -int typeahead(int fd) +int +typeahead(int fd) { - T((T_CALLED("typeahead(%d)"), fd)); - SP->_checkfd = fd; - returnCode(OK); + T((T_CALLED("typeahead(%d)"), fd)); + SP->_checkfd = fd; + returnCode(OK); } /* @@ -215,18 +209,20 @@ int typeahead(int fd) */ #ifdef NCURSES_EXT_FUNCS -static int has_key_internal(int keycode, struct tries *tp) +static int +has_key_internal(int keycode, struct tries *tp) { if (tp == 0) - return(FALSE); + return (FALSE); else if (tp->value == keycode) - return(TRUE); + return (TRUE); else - return(has_key_internal(keycode, tp->child) - || has_key_internal(keycode, tp->sibling)); + return (has_key_internal(keycode, tp->child) + || has_key_internal(keycode, tp->sibling)); } -int has_key(int keycode) +int +has_key(int keycode) { T((T_CALLED("has_key(%d)"), keycode)); returnCode(has_key_internal(keycode, SP->_keytry)); @@ -240,24 +236,22 @@ int has_key(int keycode) * flush, then the next wgetch may get the escape sequence that corresponds to * the terminal state _before_ switching modes. */ -int _nc_keypad(bool flag) +int +_nc_keypad(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(); - } - - if (flag && !SP->_tried) { - _nc_init_keytry(); - SP->_tried = TRUE; - } - return(OK); + 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(); + } + + if (flag && !SP->_tried) { + _nc_init_keytry(); + SP->_tried = TRUE; + } + return (OK); } |